mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
More work
This commit is contained in:
1 parent
eba5f7e356
commit
c6f3c162f9
19 files changed
+146
-163
No files matched your search
@@ -5,7 +5,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -52,6 +52,11 @@ public class Coord4D extends BlockPos
|
||||
{
|
||||
this(x, y, z, world.provider.getDimensionId());
|
||||
}
|
||||
|
||||
public Coord4D(Vec3i pos, World world)
|
||||
{
|
||||
this(pos, world.provider.getDimensionId());
|
||||
}
|
||||
|
||||
public Coord4D(double x, double y, double z)
|
||||
{
|
||||
@@ -161,7 +166,7 @@ public class Coord4D extends BlockPos
|
||||
}
|
||||
}
|
||||
|
||||
List<TileEntity> added = (List<TileEntity>)MekanismUtils.getPrivateValue(world, World.class, ObfuscatedNames.World_addedTileEntityList);
|
||||
List<TileEntity> added = (List<TileEntity>)ReflectionUtils.getPrivateValue(world, World.class, ObfuscatedNames.World_addedTileEntityList);
|
||||
|
||||
for(TileEntity iter : added)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package mekanism.api.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class ReflectionUtils
|
||||
{
|
||||
/**
|
||||
* Retrieves a private value from a defined class and field.
|
||||
* @param obj - the Object to retrieve the value from, null if static
|
||||
* @param c - Class to retrieve field value from
|
||||
* @param fields - possible names of field to iterate through
|
||||
* @return value as an Object, cast as necessary
|
||||
*/
|
||||
public static Object getPrivateValue(Object obj, Class c, String[] fields)
|
||||
{
|
||||
for(String field : fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a private value from a defined class and field to a new value.
|
||||
* @param obj - the Object to perform the operation on, null if static
|
||||
* @param value - value to set the field to
|
||||
* @param c - Class the operation will be performed on
|
||||
* @param fields - possible names of field to iterate through
|
||||
*/
|
||||
public static void setPrivateValue(Object obj, Object value, Class c, String[] fields)
|
||||
{
|
||||
for(String field : fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
f.set(obj, value);
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a private method from a class, sets it as accessible, and returns it.
|
||||
* @param c - Class the method is located in
|
||||
* @param methods - possible names of the method to iterate through
|
||||
* @param params - the Types inserted as parameters into the method
|
||||
* @return private method
|
||||
*/
|
||||
public static Method getPrivateMethod(Class c, String[] methods, Class... params)
|
||||
{
|
||||
for(String method : methods)
|
||||
{
|
||||
try {
|
||||
Method m = c.getDeclaredMethod(method, params);
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,10 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.IClientTicker;
|
||||
import mekanism.api.ObfuscatedNames;
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.ObfuscatedNames;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.CommonPlayerTickHandler;
|
||||
import mekanism.common.KeySync;
|
||||
@@ -390,13 +391,13 @@ public class ClientTickHandler
|
||||
public static void setCape(AbstractClientPlayer player, ResourceLocation cape)
|
||||
{
|
||||
try {
|
||||
Method m = MekanismUtils.getPrivateMethod(AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_getPlayerInfo);
|
||||
Method m = ReflectionUtils.getPrivateMethod(AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_getPlayerInfo);
|
||||
Object obj = m.invoke(player);
|
||||
|
||||
if(obj instanceof NetworkPlayerInfo)
|
||||
{
|
||||
NetworkPlayerInfo info = (NetworkPlayerInfo)obj;
|
||||
MekanismUtils.setPrivateValue(info, cape, NetworkPlayerInfo.class, ObfuscatedNames.NetworkPlayerInfo_locationCape);
|
||||
ReflectionUtils.setPrivateValue(info, cape, NetworkPlayerInfo.class, ObfuscatedNames.NetworkPlayerInfo_locationCape);
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@ package mekanism.client.gui.element;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.ObfuscatedNames;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import mekanism.client.gui.IGuiWrapper;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class GuiElement
|
||||
{
|
||||
@@ -48,8 +47,8 @@ public abstract class GuiElement
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize);
|
||||
MekanismUtils.setPrivateValue(guiObj, size + xSize, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize);
|
||||
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();
|
||||
}
|
||||
@@ -61,8 +60,8 @@ public abstract class GuiElement
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize);
|
||||
MekanismUtils.setPrivateValue(guiObj, size + ySize, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize);
|
||||
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();
|
||||
}
|
||||
@@ -74,9 +73,9 @@ public abstract class GuiElement
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int left = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
|
||||
int left = (Integer)ReflectionUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
|
||||
System.out.println(left + " " + guiLeft);
|
||||
MekanismUtils.setPrivateValue(guiObj, left + guiLeft, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
|
||||
ReflectionUtils.setPrivateValue(guiObj, left + guiLeft, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -88,8 +87,8 @@ public abstract class GuiElement
|
||||
if(guiObj instanceof GuiContainer)
|
||||
{
|
||||
try {
|
||||
int top = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop);
|
||||
MekanismUtils.setPrivateValue(guiObj, top + guiTop, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop);
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ import mekanism.api.gas.OreGas;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import mekanism.client.render.tileentity.RenderConfigurableMachine;
|
||||
import mekanism.client.render.tileentity.RenderDynamicTank;
|
||||
import mekanism.client.render.tileentity.RenderFluidTank;
|
||||
import mekanism.client.render.tileentity.RenderThermalEvaporationController;
|
||||
import mekanism.common.base.IMetaItem;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
@@ -765,32 +765,10 @@ public class MekanismRenderer
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static TextureMap getTextureMap(int type)
|
||||
{
|
||||
try {
|
||||
List<ITickable> l = (List<ITickable>)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables);
|
||||
|
||||
for(ITickable t : l)
|
||||
{
|
||||
if(t instanceof TextureMap)
|
||||
{
|
||||
if(((TextureMap)t).getTextureType() == type)
|
||||
{
|
||||
return (TextureMap)t;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
public static float getPartialTick()
|
||||
{
|
||||
try {
|
||||
Timer t = (Timer)MekanismUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer);
|
||||
Timer t = (Timer)ReflectionUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer);
|
||||
return t.renderPartialTicks;
|
||||
} catch(Exception e) {}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ public class CTMData
|
||||
|
||||
public boolean renderConvexConnections = false;
|
||||
|
||||
public String facingOverride;
|
||||
|
||||
public CTMData(IStringSerializable... states)
|
||||
{
|
||||
for(IStringSerializable state : states)
|
||||
@@ -33,17 +31,6 @@ public class CTMData
|
||||
return this;
|
||||
}
|
||||
|
||||
public CTMData setFacingOverride(String s)
|
||||
{
|
||||
facingOverride= s;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasFacingOverride()
|
||||
{
|
||||
return facingOverride != null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldRenderSide(IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ package mekanism.client.render.ctm;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public interface ICTMBlock<T extends Enum & IStringSerializable>
|
||||
@@ -10,5 +11,5 @@ public interface ICTMBlock<T extends Enum & IStringSerializable>
|
||||
|
||||
public PropertyEnum<? extends T> getTypeProperty();
|
||||
|
||||
public String getOverrideTexture(IBlockState state);
|
||||
public String getOverrideTexture(IBlockState state, EnumFacing side);
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import mekanism.common.block.BlockBasic;
|
||||
import mekanism.common.block.states.BlockStateFacing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -136,9 +135,9 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer
|
||||
ICTMBlock block = (ICTMBlock)state.getBlock();
|
||||
CTMData data = block.getCTMData(state);
|
||||
|
||||
if(block.getOverrideTexture(state) != null)
|
||||
if(block.getOverrideTexture(state, facing) != null)
|
||||
{
|
||||
face = CTMRegistry.textureCache.get(block.getOverrideTexture(state));
|
||||
face = CTMRegistry.textureCache.get(block.getOverrideTexture(state, facing));
|
||||
}
|
||||
|
||||
int quadGoal = ctx == null ? 1 : CTM.QUADS_PER_SIDE;
|
||||
@@ -156,15 +155,7 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer
|
||||
{
|
||||
for(BakedQuad q : from)
|
||||
{
|
||||
ChiselTextureCTM toUse = tex;
|
||||
CTMData data = ((ICTMBlock)state.getBlock()).getCTMData(state);
|
||||
|
||||
if(data.hasFacingOverride() && q.getFace() == state.getValue(BlockStateFacing.facingProperty))
|
||||
{
|
||||
toUse = CTMRegistry.textureCache.get(data.facingOverride);
|
||||
}
|
||||
|
||||
to.addAll(toUse.transformQuad(q, ctx == null ? null : ctx, quadGoal));
|
||||
to.addAll(tex.transformQuad(q, ctx == null ? null : ctx, quadGoal));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.ObfuscatedNames;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
@@ -118,7 +118,7 @@ public class SoundHandler
|
||||
public static SoundManager getSoundManager()
|
||||
{
|
||||
try {
|
||||
return (SoundManager)MekanismUtils.getPrivateValue(mc.getSoundHandler(), net.minecraft.client.audio.SoundHandler.class, ObfuscatedNames.SoundHandler_sndManager);
|
||||
return (SoundManager)ReflectionUtils.getPrivateValue(mc.getSoundHandler(), net.minecraft.client.audio.SoundHandler.class, ObfuscatedNames.SoundHandler_sndManager);
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class SoundHandler
|
||||
if(invPlayingSounds == null)
|
||||
{
|
||||
try {
|
||||
invPlayingSounds = (Map<ISound, String>)MekanismUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, ObfuscatedNames.SoundManager_invPlayingSounds);
|
||||
invPlayingSounds = (Map<ISound, String>)ReflectionUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, ObfuscatedNames.SoundManager_invPlayingSounds);
|
||||
} catch(Exception e) {
|
||||
invPlayingSounds = null;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package mekanism.common;
|
||||
|
||||
import mekanism.api.ObfuscatedNames;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import mekanism.common.entity.EntityFlame;
|
||||
import mekanism.common.item.ItemFlamethrower;
|
||||
import mekanism.common.item.ItemFreeRunners;
|
||||
@@ -9,8 +10,6 @@ import mekanism.common.item.ItemGasMask;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -102,7 +101,7 @@ public class CommonPlayerTickHandler
|
||||
|
||||
if(player instanceof EntityPlayerMP)
|
||||
{
|
||||
MekanismUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
ReflectionUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
}
|
||||
|
||||
jetpack.useGas(player.getEquipmentInSlot(3));
|
||||
|
||||
@@ -241,9 +241,9 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
TileEntity tileEntity = new Coord4D(pos, world).getTileEntity(world);
|
||||
|
||||
if(neighborBlock == this && tileEntity instanceof IMultiblock)
|
||||
if(tileEntity instanceof IMultiblock)
|
||||
{
|
||||
((IMultiblock)tileEntity).doUpdate();
|
||||
}
|
||||
@@ -1096,7 +1096,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideTexture(IBlockState state)
|
||||
public String getOverrideTexture(IBlockState state, EnumFacing side)
|
||||
{
|
||||
BasicBlockType type = state.getValue(getBasicBlock().getProperty());
|
||||
|
||||
@@ -1107,7 +1107,10 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
|
||||
if(type == BasicBlockType.THERMAL_EVAPORATION_CONTROLLER)
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "_on" : "");
|
||||
if(side == state.getValue(BlockStateFacing.facingProperty))
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "_on" : "");
|
||||
}
|
||||
}
|
||||
|
||||
if(type == BasicBlockType.INDUCTION_PORT)
|
||||
|
||||
@@ -248,7 +248,7 @@ public class FrequencyManager
|
||||
iter.remove();
|
||||
}
|
||||
else {
|
||||
TileEntity tile = coord.getTileEntity(world);
|
||||
TileEntity tile = coord.safeTileGet(world);
|
||||
|
||||
if(!(tile instanceof IFrequencyHandler))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MultiblockManager<T extends SynchronizedData<T>>
|
||||
|
||||
for(Coord4D obj : inventories.get(id).locations)
|
||||
{
|
||||
TileEntityMultiblock<T> tileEntity = (TileEntityMultiblock<T>)obj.getTileEntity(world);
|
||||
TileEntityMultiblock<T> tileEntity = (TileEntityMultiblock<T>)obj.safeTileGet(world);
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ public class MultiblockManager<T extends SynchronizedData<T>>
|
||||
{
|
||||
if(obj.dimensionId == world.provider.getDimensionId() && obj.exists(world))
|
||||
{
|
||||
TileEntity tileEntity = obj.getTileEntity(world);
|
||||
TileEntity tileEntity = obj.safeTileGet(world);
|
||||
|
||||
if(!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock)tileEntity).getManager() != this || (getStructureId(((TileEntityMultiblock<?>)tileEntity)) != null && getStructureId(((TileEntityMultiblock)tileEntity)) != inventoryID))
|
||||
{
|
||||
|
||||
@@ -316,7 +316,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
*/
|
||||
public boolean isViableNode(BlockPos pos)
|
||||
{
|
||||
TileEntity tile = new Coord4D(pos, pointer.getWorld().provider.getDimensionId()).safeTileGet(pointer.getWorld());
|
||||
TileEntity tile = new Coord4D(pos, pointer.getWorld()).safeTileGet(pointer.getWorld());
|
||||
|
||||
if(tile == null || !tile.hasWorldObj() || tile.isInvalid())
|
||||
{
|
||||
@@ -540,7 +540,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
cache.apply((T)structureFound);
|
||||
|
||||
structureFound.inventoryID = idToUse;
|
||||
System.out.println("Success");
|
||||
System.out.println("Success " + structureFound.locations.size());
|
||||
onFormed();
|
||||
|
||||
List<IStructuralMultiblock> structures = new ArrayList<IStructuralMultiblock>();
|
||||
@@ -573,7 +573,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println("No structure");
|
||||
int killed = 0;
|
||||
for(Coord4D coord : iteratedNodes)
|
||||
{
|
||||
TileEntity tile = coord.safeTileGet(pointer.getWorld());
|
||||
@@ -589,6 +589,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
}
|
||||
|
||||
tileEntity.structure = null;
|
||||
killed++;
|
||||
}
|
||||
else if(tile instanceof IStructuralMultiblock)
|
||||
{
|
||||
@@ -596,6 +597,8 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(killed + " KILLED");
|
||||
|
||||
for(Coord4D coord : innerNodes)
|
||||
{
|
||||
killInnerNode(coord);
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.ObfuscatedNames;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.util.ReflectionUtils;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
@@ -16,7 +17,6 @@ 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.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -114,7 +114,7 @@ public class PacketPortableTeleporter implements IMessageHandler<PortableTelepor
|
||||
|
||||
if(player instanceof EntityPlayerMP)
|
||||
{
|
||||
MekanismUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
ReflectionUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
}
|
||||
|
||||
player.closeScreen();
|
||||
|
||||
@@ -4,15 +4,18 @@ import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.ISustainedInventory;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory, ITickable
|
||||
@@ -31,6 +34,12 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
{
|
||||
fullName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
||||
{
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
super(name);
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
System.out.println("CREATE");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,12 +83,14 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
{
|
||||
for(EntityPlayer player : playersUsing)
|
||||
{
|
||||
player.closeScreen();
|
||||
System.out.println(worldObj.isRemote + " " + clientHasStructure + " " + structure);
|
||||
//player.closeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
//System.out.println(pos + " " + structure);
|
||||
if(structure == null)
|
||||
{
|
||||
isRendering = false;
|
||||
@@ -131,6 +133,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
|
||||
if(structure != null)
|
||||
{
|
||||
//System.out.println("Whee " + structure + " " + isInvalid());
|
||||
getSynchronizedData().didTick = false;
|
||||
|
||||
if(getSynchronizedData().inventoryID != null)
|
||||
@@ -201,7 +204,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
|
||||
data.add(isRendering);
|
||||
data.add(structure != null);
|
||||
|
||||
|
||||
if(structure != null && isRendering)
|
||||
{
|
||||
if(sendStructure)
|
||||
@@ -237,7 +240,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
|
||||
isRendering = dataStream.readBoolean();
|
||||
clientHasStructure = dataStream.readBoolean();
|
||||
|
||||
|
||||
if(clientHasStructure && isRendering)
|
||||
{
|
||||
if(dataStream.readBoolean())
|
||||
|
||||
@@ -5,8 +5,6 @@ import ic2.api.energy.EnergyNet;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -75,6 +73,7 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -83,21 +82,19 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cofh.api.item.IToolHammer;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||
@@ -990,73 +987,6 @@ public final class MekanismUtils
|
||||
player.openContainer.onCraftGuiOpened(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a private value from a defined class and field.
|
||||
* @param obj - the Object to retrieve the value from, null if static
|
||||
* @param c - Class to retrieve field value from
|
||||
* @param fields - possible names of field to iterate through
|
||||
* @return value as an Object, cast as necessary
|
||||
*/
|
||||
public static Object getPrivateValue(Object obj, Class c, String[] fields)
|
||||
{
|
||||
for(String field : fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a private value from a defined class and field to a new value.
|
||||
* @param obj - the Object to perform the operation on, null if static
|
||||
* @param value - value to set the field to
|
||||
* @param c - Class the operation will be performed on
|
||||
* @param fields - possible names of field to iterate through
|
||||
*/
|
||||
public static void setPrivateValue(Object obj, Object value, Class c, String[] fields)
|
||||
{
|
||||
for(String field : fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
f.set(obj, value);
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a private method from a class, sets it as accessible, and returns it.
|
||||
* @param c - Class the method is located in
|
||||
* @param methods - possible names of the method to iterate through
|
||||
* @param params - the Types inserted as parameters into the method
|
||||
* @return private method
|
||||
*/
|
||||
public static Method getPrivateMethod(Class c, String[] methods, Class... params)
|
||||
{
|
||||
for(String method : methods)
|
||||
{
|
||||
try {
|
||||
Method m = c.getDeclaredMethod(method, params);
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a ResourceLocation with a defined resource type and name.
|
||||
* @param type - type of resource to retrieve
|
||||
|
||||
Reference in new issue
Block a user