Compacted the proxies into one universal proxy
This commit is contained in:
parent
63a9fb5588
commit
5df94b322e
|
|
@ -1,43 +0,0 @@
|
|||
package cpw.mods.ironchest;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
public void registerRenderInformation()
|
||||
{
|
||||
}
|
||||
|
||||
public void registerTileEntitySpecialRenderer(IronChestType typ)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(X, Y, Z);
|
||||
if (te != null && te instanceof TileEntityIronChest)
|
||||
{
|
||||
TileEntityIronChest icte = (TileEntityIronChest) te;
|
||||
return new ContainerIronChest(player.inventory, icte, icte.getType(), 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public World getClientWorld()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,16 +9,17 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.ironchest.net.UniversalProxy;
|
||||
|
||||
@Mod(modid = IronChest.modid, name = IronChest.name)
|
||||
public class IronChest {
|
||||
public static final String modid = "IronChest", name = "Iron Chests";
|
||||
public static final String modid = "IronChest", name = "Iron Chests", proxyPath = "cpw.mods.ironchest.net.UniversalProxy";
|
||||
|
||||
@Instance(modid)
|
||||
public static IronChest instance;
|
||||
|
||||
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
@SidedProxy(clientSide = proxyPath, serverSide = proxyPath)
|
||||
public static UniversalProxy proxy;
|
||||
|
||||
public static BlockIronChest ironChestBlock;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.util.EnumMap;
|
|||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
|
||||
|
|
@ -70,7 +71,7 @@ public enum PacketHandler {
|
|||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, IronChestMessage msg) throws Exception
|
||||
{
|
||||
World world = IronChest.proxy.getClientWorld();
|
||||
World world = FMLClientHandler.instance().getClient().theWorld;
|
||||
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
|
||||
if (te instanceof TileEntityIronChest)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
package cpw.mods.ironchest.client;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.ironchest.CommonProxy;
|
||||
import cpw.mods.ironchest.IronChestType;
|
||||
import cpw.mods.ironchest.TileEntityIronChest;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void registerRenderInformation()
|
||||
{
|
||||
TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntitySpecialRenderer(IronChestType typ)
|
||||
{
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getClientWorld()
|
||||
{
|
||||
return FMLClientHandler.instance().getClient().theWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileEntityIronChest)
|
||||
{
|
||||
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package cpw.mods.ironchest.net;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.ironchest.ContainerIronChest;
|
||||
import cpw.mods.ironchest.IronChestType;
|
||||
import cpw.mods.ironchest.TileEntityIronChest;
|
||||
import cpw.mods.ironchest.client.GUIChest;
|
||||
import cpw.mods.ironchest.client.IronChestRenderHelper;
|
||||
import cpw.mods.ironchest.client.TileEntityIronChestRenderer;
|
||||
|
||||
public class UniversalProxy implements IGuiHandler {
|
||||
public void registerRenderInformation() {
|
||||
TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
|
||||
}
|
||||
|
||||
public void registerTileEntitySpecialRenderer(IronChestType typ) {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileEntityIronChest) {
|
||||
TileEntityIronChest chest = (TileEntityIronChest) te;
|
||||
return new ContainerIronChest(player.inventory, chest, chest.getType(), 0, 0);
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileEntityIronChest)
|
||||
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue