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,6 +18,7 @@ field_71477_af=serverPort | ||
| 18 | field_147712_ad=shaderResourceLocations | 18 | field_147712_ad=shaderResourceLocations |
| 19 | field_147713_ae=shaderIndex | 19 | field_147713_ae=shaderIndex |
| 20 | field_175083_ad=useShader | 20 | field_175083_ad=useShader |
| 21 | +field_149528_b=view | ||
| 21 | func_148833_a=processPacket | 22 | func_148833_a=processPacket |
| 22 | func_71411_J=runGameLoop | 23 | func_71411_J=runGameLoop |
| 23 | func_71407_l=runTick | 24 | func_71407_l=runTick |
| @@ -52,4 +53,11 @@ func_71370_a=resize | @@ -52,4 +53,11 @@ func_71370_a=resize | ||
| 52 | func_175069_a=loadShader | 53 | func_175069_a=loadShader |
| 53 | func_78481_a=getFOVModifier | 54 | func_78481_a=getFOVModifier |
| 54 | func_78479_a=setupCameraTransform | 55 | func_78479_a=setupCameraTransform |
| 55 | -func_147693_a=loadSoundResource | ||
| 56 | \ No newline at end of file | 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 | \ No newline at end of file | 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,7 +12,7 @@ import net.minecraft.network.play.client.C17PacketCustomPayload; | ||
| 12 | import net.minecraft.network.play.server.S01PacketJoinGame; | 12 | import net.minecraft.network.play.server.S01PacketJoinGame; |
| 13 | import net.minecraft.network.play.server.S3FPacketCustomPayload; | 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 | import com.mumfrey.liteloader.core.ClientPluginChannels; | 16 | import com.mumfrey.liteloader.core.ClientPluginChannels; |
| 17 | import com.mumfrey.liteloader.core.exceptions.UnregisteredChannelException; | 17 | import com.mumfrey.liteloader.core.exceptions.UnregisteredChannelException; |
| 18 | 18 | ||
| @@ -67,7 +67,7 @@ public class ClientPluginChannelsClient extends ClientPluginChannels | @@ -67,7 +67,7 @@ public class ClientPluginChannelsClient extends ClientPluginChannels | ||
| 67 | { | 67 | { |
| 68 | if (netHandler instanceof INetHandlerLoginClient) | 68 | if (netHandler instanceof INetHandlerLoginClient) |
| 69 | { | 69 | { |
| 70 | - NetworkManager networkManager = PrivateFields.netManager.get(((NetHandlerLoginClient)netHandler)); | 70 | + NetworkManager networkManager = PrivateFieldsClient.netManager.get(((NetHandlerLoginClient)netHandler)); |
| 71 | networkManager.sendPacket(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); | 71 | networkManager.sendPacket(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); |
| 72 | } | 72 | } |
| 73 | else if (netHandler instanceof INetHandlerPlayClient) | 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,7 +6,7 @@ import net.minecraft.client.audio.SoundHandler; | ||
| 6 | import net.minecraft.client.resources.IResourceManagerReloadListener; | 6 | import net.minecraft.client.resources.IResourceManagerReloadListener; |
| 7 | import net.minecraft.client.resources.SimpleReloadableResourceManager; | 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 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | 10 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| @@ -53,7 +53,7 @@ public class SoundHandlerReloadInhibitor | @@ -53,7 +53,7 @@ public class SoundHandlerReloadInhibitor | ||
| 53 | { | 53 | { |
| 54 | if (!this.inhibited) | 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 | if (reloadListeners != null) | 57 | if (reloadListeners != null) |
| 58 | { | 58 | { |
| 59 | this.storedIndex = reloadListeners.indexOf(this.soundHandler); | 59 | this.storedIndex = reloadListeners.indexOf(this.soundHandler); |
| @@ -87,7 +87,7 @@ public class SoundHandlerReloadInhibitor | @@ -87,7 +87,7 @@ public class SoundHandlerReloadInhibitor | ||
| 87 | { | 87 | { |
| 88 | if (this.inhibited) | 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 | if (reloadListeners != null) | 91 | if (reloadListeners != null) |
| 92 | { | 92 | { |
| 93 | if (this.storedIndex > -1) | 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 | \ No newline at end of file | 42 | \ No newline at end of file |
java/client/com/mumfrey/liteloader/util/ModUtilities.java
| @@ -6,13 +6,8 @@ import java.util.IdentityHashMap; | @@ -6,13 +6,8 @@ import java.util.IdentityHashMap; | ||
| 6 | import java.util.List; | 6 | import java.util.List; |
| 7 | import java.util.Map; | 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 | import net.minecraft.block.Block; | 9 | import net.minecraft.block.Block; |
| 14 | import net.minecraft.client.Minecraft; | 10 | import net.minecraft.client.Minecraft; |
| 15 | -import net.minecraft.client.renderer.Tessellator; | ||
| 16 | import net.minecraft.client.renderer.entity.Render; | 11 | import net.minecraft.client.renderer.entity.Render; |
| 17 | import net.minecraft.client.renderer.entity.RenderManager; | 12 | import net.minecraft.client.renderer.entity.RenderManager; |
| 18 | import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; | 13 | import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; |
| @@ -21,16 +16,18 @@ import net.minecraft.entity.Entity; | @@ -21,16 +16,18 @@ import net.minecraft.entity.Entity; | ||
| 21 | import net.minecraft.init.Blocks; | 16 | import net.minecraft.init.Blocks; |
| 22 | import net.minecraft.init.Items; | 17 | import net.minecraft.init.Items; |
| 23 | import net.minecraft.item.Item; | 18 | import net.minecraft.item.Item; |
| 24 | -import net.minecraft.launchwrapper.IClassTransformer; | ||
| 25 | -import net.minecraft.launchwrapper.Launch; | ||
| 26 | import net.minecraft.tileentity.TileEntity; | 19 | import net.minecraft.tileentity.TileEntity; |
| 27 | import net.minecraft.util.ObjectIntIdentityMap; | 20 | import net.minecraft.util.ObjectIntIdentityMap; |
| 28 | import net.minecraft.util.RegistryNamespaced; | 21 | import net.minecraft.util.RegistryNamespaced; |
| 29 | import net.minecraft.util.RegistrySimple; | 22 | import net.minecraft.util.RegistrySimple; |
| 30 | import net.minecraft.util.ResourceLocation; | 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 | import com.mumfrey.liteloader.client.overlays.IMinecraft; | 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 | import com.mumfrey.liteloader.core.runtime.Obf; | 31 | import com.mumfrey.liteloader.core.runtime.Obf; |
| 35 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | 32 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
| 36 | 33 | ||
| @@ -42,41 +39,11 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | @@ -42,41 +39,11 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
| 42 | public abstract class ModUtilities | 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 | * @return true if FML is present in the current environment | 42 | * @return true if FML is present in the current environment |
| 71 | */ | 43 | */ |
| 72 | public static boolean fmlIsPresent() | 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 | public static void setWindowSize(int width, int height) | 49 | public static void setWindowSize(int width, int height) |
| @@ -105,7 +72,7 @@ public abstract class ModUtilities | @@ -105,7 +72,7 @@ public abstract class ModUtilities | ||
| 105 | { | 72 | { |
| 106 | RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); | 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 | if (entityRenderMap != null) | 76 | if (entityRenderMap != null) |
| 110 | { | 77 | { |
| 111 | entityRenderMap.put(entityClass, renderer); | 78 | entityRenderMap.put(entityClass, renderer); |
| @@ -123,7 +90,7 @@ public abstract class ModUtilities | @@ -123,7 +90,7 @@ public abstract class ModUtilities | ||
| 123 | 90 | ||
| 124 | try | 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 | specialRendererMap.put(tileEntityClass, renderer); | 94 | specialRendererMap.put(tileEntityClass, renderer); |
| 128 | renderer.setRendererDispatcher(tileEntityRenderer); | 95 | renderer.setRendererDispatcher(tileEntityRenderer); |
| 129 | } | 96 | } |
| @@ -228,8 +195,8 @@ public abstract class ModUtilities | @@ -228,8 +195,8 @@ public abstract class ModUtilities | ||
| 228 | { | 195 | { |
| 229 | try | 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 | nameToClassMap.put(entityName, tileEntityClass); | 201 | nameToClassMap.put(entityName, tileEntityClass); |
| 235 | classToNameMap.put(tileEntityClass, entityName); | 202 | classToNameMap.put(tileEntityClass, entityName); |
| @@ -248,8 +215,7 @@ public abstract class ModUtilities | @@ -248,8 +215,7 @@ public abstract class ModUtilities | ||
| 248 | */ | 215 | */ |
| 249 | public static String getObfuscatedFieldName(String fieldName, String obfuscatedFieldName, String seargeFieldName) | 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,8 +226,7 @@ public abstract class ModUtilities | ||
| 260 | */ | 226 | */ |
| 261 | public static String getObfuscatedFieldName(Obf obf) | 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 | @SuppressWarnings("unchecked") | 232 | @SuppressWarnings("unchecked") |
| @@ -274,10 +239,10 @@ public abstract class ModUtilities | @@ -274,10 +239,10 @@ public abstract class ModUtilities | ||
| 274 | if (registry instanceof RegistryNamespaced) | 239 | if (registry instanceof RegistryNamespaced) |
| 275 | { | 240 | { |
| 276 | RegistryNamespaced rns = (RegistryNamespaced)registry; | 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 | if (registryObjects != null) | 246 | if (registryObjects != null) |
| 282 | { | 247 | { |
| 283 | V existingValue = registryObjects.get(key); | 248 | V existingValue = registryObjects.get(key); |
| @@ -287,8 +252,8 @@ public abstract class ModUtilities | @@ -287,8 +252,8 @@ public abstract class ModUtilities | ||
| 287 | 252 | ||
| 288 | if (underlyingIntegerMap != null) | 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 | if (identityMap != null) identityMap.remove(existingValue); | 257 | if (identityMap != null) identityMap.remove(existingValue); |
| 293 | if (objectList != null) objectList.remove(existingValue); | 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,6 +7,10 @@ import java.util.HashMap; | ||
| 7 | import java.util.Map; | 7 | import java.util.Map; |
| 8 | import java.util.Properties; | 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 | * Centralised obfuscation table for LiteLoader | 15 | * Centralised obfuscation table for LiteLoader |
| 12 | * | 16 | * |
| @@ -70,6 +74,14 @@ public class Obf | @@ -70,6 +74,14 @@ public class Obf | ||
| 70 | public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" ); | 74 | public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" ); |
| 71 | public static final Obf GuiTextField = new Obf("net.minecraft.client.gui.GuiTextField", "bul" ); | 75 | public static final Obf GuiTextField = new Obf("net.minecraft.client.gui.GuiTextField", "bul" ); |
| 72 | public static final Obf SoundHandler = new Obf("net.minecraft.client.audio.SoundHandler", "czh" ); | 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 | // Fields | 86 | // Fields |
| 75 | // ----------------------------------------------------------------------------------------- | 87 | // ----------------------------------------------------------------------------------------- |
| @@ -93,6 +105,7 @@ public class Obf | @@ -93,6 +105,7 @@ public class Obf | ||
| 93 | public static final Obf shaderResourceLocations = new Obf("field_147712_ad", "ab" ); | 105 | public static final Obf shaderResourceLocations = new Obf("field_147712_ad", "ab" ); |
| 94 | public static final Obf shaderIndex = new Obf("field_147713_ae", "ac" ); | 106 | public static final Obf shaderIndex = new Obf("field_147713_ae", "ac" ); |
| 95 | public static final Obf useShader = new Obf("field_175083_ad", "ad" ); | 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 | // Methods | 110 | // Methods |
| 98 | // ----------------------------------------------------------------------------------------- | 111 | // ----------------------------------------------------------------------------------------- |
| @@ -132,6 +145,13 @@ public class Obf | @@ -132,6 +145,13 @@ public class Obf | ||
| 132 | public static final Obf getFOVModifier = new Obf("func_78481_a", "a" ); | 145 | public static final Obf getFOVModifier = new Obf("func_78481_a", "a" ); |
| 133 | public static final Obf setupCameraTransform = new Obf("func_78479_a", "a" ); | 146 | public static final Obf setupCameraTransform = new Obf("func_78479_a", "a" ); |
| 134 | public static final Obf loadSoundResource = new Obf("func_147693_a", "a" ); | 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 | public static final int MCP = 0; | 156 | public static final int MCP = 0; |
| 137 | public static final int SRG = 1; | 157 | public static final int SRG = 1; |
| @@ -383,4 +403,61 @@ public class Obf | @@ -383,4 +403,61 @@ public class Obf | ||
| 383 | return this.ordinal; | 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 | import java.lang.reflect.Field; | 3 | import java.lang.reflect.Field; |
| 4 | import java.lang.reflect.Modifier; | 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 | import com.mumfrey.liteloader.core.runtime.Obf; | 8 | import com.mumfrey.liteloader.core.runtime.Obf; |
| 21 | -import com.mumfrey.liteloader.util.ModUtilities; | ||
| 22 | 9 | ||
| 23 | /** | 10 | /** |
| 24 | * Wrapper for obf/mcp reflection-accessed private fields, mainly added to centralise the locations I have to update the obfuscated field names | 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,7 +15,6 @@ import com.mumfrey.liteloader.util.ModUtilities; | ||
| 28 | * @param <P> Parent class type, the type of the class that owns the field | 15 | * @param <P> Parent class type, the type of the class that owns the field |
| 29 | * @param <T> Field type, the type of the field value | 16 | * @param <T> Field type, the type of the field value |
| 30 | */ | 17 | */ |
| 31 | -@SuppressWarnings("rawtypes") | ||
| 32 | public class PrivateFields<P, T> | 18 | public class PrivateFields<P, T> |
| 33 | { | 19 | { |
| 34 | /** | 20 | /** |
| @@ -51,7 +37,7 @@ public class PrivateFields<P, T> | @@ -51,7 +37,7 @@ public class PrivateFields<P, T> | ||
| 51 | protected PrivateFields(Class<P> owner, Obf obf) | 37 | protected PrivateFields(Class<P> owner, Obf obf) |
| 52 | { | 38 | { |
| 53 | this.parentClass = owner; | 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,17 +123,7 @@ public class PrivateFields<P, T> | ||
| 137 | 123 | ||
| 138 | return value; | 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 | \ No newline at end of file | 130 | \ No newline at end of file |