From 2452f85f092f4d9fefabdae632889dca344129f7 Mon Sep 17 00:00:00 2001 From: Guichaguri Date: Sun, 30 Oct 2016 03:25:39 -0200 Subject: [PATCH] Added better mappings, faster beacon beam rendering, fixes --- build.gradle | 68 +++++++- mappings.srg | 41 +++++ .../java/guichaguri/betterfps/ASMUtils.java | 10 +- .../java/guichaguri/betterfps/BetterFps.java | 4 - .../guichaguri/betterfps/BetterFpsClient.java | 15 -- .../guichaguri/betterfps/BetterFpsConfig.java | 2 + .../guichaguri/betterfps/BetterFpsHelper.java | 8 +- .../guichaguri/betterfps/UpdateChecker.java | 29 ++-- .../clones/tileentity/BeaconRenderer.java | 73 ++++++++ .../clones/tileentity/HopperLogic.java | 5 +- .../betterfps/gui/GuiBetterFpsConfig.java | 68 ++++++-- .../transformers/CapTransformer.java | 10 +- .../transformers/EventTransformer.java | 75 ++------ .../transformers/MathTransformer.java | 21 ++- .../transformers/MiscTransformer.java | 12 +- .../transformers/VisualChunkTransformer.java | 50 +++--- .../transformers/WeakerTransformer.java | 8 +- .../cloner/ClonerTransformer.java | 39 +++-- .../betterfps/transformers/cloner/Named.java | 4 +- .../betterfps/tweaker/BetterFpsTweaker.java | 17 ++ .../betterfps/tweaker/Mappings.java | 164 ++++++++++++++++++ .../guichaguri/betterfps/tweaker/Naming.java | 120 ------------- 22 files changed, 531 insertions(+), 312 deletions(-) create mode 100644 mappings.srg create mode 100644 src/main/java/guichaguri/betterfps/clones/tileentity/BeaconRenderer.java create mode 100644 src/main/java/guichaguri/betterfps/tweaker/Mappings.java delete mode 100644 src/main/java/guichaguri/betterfps/tweaker/Naming.java diff --git a/build.gradle b/build.gradle index 773eef6..fd73b77 100644 --- a/build.gradle +++ b/build.gradle @@ -13,18 +13,18 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' } } apply plugin: 'net.minecraftforge.gradle.tweaker-client' -version = "1.3.0" +version = "1.3.3" group = "guichaguri.betterfps" archivesBaseName = "BetterFps" minecraft { - version = "1.9.4" + version = "1.10.2" runDir = "run" tweakClass = "guichaguri.betterfps.tweaker.BetterFpsTweaker"; mappings = "snapshot_20160518" @@ -32,6 +32,11 @@ minecraft { at 'betterfps_at.cfg' } +sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly. +compileJava { + sourceCompatibility = targetCompatibility = "1.6" +} + jar { manifest { attributes 'TweakClass': project.minecraft.tweakClass, @@ -47,6 +52,7 @@ jar { dependencies { //compile 'org.ow2.asm:asm-debug-all:5.0.3' //compile 'net.minecraft:launchwrapper:1.12' + testCompile 'junit:junit:4.12' } processResources { @@ -61,11 +67,63 @@ processResources { expand 'version': project.version } - // copy everything else, thats not the json + // copy everything else, except the json from(sourceSets.main.resources.srcDirs) { exclude 'META-INF/betterfps.json' } } +String srgInput = 'mappings.srg' +String srgOutput = 'src/main/resources/betterfps.srg' -runClient.args "--username", "BetterFps" \ No newline at end of file +/** + * Task created by Guichaguri to update the requested mappings of a SRG file + * You might have to update the input file when the mappings version change. + */ +task updateMappings(dependsOn: 'genSrgs') { + def classes = [:]; + def fields = [:]; + def methods = [:]; + def i = 0; + + println 'Searching mappings to update' + String[] reqMapping = file(srgInput).readLines() + reqMapping.each { + String[] mapping = it.split(' ') + if(it.startsWith('#')) { + // Comment + } else if(mapping[0].equals('CL:')) { // Class + if(mapping.length >= 2) classes.put(mapping[2], mapping[1]); + } else if(mapping[0].equals('FD:')) { // Field + if(mapping.length >= 2) fields.put(mapping[2], mapping[1]); + } else if(mapping[0].equals('MD:')) { // Method + if(mapping.length >= 3) methods.put(mapping[2] + mapping[3], mapping[1]); + } + } + println 'Updating mappings' + file(srgOutput).withWriter { out -> + String[] mappings = tasks['genSrgs'].getNotchToMcp().readLines() + mappings.each { + String[] mapping = it.split(' ') + if (mapping[0].equals('CL:')) { // Class + if(mapping.length >= 3 && classes.containsKey(mapping[2])) { + out.println it + ' ' + classes.get(mapping[2]) + i++ + } + } else if(mapping[0].equals('FD:')) { // Field + if(mapping.length >= 3 && fields.containsKey(mapping[2])) { + out.println it + ' ' + fields.get(mapping[2]) + i++ + } + } else if(mapping[0].equals('MD:')) { // Method + if(mapping.length >= 5 && methods.containsKey(mapping[3] + mapping[4])) { + out.println it + ' ' + methods.get(mapping[3] + mapping[4]) + i++ + } + } + } + def entries = classes.size() + fields.size() + methods.size(); + println 'Done. Updated ' + i + '/' + entries + ' entries' + if(i < entries) println 'WARNING: ' + (entries - i) + ' entries were not found! You should check them' + } +} \ No newline at end of file diff --git a/mappings.srg b/mappings.srg new file mode 100644 index 0000000..63678a1 --- /dev/null +++ b/mappings.srg @@ -0,0 +1,41 @@ +# The names will be obfuscated and written in resources/betterfps.srg by my gradle task automatically +# Prefixes: CL for classes, FD for fields and MD for methods +# Make sure all names are correct for the current version before compiling + +# PREFIX: IDENTIFIER NAME [DESC] + +CL: Minecraft net/minecraft/client/Minecraft +CL: World net/minecraft/world/World +CL: Chunk net/minecraft/world/chunk/Chunk +CL: EntityPlayer net/minecraft/entity/player/EntityPlayer +CL: MathHelper net/minecraft/util/math/MathHelper +CL: EntityTNTPrimed net/minecraft/entity/item/EntityTNTPrimed +CL: ClientBrandRetriever net/minecraft/client/ClientBrandRetriever +CL: GuiOptions net/minecraft/client/gui/GuiOptions +CL: WorldClient net/minecraft/client/multiplayer/WorldClient +CL: WorldServer net/minecraft/world/WorldServer +CL: IntegratedServer net/minecraft/server/integrated/IntegratedServer +CL: DedicatedServer net/minecraft/server/dedicated/DedicatedServer +CL: TileEntityBeacon net/minecraft/tileentity/TileEntityBeacon +CL: BeamSegment net/minecraft/tileentity/TileEntityBeacon$BeamSegment +CL: TileEntityBeaconRenderer net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer +CL: TileEntityHopper net/minecraft/tileentity/TileEntityHopper +CL: BlockHopper net/minecraft/block/BlockHopper +CL: ModelBox net/minecraft/client/model/ModelBox +CL: EntityRenderer net/minecraft/client/renderer/EntityRenderer + +MD: startGame net/minecraft/client/Minecraft/startGame ()V +MD: freeMemory net/minecraft/client/Minecraft/freeMemory ()V +MD: sin net/minecraft/util/math/MathHelper/sin (F)F +MD: cos net/minecraft/util/math/MathHelper/cos (F)F +MD: tick net/minecraft/world/World/tick ()V +MD: updateBlocks net/minecraft/world/World/updateBlocks ()V +MD: onUpdate net/minecraft/entity/Entity/onUpdate ()V +MD: getClientModName net/minecraft/client/ClientBrandRetriever/getClientModName ()Ljava/lang/String; +MD: initGui net/minecraft/client/gui/GuiScreen/initGui ()V +MD: startServer net/minecraft/server/MinecraftServer/startServer ()Z +MD: captureDroppedItems net/minecraft/tileentity/TileEntityHopper/captureDroppedItems (Lnet/minecraft/tileentity/IHopper;)Z +MD: renderBeamSegment net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer/renderBeamSegment (DDDDDDII[FDD)V + +FD: memoryReserve net/minecraft/client/Minecraft/memoryReserve [B +FD: SIN_TABLE net/minecraft/util/math/MathHelper/SIN_TABLE [F \ No newline at end of file diff --git a/src/main/java/guichaguri/betterfps/ASMUtils.java b/src/main/java/guichaguri/betterfps/ASMUtils.java index a7cfc6e..caeb106 100644 --- a/src/main/java/guichaguri/betterfps/ASMUtils.java +++ b/src/main/java/guichaguri/betterfps/ASMUtils.java @@ -1,6 +1,6 @@ package guichaguri.betterfps; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import java.util.List; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; @@ -25,16 +25,16 @@ public static byte[] writeClass(ClassNode node, int flags) { return writer.toByteArray(); } - public static MethodNode findMethod(ClassNode node, Naming naming) { + public static MethodNode findMethod(ClassNode node, Mappings mappings) { for(MethodNode m : node.methods) { - if(naming.is(m.name, m.desc)) return m; + if(mappings.is(m.name, m.desc)) return m; } return null; } - public static FieldNode findField(ClassNode node, Naming naming) { + public static FieldNode findField(ClassNode node, Mappings mappings) { for(FieldNode m : node.fields) { - if(naming.is(m.name, m.desc)) return m; + if(mappings.is(m.name, m.desc)) return m; } return null; } diff --git a/src/main/java/guichaguri/betterfps/BetterFps.java b/src/main/java/guichaguri/betterfps/BetterFps.java index ade3beb..49ac03c 100644 --- a/src/main/java/guichaguri/betterfps/BetterFps.java +++ b/src/main/java/guichaguri/betterfps/BetterFps.java @@ -1,14 +1,10 @@ package guichaguri.betterfps; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - /** * Common event handling * @author Guilherme Chaguri */ public class BetterFps { - public static final Logger log = LogManager.getLogger("BetterFps"); public static boolean isClient = false; diff --git a/src/main/java/guichaguri/betterfps/BetterFpsClient.java b/src/main/java/guichaguri/betterfps/BetterFpsClient.java index 0587b1a..32714b2 100644 --- a/src/main/java/guichaguri/betterfps/BetterFpsClient.java +++ b/src/main/java/guichaguri/betterfps/BetterFpsClient.java @@ -1,9 +1,6 @@ package guichaguri.betterfps; -import guichaguri.betterfps.gui.GuiBetterFpsConfig; import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.KeyBinding; -import org.lwjgl.input.Keyboard; /** * Client event handling @@ -11,7 +8,6 @@ */ public class BetterFpsClient { protected static Minecraft mc; - private static KeyBinding MENU_KEY = new KeyBinding("BetterFps", Keyboard.KEY_F12, "key.categories.misc"); // Called in Minecraft.startGame public static void start(Minecraft minecraft) { @@ -23,10 +19,6 @@ public static void start(Minecraft minecraft) { } BetterFpsHelper.init(); - // TODO unused. remove it - //mc.gameSettings.keyBindings = ArrayUtils.add(mc.gameSettings.keyBindings, MENU_KEY); - //mc.gameSettings.loadOptions(); - UpdateChecker.check(); } @@ -35,11 +27,4 @@ public static void worldLoad() { UpdateChecker.showChat(); } - // Called at the end of KeyBinding.onTick - public static void keyEvent(int key) {//TODO unused. remove it - if(MENU_KEY.getKeyCode() == key) { - mc.displayGuiScreen(new GuiBetterFpsConfig(mc.currentScreen)); - } - } - } diff --git a/src/main/java/guichaguri/betterfps/BetterFpsConfig.java b/src/main/java/guichaguri/betterfps/BetterFpsConfig.java index 7fc70ae..2e40c69 100644 --- a/src/main/java/guichaguri/betterfps/BetterFpsConfig.java +++ b/src/main/java/guichaguri/betterfps/BetterFpsConfig.java @@ -36,4 +36,6 @@ public static Object getValue(String key) { public boolean fastBeacon = true; + public boolean fastBeaconRender = false; + } diff --git a/src/main/java/guichaguri/betterfps/BetterFpsHelper.java b/src/main/java/guichaguri/betterfps/BetterFpsHelper.java index b751d32..9a748b7 100644 --- a/src/main/java/guichaguri/betterfps/BetterFpsHelper.java +++ b/src/main/java/guichaguri/betterfps/BetterFpsHelper.java @@ -7,19 +7,23 @@ import java.util.LinkedHashMap; import java.util.Properties; import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * @author Guilherme Chaguri */ public class BetterFpsHelper { - public static final String MC_VERSION = "1.9"; - public static final String VERSION = "1.2.1"; + public static final String MC_VERSION = "1.10.2"; + public static final String VERSION = "1.3.3"; public static final String URL = "http://guichaguri.github.io/BetterFps/"; public static final String UPDATE_URL = "http://widget.mcf.li/mc-mods/minecraft/229876-betterfps.json"; + public static final Logger LOG = LogManager.getLogger("BetterFps"); + // Config Name, Class Name public static final LinkedHashMap helpers = new LinkedHashMap(); diff --git a/src/main/java/guichaguri/betterfps/UpdateChecker.java b/src/main/java/guichaguri/betterfps/UpdateChecker.java index 83b2ecb..881e900 100644 --- a/src/main/java/guichaguri/betterfps/UpdateChecker.java +++ b/src/main/java/guichaguri/betterfps/UpdateChecker.java @@ -3,7 +3,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; @@ -32,12 +31,17 @@ public static void check() { } if(!updateCheck) { updateCheck = true; - Thread thread = new Thread(new UpdateChecker(), "BetterFps Update Checker"); - thread.setDaemon(true); - thread.start(); + checkForced(); } } + public static void checkForced() { + done = false; + Thread thread = new Thread(new UpdateChecker(), "BetterFps Update Checker"); + thread.setDaemon(true); + thread.start(); + } + public static void showChat() { if(!done) return; if(updateVersion == null && updateDownload == null) return; @@ -76,10 +80,10 @@ public static void showConsole() { if(!done) return; if(updateVersion == null && updateDownload == null) return; - BetterFps.log.info("BetterFps " + updateVersion + " is available"); - BetterFps.log.info(getRandomPhrase()); - BetterFps.log.info("Download: " + updateDownload); - BetterFps.log.info("More: " + BetterFpsHelper.URL); + BetterFpsHelper.LOG.info("BetterFps " + updateVersion + " is available"); + BetterFpsHelper.LOG.info(getRandomPhrase()); + BetterFpsHelper.LOG.info("Download: " + updateDownload); + BetterFpsHelper.LOG.info("More: " + BetterFpsHelper.URL); updateVersion = null; updateDownload = null; @@ -97,6 +101,7 @@ private static TextComponentString createButton(String label, String link, Strin } private static String getRandomPhrase() { + // Thanks to Kevin8082 for some of this phrases String[] phrases = new String[]{ "Just another annoying update.", "Babe are you a new update? Because not now.", @@ -105,9 +110,9 @@ private static String getRandomPhrase() { "Not again D:", "<3", "You will probably update just to get rid of this reminder", - "HARD WARE FAILURE! HARD WARE FAILURE! No wait, I derped out.", + "HARDWARE FAILURE! HARDWARE FAILURE! No wait, I derped out.", "Less annoying than Windows Updater... I think", - "Rope is cut, loot is mine, 90 second timer, and the entire server is after me now, great...", + "Rope is cut, update is out, and the entire server is after me now, great...", "It's free. Go get it ;)", "Some bugs are now fixed, but new ones have been introduced", "It will not update automagically, you know...", @@ -147,10 +152,8 @@ public void run() { showChat(); } } - } catch(IOException ex) { - BetterFps.log.warn("Could not check for updates: " + ex.getLocalizedMessage()); } catch(Exception ex) { - ex.printStackTrace(); + BetterFpsHelper.LOG.warn("Could not check for updates: " + ex.getMessage()); } finally { done = true; } diff --git a/src/main/java/guichaguri/betterfps/clones/tileentity/BeaconRenderer.java b/src/main/java/guichaguri/betterfps/clones/tileentity/BeaconRenderer.java new file mode 100644 index 0000000..aa7284d --- /dev/null +++ b/src/main/java/guichaguri/betterfps/clones/tileentity/BeaconRenderer.java @@ -0,0 +1,73 @@ +package guichaguri.betterfps.clones.tileentity; + +import guichaguri.betterfps.transformers.cloner.CopyBoolCondition; +import guichaguri.betterfps.transformers.cloner.CopyMode; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.math.MathHelper; +import org.lwjgl.opengl.GL11; + +/** + * @author Guilherme Chaguri + */ +public class BeaconRenderer extends TileEntityBeaconRenderer { + + @CopyMode(CopyMode.Mode.IGNORE) // Ignore the constructor to prevent an infinite loop + public BeaconRenderer() {} + + @CopyBoolCondition(key = "fastBeaconRender", value = true) + @CopyMode(CopyMode.Mode.REPLACE) + public static void renderBeamSegment(double x, double y, double z, double partialTicks, double scale, double worldTime, int beamY, int beamHeight, float[] colors, double p_188205_15_, double p_188205_17_) { + int maxY = beamY + beamHeight; + GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + GlStateManager.disableLighting(); + GlStateManager.disableCull(); + GlStateManager.disableBlend(); + GlStateManager.depthMask(true); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer vertexbuffer = tessellator.getBuffer(); + double time = worldTime + partialTicks; + double d1 = beamHeight < 0 ? time : -time; + double d2 = MathHelper.frac(d1 * 0.2D - (double)MathHelper.floor_double(d1 * 0.1D)); + float r = colors[0]; + float g = colors[1]; + float b = colors[2]; + double d3 = time * 0.025D * -1.5D; + double d4 = 0.5D + Math.cos(d3 + 2.356194490192345D) * p_188205_15_; + double d5 = 0.5D + Math.sin(d3 + 2.356194490192345D) * p_188205_15_; + double d6 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * p_188205_15_; + double d7 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * p_188205_15_; + double d8 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * p_188205_15_; + double d9 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * p_188205_15_; + double d10 = 0.5D + Math.cos(d3 + 5.497787143782138D) * p_188205_15_; + double d11 = 0.5D + Math.sin(d3 + 5.497787143782138D) * p_188205_15_; + double d14 = -1.0D + d2; + double d15 = (double)beamHeight * scale * (0.5D / p_188205_15_) + d14; + vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + vertexbuffer.pos(x + d4, y + (double)maxY, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d4, y + (double)beamY, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d6, y + (double)beamY, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d6, y + (double)maxY, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d10, y + (double)maxY, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d10, y + (double)beamY, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d8, y + (double)beamY, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d8, y + (double)maxY, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d6, y + (double)maxY, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d6, y + (double)beamY, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d10, y + (double)beamY, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d10, y + (double)maxY, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d8, y + (double)maxY, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d8, y + (double)beamY, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d4, y + (double)beamY, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + vertexbuffer.pos(x + d4, y + (double)maxY, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F).endVertex(); + tessellator.draw(); + GlStateManager.enableLighting(); + GlStateManager.enableTexture2D(); + } + +} diff --git a/src/main/java/guichaguri/betterfps/clones/tileentity/HopperLogic.java b/src/main/java/guichaguri/betterfps/clones/tileentity/HopperLogic.java index a5b7afa..ca5c05e 100644 --- a/src/main/java/guichaguri/betterfps/clones/tileentity/HopperLogic.java +++ b/src/main/java/guichaguri/betterfps/clones/tileentity/HopperLogic.java @@ -1,7 +1,7 @@ package guichaguri.betterfps.clones.tileentity; import guichaguri.betterfps.transformers.cloner.Named; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import guichaguri.betterfps.transformers.cloner.CopyMode; import guichaguri.betterfps.transformers.cloner.CopyMode.Mode; import net.minecraft.block.state.IBlockState; @@ -22,7 +22,7 @@ public class HopperLogic extends TileEntityHopper { public boolean canPickupDrops = true; public boolean isOnTransferCooldown = false; - @Named(Naming.M_captureDroppedItems) + @Named(Mappings.M_captureDroppedItems) public static boolean captureDroppedItems(IHopper hopper) { // This is to keep the same functionality in the Minecart with Hopper and other custom modded hoppers HopperLogic hopperTE = hopper.getClass() == TileEntityHopper.class ? (HopperLogic)hopper : null; @@ -90,6 +90,7 @@ public boolean isOnTransferCooldown() { } public void checkBlockOnTop() { + // Cache some values BlockPos topPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()); IBlockState state = worldObj.getBlockState(topPos); canPickupDrops = !state.getBlock().isOpaqueCube(state); diff --git a/src/main/java/guichaguri/betterfps/gui/GuiBetterFpsConfig.java b/src/main/java/guichaguri/betterfps/gui/GuiBetterFpsConfig.java index f17c85f..dedc7d5 100644 --- a/src/main/java/guichaguri/betterfps/gui/GuiBetterFpsConfig.java +++ b/src/main/java/guichaguri/betterfps/gui/GuiBetterFpsConfig.java @@ -1,6 +1,10 @@ package guichaguri.betterfps.gui; import guichaguri.betterfps.BetterFpsConfig; +import guichaguri.betterfps.BetterFpsHelper; +import guichaguri.betterfps.UpdateChecker; +import guichaguri.betterfps.gui.GuiCycleButton.GuiBooleanButton; +import guichaguri.betterfps.tweaker.BetterFpsTweaker; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -8,15 +12,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import guichaguri.betterfps.BetterFpsHelper; -import guichaguri.betterfps.gui.GuiCycleButton.GuiBooleanButton; -import guichaguri.betterfps.tweaker.BetterFpsTweaker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; import net.minecraft.util.Util; import net.minecraft.util.Util.EnumOS; +import net.minecraft.util.text.TextComponentString; import org.lwjgl.input.Mouse; /** @@ -25,9 +27,7 @@ public class GuiBetterFpsConfig extends GuiScreen { private GuiScreen parent = null; - public GuiBetterFpsConfig() { - - } + public GuiBetterFpsConfig() {} public GuiBetterFpsConfig(GuiScreen parent) { this.parent = parent; } @@ -38,14 +38,16 @@ private List initButtons() { BetterFpsConfig config = BetterFpsConfig.getConfig(); buttons.add(new AlgorithmButton(2, "Algorithm", BetterFpsHelper.displayHelpers, config.algorithm, new String[] { - "The algorithm of sine & cosine methods", - "§cRequires restarting to take effect", - "", "§eShift-click me to test algorithms §7(This will take a few seconds)", - "", "§aMore information soon" + "The algorithm for calculating sine and cosine", + "§cRequires restarting to take effect", "", + "§eShift-click me to test algorithms §7(This will take a few seconds)", "", + "§aMore information here soon", "", + "Default in Vanilla: Vanilla Algorithm", + "Default in BetterFps: Riven's \"Half\" Algorithm", })); - buttons.add(new GuiBooleanButton(3, "Update Checker", config.updateChecker, new String[] { - "Whether will check for updates on startup", - "It's highly recommended enabling this option", "", + buttons.add(new UpdateCheckerButton(3, "Update Checker", config.updateChecker, new String[] { + "Whether updates will be checked on startup", "", + "§eShift-click me to check for updates §7(This will take a few seconds)", "", "Default: On" })); buttons.add(new GuiBooleanButton(4, "Preallocate Memory", config.preallocateMemory, new String[] { @@ -54,7 +56,9 @@ private List initButtons() { "Default in Vanilla: On", "Default in BetterFps: Off", "", - "Note: This allocation will only be cleaned once the memory is almost full"})); + "Note: This allocation will be cleaned only when the memory is almost full", + "Useful for modpacks that require a lot of RAM" + })); buttons.add(new GuiBooleanButton(5, "Fast Box Render", config.fastBoxRender, new String[] { "Whether will only render the exterior of boxes.", "§cRequires restarting to take effect", "", @@ -62,22 +66,27 @@ private List initButtons() { "Default in BetterFps: On" })); buttons.add(new GuiBooleanButton(6, "Fog", config.fog, new String[] { - "Whether will render the fog.", + "Whether fog will be rendered.", "§cRequires restarting to take effect", "", "Default: On" })); buttons.add(new GuiBooleanButton(7, "Fast Hopper", config.fastHopper, new String[] { - "Whether will improve the hopper.", + "Whether hopper improvements will be enabled.", "§cRequires restarting to take effect", "", "Default in Vanilla: Off", "Default in BetterFps: On" })); buttons.add(new GuiBooleanButton(8, "Fast Beacon", config.fastBeacon, new String[] { - "Whether will improve the beacon.", + "Whether the beacon improvements will be enabled.", "§cRequires restarting to take effect", "", "Default in Vanilla: Off", "Default in BetterFps: On" })); + buttons.add(new GuiBooleanButton(9, "Fast Beacon Rendering", config.fastBeaconRender, new String[] { + "Whether the beacon glow will be removed.", + "§cRequires restarting to take effect", "", + "Default: Off" + })); return buttons; } @@ -183,6 +192,11 @@ protected void actionPerformed(GuiButton button) throws IOException { if(fastBeacon != config.fastBeacon) restart = true; config.fastBeacon = fastBeacon; + GuiCycleButton beaconRenderButton = getCycleButton(9); + boolean fastBeaconRender = beaconRenderButton.getSelectedValue(); + if(fastBeaconRender != config.fastBeaconRender) restart = true; + config.fastBeaconRender = fastBeaconRender; + BetterFpsHelper.saveConfig(); mc.displayGuiScreen(restart ? new GuiRestartDialog(parent) : parent); @@ -236,16 +250,17 @@ private void updateAlgorithm() { String line; while((line = in.readLine()) != null) { if(BetterFpsHelper.helpers.containsKey(line)) { + BetterFpsHelper.LOG.info("Found an algorithm! (" + line + ")"); for(int i = 0; i < keys.size(); i++) { if(keys.get(i).equals(line)) { key = i; - updateTitle(); break; } } } } } catch(Exception ex) {} + updateTitle(); process = null; } } @@ -261,18 +276,35 @@ public boolean shiftClick() { if((process != null) && (isRunning())) { return true; } + + BetterFpsHelper.LOG.info("Testing algorithms..."); List args = new ArrayList(); args.add(getJavaDir()); args.add("-Dtester=" + Minecraft.getMinecraft().mcDataDir.getAbsolutePath()); args.add("-cp"); args.add(BetterFpsTweaker.class.getProtectionDomain().getCodeSource().getLocation().getFile()); args.add("BetterFpsInstaller"); + try { process = new ProcessBuilder(args).start(); + displayString = "Testing..."; } catch(Exception ex) { ex.printStackTrace(); } return true; } } + + private static class UpdateCheckerButton extends GuiBooleanButton { + public UpdateCheckerButton(int buttonId, String title, boolean defaultValue, String[] helpLines) { + super(buttonId, title, defaultValue, helpLines); + } + + @Override + public boolean shiftClick() { + Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new TextComponentString("Checking updates...")); + UpdateChecker.checkForced(); + return true; + } + } } diff --git a/src/main/java/guichaguri/betterfps/transformers/CapTransformer.java b/src/main/java/guichaguri/betterfps/transformers/CapTransformer.java index 6980770..b1d27cd 100644 --- a/src/main/java/guichaguri/betterfps/transformers/CapTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/CapTransformer.java @@ -1,8 +1,8 @@ package guichaguri.betterfps.transformers; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.BetterFpsHelper; +import guichaguri.betterfps.tweaker.Mappings; import java.util.Iterator; -import guichaguri.betterfps.BetterFps; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; @@ -19,7 +19,7 @@ public class CapTransformer implements IClassTransformer { public byte[] transform(String name, String transformedName, byte[] bytes) { if(bytes == null) return null; - if(Naming.C_PrimedTNT.is(name)) { + if(Mappings.C_PrimedTNT.is(name)) { return patchEntityUpdateCap(bytes, "TNT_TICKS", "MAX_TNT_TICKS"); } @@ -37,8 +37,8 @@ private byte[] patchEntityUpdateCap(byte[] bytes, String fieldName, String maxFi while(methods.hasNext()) { MethodNode method = methods.next(); - if(Naming.M_onUpdate.is(method.name, method.desc)) { - BetterFps.log.info("Patching Entity Cap... (" + classNode.name + ")"); + if(Mappings.M_onUpdate.is(method.name, method.desc)) { + BetterFpsHelper.LOG.info("Patching Entity Cap... (" + classNode.name + ")"); InsnList list = new InsnList(); boolean b = false; diff --git a/src/main/java/guichaguri/betterfps/transformers/EventTransformer.java b/src/main/java/guichaguri/betterfps/transformers/EventTransformer.java index d09bc6e..1633a85 100644 --- a/src/main/java/guichaguri/betterfps/transformers/EventTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/EventTransformer.java @@ -1,8 +1,7 @@ package guichaguri.betterfps.transformers; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import java.util.Iterator; -import guichaguri.betterfps.BetterFps; import guichaguri.betterfps.BetterFpsHelper; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; @@ -21,19 +20,17 @@ public byte[] transform(String name, String transformedName, byte[] bytes) { if(bytes == null) return new byte[0]; try { - if(Naming.C_Minecraft.is(name)) { + if(Mappings.C_Minecraft.is(name)) { return patchClientStart(bytes); - } else if(Naming.C_KeyBinding.is(name)) { - //return patchKeyTick(bytes); TODO remove - } else if(Naming.C_World.is(name)) {//tick + } else if(Mappings.C_World.is(name)) {//tick return patchWorldTick(bytes); - } else if(Naming.C_ClientBrandRetriever.is(name)) { + } else if(Mappings.C_ClientBrandRetriever.is(name)) { return patchClientBrand(bytes); - } else if(Naming.C_WorldClient.is(name)) { + } else if(Mappings.C_WorldClient.is(name)) { return patchClientWorldLoad(bytes); - } else if(Naming.C_DedicatedServer.is(name)) { + } else if(Mappings.C_DedicatedServer.is(name)) { return patchServerStart(bytes); - } else if(Naming.C_IntegratedServer.is(name)) { + } else if(Mappings.C_IntegratedServer.is(name)) { return patchServerStart(bytes); } } catch(Exception ex) { @@ -54,8 +51,8 @@ private byte[] patchClientStart(byte[] bytes) { while(methods.hasNext()) { MethodNode method = methods.next(); - if(Naming.M_startGame.is(method.name, method.desc)) { - BetterFps.log.info("Patching Game Start..."); + if(Mappings.M_startGame.is(method.name, method.desc)) { + BetterFpsHelper.LOG.info("Patching Game Start..."); InsnList list = new InsnList(); for(AbstractInsnNode node : method.instructions.toArray()) { @@ -83,44 +80,6 @@ private byte[] patchClientStart(byte[] bytes) { return writer.toByteArray(); } - private byte[] patchKeyTick(byte[] bytes) throws Exception { - ClassNode classNode = new ClassNode(); - ClassReader classReader = new ClassReader(bytes); - classReader.accept(classNode, ClassReader.SKIP_FRAMES); - - Iterator methods = classNode.methods.iterator(); - boolean patch = false; - - while(methods.hasNext()) { - MethodNode method = methods.next(); - - if(Naming.M_onTick.is(method.name, method.desc)) { - BetterFps.log.info("Patching Key Event..."); - InsnList list = new InsnList(); - for(AbstractInsnNode node : method.instructions.toArray()) { - if(node.getOpcode() == Opcodes.RETURN) { // Just before adding the return - - list.add(new VarInsnNode(Opcodes.ILOAD, 0)); - list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, - "guichaguri/betterfps/BetterFpsClient", "keyEvent", "(I)V", false)); - - } - list.add(node); - } - - method.instructions.clear(); - method.instructions.add(list); - patch = true; - } - } - - if(!patch) return bytes; - - ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - classNode.accept(writer); - return writer.toByteArray(); - } - private byte[] patchWorldTick(byte[] bytes) { ClassNode classNode = new ClassNode(); @@ -133,8 +92,8 @@ private byte[] patchWorldTick(byte[] bytes) { while(methods.hasNext()) { MethodNode method = methods.next(); - if(Naming.M_tick.is(method.name, method.desc)) { - BetterFps.log.info("Patching World Event..."); + if(Mappings.M_tick.is(method.name, method.desc)) { + BetterFpsHelper.LOG.info("Patching World Event..."); InsnList list = new InsnList(); for(AbstractInsnNode node : method.instructions.toArray()) { if(node.getOpcode() == Opcodes.RETURN) { // Just before adding the return @@ -171,8 +130,8 @@ public byte[] patchClientBrand(byte[] bytes) { while(methods.hasNext()) { MethodNode method = methods.next(); - if(Naming.M_getClientModName.is(method.name, method.desc)) { - BetterFps.log.info("Patching Client Brand..."); + if(Mappings.M_getClientModName.is(method.name, method.desc)) { + BetterFpsHelper.LOG.info("Patching Client Brand..."); InsnList list = new InsnList(); for(AbstractInsnNode node : method.instructions.toArray()) { if(node instanceof LdcInsnNode) { @@ -204,8 +163,8 @@ public byte[] patchClientWorldLoad(byte[] bytes) { boolean patch = false; for(MethodNode method : classNode.methods) { - if(Naming.M_Constructor.is(method.name)) { - BetterFps.log.info("Patching World Client Event..."); + if(Mappings.M_Constructor.is(method.name)) { + BetterFpsHelper.LOG.info("Patching World Client Event..."); InsnList list = new InsnList(); for(AbstractInsnNode node : method.instructions.toArray()) { if(node.getOpcode() == Opcodes.RETURN) { // Just before adding the return @@ -237,8 +196,8 @@ public byte[] patchServerStart(byte[] bytes) { boolean patch = false; for(MethodNode method : classNode.methods) { - if(Naming.M_startServer.is(method.name, method.desc)) { - BetterFps.log.info("Patching Server Start Event..."); + if(Mappings.M_startServer.is(method.name, method.desc)) { + BetterFpsHelper.LOG.info("Patching Server Start Event..."); InsnList list = new InsnList(); list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "guichaguri/betterfps/BetterFps", "serverStart", "()V", false)); diff --git a/src/main/java/guichaguri/betterfps/transformers/MathTransformer.java b/src/main/java/guichaguri/betterfps/transformers/MathTransformer.java index e10e329..76cd3d8 100644 --- a/src/main/java/guichaguri/betterfps/transformers/MathTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/MathTransformer.java @@ -1,9 +1,8 @@ package guichaguri.betterfps.transformers; -import guichaguri.betterfps.BetterFps; import guichaguri.betterfps.BetterFpsConfig; import guichaguri.betterfps.BetterFpsHelper; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import java.util.Iterator; import java.util.jar.JarFile; import java.util.zip.ZipEntry; @@ -27,7 +26,7 @@ public class MathTransformer implements IClassTransformer { public byte[] transform(String name, String name2, byte[] bytes) { if(bytes == null) return new byte[0]; - if(Naming.C_MathHelper.is(name)) { + if(Mappings.C_MathHelper.is(name)) { try { return patchMath(bytes); } catch(Exception ex) { @@ -48,15 +47,15 @@ private byte[] patchMath(byte[] bytes) throws Exception { String algorithmClass = BetterFpsHelper.helpers.get(config.algorithm); if(algorithmClass == null) { - BetterFps.log.error("The algorithm is invalid. We're going to use Vanilla Algorithm instead."); + BetterFpsHelper.LOG.error("The algorithm is invalid. We're going to use Vanilla Algorithm instead."); config.algorithm = "vanilla"; } if(config.algorithm.equals("vanilla")) { - BetterFps.log.info("Letting Minecraft use " + BetterFpsHelper.displayHelpers.get(config.algorithm)); + BetterFpsHelper.LOG.info("Letting Minecraft use " + BetterFpsHelper.displayHelpers.get(config.algorithm)); return bytes; } else { - BetterFps.log.info("Patching Minecraft using " + BetterFpsHelper.displayHelpers.get(config.algorithm)); + BetterFpsHelper.LOG.info("Patching Minecraft using " + BetterFpsHelper.displayHelpers.get(config.algorithm)); } ClassReader reader; @@ -87,22 +86,22 @@ private byte[] patchMath(byte[] bytes) throws Exception { while(methods.hasNext()) { MethodNode method = methods.next(); - if(Naming.M_sin.is(method.name, method.desc)) { + if(Mappings.M_sin.is(method.name, method.desc)) { // SIN patchSin(method, mathnode, className, mathClass); patched = true; - } else if(Naming.M_cos.is(method.name, method.desc)) { + } else if(Mappings.M_cos.is(method.name, method.desc)) { // COS patchCos(method, mathnode, className, mathClass); patched = true; - } /*else if(Naming.M_StaticBlock.is(method.name, method.desc)) { + } /*else if(Mappings.M_StaticBlock.is(method.name, method.desc)) { InsnList list = new InsnList(); for(int i = 0; i < method.instructions.size(); i++) { AbstractInsnNode node = list.get(i); if(node instanceof FieldInsnNode) { FieldInsnNode field = (FieldInsnNode)node; - if(field.owner.equals(className) && Naming.F_SIN_TABLE.is(field.name, field.desc)) { + if(field.owner.equals(className) && Mappings.F_SIN_TABLE.is(field.name, field.desc)) { } } @@ -117,7 +116,7 @@ private byte[] patchMath(byte[] bytes) throws Exception { Iterator fields = classNode.fields.iterator(); while(fields.hasNext()) { FieldNode field = fields.next(); - if(Naming.F_SIN_TABLE.is(field.name, field.desc)) { // Remove this unused array to get less ram usage + if(Mappings.F_SIN_TABLE.is(field.name, field.desc)) { // Remove this unused array to get less ram usage //fields.remove(); // TODO finish break; diff --git a/src/main/java/guichaguri/betterfps/transformers/MiscTransformer.java b/src/main/java/guichaguri/betterfps/transformers/MiscTransformer.java index 1098c34..2bed764 100644 --- a/src/main/java/guichaguri/betterfps/transformers/MiscTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/MiscTransformer.java @@ -3,7 +3,7 @@ import guichaguri.betterfps.ASMUtils; import guichaguri.betterfps.BetterFpsConfig; import guichaguri.betterfps.BetterFpsHelper; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import java.util.Iterator; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; @@ -23,7 +23,7 @@ public class MiscTransformer implements IClassTransformer { public byte[] transform(String name, String transformedName, byte[] bytes) { if(bytes == null) return null; - if(Naming.C_Minecraft.is(name)) { + if(Mappings.C_Minecraft.is(name)) { return patchMinecraft(bytes); } @@ -41,7 +41,7 @@ public byte[] patchMinecraft(byte[] bytes) { Iterator i = classNode.fields.iterator(); while(i.hasNext()) { FieldNode field = i.next(); - if((!config.preallocateMemory) && (Naming.F_memoryReserve.is(field.name, field.desc))) { + if((!config.preallocateMemory) && (Mappings.F_memoryReserve.is(field.name, field.desc))) { i.remove(); patch = true; } @@ -49,14 +49,14 @@ public byte[] patchMinecraft(byte[] bytes) { for(MethodNode method : classNode.methods) { if(!config.preallocateMemory) { - if((Naming.M_freeMemory.is(method.name, method.desc)) || - (Naming.M_StaticBlock.is(method.name, method.desc))) { + if((Mappings.M_freeMemory.is(method.name, method.desc)) || + (Mappings.M_StaticBlock.is(method.name, method.desc))) { int loc = -1; for(int o = 0; o < method.instructions.size(); o++) { AbstractInsnNode node = method.instructions.get(o); if((node instanceof FieldInsnNode) && (node.getOpcode() == Opcodes.PUTSTATIC)) { FieldInsnNode field = (FieldInsnNode) node; - if(Naming.F_memoryReserve.is(field.name, field.desc)) { + if(Mappings.F_memoryReserve.is(field.name, field.desc)) { loc = o; break; } diff --git a/src/main/java/guichaguri/betterfps/transformers/VisualChunkTransformer.java b/src/main/java/guichaguri/betterfps/transformers/VisualChunkTransformer.java index f0541fb..9a4f0c2 100644 --- a/src/main/java/guichaguri/betterfps/transformers/VisualChunkTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/VisualChunkTransformer.java @@ -1,8 +1,8 @@ package guichaguri.betterfps.transformers; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.BetterFpsHelper; +import guichaguri.betterfps.tweaker.Mappings; import guichaguri.betterfps.ASMUtils; -import guichaguri.betterfps.BetterFps; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; @@ -21,37 +21,39 @@ public class VisualChunkTransformer implements IClassTransformer { public byte[] transform(String name, String transformedName, byte[] bytes) { if(bytes == null) return bytes; - if(Naming.C_WorldServer.is(name)) { + if(Mappings.C_WorldServer.is(name)) { ClassNode node = ASMUtils.readClass(bytes, 0); for(MethodNode m : node.methods) { - if(Naming.M_updateBlocks.is(m.name, m.desc)) { - BetterFps.log.info("PATCH TICK +++++++++++++++++++++++++ " + node.name); + if(Mappings.M_updateBlocks.is(m.name, m.desc)) { + BetterFpsHelper.LOG.info("PATCH TICK +++++++++++++++++++++++++ " + node.name); patchTick(m, "thunder"); } } return ASMUtils.writeClass(node, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - } else if(Naming.C_WorldClient.is(name)) { + } else if(Mappings.C_WorldClient.is(name)) { ClassNode node = ASMUtils.readClass(bytes, 0); for(MethodNode m : node.methods) { - if(Naming.M_updateBlocks.is(m.name, m.desc)) { - BetterFps.log.info("PATCH TICK +++++++++++++++++++++++++ " + node.name); + if(Mappings.M_updateBlocks.is(m.name, m.desc)) { + BetterFpsHelper.LOG.info("PATCH TICK +++++++++++++++++++++++++ " + node.name); //patchTick(m, null); } } return ASMUtils.writeClass(node, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - } else if(Naming.C_World.is(name)) { + } else if(Mappings.C_World.is(name)) { ClassNode node = ASMUtils.readClass(bytes, 0); for(MethodNode m : node.methods) { - if(Naming.M_setActivePlayerChunksAndCheckLight.is(m.name, m.desc)) { + /*if(Mappings.M_setActivePlayerChunksAndCheckLight.is(m.name, m.desc)) { patchTickableCheck(m); - } + }*/ + //TODO setActivePlayerChunksAndCheckLight was removed } return ASMUtils.writeClass(node, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - } else if(Naming.C_ChunkCoordIntPair.is(name)) { + }/* else if(Mappings.C_ChunkCoordIntPair.is(name)) { ClassNode node = ASMUtils.readClass(bytes, 0); patchChunk(node); return ASMUtils.writeClass(node, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - } + }*/ + //TODO ChunkCoordIntPair was removed return bytes; } @@ -94,13 +96,14 @@ private void patchTickableCheck(MethodNode method) { for(AbstractInsnNode node : method.instructions.toArray()) { if(node instanceof MethodInsnNode) { MethodInsnNode m = (MethodInsnNode)node; - if((Naming.C_ChunkCoordIntPair.isASM(m.owner)) && (Naming.M_Constructor.is(m.name))) { - BetterFps.log.info("Patching tickable chunks check..."); + //TODO ChunkCoordIntPair was removed + /*if((Mappings.C_ChunkCoordIntPair.isASM(m.owner)) && (Mappings.M_Constructor.is(m.name))) { + BetterFps.LOG.info("Patching tickable chunks check..."); list.add(new VarInsnNode(Opcodes.ILOAD, 6)); // i1 list.add(new VarInsnNode(Opcodes.ILOAD, 7)); // j1 list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "guichaguri/betterfps/BetterFps", "isTickable", "(II)Z", false)); m.desc = "(IIZ)V"; - } + }*/ } list.add(node); } @@ -141,11 +144,12 @@ private void patchTick(MethodNode method, String afterLdcStr) { int s = node.desc.length(); if(s <= 2) continue; String c = node.desc.substring(1, s - 1); - if(Naming.C_ChunkCoordIntPair.isASM(c)) { + //TODO ChunkCoordIntPair was removed + /*if(Mappings.C_ChunkCoordIntPair.isASM(c)) { coordName = c; lvs.add(node.index); - BetterFps.log.info("PATCH TICK ----------------------- " + node.index + " - " + method.name); - } + BetterFps.LOG.info("PATCH TICK ----------------------- " + node.index + " - " + method.name); + }*/ } if(lvs.isEmpty()) return; @@ -161,7 +165,7 @@ private void patchTick(MethodNode method, String afterLdcStr) { list.add(node); if((afterLdc) && (node instanceof LdcInsnNode)) { if(afterLdcStr.equals(((LdcInsnNode)node).cst) && lastVar != null) { - BetterFps.log.info(frames.size()); + BetterFpsHelper.LOG.info(frames.size()); addTickCheck(list, lastVar, coordName, frames.get(frame)); } } else if((node.getOpcode() == Opcodes.ASTORE) && (node instanceof VarInsnNode)) { @@ -170,7 +174,7 @@ private void patchTick(MethodNode method, String afterLdcStr) { if(afterLdc) { lastVar = var; } else { - BetterFps.log.info(frames.size()); + BetterFpsHelper.LOG.info(frames.size()); addTickCheck(list, var, coordName, frames.get(frame)); } } @@ -195,10 +199,10 @@ private void addTickCheck(InsnList list, VarInsnNode var, String coordName, Labe LabelNode l2 = new LabelNode(); list.add(l2); if(loop != null) { - BetterFps.log.info("----------- LOOP: " + loop.getOpcode()); + BetterFpsHelper.LOG.info("----------- LOOP: " + loop.getOpcode()); list.add(new JumpInsnNode(Opcodes.GOTO, loop)); } else { - BetterFps.log.info("----------- RETURN "); + BetterFpsHelper.LOG.info("----------- RETURN "); list.add(new InsnNode(Opcodes.RETURN)); //TODO continue } list.add(l1); diff --git a/src/main/java/guichaguri/betterfps/transformers/WeakerTransformer.java b/src/main/java/guichaguri/betterfps/transformers/WeakerTransformer.java index 0a634ff..34eb466 100644 --- a/src/main/java/guichaguri/betterfps/transformers/WeakerTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/WeakerTransformer.java @@ -1,6 +1,6 @@ package guichaguri.betterfps.transformers; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; @@ -23,14 +23,14 @@ public byte[] transform(String name, String transformedName, byte[] bytes) { return bytes; } - public byte[] patchWeakKeys(byte[] bytes, Naming[] fieldsToWeak) { + public byte[] patchWeakKeys(byte[] bytes, Mappings[] fieldsToWeak) { ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, ClassReader.SKIP_FRAMES); boolean patch = false; for(FieldNode field : classNode.fields) { - weakLoop: for(Naming f : fieldsToWeak) { + weakLoop: for(Mappings f : fieldsToWeak) { if(f.is(field.name, field.desc)) { String oldDesc = field.desc; field.desc = "Ljava/lang/ref/WeakReference;"; @@ -52,7 +52,7 @@ public byte[] patchWeakKeys(byte[] bytes, Naming[] fieldsToWeak) { if(node instanceof FieldInsnNode) { FieldInsnNode fNode = (FieldInsnNode)node; if(!fNode.owner.equals(classNode.name)) continue instLoop; - weakLoop: for(Naming f : fieldsToWeak) { + weakLoop: for(Mappings f : fieldsToWeak) { if(f.is(fNode.name, fNode.desc)) { fNode.desc = "Ljava/lang/ref/WeakReference;"; if(fNode.getOpcode() == Opcodes.PUTFIELD) { diff --git a/src/main/java/guichaguri/betterfps/transformers/cloner/ClonerTransformer.java b/src/main/java/guichaguri/betterfps/transformers/cloner/ClonerTransformer.java index 5264d40..bc487e2 100644 --- a/src/main/java/guichaguri/betterfps/transformers/cloner/ClonerTransformer.java +++ b/src/main/java/guichaguri/betterfps/transformers/cloner/ClonerTransformer.java @@ -2,13 +2,12 @@ import guichaguri.betterfps.ASMUtils; import guichaguri.betterfps.BetterFpsConfig; -import guichaguri.betterfps.tweaker.Naming; +import guichaguri.betterfps.tweaker.Mappings; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.jar.JarFile; import java.util.zip.ZipEntry; -import guichaguri.betterfps.BetterFps; import guichaguri.betterfps.BetterFpsHelper; import guichaguri.betterfps.transformers.cloner.CopyMode.Mode; import net.minecraft.launchwrapper.IClassTransformer; @@ -26,7 +25,7 @@ public class ClonerTransformer implements IClassTransformer { private static final List clones = new ArrayList(); - public static void add(String clazz, Naming target) { + public static void add(String clazz, Mappings target) { clones.add(new Clone(clazz.replaceAll("\\.", "/"), target)); } @@ -34,17 +33,19 @@ public static void add(String clazz, Naming target) { BetterFpsConfig config = BetterFpsConfig.getConfig(); if(config.fastBeacon) { - add("guichaguri.betterfps.clones.tileentity.BeaconLogic", Naming.C_TileEntityBeacon); + add("guichaguri.betterfps.clones.tileentity.BeaconLogic", Mappings.C_TileEntityBeacon); } + add("guichaguri.betterfps.clones.tileentity.BeaconRenderer", Mappings.C_TileEntityBeaconRenderer); + if(config.fastHopper) { - add("guichaguri.betterfps.clones.tileentity.HopperLogic", Naming.C_TileEntityHopper); - add("guichaguri.betterfps.clones.block.HopperBlock", Naming.C_BlockHopper); + add("guichaguri.betterfps.clones.tileentity.HopperLogic", Mappings.C_TileEntityHopper); + add("guichaguri.betterfps.clones.block.HopperBlock", Mappings.C_BlockHopper); } - add("guichaguri.betterfps.clones.client.ModelBoxLogic", Naming.C_ModelBox); - add("guichaguri.betterfps.clones.client.EntityRenderLogic", Naming.C_EntityRenderer); - add("guichaguri.betterfps.clones.client.GuiOptionsLogic", Naming.C_GuiOptions); + add("guichaguri.betterfps.clones.client.ModelBoxLogic", Mappings.C_ModelBox); + add("guichaguri.betterfps.clones.client.EntityRenderLogic", Mappings.C_EntityRenderer); + add("guichaguri.betterfps.clones.client.GuiOptionsLogic", Mappings.C_GuiOptions); } @Override @@ -60,7 +61,7 @@ public byte[] transform(String name, String transformedName, byte[] bytes) { } if(foundClones != null) { - BetterFps.log.info("Found " + foundClones.size() + " class patches for " + name); + BetterFpsHelper.LOG.info("Found " + foundClones.size() + " class patches for " + name); return patchClones(foundClones, bytes); } @@ -97,7 +98,7 @@ public byte[] patchClones(List clones, byte[] bytes) { fields: for(FieldNode field : cloneClass.fields) { CopyMode.Mode mode = Mode.REPLACE; - Naming name = null; + Mappings name = null; if(field.visibleAnnotations != null) { boolean canCopy = canCopy(field.visibleAnnotations); if(!canCopy) continue fields; @@ -110,7 +111,7 @@ public byte[] patchClones(List clones, byte[] bytes) { methods: for(MethodNode method : cloneClass.methods) { CopyMode.Mode mode = Mode.REPLACE; - Naming name = null; + Mappings name = null; if(method.visibleAnnotations != null) { boolean canCopy = canCopy(method.visibleAnnotations); if(!canCopy) continue methods; @@ -122,7 +123,7 @@ public byte[] patchClones(List clones, byte[] bytes) { } } catch(Exception ex) { - BetterFps.log.error("Could not patch with " + c.clonePath + ": " + ex); + BetterFpsHelper.LOG.error("Could not patch with " + c.clonePath + ": " + ex); ex.printStackTrace(); } @@ -145,10 +146,10 @@ private Mode getCopyMode(List annotations) { return Mode.REPLACE; } - private Naming getNaming(List annotations) { + private Mappings getNaming(List annotations) { for(AnnotationNode node : annotations) { if(node.desc.equals(Type.getDescriptor(Named.class))) { - Naming n = ASMUtils.getAnnotationValue(node, "value", Naming.class); + Mappings n = ASMUtils.getAnnotationValue(node, "value", Mappings.class); if(n != null) return n; } } @@ -176,7 +177,7 @@ private boolean canCopy(List annotations) { } - private void cloneField(FieldNode e, ClassNode node, Mode mode, Naming name) { + private void cloneField(FieldNode e, ClassNode node, Mode mode, Mappings name) { if(mode == Mode.IGNORE) return; for(int i = 0; i < node.fields.size(); i++) { FieldNode field = node.fields.get(i); @@ -197,7 +198,7 @@ private void cloneField(FieldNode e, ClassNode node, Mode mode, Naming name) { node.fields.add(e); } - private boolean cloneMethod(MethodNode e, ClassNode node, ClassNode original, Mode mode, Naming name) { + private boolean cloneMethod(MethodNode e, ClassNode node, ClassNode original, Mode mode, Mappings name) { if(mode == Mode.IGNORE) return false; MethodNode originalMethod = null; for(int i = 0; i < node.methods.size(); i++) { @@ -302,9 +303,9 @@ private void replaceOcurrences(MethodNode method, ClassNode classNode, ClassNode public static class Clone { public final String clonePath; - public final Naming target; + public final Mappings target; - public Clone(String clonePath, Naming target) { + public Clone(String clonePath, Mappings target) { this.clonePath = clonePath; this.target = target; } diff --git a/src/main/java/guichaguri/betterfps/transformers/cloner/Named.java b/src/main/java/guichaguri/betterfps/transformers/cloner/Named.java index 0f8b48c..0d554c8 100644 --- a/src/main/java/guichaguri/betterfps/transformers/cloner/Named.java +++ b/src/main/java/guichaguri/betterfps/transformers/cloner/Named.java @@ -1,10 +1,10 @@ package guichaguri.betterfps.transformers.cloner; +import guichaguri.betterfps.tweaker.Mappings; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import guichaguri.betterfps.tweaker.Naming; /** * @author Guilherme Chaguri @@ -13,6 +13,6 @@ @Target({ElementType.FIELD, ElementType.METHOD}) public @interface Named { - Naming value(); // Original name of the method/field + Mappings value(); // Original name of the method/field } diff --git a/src/main/java/guichaguri/betterfps/tweaker/BetterFpsTweaker.java b/src/main/java/guichaguri/betterfps/tweaker/BetterFpsTweaker.java index 0bc02f1..3e69ca4 100644 --- a/src/main/java/guichaguri/betterfps/tweaker/BetterFpsTweaker.java +++ b/src/main/java/guichaguri/betterfps/tweaker/BetterFpsTweaker.java @@ -50,6 +50,7 @@ public void acceptOptions(List args, File gameDir, File assetsDir, Strin @Override public void injectIntoClassLoader(LaunchClassLoader cl) { + loadMappings(); for(String transformer : TRANSFORMERS) { cl.registerTransformer(transformer); @@ -59,6 +60,7 @@ public void injectIntoClassLoader(LaunchClassLoader cl) { cl.addTransformerExclusion(excluded); } + cl.addClassLoaderExclusion("guichaguri.betterfps.clones"); } @Override @@ -79,4 +81,19 @@ public String[] getLaunchArguments() { return new String[0]; } + + private void loadMappings() { + BetterFpsHelper.LOG.debug("Loading Mappings..."); + try { + // Normal environment + Mappings.loadMappings(BetterFpsTweaker.class.getResourceAsStream("betterfps.srg")); + } catch(Exception ex) { + try { + // Dev environment + Mappings.loadMappings(BetterFpsTweaker.class.getClassLoader().getResourceAsStream("betterfps.srg")); + } catch(Exception ex2) { + BetterFpsHelper.LOG.error("Could not load mappings. Things will not work!"); + } + } + } } diff --git a/src/main/java/guichaguri/betterfps/tweaker/Mappings.java b/src/main/java/guichaguri/betterfps/tweaker/Mappings.java new file mode 100644 index 0000000..5cb5029 --- /dev/null +++ b/src/main/java/guichaguri/betterfps/tweaker/Mappings.java @@ -0,0 +1,164 @@ +package guichaguri.betterfps.tweaker; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; + +/** + * + * @author Guilherme Chaguri + */ +public enum Mappings { // TODO BUKKIT + + // Prefixes + // C_ is for classes + // M_ is for methods + // F_ is for fields + + M_StaticBlock(Type.METHOD, "StaticBlock", ""), + M_Constructor(Type.METHOD, "Constructor", ""), + + C_Minecraft(Type.CLASS, "Minecraft"), + C_World(Type.CLASS, "World"), + C_Chunk(Type.CLASS, "Chunk"), + C_EntityPlayer(Type.CLASS, "EntityPlayer"), + C_MathHelper(Type.CLASS, "MathHelper"), + C_PrimedTNT(Type.CLASS, "EntityTNTPrimed"), + C_ClientBrandRetriever(Type.CLASS, "ClientBrandRetriever"), + C_GuiOptions(Type.CLASS, "GuiOptions"), + C_WorldClient(Type.CLASS, "WorldClient"), + C_WorldServer(Type.CLASS, "WorldServer"), + C_IntegratedServer(Type.CLASS, "IntegratedServer"), + C_DedicatedServer(Type.CLASS, "DedicatedServer"), + C_TileEntityBeacon(Type.CLASS, "TileEntityBeacon"), + C_TileEntityBeaconRenderer(Type.CLASS, "TileEntityBeaconRenderer"), + C_BeamSegment(Type.CLASS, "TileEntityBeacon$BeamSegment"), + C_TileEntityHopper(Type.CLASS, "TileEntityHopper"), + C_BlockHopper(Type.CLASS, "BlockHopper"), + C_ModelBox(Type.CLASS, "ModelBox"), + C_EntityRenderer(Type.CLASS, "EntityRenderer"), + + M_startGame(Type.METHOD, "startGame"), // Minecraft + M_sin(Type.METHOD, "sin"), // MathHelper + M_cos(Type.METHOD, "cos"), // MathHelper + M_tick(Type.METHOD, "tick"), // World + M_onUpdate(Type.METHOD, "onUpdate"), // Entity + M_updateBlocks(Type.METHOD, "updateBlocks"), // World + M_getClientModName(Type.METHOD, "getClientModName"), // ClientBrandRetriever + M_freeMemory(Type.METHOD, "freeMemory"), // Minecraft + M_initGui(Type.METHOD, "initGui"), // GuiScreen + M_startServer(Type.METHOD, "startServer"), // MinecraftServer + M_captureDroppedItems(Type.METHOD, "captureDroppedItems"), // TileEntityHopper + + F_memoryReserve(Type.FIELD, "memoryReserve"), // Minecraft + F_SIN_TABLE(Type.FIELD, "SIN_TABLE"); // MathHelper + + public static void loadMappings(InputStream srg) throws IOException { + List lines = IOUtils.readLines(srg, "UTF-8"); + for(String line : lines) { + String[] m = line.split(" "); + String identifier = m[m.length - 1]; + + for(Mappings mp : values()) { + if(m[0].equals("CL:")) { + if(m.length >= 4 && mp.type == Type.CLASS && mp.identifier.equals(identifier)) { + mp.deobfName = m[2]; + mp.obfName = m[1]; + } + } else if(m[0].equals("FD:")) { + if(m.length >= 4 && mp.type == Type.FIELD && mp.identifier.equals(identifier)) { + loadNames(m, mp, 2, 1); + } + } else if(m[0].equals("MD:")) { + if(m.length >= 6 && mp.type == Type.METHOD && mp.identifier.equals(identifier)) { + loadNames(m, mp, 3, 1); + mp.deobfDesc = m[4]; + mp.obfDesc = m[2]; + } + } + } + } + } + + private static void loadNames(String[] m, Mappings mp, int deobf, int obf) { + String[] name = m[deobf].split("/"); + mp.deobfName = name[name.length - 1]; + mp.ownerDeobfName = StringUtils.join(name, "/", 0, name.length - 1); + + name = m[obf].split("/"); + mp.obfName = name[name.length - 1]; + mp.ownerObfName = StringUtils.join(name, "/", 0, name.length - 1); + } + + public final Type type; + public final String identifier; + protected String deobfName, obfName; + protected String ownerDeobfName, ownerObfName; + protected String deobfDesc, obfDesc; + + Mappings(Type type, String identifier) { + this.type = type; + this.identifier = identifier; + } + + Mappings(Type type, String identifier, String name) { + this(type, identifier); + this.deobfName = name; + this.obfName = name; + } + + public boolean is(String n) { + n = n.replaceAll("\\.", "/"); + return deobfName.equals(n) || obfName.equals(n); + } + + public boolean isObf(String n) { + return !deobfName.equals(obfName) && obfName.equals(n.replaceAll("\\.", "/")); + } + + public boolean isDesc(String n) { + return deobfDesc == null || obfDesc == null || n.equals(deobfDesc) || n.equals(obfDesc); + } + + public boolean isOwner(String n) { + n = n.replaceAll("\\.", "/"); + return ownerDeobfName == null || ownerObfName == null || n.equals(ownerDeobfName) || n.equals(ownerObfName); + } + + public boolean is(String n, String d) { + return is(n) && isDesc(d); + } + + public boolean is(MethodNode method) { + return (method.name.equals(deobfName) || method.name.equals(obfName)) && isDesc(method.desc); + } + + public boolean is(FieldNode field) { + return (field.name.equals(deobfName) || field.name.equals(obfName)) && isDesc(field.desc); + } + + public boolean is(MethodInsnNode method) { + return is(method.name) && isDesc(method.desc) && isOwner(method.owner); + } + + public boolean is(FieldInsnNode field) { + return is(field.name) && isDesc(field.desc) && isOwner(field.owner); + } + + @Override + public String toString() { + return identifier; + } + + + enum Type { + CLASS, METHOD, FIELD + } + +} diff --git a/src/main/java/guichaguri/betterfps/tweaker/Naming.java b/src/main/java/guichaguri/betterfps/tweaker/Naming.java deleted file mode 100644 index 76e748d..0000000 --- a/src/main/java/guichaguri/betterfps/tweaker/Naming.java +++ /dev/null @@ -1,120 +0,0 @@ -package guichaguri.betterfps.tweaker; - -/** - * - * @author Guilherme Chaguri - */ -public enum Naming { // TODO BUKKIT - - // Prefixes - // C_ is for classes - // M_ is for methods - // F_ is for fields - - M_StaticBlock("", null, null, "()V"), - M_Constructor("", null, null, "()V"), - - C_Minecraft("net.minecraft.client.Minecraft", null), //TODO obfuscated - C_KeyBinding("net.minecraft.client.settings.KeyBinding", null), //TODO obfuscated - C_World("net.minecraft.world.World", null, null), //TODO obfuscated + bukkit - C_Chunk("net.minecraft.world.chunk.Chunk", null, null), // TODO obfuscated + bukkit - C_ChunkCoordIntPair("net.minecraft.world.ChunkCoordIntPair", null, null), // TODO obfuscated + bukkit - C_EntityPlayer("net.minecraft.entity.player.EntityPlayer", null, null), // TODO obfuscated + bukkit - C_MathHelper("net.minecraft.util.MathHelper", null, null), // TODO obfuscated + bukkit - C_PrimedTNT("net.minecraft.entity.item.EntityTNTPrimed", null, null), //TODO obfuscated + bukkit - C_ClientBrandRetriever("net.minecraft.client.ClientBrandRetriever", null), - C_GuiOptions("net.minecraft.client.gui.GuiOptions", null), //TODO obfuscated - C_WorldClient("net.minecraft.client.multiplayer.WorldClient", null), // TODO obfuscated - C_WorldServer("net.minecraft.world.WorldServer", null, null), // TODO obfuscated + bukkit - C_IntegratedServer("net.minecraft.server.integrated.IntegratedServer", null), // TODO obfuscated - C_DedicatedServer("net.minecraft.server.dedicated.DedicatedServer", null, null), // TODO obfuscated + bukkit - C_TileEntityBeacon("net.minecraft.tileentity.TileEntityBeacon", null, null), // TODO obfuscated + bukkit - C_BeamSegment("net.minecraft.tileentity.TileEntityBeacon$BeamSegment", null, null), // TODO obfuscated + bukkit - C_TileEntityHopper("net.minecraft.tileentity.TileEntityHopper", null, null), // TODO obfuscated + bukkit - C_BlockHopper("net.minecraft.block.BlockHopper", null, null), // TODO obfuscated + bukkit - C_ModelBox("net.minecraft.client.model.ModelBox", null), // TODO obfuscated - C_EntityRenderer("net.minecraft.client.renderer.EntityRenderer", null), - - M_startGame("startGame", null, null, "()V"), //TODO obfuscated // Minecraft - M_onTick("onTick", null, null, "(I)V"), //TODO obfuscated // KeyBinding - M_sin("sin", "a", null, "(F)F"), // MathHelper - M_cos("cos", "b", null, "(F)F"), // MathHelper - M_tick("tick", null, null, "()V"), //TODO obfuscated // World - M_onUpdate("onUpdate", null, null, "()V"), //TODO obfuscated // Entity - M_updateBlocks("updateBlocks", null, null, "()V"), // TODO obfuscated // World - M_getClientModName("getClientModName", null, null, "()Ljava/lang/String;"), // ClientBrandRetriever - M_freeMemory("freeMemory", null, null, "()V"), // TODO obfuscated // Minecraft - M_initGui("initGui", null, null, "()V"), // TODO obfuscated // GuiScreen - M_startServer("startServer", null, null, "()Z"), // TODO obfuscated // MinecraftServer - M_setActivePlayerChunksAndCheckLight("setActivePlayerChunksAndCheckLight", null, null, "()V"), // TODO obfuscated // World - M_captureDroppedItems("captureDroppedItems", null, null, null), // TODO obfuscated // TileEntityHopper - - F_memoryReserve("memoryReserve", null, null, "[B"), // TODO obfuscated // Minecraft - F_SIN_TABLE("SIN_TABLE", "a", null, "[F"); // MathHelper - - - private String deob; - private String deobRepl; - private String ob; - private String obRepl; - private String bukkit; - private String bukkitRepl; - - private boolean useOb = false; - private boolean useBukkit = false; - - // Only used for methods and fields - private String desc; - - // For client classes only - Naming(String deob, String ob) { - this(deob, ob, null); - } - - // For common classes - Naming(String deob, String ob, String bukkit) { - this.deob = deob; - this.deobRepl = deob.replaceAll("\\.", "/"); - if(ob != null) { - this.useOb = true; - this.ob = ob; - this.obRepl = ob.replaceAll("\\.", "/"); - } - if(bukkit != null) { - this.useBukkit = true; - this.bukkit = bukkit; - this.bukkitRepl = bukkit.replaceAll("\\.", "/"); - } - } - - // For methods/fields - Naming(String deob, String ob, String bukkit, String desc) { - this(deob, ob, bukkit); - this.desc = desc; - } - - // Used to check names - public boolean is(String name) { - if(name.equals(deob)) return true; - if(useOb && name.equals(ob)) return true; - if(useBukkit && name.equals(bukkit)) return true; - return false; - } - - // Used to check class names inside ASM - public boolean isASM(String name) { - if(name.equals(deobRepl)) return true; - if(useOb && name.equals(obRepl)) return true; - if(useBukkit && name.equals(bukkitRepl)) return true; - return false; - } - - // Used to check names and desc - public boolean is(String name, String desc) { - if((this.desc.equals(desc)) && (is(name))) { - return true; - } - return false; - } - -}