diff --git a/common/buildcraft/core/render/RenderRobot.java b/common/buildcraft/core/render/RenderRobot.java index 64cec9f9..671533ef 100644 --- a/common/buildcraft/core/render/RenderRobot.java +++ b/common/buildcraft/core/render/RenderRobot.java @@ -17,8 +17,10 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemBlock; @@ -35,11 +37,27 @@ import buildcraft.core.robots.EntityRobot; public class RenderRobot extends Render implements IItemRenderer { + private final EntityItem dummyEntityItem = new EntityItem(null); + private final RenderItem customRenderItem; + protected ModelBase model = new ModelBase() { }; private ModelRenderer box; public RenderRobot() { + customRenderItem = new RenderItem() { + @Override + public boolean shouldBob() { + return false; + } + + @Override + public boolean shouldSpreadItems() { + return false; + } + }; + customRenderItem.setRenderManager(RenderManager.instance); + box = new ModelRenderer(model, 0, 0); box.addBox(-4F, -4F, -4F, 8, 8, 8); box.rotationPointX = 0; @@ -63,6 +81,34 @@ public class RenderRobot extends Render implements IItemRenderer { box.render(factor); + if (robot.getStackInSlot(0) != null) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.125F, 0, -0.125F); + doRenderItem(robot.getStackInSlot(0), 1.0F); + GL11.glPopMatrix(); + } + + if (robot.getStackInSlot(1) != null) { + GL11.glPushMatrix(); + GL11.glTranslatef(+0.125F, 0, -0.125F); + doRenderItem(robot.getStackInSlot(1), 1.0F); + GL11.glPopMatrix(); + } + + if (robot.getStackInSlot(2) != null) { + GL11.glPushMatrix(); + GL11.glTranslatef(+0.125F, 0, +0.125F); + doRenderItem(robot.getStackInSlot(2), 1.0F); + GL11.glPopMatrix(); + } + + if (robot.getStackInSlot(3) != null) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.125F, 0, +0.125F); + doRenderItem(robot.getStackInSlot(3), 1.0F); + GL11.glPopMatrix(); + } + if (robot.itemInUse != null) { GL11.glPushMatrix(); @@ -267,4 +313,16 @@ public class RenderRobot extends Render implements IItemRenderer { } } + private void doRenderItem(ItemStack stack, float light) { + float renderScale = 0.5f; + GL11.glPushMatrix(); + GL11.glTranslatef(0, 0.28F, 0); + GL11.glScalef(renderScale, renderScale, renderScale); + dummyEntityItem.setEntityItemStack(stack); + customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0); + + GL11.glPopMatrix(); + + } + } diff --git a/common/buildcraft/core/robots/EntityRobot.java b/common/buildcraft/core/robots/EntityRobot.java index ca4581f5..073028a6 100755 --- a/common/buildcraft/core/robots/EntityRobot.java +++ b/common/buildcraft/core/robots/EntityRobot.java @@ -251,7 +251,7 @@ public class EntityRobot extends EntityRobotBase implements if (energyFX >= 10) { energyFX = 0; ForgeDirection dir = ForgeDirection.values()[worldObj.rand.nextInt(6)]; - dir = ForgeDirection.UP; + dir = ForgeDirection.DOWN; Minecraft.getMinecraft().effectRenderer.addEffect(new EntityRobotEnergyFX( worldObj, posX + dir.offsetX * 0.25, posY + dir.offsetY * 0.25, posZ + dir.offsetZ * 0.25, @@ -567,6 +567,8 @@ public class EntityRobot extends EntityRobotBase implements inv[var1] = null; } + RPCHandler.rpcBroadcastAllPlayers(this, "rpcClientSetInventory", var1, inv[var1]); + return result; } @@ -578,6 +580,8 @@ public class EntityRobot extends EntityRobotBase implements @Override public void setInventorySlotContents(int var1, ItemStack var2) { inv[var1] = var2; + + RPCHandler.rpcBroadcastAllPlayers(this, "rpcClientSetInventory", var1, inv[var1]); } @Override @@ -635,9 +639,18 @@ public class EntityRobot extends EntityRobotBase implements itemInUse = stack; } + @RPC(RPCSide.CLIENT) + private void rpcClientSetInventory(int i, ItemStack stack) { + inv[i] = stack; + } + @RPC(RPCSide.SERVER) public void requestInitialization(RPCMessageInfo info) { RPCHandler.rpcPlayer(info.sender, this, "rpcInitialize", itemInUse, itemActive); + + for (int i = 0; i < inv.length; ++i) { + RPCHandler.rpcPlayer(info.sender, this, "rpcClientSetInventory", i, inv[i]); + } } @RPC(RPCSide.CLIENT)