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.ICustomItemRenderer;
import net.minecraft.src.forge.MinecraftForgeClient;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest;
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) {
if (tile==null) {
return;
}
int facing = 3;
IronChestType type=tile.getType();
if (tile != null && tile.worldObj != null) {
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();
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
@ -75,7 +83,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (tile.getType().isTransparent()) {
if (type.isTransparent()) {
random.setSeed(254L);
float shiftX;
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.ITextureProvider;
public class BlockIronChest extends BlockContainer implements ITextureProvider, IMultipassRender {
public class BlockIronChest extends BlockContainer implements ITextureProvider {
private Random random;
public BlockIronChest(int id) {
super(id, Material.iron);
setBlockName("IronChest");
setHardness(3.0F);
setRequiresSelfNotify();
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) {
IronChestType type=IronChestType.values()[l];
TileEntity te = worldAccess.getBlockTileEntity(i, j, k);
TileEntityIronChest icte=null;
if (te!=null && te instanceof TileEntityIronChest) {
TileEntityIronChest icte=(TileEntityIronChest) te;
icte=(TileEntityIronChest)te;
}
if (l==0 || l==1) { // Top and Bottom
return icte.getType().getTextureRow()*16+1;
} else if (l==icte.getFacing()) { // Front
return icte.getType().getTextureRow()*16+2;
return type.getTextureRow()*16+1;
} else if (icte!=null && l==icte.getFacing()) { // Front
return type.getTextureRow()*16+2;
} else { // Back and Sides
return icte.getType().getTextureRow()*16;
return type.getTextureRow()*16;
}
}
return 0;
}
@Override
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) {
return n==0;
}
}*/
}

View File

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

View File

@ -299,4 +299,14 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
public ItemStack[] getTopItemStacks() {
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;
}
}