Render Tome of Alchemical Knowledge on top of the Research Station
This commit is contained in:
parent
483226c38f
commit
e06c6f1519
|
@ -1,24 +1,52 @@
|
|||
package com.pahimar.ee3.client.renderer.tileentity;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.pahimar.ee3.client.renderer.model.ModelResearchStation;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.ee3.tileentity.TileEntityResearchStation;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityRendererResearchStation extends TileEntitySpecialRenderer
|
||||
{
|
||||
private final ModelResearchStation modelResearchStation = new ModelResearchStation();
|
||||
private final RenderItem customRenderItem;
|
||||
|
||||
public TileEntityRendererResearchStation()
|
||||
{
|
||||
customRenderItem = new RenderItem()
|
||||
{
|
||||
@Override
|
||||
public boolean shouldBob()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
customRenderItem.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityResearchStation)
|
||||
{
|
||||
TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) tileEntity;
|
||||
|
||||
/**
|
||||
* Render the Research Station
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
|
||||
// Scale, Translate, Rotate
|
||||
|
@ -32,6 +60,27 @@ public class TileEntityRendererResearchStation extends TileEntitySpecialRenderer
|
|||
modelResearchStation.render();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
/**
|
||||
* Render the Tome of Alchemical Knowledge
|
||||
*/
|
||||
GL11.glPushMatrix();
|
||||
|
||||
ItemStack tome = tileEntityResearchStation.getStackInSlot(TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX);
|
||||
if (tome != null)
|
||||
{
|
||||
EntityItem ghostEntityItem = new EntityItem(tileEntityResearchStation.getWorldObj());
|
||||
ghostEntityItem.hoverStart = 0.0F;
|
||||
ghostEntityItem.setEntityItemStack(tome);
|
||||
|
||||
GL11.glTranslated(x + 0.6F, y + 1.015625F, z + 0.35F);
|
||||
GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,5 +29,6 @@ public class PacketHandler
|
|||
INSTANCE.registerMessage(MessageSingleParticleEvent.class, MessageSingleParticleEvent.class, 14, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageSliderElementUpdated.class, MessageSliderElementUpdated.class, 15, Side.SERVER);
|
||||
INSTANCE.registerMessage(MessageTransmutationKnowledgeUpdate.class, MessageTransmutationKnowledgeUpdate.class, 16, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageTileEntityResearchStation.class, MessageTileEntityResearchStation.class, 17, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.pahimar.ee3.network.message;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileEntityResearchStation;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class MessageTileEntityResearchStation implements IMessage, IMessageHandler<MessageTileEntityResearchStation, IMessage>
|
||||
{
|
||||
public int x, y, z;
|
||||
public ItemStack tomeItemStack;
|
||||
|
||||
public MessageTileEntityResearchStation()
|
||||
{
|
||||
}
|
||||
|
||||
public MessageTileEntityResearchStation(TileEntityResearchStation tileEntityResearchStation)
|
||||
{
|
||||
this.x = tileEntityResearchStation.xCoord;
|
||||
this.y = tileEntityResearchStation.yCoord;
|
||||
this.z = tileEntityResearchStation.zCoord;
|
||||
this.tomeItemStack = tileEntityResearchStation.getStackInSlot(TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
tomeItemStack = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
ByteBufUtils.writeItemStack(buf, tomeItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageTileEntityResearchStation message, MessageContext ctx)
|
||||
{
|
||||
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(message.x, message.y, message.z);
|
||||
|
||||
if (tileEntity instanceof TileEntityResearchStation)
|
||||
{
|
||||
((TileEntityResearchStation) tileEntity).setInventorySlotContents(TileEntityResearchStation.TOME_SLOT_INVENTORY_INDEX, message.tomeItemStack);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("MessageTileEntityResearchStation - x:%s, y:%s, z:%s, tome:%s", x, y, z, tomeItemStack.toString());
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@ package com.pahimar.ee3.tileentity;
|
|||
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageTileEntityResearchStation;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.util.ItemHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -11,6 +13,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -167,6 +170,12 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor
|
|||
}
|
||||
itemLearnTime = nbtTagCompound.getInteger("itemLearnTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityResearchStation(this));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getLearnProgressScaled(int scale)
|
||||
|
|
Loading…
Reference in New Issue