change inventory system
This commit is contained in:
parent
771a8bfa89
commit
6bb1c7c050
18 changed files with 333 additions and 1082 deletions
|
@ -32,6 +32,7 @@ import common.entity.projectile.EntityArrow;
|
|||
import common.entity.types.EntityLiving;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.init.CraftingRegistry;
|
||||
import common.init.EntityRegistry;
|
||||
import common.init.Items;
|
||||
import common.init.SoundEvent;
|
||||
|
@ -41,10 +42,10 @@ import common.inventory.ContainerEnchantment;
|
|||
import common.inventory.ContainerEntityInventory;
|
||||
import common.inventory.ContainerMerchant;
|
||||
import common.inventory.ContainerTile;
|
||||
import common.inventory.ContainerWorkbench;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryBasic;
|
||||
import common.inventory.Slot;
|
||||
import common.inventory.SlotCrafting;
|
||||
import common.item.Item;
|
||||
import common.item.ItemControl;
|
||||
import common.item.ItemStack;
|
||||
|
@ -836,12 +837,9 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
public void sendSlot(Container container, int index, ItemStack stack)
|
||||
{
|
||||
if (!(container.getSlot(index) instanceof SlotCrafting))
|
||||
if (!this.isChangingQuantityOnly)
|
||||
{
|
||||
if (!this.isChangingQuantityOnly)
|
||||
{
|
||||
this.sendPacket(new SPacketSetSlot(container.windowId, index, stack));
|
||||
}
|
||||
this.sendPacket(new SPacketSetSlot(container.windowId, index, stack));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1948,7 +1946,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
if(msg.length() > 30)
|
||||
throw new IllegalArgumentException("Ungültiger Name");
|
||||
if(packetIn.getArg() == -1)
|
||||
this.entity.inventoryContainer.renameItem(5 + Equipment.ARMOR_SLOTS + this.entity.getSelectedIndex(), msg);
|
||||
this.entity.inventoryContainer.renameItem(Equipment.ARMOR_SLOTS + this.entity.getSelectedIndex(), msg);
|
||||
else
|
||||
this.entity.openContainer.renameItem(packetIn.getArg(), msg);
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
|
@ -2803,7 +2801,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
this.profiling = false;
|
||||
break;
|
||||
|
||||
case CRAFT_ITEM: {
|
||||
case CRAFT_SINGLE: {
|
||||
if(this.entity.getMouseItem() == null) {
|
||||
Slot slot = this.entity.openContainer.getSlot(packetIn.getAuxData());
|
||||
if(slot != null && slot.canCheatItem() && slot.getHasStack()) {
|
||||
|
@ -2818,6 +2816,13 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CRAFT_ITEM: {
|
||||
int tier = this.entity.openContainer == this.entity.inventoryContainer ? 0 : (this.entity.openContainer instanceof ContainerWorkbench bench ? bench.getTier() : -1);
|
||||
if(tier >= 0)
|
||||
CraftingRegistry.doCrafting(this.entity, tier, packetIn.getAuxData());
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültige Aktion!");
|
||||
|
@ -2889,7 +2894,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
Item item = packet.getItem();
|
||||
if(item == null)
|
||||
return;
|
||||
ItemStack stack = new ItemStack(item, packet.isStacked() ? item.getMaxAmount() : 1);
|
||||
ItemStack stack = new ItemStack(item, packet.isStacked() ? Math.min(item.getMaxAmount(), 100) : 1);
|
||||
int amount = stack.getSize();
|
||||
if(amount <= 0)
|
||||
return;
|
||||
|
@ -2903,7 +2908,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
this.entity.dropItem(stack, false, true);
|
||||
}
|
||||
else {
|
||||
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(5 + Equipment.ARMOR_SLOTS + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
|
||||
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(Equipment.ARMOR_SLOTS + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
|
||||
if(slot == null || !slot.canCheatItem())
|
||||
return;
|
||||
stack.setSize(Math.min(slot.getItemStackLimit(stack), stack.getSize()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue