mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Use ATed methods & fields instead of ReflectionUtils. Removed ObfuscatedNames as no longer needed.
This commit is contained in:
1 parent
7640990aa2
commit
a30f3e076b
8 files changed
+23
-93
No files matched your search
@@ -4,7 +4,6 @@ import static mekanism.client.sound.SoundHandler.Channel.FLAMETHROWER;
|
||||
import static mekanism.client.sound.SoundHandler.Channel.GASMASK;
|
||||
import static mekanism.client.sound.SoundHandler.Channel.JETPACK;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -21,7 +20,6 @@ import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.CommonPlayerTickHandler;
|
||||
import mekanism.common.KeySync;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.config.MekanismConfig.client;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
@@ -45,7 +43,6 @@ import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
|
||||
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
||||
import mekanism.common.util.ListUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.ReflectionUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
@@ -484,17 +481,12 @@ public class ClientTickHandler
|
||||
|
||||
public static void setCape(AbstractClientPlayer player, ResourceLocation cape)
|
||||
{
|
||||
try {
|
||||
Method m = ReflectionUtils.getPrivateMethod(AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_getPlayerInfo);
|
||||
Object obj = m.invoke(player);
|
||||
|
||||
if(obj instanceof NetworkPlayerInfo)
|
||||
{
|
||||
NetworkPlayerInfo info = (NetworkPlayerInfo)obj;
|
||||
Map<MinecraftProfileTexture.Type, ResourceLocation> map = (Map<MinecraftProfileTexture.Type, ResourceLocation>)ReflectionUtils.getPrivateValue(info, NetworkPlayerInfo.class, ObfuscatedNames.NetworkPlayerInfo_playerTextures);
|
||||
map.put(MinecraftProfileTexture.Type.CAPE, cape);
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
NetworkPlayerInfo info = player.getPlayerInfo();
|
||||
|
||||
if (info != null) {
|
||||
Map<MinecraftProfileTexture.Type, ResourceLocation> map = info.playerTextures;
|
||||
map.put(MinecraftProfileTexture.Type.CAPE, cape);
|
||||
}
|
||||
}
|
||||
|
||||
public static void killDeadNetworks()
|
||||
|
||||
@@ -4,8 +4,6 @@ import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.client.gui.IGuiWrapper;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.util.ReflectionUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -46,12 +44,8 @@ public abstract class GuiElement
|
||||
{
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int size = (Integer)ReflectionUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize);
|
||||
ReflectionUtils.setPrivateValue(guiObj, size + xSize, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
GuiContainer guiC = ((GuiContainer)guiObj);
|
||||
guiC.xSize += xSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +53,8 @@ public abstract class GuiElement
|
||||
{
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int size = (Integer)ReflectionUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize);
|
||||
ReflectionUtils.setPrivateValue(guiObj, size + ySize, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
GuiContainer guiC = ((GuiContainer)guiObj);
|
||||
guiC.ySize += ySize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +62,8 @@ public abstract class GuiElement
|
||||
{
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int left = (Integer)ReflectionUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
|
||||
ReflectionUtils.setPrivateValue(guiObj, left + guiLeft, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
GuiContainer guiC = ((GuiContainer)guiObj);
|
||||
guiC.guiLeft += guiLeft;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +71,8 @@ public abstract class GuiElement
|
||||
{
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int top = (Integer)ReflectionUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop);
|
||||
ReflectionUtils.setPrivateValue(guiObj, top + guiTop, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
GuiContainer guiC = ((GuiContainer)guiObj);
|
||||
guiC.guiTop += guiTop;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ import mekanism.client.render.tileentity.RenderFluidTank;
|
||||
import mekanism.client.render.tileentity.RenderThermalEvaporationController;
|
||||
import mekanism.client.render.transmitter.RenderLogisticalTransporter;
|
||||
import mekanism.client.render.transmitter.RenderMechanicalPipe;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.base.IMetaItem;
|
||||
import mekanism.common.util.ReflectionUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
@@ -265,7 +263,7 @@ public class MekanismRenderer
|
||||
|
||||
public static boolean isDrawing(VertexBuffer buffer)
|
||||
{
|
||||
return (boolean)ReflectionUtils.getPrivateValue(buffer, VertexBuffer.class, ObfuscatedNames.VertexBuffer_isDrawing);
|
||||
return buffer.isDrawing;
|
||||
}
|
||||
|
||||
public static class Model3D
|
||||
@@ -539,12 +537,9 @@ public class MekanismRenderer
|
||||
|
||||
public static float getPartialTick()
|
||||
{
|
||||
try {
|
||||
Timer t = (Timer)ReflectionUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer);
|
||||
return t.renderPartialTicks;
|
||||
} catch(Exception e) {}
|
||||
|
||||
return 0;
|
||||
Timer t = Minecraft.getMinecraft().timer;
|
||||
return t.renderPartialTicks;
|
||||
|
||||
}
|
||||
|
||||
public static ResourceLocation getBlocksTexture()
|
||||
|
||||
@@ -3,9 +3,7 @@ package mekanism.client.sound;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.config.MekanismConfig.client;
|
||||
import mekanism.common.util.ReflectionUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
@@ -118,11 +116,7 @@ public class SoundHandler
|
||||
|
||||
public static SoundManager getSoundManager()
|
||||
{
|
||||
try {
|
||||
return (SoundManager)ReflectionUtils.getPrivateValue(mc.getSoundHandler(), net.minecraft.client.audio.SoundHandler.class, ObfuscatedNames.SoundHandler_sndManager);
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
return mc.getSoundHandler().sndManager;
|
||||
}
|
||||
|
||||
//Fudge required because sound thread gets behind and the biMap crashes when rapidly toggling sounds.
|
||||
@@ -130,11 +124,7 @@ public class SoundHandler
|
||||
{
|
||||
if(invPlayingSounds == null)
|
||||
{
|
||||
try {
|
||||
invPlayingSounds = (Map<ISound, String>)ReflectionUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, ObfuscatedNames.SoundManager_invPlayingSounds);
|
||||
} catch(Exception e) {
|
||||
invPlayingSounds = null;
|
||||
}
|
||||
invPlayingSounds = getSoundManager().invPlayingSounds;
|
||||
}
|
||||
|
||||
return invPlayingSounds;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class CommonPlayerTickHandler
|
||||
|
||||
if(player instanceof EntityPlayerMP)
|
||||
{
|
||||
ReflectionUtils.setPrivateValue(((EntityPlayerMP)player).connection, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
((EntityPlayerMP)player).connection.floatingTickCount = 0;
|
||||
}
|
||||
|
||||
jetpack.useGas(stack);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package mekanism.common;
|
||||
|
||||
public final class ObfuscatedNames
|
||||
{
|
||||
public static String[] Minecraft_timer = new String[] {"timer", "field_71428_T"};
|
||||
public static String[] GuiContainer_xSize = new String[] {"xSize", "field_146999_f"};
|
||||
public static String[] GuiContainer_ySize = new String[] {"ySize", "field_147000_g"};
|
||||
public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_147003_i"};
|
||||
public static String[] GuiContainer_guiTop = new String[] {"guiTop", "field_147009_r"};
|
||||
public static String[] NetHandlerPlayServer_floatingTickCount = new String[] {"floatingTickCount", "field_147365_f"};
|
||||
public static String[] SoundHandler_sndManager = new String[] {"sndManager", "field_147694_f"};
|
||||
public static String[] SoundManager_sndSystem = new String[] {"sndSystem", "field_148620_e"};
|
||||
public static String[] SoundManager_invPlayingSounds = new String[] {"invPlayingSounds", "field_148630_i"};
|
||||
public static String[] AbstractClientPlayer_getPlayerInfo = new String[] {"getPlayerInfo", "func_175155_b"};
|
||||
public static String[] NetworkPlayerInfo_playerTextures = new String[] {"playerTextures", "field_187107_a"};
|
||||
public static String[] Entity_copyDataFromOld = new String[] {"copyDataFromOld", "func_180432_n"};
|
||||
public static String[] VertexBuffer_isDrawing = new String[] {"isDrawing", "field_179010_r"};
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import java.util.UUID;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
import mekanism.common.frequency.FrequencyManager;
|
||||
@@ -17,12 +16,10 @@ import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.network.PacketPortableTeleporter.PortableTeleporterMessage;
|
||||
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import mekanism.common.util.ReflectionUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
@@ -125,7 +122,7 @@ public class PacketPortableTeleporter implements IMessageHandler<PortableTelepor
|
||||
|
||||
if(player instanceof EntityPlayerMP)
|
||||
{
|
||||
ReflectionUtils.setPrivateValue(((EntityPlayerMP)player).connection, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
((EntityPlayerMP)player).connection.floatingTickCount = 0;
|
||||
}
|
||||
|
||||
player.closeScreen();
|
||||
|
||||
@@ -2,7 +2,6 @@ package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -14,7 +13,6 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
@@ -35,7 +33,6 @@ import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.tile.prefab.TileEntityElectricBlock;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.ReflectionUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -441,12 +438,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
if(e != null)
|
||||
{
|
||||
try {
|
||||
Method m = ReflectionUtils.getPrivateMethod(Entity.class, ObfuscatedNames.Entity_copyDataFromOld, Entity.class);
|
||||
m.invoke(e, entity);
|
||||
} catch(Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
e.copyDataFromOld(entity);
|
||||
|
||||
world.spawnEntity(e);
|
||||
teleporter.didTeleport.add(e.getPersistentID());
|
||||
|
||||
Reference in new issue
Block a user