From ccd3c00ff5a6770db3bbcfe13dd5597131b6faf9 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Mon, 19 Aug 2024 00:04:43 +0530 Subject: [PATCH] chore: remove accidentally committed remapped sources --- .../xyz/devcomp/elytralock/ElytraLock.java | 60 ------------------- .../elytralock/config/ConfigHandler.java | 37 ------------ .../elytralock/config/ConfigModel.java | 11 ---- .../devcomp/elytralock/config/ConfigUtil.java | 9 --- .../events/ClientTickEndHandler.java | 33 ---------- .../elytralock/events/HudRenderHandler.java | 24 -------- .../integrations/ModMenuIntegration.java | 19 ------ .../ClientPlayerInteractionManagerMixin.java | 38 ------------ .../elytralock/mixin/PlayerEntityMixin.java | 33 ---------- .../elytralock/util/RunOnceOnToggle.java | 28 --------- 10 files changed, 292 deletions(-) delete mode 100644 remappedSrc/xyz/devcomp/elytralock/ElytraLock.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/config/ConfigHandler.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/config/ConfigModel.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/config/ConfigUtil.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/events/ClientTickEndHandler.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/events/HudRenderHandler.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/integrations/ModMenuIntegration.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/mixin/ClientPlayerInteractionManagerMixin.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/mixin/PlayerEntityMixin.java delete mode 100644 remappedSrc/xyz/devcomp/elytralock/util/RunOnceOnToggle.java diff --git a/remappedSrc/xyz/devcomp/elytralock/ElytraLock.java b/remappedSrc/xyz/devcomp/elytralock/ElytraLock.java deleted file mode 100644 index 3be9cd0..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/ElytraLock.java +++ /dev/null @@ -1,60 +0,0 @@ -package xyz.devcomp.elytralock; - -import xyz.devcomp.elytralock.config.ConfigHandler; -import xyz.devcomp.elytralock.config.ConfigUtil; -import xyz.devcomp.elytralock.events.ClientTickEndHandler; -import xyz.devcomp.elytralock.events.HudRenderHandler; - -import org.lwjgl.glfw.GLFW; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; -import net.fabricmc.loader.api.FabricLoader; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; - -public class ElytraLock implements ClientModInitializer { - public static final Logger LOGGER = LoggerFactory.getLogger("Elytra Lock"); - public static final FabricLoader LOADER = FabricLoader.getInstance(); - private static KeyBinding lockKeybind; - private static boolean locked = false; - public static MinecraftClient client; - - @Override - public void onInitializeClient() { - LOGGER.info("ElytraLock initializing!"); - - lockKeybind = KeyBindingHelper.registerKeyBinding( - new KeyBinding("key.elytralock.lock", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_J, "category.elytralock")); - LOGGER.info("Registered keybind for locking elytra"); - - client = MinecraftClient.getInstance(); - - if (ConfigUtil.isYaclLoaded()) { - LOGGER.info("YACL_v3 is loaded, loading elytra toggle"); - locked = new ConfigHandler().getInstance().toggle; - } else { - LOGGER.warn("YACL_v3 is not loaded, not persisting elytra toggle"); - } - - HudRenderCallback.EVENT.register(new HudRenderHandler()); - ClientTickEvents.END_CLIENT_TICK.register(new ClientTickEndHandler()); - - LOGGER.info("Registered HUD_RENDER & END_CLIENT_TICK events successfully!"); - } - - public static boolean isLocked() { - if (lockKeybind.wasPressed()) { - locked = !locked; - } - - return locked; - } -} \ No newline at end of file diff --git a/remappedSrc/xyz/devcomp/elytralock/config/ConfigHandler.java b/remappedSrc/xyz/devcomp/elytralock/config/ConfigHandler.java deleted file mode 100644 index a504338..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/config/ConfigHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package xyz.devcomp.elytralock.config; - -import xyz.devcomp.elytralock.ElytraLock; - -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.util.Identifier; - -import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; -import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder; - -public class ConfigHandler { - private boolean isLoaded = false; - public static final ConfigClassHandler HANDLER = ConfigClassHandler.createBuilder(ConfigModel.class) - .id(new Identifier("elytralock", "config")) - .serializer(config -> GsonConfigSerializerBuilder.create(config) - .setPath(ElytraLock.LOADER.getConfigDir().resolve("elytra-lock.json")) - .setJson5(true) - .build()) - .build(); - - private void loadConfig() { - if (!this.isLoaded) { - ElytraLock.LOGGER.info("ElytraLock config not loaded, loading"); - this.isLoaded = HANDLER.load(); - } - } - - public Screen showGui(Screen parent) { - this.loadConfig(); - return HANDLER.generateGui().generateScreen(parent); - } - - public ConfigModel getInstance() { - this.loadConfig(); - return HANDLER.instance(); - } -} \ No newline at end of file diff --git a/remappedSrc/xyz/devcomp/elytralock/config/ConfigModel.java b/remappedSrc/xyz/devcomp/elytralock/config/ConfigModel.java deleted file mode 100644 index b2640a1..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/config/ConfigModel.java +++ /dev/null @@ -1,11 +0,0 @@ -package xyz.devcomp.elytralock.config; - -import dev.isxander.yacl3.config.v2.api.SerialEntry; -import dev.isxander.yacl3.config.v2.api.autogen.*; - -public class ConfigModel { - @SerialEntry(comment = "The status of the lock toggle") - @AutoGen(category = "elytralock") - @TickBox - public boolean toggle = false; -} \ No newline at end of file diff --git a/remappedSrc/xyz/devcomp/elytralock/config/ConfigUtil.java b/remappedSrc/xyz/devcomp/elytralock/config/ConfigUtil.java deleted file mode 100644 index de42b2f..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/config/ConfigUtil.java +++ /dev/null @@ -1,9 +0,0 @@ -package xyz.devcomp.elytralock.config; - -import xyz.devcomp.elytralock.ElytraLock; - -public class ConfigUtil { - public static boolean isYaclLoaded() { - return ElytraLock.LOADER.isModLoaded("yet_another_config_lib_v3"); - } -} diff --git a/remappedSrc/xyz/devcomp/elytralock/events/ClientTickEndHandler.java b/remappedSrc/xyz/devcomp/elytralock/events/ClientTickEndHandler.java deleted file mode 100644 index 870b3ec..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/events/ClientTickEndHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.devcomp.elytralock.events; - -import java.util.function.Consumer; - -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents.EndTick; -import net.minecraft.client.MinecraftClient; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import xyz.devcomp.elytralock.ElytraLock; -import xyz.devcomp.elytralock.util.RunOnceOnToggle; - -public class ClientTickEndHandler implements EndTick { - private static RunOnceOnToggle impl = new RunOnceOnToggle( - new Consumer() { - public void accept(MinecraftClient client) { - PlayerInventory inventory = client.player.getInventory(); - - // 0 -> boots - // 1 -> leggings - // 2 -> chestplate - // 3 -> helmet - ItemStack chestArmor = inventory.armor.get(2); - if (chestArmor.isOf(Items.ELYTRA)) { - ElytraLock.LOGGER.info("Detected player wearing elytra even though it's locked"); - } - } - }); - - public void onEndTick(MinecraftClient client) { - impl.run(client); - } -} diff --git a/remappedSrc/xyz/devcomp/elytralock/events/HudRenderHandler.java b/remappedSrc/xyz/devcomp/elytralock/events/HudRenderHandler.java deleted file mode 100644 index ea1b94f..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/events/HudRenderHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package xyz.devcomp.elytralock.events; - -import xyz.devcomp.elytralock.ElytraLock; - -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.Window; -import net.minecraft.util.Identifier; - -public class HudRenderHandler implements HudRenderCallback { - public static final int WIDTH = 16; - public static final int HEIGHT = 16; - - public void onHudRender(DrawContext context, float delta) { - // FIXME: Perhaps don't check whether the elytra is locked on every frame - Identifier icon = new Identifier("elytra-lock", - "textures/gui/" + (ElytraLock.isLocked() ? "locked" : "unlocked") + ".png"); - - Window window = ElytraLock.client.getWindow(); - int width = window.getScaledWidth(), height = window.getScaledHeight(); - - context.drawTexture(icon, (width / 2) + 95, height - HEIGHT - 3, 0, 0, WIDTH, HEIGHT, WIDTH, HEIGHT); - } -} \ No newline at end of file diff --git a/remappedSrc/xyz/devcomp/elytralock/integrations/ModMenuIntegration.java b/remappedSrc/xyz/devcomp/elytralock/integrations/ModMenuIntegration.java deleted file mode 100644 index 9206e6e..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/integrations/ModMenuIntegration.java +++ /dev/null @@ -1,19 +0,0 @@ -package xyz.devcomp.elytralock.integrations; - -import xyz.devcomp.elytralock.ElytraLock; -import xyz.devcomp.elytralock.config.ConfigHandler; -import xyz.devcomp.elytralock.config.ConfigUtil; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; - -public class ModMenuIntegration implements ModMenuApi { - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return (parent) -> { - if (!ConfigUtil.isYaclLoaded()) - return parent; - return ElytraLock.config.showGui(parent); - }; - } -} diff --git a/remappedSrc/xyz/devcomp/elytralock/mixin/ClientPlayerInteractionManagerMixin.java b/remappedSrc/xyz/devcomp/elytralock/mixin/ClientPlayerInteractionManagerMixin.java deleted file mode 100644 index 591b3b0..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/mixin/ClientPlayerInteractionManagerMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -package xyz.devcomp.elytralock.mixin; - -import xyz.devcomp.elytralock.ElytraLock; - -import org.apache.commons.lang3.mutable.MutableObject; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.llamalad7.mixinextras.sugar.Local; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.network.ClientPlayerInteractionManager; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.text.Text; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; - -@Environment(EnvType.CLIENT) -@Mixin(ClientPlayerInteractionManager.class) -public class ClientPlayerInteractionManagerMixin { - @Inject(method = "interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;", at = @At(value = "INVOKE", target = "net/minecraft/client/network/ClientPlayerInteractionManager.sendSequencedPacket (Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V"), cancellable = true) - private void skipElytra(PlayerEntity player, Hand hand, CallbackInfoReturnable info, @Local MutableObject mutableObject) { - ItemStack itemStack = player.getStackInHand(hand); - if (itemStack.isOf(Items.ELYTRA) && ElytraLock.isLocked()) { - ElytraLock.LOGGER.info("Skipping sending PlayerInteractItemC2SPacket for locked elytra"); - ElytraLock.client.inGameHud.getChatHud().addMessage(Text.translatable("elytralock.chat.lockedMessage")); - - mutableObject.setValue(ActionResult.FAIL); - info.setReturnValue((ActionResult) mutableObject.getValue()); - } - } -} diff --git a/remappedSrc/xyz/devcomp/elytralock/mixin/PlayerEntityMixin.java b/remappedSrc/xyz/devcomp/elytralock/mixin/PlayerEntityMixin.java deleted file mode 100644 index 39f8975..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/mixin/PlayerEntityMixin.java +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.devcomp.elytralock.mixin; - -import java.util.function.Consumer; - -import xyz.devcomp.elytralock.ElytraLock; -import xyz.devcomp.elytralock.util.RunOnceOnToggle; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.entity.player.PlayerEntity; - -// TODO: In the future, make fall flying prevention and elytra lock separate -// Fall flying prevention should be subset of elytra locking which should be -// individually toggleable - -@Mixin(PlayerEntity.class) -public class PlayerEntityMixin { - private static RunOnceOnToggle logOnce = new RunOnceOnToggle( - new Consumer() { - public void accept(String msg) { - ElytraLock.LOGGER.info(msg); - } - }); - - @Inject(method = "checkFallFlying()Z", at = @At("HEAD"), cancellable = true) - private void preventFallFlying(CallbackInfoReturnable info) { - if (logOnce.run("Elytra is locked, so preventing fall flying")) - info.setReturnValue(false); - } -} \ No newline at end of file diff --git a/remappedSrc/xyz/devcomp/elytralock/util/RunOnceOnToggle.java b/remappedSrc/xyz/devcomp/elytralock/util/RunOnceOnToggle.java deleted file mode 100644 index 8aa004b..0000000 --- a/remappedSrc/xyz/devcomp/elytralock/util/RunOnceOnToggle.java +++ /dev/null @@ -1,28 +0,0 @@ -package xyz.devcomp.elytralock.util; - -import java.util.function.Consumer; - -import xyz.devcomp.elytralock.ElytraLock; - -public class RunOnceOnToggle { - private static boolean hasRun = false; - private Consumer toRun; - - public RunOnceOnToggle(Consumer toRun) { - this.toRun = toRun; - } - - public boolean run(T param) { - boolean isLocked = ElytraLock.isLocked(); - if (isLocked) { - if (!hasRun) { - toRun.accept(param); - hasRun = true; - } - } else { - hasRun = false; - } - - return isLocked; - } -}