Merge branch '1.11' into 1.12

* 1.11:
  remove some now redundant variable assignments
  add `FMLAT` line to core jar manifest
  Use ATed methods & fields instead of ReflectionUtils. Removed ObfuscatedNames as no longer needed.
  add access transformer

Conflicts:
	src/main/java/mekanism/client/render/MekanismRenderer.java
	src/main/java/mekanism/common/ObfuscatedNames.java
	src/main/java/mekanism/common/network/PacketPortableTeleporter.java
This commit is contained in:
aidancbrady committed 2017-08-16 14:02:27 -04:00
commit 2c4ba7543d
12 files changed
+167 -179

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,11 @@ 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) {
info.playerTextures.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,7 @@ 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)guiObj).xSize += xSize;
}
}
@@ -59,12 +52,7 @@ 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)guiObj).ySize += ySize;
}
}
@@ -72,12 +60,7 @@ 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)guiObj).guiLeft += guiLeft;
}
}
@@ -85,12 +68,7 @@ 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)guiObj).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;
@@ -259,12 +257,12 @@ public class MekanismRenderer
public static boolean isDrawing(Tessellator tess)
{
return isDrawing(tess.getBuffer());
return tess.getBuffer().isDrawing;
}
public static boolean isDrawing(BufferBuilder buffer)
{
return (boolean)ReflectionUtils.getPrivateValue(buffer, BufferBuilder.class, ObfuscatedNames.VertexBuffer_isDrawing);
return buffer.isDrawing;
}
public static class Model3D
@@ -65,7 +65,7 @@ public abstract class RenderTransmitterBase<T extends TileEntityTransmitter> ext
public void renderTransparency(BufferBuilder renderer, TextureAtlasSprite icon, IBakedModel cc, ColourRGBA color)
{
if(!MekanismRenderer.isDrawing(renderer))
if(!renderer.isDrawing)
{
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
}
@@ -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;
@@ -112,26 +110,13 @@ 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.
public static Map<ISound, String> getSoundMap()
{
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;
}
}
return invPlayingSounds;
return mc.getSoundHandler().sndManager.invPlayingSounds;
}
public static boolean canRestartSound(ITickableSound sound)
@@ -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);
@@ -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;
@@ -38,110 +35,113 @@ public class PacketPortableTeleporter implements IMessageHandler<PortableTelepor
{
EntityPlayer player = PacketHandler.getPlayer(context);
PacketHandler.handlePacket(() ->
{
ItemStack itemstack = player.getHeldItem(message.currentHand);
World world = player.world;
if(!itemstack.isEmpty() && itemstack.getItem() instanceof ItemPortableTeleporter)
{
ItemPortableTeleporter item = (ItemPortableTeleporter)itemstack.getItem();
switch(message.packetType)
{
case DATA_REQUEST:
sendDataResponse(message.frequency, world, player, item, itemstack, message.currentHand);
break;
case DATA_RESPONSE:
Mekanism.proxy.handleTeleporterUpdate(message);
break;
case SET_FREQ:
FrequencyManager manager1 = getManager(message.frequency.isPublic() ? null : player.getUniqueID(), world);
Frequency toUse = null;
for(Frequency freq : manager1.getFrequencies())
{
if(freq.name.equals(message.frequency.name))
{
toUse = freq;
break;
}
}
if(toUse == null)
{
toUse = new Frequency(message.frequency.name, player.getPersistentID()).setPublic(message.frequency.isPublic());
manager1.addFrequency(toUse);
}
item.setFrequency(itemstack, toUse.name);
item.setPrivateMode(itemstack, !toUse.publicFreq);
sendDataResponse(toUse, world, player, item, itemstack, message.currentHand);
break;
case DEL_FREQ:
FrequencyManager manager = getManager(message.frequency.isPublic() ? null : player.getUniqueID(), world);
manager.remove(message.frequency.name, player.getUniqueID());
item.setFrequency(itemstack, null);
item.setPrivateMode(itemstack, false);
break;
case TELEPORT:
FrequencyManager manager2 = getManager(message.frequency.isPublic() ? null : player.getUniqueID(), world);
Frequency found = null;
for(Frequency freq : manager2.getFrequencies())
{
if(message.frequency.name.equals(freq.name))
{
found = freq;
break;
}
}
if(found == null)
{
break;
}
Coord4D coords = found.getClosestCoords(new Coord4D(player));
if(coords != null)
{
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(coords.dimensionId);
TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
if(teleporter != null)
{
try {
teleporter.didTeleport.add(player.getPersistentID());
teleporter.teleDelay = 5;
item.setEnergy(itemstack, item.getEnergy(itemstack) - ItemPortableTeleporter.calculateEnergyCost(player, coords));
if(player instanceof EntityPlayerMP)
{
ReflectionUtils.setPrivateValue(((EntityPlayerMP)player).connection, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
}
player.closeScreen();
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(new Coord4D(player)), coords.getTargetPoint(40D));
TileEntityTeleporter.teleportPlayerTo((EntityPlayerMP)player, coords, teleporter);
TileEntityTeleporter.alignPlayer((EntityPlayerMP)player, coords);
world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
Mekanism.packetHandler.sendToReceivers(new PortalFXMessage(coords), new Range4D(coords));
} catch(Exception e) {}
}
}
break;
}
}
}, player);
PacketHandler.handlePacket(new Runnable() {
@Override
public void run()
{
ItemStack itemstack = player.getHeldItem(message.currentHand);
World world = player.world;
if(!itemstack.isEmpty() && itemstack.getItem() instanceof ItemPortableTeleporter)
{
ItemPortableTeleporter item = (ItemPortableTeleporter)itemstack.getItem();
switch(message.packetType)
{
case DATA_REQUEST:
sendDataResponse(message.frequency, world, player, item, itemstack, message.currentHand);
break;
case DATA_RESPONSE:
Mekanism.proxy.handleTeleporterUpdate(message);
break;
case SET_FREQ:
FrequencyManager manager1 = getManager(message.frequency.isPublic() ? null : player.getUniqueID(), world);
Frequency toUse = null;
for(Frequency freq : manager1.getFrequencies())
{
if(freq.name.equals(message.frequency.name))
{
toUse = freq;
break;
}
}
if(toUse == null)
{
toUse = new Frequency(message.frequency.name, player.getPersistentID()).setPublic(message.frequency.isPublic());
manager1.addFrequency(toUse);
}
item.setFrequency(itemstack, toUse.name);
item.setPrivateMode(itemstack, !toUse.publicFreq);
sendDataResponse(toUse, world, player, item, itemstack, message.currentHand);
break;
case DEL_FREQ:
FrequencyManager manager = getManager(message.frequency.isPublic() ? null : player.getUniqueID(), world);
manager.remove(message.frequency.name, player.getUniqueID());
item.setFrequency(itemstack, null);
item.setPrivateMode(itemstack, false);
break;
case TELEPORT:
FrequencyManager manager2 = getManager(message.frequency.isPublic() ? null : player.getUniqueID(), world);
Frequency found = null;
for(Frequency freq : manager2.getFrequencies())
{
if(message.frequency.name.equals(freq.name))
{
found = freq;
break;
}
}
if(found == null)
{
break;
}
Coord4D coords = found.getClosestCoords(new Coord4D(player));
if(coords != null)
{
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(coords.dimensionId);
TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
if(teleporter != null)
{
try {
teleporter.didTeleport.add(player.getPersistentID());
teleporter.teleDelay = 5;
item.setEnergy(itemstack, item.getEnergy(itemstack) - item.calculateEnergyCost(player, coords));
if(player instanceof EntityPlayerMP)
{
((EntityPlayerMP)player).connection.floatingTickCount = 0;
}
player.closeScreen();
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(new Coord4D(player)), coords.getTargetPoint(40D));
TileEntityTeleporter.teleportPlayerTo((EntityPlayerMP)player, coords, teleporter);
TileEntityTeleporter.alignPlayer((EntityPlayerMP)player, coords);
world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
Mekanism.packetHandler.sendToReceivers(new PortalFXMessage(coords), new Range4D(coords));
} catch(Exception e) {}
}
}
break;
}
}
}
}, player);
return null;
}
@@ -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;
@@ -437,12 +434,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());