item slot refactor

This commit is contained in:
Sen 2025-08-01 18:19:14 +02:00
parent c3f9655338
commit 6fb9ded711
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
90 changed files with 1177 additions and 1622 deletions

View file

@ -124,7 +124,6 @@ import common.init.ItemRegistry;
import common.init.Items;
import common.init.Registry;
import common.init.SoundEvent;
import common.inventory.InventoryPlayer;
import common.item.Item;
import common.item.ItemControl;
import common.item.ItemStack;
@ -871,9 +870,9 @@ public class Client implements IThreadListener {
{
if (this.keyBindsHotbar[l].isPressed())
{
if(this.player.inventory.currentItem != l)
if(this.player.getSelectedIndex() != l)
this.controller.resetUseCooldown();
this.player.inventory.currentItem = l;
this.player.setSelectedIndex(l);
}
}
@ -1065,14 +1064,14 @@ public class Client implements IThreadListener {
}
}
int selected = this.player.inventory.currentItem;
int selected = this.player.getSelectedIndex();
for(int n = 0; n < 9; n++) {
int x = this.fbX / 2 - 180 + n * 40 + 4;
int y = this.fbY - 40;
Drawing.drawRectBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff4f4f4f);
}
ItemStack itemstack = this.player.inventory.getCurrentItem();
ItemStack itemstack = this.player.getHeldItem();
String current = itemstack != null ? itemstack.getItem().getHotbarText(this.player, itemstack) : "";
if(!current.isEmpty())
Drawing.drawTextUpward(current, this.fbX / 2, this.fbY - 60, 0xffffffff);
@ -1211,7 +1210,7 @@ public class Client implements IThreadListener {
for(int index = 0; index < 9; ++index) {
int xPos = index * 20;
ItemStack itemstack = this.player.inventory.mainInventory[index];
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
GlState.enableDepth();
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
@ -1246,10 +1245,10 @@ public class Client implements IThreadListener {
GlState.disableDepth();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
for(int index = 0; index < 9; ++index) {
ItemStack itemstack = this.player.inventory.mainInventory[index];
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
GuiContainer.renderItemOverlay(itemstack,
this.fbX / 2 - 180 + 4 + 1 + index * 40, this.fbY - 40 + 1, null, index == this.player.inventory.currentItem ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), 2);
this.fbX / 2 - 180 + 4 + 1 + index * 40, this.fbY - 40 + 1, null, index == this.player.getSelectedIndex() ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax(), 2);
}
}
}
@ -1367,7 +1366,11 @@ public class Client implements IThreadListener {
if(this.zooming)
this.zoomLevel = ExtMath.clampf(this.zoomLevel + (dir < 0 ? -0.25f : 0.25f), 2.0f, 16.0f);
else if(this.player != null) {
this.player.inventory.changeCurrentItem(dir);
this.player.setSelectedIndex(this.player.getSelectedIndex() - dir);
if(this.player.getSelectedIndex() < 0)
this.player.setSelectedIndex(9 - 1);
else if(this.player.getSelectedIndex() >= 9)
this.player.setSelectedIndex(0);
this.controller.resetUseCooldown();
}
}
@ -1384,7 +1387,7 @@ public class Client implements IThreadListener {
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.setMouseItem(null);
this.player.openContainer = this.player.inventoryContainer;
}
if (this.open != null)
@ -1451,13 +1454,13 @@ public class Client implements IThreadListener {
}
else
{
ItemStack itemstack = this.player.inventory.getCurrentItem();
ItemStack itemstack = this.player.getHeldItem();
if ((this.pointed.type != ObjectType.BLOCK || this.world.getState(this.pointed.block).getBlock() == Blocks.air) && itemstack != null && itemstack.getItem().onAction(itemstack, this.player, this.world, ItemControl.PRIMARY, null))
{
this.player.swingItem();
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.PRIMARY.ordinal()));
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
this.player.setHeldItem(null);
this.leftClickCounter = 10;
return;
}
@ -1493,7 +1496,7 @@ public class Client implements IThreadListener {
{
this.rightClickTimer = 4;
boolean flag = true;
ItemStack itemstack = this.player.inventory.getCurrentItem();
ItemStack itemstack = this.player.getHeldItem();
if (itemstack != null && itemstack.getItem() == Items.camera && !this.saving)
{
@ -1511,7 +1514,7 @@ public class Client implements IThreadListener {
this.player.swingItem();
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.SECONDARY.ordinal()));
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
this.player.setHeldItem(null);
return;
}
@ -1545,7 +1548,7 @@ public class Client implements IThreadListener {
if (itemstack.isEmpty())
{
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
this.player.setHeldItem(null);
}
else if (itemstack.getSize() != i)
{
@ -1557,7 +1560,7 @@ public class Client implements IThreadListener {
if (flag)
{
ItemStack itemstack1 = this.player.inventory.getCurrentItem();
ItemStack itemstack1 = this.player.getHeldItem();
if (itemstack1 != null && this.controller.sendUseItem(this.player, this.world, itemstack1))
{
@ -1574,7 +1577,7 @@ public class Client implements IThreadListener {
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem().onAction(this.player.getHeldItem(), this.player, this.world, ItemControl.TERTIARY, null)) {
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.TERTIARY.ordinal()));
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
this.player.setHeldItem(null);
return;
}
@ -1586,12 +1589,13 @@ public class Client implements IThreadListener {
if(item == null)
return;
InventoryPlayer inventoryplayer = this.player.inventory;
if(inventoryplayer.setCurrentItem(item))
int idx = this.player.getInventorySlotContainItem(item);
if(idx >= 0 && idx < 9) {
this.player.setSelectedIndex(idx);
this.controller.resetUseCooldown();
}
if(this.itemCheat) {
this.player.client.addToSendQueue(new CPacketCheat(item, -2 - inventoryplayer.currentItem, this.ctrl()));
this.player.client.addToSendQueue(new CPacketCheat(item, -2 - this.player.getSelectedIndex(), this.ctrl()));
}
}
}
@ -1603,7 +1607,7 @@ public class Client implements IThreadListener {
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem().onAction(this.player.getHeldItem(), this.player, this.world, ItemControl.QUARTERNARY, null)) {
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.QUARTERNARY.ordinal()));
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
this.player.setHeldItem(null);
return;
}
}

View file

@ -3,13 +3,13 @@ package client.gui.container;
import common.init.Blocks;
import common.inventory.ContainerBrewingStand;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
public class GuiBrewing extends GuiContainer {
private final InventoryPlayer playerInv;
private final EntityNPC playerInv;
private final IInventory brewer;
public GuiBrewing(InventoryPlayer player, IInventory brewer) {
public GuiBrewing(EntityNPC player, IInventory brewer) {
super(new ContainerBrewingStand(player, brewer));
this.playerInv = player;
this.brewer = brewer;

View file

@ -1,16 +1,15 @@
package client.gui.container;
import client.Client;
import common.block.Block;
import common.inventory.ContainerChest;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
public class GuiChest extends GuiContainer {
private final Block block;
public GuiChest(InventoryPlayer inv, IInventory chest, Block block) {
super(new ContainerChest(inv, chest, Client.CLIENT.player));
public GuiChest(EntityNPC player, IInventory chest, Block block) {
super(new ContainerChest(player, chest));
this.block = block;
int i = 222;
int j = i - 108;

View file

@ -26,13 +26,12 @@ import client.renderer.ItemRenderer;
import client.renderer.entity.RenderItem;
import client.window.Bind;
import client.window.Button;
import common.attributes.Attribute;
import common.collect.Lists;
import common.collect.Sets;
import common.enchantment.Enchantment;
import common.entity.npc.Attribute;
import common.init.ItemRegistry;
import common.inventory.Container;
import common.inventory.InventoryPlayer;
import common.inventory.Slot;
import common.item.CheatTab;
import common.item.ItemStack;
@ -141,7 +140,8 @@ public abstract class GuiContainer extends Gui
}
}
Map<Attribute, Float> mods = stack.getAttributeModifiers(null);
Map<Attribute, Float> mods = stack.getAttributeModifiers();
mods.putAll(stack.getArmorModifiers(null));
if(!mods.isEmpty()) {
list.add("");
@ -390,8 +390,7 @@ public abstract class GuiContainer extends Gui
ItemRenderer.disableStandardItemLighting();
ItemRenderer.enableGUIStandardItemLighting();
InventoryPlayer inventoryplayer = this.gm.player.inventory;
ItemStack stack = inventoryplayer.getItemStack();
ItemStack stack = this.gm.player.getMouseItem();
if(this.gm.itemCheat)
stack = stack == null ? this.cheatStack : stack;
if(Bind.CRAFT.isDown())
@ -420,11 +419,11 @@ public abstract class GuiContainer extends Gui
this.drawItemStack(stack, mouseX - j2, mouseY - k2, s);
}
if (inventoryplayer.getItemStack() == null && this.cheatStack == null && stack != null)
if (this.gm.player.getMouseItem() == null && this.cheatStack == null && stack != null)
{
this.renderToolTip(stack, mouseX, mouseY);
}
else if (inventoryplayer.getItemStack() == null && this.cheatStack == null && this.theSlot != null && this.theSlot.getHasStack())
else if (this.gm.player.getMouseItem() == null && this.cheatStack == null && this.theSlot != null && this.theSlot.getHasStack())
{
ItemStack itemstack1 = this.theSlot.getStack();
this.renderToolTip(itemstack1, mouseX, mouseY);
@ -504,7 +503,7 @@ public abstract class GuiContainer extends Gui
int j = slotIn.yDisplayPosition;
ItemStack itemstack = slotIn.getStack();
boolean flag = false;
ItemStack itemstack1 = this.gm.player.inventory.getItemStack();
ItemStack itemstack1 = this.gm.player.getMouseItem();
String s = null;
if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null)
@ -550,7 +549,7 @@ public abstract class GuiContainer extends Gui
private void updateDragSplitting()
{
ItemStack itemstack = this.gm.player.inventory.getItemStack();
ItemStack itemstack = this.gm.player.getMouseItem();
if (itemstack != null && this.dragSplitting)
{
@ -607,7 +606,7 @@ public abstract class GuiContainer extends Gui
if((mouseButton == 0 || mouseButton == 1 || mouseButton == 2) && this.clickSide(this.gm.mouseX, this.gm.mouseY, -1, this.gm.shift() || mouseButton == 1, this.gm.ctrl() || mouseButton == 2))
return;
if(mouseButton == 0) {
if(this.gm.itemCheat && this.gm.player != null && this.gm.player.inventory.getItemStack() == null) {
if(this.gm.itemCheat && this.gm.player != null && this.gm.player.getMouseItem() == null) {
for (CheatTab tab : CheatTab.values())
{
if (this.isInsideTab(tab, this.gm.mouseX, this.gm.mouseY))
@ -647,7 +646,7 @@ public abstract class GuiContainer extends Gui
{
if (!this.dragSplitting)
{
if (this.gm.player.inventory.getItemStack() == null)
if (this.gm.player.getMouseItem() == null)
{
boolean flag2 = l != -999 && this.gm.shift();
int i1 = 0;
@ -695,7 +694,7 @@ public abstract class GuiContainer extends Gui
if(this.gm == null || this.cheatStack != null)
return;
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
ItemStack itemstack = this.gm.player.inventory.getItemStack();
ItemStack itemstack = this.gm.player.getMouseItem();
if (this.dragSplitting && slot != null && itemstack != null && itemstack.getSize() > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{
@ -772,7 +771,7 @@ public abstract class GuiContainer extends Gui
this.handleMouseClick((Slot)null, -999, Container.getDragCode(2, this.dragSplittingLimit), 5);
}
else if (this.gm.player.inventory.getItemStack() != null)
else if (this.gm.player.getMouseItem() != null)
{
boolean flag1 = k != -999 && this.gm.shift();
@ -785,7 +784,7 @@ public abstract class GuiContainer extends Gui
}
}
if (this.gm.player.inventory.getItemStack() == null)
if (this.gm.player.getMouseItem() == null)
{
this.lastClickTime = 0L;
}
@ -829,7 +828,7 @@ public abstract class GuiContainer extends Gui
public void useHotbar(int slot)
{
if (!this.clickSide(this.gm.mouseX, this.gm.mouseY, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null)
if (!this.clickSide(this.gm.mouseX, this.gm.mouseY, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.player != null && this.gm.player.getMouseItem() == null && this.cheatStack == null && this.theSlot != null)
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, slot, 2);
}
@ -971,7 +970,7 @@ public abstract class GuiContainer extends Gui
}
private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) {
if(this.gm.itemCheat && this.isPointInRegion(this.cheatX, this.cheatY, 18 * this.cheatWidth, 18 * this.cheatHeight, mouseX, mouseY) && this.gm.player != null && this.gm.player.inventory.getItemStack() == null && this.cheatStack == null) {
if(this.gm.itemCheat && this.isPointInRegion(this.cheatX, this.cheatY, 18 * this.cheatWidth, 18 * this.cheatHeight, mouseX, mouseY) && this.gm.player != null && this.gm.player.getMouseItem() == null && this.cheatStack == null) {
int size = (ITEM_LIST.size() + this.cheatWidth - 1) / this.cheatWidth - this.cheatHeight;
int off = (int)((double)(this.currentScroll * (float)size) + 0.5D);

View file

@ -2,14 +2,14 @@ package client.gui.container;
import common.block.tech.BlockWorkbench;
import common.inventory.ContainerWorkbench;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
import common.util.BlockPos;
import common.world.World;
public class GuiCrafting extends GuiContainer {
private final BlockWorkbench type;
public GuiCrafting(InventoryPlayer inv, World world, BlockWorkbench type) {
public GuiCrafting(EntityNPC inv, World world, BlockWorkbench type) {
super(new ContainerWorkbench(inv, world, BlockPos.ORIGIN, type));
this.type = type;
this.ySize = 112 + 18 * this.type.getSize();

View file

@ -1,10 +1,9 @@
package client.gui.container;
import client.Client;
import client.gui.element.Label;
import common.inventory.ContainerTile;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
import common.tileentity.Device;
public class GuiDevice extends GuiContainer {
@ -16,8 +15,8 @@ public class GuiDevice extends GuiContainer {
private Label temp;
private Label desc;
public GuiDevice(InventoryPlayer player, IInventory inv, Device tile) {
super(new ContainerTile(player, tile, inv, Client.CLIENT.player));
public GuiDevice(EntityNPC player, IInventory inv, Device tile) {
super(new ContainerTile(player, tile, inv));
this.playerInv = player;
this.tileInv = tile;
this.ySize = 153;

View file

@ -3,12 +3,12 @@ package client.gui.container;
import common.block.tech.BlockDispenser;
import common.inventory.ContainerDispenser;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
public class GuiDispenser extends GuiContainer {
private final BlockDispenser block;
public GuiDispenser(InventoryPlayer playerInv, IInventory dispenser, BlockDispenser block) {
public GuiDispenser(EntityNPC playerInv, IInventory dispenser, BlockDispenser block) {
super(new ContainerDispenser(playerInv, dispenser));
this.block = block;
}

View file

@ -7,7 +7,7 @@ import client.gui.element.PressType;
import common.enchantment.Enchantment;
import common.init.Blocks;
import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
import common.rng.Random;
import common.util.Pair;
import common.util.Color;
@ -25,7 +25,7 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
private final Label[] labels = new Label[3];
private final Label[] mana = new Label[3];
public GuiEnchant(InventoryPlayer inv, World world) {
public GuiEnchant(EntityNPC inv, World world) {
super(new ContainerEnchantment(inv, world));
this.enchantment = (ContainerEnchantment)this.inventorySlots;
}

View file

@ -1,15 +1,15 @@
package client.gui.container;
import client.Client;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.inventory.ContainerEntityInventory;
import common.inventory.IInventory;
public class GuiEntity extends GuiContainer {
private final String title;
public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity) {
super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
public GuiEntity(EntityNPC player, IInventory entityInv, Entity entity) {
super(new ContainerEntityInventory(player, entityInv, entity));
this.title = entity.getName();
}

View file

@ -3,14 +3,14 @@ package client.gui.container;
import common.block.tech.BlockFurnace;
import common.inventory.ContainerFurnace;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
import common.tileentity.TileEntityFurnace;
public class GuiFurnace extends GuiContainer {
private final BlockFurnace block;
private final IInventory furnace;
public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv, BlockFurnace block) {
public GuiFurnace(EntityNPC playerInv, IInventory furnaceInv, BlockFurnace block) {
super(new ContainerFurnace(playerInv, furnaceInv));
this.block = block;
this.furnace = furnaceInv;

View file

@ -4,10 +4,10 @@ import client.Client;
import common.init.Blocks;
import common.inventory.ContainerHopper;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
public class GuiHopper extends GuiContainer {
public GuiHopper(InventoryPlayer playerInv, IInventory hopper) {
public GuiHopper(EntityNPC playerInv, IInventory hopper) {
super(new ContainerHopper(playerInv, hopper, Client.CLIENT.player));
this.ySize = 133;
}

View file

@ -9,7 +9,7 @@ import client.renderer.GlState;
import client.renderer.ItemRenderer;
import common.entity.Entity;
import common.inventory.ContainerMerchant;
import common.inventory.InventoryPlayer;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.packet.CPacketAction;
import common.village.MerchantRecipe;
@ -23,7 +23,7 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
private ActButton prevBtn;
private ActButton nextBtn;
public GuiMerchant(InventoryPlayer inv, Entity entity, World world) {
public GuiMerchant(EntityNPC inv, Entity entity, World world) {
super(new ContainerMerchant(inv, null, world));
this.title = entity.getName();
}

View file

@ -1,17 +1,17 @@
package client.gui.container;
import client.gui.element.Label;
import common.entity.npc.EntityNPC;
import common.inventory.ContainerRepair;
import common.inventory.InventoryPlayer;
import common.util.Color;
import common.world.World;
public class GuiRepair extends GuiContainer {
private ContainerRepair anvil;
private Label info;
private InventoryPlayer playerInv;
private EntityNPC playerInv;
public GuiRepair(InventoryPlayer inv, World world) {
public GuiRepair(EntityNPC inv, World world) {
super(new ContainerRepair(inv, world));
this.playerInv = inv;
this.anvil = (ContainerRepair)this.inventorySlots;
@ -23,7 +23,7 @@ public class GuiRepair extends GuiContainer {
this.info.setText(Color.DARK_RED + "Zu teuer!");
else if(this.anvil.maximumCost <= 0 || !this.anvil.getSlot(2).getHasStack())
this.info.setText("");
else if(!this.anvil.getSlot(2).canTakeStack(this.playerInv.player))
else if(!this.anvil.getSlot(2).canTakeStack(this.playerInv))
this.info.setText(Color.RED + "Manakosten: " + this.anvil.maximumCost);
else
this.info.setText(Color.GREEN + "Manakosten: " + this.anvil.maximumCost);

View file

@ -52,7 +52,6 @@ import common.init.Items;
import common.init.SoundEvent;
import common.inventory.Container;
import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer;
import common.inventory.InventoryWarpChest;
import common.item.ItemStack;
import common.item.material.ItemGrindedBones;
@ -530,11 +529,11 @@ public class ClientPlayer implements IClientPlayer
if (i == 0)
{
player.inventory.mainInventory[player.inventory.currentItem] = null;
player.setHeldItem(null);
}
else
{
player.inventory.mainInventory[player.inventory.currentItem] = new ItemStack(ItemRegistry.byId(i));
player.setHeldItem(new ItemStack(ItemRegistry.byId(i)));
}
player.setPositionAndRotation(x, y, z, yaw, pitch);
@ -588,11 +587,11 @@ public class ClientPlayer implements IClientPlayer
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < InventoryPlayer.getHotbarSize())
if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < 9)
{
if(this.gm.player.inventory.currentItem != packetIn.getHeldItemHotbarIndex())
if(this.gm.player.getSelectedIndex() != packetIn.getHeldItemHotbarIndex())
this.gm.controller.resetUseCooldown();
this.gm.player.inventory.currentItem = packetIn.getHeldItemHotbarIndex();
this.gm.player.setSelectedIndex(packetIn.getHeldItemHotbarIndex());
}
}
@ -1117,7 +1116,7 @@ public class ClientPlayer implements IClientPlayer
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));
this.gm.show(new GuiDevice(player, new LocalContainer(slots), dev));
}
else if (packet.getEntityId() != -1)
{
@ -1125,44 +1124,44 @@ public class ClientPlayer implements IClientPlayer
if(entity == null)
return;
if(entity instanceof EntityNPC)
this.gm.show(new GuiMerchant(player.inventory, entity, player.worldObj));
this.gm.show(new GuiMerchant(player, entity, player.worldObj));
else
this.gm.show(new GuiEntity(player.inventory, new InventoryBasic(slots), entity));
this.gm.show(new GuiEntity(player, new InventoryBasic(slots), entity));
}
else if (block == Blocks.warp_chest)
{
this.gm.show(new GuiChest(player.inventory, new InventoryWarpChest(), block));
this.gm.show(new GuiChest(player, new InventoryWarpChest(), block));
}
else if (block == Blocks.enchanting_table)
{
this.gm.show(new GuiEnchant(player.inventory, player.worldObj));
this.gm.show(new GuiEnchant(player, player.worldObj));
}
else if (block instanceof BlockAnvil)
{
this.gm.show(new GuiRepair(player.inventory, player.worldObj));
this.gm.show(new GuiRepair(player, player.worldObj));
}
else if (block instanceof BlockChest)
{
this.gm.show(new GuiChest(player.inventory, new InventoryBasic(slots), block));
this.gm.show(new GuiChest(player, new InventoryBasic(slots), block));
}
else if (block == Blocks.hopper)
{
this.gm.show(new GuiHopper(player.inventory, new InventoryBasic(slots)));
this.gm.show(new GuiHopper(player, new InventoryBasic(slots)));
}
else if (block instanceof BlockFurnace furnace)
{
this.gm.show(new GuiFurnace(player.inventory, new LocalContainer(slots), furnace));
this.gm.show(new GuiFurnace(player, new LocalContainer(slots), furnace));
}
else if (block == Blocks.brewing_stand)
{
this.gm.show(new GuiBrewing(player.inventory, new LocalContainer(slots)));
this.gm.show(new GuiBrewing(player, new LocalContainer(slots)));
}
else if (block instanceof BlockDispenser dispenser)
{
this.gm.show(new GuiDispenser(player.inventory, new InventoryBasic(slots), dispenser));
this.gm.show(new GuiDispenser(player, new InventoryBasic(slots), dispenser));
}
else if(block instanceof BlockWorkbench bench) {
this.gm.show(new GuiCrafting(player.inventory, player.worldObj, bench));
this.gm.show(new GuiCrafting(player, player.worldObj, bench));
}
else {
return;
@ -1180,7 +1179,7 @@ public class ClientPlayer implements IClientPlayer
if (packetIn.getWindowId() == -1)
{
entityplayer.inventory.setItemStack(packetIn.getStack());
entityplayer.setMouseItem(packetIn.getStack());
}
else
{

View file

@ -40,7 +40,6 @@ public class ItemRenderer
private ItemStack itemToRender;
private float equippedProgress;
private float prevEquippedProgress;
private int equippedItemSlot = -1;
private static FloatBuffer setColorBuffer(float r, float g, float b, float a)
{
@ -497,7 +496,7 @@ public class ItemRenderer
{
this.prevEquippedProgress = this.equippedProgress;
EntityNPC entityplayer = this.gm.player;
ItemStack itemstack = entityplayer.inventory.getCurrentItem();
ItemStack itemstack = entityplayer.getHeldItem();
boolean flag = false;
if (this.itemToRender != null && itemstack != null)
@ -524,7 +523,6 @@ public class ItemRenderer
if (this.equippedProgress < 0.1F)
{
this.itemToRender = itemstack;
this.equippedItemSlot = entityplayer.inventory.currentItem;
}
}

View file

@ -16,6 +16,7 @@ import client.renderer.layers.LayerArmor;
import client.renderer.model.ModelHorse;
import client.renderer.texture.TextureManager;
import client.renderer.texture.TextureMap;
import common.entity.animal.EntityHorse;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.Item;
@ -145,11 +146,14 @@ public class RenderItem
GL11.glTranslatef(0.9f, 0.5f, 0.0f);
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
GL11.glScalef(0.85f, -0.85f, 0.85f);
Class<? extends EntityLiving> clazz = horseArmor.getArmorType().getAnimalType();
boolean cull = GlState.isCullEnabled();
if(cull)
GlState.disableCull();
this.manager.bindTexture("textures/armor/" + horseArmor.getArmorTexture() + "_horse.png");
this.horse.render(null, 0, 0, 0, 0, 0, 0.0625F);
if(clazz == EntityHorse.class) {
this.manager.bindTexture("textures/armor/" + horseArmor.getArmorTexture() + "_horse.png");
this.horse.render(null, 0, 0, 0, 0, 0, 0.0625F);
}
if(cull)
GlState.enableCull();
GL11.glPopMatrix();

View file

@ -26,7 +26,7 @@ public class LayerArmor implements LayerRenderer<EntityNPC>
static {
List<Equipment> list = Lists.newArrayList();
for(Equipment tool : Equipment.values()) {
if(tool.isArmor() && tool.isArmorRendered() && !tool.isAnimalArmor())
if(tool.isArmor() && tool.isMainArmor() && !tool.isAnimalArmor())
list.add(tool);
}
SLOTS = list.toArray(new Equipment[list.size()]);

View file

@ -65,7 +65,7 @@ public class PlayerController {
stack.getItem().onBlockDestroyed(stack, world, block, pos, this.gm.player);
if(stack.isEmpty()) {
this.gm.player.destroyCurrentEquippedItem();
this.gm.player.setHeldItem(null);
}
}
@ -83,7 +83,7 @@ public class PlayerController {
this.interacting = true;
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face));
if(this.gm.player.getHeldItem() != null && this.gm.player.getHeldItem().isEmpty())
this.gm.player.inventory.mainInventory[this.gm.player.inventory.currentItem] = null;
this.gm.player.setHeldItem(null);
return true;
}
if(!this.hitting || !this.isHitting(pos)) {
@ -200,7 +200,7 @@ public class PlayerController {
}
private void syncItem() {
int slot = this.gm.player.inventory.currentItem;
int slot = this.gm.player.getSelectedIndex();
if(slot != this.lastSelected) {
this.lastSelected = slot;
@ -235,7 +235,7 @@ public class PlayerController {
flag = true;
}
this.handler.addToSendQueue(new CPacketPlace(pos, side.getIndex(), player.inventory.getCurrentItem(), f, f1, f2));
this.handler.addToSendQueue(new CPacketPlace(pos, side.getIndex(), player.getHeldItem(), f, f1, f2));
if(!flag) {
if(stack == null) {
@ -255,16 +255,16 @@ public class PlayerController {
this.syncItem();
if(this.itemUseCooldown > 0)
return false;
this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem()));
this.handler.addToSendQueue(new CPacketPlace(player.getHeldItem()));
int size = stack.getSize();
this.itemUseCooldown = this.itemUseCooldownMax = stack.getItem().getUseCooldown(stack, world, player);
ItemStack changed = stack.getItem().onItemRightClick(stack, world, player);
if(changed != stack || changed != null && changed.getSize() != size) {
player.inventory.mainInventory[player.inventory.currentItem] = changed;
player.setHeldItem(changed);
if(changed.isEmpty()) {
player.inventory.mainInventory[player.inventory.currentItem] = null;
player.setHeldItem(null);
}
return true;
@ -293,7 +293,7 @@ public class PlayerController {
}
public ItemStack windowClick(int window, int slot, int button, int mode, EntityNPC player) {
short id = player.openContainer.getNextTransactionID(player.inventory);
short id = player.openContainer.getNextTransactionID(player);
ItemStack stack = player.openContainer.slotClick(slot, button, mode, player);
this.handler.addToSendQueue(new CPacketClick(window, slot, button, mode, stack, id));
return stack;