add pipe display item
This commit is contained in:
parent
6e5a1b7e37
commit
b4daadcb45
17 changed files with 322 additions and 112 deletions
|
@ -119,6 +119,7 @@ import common.packet.SPacketTimeUpdate;
|
|||
import common.packet.SPacketTrades;
|
||||
import common.packet.SPacketUpdateDisplay;
|
||||
import common.packet.SPacketUpdateHealth;
|
||||
import common.packet.SPacketUpdatePipe;
|
||||
import common.rng.Random;
|
||||
import common.sound.PositionedSound;
|
||||
import common.sound.Sound;
|
||||
|
@ -126,6 +127,7 @@ import common.tileentity.TileEntity;
|
|||
import common.tileentity.TileEntityChest;
|
||||
import common.tileentity.Device;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntityItemPipe;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Pair;
|
||||
|
@ -1267,6 +1269,15 @@ public class ClientPlayer implements IClientPlayer
|
|||
}
|
||||
}
|
||||
|
||||
public void handleUpdatePipe(SPacketUpdatePipe packet) {
|
||||
NetHandler.checkThread(packet, this, this.gm, this.world);
|
||||
if(this.gm.world.isBlockLoaded(packet.getPos())) {
|
||||
TileEntity te = this.gm.world.getTileEntity(packet.getPos());
|
||||
if(te instanceof TileEntityItemPipe pipe)
|
||||
pipe.setDisplayedItem(packet.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progressbar of the opened window to the specified value
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package client.renderer.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import client.Client;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.blockmodel.IBakedModel;
|
||||
import client.renderer.entity.RenderItem;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import common.item.ItemStack;
|
||||
import common.tileentity.TileEntityItemPipe;
|
||||
|
||||
public class ItemPipeRenderer extends ElementRenderer<TileEntityItemPipe> {
|
||||
public void renderElements(TileEntityItemPipe te, double x, double y, double z, float partialTicks) {
|
||||
ItemStack itemstack = te.getDisplayedItem();
|
||||
if(itemstack == null)
|
||||
return;
|
||||
Client.CLIENT.getTextureManager().bindTexture(TextureMap.BLOCKS);
|
||||
GlState.enableRescaleNormal();
|
||||
GlState.alphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
GlState.enableBlend();
|
||||
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
RenderItem itemRenderer = Client.CLIENT.getRenderItem();
|
||||
IBakedModel ibakedmodel = itemRenderer.getItemModelMesher().getItemModel(itemstack);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 0.5f, (float)z + 0.5F);
|
||||
if(ibakedmodel.isGui3d())
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
itemRenderer.renderItem(itemstack, ibakedmodel);
|
||||
GL11.glPopMatrix();
|
||||
GlState.disableRescaleNormal();
|
||||
GlState.disableBlend();
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import common.collect.Maps;
|
|||
import common.entity.Entity;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntityItemPipe;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.BlockPos;
|
||||
import common.world.World;
|
||||
|
@ -29,6 +30,7 @@ public class SpecialRenderer {
|
|||
private SpecialRenderer() {
|
||||
this.renderers.put(TileEntitySign.class, new SignRenderer());
|
||||
this.renderers.put(TileEntityDisplay.class, new DisplayRenderer());
|
||||
this.renderers.put(TileEntityItemPipe.class, new ItemPipeRenderer());
|
||||
}
|
||||
|
||||
private <T extends TileEntity> ElementRenderer<T> getRenderer(Class<? extends TileEntity> clazz) {
|
||||
|
|
BIN
client/src/main/resources/textures/blocks/suction_pipe.png
Executable file
BIN
client/src/main/resources/textures/blocks/suction_pipe.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 173 B |
Binary file not shown.
After Width: | Height: | Size: 178 B |
Loading…
Add table
Add a link
Reference in a new issue