diff --git a/build.gradle b/build.gradle index 2c66c6c..e7e1332 100644 --- a/build.gradle +++ b/build.gradle @@ -47,6 +47,9 @@ subprojects { rootProject.tasks.publishToMavenLocal.dependsOn(publishToMavenLocal) afterEvaluate { + final String reindevVersion = project['reindev.version'] as String + final String reindevVersionAllowFrom = project['reindev.version.allowFrom'] as String + publishing { publications { release(MavenPublication) { @@ -56,10 +59,18 @@ subprojects { version = '1.0' // JitPack only work with "1.0" as version pom { url = 'https://github.com/Fox2Code/FoxLoader' - properties = [ - "foxloader.version": project['foxloader.version'] as String, - "reindev.version" : project['reindev.version'] as String, - ] + if (reindevVersion == reindevVersionAllowFrom) { + properties = [ + "foxloader.version": project['foxloader.version'] as String, + "reindev.version" : reindevVersion, + ] + } else { + properties = [ + "foxloader.version": project['foxloader.version'] as String, + "reindev.version" : reindevVersion, + "reindev.version.allowFrom" : reindevVersionAllowFrom, + ] + } } } } diff --git a/client/src/main/java/com/fox2code/foxloader/client/gui/GuiLinkConfirm.java b/client/src/main/java/com/fox2code/foxloader/client/gui/GuiLinkConfirm.java deleted file mode 100644 index 29e8157..0000000 --- a/client/src/main/java/com/fox2code/foxloader/client/gui/GuiLinkConfirm.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.fox2code.foxloader.client.gui; - -import com.fox2code.foxloader.launcher.utils.Platform; -import net.minecraft.src.client.gui.*; - -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.io.IOException; -import java.net.URI; - -public class GuiLinkConfirm extends GuiYesNo { - private final GuiScreen parentScreen; - private final String link; - private final String openText; - private final String copyText; - private final String cancelText; - private final String warningText; - - public GuiLinkConfirm(GuiScreen origin, String link) { - super(origin, StringTranslate.getInstance().translateKey("chat.link.confirm"), link, "", "", -1); - this.parentScreen = origin; - this.link = link; - StringTranslate stringTranslate = StringTranslate.getInstance(); - this.openText = stringTranslate.translateKey("chat.link.open"); - this.copyText = stringTranslate.translateKey("chat.copy"); - this.cancelText = stringTranslate.translateKey("gui.no"); - this.warningText = stringTranslate.translateKey("chat.link.warning"); - } - - @Override - public void initGui() { - final int y = this.height / 6 + 96; - this.controlList.add(new GuiSmallButton(0, this.width / 2 - 50 - 105, y, 100, 20, this.openText)); - this.controlList.add(new GuiSmallButton(1, this.width / 2 - 50, y, 100, 20, this.copyText)); - this.controlList.add(new GuiSmallButton(2, this.width / 2 - 50 + 105, y, 100, 20, this.cancelText)); - } - - @Override - protected void actionPerformed(GuiButton button) { - switch (button.id) { - case 0: - this.openLinkInBrowser(); - break; - case 1: - Toolkit.getDefaultToolkit().getSystemClipboard() - .setContents(new StringSelection(this.link), null); - break; - case 2: - } - this.mc.displayGuiScreen(this.parentScreen); - } - - private void openLinkInBrowser() { - if (Desktop.isDesktopSupported()) { - Desktop desktop = Desktop.getDesktop(); - if (desktop.isSupported(Desktop.Action.BROWSE)) { - try { - desktop.browse(URI.create(this.link)); - return; - } catch (IOException ignored) {} - } - } - try { - Runtime.getRuntime().exec(new String[]{Platform.getPlatform().open, this.link}); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void drawScreen(int var1, int var2, float deltaTicks) { - super.drawScreen(var1, var2, deltaTicks); - this.drawCenteredString(this.fontRenderer, this.warningText, this.width / 2, 110, 16764108); - } -} diff --git a/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGuiChat.java b/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGuiChat.java deleted file mode 100644 index 58d0099..0000000 --- a/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGuiChat.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.fox2code.foxloader.client.mixins; - -import com.fox2code.foxloader.client.gui.GuiLinkConfirm; -import com.fox2code.foxloader.launcher.utils.NetUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.src.client.gui.ChatLine; -import net.minecraft.src.client.gui.GuiChat; -import net.minecraft.src.client.gui.GuiScreen; -import net.minecraft.src.client.gui.ScaledResolution; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -/** - * @see net.minecraft.src.client.gui.GuiIngame - */ -@Mixin(GuiChat.class) -public class MixinGuiChat extends GuiScreen { - @Shadow public int scrollChat; - - @Inject(method = "mouseClicked", at = @At("RETURN")) - public void onMouseClickedHook(int x, int y, int clickType, CallbackInfo ci) { - if (clickType == 0) { - int cursor = x - 2; - if (cursor < 0 || cursor > 320) return; - int rawIndex = y - ScaledResolution.instance.getScaledHeight() + 48; - rawIndex = this.scrollChat - rawIndex / 9; - if (rawIndex < 0) return; - final List chatMessageList = - Minecraft.theMinecraft.ingameGUI.chatMessageList; - int maxIndex = Math.min(20 + this.scrollChat, chatMessageList.size()); - if (rawIndex >= maxIndex) return; - ChatLine clickedLine = chatMessageList.get(rawIndex); - String message = clickedLine.message; - int start = message.indexOf("https://"); - if (start == -1) return; - int end = start; - while (end < message.length() && - message.charAt(end) != ' ') { - end++; - } - String preLink = message.substring(0, start); - int startCursor = this.fontRenderer.getStringWidth(preLink); - if (cursor < startCursor) return; - String link = message.substring(start, end); - if (!NetUtils.isValidURL(link)) return; - int endCursor = startCursor + this.fontRenderer.getStringWidth(link); - if (cursor > endCursor) return; - Minecraft.getInstance().displayGuiScreen(new GuiLinkConfirm(this, link)); - } - } -} diff --git a/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGuiContainer.java b/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGuiContainer.java deleted file mode 100644 index 002c73f..0000000 --- a/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinGuiContainer.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fox2code.foxloader.client.mixins; - -import com.fox2code.foxloader.loader.ModLoader; -import net.minecraft.src.client.gui.GuiContainer; -import org.lwjgl.input.Keyboard; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(GuiContainer.class) -public class MixinGuiContainer { - @Redirect(method = "getItemInfo", at = @At(value = "INVOKE", - target = "Lorg/lwjgl/input/Keyboard;isKeyDown(I)Z")) - public boolean redirectIsKeyDown(int key) { - return ModLoader.DEV_MODE || Keyboard.isKeyDown(key); - } -} diff --git a/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinWorld.java b/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinWorld.java index d61d90d..0d80a2e 100644 --- a/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinWorld.java +++ b/client/src/main/java/com/fox2code/foxloader/client/mixins/MixinWorld.java @@ -83,10 +83,4 @@ public List getRegisteredTileEntities() { public List getRegisteredNetworkPlayers() { return (List) (Object) this.playerEntities; } - - @Redirect(method = "getLoadedBlockIdOrM1", at = @At(value = "INVOKE", target = - "Lnet/minecraft/src/game/level/World;getLoadedChunkFromBlockCoords(III)Lnet/minecraft/src/game/level/chunk/Chunk;")) - public Chunk hotfix_getLoadedBlockIdOrM1(World instance, int x, int y, int z) { - return instance.getLoadedChunkFromChunkCoords(x, y, z); - } } diff --git a/client/src/main/resources/foxloader.client.mixins.json b/client/src/main/resources/foxloader.client.mixins.json index e8c54b2..0e21bd8 100644 --- a/client/src/main/resources/foxloader.client.mixins.json +++ b/client/src/main/resources/foxloader.client.mixins.json @@ -18,8 +18,6 @@ "MixinEntityPlayerSP", "MixinEntityRenderer", "MixinGameSettings", - "MixinGuiChat", - "MixinGuiContainer", "MixinGuiDebug", "MixinGuiMainMenu", "MixinGuiTextField", diff --git a/common/src/main/java/com/fox2code/foxloader/loader/PreLoader.java b/common/src/main/java/com/fox2code/foxloader/loader/PreLoader.java index db5a1b0..4a9d8fc 100644 --- a/common/src/main/java/com/fox2code/foxloader/loader/PreLoader.java +++ b/common/src/main/java/com/fox2code/foxloader/loader/PreLoader.java @@ -186,12 +186,10 @@ static void loadPrePatches(boolean client) { } registerPrePatch(new VarNameTransformer()); registerPrePatch(new RegistryTransformer()); - registerPrePatch(new OptimizerChunkCacheTransformer()); if (client) { registerPrePatch(new MinecraftClientDebugTransformer()); registerPrePatch(new FrustrumHelperTransformer()); registerPrePatch(new NetworkMappingTransformer()); - registerPrePatch(new OptimizerTessellatorTransformer()); } } diff --git a/common/src/main/java/com/fox2code/foxloader/loader/transformer/FrustrumHelperTransformer.java b/common/src/main/java/com/fox2code/foxloader/loader/transformer/FrustrumHelperTransformer.java index 400889e..73ac9c9 100644 --- a/common/src/main/java/com/fox2code/foxloader/loader/transformer/FrustrumHelperTransformer.java +++ b/common/src/main/java/com/fox2code/foxloader/loader/transformer/FrustrumHelperTransformer.java @@ -3,8 +3,6 @@ import org.objectweb.asm.tree.*; public class FrustrumHelperTransformer implements PreClassTransformer { - private static final String PARTICLE = "net/minecraft/src/client/particle/EntityFX"; - private static final String BOUNDINGBOX ="net/minecraft/src/client/physics/AxisAlignedBB"; private static final String FRUSTRUM = "net/minecraft/src/client/renderer/Frustrum"; private static final String FRUSTRUM_HELPER = "com/fox2code/foxloader/client/FrustrumHelper"; private static final String FRUSTRUM_HOOKS = "com/fox2code/foxloader/client/FrustrumHelper$Hooks"; @@ -13,7 +11,6 @@ public class FrustrumHelperTransformer implements PreClassTransformer { public void transform(ClassNode classNode, String className) { if (!className.startsWith("net.minecraft.")) return; boolean entityRenderer = className.equals("net.minecraft.src.client.renderer.EntityRenderer"); - boolean effectRenderer = className.equals("net.minecraft.src.client.particle.EffectRenderer"); for (MethodNode methodNode : classNode.methods) { InsnList insnList = methodNode.instructions; for (AbstractInsnNode abstractInsnNode : methodNode.instructions) { @@ -40,27 +37,6 @@ public void transform(ClassNode classNode, String className) { FRUSTRUM_HOOKS, "update", "(L" + FRUSTRUM + ";DDD)V", false)); insnList.remove(methodInsnNode); } - } else if (effectRenderer && abstractInsnNode.getOpcode() == CHECKCAST && - methodNode.name.startsWith("render")) { - TypeInsnNode typeInsnNode = (TypeInsnNode) abstractInsnNode; - if (!typeInsnNode.desc.equals(PARTICLE)) continue; - abstractInsnNode = typeInsnNode.getNext(); - if (!(abstractInsnNode.getOpcode() == ASTORE)) continue; - VarInsnNode varInsnNode = (VarInsnNode) abstractInsnNode; - InsnList insns = new InsnList(); - LabelNode endLabel = new LabelNode(); - insns.add(new VarInsnNode(ALOAD, varInsnNode.var)); - insns.add(new FieldInsnNode(GETFIELD, PARTICLE, - "boundingBox", "L" + BOUNDINGBOX + ";")); - insns.add(new MethodInsnNode(INVOKESTATIC, FRUSTRUM_HELPER, - "isBoundingBoxInFrustum", "(L" + BOUNDINGBOX + ";)Z")); - insns.add(new JumpInsnNode(IFEQ, endLabel)); - AbstractInsnNode nextReal = varInsnNode.getNext(); - insnList.insert(varInsnNode, insns); - while (nextReal != null && nextReal.getOpcode() != INVOKEVIRTUAL) { - nextReal = nextReal.getNext(); - } - insnList.insert(nextReal, endLabel); } } } diff --git a/common/src/main/java/com/fox2code/foxloader/loader/transformer/OptimizerChunkCacheTransformer.java b/common/src/main/java/com/fox2code/foxloader/loader/transformer/OptimizerChunkCacheTransformer.java deleted file mode 100644 index 3dbff27..0000000 --- a/common/src/main/java/com/fox2code/foxloader/loader/transformer/OptimizerChunkCacheTransformer.java +++ /dev/null @@ -1,286 +0,0 @@ -package com.fox2code.foxloader.loader.transformer; - -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; - -public class OptimizerChunkCacheTransformer implements PreClassTransformer { - private static final boolean DEBUG = true; - private static final String CHUNK_CACHE = "net/minecraft/src/game/level/chunk/ChunkCache"; - private static final String CHUNK = "net/minecraft/src/game/level/chunk/Chunk"; - private static final String[] chunkFields = new String[]{"chunkX", "chunkY", "chunkZ"}; - private static final int[] opcodeAssumption = new int[]{ - ILOAD, ICONST_4, ISHR, ALOAD, GETFIELD, ISUB, ISTORE - }; - private static final int[] opcodeAssumption2 = new int[]{ - GETFIELD, ILOAD, AALOAD, ILOAD, AALOAD, ILOAD, AALOAD - }; - - @Override - public void transform(ClassNode classNode, String className) { - if (!"net.minecraft.src.game.level.chunk.ChunkCache".equals(className)) return; - - classNode.fields.add(new FieldNode(ACC_PRIVATE, "lastChunkX", "I", null, null)); - classNode.fields.add(new FieldNode(ACC_PRIVATE, "lastChunkY", "I", null, null)); - classNode.fields.add(new FieldNode(ACC_PRIVATE, "lastChunkZ", "I", null, null)); - classNode.fields.add(new FieldNode(ACC_PRIVATE, "lastChunk", "L" + CHUNK + ";", null, null)); - appendInitializer(TransformerUtils.getMethod(classNode, "")); - MethodNode set = TransformerUtils.findMethod(classNode, "set"); - if (set != null) { - appendInitializer(set); - } - for (MethodNode methodNode : classNode.methods) { - if (!methodNode.name.startsWith("<") && - !methodNode.name.equals("set") && - !methodNode.name.equals("reset")) { - optimizeSingleMethod(methodNode); - } - } - } - - public void appendInitializer(MethodNode methodNode) { - // Prefill cache with one chunk to avoid having to handle edge cases - InsnList insnList = new InsnList(); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new InsnNode(ICONST_0)); - insnList.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunkX", "I")); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new InsnNode(ICONST_0)); - insnList.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunkY", "I")); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new InsnNode(ICONST_0)); - insnList.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunkZ", "I")); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "chunkArray", "[[[L" + CHUNK + ";")); - insnList.add(new InsnNode(ICONST_0)); - insnList.add(new InsnNode(AALOAD)); - insnList.add(new InsnNode(ICONST_0)); - insnList.add(new InsnNode(AALOAD)); - insnList.add(new InsnNode(ICONST_0)); - insnList.add(new InsnNode(AALOAD)); - insnList.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunk", "L" + CHUNK + ";")); - AbstractInsnNode abstractInsnNode = methodNode.instructions.getLast(); - while (abstractInsnNode != null && abstractInsnNode.getOpcode() != RETURN) { - abstractInsnNode = abstractInsnNode.getPrevious(); - } - if (abstractInsnNode == null) { - throw new RuntimeException("Incompatible return type for \"set" + methodNode.desc + "\"???"); - } - methodNode.instructions.insertBefore(abstractInsnNode, insnList); - } - - public void optimizeSingleMethod(MethodNode methodNode) { - String debugName = methodNode.name + methodNode.desc; - final int returnOpcode = Type.getReturnType(methodNode.desc).getOpcode(IRETURN); - InsnList methodInsns = methodNode.instructions; - AbstractInsnNode opcode = methodInsns.getFirst(); - int assumptionX = 0, assumptionY = 0, assumptionZ = 0; - assumptionLoop: - for (int i = 0; i < 3; i++) { - String fieldName = chunkFields[i]; - for (int assumedOpcode : opcodeAssumption) { - while (opcode.getOpcode() == -1) { - opcode = opcode.getNext(); - if (opcode == null) - break assumptionLoop; - } - if (opcode.getOpcode() != assumedOpcode) { - if (DEBUG) { - System.out.println("Failed assumption of " + debugName + " cause wrong opcode, expected: " + - assumedOpcode + ", got " + opcode.getOpcode()); - } - break assumptionLoop; - } - if (opcode.getOpcode() == GETFIELD && - !fieldName.equals(((FieldInsnNode) opcode).name)) { - if (DEBUG) { - System.out.println("Failed assumption of " + debugName + " cause wrong get field name, expected: " + - fieldName + ", got " + ((FieldInsnNode) opcode).name); - } - break assumptionLoop; - } - if (opcode.getOpcode() == ISTORE) { - switch (i) { - case 0: - assumptionX = ((VarInsnNode) opcode).var; - break; - case 1: - assumptionY = ((VarInsnNode) opcode).var; - break; - case 2: - assumptionZ = ((VarInsnNode) opcode).var; - if (DEBUG) { - System.out.println("Assumed " + - methodNode.name + methodNode.desc); - } - break; - } - } - opcode = opcode.getNext(); - if (opcode == null) - break assumptionLoop; - } - } - // If we can, try using header assumption - if (assumptionZ != 0 && opcode != null) { - AbstractInsnNode retOpCode = opcode.getNext(); - while (retOpCode.getOpcode() != returnOpcode) { - retOpCode = retOpCode.getNext(); - if (retOpCode == null) break; - } - if (retOpCode != null) { - while (retOpCode.getOpcode() != AALOAD) { - retOpCode = retOpCode.getPrevious(); - if (retOpCode == null) break; - } - if (retOpCode != null) { - retOpCode = retOpCode.getNext(); - if (retOpCode.getOpcode() == ASTORE) { - VarInsnNode aStore = (VarInsnNode) retOpCode; - LabelNode next; - if (retOpCode.getNext() instanceof LabelNode) { - next = (LabelNode) retOpCode.getNext(); - } else { - methodInsns.insert(retOpCode, next = new LabelNode()); - } - InsnList toInjectPre = new InsnList(); - LabelNode fallback = new LabelNode(); - if (methodNode.localVariables != null) { - for (LocalVariableNode localVariableNode : methodNode.localVariables) { - if (localVariableNode.index == aStore.var) { - toInjectPre.add(localVariableNode.start = new LabelNode()); - } - } - } - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunkX", "I")); - toInjectPre.add(new VarInsnNode(ILOAD, assumptionX)); - toInjectPre.add(new JumpInsnNode(IF_ICMPNE, fallback)); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunkY", "I")); - toInjectPre.add(new VarInsnNode(ILOAD, assumptionY)); - toInjectPre.add(new JumpInsnNode(IF_ICMPNE, fallback)); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunkZ", "I")); - toInjectPre.add(new VarInsnNode(ILOAD, assumptionZ)); - toInjectPre.add(new JumpInsnNode(IF_ICMPNE, fallback)); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunk", "L" + CHUNK + ";")); - toInjectPre.add(new VarInsnNode(ASTORE, aStore.var)); - // Work like "toInjectPre.add(new JumpInsnNode(GOTO, next));" but - // work better with decompilers to produce beginner-friendly code. - toInjectPre.add(TransformerUtils.copyCodeUntil(next, returnOpcode)); - toInjectPre.add(fallback); - - InsnList toInjectPost = new InsnList(); - toInjectPost.add(new VarInsnNode(ALOAD, 0)); - toInjectPost.add(new VarInsnNode(ILOAD, assumptionX)); - toInjectPost.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunkX", "I")); - toInjectPost.add(new VarInsnNode(ALOAD, 0)); - toInjectPost.add(new VarInsnNode(ILOAD, assumptionY)); - toInjectPost.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunkY", "I")); - toInjectPost.add(new VarInsnNode(ALOAD, 0)); - toInjectPost.add(new VarInsnNode(ILOAD, assumptionZ)); - toInjectPost.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunkZ", "I")); - toInjectPost.add(new VarInsnNode(ALOAD, 0)); - toInjectPost.add(new VarInsnNode(ALOAD, aStore.var)); - toInjectPost.add(new FieldInsnNode(PUTFIELD, CHUNK_CACHE, "lastChunk", "L" + CHUNK + ";")); - // Do the injection - methodInsns.insert(opcode, toInjectPre); - methodInsns.insertBefore(next, toInjectPost); - - if (DEBUG) { - System.out.println("Injected into " + debugName + " with the method hook way!"); - } - return; - } - } - } - } - // Try different assumption set then - opcode = null; - assumptionZ = 0; - FieldInsnNode fieldInsnNode = null; - assumptionLoop: - for (AbstractInsnNode abstractInsnNode : methodInsns) { - if (abstractInsnNode.getOpcode() == GETFIELD && - (fieldInsnNode = (FieldInsnNode) abstractInsnNode).name.equals("chunkArray")) { - int i = 0; - - for (int assumedOpcode : opcodeAssumption2) { - while (abstractInsnNode.getOpcode() == -1) { - abstractInsnNode = abstractInsnNode.getNext(); - if (abstractInsnNode == null) { - assumptionZ = 0; - continue assumptionLoop; - } - } - if (abstractInsnNode.getOpcode() != assumedOpcode) { - if (DEBUG) { - System.out.println("Failed assumption of a " + debugName + - " chunkArray field instruction cause wrong opcode, expected: " + - assumedOpcode + ", got " + abstractInsnNode.getOpcode()); - } - assumptionZ = 0; - continue assumptionLoop; - } - if (assumedOpcode == ILOAD) { - switch (i++) { - case 0: - assumptionX = ((VarInsnNode) abstractInsnNode).var; - break; - case 1: - assumptionY = ((VarInsnNode) abstractInsnNode).var; - break; - case 2: - assumptionZ = ((VarInsnNode) abstractInsnNode).var; - break; - } - } else if (assumedOpcode == AALOAD && assumptionZ != 0) { - opcode = abstractInsnNode; - if (DEBUG) { - System.out.println("Assumed for instruction " + - methodNode.name + methodNode.desc); - } - break assumptionLoop; - } - abstractInsnNode = abstractInsnNode.getNext(); - if (abstractInsnNode == null) { - continue assumptionLoop; - } - } - } - } - if (assumptionZ != 0 && opcode != null && - fieldInsnNode.getPrevious().getOpcode() == ALOAD) { - InsnList toInjectPre = new InsnList(); - LabelNode fallback = new LabelNode(); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunkX", "I")); - toInjectPre.add(new VarInsnNode(ILOAD, assumptionX)); - toInjectPre.add(new JumpInsnNode(IF_ICMPNE, fallback)); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunkY", "I")); - toInjectPre.add(new VarInsnNode(ILOAD, assumptionY)); - toInjectPre.add(new JumpInsnNode(IF_ICMPNE, fallback)); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunkZ", "I")); - toInjectPre.add(new VarInsnNode(ILOAD, assumptionZ)); - toInjectPre.add(new JumpInsnNode(IF_ICMPNE, fallback)); - toInjectPre.add(new VarInsnNode(ALOAD, 0)); - toInjectPre.add(new FieldInsnNode(GETFIELD, CHUNK_CACHE, "lastChunk", "L" + CHUNK + ";")); - LabelNode solved = new LabelNode(); - toInjectPre.add(new JumpInsnNode(GOTO, solved)); - toInjectPre.add(fallback); - methodInsns.insertBefore(fieldInsnNode.getPrevious(), toInjectPre); - methodInsns.insert(opcode, solved); - if (DEBUG) { - System.out.println("Injected into " + debugName + " with the instruction hook way!"); - } - } else if (DEBUG && assumptionZ != 0) { - System.out.println(assumptionZ + " " + - (opcode == null ? "null" : opcode.getOpcode()) + " " + - fieldInsnNode.name + " " + fieldInsnNode.getPrevious().getOpcode()); - } - } -} diff --git a/common/src/main/java/com/fox2code/foxloader/loader/transformer/OptimizerTessellatorTransformer.java b/common/src/main/java/com/fox2code/foxloader/loader/transformer/OptimizerTessellatorTransformer.java deleted file mode 100644 index 5bd39c1..0000000 --- a/common/src/main/java/com/fox2code/foxloader/loader/transformer/OptimizerTessellatorTransformer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.fox2code.foxloader.loader.transformer; - -import org.objectweb.asm.tree.*; - -public class OptimizerTessellatorTransformer implements PreClassTransformer { - private static final String TESSELLATOR = "net/minecraft/src/client/renderer/Tessellator"; - - @Override - public void transform(ClassNode classNode, String className) { - if (!"net.minecraft.src.client.renderer.Tessellator".equals(className)) return; - TransformerUtils.getField(classNode, "textureU").value = -1; - TransformerUtils.getField(classNode, "textureV").value = -1; - InsnList insnList = new InsnList(); - LabelNode notMatch = new LabelNode(); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new FieldInsnNode(GETFIELD, TESSELLATOR, "textureU", "D")); - insnList.add(new VarInsnNode(DLOAD, 1)); - insnList.add(new InsnNode(DCMPL)); - insnList.add(new JumpInsnNode(IFNE, notMatch)); - insnList.add(new VarInsnNode(ALOAD, 0)); - insnList.add(new FieldInsnNode(GETFIELD, TESSELLATOR, "textureV", "D")); - insnList.add(new VarInsnNode(DLOAD, 3)); - insnList.add(new InsnNode(DCMPL)); - insnList.add(new JumpInsnNode(IFNE, notMatch)); - insnList.add(new InsnNode(RETURN)); - insnList.add(notMatch); - MethodNode setTextureUV =TransformerUtils.getMethod( - classNode, "setTextureUV", "(DD)V"); - AbstractInsnNode abstractInsnNode = setTextureUV.instructions.getFirst(); - while (abstractInsnNode.getOpcode() == -1) { - abstractInsnNode = abstractInsnNode.getNext(); - if (abstractInsnNode == null) return; - } - setTextureUV.instructions.insertBefore(abstractInsnNode, insnList); - } -} diff --git a/gradle.properties b/gradle.properties index febf5d7..20367dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,16 @@ org.gradle.parallel=true org.gradle.jvmargs=-Xmx1024m -XX:-UseGCOverheadLimit -Dfile.encoding=UTF-8 # FoxLoader properties -foxloader.version=1.2.3 -foxloader.lastReIndevTransformerChanges=1.2.1 +foxloader.version=1.2.4 +foxloader.lastReIndevTransformerChanges=1.2.4 # ReIndev properties -reindev.clientUrl=https://cdn.fox2code.com/files/reindev_2.8.1_01.jar -reindev.serverUrl=https://cdn.fox2code.com/files/reindev281-01_server.jar -reindev.clientJar=reindev_2.8.1_01.jar -reindev.serverJar=reindev281-01_server.jar -reindev.version=2.8.1_1 +reindev.clientUrl=https://cdn.fox2code.com/files/reindev_2.8.1_02.jar +reindev.serverUrl=https://cdn.fox2code.com/files/reindev281-02_server.jar +reindev.clientJar=reindev_2.8.1_02.jar +reindev.serverJar=reindev281-02_server.jar +reindev.version=2.8.1_2 +reindev.version.allowFrom=2.8.1_1 #Spark properties spark.dependency=maven.modrinth:spark:1.10.37-fabric diff --git a/server/src/main/java/com/fox2code/foxloader/server/mixins/MixinWorld.java b/server/src/main/java/com/fox2code/foxloader/server/mixins/MixinWorld.java index 5151c74..1ad4d32 100644 --- a/server/src/main/java/com/fox2code/foxloader/server/mixins/MixinWorld.java +++ b/server/src/main/java/com/fox2code/foxloader/server/mixins/MixinWorld.java @@ -79,10 +79,4 @@ public List getRegisteredTileEntities() { public List getRegisteredNetworkPlayers() { return (List) (Object) this.playerEntities; } - - @Redirect(method = "getLoadedBlockIdOrM1", at = @At(value = "INVOKE", target = - "Lnet/minecraft/src/game/level/World;getLoadedChunkFromBlockCoords(III)Lnet/minecraft/src/game/level/chunk/Chunk;")) - public Chunk hotfix_getLoadedBlockIdOrM1(World instance, int x, int y, int z) { - return instance.getLoadedChunkFromChunkCoords(x, y, z); - } }