Fix SMP display of chest types and upgrader effects

This commit is contained in:
Christian Weeks 2012-02-18 10:05:28 -05:00
parent 0c3e0e7a0b
commit 5ec981acb8
4 changed files with 36 additions and 17 deletions

View File

@ -22,6 +22,7 @@ import net.minecraft.src.TileEntitySpecialRenderer;
import net.minecraft.src.forge.ForgeHooksClient; import net.minecraft.src.forge.ForgeHooksClient;
import net.minecraft.src.forge.ICustomItemRenderer; import net.minecraft.src.forge.ICustomItemRenderer;
import net.minecraft.src.forge.MinecraftForgeClient; import net.minecraft.src.forge.MinecraftForgeClient;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
@ -38,11 +39,18 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
} }
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) { public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
if (tile==null) {
return;
}
int facing = 3; int facing = 3;
IronChestType type=tile.getType();
if (tile != null && tile.worldObj != null) { if (tile != null && tile.worldObj != null) {
facing = tile.getFacing(); facing = tile.getFacing();
type=tile.getType();
int typ=tile.worldObj.getBlockMetadata(tile.xCoord,tile.yCoord,tile.zCoord);
type=IronChestType.values()[typ];
} }
bindTextureByName(tile.getType().getModelTexture()); bindTextureByName(type.getModelTexture());
glPushMatrix(); glPushMatrix();
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
@ -75,7 +83,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
glPopMatrix(); glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (tile.getType().isTransparent()) { if (type.isTransparent()) {
random.setSeed(254L); random.setSeed(254L);
float shiftX; float shiftX;
float shiftY; float shiftY;

View File

@ -17,13 +17,14 @@ import net.minecraft.src.mod_IronChest;
import net.minecraft.src.forge.IMultipassRender; import net.minecraft.src.forge.IMultipassRender;
import net.minecraft.src.forge.ITextureProvider; import net.minecraft.src.forge.ITextureProvider;
public class BlockIronChest extends BlockContainer implements ITextureProvider, IMultipassRender { public class BlockIronChest extends BlockContainer implements ITextureProvider {
private Random random; private Random random;
public BlockIronChest(int id) { public BlockIronChest(int id) {
super(id, Material.iron); super(id, Material.iron);
setBlockName("IronChest"); setBlockName("IronChest");
setHardness(3.0F); setHardness(3.0F);
setRequiresSelfNotify();
random=new Random(); random=new Random();
} }
@ -56,19 +57,20 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider,
} }
public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) { public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) {
IronChestType type=IronChestType.values()[l];
TileEntity te = worldAccess.getBlockTileEntity(i, j, k); TileEntity te = worldAccess.getBlockTileEntity(i, j, k);
if (te != null && te instanceof TileEntityIronChest) { TileEntityIronChest icte=null;
TileEntityIronChest icte=(TileEntityIronChest) te; if (te!=null && te instanceof TileEntityIronChest) {
icte=(TileEntityIronChest)te;
}
if (l==0 || l==1) { // Top and Bottom if (l==0 || l==1) { // Top and Bottom
return icte.getType().getTextureRow()*16+1; return type.getTextureRow()*16+1;
} else if (l==icte.getFacing()) { // Front } else if (icte!=null && l==icte.getFacing()) { // Front
return icte.getType().getTextureRow()*16+2; return type.getTextureRow()*16+2;
} else { // Back and Sides } else { // Back and Sides
return icte.getType().getTextureRow()*16; return type.getTextureRow()*16;
} }
} }
return 0;
}
@Override @Override
public int getBlockTextureFromSideAndMetadata(int i, int j) { public int getBlockTextureFromSideAndMetadata(int i, int j) {
@ -181,8 +183,8 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider,
} }
} }
@Override /* @Override
public boolean canRenderInPass(int n) { public boolean canRenderInPass(int n) {
return n==0; return n==0;
} }*/
} }

View File

@ -29,8 +29,7 @@ public class ItemChestChanger extends Item implements ITextureProvider {
return false; return false;
} }
world.setBlockTileEntity(X, Y, Z, newchest); world.setBlockTileEntity(X, Y, Z, newchest);
world.setBlockMetadata(X, Y, Z, newchest.getType().ordinal()); world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal());
world.markBlockNeedsUpdate(X, Y, Z);
world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z)); world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z));
stack.stackSize=0; stack.stackSize=0;
return true; return true;

View File

@ -299,4 +299,14 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
public ItemStack[] getTopItemStacks() { public ItemStack[] getTopItemStacks() {
return topStacks; return topStacks;
} }
public TileEntityIronChest updateFromMetadata(int l) {
if (worldObj!=null && worldObj.isRemote) {
if (l!=type.ordinal()) {
worldObj.setBlockTileEntity(xCoord, yCoord, zCoord, IronChestType.makeEntity(l));
return (TileEntityIronChest)worldObj.getBlockTileEntity(xCoord, yCoord, zCoord);
}
}
return this;
}
} }