chore: remove accidentally committed remapped sources

This commit is contained in:
Erica Marigold 2024-08-19 00:04:43 +05:30
parent 4f4ab374a8
commit ccd3c00ff5
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1
10 changed files with 0 additions and 292 deletions

View file

@ -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;
}
}

View file

@ -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<ConfigModel> 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();
}
}

View file

@ -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;
}

View file

@ -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");
}
}

View file

@ -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<MinecraftClient> impl = new RunOnceOnToggle<MinecraftClient>(
new Consumer<MinecraftClient>() {
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);
}
}

View file

@ -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);
}
}

View file

@ -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);
};
}
}

View file

@ -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<ActionResult> info, @Local MutableObject<ActionResult> 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());
}
}
}

View file

@ -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<String> logOnce = new RunOnceOnToggle<String>(
new Consumer<String>() {
public void accept(String msg) {
ElytraLock.LOGGER.info(msg);
}
});
@Inject(method = "checkFallFlying()Z", at = @At("HEAD"), cancellable = true)
private void preventFallFlying(CallbackInfoReturnable<Boolean> info) {
if (logOnce.run("Elytra is locked, so preventing fall flying"))
info.setReturnValue(false);
}
}

View file

@ -1,28 +0,0 @@
package xyz.devcomp.elytralock.util;
import java.util.function.Consumer;
import xyz.devcomp.elytralock.ElytraLock;
public class RunOnceOnToggle<T> {
private static boolean hasRun = false;
private Consumer<T> toRun;
public RunOnceOnToggle(Consumer<T> 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;
}
}