Commit 1dd64987f1b054d2d9e8e3b75bd657c4a7cc8c82
1 parent
171e491f
moving PrivateFields to common and adding PrivateFieldsClient for client side
Showing
7 changed files
with
153 additions
and
86 deletions
debug/obfuscation.properties
| ... | ... | @@ -18,6 +18,7 @@ field_71477_af=serverPort |
| 18 | 18 | field_147712_ad=shaderResourceLocations |
| 19 | 19 | field_147713_ae=shaderIndex |
| 20 | 20 | field_175083_ad=useShader |
| 21 | +field_149528_b=view | |
| 21 | 22 | func_148833_a=processPacket |
| 22 | 23 | func_71411_J=runGameLoop |
| 23 | 24 | func_71407_l=runTick |
| ... | ... | @@ -52,4 +53,11 @@ func_71370_a=resize |
| 52 | 53 | func_175069_a=loadShader |
| 53 | 54 | func_78481_a=getFOVModifier |
| 54 | 55 | func_78479_a=setupCameraTransform |
| 55 | -func_147693_a=loadSoundResource | |
| 56 | 56 | \ No newline at end of file |
| 57 | +func_147693_a=loadSoundResource | |
| 58 | +func_180784_a=onBlockClicked | |
| 59 | +func_180236_a=activateBlockOrUseItem | |
| 60 | +func_147346_a=processPlayerBlockPlacement | |
| 61 | +func_175087_a=handleAnimation | |
| 62 | +func_147345_a=processPlayerDigging | |
| 63 | +func_71190_q=updateTimeLightAndEntities | |
| 64 | +func_180031_a=checkThreadAndEnqueue | |
| 57 | 65 | \ No newline at end of file | ... | ... |
java/client/com/mumfrey/liteloader/client/ClientPluginChannelsClient.java
| ... | ... | @@ -12,7 +12,7 @@ import net.minecraft.network.play.client.C17PacketCustomPayload; |
| 12 | 12 | import net.minecraft.network.play.server.S01PacketJoinGame; |
| 13 | 13 | import net.minecraft.network.play.server.S3FPacketCustomPayload; |
| 14 | 14 | |
| 15 | -import com.mumfrey.liteloader.client.util.PrivateFields; | |
| 15 | +import com.mumfrey.liteloader.client.util.PrivateFieldsClient; | |
| 16 | 16 | import com.mumfrey.liteloader.core.ClientPluginChannels; |
| 17 | 17 | import com.mumfrey.liteloader.core.exceptions.UnregisteredChannelException; |
| 18 | 18 | |
| ... | ... | @@ -67,7 +67,7 @@ public class ClientPluginChannelsClient extends ClientPluginChannels |
| 67 | 67 | { |
| 68 | 68 | if (netHandler instanceof INetHandlerLoginClient) |
| 69 | 69 | { |
| 70 | - NetworkManager networkManager = PrivateFields.netManager.get(((NetHandlerLoginClient)netHandler)); | |
| 70 | + NetworkManager networkManager = PrivateFieldsClient.netManager.get(((NetHandlerLoginClient)netHandler)); | |
| 71 | 71 | networkManager.sendPacket(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); |
| 72 | 72 | } |
| 73 | 73 | else if (netHandler instanceof INetHandlerPlayClient) | ... | ... |
java/client/com/mumfrey/liteloader/client/SoundHandlerReloadInhibitor.java
| ... | ... | @@ -6,7 +6,7 @@ import net.minecraft.client.audio.SoundHandler; |
| 6 | 6 | import net.minecraft.client.resources.IResourceManagerReloadListener; |
| 7 | 7 | import net.minecraft.client.resources.SimpleReloadableResourceManager; |
| 8 | 8 | |
| 9 | -import com.mumfrey.liteloader.client.util.PrivateFields; | |
| 9 | +import com.mumfrey.liteloader.client.util.PrivateFieldsClient; | |
| 10 | 10 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
| 11 | 11 | |
| 12 | 12 | /** |
| ... | ... | @@ -53,7 +53,7 @@ public class SoundHandlerReloadInhibitor |
| 53 | 53 | { |
| 54 | 54 | if (!this.inhibited) |
| 55 | 55 | { |
| 56 | - List<IResourceManagerReloadListener> reloadListeners = PrivateFields.reloadListeners.get(this.resourceManager); | |
| 56 | + List<IResourceManagerReloadListener> reloadListeners = PrivateFieldsClient.reloadListeners.get(this.resourceManager); | |
| 57 | 57 | if (reloadListeners != null) |
| 58 | 58 | { |
| 59 | 59 | this.storedIndex = reloadListeners.indexOf(this.soundHandler); |
| ... | ... | @@ -87,7 +87,7 @@ public class SoundHandlerReloadInhibitor |
| 87 | 87 | { |
| 88 | 88 | if (this.inhibited) |
| 89 | 89 | { |
| 90 | - List<IResourceManagerReloadListener> reloadListeners = PrivateFields.reloadListeners.get(this.resourceManager); | |
| 90 | + List<IResourceManagerReloadListener> reloadListeners = PrivateFieldsClient.reloadListeners.get(this.resourceManager); | |
| 91 | 91 | if (reloadListeners != null) |
| 92 | 92 | { |
| 93 | 93 | if (this.storedIndex > -1) | ... | ... |
java/client/com/mumfrey/liteloader/client/util/PrivateFieldsClient.java
0 → 100644
| 1 | +package com.mumfrey.liteloader.client.util; | |
| 2 | + | |
| 3 | +import java.util.IdentityHashMap; | |
| 4 | +import java.util.List; | |
| 5 | +import java.util.Map; | |
| 6 | + | |
| 7 | +import net.minecraft.client.network.NetHandlerLoginClient; | |
| 8 | +import net.minecraft.client.renderer.entity.RenderManager; | |
| 9 | +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; | |
| 10 | +import net.minecraft.client.resources.IResourceManagerReloadListener; | |
| 11 | +import net.minecraft.client.resources.SimpleReloadableResourceManager; | |
| 12 | +import net.minecraft.network.NetworkManager; | |
| 13 | +import net.minecraft.tileentity.TileEntity; | |
| 14 | +import net.minecraft.util.ObjectIntIdentityMap; | |
| 15 | +import net.minecraft.util.RegistryNamespaced; | |
| 16 | +import net.minecraft.util.RegistrySimple; | |
| 17 | + | |
| 18 | +import com.mumfrey.liteloader.core.runtime.Obf; | |
| 19 | +import com.mumfrey.liteloader.util.PrivateFields; | |
| 20 | + | |
| 21 | +@SuppressWarnings("rawtypes") | |
| 22 | +public class PrivateFieldsClient<P, T> extends PrivateFields<P, T> | |
| 23 | +{ | |
| 24 | + private PrivateFieldsClient(Class<P> owner, Obf obf) | |
| 25 | + { | |
| 26 | + super(owner, obf); | |
| 27 | + } | |
| 28 | + | |
| 29 | + public static final PrivateFieldsClient<RenderManager, Map> entityRenderMap = new PrivateFieldsClient<RenderManager, Map> (RenderManager.class, Obf.entityRenderMap); | |
| 30 | + public static final PrivateFieldsClient<NetHandlerLoginClient, NetworkManager> netManager = new PrivateFieldsClient<NetHandlerLoginClient, NetworkManager> (NetHandlerLoginClient.class, Obf.networkManager); | |
| 31 | + public static final PrivateFieldsClient<RegistrySimple, Map> registryObjects = new PrivateFieldsClient<RegistrySimple, Map> (RegistrySimple.class, Obf.registryObjects); | |
| 32 | + public static final PrivateFieldsClient<RegistryNamespaced, ObjectIntIdentityMap> underlyingIntegerMap = new PrivateFieldsClient<RegistryNamespaced, ObjectIntIdentityMap>(RegistryNamespaced.class, Obf.underlyingIntegerMap); | |
| 33 | + public static final PrivateFieldsClient<ObjectIntIdentityMap, IdentityHashMap> identityMap = new PrivateFieldsClient<ObjectIntIdentityMap, IdentityHashMap> (ObjectIntIdentityMap.class, Obf.identityMap); | |
| 34 | + public static final PrivateFieldsClient<ObjectIntIdentityMap, List> objectList = new PrivateFieldsClient<ObjectIntIdentityMap, List> (ObjectIntIdentityMap.class, Obf.objectList); | |
| 35 | + public static final PrivateFieldsClient<TileEntityRendererDispatcher, Map> specialRendererMap = new PrivateFieldsClient<TileEntityRendererDispatcher, Map> (TileEntityRendererDispatcher.class, Obf.mapSpecialRenderers); | |
| 36 | + public static final PrivateFieldsClient<TileEntity, Map> tileEntityNameToClassMap = new PrivateFieldsClient<TileEntity, Map> (TileEntity.class, Obf.tileEntityNameToClassMap); | |
| 37 | + public static final PrivateFieldsClient<TileEntity, Map> tileEntityClassToNameMap = new PrivateFieldsClient<TileEntity, Map> (TileEntity.class, Obf.tileEntityClassToNameMap); | |
| 38 | + | |
| 39 | + public static final PrivateFieldsClient<SimpleReloadableResourceManager, List<IResourceManagerReloadListener>> reloadListeners = | |
| 40 | + new PrivateFieldsClient<SimpleReloadableResourceManager, List<IResourceManagerReloadListener>>(SimpleReloadableResourceManager.class, Obf.reloadListeners); | |
| 41 | +} | |
| 0 | 42 | \ No newline at end of file | ... | ... |
java/client/com/mumfrey/liteloader/util/ModUtilities.java
| ... | ... | @@ -6,13 +6,8 @@ import java.util.IdentityHashMap; |
| 6 | 6 | import java.util.List; |
| 7 | 7 | import java.util.Map; |
| 8 | 8 | |
| 9 | -import org.lwjgl.LWJGLException; | |
| 10 | -import org.lwjgl.opengl.Display; | |
| 11 | -import org.lwjgl.opengl.DisplayMode; | |
| 12 | - | |
| 13 | 9 | import net.minecraft.block.Block; |
| 14 | 10 | import net.minecraft.client.Minecraft; |
| 15 | -import net.minecraft.client.renderer.Tessellator; | |
| 16 | 11 | import net.minecraft.client.renderer.entity.Render; |
| 17 | 12 | import net.minecraft.client.renderer.entity.RenderManager; |
| 18 | 13 | import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; |
| ... | ... | @@ -21,16 +16,18 @@ import net.minecraft.entity.Entity; |
| 21 | 16 | import net.minecraft.init.Blocks; |
| 22 | 17 | import net.minecraft.init.Items; |
| 23 | 18 | import net.minecraft.item.Item; |
| 24 | -import net.minecraft.launchwrapper.IClassTransformer; | |
| 25 | -import net.minecraft.launchwrapper.Launch; | |
| 26 | 19 | import net.minecraft.tileentity.TileEntity; |
| 27 | 20 | import net.minecraft.util.ObjectIntIdentityMap; |
| 28 | 21 | import net.minecraft.util.RegistryNamespaced; |
| 29 | 22 | import net.minecraft.util.RegistrySimple; |
| 30 | 23 | import net.minecraft.util.ResourceLocation; |
| 31 | 24 | |
| 25 | +import org.lwjgl.LWJGLException; | |
| 26 | +import org.lwjgl.opengl.Display; | |
| 27 | +import org.lwjgl.opengl.DisplayMode; | |
| 28 | + | |
| 32 | 29 | import com.mumfrey.liteloader.client.overlays.IMinecraft; |
| 33 | -import com.mumfrey.liteloader.client.util.PrivateFields; | |
| 30 | +import com.mumfrey.liteloader.client.util.PrivateFieldsClient; | |
| 34 | 31 | import com.mumfrey.liteloader.core.runtime.Obf; |
| 35 | 32 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
| 36 | 33 | |
| ... | ... | @@ -42,41 +39,11 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
| 42 | 39 | public abstract class ModUtilities |
| 43 | 40 | { |
| 44 | 41 | /** |
| 45 | - * True if FML is being used, in which case we use searge names instead of raw field/method names | |
| 46 | - */ | |
| 47 | - private static boolean fmlDetected = false; | |
| 48 | - | |
| 49 | - private static boolean seargeNames = false; | |
| 50 | - | |
| 51 | - static | |
| 52 | - { | |
| 53 | - // Check for FML | |
| 54 | - ModUtilities.fmlDetected = ModUtilities.fmlIsPresent(); | |
| 55 | - | |
| 56 | - try | |
| 57 | - { | |
| 58 | - Minecraft.class.getDeclaredField("running"); | |
| 59 | - } | |
| 60 | - catch (SecurityException ex) | |
| 61 | - { | |
| 62 | - } | |
| 63 | - catch (NoSuchFieldException ex) | |
| 64 | - { | |
| 65 | - ModUtilities.seargeNames = true; | |
| 66 | - } | |
| 67 | - } | |
| 68 | - | |
| 69 | - /** | |
| 70 | 42 | * @return true if FML is present in the current environment |
| 71 | 43 | */ |
| 72 | 44 | public static boolean fmlIsPresent() |
| 73 | 45 | { |
| 74 | -// if (ClientBrandRetriever.getClientModName().contains("fml")) return true; | |
| 75 | - | |
| 76 | - for (IClassTransformer transformer : Launch.classLoader.getTransformers()) | |
| 77 | - if (transformer.getClass().getName().contains("fml")) return true; | |
| 78 | - | |
| 79 | - return false; | |
| 46 | + return Obf.fmlIsPresent(); | |
| 80 | 47 | } |
| 81 | 48 | |
| 82 | 49 | public static void setWindowSize(int width, int height) |
| ... | ... | @@ -105,7 +72,7 @@ public abstract class ModUtilities |
| 105 | 72 | { |
| 106 | 73 | RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); |
| 107 | 74 | |
| 108 | - Map<Class<? extends Entity>, Render> entityRenderMap = PrivateFields.entityRenderMap.get(renderManager); | |
| 75 | + Map<Class<? extends Entity>, Render> entityRenderMap = PrivateFieldsClient.entityRenderMap.get(renderManager); | |
| 109 | 76 | if (entityRenderMap != null) |
| 110 | 77 | { |
| 111 | 78 | entityRenderMap.put(entityClass, renderer); |
| ... | ... | @@ -123,7 +90,7 @@ public abstract class ModUtilities |
| 123 | 90 | |
| 124 | 91 | try |
| 125 | 92 | { |
| 126 | - Map<Class<? extends TileEntity>, TileEntitySpecialRenderer> specialRendererMap = PrivateFields.specialRendererMap.get(tileEntityRenderer); | |
| 93 | + Map<Class<? extends TileEntity>, TileEntitySpecialRenderer> specialRendererMap = PrivateFieldsClient.specialRendererMap.get(tileEntityRenderer); | |
| 127 | 94 | specialRendererMap.put(tileEntityClass, renderer); |
| 128 | 95 | renderer.setRendererDispatcher(tileEntityRenderer); |
| 129 | 96 | } |
| ... | ... | @@ -228,8 +195,8 @@ public abstract class ModUtilities |
| 228 | 195 | { |
| 229 | 196 | try |
| 230 | 197 | { |
| 231 | - Map<String, Class<? extends TileEntity>> nameToClassMap = PrivateFields.tileEntityNameToClassMap.get(null); | |
| 232 | - Map<Class<? extends TileEntity>, String> classToNameMap = PrivateFields.tileEntityClassToNameMap.get(null); | |
| 198 | + Map<String, Class<? extends TileEntity>> nameToClassMap = PrivateFieldsClient.tileEntityNameToClassMap.get(null); | |
| 199 | + Map<Class<? extends TileEntity>, String> classToNameMap = PrivateFieldsClient.tileEntityClassToNameMap.get(null); | |
| 233 | 200 | |
| 234 | 201 | nameToClassMap.put(entityName, tileEntityClass); |
| 235 | 202 | classToNameMap.put(tileEntityClass, entityName); |
| ... | ... | @@ -248,8 +215,7 @@ public abstract class ModUtilities |
| 248 | 215 | */ |
| 249 | 216 | public static String getObfuscatedFieldName(String fieldName, String obfuscatedFieldName, String seargeFieldName) |
| 250 | 217 | { |
| 251 | - boolean deobfuscated = Tessellator.class.getSimpleName().equals("Tessellator"); | |
| 252 | - return deobfuscated ? (ModUtilities.seargeNames ? seargeFieldName : fieldName) : (ModUtilities.fmlDetected ? seargeFieldName : obfuscatedFieldName); | |
| 218 | + return Obf.getObfuscatedFieldName(fieldName, obfuscatedFieldName, seargeFieldName); | |
| 253 | 219 | } |
| 254 | 220 | |
| 255 | 221 | /** |
| ... | ... | @@ -260,8 +226,7 @@ public abstract class ModUtilities |
| 260 | 226 | */ |
| 261 | 227 | public static String getObfuscatedFieldName(Obf obf) |
| 262 | 228 | { |
| 263 | - boolean deobfuscated = Tessellator.class.getSimpleName().equals("Tessellator"); | |
| 264 | - return deobfuscated ? (ModUtilities.seargeNames ? obf.srg : obf.name) : (ModUtilities.fmlDetected ? obf.srg : obf.obf); | |
| 229 | + return Obf.getObfuscatedFieldName(obf); | |
| 265 | 230 | } |
| 266 | 231 | |
| 267 | 232 | @SuppressWarnings("unchecked") |
| ... | ... | @@ -274,10 +239,10 @@ public abstract class ModUtilities |
| 274 | 239 | if (registry instanceof RegistryNamespaced) |
| 275 | 240 | { |
| 276 | 241 | RegistryNamespaced rns = (RegistryNamespaced)registry; |
| 277 | - underlyingIntegerMap = PrivateFields.underlyingIntegerMap.get(rns); | |
| 242 | + underlyingIntegerMap = PrivateFieldsClient.underlyingIntegerMap.get(rns); | |
| 278 | 243 | } |
| 279 | 244 | |
| 280 | - Map<K, V> registryObjects = PrivateFields.registryObjects.get(registry); | |
| 245 | + Map<K, V> registryObjects = PrivateFieldsClient.registryObjects.get(registry); | |
| 281 | 246 | if (registryObjects != null) |
| 282 | 247 | { |
| 283 | 248 | V existingValue = registryObjects.get(key); |
| ... | ... | @@ -287,8 +252,8 @@ public abstract class ModUtilities |
| 287 | 252 | |
| 288 | 253 | if (underlyingIntegerMap != null) |
| 289 | 254 | { |
| 290 | - IdentityHashMap<V, Integer> identityMap = PrivateFields.identityMap.get(underlyingIntegerMap); | |
| 291 | - List<V> objectList = PrivateFields.objectList.get(underlyingIntegerMap); | |
| 255 | + IdentityHashMap<V, Integer> identityMap = PrivateFieldsClient.identityMap.get(underlyingIntegerMap); | |
| 256 | + List<V> objectList = PrivateFieldsClient.objectList.get(underlyingIntegerMap); | |
| 292 | 257 | if (identityMap != null) identityMap.remove(existingValue); |
| 293 | 258 | if (objectList != null) objectList.remove(existingValue); |
| 294 | 259 | } | ... | ... |
java/common/com/mumfrey/liteloader/core/runtime/Obf.java
| ... | ... | @@ -7,6 +7,10 @@ import java.util.HashMap; |
| 7 | 7 | import java.util.Map; |
| 8 | 8 | import java.util.Properties; |
| 9 | 9 | |
| 10 | +import net.minecraft.launchwrapper.IClassTransformer; | |
| 11 | +import net.minecraft.launchwrapper.Launch; | |
| 12 | +import net.minecraft.server.MinecraftServer; | |
| 13 | + | |
| 10 | 14 | /** |
| 11 | 15 | * Centralised obfuscation table for LiteLoader |
| 12 | 16 | * |
| ... | ... | @@ -70,6 +74,14 @@ public class Obf |
| 70 | 74 | public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" ); |
| 71 | 75 | public static final Obf GuiTextField = new Obf("net.minecraft.client.gui.GuiTextField", "bul" ); |
| 72 | 76 | public static final Obf SoundHandler = new Obf("net.minecraft.client.audio.SoundHandler", "czh" ); |
| 77 | + public static final Obf BlockPos = new Obf("net.minecraft.util.BlockPos", "dt" ); | |
| 78 | + public static final Obf EnumFacing = new Obf("net.minecraft.util.EnumFacing", "ej" ); | |
| 79 | + public static final Obf ItemInWorldManager = new Obf("net.minecraft.server.management.ItemInWorldManager", "qx" ); | |
| 80 | + public static final Obf NetHandlerPlayServer = new Obf("net.minecraft.network.NetHandlerPlayServer", "rj" ); | |
| 81 | + public static final Obf EntityPlayer = new Obf("net.minecraft.entity.player.EntityPlayer", "ahd" ); | |
| 82 | + public static final Obf World = new Obf("net.minecraft.world.World", "aqu" ); | |
| 83 | + public static final Obf ItemStack = new Obf("net.minecraft.item.ItemStack", "amj" ); | |
| 84 | + public static final Obf PacketThreadUtil = new Obf("net.minecraft.network.PacketThreadUtil", "ig" ); | |
| 73 | 85 | |
| 74 | 86 | // Fields |
| 75 | 87 | // ----------------------------------------------------------------------------------------- |
| ... | ... | @@ -93,6 +105,7 @@ public class Obf |
| 93 | 105 | public static final Obf shaderResourceLocations = new Obf("field_147712_ad", "ab" ); |
| 94 | 106 | public static final Obf shaderIndex = new Obf("field_147713_ae", "ac" ); |
| 95 | 107 | public static final Obf useShader = new Obf("field_175083_ad", "ad" ); |
| 108 | + public static final Obf viewDistance = new Obf("field_149528_b", "b" ); | |
| 96 | 109 | |
| 97 | 110 | // Methods |
| 98 | 111 | // ----------------------------------------------------------------------------------------- |
| ... | ... | @@ -132,6 +145,13 @@ public class Obf |
| 132 | 145 | public static final Obf getFOVModifier = new Obf("func_78481_a", "a" ); |
| 133 | 146 | public static final Obf setupCameraTransform = new Obf("func_78479_a", "a" ); |
| 134 | 147 | public static final Obf loadSoundResource = new Obf("func_147693_a", "a" ); |
| 148 | + public static final Obf onBlockClicked = new Obf("func_180784_a", "a" ); | |
| 149 | + public static final Obf activateBlockOrUseItem = new Obf("func_180236_a", "a" ); | |
| 150 | + public static final Obf processPlayerBlockPlacement = new Obf("func_147346_a", "a" ); | |
| 151 | + public static final Obf handleAnimation = new Obf("func_175087_a", "a" ); | |
| 152 | + public static final Obf processPlayerDigging = new Obf("func_147345_a", "a" ); | |
| 153 | + public static final Obf updateTimeLightAndEntities = new Obf("func_71190_q", "z" ); | |
| 154 | + public static final Obf checkThreadAndEnqueue = new Obf("func_180031_a", "a" ); | |
| 135 | 155 | |
| 136 | 156 | public static final int MCP = 0; |
| 137 | 157 | public static final int SRG = 1; |
| ... | ... | @@ -383,4 +403,61 @@ public class Obf |
| 383 | 403 | return this.ordinal; |
| 384 | 404 | } |
| 385 | 405 | } |
| 406 | + | |
| 407 | + /** | |
| 408 | + * True if FML is being used, in which case we use searge names instead of raw field/method names | |
| 409 | + */ | |
| 410 | + private static boolean fmlDetected = false; | |
| 411 | + | |
| 412 | + private static boolean seargeNames = false; | |
| 413 | + | |
| 414 | + static | |
| 415 | + { | |
| 416 | + // Check for FML | |
| 417 | + Obf.fmlDetected = Obf.fmlIsPresent(); | |
| 418 | + | |
| 419 | + try | |
| 420 | + { | |
| 421 | + MinecraftServer.class.getDeclaredField("serverRunning"); | |
| 422 | + } | |
| 423 | + catch (SecurityException ex) | |
| 424 | + { | |
| 425 | + } | |
| 426 | + catch (NoSuchFieldException ex) | |
| 427 | + { | |
| 428 | + Obf.seargeNames = true; | |
| 429 | + } | |
| 430 | + } | |
| 431 | + | |
| 432 | + public static boolean fmlIsPresent() | |
| 433 | + { | |
| 434 | + for (IClassTransformer transformer : Launch.classLoader.getTransformers()) | |
| 435 | + if (transformer.getClass().getName().contains("fml")) return true; | |
| 436 | + | |
| 437 | + return false; | |
| 438 | + } | |
| 439 | + | |
| 440 | + /** | |
| 441 | + * Abstraction helper function | |
| 442 | + * | |
| 443 | + * @param fieldName Name of field to get, returned unmodified if in debug mode | |
| 444 | + * @return Obfuscated field name if present | |
| 445 | + */ | |
| 446 | + public static String getObfuscatedFieldName(String fieldName, String obfuscatedFieldName, String seargeFieldName) | |
| 447 | + { | |
| 448 | + boolean deobfuscated = MinecraftServer.class.getSimpleName().equals("MinecraftServer"); | |
| 449 | + return deobfuscated ? (Obf.seargeNames ? seargeFieldName : fieldName) : (Obf.fmlDetected ? seargeFieldName : obfuscatedFieldName); | |
| 450 | + } | |
| 451 | + | |
| 452 | + /** | |
| 453 | + * Abstraction helper function | |
| 454 | + * | |
| 455 | + * @param obf Field to get, returned unmodified if in debug mode | |
| 456 | + * @return Obfuscated field name if present | |
| 457 | + */ | |
| 458 | + public static String getObfuscatedFieldName(Obf obf) | |
| 459 | + { | |
| 460 | + boolean deobfuscated = MinecraftServer.class.getSimpleName().equals("MinecraftServer"); | |
| 461 | + return deobfuscated ? (Obf.seargeNames ? obf.srg : obf.name) : (Obf.fmlDetected ? obf.srg : obf.obf); | |
| 462 | + } | |
| 386 | 463 | } | ... | ... |
java/client/com/mumfrey/liteloader/client/util/PrivateFields.java renamed to java/common/com/mumfrey/liteloader/util/PrivateFields.java
| 1 | -package com.mumfrey.liteloader.client.util; | |
| 1 | +package com.mumfrey.liteloader.util; | |
| 2 | 2 | |
| 3 | 3 | import java.lang.reflect.Field; |
| 4 | 4 | import java.lang.reflect.Modifier; |
| 5 | -import java.util.IdentityHashMap; | |
| 6 | -import java.util.List; | |
| 7 | -import java.util.Map; | |
| 8 | 5 | |
| 9 | -import net.minecraft.client.network.NetHandlerLoginClient; | |
| 10 | -import net.minecraft.client.renderer.entity.RenderManager; | |
| 11 | -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; | |
| 12 | -import net.minecraft.client.resources.IResourceManagerReloadListener; | |
| 13 | -import net.minecraft.client.resources.SimpleReloadableResourceManager; | |
| 14 | -import net.minecraft.network.NetworkManager; | |
| 15 | -import net.minecraft.tileentity.TileEntity; | |
| 16 | -import net.minecraft.util.ObjectIntIdentityMap; | |
| 17 | -import net.minecraft.util.RegistryNamespaced; | |
| 18 | -import net.minecraft.util.RegistrySimple; | |
| 6 | +import net.minecraft.network.play.client.C15PacketClientSettings; | |
| 19 | 7 | |
| 20 | 8 | import com.mumfrey.liteloader.core.runtime.Obf; |
| 21 | -import com.mumfrey.liteloader.util.ModUtilities; | |
| 22 | 9 | |
| 23 | 10 | /** |
| 24 | 11 | * Wrapper for obf/mcp reflection-accessed private fields, mainly added to centralise the locations I have to update the obfuscated field names |
| ... | ... | @@ -28,7 +15,6 @@ import com.mumfrey.liteloader.util.ModUtilities; |
| 28 | 15 | * @param <P> Parent class type, the type of the class that owns the field |
| 29 | 16 | * @param <T> Field type, the type of the field value |
| 30 | 17 | */ |
| 31 | -@SuppressWarnings("rawtypes") | |
| 32 | 18 | public class PrivateFields<P, T> |
| 33 | 19 | { |
| 34 | 20 | /** |
| ... | ... | @@ -51,7 +37,7 @@ public class PrivateFields<P, T> |
| 51 | 37 | protected PrivateFields(Class<P> owner, Obf obf) |
| 52 | 38 | { |
| 53 | 39 | this.parentClass = owner; |
| 54 | - this.fieldName = ModUtilities.getObfuscatedFieldName(obf); | |
| 40 | + this.fieldName = Obf.getObfuscatedFieldName(obf); | |
| 55 | 41 | } |
| 56 | 42 | |
| 57 | 43 | /** |
| ... | ... | @@ -137,17 +123,7 @@ public class PrivateFields<P, T> |
| 137 | 123 | |
| 138 | 124 | return value; |
| 139 | 125 | } |
| 140 | - | |
| 141 | - public static final PrivateFields<RenderManager, Map> entityRenderMap = new PrivateFields<RenderManager, Map> (RenderManager.class, Obf.entityRenderMap); | |
| 142 | - public static final PrivateFields<NetHandlerLoginClient, NetworkManager> netManager = new PrivateFields<NetHandlerLoginClient, NetworkManager> (NetHandlerLoginClient.class, Obf.networkManager); | |
| 143 | - public static final PrivateFields<RegistrySimple, Map> registryObjects = new PrivateFields<RegistrySimple, Map> (RegistrySimple.class, Obf.registryObjects); | |
| 144 | - public static final PrivateFields<RegistryNamespaced, ObjectIntIdentityMap> underlyingIntegerMap = new PrivateFields<RegistryNamespaced, ObjectIntIdentityMap>(RegistryNamespaced.class, Obf.underlyingIntegerMap); | |
| 145 | - public static final PrivateFields<ObjectIntIdentityMap, IdentityHashMap> identityMap = new PrivateFields<ObjectIntIdentityMap, IdentityHashMap> (ObjectIntIdentityMap.class, Obf.identityMap); | |
| 146 | - public static final PrivateFields<ObjectIntIdentityMap, List> objectList = new PrivateFields<ObjectIntIdentityMap, List> (ObjectIntIdentityMap.class, Obf.objectList); | |
| 147 | - public static final PrivateFields<TileEntityRendererDispatcher, Map> specialRendererMap = new PrivateFields<TileEntityRendererDispatcher, Map> (TileEntityRendererDispatcher.class, Obf.mapSpecialRenderers); | |
| 148 | - public static final PrivateFields<TileEntity, Map> tileEntityNameToClassMap = new PrivateFields<TileEntity, Map> (TileEntity.class, Obf.tileEntityNameToClassMap); | |
| 149 | - public static final PrivateFields<TileEntity, Map> tileEntityClassToNameMap = new PrivateFields<TileEntity, Map> (TileEntity.class, Obf.tileEntityClassToNameMap); | |
| 150 | 126 | |
| 151 | - public static final PrivateFields<SimpleReloadableResourceManager, List<IResourceManagerReloadListener>> reloadListeners = | |
| 152 | - new PrivateFields<SimpleReloadableResourceManager, List<IResourceManagerReloadListener>>(SimpleReloadableResourceManager.class, Obf.reloadListeners); | |
| 127 | + public static final PrivateFields<C15PacketClientSettings, Integer> viewDistance = new PrivateFields<C15PacketClientSettings, Integer>(C15PacketClientSettings.class, Obf.viewDistance); | |
| 128 | + | |
| 153 | 129 | } |
| 154 | 130 | \ No newline at end of file | ... | ... |