pre-fix for guis, large chests

This commit is contained in:
Sen 2025-07-14 17:01:04 +02:00
parent ab3bc0407c
commit 2e43f24e23
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
99 changed files with 756 additions and 3619 deletions

View file

@ -1233,8 +1233,12 @@ public class Client implements IThreadListener {
{
if(!this.refreshing)
this.waitingForFile = false;
if(this.player != null)
this.player.setScreenClosed();
if(this.player != null) {
if(this.getNetHandler() != null)
this.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER, this.player.openContainer.windowId));
this.player.inventory.setItemStack(null);
this.player.openContainer = this.player.inventoryContainer;
}
if (this.open != null)
{
this.open.onGuiClosed();

View file

@ -1,5 +1,6 @@
package client.gui.container;
import common.init.Blocks;
import common.inventory.ContainerBrewingStand;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
@ -25,7 +26,7 @@ public class GuiBrewing extends GuiContainer {
}
public void addElements() {
this.label(this.brewer.getCommandName(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label(Blocks.brewing_stand.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
}
}

View file

@ -1,24 +1,24 @@
package client.gui.container;
import client.Client;
import common.block.Block;
import common.inventory.ContainerChest;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
public class GuiChest extends GuiContainer {
private final IInventory upper;
private final IInventory lower;
private final Block block;
public GuiChest(IInventory upper, IInventory lower) {
super(new ContainerChest(upper, lower, Client.CLIENT.player));
this.upper = upper;
this.lower = lower;
public GuiChest(InventoryPlayer inv, IInventory chest, Block block) {
super(new ContainerChest(inv, chest, Client.CLIENT.player));
this.block = block;
int i = 222;
int j = i - 108;
this.ySize = j + (lower.getSizeInventory() / 9) * 18;
this.ySize = j + (chest.getSizeInventory() / 9) * 18;
}
public void addElements() {
this.label(this.lower.getCommandName(), 8, 6);
this.label(this.upper.getCommandName(), 8, this.ySize - 96 + 2);
this.label(this.block.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
}
}

View file

@ -5,18 +5,18 @@ import client.gui.element.Label;
import common.inventory.ContainerTile;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.tileentity.TileEntityDevice;
import common.tileentity.Device;
public class GuiTile extends GuiContainer {
public class GuiDevice extends GuiContainer {
private final IInventory playerInv;
private final IInventory tileInv;
private final TileEntityDevice tile;
private final Device tile;
private Label header;
private Label temp;
private Label desc;
public GuiTile(InventoryPlayer player, IInventory inv, TileEntityDevice tile) {
public GuiDevice(InventoryPlayer player, IInventory inv, Device tile) {
super(new ContainerTile(player, tile, inv, Client.CLIENT.player));
this.playerInv = player;
this.tileInv = tile;
@ -26,14 +26,14 @@ public class GuiTile extends GuiContainer {
public void updateScreen() {
super.updateScreen();
this.header.setText(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name);
this.header.setText(this.tile.getStatus().color + this.tile.getBlockType().getDisplay() + " - " + this.tile.getStatus().name);
this.temp.setText(String.format("Temperatur: %d °", this.tile.getTemperature()));
this.desc.setText(this.tile.formatDisplay((ContainerTile)this.inventorySlots));
}
public void addElements() {
this.header = this.label("", 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.temp = this.label("", 8, 18);
this.desc = this.label("", 8, 28);
}

View file

@ -1,21 +1,20 @@
package client.gui.container;
import common.block.tech.BlockDispenser;
import common.inventory.ContainerDispenser;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
public class GuiDispenser extends GuiContainer {
private final InventoryPlayer playerInv;
private final IInventory dispenser;
private final BlockDispenser block;
public GuiDispenser(InventoryPlayer playerInv, IInventory dispenser) {
public GuiDispenser(InventoryPlayer playerInv, IInventory dispenser, BlockDispenser block) {
super(new ContainerDispenser(playerInv, dispenser));
this.playerInv = playerInv;
this.dispenser = dispenser;
this.block = block;
}
public void addElements() {
this.label(this.dispenser.getCommandName(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label(this.block.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
}
}

View file

@ -6,6 +6,7 @@ import client.gui.element.Label;
import client.gui.element.PressType;
import common.color.TextColor;
import common.enchantment.Enchantment;
import common.init.Blocks;
import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer;
import common.rng.Random;
@ -17,20 +18,16 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
"the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale "
.split(" ");
private final InventoryPlayer playerInv;
private final Random nameRand = new Random();
private final Random random = new Random();
private final ContainerEnchantment enchantment;
private final String title;
private final ActButton[] buttons = new ActButton[3];
private final Label[] labels = new Label[3];
private final Label[] mana = new Label[3];
public GuiEnchant(InventoryPlayer inv, World world, String title) {
public GuiEnchant(InventoryPlayer inv, World world) {
super(new ContainerEnchantment(inv, world));
this.playerInv = inv;
this.enchantment = (ContainerEnchantment)this.inventorySlots;
this.title = title;
}
public void updateScreen() {
@ -62,8 +59,8 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
}
public void addElements() {
this.label(this.title, 12, 5);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label(Blocks.enchanting_table.getDisplay(), 12, 5);
this.label("Inventar", 8, this.ySize - 96 + 2);
for(int l = 0; l < 3; ++l) {
int i1 = 60;
int j1 = i1 + 2;

View file

@ -6,17 +6,15 @@ import common.inventory.ContainerEntityInventory;
import common.inventory.IInventory;
public class GuiEntity extends GuiContainer {
private final IInventory playerInv;
private final IInventory entity;
private final String title;
public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity) {
super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
this.playerInv = playerInv;
this.entity = entityInv;
this.title = entity.getName();
}
public void addElements() {
this.label(this.entity.getCommandName(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label(this.title, 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
}
}

View file

@ -1,17 +1,18 @@
package client.gui.container;
import common.block.tech.BlockFurnace;
import common.inventory.ContainerFurnace;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.tileentity.TileEntityFurnace;
public class GuiFurnace extends GuiContainer {
private final InventoryPlayer playerInv;
private final BlockFurnace block;
private final IInventory furnace;
public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv) {
public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv, BlockFurnace block) {
super(new ContainerFurnace(playerInv, furnaceInv));
this.playerInv = playerInv;
this.block = block;
this.furnace = furnaceInv;
}
@ -31,8 +32,8 @@ public class GuiFurnace extends GuiContainer {
}
public void addElements() {
this.label(this.furnace.getCommandName(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label(this.block.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
}
private int getCookProgressScaled(int pixels) {

View file

@ -1,23 +1,19 @@
package client.gui.container;
import client.Client;
import common.init.Blocks;
import common.inventory.ContainerHopper;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
public class GuiHopper extends GuiContainer {
private final IInventory playerInv;
private final IInventory hopper;
public GuiHopper(InventoryPlayer playerInv, IInventory hopper) {
super(new ContainerHopper(playerInv, hopper, Client.CLIENT.player));
this.playerInv = playerInv;
this.hopper = hopper;
this.ySize = 133;
}
public void addElements() {
this.label(this.hopper.getCommandName(), 8, 6);
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.label(Blocks.hopper.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
}
}

View file

@ -7,6 +7,7 @@ import client.gui.element.ButtonCallback;
import client.gui.element.PressType;
import client.renderer.GlState;
import client.renderer.ItemRenderer;
import common.entity.Entity;
import common.inventory.ContainerMerchant;
import common.inventory.InventoryPlayer;
import common.item.ItemStack;
@ -22,9 +23,9 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
private ActButton prevBtn;
private ActButton nextBtn;
public GuiMerchant(InventoryPlayer inv, String name, World world) {
public GuiMerchant(InventoryPlayer inv, Entity entity, World world) {
super(new ContainerMerchant(inv, null, world));
this.title = name != null ? name : "NSC";
this.title = entity.getName();
}
public void addButtons() {

View file

@ -16,7 +16,7 @@ import client.gui.container.GuiEnchant;
import client.gui.container.GuiFurnace;
import client.gui.container.GuiHopper;
import client.gui.container.GuiEntity;
import client.gui.container.GuiTile;
import client.gui.container.GuiDevice;
import client.gui.container.GuiMerchant;
import client.gui.container.GuiRepair;
import client.gui.ingame.GuiSign;
@ -26,6 +26,10 @@ import client.util.PlayerController;
import client.world.ChunkClient;
import client.world.WorldClient;
import common.block.Block;
import common.block.tech.BlockAnvil;
import common.block.tech.BlockChest;
import common.block.tech.BlockDispenser;
import common.block.tech.BlockFurnace;
import common.block.tech.BlockWorkbench;
import common.dimension.Dimension;
import common.effect.StatusEffect;
@ -38,14 +42,14 @@ import common.entity.npc.EntityNPC;
import common.entity.npc.PlayerCharacter;
import common.entity.projectile.EntityProjectile;
import common.entity.types.EntityLiving;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.init.EntityRegistry;
import common.init.ItemRegistry;
import common.init.SoundEvent;
import common.inventory.AnimalChest;
import common.inventory.Container;
import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer;
import common.inventory.InventoryWarpChest;
import common.item.ItemStack;
import common.log.Log;
import common.network.IClientPlayer;
@ -121,7 +125,7 @@ import common.packet.SPacketUpdateHealth;
import common.rng.Random;
import common.sound.Sound;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityDevice;
import common.tileentity.Device;
import common.tileentity.TileEntityDisplay;
import common.tileentity.TileEntitySign;
import common.util.Pair;
@ -1111,79 +1115,68 @@ public class ClientPlayer implements IClientPlayer
this.gm.player.motionZ += (double)packetIn.func_149147_e();
}
/**
* Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
* Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
*/
public void handleOpenWindow(SPacketOpenWindow packet)
{
NetHandler.checkThread(packet, this, this.gm, this.world);
EntityNPC player = this.gm.player;
String id = packet.getGuiId();
String title = packet.getWindowTitle();
Block block = packet.getGuiId();
int slots = packet.getSlotCount();
LocalContainer local = new LocalContainer(title, slots);
if ("container".equals(id))
if(packet.getTilePos() != null)
{
this.gm.show(new GuiChest(player.inventory, new InventoryBasic(title, slots)));
TileEntity tile = this.world.getTileEntity(packet.getTilePos());
if(!(tile instanceof Device dev))
return;
this.gm.show(new GuiDevice(this.gm.player.inventory, new LocalContainer(slots), dev));
}
else if ("enchanting_table".equals(id))
{
this.gm.show(new GuiEnchant(player.inventory, player.worldObj, title));
}
else if ("anvil".equals(id))
{
this.gm.show(new GuiRepair(player.inventory, player.worldObj));
}
else if ("chest".equals(id))
{
this.gm.show(new GuiChest(player.inventory, local));
}
else if ("hopper".equals(id))
{
this.gm.show(new GuiHopper(player.inventory, local));
}
else if ("furnace".equals(id))
{
this.gm.show(new GuiFurnace(player.inventory, local));
}
else if ("brewing_stand".equals(id))
{
this.gm.show(new GuiBrewing(player.inventory, local));
}
else if ("dispenser".equals(id) || "dropper".equals(id))
{
this.gm.show(new GuiDispenser(player.inventory, local));
}
else if ("trade".equals(id))
{
this.gm.show(new GuiMerchant(player.inventory, title, player.worldObj));
}
else if ("entity".equals(id))
else if (packet.getEntityId() != -1)
{
Entity entity = this.world.getEntityByID(packet.getEntityId());
if(entity == null)
return;
this.gm.show(new GuiEntity(player.inventory, new AnimalChest(title, true, slots), entity));
if(entity instanceof EntityNPC)
this.gm.show(new GuiMerchant(player.inventory, entity, player.worldObj));
else
this.gm.show(new GuiEntity(player.inventory, new InventoryBasic(slots), entity));
}
else if ("tile".equals(id))
else if (block == Blocks.warp_chest)
{
TileEntity tile = this.world.getTileEntity(packet.getTilePos());
if(!(tile instanceof TileEntityDevice dev))
return;
this.gm.show(new GuiTile(this.gm.player.inventory, local, dev));
this.gm.show(new GuiChest(player.inventory, new InventoryWarpChest(), block));
}
else
else if (block == Blocks.enchanting_table)
{
Block block = BlockRegistry.byName(id);
if(block instanceof BlockWorkbench bench) {
this.gm.show(new GuiCrafting(player.inventory, player.worldObj, bench));
}
else {
this.gm.show(new GuiChest(player.inventory, local));
}
this.gm.show(new GuiEnchant(player.inventory, player.worldObj));
}
else if (block instanceof BlockAnvil)
{
this.gm.show(new GuiRepair(player.inventory, player.worldObj));
}
else if (block instanceof BlockChest)
{
this.gm.show(new GuiChest(player.inventory, new InventoryBasic(slots), block));
}
else if (block == Blocks.hopper)
{
this.gm.show(new GuiHopper(player.inventory, new InventoryBasic(slots)));
}
else if (block instanceof BlockFurnace furnace)
{
this.gm.show(new GuiFurnace(player.inventory, new LocalContainer(slots), furnace));
}
else if (block == Blocks.brewing_stand)
{
this.gm.show(new GuiBrewing(player.inventory, new LocalContainer(slots)));
}
else if (block instanceof BlockDispenser dispenser)
{
this.gm.show(new GuiDispenser(player.inventory, new InventoryBasic(slots), dispenser));
}
else if(block instanceof BlockWorkbench bench) {
this.gm.show(new GuiCrafting(player.inventory, player.worldObj, bench));
}
else {
return;
}
player.openContainer.windowId = packet.getWindowId();
}
@ -1339,25 +1332,14 @@ public class ClientPlayer implements IClientPlayer
}
}
/**
* Updates the metadata of instances of the following entitytypes: Mob spawners, command blocks,
* beacons, skulls, flowerpot
*/
public void handleUpdateTileEntity(SPacketUpdateDevice packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
if (this.gm.world.isBlockLoaded(packetIn.getPos()))
{
TileEntity tileentity = this.gm.world.getTileEntity(packetIn.getPos());
// int i = packetIn.getTileEntityType();
if (tileentity != null && packetIn.isTileEntityType(tileentity)) // i == 1 && tileentity instanceof TileEntityMobSpawner || /* i == 2 && tileentity instanceof TileEntityCommandBlock || */ i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || /* i == 5 && tileentity instanceof TileEntityFlowerPot || */ i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityMachine)
{
tileentity.readTags(packetIn.getTags());
}
}
}
public void handleUpdateDevice(SPacketUpdateDevice 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 != null && packet.getType() == te.getBlockType())
te.readTags(packet.getTag());
}
}
/**
* Sets the progressbar of the opened window to the specified value

View file

@ -3,18 +3,14 @@ package client.network;
import java.util.Map;
import common.collect.Maps;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.IInventory;
import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer;
import common.tileentity.ILockableContainer;
import common.tileentity.Passcode;
public class LocalContainer extends InventoryBasic implements ILockableContainer {
public class LocalContainer extends InventoryBasic implements IInventory {
private Map<Integer, Integer> fields = Maps.<Integer, Integer>newHashMap();
public LocalContainer(String title, int slotCount) {
super(title, slotCount);
public LocalContainer(int slotCount) {
super(slotCount);
}
public int getField(int id) {
@ -28,23 +24,4 @@ public class LocalContainer extends InventoryBasic implements ILockableContainer
public int getFieldCount() {
return this.fields.size();
}
public boolean isLocked() {
return false;
}
public void setLockCode(Passcode code) {
}
public Passcode getLockCode() {
return Passcode.EMPTY_CODE;
}
public String getGuiID() {
return null;
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) {
throw new UnsupportedOperationException();
}
}

View file

@ -43,7 +43,6 @@ import common.model.BlockLayer;
import common.rng.Random;
import common.sound.Sound;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.InheritanceMultiMap;
@ -686,23 +685,6 @@ public class RenderGlobal
{
BlockPos blockpos = destroyblockprogress.getPosition();
TileEntity tileentity1 = this.theWorld.getTileEntity(blockpos);
if (tileentity1 instanceof TileEntityChest)
{
TileEntityChest tileentitychest = (TileEntityChest)tileentity1;
if (tileentitychest.adjacentChestXNeg != null)
{
blockpos = blockpos.offset(Facing.WEST);
tileentity1 = this.theWorld.getTileEntity(blockpos);
}
else if (tileentitychest.adjacentChestZNeg != null)
{
blockpos = blockpos.offset(Facing.NORTH);
tileentity1 = this.theWorld.getTileEntity(blockpos);
}
}
Block block = this.theWorld.getState(blockpos).getBlock();
if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockSign))

View file

@ -1,23 +0,0 @@
package client.renderer.model;
public class ModelLargeChest extends ModelChest
{
public ModelLargeChest()
{
this.chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
this.chestLid.addBox(0.0F, -5.0F, -14.0F, 30, 5, 14, 0.0F);
this.chestLid.rotationPointX = 1.0F;
this.chestLid.rotationPointY = 7.0F;
this.chestLid.rotationPointZ = 15.0F;
this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F);
this.chestKnob.rotationPointX = 16.0F;
this.chestKnob.rotationPointY = 7.0F;
this.chestKnob.rotationPointZ = 15.0F;
this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64);
this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 30, 10, 14, 0.0F);
this.chestBelow.rotationPointX = 1.0F;
this.chestBelow.rotationPointY = 6.0F;
this.chestBelow.rotationPointZ = 1.0F;
}
}

View file

@ -4,40 +4,16 @@ import org.lwjgl.opengl.GL11;
import client.renderer.GlState;
import client.renderer.model.ModelChest;
import client.renderer.model.ModelLargeChest;
import common.block.tech.BlockChest;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.tileentity.TileEntityChest;
import common.world.State;
public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntityChest>
{
private static final String textureTrappedDouble = "textures/blocks/chest_trapped_double.png";
// private static final ResourceLocation textureChristmasDouble = new ResourceLocation("textures/tile/chest_christmas_double.png");
private static final String textureNormalDouble = "textures/blocks/chest_normal_double.png";
private static final String textureTrapped = "textures/blocks/chest_trapped.png";
// private static final ResourceLocation textureChristmas = new ResourceLocation("textures/tile/chest_christmas.png");
private static final String textureNormal = "textures/blocks/chest_normal.png";
private ModelChest simpleChest = new ModelChest();
private ModelChest largeChest = new ModelLargeChest();
// private boolean isChristmas;
// public TileEntityChestRenderer()
// {
// this.setChristmas(true);
// }
// public void setChristmas(boolean xmas) {
// if(!xmas) {
// this.isChristmas = false;
// }
// else {
// Calendar calendar = Calendar.getInstance();
// if(calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
// this.isChristmas = true;
// }
// }
private final ModelChest model = new ModelChest();
public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage)
{
@ -45,161 +21,81 @@ public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntit
GlState.depthFunc(GL11.GL_LEQUAL);
GlState.depthMask(true);
int i = 0;
BlockChest block = Blocks.chest;
if (te.hasWorldObj())
{
State state = te.getBlockState();
if(state.getBlock() instanceof BlockChest) {
if(state.getBlock() instanceof BlockChest chest) {
i = state.getValue(BlockChest.FACING).getIndex();
if (i == 0)
{
((BlockChest)state.getBlock()).checkForSurroundingChests(te.getWorld(), te.getPos(), te.getWorld().getState(te.getPos()));
i = state.getValue(BlockChest.FACING).getIndex();
}
block = chest;
}
te.checkForAdjacentChests();
}
if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null)
if (destroyStage >= 0)
{
ModelChest modelchest;
if (te.adjacentChestXPos == null && te.adjacentChestZPos == null)
{
modelchest = this.simpleChest;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(4.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
// else if (this.isChristmas)
// {
// this.bindTexture(textureChristmas);
// }
else if (te.getChestType() == 1)
{
this.bindTexture(textureTrapped);
}
else
{
this.bindTexture(textureNormal);
}
}
else
{
modelchest = this.largeChest;
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(8.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
// else if (this.isChristmas)
// {
// this.bindTexture(textureChristmasDouble);
// }
else if (te.getChestType() == 1)
{
this.bindTexture(textureTrappedDouble);
}
else
{
this.bindTexture(textureNormalDouble);
}
}
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GlState.enableRescaleNormal();
GL11.glScalef(4.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
else
{
this.bindTexture("textures/blocks/" + BlockRegistry.getName(block) + ".png");
}
if (destroyStage < 0)
{
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
GL11.glPushMatrix();
GlState.enableRescaleNormal();
GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
int j = 0;
if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 0;
}
if (i == 4)
{
j = 90;
}
if (i == 5)
{
j = -90;
}
if (i == 2 && te.adjacentChestXPos != null)
{
GL11.glTranslatef(1.0F, 0.0F, 0.0F);
}
if (i == 5 && te.adjacentChestZPos != null)
{
GL11.glTranslatef(0.0F, 0.0F, -1.0F);
}
GL11.glRotatef((float)j, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
if (te.adjacentChestZNeg != null)
{
float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
if (f1 > f)
{
f = f1;
}
}
if (te.adjacentChestXNeg != null)
{
float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks;
if (f2 > f)
{
f = f2;
}
}
f = 1.0F - f;
f = 1.0F - f * f * f;
modelchest.chestLid.rotateAngleX = -(f * (float)Math.PI / 2.0F);
modelchest.renderAll();
GlState.disableRescaleNormal();
GL11.glPopMatrix();
if (destroyStage < 0)
{
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
if (destroyStage >= 0)
{
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
int j = 0;
if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 0;
}
if (i == 4)
{
j = 90;
}
if (i == 5)
{
j = -90;
}
GL11.glRotatef((float)j, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
f = 1.0F - f;
f = 1.0F - f * f * f;
this.model.chestLid.rotateAngleX = -(f * (float)Math.PI / 2.0F);
this.model.renderAll();
GlState.disableRescaleNormal();
GL11.glPopMatrix();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
}
}

View file

@ -1,20 +1,30 @@
package client.renderer.tileentity;
import common.init.Items;
import common.block.tech.BlockChest;
import common.item.ItemStack;
import common.item.block.ItemChest;
import common.tileentity.TileEntityChest;
import common.util.Facing;
import common.world.State;
public class TileEntityItemStackRenderer {
public static TileEntityItemStackRenderer instance = new TileEntityItemStackRenderer();
private State state;
private final TileEntityChest chest = new TileEntityChest(0);
private final TileEntityChest trapChest = new TileEntityChest(1);
private final TileEntityChest chest = new TileEntityChest(0) {
public boolean hasWorldObj() {
return true;
}
public State getBlockState() {
return TileEntityItemStackRenderer.this.state;
}
};
public void renderByItem(ItemStack stack) {
if(stack.getItem() == Items.trapped_chest) {
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.trapChest, 0.0D, 0.0D, 0.0D, 0.0F);
}
else if(stack.getItem() == Items.chest) {
if(stack.getItem() instanceof ItemChest chest) {
this.state = chest.getBlock().getState().withProperty(BlockChest.FACING, Facing.SOUTH);
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 4.9 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB