From b146c62e2cd3f3a91714c803f9019adac8eeccb9 Mon Sep 17 00:00:00 2001 From: xTracr Date: Fri, 1 Mar 2024 19:27:30 +0800 Subject: [PATCH] Removed commands --- .../com/xtracr/realcamera/RealCameraCore.java | 10 +-- .../realcamera/command/ClientCommand.java | 61 ------------------- .../realcamera/util/VertexRecorder.java | 6 ++ .../assets/realcamera/lang/en_us.json | 4 -- .../assets/realcamera/lang/zh_cn.json | 4 -- .../xtracr/realcamera/RealCameraFabric.java | 4 -- .../com/xtracr/realcamera/EventHandler.java | 8 --- .../xtracr/realcamera/RealCameraForge.java | 1 - 8 files changed, 11 insertions(+), 87 deletions(-) delete mode 100644 common/src/main/java/com/xtracr/realcamera/command/ClientCommand.java diff --git a/common/src/main/java/com/xtracr/realcamera/RealCameraCore.java b/common/src/main/java/com/xtracr/realcamera/RealCameraCore.java index 59a90c0..f60ab2c 100644 --- a/common/src/main/java/com/xtracr/realcamera/RealCameraCore.java +++ b/common/src/main/java/com/xtracr/realcamera/RealCameraCore.java @@ -34,7 +34,7 @@ import java.util.function.BiFunction; public class RealCameraCore { - private static VertexRecorder recorder = new VertexRecorder(); + private static final VertexRecorder recorder = new VertexRecorder(); private static String status = "Successful"; private static boolean renderingPlayer = false; private static boolean active = false; @@ -123,9 +123,9 @@ public static void computeCamera(MinecraftClient client, float tickDelta) { if (config().isClassic()) return; // GameRenderer.renderWorld + recorder.clear(); MatrixStack matrixStack = new MatrixStack(); - recorder = new VertexRecorder(); - virtualRender(client, tickDelta, matrixStack, recorder); + virtualRender(client, tickDelta, matrixStack); recorder.buildLastRecord(); // ModelPart$Cuboid.renderCuboid @@ -168,7 +168,7 @@ private static ModConfig config() { return ConfigFile.modConfig; } - private static void virtualRender(MinecraftClient client, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider consumers) { + private static void virtualRender(MinecraftClient client, float tickDelta, MatrixStack matrixStack) { ClientPlayerEntity player = client.player; // WorldRenderer.render if (player.age == 0) { @@ -184,7 +184,7 @@ private static void virtualRender(MinecraftClient client, float tickDelta, Matri EntityRenderDispatcher dispatcher = client.getEntityRenderDispatcher(); dispatcher.configure(client.world, client.gameRenderer.getCamera(), player); if (config().binding.experimental) dispatcher.render(player, renderOffset.getX(), renderOffset.getY(), renderOffset.getZ(), - MathHelper.lerp(tickDelta, player.prevYaw, player.getYaw()), tickDelta, matrixStack, consumers, dispatcher.getLight(player, tickDelta)); + MathHelper.lerp(tickDelta, player.prevYaw, player.getYaw()), tickDelta, matrixStack, recorder, dispatcher.getLight(player, tickDelta)); matrixStack.pop(); // EntityRenderDispatcher.render if (config().compatPhysicsMod()) diff --git a/common/src/main/java/com/xtracr/realcamera/command/ClientCommand.java b/common/src/main/java/com/xtracr/realcamera/command/ClientCommand.java deleted file mode 100644 index 8bc4a47..0000000 --- a/common/src/main/java/com/xtracr/realcamera/command/ClientCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.xtracr.realcamera.command; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.builder.RequiredArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import com.xtracr.realcamera.RealCamera; -import com.xtracr.realcamera.config.ConfigFile; -import com.xtracr.realcamera.config.ModConfig; -import net.minecraft.client.MinecraftClient; -import net.minecraft.command.CommandRegistryAccess; -import net.minecraft.command.CommandSource; -import net.minecraft.text.Text; - -public class ClientCommand{ - private static final String KEY_COMMAND = "message." + RealCamera.FULL_ID + ".command_"; - private static final ModConfig config = ConfigFile.modConfig; - - public void register(CommandDispatcher dispatcher, CommandRegistryAccess access) { - final LiteralArgumentBuilder builder = literal(RealCamera.MODID); - builder.then(literal("config") - .then(literal("delete") - .then(argument("name", StringArgumentType.string()).executes(this::deleteList))) - .then(literal("listAll").executes(this::listAll))); - - dispatcher.register(builder); - } - - private int deleteList(CommandContext context) { - final String name = StringArgumentType.getString(context, "name"); - if (!config.binding.targetMap.containsKey(name)) { - printGameMessage(Text.translatable(KEY_COMMAND + "delete_failure", name)); - return 0; - } - config.binding.targetMap.remove(name); - ConfigFile.save(); - printGameMessage(Text.translatable(KEY_COMMAND + "delete_success", name)); - return 1; - } - - private int listAll(CommandContext context) { - StringBuffer buffer = new StringBuffer(); - config.binding.targetMap.forEach((name, target) -> buffer.append("\n'").append(name).append("' -> ").append(target)); - printGameMessage(Text.translatable(KEY_COMMAND + "listAll", config.binding.targetMap.size(), buffer.toString())); - return 1; - } - - private static void printGameMessage(Text text) { - MinecraftClient.getInstance().getMessageHandler().onGameMessage(text, false); - } - - private RequiredArgumentBuilder argument(final String name, final ArgumentType type) { - return RequiredArgumentBuilder.argument(name, type); - } - - private LiteralArgumentBuilder literal(final String name) { - return LiteralArgumentBuilder.literal(name); - } -} diff --git a/common/src/main/java/com/xtracr/realcamera/util/VertexRecorder.java b/common/src/main/java/com/xtracr/realcamera/util/VertexRecorder.java index 49bb8cb..e958844 100644 --- a/common/src/main/java/com/xtracr/realcamera/util/VertexRecorder.java +++ b/common/src/main/java/com/xtracr/realcamera/util/VertexRecorder.java @@ -24,6 +24,12 @@ public class VertexRecorder implements VertexConsumerProvider { protected BuiltRecord currentRecord; private VertexRecord lastRecord; + public void clear() { + records.clear(); + currentRecord = null; + lastRecord = null; + } + public int quadCount() { if (currentRecord == null) return 0; return currentRecord.quadCount; diff --git a/common/src/main/resources/assets/realcamera/lang/en_us.json b/common/src/main/resources/assets/realcamera/lang/en_us.json index c06f0b9..6b27f62 100644 --- a/common/src/main/resources/assets/realcamera/lang/en_us.json +++ b/common/src/main/resources/assets/realcamera/lang/en_us.json @@ -96,10 +96,6 @@ "config.tooltip.xtracr_realcamera.autoBind": "Automatically searches through saved lists based on the current player model texture", "config.tooltip.xtracr_realcamera.depth": "Planes where all vertex-to-screen distances are less than this value will not be rendered", - "message.xtracr_realcamera.command_delete_failure": "Failed to find '%s'", - "message.xtracr_realcamera.command_delete_success": "Successfully deleted '%s'", - "message.xtracr_realcamera.command_listAll": "Found %d results: %s", - "screen.xtracr_realcamera.modelView_title": "Model View", "screen.widget.xtracr_realcamera.modelView_selectMode": "Selecting", "screen.widget.xtracr_realcamera.modelView_forwardMode": "Forward Vector", diff --git a/common/src/main/resources/assets/realcamera/lang/zh_cn.json b/common/src/main/resources/assets/realcamera/lang/zh_cn.json index 5c2a60b..d72f97e 100644 --- a/common/src/main/resources/assets/realcamera/lang/zh_cn.json +++ b/common/src/main/resources/assets/realcamera/lang/zh_cn.json @@ -96,10 +96,6 @@ "config.tooltip.xtracr_realcamera.autoBind": "根据当前玩家模型纹理,自动在已保存的配置中搜索合适项", "config.tooltip.xtracr_realcamera.depth": "全部顶点到屏幕距离均小于该值的面不会被渲染", - "message.xtracr_realcamera.command_delete_failure": "未能找到'%s'", - "message.xtracr_realcamera.command_delete_success": "成功删除'%s'", - "message.xtracr_realcamera.command_listAll": "找到了%d个结果: %s", - "screen.xtracr_realcamera.modelView_title": "模型视图", "screen.widget.xtracr_realcamera.modelView_selectMode": "选择", "screen.widget.xtracr_realcamera.modelView_forwardMode": "向前矢量", diff --git a/fabric/src/main/java/com/xtracr/realcamera/RealCameraFabric.java b/fabric/src/main/java/com/xtracr/realcamera/RealCameraFabric.java index 90d267b..912a5aa 100644 --- a/fabric/src/main/java/com/xtracr/realcamera/RealCameraFabric.java +++ b/fabric/src/main/java/com/xtracr/realcamera/RealCameraFabric.java @@ -1,11 +1,8 @@ package com.xtracr.realcamera; -import com.xtracr.realcamera.command.ClientCommand; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; 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.WorldRenderEvents; @@ -19,6 +16,5 @@ public void onInitializeClient() { ClientTickEvents.END_CLIENT_TICK.register(KeyBindings::handle); WorldRenderEvents.START.register(EventHandler::onWorldRenderStart); - ClientCommandRegistrationCallback.EVENT.register(new ClientCommand()::register); } } diff --git a/forge/src/main/java/com/xtracr/realcamera/EventHandler.java b/forge/src/main/java/com/xtracr/realcamera/EventHandler.java index ff32f74..2dd015e 100644 --- a/forge/src/main/java/com/xtracr/realcamera/EventHandler.java +++ b/forge/src/main/java/com/xtracr/realcamera/EventHandler.java @@ -1,12 +1,9 @@ package com.xtracr.realcamera; -import com.xtracr.realcamera.command.ClientCommand; import com.xtracr.realcamera.config.ConfigFile; import com.xtracr.realcamera.util.CrosshairUtil; import net.minecraft.client.MinecraftClient; -import net.minecraft.server.command.ServerCommandSource; import net.minecraftforge.client.event.InputEvent.Key; -import net.minecraftforge.client.event.RegisterClientCommandsEvent; import net.minecraftforge.client.event.RenderLevelStageEvent; import net.minecraftforge.client.event.ViewportEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -24,11 +21,6 @@ public static void onCameraUpdate(ViewportEvent.ComputeCameraAngles event) { } } - @SubscribeEvent - public static void onClientCommandRegister(RegisterClientCommandsEvent event) { - new ClientCommand().register(event.getDispatcher(), event.getBuildContext()); - } - @SubscribeEvent public static void onRenderWorldStage(RenderLevelStageEvent event) { if (RenderLevelStageEvent.Stage.AFTER_SKY.equals(event.getStage())) { diff --git a/forge/src/main/java/com/xtracr/realcamera/RealCameraForge.java b/forge/src/main/java/com/xtracr/realcamera/RealCameraForge.java index 607bcf0..456a048 100644 --- a/forge/src/main/java/com/xtracr/realcamera/RealCameraForge.java +++ b/forge/src/main/java/com/xtracr/realcamera/RealCameraForge.java @@ -29,7 +29,6 @@ public void clientSetup(FMLClientSetupEvent event) { MinecraftForge.EVENT_BUS.addListener(EventHandler::onKeyInput); MinecraftForge.EVENT_BUS.addListener(EventPriority.LOWEST, EventHandler::onCameraUpdate); - MinecraftForge.EVENT_BUS.addListener(EventHandler::onClientCommandRegister); MinecraftForge.EVENT_BUS.addListener(EventHandler::onRenderWorldStage); if (ModList.get().isLoaded("cloth_config")) {