Some tweaks to the code layout. The common proxy should *not* have client gui code references.
This commit is contained in:
parent
f91a505a56
commit
aa0e926532
|
@ -11,12 +11,15 @@
|
||||||
package cpw.mods.ironchest.client;
|
package cpw.mods.ironchest.client;
|
||||||
|
|
||||||
import net.minecraft.src.ChestItemRenderHelper;
|
import net.minecraft.src.ChestItemRenderHelper;
|
||||||
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.ironchest.CommonProxy;
|
import cpw.mods.ironchest.CommonProxy;
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,4 +38,15 @@ public class ClientProxy extends CommonProxy {
|
||||||
public World getClientWorld() {
|
public World getClientWorld() {
|
||||||
return FMLClientHandler.instance().getClient().theWorld;
|
return FMLClientHandler.instance().getClient().theWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
|
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public enum ChestChangerType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemChestChanger buildItem(Configuration cfg, int id) {
|
public ItemChestChanger buildItem(Configuration cfg, int id) {
|
||||||
int itemId = cfg.getOrCreateIntProperty(itemName, Configuration.CATEGORY_ITEM, id).getInt(id);
|
int itemId = cfg.get(Configuration.CATEGORY_ITEM, itemName, id).getInt(id);
|
||||||
item = new ItemChestChanger(itemId, this);
|
item = new ItemChestChanger(itemId, this);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,10 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
|
||||||
import cpw.mods.ironchest.client.GUIChest;
|
|
||||||
|
|
||||||
|
|
||||||
public class CommonProxy implements IGuiHandler {
|
public class CommonProxy implements IGuiHandler {
|
||||||
|
@ -30,12 +29,7 @@ public class CommonProxy implements IGuiHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
return null;
|
||||||
if (te != null && te instanceof TileEntityIronChest) {
|
|
||||||
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,10 +29,9 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
|
||||||
@Mod(modid = "IronChest", name = "Iron Chests", dependencies="required-after:FML@[3.1.15,)")
|
@Mod(modid = "IronChest", name = "Iron Chests", dependencies="required-after:FML@[4.0,)")
|
||||||
@NetworkMod(channels = { "IronChest" }, versionBounds = "[4.0,)", clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
@NetworkMod(channels = { "IronChest" }, versionBounds = "[4.1,)", clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||||
public class IronChest {
|
public class IronChest {
|
||||||
|
|
||||||
public static BlockIronChest ironChestBlock;
|
public static BlockIronChest ironChestBlock;
|
||||||
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
|
@ -49,10 +48,10 @@ public class IronChest {
|
||||||
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
|
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
try {
|
try {
|
||||||
cfg.load();
|
cfg.load();
|
||||||
blockId = cfg.getOrCreateBlockIdProperty("ironChests", 181).getInt(181);
|
blockId = cfg.get(Configuration.CATEGORY_BLOCK, "ironChests", 181).getInt(181);
|
||||||
ChestChangerType.buildItems(cfg, 29501);
|
ChestChangerType.buildItems(cfg, 29501);
|
||||||
CACHE_RENDER = cfg.getOrCreateBooleanProperty("cacheRenderingInformation", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true);
|
||||||
OCELOTS_SITONCHESTS = cfg.getOrCreateBooleanProperty("ocelotsSitOnChests", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
OCELOTS_SITONCHESTS = cfg.get(Configuration.CATEGORY_GENERAL, "ocelotsSitOnChests", true).getBoolean(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FMLLog.log(Level.SEVERE, e, "IronChest has a problem loading it's configuration");
|
FMLLog.log(Level.SEVERE, e, "IronChest has a problem loading it's configuration");
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue