Found it; I'd accidentally put the containers in the client side instead of the GUIs.
No errors again now, but I can still only open one of the three chests. Here's the relevant code currently:
[spoiler=GuiHandler]
package co.uk.silvania.Remula.tileentity;
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 GuiHandler implements IGuiHandler {
public GuiHandler() {
}
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
switch(id) {
case 0: {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityRemulaChest) {
if(id == 0)
return new ContainerRemulaChest(player.inventory, (TileEntityRemulaChest) tileEntity);
}
return null;
}
case 1: {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntitySilvaniteChest) {
if(id == 2)
return new ContainerSilvaniteChest(player.inventory, (TileEntitySilvaniteChest) tileEntity);
}
return null;
}
case 2: {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityMerciliteChest) {
if(id == 1)
return new ContainerMerciliteChest(player.inventory, (TileEntityMerciliteChest) tileEntity);
}
return null;
}
}
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
switch(id) {
case 0: {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityRemulaChest) {
if(id == 0)
return new RemulaGuiChest(player.inventory, (TileEntityRemulaChest) tileEntity);
}
}
break;
case 1: {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntitySilvaniteChest) {
if(id == 2)
return new SilvaniteGuiChest(player.inventory, (TileEntitySilvaniteChest) tileEntity);
}
}
break;
case 2: {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityMerciliteChest) {
if(id == 1)
return new MerciliteGuiChest(player.inventory, (TileEntityMerciliteChest) tileEntity);
}
}
break;
}
return null;
}
}
[spoiler=SilvaniteChest]
package co.uk.silvania.Remula.tileentity;
import java.util.Random;
import co.uk.silvania.Remula.CommonProxy;
import co.uk.silvania.Remula.Remula;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class SilvaniteChest extends BlockContainer {
public SilvaniteChest (int id) {
super(id, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(Remula.tabRemula);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int i, float j, float k, float l) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking()) {
return false;
}
player.openGui(Remula.instance, 2, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 22;
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
byte var10 = 0;
int var11 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var11 == 0)
{
var10 = 2;
}
if (var11 == 1)
{
var10 = 5;
}
if (var11 == 2)
{
var10 = 3;
}
if (var11 == 3)
{
var10 = 4;
}
if (var6 != this.blockID && var7 != this.blockID && var8 != this.blockID && var9 != this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
else
{
if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5))
{
if (var6 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3))
{
if (var8 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
}
}
private void dropItems(World world, int x, int y, int z){
Random rand = new Random();
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory)) {
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0) {
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
if (item.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntitySilvaniteChest();
}
}
[spoiler=MerciliteChest]
package co.uk.silvania.Remula.tileentity;
import java.util.Random;
import co.uk.silvania.Remula.CommonProxy;
import co.uk.silvania.Remula.Remula;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class MerciliteChest extends BlockContainer {
public MerciliteChest (int id) {
super(id, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(Remula.tabRemula);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
this.currentTexture = "/co/uk/silvania/Remula/resources/SilvaniteChest1.png";
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int i, float j, float k, float l) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking()) {
return false;
}
player.openGui(Remula.instance, 1, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 22;
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
byte var10 = 0;
int var11 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var11 == 0)
{
var10 = 2;
}
if (var11 == 1)
{
var10 = 5;
}
if (var11 == 2)
{
var10 = 3;
}
if (var11 == 3)
{
var10 = 4;
}
if (var6 != this.blockID && var7 != this.blockID && var8 != this.blockID && var9 != this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
else
{
if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5))
{
if (var6 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3))
{
if (var8 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
}
}
private void dropItems(World world, int x, int y, int z){
Random rand = new Random();
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory)) {
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0) {
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
if (item.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntityMerciliteChest();
}
}
[spoiler=RemulaChest]
package co.uk.silvania.Remula.tileentity;
import java.util.Random;
import co.uk.silvania.Remula.CommonProxy;
import co.uk.silvania.Remula.Remula;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class RemulaChest extends BlockContainer {
public RemulaChest (int id) {
super(id, Material.iron);
setHardness(2.0F);
setResistance(5.0F);
setCreativeTab(Remula.tabRemula);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int i, float j, float k, float l) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking()) {
return false;
}
player.openGui(Remula.instance, 0, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 22;
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
byte var10 = 0;
int var11 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var11 == 0)
{
var10 = 2;
}
if (var11 == 1)
{
var10 = 5;
}
if (var11 == 2)
{
var10 = 3;
}
if (var11 == 3)
{
var10 = 4;
}
if (var6 != this.blockID && var7 != this.blockID && var8 != this.blockID && var9 != this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
else
{
if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5))
{
if (var6 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3))
{
if (var8 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
}
}
private void dropItems(World world, int x, int y, int z){
Random rand = new Random();
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory)) {
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0) {
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
if (item.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntityRemulaChest();
}
}
[spoiler=parts of my mod file]
@Instance("Remula")
public static Remula instance;
public static GuiHandler remulaGuiHandler = new GuiHandler();
@PreInit
public void preInit(FMLPreInitializationEvent event) {
NetworkRegistry.instance().registerGuiHandler(this, remulaGuiHandler);
}
@Init
public void load(FMLInitializationEvent event) {
proxy.registerRenderThings();
proxy.init();
NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());