From c376d92790f244e3201b5e32122b7e575543cfd8 Mon Sep 17 00:00:00 2001 From: Sen Date: Mon, 7 Jul 2025 15:20:52 +0200 Subject: [PATCH] fix itemstack sizes --- client/src/main/java/client/Client.java | 12 +- .../client/gui/container/GuiContainer.java | 146 ++- .../java/client/renderer/EntityRenderer.java | 2 +- .../java/client/renderer/ItemRenderer.java | 153 +-- .../renderer/entity/RenderEntityItem.java | 12 +- .../java/client/util/PlayerController.java | 16 +- .../common/ai/EntityAIControlledByPlayer.java | 4 +- .../java/common/ai/EntityAIShareItems.java | 14 +- .../java/common/ai/EntityAITakePlace.java | 7 +- .../block/artificial/BlockFlowerPot.java | 2 +- .../java/common/block/natural/BlockOre.java | 2 +- .../java/common/block/tech/BlockCauldron.java | 3 +- .../common/block/tech/BlockDispenser.java | 2 +- .../java/common/block/tech/BlockDropper.java | 8 +- .../main/java/common/block/tech/BlockTNT.java | 4 +- .../java/common/enchantment/Enchantment.java | 4 +- .../src/main/java/common/entity/Entity.java | 2 +- .../java/common/entity/animal/EntityCow.java | 2 +- .../common/entity/animal/EntityHorse.java | 6 +- .../common/entity/animal/EntityMooshroom.java | 4 +- .../common/entity/animal/EntityOcelot.java | 7 +- .../common/entity/animal/EntitySheep.java | 2 +- .../java/common/entity/animal/EntityWolf.java | 16 +- .../entity/item/EntityCartContainer.java | 10 +- .../java/common/entity/item/EntityItem.java | 32 +- .../java/common/entity/npc/EntityHaunter.java | 2 +- .../java/common/entity/npc/EntityNPC.java | 59 +- .../common/entity/types/EntityAnimal.java | 30 +- .../common/entity/types/EntityLiving.java | 37 +- .../java/common/init/CraftingRegistry.java | 9 +- .../main/java/common/inventory/Container.java | 120 +- .../inventory/ContainerBrewingStand.java | 4 +- .../java/common/inventory/ContainerChest.java | 2 +- .../common/inventory/ContainerDispenser.java | 4 +- .../inventory/ContainerEnchantment.java | 11 +- .../inventory/ContainerEntityInventory.java | 2 +- .../common/inventory/ContainerFurnace.java | 4 +- .../common/inventory/ContainerHopper.java | 2 +- .../common/inventory/ContainerMerchant.java | 4 +- .../common/inventory/ContainerPlayer.java | 8 +- .../common/inventory/ContainerRepair.java | 10 +- .../java/common/inventory/ContainerTile.java | 2 +- .../common/inventory/ContainerWorkbench.java | 4 +- .../java/common/inventory/InventoryBasic.java | 22 +- .../common/inventory/InventoryCrafting.java | 6 +- .../common/inventory/InventoryHelper.java | 10 +- .../common/inventory/InventoryMerchant.java | 10 +- .../common/inventory/InventoryPlayer.java | 52 +- .../src/main/java/common/inventory/Slot.java | 2 +- .../common/inventory/SlotFurnaceOutput.java | 2 +- .../common/inventory/SlotMerchantResult.java | 12 +- common/src/main/java/common/item/Item.java | 4 +- .../src/main/java/common/item/ItemStack.java | 1043 ++++++----------- common/src/main/java/common/item/RngLoot.java | 20 +- .../main/java/common/item/block/ItemBed.java | 2 +- .../java/common/item/block/ItemBlock.java | 4 +- .../main/java/common/item/block/ItemDoor.java | 2 +- .../java/common/item/block/ItemLilyPad.java | 2 +- .../common/item/block/ItemMetalBlock.java | 2 +- .../java/common/item/block/ItemRedstone.java | 2 +- .../java/common/item/block/ItemSeedFood.java | 2 +- .../java/common/item/block/ItemSeeds.java | 2 +- .../main/java/common/item/block/ItemSign.java | 2 +- .../main/java/common/item/block/ItemSlab.java | 4 +- .../common/item/block/ItemSmallBlock.java | 4 +- .../main/java/common/item/block/ItemSnow.java | 4 +- .../main/java/common/item/block/ItemTNT.java | 2 +- .../java/common/item/material/ItemBook.java | 17 +- .../java/common/item/material/ItemDye.java | 8 +- .../java/common/item/material/ItemMetal.java | 2 +- .../java/common/item/spawner/ItemBoat.java | 4 +- .../common/item/spawner/ItemMinecart.java | 4 +- .../item/spawner/ItemMonsterPlacer.java | 6 +- .../common/item/spawner/ItemNpcSpawner.java | 6 +- .../main/java/common/item/tool/ItemArmor.java | 7 +- .../main/java/common/item/tool/ItemBow.java | 2 +- .../java/common/item/tool/ItemBucket.java | 12 +- .../java/common/item/tool/ItemBucketMilk.java | 4 +- .../common/item/tool/ItemCarrotOnAStick.java | 4 +- .../java/common/item/tool/ItemChargedOrb.java | 6 +- .../main/java/common/item/tool/ItemDie.java | 2 +- .../java/common/item/tool/ItemDynamite.java | 2 +- .../main/java/common/item/tool/ItemEgg.java | 2 +- .../java/common/item/tool/ItemExpBottle.java | 2 +- .../java/common/item/tool/ItemFireball.java | 4 +- .../java/common/item/tool/ItemFirework.java | 4 +- .../java/common/item/tool/ItemFishingRod.java | 2 +- .../common/item/tool/ItemFlintAndSteel.java | 7 +- .../main/java/common/item/tool/ItemFood.java | 2 +- .../common/item/tool/ItemGlassBottle.java | 3 +- .../java/common/item/tool/ItemGunBase.java | 2 +- .../main/java/common/item/tool/ItemHoe.java | 2 +- .../java/common/item/tool/ItemNameTag.java | 2 +- .../java/common/item/tool/ItemPotion.java | 6 +- .../java/common/item/tool/ItemSaddle.java | 2 +- .../java/common/item/tool/ItemShears.java | 2 +- .../java/common/item/tool/ItemSnowball.java | 2 +- .../main/java/common/item/tool/ItemSword.java | 4 +- .../main/java/common/item/tool/ItemTool.java | 4 +- .../common/item/tool/ItemWeatherToken.java | 2 +- .../java/common/network/PacketBuffer.java | 10 +- .../tileentity/TileEntityBrewingStand.java | 6 +- .../common/tileentity/TileEntityChest.java | 10 +- .../common/tileentity/TileEntityDevice.java | 20 +- .../tileentity/TileEntityDispenser.java | 10 +- .../common/tileentity/TileEntityFurnace.java | 24 +- .../common/tileentity/TileEntityHopper.java | 38 +- .../common/village/MerchantRecipeList.java | 10 +- .../server/command/commands/CommandItem.java | 13 +- .../server/command/commands/CommandMore.java | 4 +- .../src/main/java/server/network/Player.java | 48 +- 111 files changed, 983 insertions(+), 1353 deletions(-) diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 5f5b303a..293b85ba 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1477,7 +1477,7 @@ public class Client implements IThreadListener { if (this.world.getState(blockpos).getBlock() != Blocks.air) { - int i = itemstack != null ? itemstack.size : 0; + int i = itemstack != null ? itemstack.getSize() : 0; if (this.controller.clickRight(this.player, this.world, itemstack, blockpos, this.pointed.side, this.pointed.vec)) { @@ -1490,13 +1490,13 @@ public class Client implements IThreadListener { return; } - if (itemstack.size == 0) + if (itemstack.isEmpty()) { this.player.inventory.mainInventory[this.player.inventory.currentItem] = null; } - else if (itemstack.size != i) // || this.controller.isCreative()) + else if (itemstack.getSize() != i) // || this.controller.isCreative()) { - this.entityRenderer.itemRenderer.resetEquippedProgress(); + this.entityRenderer.itemRenderer.resetProgress(); } } } @@ -1508,7 +1508,7 @@ public class Client implements IThreadListener { if (itemstack1 != null && this.controller.sendUseItem(this.player, this.world, itemstack1)) { - this.entityRenderer.itemRenderer.resetEquippedProgress2(); + this.entityRenderer.itemRenderer.resetProgress(); } } } @@ -1980,7 +1980,7 @@ public class Client implements IThreadListener { (((EntityLiving)entity).deathTime != 0 ? "Tod: " + ((EntityLiving)entity).deathTime + "t, " : "") + "Rüstung: " + ((EntityLiving)entity).getTotalArmorValue() + ", Pfeile: " + ((EntityLiving)entity).getArrowCountInEntity() : "Rüstung: n/a, Pfeile: n/a") + "\n" + (held != null ? - "Gegens.: " + ItemRegistry.getName(held.getItem()) + " x" + held.size : "Gegens.: n/a") + "\n" + + "Gegens.: " + ItemRegistry.getName(held.getItem()) + " x" + held.getSize() : "Gegens.: n/a") + "\n" + "Eigens.: " + (entity.dead ? "D" : "") + (entity.noClip ? "N" : "") + (entity.onGround ? "G" : "") + (entity.canBeCollidedWith() ? "C" : "") + (entity.canBePushed() ? "P" : "") + (entity.isBurning() ? "B" : "") + (entity.isPlayer() ? "S" : "") diff --git a/client/src/main/java/client/gui/container/GuiContainer.java b/client/src/main/java/client/gui/container/GuiContainer.java index 0eea6d1e..5a641f61 100755 --- a/client/src/main/java/client/gui/container/GuiContainer.java +++ b/client/src/main/java/client/gui/container/GuiContainer.java @@ -1,8 +1,11 @@ package client.gui.container; +import java.text.DecimalFormat; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.Map.Entry; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; @@ -22,9 +25,13 @@ 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.color.TextColor; +import common.enchantment.Enchantment; +import common.enchantment.EnchantmentHelper; +import common.init.ItemRegistry; import common.inventory.Container; import common.inventory.InventoryPlayer; import common.inventory.Slot; @@ -50,6 +57,7 @@ public abstract class GuiContainer extends Gui } } + private static final DecimalFormat DECIMALFORMAT = new DecimalFormat("#.###"); private static final List ITEM_LIST = Lists.newArrayList(); private static CheatTab selectedTab = CheatTab.ALL; @@ -94,6 +102,91 @@ public abstract class GuiContainer extends Gui private Field cheatSearch; private String cheatLast; + public static String formatAmount(int amount) { + if(amount < 0) + return "0"; + if(amount < 1000) + return "" + amount; + else if(amount < 100000) + return (amount / 1000) + "K"; + else if(amount < 1000000) + return "." + (amount / 100000) + "M"; + else if(amount < 100000000) + return (amount / 1000000) + "M"; + else if(amount < 1000000000) + return "." + (amount / 100000000) + "B"; + else + return (amount / 1000000000) + "B+"; + } + + protected List getTooltip(ItemStack stack) { + List list = Lists.newArrayList(); + String s = stack.getColoredName(); + if(stack.getSize() != 1) + s = TextColor.YELLOW + "" + stack.getSize() + " " + TextColor.RESET + s; + s = s + TextColor.RESET; + list.add(s); + stack.getItem().addInformation(stack, this.gm.player, list); + if(stack.getItem().canBeDyed()) + list.add("Farbe: #" + Integer.toHexString(stack.getDyeColor()).toUpperCase()); + + if(stack.isItemEnchanted()) { + for(Entry enc : stack.getEnchantments()) { + list.add(enc.getKey().getFormattedName(enc.getValue())); + } + } + + int damage = stack.getItem().getAttackDamageBonus(); + damage += EnchantmentHelper.getDamageModifier(stack); + if(damage != 0) { + if(damage > 0) + list.add(TextColor.BLUE + String.format("+%d Angriffsschaden", damage)); + else + list.add(TextColor.RED + String.format("-%d Angriffsschaden", damage)); + } + + Map mods = stack.getAttributeModifiers(null); + + if(!mods.isEmpty()) { + list.add(""); + for(Entry entry : mods.entrySet()) { + float amt = entry.getValue(); + if(stack.getSize() != 1) { + double total = amt * (double)stack.getSize(); + if(amt > 0.0D) + list.add(TextColor.BLUE + String.format("+%s %s [%dx +%s]", DECIMALFORMAT.format(total), entry.getKey(), stack.getSize(), + DECIMALFORMAT.format(amt))); + else if(amt < 0.0D) + list.add(TextColor.RED + String.format("-%s %s [%dx -%s]", DECIMALFORMAT.format(total * -1.0), entry.getKey(), stack.getSize(), + DECIMALFORMAT.format(amt * -1.0))); + } + else { + if(amt > 0.0D) + list.add(TextColor.BLUE + String.format("+%s %s", DECIMALFORMAT.format(amt), entry.getKey())); + else if(amt < 0.0D) + list.add(TextColor.RED + String.format("-%s %s", DECIMALFORMAT.format(amt * -1.0), entry.getKey())); + } + } + } + + if(stack.getItem().isDamageable()) { + list.add(String.format("Haltbarkeit: %d" + (stack.isItemDamaged() ? " / %d" : ""), + stack.isItemDamaged() ? (stack.getItem().getMaxDamage() - stack.getItemDamage()) : stack.getItem().getMaxDamage(), stack.getItem().getMaxDamage())); + } + + if(stack.getRepairCost() > 0) + list.add("Reparaturkosten: " + stack.getRepairCost() + " Mana"); + + if(stack.getItem().getMaxAmount() == 1) + list.add("Nicht stapelbar"); + else + list.add("Stapelbar bis " + stack.getItem().getMaxAmount()); + + list.add(TextColor.GRAY + ItemRegistry.getName(stack.getItem())); + + return list; + } + public Label label(String text, int x, int y) { x = x * 2 + this.container_x; y = y * 2 + this.container_y; @@ -315,15 +408,15 @@ public abstract class GuiContainer extends Gui if (this.dragSplitting && this.dragSplittingSlots.size() > 1) { stack = stack.copy(); - stack.size = this.dragSplittingRemnant; + stack.setSize(this.dragSplittingRemnant); - if (stack.size == 0) + if (stack.isEmpty()) { s = "" + TextColor.YELLOW + "0"; } } else if(stack == this.cheatStack) { - s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(stack.size); + s = TextColor.DGREEN + "+" + TextColor.GREEN + formatAmount(stack.getSize()); } this.drawItemStack(stack, mouseX - j2, mouseY - k2, s); @@ -367,7 +460,7 @@ public abstract class GuiContainer extends Gui } protected void renderToolTip(ItemStack stack, int x, int y) { - List list = stack.getTooltip(this.gm.player); + List list = this.getTooltip(stack); StringBuilder sb = new StringBuilder(); for(int i = 0; i < list.size(); ++i) { if(i != 0) @@ -426,18 +519,18 @@ public abstract class GuiContainer extends Gui { itemstack = itemstack1.copy(); flag = true; - Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().size); + Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().getSize()); - if (itemstack.size > itemstack.getMaxStackSize()) + if (itemstack.getSize() > itemstack.getMaxStackSize()) { - s = TextColor.YELLOW + ItemStack.formatAmount(itemstack.getMaxStackSize()); - itemstack.size = itemstack.getMaxStackSize(); + s = TextColor.YELLOW + formatAmount(itemstack.getMaxStackSize()); + itemstack.setSize(itemstack.getMaxStackSize()); } - if (itemstack.size > slotIn.getItemStackLimit(itemstack)) + if (itemstack.getSize() > slotIn.getItemStackLimit(itemstack)) { - s = TextColor.YELLOW + ItemStack.formatAmount(slotIn.getItemStackLimit(itemstack)); - itemstack.size = slotIn.getItemStackLimit(itemstack); + s = TextColor.YELLOW + formatAmount(slotIn.getItemStackLimit(itemstack)); + itemstack.setSize(slotIn.getItemStackLimit(itemstack)); } } else @@ -462,25 +555,25 @@ public abstract class GuiContainer extends Gui if (itemstack != null && this.dragSplitting) { - this.dragSplittingRemnant = itemstack.size; + this.dragSplittingRemnant = itemstack.getSize(); for (Slot slot : this.dragSplittingSlots) { ItemStack itemstack1 = itemstack.copy(); - int i = slot.getStack() == null ? 0 : slot.getStack().size; + int i = slot.getStack() == null ? 0 : slot.getStack().getSize(); Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i); - if (itemstack1.size > itemstack1.getMaxStackSize()) + if (itemstack1.getSize() > itemstack1.getMaxStackSize()) { - itemstack1.size = itemstack1.getMaxStackSize(); + itemstack1.setSize(itemstack1.getMaxStackSize()); } - if (itemstack1.size > slot.getItemStackLimit(itemstack1)) + if (itemstack1.getSize() > slot.getItemStackLimit(itemstack1)) { - itemstack1.size = slot.getItemStackLimit(itemstack1); + itemstack1.setSize(slot.getItemStackLimit(itemstack1)); } - this.dragSplittingRemnant -= itemstack1.size - i; + this.dragSplittingRemnant -= itemstack1.getSize() - i; } } } @@ -507,7 +600,7 @@ public abstract class GuiContainer extends Gui if(this.cheatStack != null) { Slot slot = this.getSlotAtPosition(mouseX, mouseY); if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.canCheatItem()) - this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack.getItem(), slot.slotNumber, mouseButton == 0 && this.cheatStack.size > 1)); + this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack.getItem(), slot.slotNumber, mouseButton == 0 && this.cheatStack.isStacked())); if(mouseButton != 1 && !this.gm.ctrl()) this.cheatStack = null; return; @@ -605,7 +698,7 @@ public abstract class GuiContainer extends Gui Slot slot = this.getSlotAtPosition(mouseX, mouseY); ItemStack itemstack = this.gm.player.inventory.getItemStack(); - if (this.dragSplitting && slot != null && itemstack != null && itemstack.size > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) + if (this.dragSplitting && slot != null && itemstack != null && itemstack.getSize() > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) { this.dragSplittingSlots.add(slot); this.updateDragSplitting(); @@ -772,13 +865,13 @@ public abstract class GuiContainer extends Gui { if (stack != null) { - if (stack.size != 1 || text != null) + if (stack.getSize() != 1 || text != null) { - String s = text == null ? ItemStack.formatAmount(stack.size) : text; + String s = text == null ? formatAmount(stack.getSize()) : text; - if (text == null && stack.size < 1) + if (text == null && stack.isEmpty()) { - s = TextColor.RED + ItemStack.formatAmount(stack.size); + s = TextColor.RED + formatAmount(stack.getSize()); } Drawing.drawTextRight(s, xPosition + 32, yPosition + 33 - Font.YGLYPH, 0xffffffff); } @@ -855,7 +948,7 @@ public abstract class GuiContainer extends Gui if(!this.cheatLast.isBlank() && this.gm.player != null) { for(Iterator iter = ITEM_LIST.iterator(); iter.hasNext();) { ItemStack stack = iter.next(); - for(String line : stack.getTooltip(this.gm.player)) { + for(String line : this.getTooltip(stack)) { if(line.toLowerCase().contains(this.cheatLast.toLowerCase())) { stack = null; break; @@ -888,8 +981,7 @@ public abstract class GuiContainer extends Gui this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(idx).getItem(), slot < 0 ? slot : -2 - slot, full)); } else { - this.cheatStack = ITEM_LIST.get(idx).copy(); - this.cheatStack.size = full ? this.cheatStack.getMaxStackSize() : 1; + this.cheatStack = ITEM_LIST.get(idx).copy(full ? ITEM_LIST.get(idx).getMaxStackSize() : 1); } return true; } diff --git a/client/src/main/java/client/renderer/EntityRenderer.java b/client/src/main/java/client/renderer/EntityRenderer.java index 615362c1..0720b2a6 100755 --- a/client/src/main/java/client/renderer/EntityRenderer.java +++ b/client/src/main/java/client/renderer/EntityRenderer.java @@ -139,7 +139,7 @@ public class EntityRenderer { float shift = light * (1.0F - dist) + dist; this.fogMult += (shift - this.fogMult) * 0.1F; ++this.rendererUpdateCount; - this.itemRenderer.updateEquippedItem(); + this.itemRenderer.update(); this.addRainParticles(); // this.bossColorModifierPrev = this.bossColorModifier; // diff --git a/client/src/main/java/client/renderer/ItemRenderer.java b/client/src/main/java/client/renderer/ItemRenderer.java index 5a86583e..a533f344 100755 --- a/client/src/main/java/client/renderer/ItemRenderer.java +++ b/client/src/main/java/client/renderer/ItemRenderer.java @@ -34,19 +34,13 @@ public class ItemRenderer private static final Vec3 LIGHT0_POS = (new Vec3(0.20000000298023224D, 1.0D, -0.699999988079071D)).normalize(); private static final Vec3 LIGHT1_POS = (new Vec3(-0.20000000298023224D, 1.0D, 0.699999988079071D)).normalize(); - /** A reference to the Game object. */ private final Client gm; - private ItemStack itemToRender; - - /** - * How far the current item has been equipped (0 disequipped and 1 fully up) - */ - private float equippedProgress; - private float prevEquippedProgress; private final RenderManager renderManager; private final RenderItem itemRenderer; - - /** The index of the currently held item (0-8, or -1 if not yet updated) */ + + 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) @@ -136,19 +130,11 @@ public class ItemRenderer } } - /** - * Returns true if given block is translucent - */ private boolean isBlockTranslucent(Block blockIn) { return blockIn != null && blockIn.getBlockLayer() == BlockLayer.TRANSLUCENT; } - /** - * Rotate the render around X and Y - * - * @param angleY The angle for the rotation arround Y - */ private void rotateArroundXAndY(float angle, float angleY) { GL11.glPushMatrix(); @@ -158,9 +144,6 @@ public class ItemRenderer GL11.glPopMatrix(); } - /** - * Set the OpenGL LightMapTextureCoords based on the EntityNPCClient - */ private void setLightMapFromPlayer(EntityNPC clientPlayer) { int i = this.gm.world.getCombinedLight(new BlockPos(clientPlayer.posX, clientPlayer.posY + (double)clientPlayer.getEyeHeight(), clientPlayer.posZ), 0); @@ -169,9 +152,6 @@ public class ItemRenderer GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, f, f1); } - /** - * Rotate the render according to the player's yaw and pitch - */ private void rotateWithPlayerRotations(EntityNPC entityplayerspIn, float partialTicks) { float f = entityplayerspIn.prevRenderArmPitch + (entityplayerspIn.renderArmPitch - entityplayerspIn.prevRenderArmPitch) * partialTicks; @@ -180,11 +160,6 @@ public class ItemRenderer GL11.glRotatef((entityplayerspIn.rotYaw - f1) * 0.1F, 0.0F, 1.0F, 0.0F); } - /** - * Return the angle to render the Map - * - * @param pitch The player's pitch - */ private float getMapAngleFromPitch(float pitch) { float f = 1.0F - pitch / 45.0F + 0.1F; @@ -273,12 +248,6 @@ public class ItemRenderer // } // } - /** - * Render the player's arm - * - * @param equipProgress The progress of equiping the item - * @param swingProgress The swing movement progression - */ private void renderPlayerArm(EntityNPC clientPlayer, float equipProgress, float swingProgress) { float f = -0.3F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI); @@ -305,11 +274,6 @@ public class ItemRenderer GlState.enableCull(); } - /** - * Rotate and translate render to show item consumption - * - * @param swingProgress The swing movement progress - */ private void doItemUsedTransformations(float swingProgress) { float f = -0.4F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI); @@ -318,33 +282,25 @@ public class ItemRenderer GL11.glTranslatef(f, f1, f2); } -// /** -// * Perform the drinking animation movement -// * -// * @param partialTicks Partials ticks -// */ -// private void performDrinking(EntityNPCSP clientPlayer, float partialTicks) -// { -// float f = (float)clientPlayer.getItemInUseCount() - partialTicks + 1.0F; -// float f1 = f / (float)this.itemToRender.getMaxItemUseDuration(); -// float f2 = ExtMath.absf(ExtMath.cos(f / 4.0F * (float)Math.PI) * 0.1F); -// -// if (f1 >= 0.8F) -// { -// f2 = 0.0F; -// } -// -// SKC.glTranslatef(0.0F, f2, 0.0F); -// float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D); -// SKC.glTranslatef(f3 * 0.6F, f3 * -0.5F, f3 * 0.0F); -// SKC.glRotatef(f3 * 90.0F, 0.0F, 1.0F, 0.0F); -// SKC.glRotatef(f3 * 10.0F, 1.0F, 0.0F, 0.0F); -// SKC.glRotatef(f3 * 30.0F, 0.0F, 0.0F, 1.0F); -// } + private void performDrinking(EntityNPC clientPlayer, float partialTicks) + { + float f = (float)clientPlayer.getItemInUseCount() - partialTicks + 1.0F; + float f1 = f / (float)this.itemToRender.getMaxItemUseDuration(); + float f2 = ExtMath.absf(ExtMath.cos(f / 4.0F * (float)Math.PI) * 0.1F); + + if (f1 >= 0.8F) + { + f2 = 0.0F; + } + + GL11.glTranslatef(0.0F, f2, 0.0F); + float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D); + GL11.glTranslatef(f3 * 0.6F, f3 * -0.5F, f3 * 0.0F); + GL11.glRotatef(f3 * 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f3 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f3 * 30.0F, 0.0F, 0.0F, 1.0F); + } - /** - * Performs transformations prior to the rendering of a held item in first person. - */ private void transformFirstPersonItem(float equipProgress, float swingProgress) { GL11.glTranslatef(0.56F, -0.52F, -0.71999997F); @@ -358,11 +314,6 @@ public class ItemRenderer GL11.glScalef(0.4F, 0.4F, 0.4F); } - /** - * Translate and rotate the render to look like holding a bow - * - * @param partialTicks Partial ticks - */ private void doBowTransformations(float partialTicks, EntityNPC clientPlayer) { GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); @@ -390,9 +341,6 @@ public class ItemRenderer GL11.glScalef(1.0F, 1.0F, 1.0F + f1 * 0.2F); } - /** - * Translate and rotate the render for holding a block - */ private void doBlockTransformations() { GL11.glTranslatef(-0.5F, 0.2F, 0.0F); @@ -401,9 +349,6 @@ public class ItemRenderer GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F); } - /** - * Renders the active item in the player's hand when in first person mode. Args: partialTickTime - */ public void renderItemInFirstPerson(float partialTicks) { float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks); @@ -419,11 +364,6 @@ public class ItemRenderer if (this.itemToRender != null) { -// if (this.itemToRender.getItem() == Items.filled_map) -// { -// this.renderItemMap(clientplayer, f2, f, f1); -// } -// else if (clientplayer.getItemInUseCount() > 0) { ItemAction enumaction = this.itemToRender.getItemUseAction(); @@ -436,9 +376,9 @@ public class ItemRenderer case EAT: case DRINK: -// this.performDrinking(clientplayer, partialTicks); -// this.transformFirstPersonItem(f, 0.0F); -// break; + this.performDrinking(clientplayer, partialTicks); + this.transformFirstPersonItem(f, 0.0F); + break; case BLOCK: this.transformFirstPersonItem(f, 0.0F); @@ -458,7 +398,7 @@ public class ItemRenderer this.renderItem(clientplayer, this.itemToRender, Transforms.Camera.FIRST_PERSON); } - else // if (!clientplayer.isInvisible()) + else { this.renderPlayerArm(clientplayer, f, f1); } @@ -468,9 +408,6 @@ public class ItemRenderer ItemRenderer.disableStandardItemLighting(); } - /** - * Renders all the overlays that are in first person mode. Args: partialTickTime - */ public void renderOverlays(float partialTicks) { GlState.disableAlpha(); @@ -496,27 +433,20 @@ public class ItemRenderer if (iblockstate.getBlock().getRenderType() != -1) { - this.renderBlockInHand(partialTicks, this.gm.getBlockRendererDispatcher().getModelManager().getTexture(iblockstate)); + this.renderBlockInside(partialTicks, this.gm.getBlockRendererDispatcher().getModelManager().getTexture(iblockstate)); } } if(this.gm.player.isBurning()) { - this.renderFireInFirstPerson(partialTicks); + this.renderFireOverlay(partialTicks); } GlState.enableAlpha(); } - /** - * Render the block in the player's hand - * - * @param partialTicks Partial ticks - * @param atlas The TextureAtlasSprite to render - */ - private void renderBlockInHand(float partialTicks, TextureAtlasSprite atlas) + private void renderBlockInside(float partialTicks, TextureAtlasSprite atlas) { this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS); -// Tessellator tessellator = Tessellator.getInstance(); RenderBuffer worldrenderer = Tessellator.getBuffer(); float f = 0.1F; GlState.color(0.1F, 0.1F, 0.1F, 0.5F); @@ -540,14 +470,8 @@ public class ItemRenderer GlState.color(1.0F, 1.0F, 1.0F, 1.0F); } - /** - * Renders the fire on the screen for first person mode. Arg: partialTickTime - * - * @param partialTicks Partial ticks - */ - private void renderFireInFirstPerson(float partialTicks) + private void renderFireOverlay(float partialTicks) { -// Tessellator tessellator = Tessellator.getInstance(); RenderBuffer worldrenderer = Tessellator.getBuffer(); GlState.color(1.0F, 1.0F, 1.0F, 0.9F); GlState.depthFunc(GL11.GL_ALWAYS); @@ -587,7 +511,7 @@ public class ItemRenderer GlState.depthFunc(GL11.GL_LEQUAL); } - public void updateEquippedItem() + public void update() { this.prevEquippedProgress = this.equippedProgress; EntityNPC entityplayer = this.gm.player; @@ -596,7 +520,7 @@ public class ItemRenderer if (this.itemToRender != null && itemstack != null) { - if (!this.itemToRender.getIsItemStackEqual(itemstack)) + if (!this.itemToRender.allEquals(itemstack)) { flag = true; } @@ -622,18 +546,7 @@ public class ItemRenderer } } - /** - * Resets equippedProgress - */ - public void resetEquippedProgress() - { - this.equippedProgress = 0.0F; - } - - /** - * Resets equippedProgress - */ - public void resetEquippedProgress2() + public void resetProgress() { this.equippedProgress = 0.0F; } diff --git a/client/src/main/java/client/renderer/entity/RenderEntityItem.java b/client/src/main/java/client/renderer/entity/RenderEntityItem.java index 9767fecd..f154a921 100755 --- a/client/src/main/java/client/renderer/entity/RenderEntityItem.java +++ b/client/src/main/java/client/renderer/entity/RenderEntityItem.java @@ -37,7 +37,7 @@ public class RenderEntityItem extends Render else { boolean flag = p_177077_9_.isGui3d(); - int i = this.func_177078_a(itemstack); + int i = this.getMultiplier(itemstack); float f = 0.25F; float f1 = ExtMath.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F; float f2 = p_177077_9_.getTransforms().get(Transforms.Camera.GROUND).scale(); @@ -62,23 +62,23 @@ public class RenderEntityItem extends Render } } - private int func_177078_a(ItemStack stack) + private int getMultiplier(ItemStack stack) { int i = 1; - if (stack.size > 48) + if (stack.getSize() > 48) { i = 5; } - else if (stack.size > 32) + else if (stack.getSize() > 32) { i = 4; } - else if (stack.size > 16) + else if (stack.getSize() > 16) { i = 3; } - else if (stack.size > 1) + else if (stack.getSize() > 1) { i = 2; } diff --git a/client/src/main/java/client/util/PlayerController.java b/client/src/main/java/client/util/PlayerController.java index 2d33c278..4ecb1725 100755 --- a/client/src/main/java/client/util/PlayerController.java +++ b/client/src/main/java/client/util/PlayerController.java @@ -62,9 +62,9 @@ public class PlayerController { ItemStack stack = this.gm.player.getCurrentEquippedItem(); if(stack != null) { - stack.onBlockDestroyed(world, block, pos, this.gm.player); + stack.getItem().onBlockDestroyed(stack, world, block, pos, this.gm.player); - if(stack.size == 0) { + if(stack.isEmpty()) { this.gm.player.destroyCurrentEquippedItem(); } } @@ -189,7 +189,7 @@ public class PlayerController { if(this.stack != null && stack != null) { flag = stack.getItem() == this.stack.getItem() - && ItemStack.areItemStackTagsEqual(stack, this.stack); + && ItemStack.dataEquals(stack, this.stack); } return pos.equals(this.position) && flag; @@ -243,7 +243,7 @@ public class PlayerController { return false; } else { - return stack.onItemUse(player, world, pos, side, f, f1, f2); + return stack.getItem().onItemUse(stack, player, world, pos, side, f, f1, f2); } } else { @@ -255,13 +255,13 @@ public class PlayerController { public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) { this.syncItem(); this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem())); - int size = stack.size; - ItemStack changed = stack.useItemRightClick(world, player); + int size = stack.getSize(); + ItemStack changed = stack.getItem().onItemRightClick(stack, world, player); - if(changed != stack || changed != null && changed.size != size) { + if(changed != stack || changed != null && changed.getSize() != size) { player.inventory.mainInventory[player.inventory.currentItem] = changed; - if(changed.size == 0) { + if(changed.isEmpty()) { player.inventory.mainInventory[player.inventory.currentItem] = null; } diff --git a/common/src/main/java/common/ai/EntityAIControlledByPlayer.java b/common/src/main/java/common/ai/EntityAIControlledByPlayer.java index d3dccbd0..e2e52ba4 100755 --- a/common/src/main/java/common/ai/EntityAIControlledByPlayer.java +++ b/common/src/main/java/common/ai/EntityAIControlledByPlayer.java @@ -176,9 +176,9 @@ public class EntityAIControlledByPlayer extends EntityAIBase if (itemstack != null && itemstack.getItem() == Items.carrot_on_a_stick) { - itemstack.damageItem(1, entityplayer); + itemstack.damage(1, entityplayer); - if (itemstack.size == 0) + if (itemstack.isEmpty()) { ItemStack itemstack1 = new ItemStack(Items.fishing_rod); itemstack1.copyData(itemstack); diff --git a/common/src/main/java/common/ai/EntityAIShareItems.java b/common/src/main/java/common/ai/EntityAIShareItems.java index ad9cc717..f022e9ae 100755 --- a/common/src/main/java/common/ai/EntityAIShareItems.java +++ b/common/src/main/java/common/ai/EntityAIShareItems.java @@ -60,21 +60,21 @@ public class EntityAIShareItems extends EntityAIWatchClosest2 { Item item = itemstack.getItem(); - if ((item == Items.bread || item == Items.potato || item == Items.carrot) && itemstack.size > 3) + if ((item == Items.bread || item == Items.potato || item == Items.carrot) && itemstack.getSize() > 3) { - int l = itemstack.size / 2; - itemstack.size -= l; + int l = itemstack.getSize() / 2; + itemstack.decrSize(l); itemstack1 = new ItemStack(item, l); } - else if (item == Items.wheats && itemstack.size > 5) + else if (item == Items.wheats && itemstack.getSize() > 5) { - int j = itemstack.size / 2 / 3 * 3; + int j = itemstack.getSize() / 2 / 3 * 3; int k = j / 3; - itemstack.size -= j; + itemstack.decrSize(j); itemstack1 = new ItemStack(Items.bread, k); } - if (itemstack.size <= 0) + if (itemstack.isEmpty()) { inventorybasic.setInventorySlotContents(i, (ItemStack)null); } diff --git a/common/src/main/java/common/ai/EntityAITakePlace.java b/common/src/main/java/common/ai/EntityAITakePlace.java index 63f3b065..82fe9303 100755 --- a/common/src/main/java/common/ai/EntityAITakePlace.java +++ b/common/src/main/java/common/ai/EntityAITakePlace.java @@ -84,8 +84,7 @@ public class EntityAITakePlace extends EntityAIBase (float)this.entity.getVerticalFaceSpeed()); this.entity.swingItem(); world.setState(blockpos, state, 3); - --stack.size; - if(stack.size <= 0) + if(stack.decrSize()) this.entity.setItemNoUpdate(0, null); } } @@ -94,14 +93,14 @@ public class EntityAITakePlace extends EntityAIBase Block block = state.getBlock(); if (STEALABLE.containsKey(state) && - (this.entity.getHeldItem() == null || (STEALABLE.get(state) == this.entity.getHeldItem().getItem() && this.entity.getHeldItem().size < this.entity.getHeldItem().getMaxStackSize()))) + (this.entity.getHeldItem() == null || (STEALABLE.get(state) == this.entity.getHeldItem().getItem() && !this.entity.getHeldItem().isFull()))) { this.entity.getLookHelper().setLookPosition((double)i + 0.5, (double)j + 0.5, (double)k + 0.5, 10.0F, (float)this.entity.getVerticalFaceSpeed()); this.entity.swingItem(); world.setState(blockpos, Blocks.air.getState()); if(this.entity.getHeldItem() != null) - ++this.entity.getHeldItem().size; + this.entity.getHeldItem().incrSize(); else this.entity.setItemNoUpdate(0, new ItemStack(STEALABLE.get(state))); } diff --git a/common/src/main/java/common/block/artificial/BlockFlowerPot.java b/common/src/main/java/common/block/artificial/BlockFlowerPot.java index 3142e6f9..d894062c 100755 --- a/common/src/main/java/common/block/artificial/BlockFlowerPot.java +++ b/common/src/main/java/common/block/artificial/BlockFlowerPot.java @@ -163,7 +163,7 @@ public class BlockFlowerPot extends Block // worldIn.markBlockForUpdate(pos); // playerIn.triggerAchievement(StatRegistry.flowerPottedStat); - if (/* !playerIn.creative && */ --itemstack.size <= 0) + if (itemstack.decrSize()) { playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null); } diff --git a/common/src/main/java/common/block/natural/BlockOre.java b/common/src/main/java/common/block/natural/BlockOre.java index 90a278cd..5552ca01 100755 --- a/common/src/main/java/common/block/natural/BlockOre.java +++ b/common/src/main/java/common/block/natural/BlockOre.java @@ -59,7 +59,7 @@ public class BlockOre extends Block public int quantityDropped(Random random) { - return this.dropItem == null ? 1 : (this.dropItem.size + (this.dropChance > 0 ? random.zrange(this.dropChance + 1) : 0)); + return this.dropItem == null ? 1 : (this.dropItem.getSize() + (this.dropChance > 0 ? random.zrange(this.dropChance + 1) : 0)); // this == Blocks.lapis_ore ? 4 + random.nextInt(5) : 1; } diff --git a/common/src/main/java/common/block/tech/BlockCauldron.java b/common/src/main/java/common/block/tech/BlockCauldron.java index 788b4722..ad067e52 100755 --- a/common/src/main/java/common/block/tech/BlockCauldron.java +++ b/common/src/main/java/common/block/tech/BlockCauldron.java @@ -522,9 +522,8 @@ public class BlockCauldron extends Block } // playerIn.triggerAchievement(StatRegistry.cauldronUsedStat); - --itemstack.size; - if (itemstack.size <= 0) + if (itemstack.decrSize()) { playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null); } diff --git a/common/src/main/java/common/block/tech/BlockDispenser.java b/common/src/main/java/common/block/tech/BlockDispenser.java index 25db8a20..741d97a1 100755 --- a/common/src/main/java/common/block/tech/BlockDispenser.java +++ b/common/src/main/java/common/block/tech/BlockDispenser.java @@ -143,7 +143,7 @@ public class BlockDispenser extends BlockContainer implements Directional ItemStack itemstack = tileentitydispenser.getStackInSlot(i); if(itemstack != null) { ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos); - tileentitydispenser.setInventorySlotContents(i, itemstack1.size <= 0 ? null : itemstack1); + tileentitydispenser.setInventorySlotContents(i, itemstack1.isEmpty() ? null : itemstack1); } } } diff --git a/common/src/main/java/common/block/tech/BlockDropper.java b/common/src/main/java/common/block/tech/BlockDropper.java index 06a2e9a9..a9aaefa3 100755 --- a/common/src/main/java/common/block/tech/BlockDropper.java +++ b/common/src/main/java/common/block/tech/BlockDropper.java @@ -15,7 +15,7 @@ public class BlockDropper extends BlockDispenser protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos) { Facing facing = world.getState(pos).getValue(FACING); - dispense(world, 6.0, facing, getDispensePosition(pos, facing), stack.splitStack(1)); + dispense(world, 6.0, facing, getDispensePosition(pos, facing), stack.split(1)); world.playAuxSFX(1000, pos, 0); world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3); return stack; @@ -56,20 +56,20 @@ public class BlockDropper extends BlockDispenser { itemstack1 = this.dispenseStack(itemstack, worldIn, pos); - if (itemstack1 != null && itemstack1.size <= 0) + if (itemstack1 != null && itemstack1.isEmpty()) { itemstack1 = null; } } else { - itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite()); + itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().split(1), enumfacing.getOpposite()); if (itemstack1 == null) { itemstack1 = itemstack.copy(); - if (--itemstack1.size <= 0) + if (itemstack1.decrSize()) { itemstack1 = null; } diff --git a/common/src/main/java/common/block/tech/BlockTNT.java b/common/src/main/java/common/block/tech/BlockTNT.java index 8e02c34d..de5e8c8d 100755 --- a/common/src/main/java/common/block/tech/BlockTNT.java +++ b/common/src/main/java/common/block/tech/BlockTNT.java @@ -119,11 +119,11 @@ public class BlockTNT extends Block if (item == Items.flint_and_steel) { - playerIn.getCurrentEquippedItem().damageItem(1, playerIn); + playerIn.getCurrentEquippedItem().damage(1, playerIn); } else // if (!playerIn.creative) { - --playerIn.getCurrentEquippedItem().size; + playerIn.getCurrentEquippedItem().decrSize(); } return true; diff --git a/common/src/main/java/common/enchantment/Enchantment.java b/common/src/main/java/common/enchantment/Enchantment.java index d9058fe6..462c2af6 100755 --- a/common/src/main/java/common/enchantment/Enchantment.java +++ b/common/src/main/java/common/enchantment/Enchantment.java @@ -198,12 +198,12 @@ public enum Enchantment implements Displayable, Identifyable if (itemstack != null) { - itemstack.damageItem(3, user); + itemstack.damage(3, user); } } else if (itemstack != null) { - itemstack.damageItem(1, user); + itemstack.damage(1, user); } } }, diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index da2488ae..df7ab458 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -1638,7 +1638,7 @@ public abstract class Entity */ public EntityItem entityDropItem(ItemStack itemStackIn, float offsetY) { - if (itemStackIn.size != 0 && itemStackIn.getItem() != null) + if (!itemStackIn.isEmpty() && itemStackIn.getItem() != null) { EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)offsetY, this.posZ, itemStackIn); entityitem.setDefaultPickupDelay(); diff --git a/common/src/main/java/common/entity/animal/EntityCow.java b/common/src/main/java/common/entity/animal/EntityCow.java index 62641f85..711a0bb1 100755 --- a/common/src/main/java/common/entity/animal/EntityCow.java +++ b/common/src/main/java/common/entity/animal/EntityCow.java @@ -124,7 +124,7 @@ public class EntityCow extends EntityAnimal if (itemstack != null && itemstack.getItem() == Items.bucket /* && !player.creative */ && !this.isChild()) { - if (itemstack.size-- == 1) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.milk_bucket)); } diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index bee647db..610e4620 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -935,7 +935,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (!this.isTame() && !flag) { - if (itemstack != null && itemstack.interactWithEntity(player, this)) + if (itemstack != null && itemstack.getItem().itemInteractionForEntity(itemstack, player, this)) { return true; } @@ -960,7 +960,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (flag) { - if (/* !player.creative && */ --itemstack.size == 0) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } @@ -971,7 +971,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (this.func_110253_bW() && this.passenger == null) { - if (itemstack != null && itemstack.interactWithEntity(player, this)) + if (itemstack != null && itemstack.getItem().itemInteractionForEntity(itemstack, player, this)) { return true; } diff --git a/common/src/main/java/common/entity/animal/EntityMooshroom.java b/common/src/main/java/common/entity/animal/EntityMooshroom.java index bcda8a07..f1e08908 100755 --- a/common/src/main/java/common/entity/animal/EntityMooshroom.java +++ b/common/src/main/java/common/entity/animal/EntityMooshroom.java @@ -30,7 +30,7 @@ public class EntityMooshroom extends EntityCow if (itemstack != null && itemstack.getItem() == Items.bowl && !this.isChild()) { - if (itemstack.size == 1) + if (itemstack.getSize() == 1) { player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.mushroom_stew)); return true; @@ -67,7 +67,7 @@ public class EntityMooshroom extends EntityCow this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Items.red_mushroom))); } - itemstack.damageItem(1, player); + itemstack.damage(1, player); this.playSound(SoundEvent.CUT, 1.0F); } diff --git a/common/src/main/java/common/entity/animal/EntityOcelot.java b/common/src/main/java/common/entity/animal/EntityOcelot.java index 3dd9c4d9..2cffee8e 100755 --- a/common/src/main/java/common/entity/animal/EntityOcelot.java +++ b/common/src/main/java/common/entity/animal/EntityOcelot.java @@ -219,12 +219,7 @@ public class EntityOcelot extends EntityTameable } else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() instanceof ItemFishFood fish && !fish.isCooked() && player.getDistanceSqToEntity(this) < 9.0D) { -// if (!player.creative) -// { - --itemstack.size; -// } - - if (itemstack.size <= 0) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } diff --git a/common/src/main/java/common/entity/animal/EntitySheep.java b/common/src/main/java/common/entity/animal/EntitySheep.java index b3654128..7a63f34a 100755 --- a/common/src/main/java/common/entity/animal/EntitySheep.java +++ b/common/src/main/java/common/entity/animal/EntitySheep.java @@ -199,7 +199,7 @@ public class EntitySheep extends EntityAnimal } } - itemstack.damageItem(1, player); + itemstack.damage(1, player); this.playSound(SoundEvent.CUT, 1.0F); } diff --git a/common/src/main/java/common/entity/animal/EntityWolf.java b/common/src/main/java/common/entity/animal/EntityWolf.java index 3f5d1074..f188f7ba 100755 --- a/common/src/main/java/common/entity/animal/EntityWolf.java +++ b/common/src/main/java/common/entity/animal/EntityWolf.java @@ -360,14 +360,9 @@ public class EntityWolf extends EntityTameable if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectInt(18) < 20) { -// if (!player.creative) -// { - --itemstack.size; -// } - this.heal(itemfood.getHealAmount(itemstack)); - if (itemstack.size <= 0) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } @@ -383,7 +378,7 @@ public class EntityWolf extends EntityTameable { this.setCollarColor(enumdyecolor); - if (/* !player.creative && */ --itemstack.size <= 0) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } @@ -403,12 +398,7 @@ public class EntityWolf extends EntityTameable } else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry()) { -// if (!player.creative) -// { - --itemstack.size; -// } - - if (itemstack.size <= 0) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } diff --git a/common/src/main/java/common/entity/item/EntityCartContainer.java b/common/src/main/java/common/entity/item/EntityCartContainer.java index 561bf646..761474ea 100755 --- a/common/src/main/java/common/entity/item/EntityCartContainer.java +++ b/common/src/main/java/common/entity/item/EntityCartContainer.java @@ -62,7 +62,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl { if (this.minecartContainerItems[index] != null) { - if (this.minecartContainerItems[index].size <= count) + if (this.minecartContainerItems[index].getSize() <= count) { ItemStack itemstack1 = this.minecartContainerItems[index]; this.minecartContainerItems[index] = null; @@ -70,9 +70,9 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl } else { - ItemStack itemstack = this.minecartContainerItems[index].splitStack(count); + ItemStack itemstack = this.minecartContainerItems[index].split(count); - if (this.minecartContainerItems[index].size == 0) + if (this.minecartContainerItems[index].isEmpty()) { this.minecartContainerItems[index] = null; } @@ -110,9 +110,9 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl { this.minecartContainerItems[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } } diff --git a/common/src/main/java/common/entity/item/EntityItem.java b/common/src/main/java/common/entity/item/EntityItem.java index 6042aad3..bbf7669c 100755 --- a/common/src/main/java/common/entity/item/EntityItem.java +++ b/common/src/main/java/common/entity/item/EntityItem.java @@ -212,39 +212,39 @@ public class EntityItem extends Entity } else if (other.isEntityAlive() && this.isEntityAlive()) { - ItemStack itemstack = this.getEntityItem(); - ItemStack itemstack1 = other.getEntityItem(); + ItemStack stack = this.getEntityItem(); + ItemStack otherStack = other.getEntityItem(); if (this.delayBeforeCanPickup != 32767 && other.delayBeforeCanPickup != 32767) { if (this.age != -32768 && other.age != -32768) { - if (itemstack1.getItem() != itemstack.getItem()) + if (otherStack.getItem() != stack.getItem()) { return false; } - else if (!itemstack1.dataEquals(itemstack)) + else if (!otherStack.dataEquals(stack)) { return false; } - else if (itemstack1.getItem() == null) + else if (otherStack.getItem() == null) { return false; } - else if (itemstack1.size < itemstack.size) + else if (otherStack.getSize() < stack.getSize()) { return other.combineItems(this); } - else if (itemstack1.size + itemstack.size > itemstack1.getMaxStackSize()) + else if (otherStack.getSize() + stack.getSize() > otherStack.getMaxStackSize()) { return false; } else { - itemstack1.size += itemstack.size; + otherStack.incrSize(stack.getSize()); other.delayBeforeCanPickup = Math.max(other.delayBeforeCanPickup, this.delayBeforeCanPickup); other.age = Math.min(other.age, this.age); - other.setEntityItemStack(itemstack1); + other.setEntityItemStack(otherStack); this.setDead(); return true; } @@ -389,7 +389,7 @@ public class EntityItem extends Entity if (!this.worldObj.client) { ItemStack itemstack = this.getEntityItem(); - int i = itemstack.size; + int i = itemstack.getSize(); if (this.delayBeforeCanPickup == 0 // && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getUser())) && entityIn.inventory.addItemStackToInventory(itemstack)) @@ -436,7 +436,7 @@ public class EntityItem extends Entity entityIn.onItemPickup(this, i); - if (itemstack.size <= 0) + if (itemstack.isEmpty()) { this.setDead(); } @@ -451,10 +451,8 @@ public class EntityItem extends Entity { if(this.hasCustomName()) return this.getCustomNameTag(); - String comp = super.getTypeName(); - comp += " (" + this.getEntityItem().size + " * " + - ItemRegistry.getName(this.getEntityItem().getItem()) + ")"; - return comp; + ItemStack stack = this.getEntityItem(); + return super.getTypeName() + " (" + (stack.isStacked() ? stack.getSize() + " * " : "") + stack.getItem().getDisplay() + ")"; } /** @@ -600,9 +598,9 @@ public class EntityItem extends Entity public String getDisplayName() { ItemStack stack = this.getEntityItem(); - if(stack.size <= 1) + if(!stack.isStacked()) return null; - return TextColor.DGREEN + "" + stack.size; + return TextColor.DGREEN + "" + stack.getSize(); } public EntityType getType() { diff --git a/common/src/main/java/common/entity/npc/EntityHaunter.java b/common/src/main/java/common/entity/npc/EntityHaunter.java index 690fd142..b41f1c51 100755 --- a/common/src/main/java/common/entity/npc/EntityHaunter.java +++ b/common/src/main/java/common/entity/npc/EntityHaunter.java @@ -237,7 +237,7 @@ public class EntityHaunter extends EntityNPC { if (!this.worldObj.client) { this.ignite(); - itemstack.damageItem(1, player); + itemstack.damage(1, player); return true; } } diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index 647b8fd8..8bc4decf 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -564,19 +564,6 @@ public abstract class EntityNPC extends EntityLiving // return ; // } - protected void consumeItemFromStack(EntityNPC player, ItemStack stack) - { -// if (!player.creative) -// { - --stack.size; - - if (stack.size <= 0) - { - player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); - } -// } - } - // protected boolean canDropLoot() // { // return true; @@ -636,13 +623,14 @@ public abstract class EntityNPC extends EntityLiving public boolean interact(EntityNPC player) { - ItemStack itemstack = player.inventory.getCurrentItem(); - boolean flag = itemstack != null && !(itemstack.getItem() instanceof ItemTool || itemstack.getItem() instanceof ItemSword || - itemstack.getItem() instanceof ItemHoe || itemstack.getItem() instanceof ItemShears); + ItemStack stack = player.inventory.getCurrentItem(); + boolean flag = stack != null && !(stack.getItem() instanceof ItemTool || stack.getItem() instanceof ItemSword || + stack.getItem() instanceof ItemHoe || stack.getItem() instanceof ItemShears); - if (itemstack != null && !this.isPlayer() && this.isBreedingItem(itemstack) && this.getGrowingAge() == 0 && !this.isMating()) + if (stack != null && !this.isPlayer() && this.isBreedingItem(stack) && this.getGrowingAge() == 0 && !this.isMating()) { - this.consumeItemFromStack(player, itemstack); + if(stack.decrSize()) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); if (!this.worldObj.client) { this.setIsWillingToMate(true); @@ -651,9 +639,10 @@ public abstract class EntityNPC extends EntityLiving } return true; } - else if (itemstack != null && !this.isPlayer() && this.isBreedingItem(itemstack) && this.getGrowingAge() < 0) + else if (stack != null && !this.isPlayer() && this.isBreedingItem(stack) && this.getGrowingAge() < 0) { - this.consumeItemFromStack(player, itemstack); + if(stack.decrSize()) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); if (!this.worldObj.client) { this.grow(this.rand.range(200, 250)); @@ -1437,7 +1426,7 @@ public abstract class EntityNPC extends EntityLiving } else { - stack.size = remain.size; + stack.setSize(remain.getSize()); } } } @@ -1670,7 +1659,7 @@ public abstract class EntityNPC extends EntityLiving ItemStack itemstack = this.prevEquipment[j]; ItemStack itemstack1 = this.getItem(j); - if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) + if (!ItemStack.allEquals(itemstack1, itemstack)) { ((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityEquipment(this.getId(), j, itemstack1)); @@ -1681,7 +1670,7 @@ public abstract class EntityNPC extends EntityLiving if (itemstack1 != null) { - this.attributes.add(itemstack1.getAttributeModifiers(UsageSlot.getByIndex(j)), -1 - j, itemstack1.size); + this.attributes.add(itemstack1.getAttributeModifiers(UsageSlot.getByIndex(j)), -1 - j, itemstack1.getSize()); } this.prevEquipment[j] = itemstack1 == null ? null : itemstack1.copy(); @@ -1959,7 +1948,7 @@ public abstract class EntityNPC extends EntityLiving this.client.addToSendQueue(new CPacketBreak(c07packetplayerdigging$action, BlockPos.ORIGIN, Facing.DOWN)); return null; } - return this.dropItem(this.inventory.decrStackSize(this.inventory.currentItem, dropAll && this.inventory.getCurrentItem() != null ? this.inventory.getCurrentItem().size : 1), false, true); + return this.dropItem(this.inventory.decrStackSize(this.inventory.currentItem, dropAll && this.inventory.getCurrentItem() != null ? this.inventory.getCurrentItem().getSize() : 1), false, true); } /** @@ -2905,14 +2894,14 @@ public abstract class EntityNPC extends EntityLiving if (this.itemInUse != null) { this.updateItemUse(this.itemInUse, 16); - int i = this.itemInUse.size; - ItemStack itemstack = this.itemInUse.onItemUseFinish(this.worldObj, this); + int i = this.itemInUse.getSize(); + ItemStack itemstack = this.itemInUse.getItem().onItemUseFinish(this.itemInUse, this.worldObj, this); - if (itemstack != this.itemInUse || itemstack != null && itemstack.size != i) + if (itemstack != this.itemInUse || itemstack != null && itemstack.getSize() != i) { this.inventory.mainInventory[this.inventory.currentItem] = itemstack; - if (itemstack.size == 0) + if (itemstack.isEmpty()) { this.inventory.mainInventory[this.inventory.currentItem] = null; } @@ -3035,7 +3024,7 @@ public abstract class EntityNPC extends EntityLiving { if (this.itemInUse != null) { - this.itemInUse.onPlayerStoppedUsing(this.worldObj, this, this.itemInUseCount); + this.itemInUse.getItem().onPlayerStoppedUsing(this.itemInUse, this.worldObj, this, this.itemInUseCount); } this.clearItemInUse(); @@ -3210,7 +3199,7 @@ public abstract class EntityNPC extends EntityLiving { return null; } - else if (droppedItem.size == 0) + else if (droppedItem.isEmpty()) { return null; } @@ -3622,9 +3611,9 @@ public abstract class EntityNPC extends EntityLiving // itemstack = itemstack1; // } - if (itemstack.interactWithEntity(this, (EntityLiving)targetEntity)) + if (itemstack.getItem().itemInteractionForEntity(itemstack, this, (EntityLiving)targetEntity)) { - if (itemstack.size <= 0) // && !this.creative) + if (itemstack.isEmpty()) // && !this.creative) { this.destroyCurrentEquippedItem(); } @@ -3639,7 +3628,7 @@ public abstract class EntityNPC extends EntityLiving { if (itemstack != null && itemstack == this.getCurrentEquippedItem()) { - if (itemstack.size <= 0) // && !this.creative) + if (itemstack.isEmpty()) // && !this.creative) { this.destroyCurrentEquippedItem(); } @@ -3790,9 +3779,9 @@ public abstract class EntityNPC extends EntityLiving if (itemstack != null && entity instanceof EntityLiving) { - itemstack.hitEntity((EntityLiving)entity, this); + itemstack.getItem().hitEntity(itemstack, (EntityLiving)entity, this); - if (itemstack.size <= 0) + if (itemstack.isEmpty()) { this.destroyCurrentEquippedItem(); } diff --git a/common/src/main/java/common/entity/types/EntityAnimal.java b/common/src/main/java/common/entity/types/EntityAnimal.java index 2c82f234..0b627a8e 100755 --- a/common/src/main/java/common/entity/types/EntityAnimal.java +++ b/common/src/main/java/common/entity/types/EntityAnimal.java @@ -164,20 +164,22 @@ public abstract class EntityAnimal extends EntityLiving */ public boolean interact(EntityNPC player) { - ItemStack itemstack = player.inventory.getCurrentItem(); + ItemStack stack = player.inventory.getCurrentItem(); - if (itemstack != null) + if (stack != null) { - if (this.isBreedingItem(itemstack) && this.getGrowingAge() == 0 && !this.isInLove()) + if (this.isBreedingItem(stack) && this.getGrowingAge() == 0 && !this.isInLove()) { - this.consumeItemFromStack(player, itemstack); + if(stack.decrSize()) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); this.setInLove(player); return true; } - if (this.isChild() && this.isBreedingItem(itemstack)) + if (this.isChild() && this.isBreedingItem(stack)) { - this.consumeItemFromStack(player, itemstack); + if(stack.decrSize()) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); if(!this.worldObj.client) this.grow((int)((float)(-this.getGrowingAge() / 20) * 0.1F)); return true; @@ -187,22 +189,6 @@ public abstract class EntityAnimal extends EntityLiving return super.interact(player); } - /** - * Decreases ItemStack size by one - */ - protected void consumeItemFromStack(EntityNPC player, ItemStack stack) - { -// if (!player.creative) -// { - --stack.size; - - if (stack.size <= 0) - { - player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); - } -// } - } - public void setInLove(EntityNPC player) { if(!this.worldObj.client) { diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index b6990122..9c7a674d 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -900,7 +900,7 @@ public abstract class EntityLiving extends Entity { if ((source == DamageSource.anvil || source == DamageSource.fallingBlock) && this.getItem(4) != null) { - this.getItem(4).damageItem((int)(amount * 4.0F + this.rand.floatv() * (float)amount * 2.0F), this); + this.getItem(4).damage((int)(amount * 4.0F + this.rand.floatv() * (float)amount * 2.0F), this); amount = (int)((float)amount * 0.75F); } @@ -2684,33 +2684,17 @@ public abstract class EntityLiving extends Entity public boolean interactFirst(EntityNPC player) { if(this.getLeashed() && this.getLeashedTo() == player) { - this.clearLeashed(true, true); // !player.creative); + this.clearLeashed(true, true); return true; } - else { - ItemStack stack = player.inventory.getCurrentItem(); - - if(stack != null && stack.getItem() == Items.lead && this.allowLeashing()) { - if(!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed()) { - this.setLeashedTo(player, true); - --stack.size; - return true; - } - - if(((EntityTameable)this).isOwner(player)) { - this.setLeashedTo(player, true); - --stack.size; - return true; - } - } - - if(this.interact(player)) { - return true; - } - else { - return super.interactFirst(player); - } + ItemStack stack = player.inventory.getCurrentItem(); + if(stack != null && stack.getItem() == Items.lead && this.allowLeashing() && (!(this instanceof EntityTameable tameable) || !tameable.isTamed() || tameable.isOwner(player))) { + this.setLeashedTo(player, true); + if(stack.decrSize()) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + return true; } + return this.interact(player) || super.interactFirst(player); } // protected boolean interact(EntityNPC player) { @@ -3140,9 +3124,8 @@ public abstract class EntityLiving extends Entity // if (!player.creative) // { - --itemstack.size; - if (itemstack.size <= 0) + if (itemstack.decrSize()) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } diff --git a/common/src/main/java/common/init/CraftingRegistry.java b/common/src/main/java/common/init/CraftingRegistry.java index 935d162b..6b2375c2 100755 --- a/common/src/main/java/common/init/CraftingRegistry.java +++ b/common/src/main/java/common/init/CraftingRegistry.java @@ -527,7 +527,7 @@ public abstract class CraftingRegistry { ItemStack itemstack1 = (ItemStack)list.get(0); - if (itemstack.getItem() != itemstack1.getItem() || itemstack1.size != 1 || itemstack.size != 1 || !itemstack1.getItem().isDamageable()) + if (itemstack.getItem() != itemstack1.getItem() || itemstack1.getSize() != 1 || itemstack.getSize() != 1 || !itemstack1.getItem().isDamageable()) { return false; } @@ -557,7 +557,7 @@ public abstract class CraftingRegistry { ItemStack itemstack1 = (ItemStack)list.get(0); - if (itemstack.getItem() != itemstack1.getItem() || itemstack1.size != 1 || itemstack.size != 1 || !itemstack1.getItem().isDamageable()) + if (itemstack.getItem() != itemstack1.getItem() || itemstack1.getSize() != 1 || itemstack.getSize() != 1 || !itemstack1.getItem().isDamageable()) { return null; } @@ -570,7 +570,7 @@ public abstract class CraftingRegistry ItemStack itemstack2 = (ItemStack)list.get(0); ItemStack itemstack3 = (ItemStack)list.get(1); - if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.size == 1 && itemstack3.size == 1 && itemstack2.getItem().isDamageable()) + if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.getSize() == 1 && itemstack3.getSize() == 1 && itemstack2.getItem().isDamageable()) { Item item = itemstack2.getItem(); int j = item.getMaxDamage() - itemstack2.getItemDamage(); @@ -686,8 +686,7 @@ public abstract class CraftingRegistry return null; } - itemstack = itemstack1.copy(); - itemstack.size = 1; + itemstack = itemstack1.copy(1); if (itemstack1.hasColor()) { diff --git a/common/src/main/java/common/inventory/Container.java b/common/src/main/java/common/inventory/Container.java index 6a9e1543..13ab4d5e 100755 --- a/common/src/main/java/common/inventory/Container.java +++ b/common/src/main/java/common/inventory/Container.java @@ -84,7 +84,7 @@ public abstract class Container ItemStack current = ((Slot)this.inventorySlots.get(i)).getStack(); ItemStack last = (ItemStack)this.inventoryItemStacks.get(i); - if (!ItemStack.areItemStacksEqual(last, current)) + if (!ItemStack.allEquals(last, current)) { last = current == null ? null : current.copy(); this.inventoryItemStacks.set(i, last); @@ -178,7 +178,7 @@ public abstract class Container { Slot slot = (Slot)this.inventorySlots.get(slotId); - if (slot != null && canAddItemToSlot(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().size > this.dragSlots.size() && this.canDragIntoSlot(slot)) + if (slot != null && canAddItemToSlot(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().getSize() > this.dragSlots.size() && this.canDragIntoSlot(slot)) { this.dragSlots.add(slot); } @@ -188,34 +188,34 @@ public abstract class Container if (!this.dragSlots.isEmpty()) { ItemStack itemstack3 = inventoryplayer.getItemStack().copy(); - int j = inventoryplayer.getItemStack().size; + int j = inventoryplayer.getItemStack().getSize(); for (Slot slot1 : this.dragSlots) { - if (slot1 != null && canAddItemToSlot(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().size >= this.dragSlots.size() && this.canDragIntoSlot(slot1)) + if (slot1 != null && canAddItemToSlot(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().getSize() >= this.dragSlots.size() && this.canDragIntoSlot(slot1)) { ItemStack itemstack1 = itemstack3.copy(); - int k = slot1.getHasStack() ? slot1.getStack().size : 0; + int k = slot1.getHasStack() ? slot1.getStack().getSize() : 0; computeStackSize(this.dragSlots, this.dragMode, itemstack1, k); - if (itemstack1.size > itemstack1.getMaxStackSize()) + if (itemstack1.isOverLimit()) { - itemstack1.size = itemstack1.getMaxStackSize(); + itemstack1.setSize(itemstack1.getMaxStackSize()); } - if (itemstack1.size > slot1.getItemStackLimit(itemstack1)) + if (itemstack1.getSize() > slot1.getItemStackLimit(itemstack1)) { - itemstack1.size = slot1.getItemStackLimit(itemstack1); + itemstack1.setSize(slot1.getItemStackLimit(itemstack1)); } - j -= itemstack1.size - k; + j -= itemstack1.getSize() - k; slot1.putStack(itemstack1); } } - itemstack3.size = j; + itemstack3.setSize(j); - if (itemstack3.size <= 0) + if (itemstack3.isEmpty()) { itemstack3 = null; } @@ -248,9 +248,9 @@ public abstract class Container if (clickedButton == 1) { - playerIn.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().splitStack(1), true); + playerIn.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().split(1), true); - if (inventoryplayer.getItemStack().size == 0) + if (inventoryplayer.getItemStack().isEmpty()) { inventoryplayer.setItemStack((ItemStack)null); } @@ -305,19 +305,19 @@ public abstract class Container { if (itemstack10 != null && slot7.isItemValid(itemstack10)) { - int k2 = clickedButton == 0 ? itemstack10.size : 1; + int k2 = clickedButton == 0 ? itemstack10.getSize() : 1; if (k2 > slot7.getItemStackLimit(itemstack10)) { k2 = slot7.getItemStackLimit(itemstack10); } - if (itemstack10.size >= k2) + if (itemstack10.getSize() >= k2) { - slot7.putStack(itemstack10.splitStack(k2)); + slot7.putStack(itemstack10.split(k2)); } - if (itemstack10.size == 0) + if (itemstack10.isEmpty()) { inventoryplayer.setItemStack((ItemStack)null); } @@ -327,11 +327,11 @@ public abstract class Container { if (itemstack10 == null) { - int j2 = clickedButton == 0 ? itemstack9.size : (itemstack9.size + 1) / 2; + int j2 = clickedButton == 0 ? itemstack9.getSize() : (itemstack9.getSize() + 1) / 2; ItemStack itemstack12 = slot7.decrStackSize(j2); inventoryplayer.setItemStack(itemstack12); - if (itemstack9.size == 0) + if (itemstack9.isEmpty()) { slot7.putStack((ItemStack)null); } @@ -340,45 +340,45 @@ public abstract class Container } else if (slot7.isItemValid(itemstack10)) { - if (itemstack9.getItem() == itemstack10.getItem() && ItemStack.areItemStackTagsEqual(itemstack9, itemstack10)) + if (itemstack9.getItem() == itemstack10.getItem() && ItemStack.dataEquals(itemstack9, itemstack10)) { - int i2 = clickedButton == 0 ? itemstack10.size : 1; + int i2 = clickedButton == 0 ? itemstack10.getSize() : 1; - if (i2 > slot7.getItemStackLimit(itemstack10) - itemstack9.size) + if (i2 > slot7.getItemStackLimit(itemstack10) - itemstack9.getSize()) { - i2 = slot7.getItemStackLimit(itemstack10) - itemstack9.size; + i2 = slot7.getItemStackLimit(itemstack10) - itemstack9.getSize(); } - if (i2 > itemstack10.getMaxStackSize() - itemstack9.size) + if (i2 > itemstack10.getMaxStackSize() - itemstack9.getSize()) { - i2 = itemstack10.getMaxStackSize() - itemstack9.size; + i2 = itemstack10.getMaxStackSize() - itemstack9.getSize(); } - itemstack10.splitStack(i2); + itemstack10.split(i2); - if (itemstack10.size == 0) + if (itemstack10.isEmpty()) { inventoryplayer.setItemStack((ItemStack)null); } - itemstack9.size += i2; + itemstack9.incrSize(i2); } - else if (itemstack10.size <= slot7.getItemStackLimit(itemstack10)) + else if (itemstack10.getSize() <= slot7.getItemStackLimit(itemstack10)) { slot7.putStack(itemstack10); inventoryplayer.setItemStack(itemstack9); } } - else if (itemstack9.getItem() == itemstack10.getItem() && itemstack10.getMaxStackSize() > 1 && ItemStack.areItemStackTagsEqual(itemstack9, itemstack10)) + else if (itemstack9.getItem() == itemstack10.getItem() && itemstack10.getMaxStackSize() > 1 && ItemStack.dataEquals(itemstack9, itemstack10)) { - int l1 = itemstack9.size; + int l1 = itemstack9.getSize(); - if (l1 > 0 && l1 + itemstack10.size <= itemstack10.getMaxStackSize()) + if (l1 > 0 && l1 + itemstack10.getSize() <= itemstack10.getMaxStackSize()) { - itemstack10.size += l1; + itemstack10.incrSize(l1); itemstack9 = slot7.decrStackSize(l1); - if (itemstack9.size == 0) + if (itemstack9.isEmpty()) { slot7.putStack((ItemStack)null); } @@ -418,14 +418,14 @@ public abstract class Container if (k1 > -1) { inventoryplayer.addItemStackToInventory(itemstack7); - slot5.decrStackSize(itemstack11.size); + slot5.decrStackSize(itemstack11.getSize()); slot5.putStack((ItemStack)null); slot5.onPickupFromSlot(playerIn, itemstack11); } } else { - slot5.decrStackSize(itemstack11.size); + slot5.decrStackSize(itemstack11.getSize()); slot5.putStack(itemstack7); slot5.onPickupFromSlot(playerIn, itemstack11); } @@ -454,7 +454,7 @@ public abstract class Container if (slot3 != null && slot3.getHasStack() && slot3.canTakeStack(playerIn)) { - ItemStack itemstack5 = slot3.decrStackSize(clickedButton == 0 ? 1 : slot3.getStack().size); + ItemStack itemstack5 = slot3.decrStackSize(clickedButton == 0 ? 1 : slot3.getStack().getSize()); slot3.onPickupFromSlot(playerIn, itemstack5); playerIn.dropPlayerItemWithRandomChoice(itemstack5, true); } @@ -471,17 +471,17 @@ public abstract class Container for (int l2 = 0; l2 < 2; ++l2) { - for (int i3 = i1; i3 >= 0 && i3 < this.inventorySlots.size() && itemstack4.size < itemstack4.getMaxStackSize(); i3 += j1) + for (int i3 = i1; i3 >= 0 && i3 < this.inventorySlots.size() && !itemstack4.isFull(); i3 += j1) { Slot slot8 = (Slot)this.inventorySlots.get(i3); - if (slot8.getHasStack() && canAddItemToSlot(slot8, itemstack4, true) && slot8.canTakeStack(playerIn) && this.canMergeSlot(itemstack4, slot8) && (l2 != 0 || slot8.getStack().size != slot8.getStack().getMaxStackSize())) + if (slot8.getHasStack() && canAddItemToSlot(slot8, itemstack4, true) && slot8.canTakeStack(playerIn) && this.canMergeSlot(itemstack4, slot8) && (l2 != 0 || !slot8.getStack().isFull())) { - int l = Math.min(itemstack4.getMaxStackSize() - itemstack4.size, slot8.getStack().size); + int l = Math.min(itemstack4.getMaxStackSize() - itemstack4.getSize(), slot8.getStack().getSize()); ItemStack itemstack2 = slot8.decrStackSize(l); - itemstack4.size += l; + itemstack4.incrSize(l); - if (itemstack2.size <= 0) + if (itemstack2.isEmpty()) { slot8.putStack((ItemStack)null); } @@ -611,26 +611,26 @@ public abstract class Container if (stack.isStackable()) { - while (stack.size > 0 && (!reverseDirection && i < endIndex || reverseDirection && i >= startIndex)) + while (!stack.isEmpty() && (!reverseDirection && i < endIndex || reverseDirection && i >= startIndex)) { Slot slot = (Slot)this.inventorySlots.get(i); ItemStack itemstack = slot.getStack(); - if (itemstack != null && itemstack.getItem() == stack.getItem() && ItemStack.areItemStackTagsEqual(stack, itemstack)) + if (itemstack != null && itemstack.getItem() == stack.getItem() && ItemStack.dataEquals(stack, itemstack)) { - int j = itemstack.size + stack.size; + int j = itemstack.getSize() + stack.getSize(); if (j <= stack.getMaxStackSize()) { - stack.size = 0; - itemstack.size = j; + stack.setSize(0); + itemstack.setSize(j); slot.onSlotChanged(); flag = true; } - else if (itemstack.size < stack.getMaxStackSize()) + else if (itemstack.getSize() < stack.getMaxStackSize()) { - stack.size -= stack.getMaxStackSize() - itemstack.size; - itemstack.size = stack.getMaxStackSize(); + stack.decrSize(stack.getMaxStackSize() - itemstack.getSize()); + itemstack.setSize(stack.getMaxStackSize()); slot.onSlotChanged(); flag = true; } @@ -647,7 +647,7 @@ public abstract class Container } } - if (stack.size > 0) + if (!stack.isEmpty()) { if (reverseDirection) { @@ -667,7 +667,7 @@ public abstract class Container { slot1.putStack(stack.copy()); slot1.onSlotChanged(); - stack.size = 0; + stack.setSize(0); flag = true; break; } @@ -732,9 +732,9 @@ public abstract class Container { boolean flag = slotIn == null || !slotIn.getHasStack(); - if (slotIn != null && slotIn.getHasStack() && stack != null && stack.isItemEqual(slotIn.getStack()) && ItemStack.areItemStackTagsEqual(slotIn.getStack(), stack)) + if (slotIn != null && slotIn.getHasStack() && stack != null && stack.itemEquals(slotIn.getStack()) && ItemStack.dataEquals(slotIn.getStack(), stack)) { - flag |= slotIn.getStack().size + (stackSizeMatters ? 0 : stack.size) <= stack.getMaxStackSize(); + flag |= slotIn.getStack().getSize() + (stackSizeMatters ? 0 : stack.getSize()) <= stack.getMaxStackSize(); } return flag; @@ -749,18 +749,18 @@ public abstract class Container switch (p_94525_1_) { case 0: - p_94525_2_.size = ExtMath.floorf((float)p_94525_2_.size / (float)p_94525_0_.size()); + p_94525_2_.setSize(ExtMath.floorf((float)p_94525_2_.getSize() / (float)p_94525_0_.size())); break; case 1: - p_94525_2_.size = 1; + p_94525_2_.setSize(1); break; case 2: - p_94525_2_.size = p_94525_2_.getItem().getMaxAmount(); + p_94525_2_.setSize(p_94525_2_.getItem().getMaxAmount()); } - p_94525_2_.size += p_94525_3_; + p_94525_2_.incrSize(p_94525_3_); } /** @@ -797,7 +797,7 @@ public abstract class Container if (itemstack != null) { - f += (float)itemstack.size / (float)Math.min(inv.getInventoryStackLimit(), itemstack.getMaxStackSize()); + f += (float)itemstack.getSize() / (float)Math.min(inv.getInventoryStackLimit(), itemstack.getMaxStackSize()); ++i; } } diff --git a/common/src/main/java/common/inventory/ContainerBrewingStand.java b/common/src/main/java/common/inventory/ContainerBrewingStand.java index 460229c3..9f5584ef 100755 --- a/common/src/main/java/common/inventory/ContainerBrewingStand.java +++ b/common/src/main/java/common/inventory/ContainerBrewingStand.java @@ -128,7 +128,7 @@ public class ContainerBrewingStand extends Container slot.onSlotChange(itemstack1, itemstack); } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -137,7 +137,7 @@ public class ContainerBrewingStand extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerChest.java b/common/src/main/java/common/inventory/ContainerChest.java index c20fb4d9..9b6eb89c 100755 --- a/common/src/main/java/common/inventory/ContainerChest.java +++ b/common/src/main/java/common/inventory/ContainerChest.java @@ -67,7 +67,7 @@ public class ContainerChest extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } diff --git a/common/src/main/java/common/inventory/ContainerDispenser.java b/common/src/main/java/common/inventory/ContainerDispenser.java index 5ed17e54..59df0fa0 100755 --- a/common/src/main/java/common/inventory/ContainerDispenser.java +++ b/common/src/main/java/common/inventory/ContainerDispenser.java @@ -63,7 +63,7 @@ public class ContainerDispenser extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -72,7 +72,7 @@ public class ContainerDispenser extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerEnchantment.java b/common/src/main/java/common/inventory/ContainerEnchantment.java index 1b69294c..28e9766e 100755 --- a/common/src/main/java/common/inventory/ContainerEnchantment.java +++ b/common/src/main/java/common/inventory/ContainerEnchantment.java @@ -330,16 +330,15 @@ public class ContainerEnchantment extends Container return null; } - if (itemstack1.size >= 1) + if (!itemstack1.isEmpty()) { - ItemStack st = itemstack1.copy(); - st.size = 1; + ItemStack st = itemstack1.copy(1); ((Slot)this.inventorySlots.get(0)).putStack(st); - --itemstack1.size; + itemstack1.decrSize(); } } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -348,7 +347,7 @@ public class ContainerEnchantment extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerEntityInventory.java b/common/src/main/java/common/inventory/ContainerEntityInventory.java index 32ba225c..f12b39b4 100755 --- a/common/src/main/java/common/inventory/ContainerEntityInventory.java +++ b/common/src/main/java/common/inventory/ContainerEntityInventory.java @@ -108,7 +108,7 @@ public class ContainerEntityInventory extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } diff --git a/common/src/main/java/common/inventory/ContainerFurnace.java b/common/src/main/java/common/inventory/ContainerFurnace.java index a4c67ff8..c7853285 100755 --- a/common/src/main/java/common/inventory/ContainerFurnace.java +++ b/common/src/main/java/common/inventory/ContainerFurnace.java @@ -143,7 +143,7 @@ public class ContainerFurnace extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -152,7 +152,7 @@ public class ContainerFurnace extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerHopper.java b/common/src/main/java/common/inventory/ContainerHopper.java index 9b8326b2..ea26801e 100755 --- a/common/src/main/java/common/inventory/ContainerHopper.java +++ b/common/src/main/java/common/inventory/ContainerHopper.java @@ -62,7 +62,7 @@ public class ContainerHopper extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } diff --git a/common/src/main/java/common/inventory/ContainerMerchant.java b/common/src/main/java/common/inventory/ContainerMerchant.java index a6b0f897..603450dc 100755 --- a/common/src/main/java/common/inventory/ContainerMerchant.java +++ b/common/src/main/java/common/inventory/ContainerMerchant.java @@ -123,7 +123,7 @@ public class ContainerMerchant extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -132,7 +132,7 @@ public class ContainerMerchant extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerPlayer.java b/common/src/main/java/common/inventory/ContainerPlayer.java index 06a92c33..6ec0e538 100755 --- a/common/src/main/java/common/inventory/ContainerPlayer.java +++ b/common/src/main/java/common/inventory/ContainerPlayer.java @@ -95,7 +95,7 @@ public class ContainerPlayer extends Container { ItemStack current = slot.getStack(); ItemStack last = (ItemStack)this.lastStacks.get(i - 9); - if (!ItemStack.areItemStacksEqual(last, current)) + if (!ItemStack.allEquals(last, current)) { if (last != null) { @@ -104,7 +104,7 @@ public class ContainerPlayer extends Container { if (current != null) { - this.attributes.add(current.getAttributeModifiers(UsageSlot.INVENTORY), slot.getIndex(), current.size); + this.attributes.add(current.getAttributeModifiers(UsageSlot.INVENTORY), slot.getIndex(), current.getSize()); } last = current == null ? null : current.copy(); @@ -226,7 +226,7 @@ public class ContainerPlayer extends Container { return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -235,7 +235,7 @@ public class ContainerPlayer extends Container { slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerRepair.java b/common/src/main/java/common/inventory/ContainerRepair.java index 2066a428..42f126c4 100755 --- a/common/src/main/java/common/inventory/ContainerRepair.java +++ b/common/src/main/java/common/inventory/ContainerRepair.java @@ -89,9 +89,9 @@ public class ContainerRepair extends Container { ItemStack itemstack = ContainerRepair.this.inputSlots.getStackInSlot(1); - if (itemstack != null && itemstack.size > ContainerRepair.this.materialCost) + if (itemstack != null && itemstack.getSize() > ContainerRepair.this.materialCost) { - itemstack.size -= ContainerRepair.this.materialCost; + itemstack.decrSize(ContainerRepair.this.materialCost); ContainerRepair.this.inputSlots.setInventorySlotContents(1, itemstack); } else @@ -210,7 +210,7 @@ public class ContainerRepair extends Container int cost; - for (cost = 0; damage > 0 && cost < repStack.size; ++cost) + for (cost = 0; damage > 0 && cost < repStack.getSize(); ++cost) { int j5 = newStack.getItemDamage() - damage; newStack.setItemDamage(j5); @@ -469,7 +469,7 @@ public class ContainerRepair extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -478,7 +478,7 @@ public class ContainerRepair extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/ContainerTile.java b/common/src/main/java/common/inventory/ContainerTile.java index e697fff3..884ad068 100755 --- a/common/src/main/java/common/inventory/ContainerTile.java +++ b/common/src/main/java/common/inventory/ContainerTile.java @@ -77,7 +77,7 @@ public class ContainerTile extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } diff --git a/common/src/main/java/common/inventory/ContainerWorkbench.java b/common/src/main/java/common/inventory/ContainerWorkbench.java index 6fdb8697..d5dcb0ea 100755 --- a/common/src/main/java/common/inventory/ContainerWorkbench.java +++ b/common/src/main/java/common/inventory/ContainerWorkbench.java @@ -129,7 +129,7 @@ public class ContainerWorkbench extends Container return null; } - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { slot.putStack((ItemStack)null); } @@ -138,7 +138,7 @@ public class ContainerWorkbench extends Container slot.onSlotChanged(); } - if (itemstack1.size == itemstack.size) + if (itemstack1.getSize() == itemstack.getSize()) { return null; } diff --git a/common/src/main/java/common/inventory/InventoryBasic.java b/common/src/main/java/common/inventory/InventoryBasic.java index 1e7086d8..ec6e889a 100755 --- a/common/src/main/java/common/inventory/InventoryBasic.java +++ b/common/src/main/java/common/inventory/InventoryBasic.java @@ -68,7 +68,7 @@ public class InventoryBasic implements IInventory { if (this.inventoryContents[index] != null) { - if (this.inventoryContents[index].size <= count) + if (this.inventoryContents[index].getSize() <= count) { ItemStack itemstack1 = this.inventoryContents[index]; this.inventoryContents[index] = null; @@ -77,9 +77,9 @@ public class InventoryBasic implements IInventory } else { - ItemStack itemstack = this.inventoryContents[index].splitStack(count); + ItemStack itemstack = this.inventoryContents[index].split(count); - if (this.inventoryContents[index].size == 0) + if (this.inventoryContents[index].isEmpty()) { this.inventoryContents[index] = null; } @@ -109,17 +109,15 @@ public class InventoryBasic implements IInventory return null; } - if (ItemStack.areItemsEqual(itemstack1, itemstack)) + if (ItemStack.itemEquals(itemstack1, itemstack)) { int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize()); - int k = Math.min(itemstack.size, j - itemstack1.size); + int k = Math.min(itemstack.getSize(), j - itemstack1.getSize()); if (k > 0) { - itemstack1.size += k; - itemstack.size -= k; - - if (itemstack.size <= 0) + itemstack1.incrSize(k); + if (itemstack.decrSize(k)) { this.markDirty(); return null; @@ -128,7 +126,7 @@ public class InventoryBasic implements IInventory } } - if (itemstack.size != stack.size) + if (itemstack.getSize() != stack.getSize()) { this.markDirty(); } @@ -160,9 +158,9 @@ public class InventoryBasic implements IInventory { this.inventoryContents[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } this.markDirty(); diff --git a/common/src/main/java/common/inventory/InventoryCrafting.java b/common/src/main/java/common/inventory/InventoryCrafting.java index e026d87c..96441c19 100755 --- a/common/src/main/java/common/inventory/InventoryCrafting.java +++ b/common/src/main/java/common/inventory/InventoryCrafting.java @@ -98,7 +98,7 @@ public class InventoryCrafting implements IInventory { if (this.stackList[index] != null) { - if (this.stackList[index].size <= count) + if (this.stackList[index].getSize() <= count) { ItemStack itemstack1 = this.stackList[index]; this.stackList[index] = null; @@ -107,9 +107,9 @@ public class InventoryCrafting implements IInventory } else { - ItemStack itemstack = this.stackList[index].splitStack(count); + ItemStack itemstack = this.stackList[index].split(count); - if (this.stackList[index].size == 0) + if (this.stackList[index].isEmpty()) { this.stackList[index] = null; } diff --git a/common/src/main/java/common/inventory/InventoryHelper.java b/common/src/main/java/common/inventory/InventoryHelper.java index 22886b31..0d2d1f04 100755 --- a/common/src/main/java/common/inventory/InventoryHelper.java +++ b/common/src/main/java/common/inventory/InventoryHelper.java @@ -40,16 +40,16 @@ public class InventoryHelper float f1 = RANDOM.floatv() * 0.8F + 0.1F; float f2 = RANDOM.floatv() * 0.8F + 0.1F; - while (stack.size > 0) + while (!stack.isEmpty()) { - int i = stack.size > 64 ? stack.size : (RANDOM.zrange(21) + 10); + int i = stack.getSize() > 64 ? stack.getSize() : (RANDOM.zrange(21) + 10); - if (i > stack.size) + if (i > stack.getSize()) { - i = stack.size; + i = stack.getSize(); } - stack.size -= i; + stack.decrSize(i); EntityItem entityitem = new EntityItem(worldIn, x + (double)f, y + (double)f1, z + (double)f2, new ItemStack(stack.getItem(), i)); entityitem.getEntityItem().copyData(stack); diff --git a/common/src/main/java/common/inventory/InventoryMerchant.java b/common/src/main/java/common/inventory/InventoryMerchant.java index b6f4bafd..4b1bf27c 100755 --- a/common/src/main/java/common/inventory/InventoryMerchant.java +++ b/common/src/main/java/common/inventory/InventoryMerchant.java @@ -59,7 +59,7 @@ public class InventoryMerchant implements IInventory this.theInventory[index] = null; return itemstack2; } - else if (this.theInventory[index].size <= count) + else if (this.theInventory[index].getSize() <= count) { ItemStack itemstack1 = this.theInventory[index]; this.theInventory[index] = null; @@ -73,9 +73,9 @@ public class InventoryMerchant implements IInventory } else { - ItemStack itemstack = this.theInventory[index].splitStack(count); + ItemStack itemstack = this.theInventory[index].split(count); - if (this.theInventory[index].size == 0) + if (this.theInventory[index].isEmpty()) { this.theInventory[index] = null; } @@ -126,9 +126,9 @@ public class InventoryMerchant implements IInventory { this.theInventory[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } if (this.inventoryResetNeededOnSlotChange(index)) diff --git a/common/src/main/java/common/inventory/InventoryPlayer.java b/common/src/main/java/common/inventory/InventoryPlayer.java index 9b0bae50..8404e053 100755 --- a/common/src/main/java/common/inventory/InventoryPlayer.java +++ b/common/src/main/java/common/inventory/InventoryPlayer.java @@ -72,7 +72,7 @@ public class InventoryPlayer implements IInventory { for (int i = 0; i < this.mainInventory.length; ++i) { - if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].size < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].size < this.getInventoryStackLimit() && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemStackIn)) + if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && !this.mainInventory[i].isFull() && this.mainInventory[i].getSize() < this.getInventoryStackLimit() && ItemStack.dataEquals(this.mainInventory[i], itemStackIn)) { return i; } @@ -183,7 +183,7 @@ public class InventoryPlayer implements IInventory private int storePartialItemStack(ItemStack itemStackIn) { Item item = itemStackIn.getItem(); - int i = itemStackIn.size; + int i = itemStackIn.getSize(); int j = this.storeItemStack(itemStackIn); if (j < 0) @@ -206,14 +206,14 @@ public class InventoryPlayer implements IInventory int k = i; - if (i > this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].size) + if (i > this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].getSize()) { - k = this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].size; + k = this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].getSize(); } - if (k > this.getInventoryStackLimit() - this.mainInventory[j].size) + if (k > this.getInventoryStackLimit() - this.mainInventory[j].getSize()) { - k = this.getInventoryStackLimit() - this.mainInventory[j].size; + k = this.getInventoryStackLimit() - this.mainInventory[j].getSize(); } if (k == 0) @@ -223,7 +223,7 @@ public class InventoryPlayer implements IInventory else { i = i - k; - this.mainInventory[j].size += k; + this.mainInventory[j].incrSize(k); // this.mainInventory[j].animationsToGo = 5; return i; } @@ -258,7 +258,7 @@ public class InventoryPlayer implements IInventory } else { - if (--this.mainInventory[i].size <= 0) + if (this.mainInventory[i].decrSize()) { this.mainInventory[i] = null; } @@ -281,7 +281,7 @@ public class InventoryPlayer implements IInventory */ public boolean addItemStackToInventory(final ItemStack itemStackIn) { - if (itemStackIn != null && itemStackIn.size != 0 && itemStackIn.getItem() != null) + if (itemStackIn != null && !itemStackIn.isEmpty() && itemStackIn.getItem() != null) { if (itemStackIn.isItemDamaged()) { @@ -289,9 +289,9 @@ public class InventoryPlayer implements IInventory if (j >= 0) { - this.mainInventory[j] = ItemStack.copyItemStack(itemStackIn); + this.mainInventory[j] = ItemStack.copy(itemStackIn); // this.mainInventory[j].animationsToGo = 5; - itemStackIn.size = 0; + itemStackIn.setSize(0); return true; } // else if (this.player.creative) @@ -310,10 +310,10 @@ public class InventoryPlayer implements IInventory while (true) { - i = itemStackIn.size; - itemStackIn.size = this.storePartialItemStack(itemStackIn); + i = itemStackIn.getSize(); + itemStackIn.setSize(this.storePartialItemStack(itemStackIn)); - if (itemStackIn.size <= 0 || itemStackIn.size >= i) + if (itemStackIn.isEmpty() || itemStackIn.getSize() >= i) { break; } @@ -326,7 +326,7 @@ public class InventoryPlayer implements IInventory // } // else // { - return itemStackIn.size < i; + return itemStackIn.getSize() < i; // } } } @@ -351,7 +351,7 @@ public class InventoryPlayer implements IInventory if (aitemstack[index] != null) { - if (aitemstack[index].size <= count) + if (aitemstack[index].getSize() <= count) { ItemStack itemstack1 = aitemstack[index]; aitemstack[index] = null; @@ -359,9 +359,9 @@ public class InventoryPlayer implements IInventory } else { - ItemStack itemstack = aitemstack[index].splitStack(count); + ItemStack itemstack = aitemstack[index].split(count); - if (aitemstack[index].size == 0) + if (aitemstack[index].isEmpty()) { aitemstack[index] = null; } @@ -422,7 +422,7 @@ public class InventoryPlayer implements IInventory if (this.mainInventory[this.currentItem] != null) { - f *= this.mainInventory[this.currentItem].getStrVsBlock(blockIn); + f *= this.mainInventory[this.currentItem].getItem().getStrVsBlock(this.mainInventory[this.currentItem], blockIn); } return f; @@ -541,7 +541,7 @@ public class InventoryPlayer implements IInventory if(!block.getMaterial().isToolRequired()) return true; ItemStack stack = this.getStackInSlot(this.currentItem); - return stack != null && stack.canHarvestBlock(block); + return stack != null && stack.getItem().canHarvestBlock(block); } /** @@ -589,9 +589,9 @@ public class InventoryPlayer implements IInventory { if (this.armorInventory[i] != null && this.armorInventory[i].getItem() instanceof ItemArmor) { - this.armorInventory[i].damageItem(damage, this.player); + this.armorInventory[i].damage(damage, this.player); - if (this.armorInventory[i].size == 0) + if (this.armorInventory[i].isEmpty()) { this.armorInventory[i] = null; } @@ -663,7 +663,7 @@ public class InventoryPlayer implements IInventory { for (int i = 0; i < this.armorInventory.length; ++i) { - if (this.armorInventory[i] != null && this.armorInventory[i].isItemEqual(itemStackIn)) + if (this.armorInventory[i] != null && this.armorInventory[i].itemEquals(itemStackIn)) { return true; } @@ -671,7 +671,7 @@ public class InventoryPlayer implements IInventory for (int j = 0; j < this.mainInventory.length; ++j) { - if (this.mainInventory[j] != null && this.mainInventory[j].isItemEqual(itemStackIn)) + if (this.mainInventory[j] != null && this.mainInventory[j].itemEquals(itemStackIn)) { return true; } @@ -703,12 +703,12 @@ public class InventoryPlayer implements IInventory { for (int i = 0; i < this.mainInventory.length; ++i) { - this.mainInventory[i] = ItemStack.copyItemStack(playerInventory.mainInventory[i]); + this.mainInventory[i] = ItemStack.copy(playerInventory.mainInventory[i]); } for (int j = 0; j < this.armorInventory.length; ++j) { - this.armorInventory[j] = ItemStack.copyItemStack(playerInventory.armorInventory[j]); + this.armorInventory[j] = ItemStack.copy(playerInventory.armorInventory[j]); } this.currentItem = playerInventory.currentItem; diff --git a/common/src/main/java/common/inventory/Slot.java b/common/src/main/java/common/inventory/Slot.java index e38aef18..7800ca50 100755 --- a/common/src/main/java/common/inventory/Slot.java +++ b/common/src/main/java/common/inventory/Slot.java @@ -37,7 +37,7 @@ public class Slot { if (p_75220_1_.getItem() == p_75220_2_.getItem()) { - int i = p_75220_2_.size - p_75220_1_.size; + int i = p_75220_2_.getSize() - p_75220_1_.getSize(); if (i > 0) { diff --git a/common/src/main/java/common/inventory/SlotFurnaceOutput.java b/common/src/main/java/common/inventory/SlotFurnaceOutput.java index 9f5340f5..e9cd2686 100755 --- a/common/src/main/java/common/inventory/SlotFurnaceOutput.java +++ b/common/src/main/java/common/inventory/SlotFurnaceOutput.java @@ -35,7 +35,7 @@ public class SlotFurnaceOutput extends Slot { if (this.getHasStack()) { - this.smelted += Math.min(amount, this.getStack().size); + this.smelted += Math.min(amount, this.getStack().getSize()); } return super.decrStackSize(amount); diff --git a/common/src/main/java/common/inventory/SlotMerchantResult.java b/common/src/main/java/common/inventory/SlotMerchantResult.java index 8d16fb3e..edba8158 100755 --- a/common/src/main/java/common/inventory/SlotMerchantResult.java +++ b/common/src/main/java/common/inventory/SlotMerchantResult.java @@ -35,7 +35,7 @@ public class SlotMerchantResult extends Slot { if (this.getHasStack()) { - this.traded += Math.min(amount, this.getStack().size); + this.traded += Math.min(amount, this.getStack().getSize()); } return super.decrStackSize(amount); @@ -76,12 +76,12 @@ public class SlotMerchantResult extends Slot // this.theMerchant.useRecipe(merchantrecipe); // playerIn.triggerAchievement(StatRegistry.timesTradedWithNpcStat); - if (itemstack != null && itemstack.size <= 0) + if (itemstack != null && itemstack.isEmpty()) { itemstack = null; } - if (itemstack1 != null && itemstack1.size <= 0) + if (itemstack1 != null && itemstack1.isEmpty()) { itemstack1 = null; } @@ -101,14 +101,14 @@ public class SlotMerchantResult extends Slot { if (itemstack1 != null && secondItem != null && itemstack1.getItem() == secondItem.getItem()) { - firstItem.size -= itemstack.size; - secondItem.size -= itemstack1.size; + firstItem.decrSize(itemstack.getSize()); + secondItem.decrSize(itemstack1.getSize()); return true; } if (itemstack1 == null && secondItem == null) { - firstItem.size -= itemstack.size; + firstItem.decrSize(itemstack.getSize()); return true; } } diff --git a/common/src/main/java/common/item/Item.java b/common/src/main/java/common/item/Item.java index ba80fc30..0f064b34 100755 --- a/common/src/main/java/common/item/Item.java +++ b/common/src/main/java/common/item/Item.java @@ -141,7 +141,7 @@ public class Item { entity.setThrowableHeading((double)facing.getFrontOffsetX(), (double)((float)facing.getFrontOffsetY() + 0.1F), (double)facing.getFrontOffsetZ(), velocity, inaccuracy); world.spawnEntityInWorld((Entity)entity); - stack.splitStack(1); + stack.split(1); return stack; } @@ -274,7 +274,7 @@ public class Item { } public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) { - BlockDispenser.dispense(world, 6.0, facing, position, stack.splitStack(1)); + BlockDispenser.dispense(world, 6.0, facing, position, stack.split(1)); return stack; } diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index 1250c0be..66e60e42 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -1,6 +1,5 @@ package common.item; -import java.text.DecimalFormat; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -8,7 +7,6 @@ import java.util.Set; import common.attributes.Attribute; import common.attributes.UsageSlot; -import common.block.Block; import common.collect.Lists; import common.collect.Maps; import common.color.TextColor; @@ -20,683 +18,398 @@ import common.init.ItemRegistry; import common.item.tool.ItemBow; import common.rng.Random; import common.tags.TagObject; -import common.util.BlockPos; -import common.util.Facing; -import common.world.World; -public final class ItemStack -{ - public static final int MAX_SIZE = 67108864; - private static final DecimalFormat DECIMALFORMAT = new DecimalFormat("#.###"); +public final class ItemStack { + public static final int MAX_SIZE = 67108864; - public int size; - private Item item; - private String name; - private int color = 0xffffffff; - private int damage; - private int repairCost; - private Map enchantments; + private Item item; + private int size; + private String name; + private int color = 0xffffffff; + private int damage; + private int repairCost; + private Map enchantments; - public ItemStack(Item item) - { - this(item, 1); - } - - public ItemStack(Item item, int amount) - { - this.item = item; - this.size = amount; - } - - public static String formatAmount(int amount) { - if(amount < 0) - return amount <= -1000000000 ? (amount / 1000000000) + "B" : ("-" + formatAmount(-amount)); - if(amount < 1000) - return "" + amount; - else if(amount < 100000) - return (amount / 1000) + "K"; - else if(amount < 1000000) - return "." + (amount / 100000) + "M"; - else if(amount < 100000000) - return (amount / 1000000) + "M"; - else if(amount < 1000000000) - return "." + (amount / 100000000) + "B"; - else - return (amount / 1000000000) + "B+"; - } - - public static ItemStack readFromTag(TagObject tag) - { - Item item = tag.hasString("id") ? ItemRegistry.byName(tag.getString("id")) : null; - int size = tag.hasInt("size") ? tag.getInt("size") : 1; - if(item == null || size < 1) - return null; - ItemStack stack = new ItemStack(item, Math.min(item.getMaxAmount(), size)); - stack.readTag(tag); - return stack; - } - - public static ItemStack getStack(String name, ItemStack def) { - if(name == null) - return def; - Item item = ItemRegistry.byName(name); - return item == null ? def : new ItemStack(item); + public static ItemStack readFromTag(TagObject tag) { + Item item = tag.hasString("id") ? ItemRegistry.byName(tag.getString("id")) : null; + int size = tag.hasInt("size") ? tag.getInt("size") : 1; + if(item == null || size < 1) + return null; + ItemStack stack = new ItemStack(item, Math.min(item.getMaxAmount(), size)); + stack.readTags(tag); + return stack; + } + + public static boolean itemEquals(ItemStack stackA, ItemStack stackB) { + return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.itemEquals(stackB) : false); + } + + public static boolean dataEquals(ItemStack stackA, ItemStack stackB) { + return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.dataEquals(stackB) : false); + } + + public static boolean allEquals(ItemStack stackA, ItemStack stackB) { + return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.allEquals(stackB) : false); + } + + public static ItemStack copy(ItemStack stack) { + return stack == null ? null : stack.copy(); + } + + public ItemStack(Item item) { + this(item, 1); + } + + public ItemStack(Item item, int amount) { + this.item = item; + this.size = amount; + } + + public TagObject writeTags(TagObject tag) { + if(this.item != null) + tag.setString("id", ItemRegistry.getName(this.item)); + if(this.size != 1) + tag.setInt("size", this.size); + if(this.color != 0xffffffff) + tag.setInt("color", this.color); + if(this.damage != 0) + tag.setInt("dmg", this.damage); + if(this.repairCost != 0) + tag.setInt("cost", this.repairCost); + if(this.name != null) + tag.setString("name", this.name); + if(this.enchantments != null) { + List list = Lists.newArrayList(); + for(Entry ench : this.enchantments.entrySet()) { + TagObject enc = new TagObject(); + enc.setString("id", ench.getKey().getName()); + if(ench.getValue() != 1) + enc.setShort("lvl", ench.getValue().shortValue()); + list.add(enc); + } + tag.setList("ench", list); + } + return tag; + } + + public void readTags(TagObject tag) { + this.color = tag.hasInt("color") ? tag.getInt("color") : 0xffffffff; + this.color = (this.color & 0xff000000) != 0 ? 0xffffffff : this.color; + this.damage = tag.hasInt("dmg") ? Math.max(0, tag.getInt("dmg")) : 0; + this.repairCost = tag.hasInt("cost") ? Math.max(0, tag.getInt("cost")) : 0; + this.name = tag.hasString("name") ? tag.getString("name") : null; + this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name; + this.enchantments = tag.hasList("ench") ? Maps.newEnumMap(Enchantment.class) : null; + if(this.enchantments != null) { + List list = tag.getList("ench"); + for(TagObject enc : list) { + if(!enc.hasString("id")) + continue; + Enchantment ench = Enchantment.getEnchantment(enc.getString("id")); + int level = enc.hasShort("lvl") ? (int)enc.getShort("lvl") : 1; + if(ench != null && level > 0) + this.enchantments.put(ench, level); + } + if(this.enchantments.isEmpty()) + this.enchantments = null; + } + } + + public boolean itemEquals(ItemStack other) { + return other != null && this.item == other.item; + } + + public boolean dataEquals(ItemStack other) { + if(this.color != other.color || this.damage != other.damage || this.repairCost != other.repairCost + || (this.name != null) != (other.name != null) || (this.name != null && !this.name.equals(other.name)) + || (this.enchantments != null) != (other.enchantments != null) + || (this.enchantments != null && this.enchantments.size() != other.enchantments.size())) + return false; + if(this.enchantments == null) + return true; + for(Entry ench : this.enchantments.entrySet()) { + if(!ench.getValue().equals(other.enchantments.get(ench.getKey()))) + return false; + } + return true; + } + + public boolean allEquals(ItemStack other) { + return this.size == other.size && this.item == other.item && this.dataEquals(other); + } + + public void copyData(ItemStack stack) { + this.color = stack.color; + this.damage = stack.damage; + this.repairCost = stack.repairCost; + this.name = stack.name; + this.enchantments = stack.enchantments == null ? null : Maps.newEnumMap(Enchantment.class); + if(this.enchantments != null) + this.enchantments.putAll(stack.enchantments); + } + + public ItemStack copy() { + ItemStack stack = new ItemStack(this.item, this.size); + stack.copyData(this); + return stack; + } + + public ItemStack copy(int size) { + ItemStack stack = new ItemStack(this.item, size); + stack.copyData(this); + return stack; + } + + public ItemStack split(int amount) { + ItemStack stack = new ItemStack(this.item, amount); + stack.copyData(this); + this.size = Math.max(this.size - amount, 0); + return stack; + } + + + public Item getItem() { + return this.item; + } + + public int getSize() { + return this.size; + } + + public boolean isEmpty() { + return this.size <= 0; + } + + public boolean isStacked() { + return this.size > 1; + } + + public boolean isFull() { + return this.size >= this.getMaxStackSize(); + } + + public boolean isOverLimit() { + return this.size > this.getMaxStackSize(); + } + + public int getMaxStackSize() { + return this.item.getMaxAmount(); + } + + public boolean isStackable() { + return this.getMaxStackSize() > 1 && (!this.isItemStackDamageable() || !this.isItemDamaged()); + } + + public boolean isItemStackDamageable() { + return this.item != null && this.item.getMaxDamage() > 0; + } + + public boolean isItemDamaged() { + return this.isItemStackDamageable() && this.getItemDamage() > 0; + } + + public int getMaxDamage() { + return this.item.getMaxDamage(); + } + + public int getMaxItemUseDuration() { + return this.item.getMaxItemUseDuration(this); + } + + public ItemAction getItemUseAction() { + return this.item.getItemUseAction(this); + } + + public ItemAction getItemPosition() { + return this.item.getItemPosition(this); + } + + public int getItemDamage() { + return this.isItemStackDamageable() ? this.damage : 0; + } + + public String getDisplayName() { + return this.name != null ? this.name : this.item.getDisplay(); + } + + public String getColoredName() { + return this.getColor() + this.getDisplayName(); + } + + public String getColoredName(TextColor reset) { + return TextColor.DGRAY + "[" + this.getColor() + this.getDisplayName() + TextColor.DGRAY + "]" + reset; + } + + public boolean hasDisplayName() { + return this.name != null; + } + + public boolean hasEffect() { + return this.item.hasEffect(this); + } + + public TextColor getColor() { + return this.item.getColor(this); + } + + public boolean isItemEnchantable() { + return !this.item.canEnchant(this) ? false : !this.isItemEnchanted(); + } + + public Set> getEnchantments() { + return this.enchantments == null ? null : this.enchantments.entrySet(); + } + + public Integer getEnchantment(Enchantment ench) { + return this.enchantments == null ? null : this.enchantments.get(ench); + } + + public boolean isItemEnchanted() { + return this.enchantments != null; + } + + public int getRepairCost() { + return this.repairCost; } - - public boolean dataEquals(ItemStack other) { - if(this.color != other.color || this.damage != other.damage || this.repairCost != other.repairCost || (this.name != null) != (other.name != null) || (this.name != null && !this.name.equals(other.name)) || (this.enchantments != null) != (other.enchantments != null) || (this.enchantments != null && this.enchantments.size() != other.enchantments.size())) - return false; - if(this.enchantments == null) - return true; - for(Entry ench : this.enchantments.entrySet()) { - if(!ench.getValue().equals(other.enchantments.get(ench.getKey()))) - return false; - } - return true; - } - - public void copyData(ItemStack stack) { - this.color = stack.color; - this.damage = stack.damage; - this.repairCost = stack.repairCost; - this.name = stack.name; - this.enchantments = stack.enchantments == null ? null : Maps.newEnumMap(Enchantment.class); - if(this.enchantments != null) - this.enchantments.putAll(stack.enchantments); - } - - /** - * Splits off a stack of the given amount of this stack and reduces this stack by the amount. - */ - public ItemStack splitStack(int amount) - { - ItemStack itemstack = new ItemStack(this.item, amount); - - itemstack.copyData(this); - - this.size -= amount; - return itemstack; - } - - /** - * Returns the object corresponding to the stack. - */ - public Item getItem() - { - return this.item; - } - - /** - * Called when the player uses this ItemStack on a Block (right-click). Places blocks, etc. (Legacy name: - * tryPlaceItemIntoWorld) - */ - public boolean onItemUse(EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) - { - boolean flag = this.getItem().onItemUse(this, playerIn, worldIn, pos, side, hitX, hitY, hitZ); - -// if (flag) -// { -// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this.item)]); -// } - - return flag; - } - - public float getStrVsBlock(Block blockIn) - { - return this.getItem().getStrVsBlock(this, blockIn); - } - - /** - * Called whenever this item stack is equipped and right clicked. Returns the new item stack to put in the position - * where this item is. Args: world, player - */ - public ItemStack useItemRightClick(World worldIn, EntityNPC playerIn) - { - return this.getItem().onItemRightClick(this, worldIn, playerIn); - } - - /** - * Called when the item in use count reach 0, e.g. item food eaten. Return the new ItemStack. Args : world, entity - */ - public ItemStack onItemUseFinish(World worldIn, EntityNPC playerIn) - { - return this.getItem().onItemUseFinish(this, worldIn, playerIn); - } - - public TagObject writeTags(TagObject tag) - { - if(this.item != null) - tag.setString("id", ItemRegistry.getName(this.item)); - if(this.size != 1) - tag.setInt("size", this.size); - if(this.color != 0xffffffff) - tag.setInt("color", this.color); - if(this.damage != 0) - tag.setInt("dmg", this.damage); - if(this.repairCost != 0) - tag.setInt("cost", this.repairCost); - if(this.name != null) - tag.setString("name", this.name); - if(this.enchantments != null) { - List list = Lists.newArrayList(); - for(Entry ench : this.enchantments.entrySet()) { - TagObject enc = new TagObject(); - enc.setString("id", ench.getKey().getName()); - if(ench.getValue() != 1) - enc.setShort("lvl", ench.getValue().shortValue()); - list.add(enc); - } - tag.setList("ench", list); - } - return tag; - } - - public void readTag(TagObject tag) - { - this.color = tag.hasInt("color") ? tag.getInt("color") : 0xffffffff; - this.color = (this.color & 0xff000000) != 0 ? 0xffffffff : this.color; - this.damage = tag.hasInt("dmg") ? Math.max(0, tag.getInt("dmg")) : 0; - this.repairCost = tag.hasInt("cost") ? Math.max(0, tag.getInt("cost")) : 0; - this.name = tag.hasString("name") ? tag.getString("name") : null; - this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name; - this.enchantments = tag.hasList("ench") ? Maps.newEnumMap(Enchantment.class) : null; - if(this.enchantments != null) { - List list = tag.getList("ench"); - for(TagObject enc : list) { - if(!enc.hasString("id")) - continue; - Enchantment ench = Enchantment.getEnchantment(enc.getString("id")); - if(ench != null) - this.enchantments.put(ench, enc.hasShort("lvl") ? (int)enc.getShort("lvl") : 1); - } - if(this.enchantments.isEmpty()) - this.enchantments = null; - } - } - - public int getMaxStackSize() - { - return this.item.getMaxAmount(); - } - - public boolean isStackable() - { - return this.getMaxStackSize() > 1 && (!this.isItemStackDamageable() || !this.isItemDamaged()); - } - - public boolean isItemStackDamageable() - { - return this.item != null && this.item.getMaxDamage() > 0; - } - - public boolean isItemDamaged() - { - return this.isItemStackDamageable() && this.getItemDamage() > 0; - } - - public int getMaxDamage() - { - return this.item.getMaxDamage(); - } - - /** - * Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment - * there is a chance for each point of damage to be negated. Returns true if it takes more damage than - * getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are - * negated. - */ - public boolean attemptDamageItem(int amount, Random rand) - { - if (!this.isItemStackDamageable()) - { - return false; - } - else - { - if (amount > 0) - { - int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.UNBREAKING, this); - int j = 0; - - for (int k = 0; i > 0 && k < amount; ++k) - { - if (Enchantment.negateDamage(this, i, rand)) - { - ++j; - } - } - - amount -= j; - - if (amount <= 0) - { - return false; - } - } - - int damage = this.getItemDamage() + amount; - this.setItemDamage(damage); - return damage > this.getMaxDamage(); - } - } - - public void damageItem(int amount, EntityLiving entityIn) - { - if (this.isItemStackDamageable()) - { - if (this.attemptDamageItem(amount, entityIn.getRNG())) - { - entityIn.renderBrokenItemStack(this); - --this.size; - - if (entityIn.isPlayer()) - { - EntityNPC entityplayer = (EntityNPC)entityIn; - - if (this.size == 0 && this.getItem() instanceof ItemBow) - { - entityplayer.destroyCurrentEquippedItem(); - } - } - - if (this.size < 0) - { - this.size = 0; - } - - this.setItemDamage(0); - } - } - } - - /** - * Calls the corresponding fct in di - */ - public void hitEntity(EntityLiving entityIn, EntityNPC playerIn) - { - boolean flag = this.item.hitEntity(this, entityIn, playerIn); - -// if (flag) -// { -// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this.item)]); -// } - } - - /** - * Called when a Block is destroyed using this ItemStack - */ - public void onBlockDestroyed(World worldIn, Block blockIn, BlockPos pos, EntityNPC playerIn) - { - boolean flag = this.item.onBlockDestroyed(this, worldIn, blockIn, pos, playerIn); - -// if (flag) -// { -// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this.item)]); -// } - } - - /** - * Check whether the given Block can be harvested using this ItemStack. - */ - public boolean canHarvestBlock(Block blockIn) - { - return this.item.canHarvestBlock(blockIn); - } - - public boolean interactWithEntity(EntityNPC playerIn, EntityLiving entityIn) - { - return this.item.itemInteractionForEntity(this, playerIn, entityIn); - } - - public ItemStack copy() - { - ItemStack itemstack = new ItemStack(this.item, this.size); - - itemstack.copyData(this); - - return itemstack; - } - - public static boolean areItemStackTagsEqual(ItemStack stackA, ItemStack stackB) - { - return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.dataEquals(stackB) : false); - } - - /** - * compares ItemStack argument1 with ItemStack argument2; returns true if both ItemStacks are equal - */ - public static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB) - { - return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.isItemStackEqual(stackB) : false); - } - - /** - * compares ItemStack argument to the instance ItemStack; returns true if both ItemStacks are equal - */ - private boolean isItemStackEqual(ItemStack other) - { - return this.size != other.size ? false : (this.item != other.item ? false : this.dataEquals(other)); - } - - /** - * Compares Item and damage value of the two stacks - */ - public static boolean areItemsEqual(ItemStack stackA, ItemStack stackB) - { - return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.isItemEqual(stackB) : false); - } - - /** - * compares ItemStack argument to the instance ItemStack; returns true if the Items contained in both ItemStacks are - * equal - */ - public boolean isItemEqual(ItemStack other) - { - return other != null && this.item == other.item; - } - -// public String getUnlocalizedName() -// { -// return this.item.getUnlocalizedName(this); -// } - - /** - * Creates a copy of a ItemStack, a null parameters will return a null. - */ - public static ItemStack copyItemStack(ItemStack stack) - { - return stack == null ? null : stack.copy(); - } - -// public String toString() -// { -// return this.stackSize + "x" + this.item.getUnlocalizedName() + "@" + this.itemDamage; -// } - -// /** -// * Called each tick as long the ItemStack in on player inventory. Used to progress the pickup animation and update -// * maps. -// */ -// public void updateAnimation(World worldIn, Entity entityIn, int inventorySlot, boolean isCurrentItem) -// { -// if (this.animationsToGo > 0) -// { -// --this.animationsToGo; -// } -// -// this.item.onUpdate(this, worldIn, entityIn, inventorySlot, isCurrentItem); -// } -// -// public void onCrafting(World worldIn, EntityNPC playerIn, int amount) -// { -//// playerIn.addStat(StatRegistry.objectCraftStats[ItemRegistry.getIdFromItem(this.item)], amount); -// this.item.onCreated(this, worldIn, playerIn); -// } - - public boolean getIsItemStackEqual(ItemStack p_179549_1_) - { - return this.isItemStackEqual(p_179549_1_); - } - - public int getMaxItemUseDuration() - { - return this.getItem().getMaxItemUseDuration(this); - } - - public ItemAction getItemUseAction() - { - return this.getItem().getItemUseAction(this); - } - - public ItemAction getItemPosition() - { - return this.getItem().getItemPosition(this); - } - - /** - * Called when the player releases the use item button. Args: world, entityplayer, itemInUseCount - */ - public void onPlayerStoppedUsing(World worldIn, EntityNPC playerIn, int timeLeft) - { - this.getItem().onPlayerStoppedUsing(this, worldIn, playerIn, timeLeft); - } - - public int getItemDamage() - { - return this.isItemStackDamageable() ? this.damage : 0; - } - - public void setItemDamage(int damage) - { - if(!this.isItemStackDamageable()) - return; - this.damage = Math.max(0, damage); - } - - public String getDisplayName() - { - return this.name != null ? this.name : this.getItem().getDisplay(); - } - - public String getColoredName() { - return this.getColor() + this.getDisplayName(); - } - - public String getColoredName(TextColor reset) { - return TextColor.DGRAY + "[" + this.getColor() + this.getDisplayName() + TextColor.DGRAY + "]" + reset; - } - - public void setStackDisplayName(String displayName) - { - this.name = displayName != null && !displayName.isEmpty() ? displayName : null; - this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name; - } - - public void clearCustomName() - { - this.name = null; - } - - public boolean hasDisplayName() - { - return this.name != null; - } - - public List getTooltip(EntityNPC playerIn) - { - List list = Lists.newArrayList(); - String s = this.getColoredName(); - if(this.size != 1) - s = TextColor.YELLOW + "" + this.size + " " + TextColor.RESET + s; - s = s + TextColor.RESET; - list.add(s); - this.item.addInformation(this, playerIn, list); - if(this.item.canBeDyed()) - list.add("Farbe: #" + Integer.toHexString(this.getDyeColor()).toUpperCase()); - - if (this.enchantments != null) - { - for (Entry enc : this.enchantments.entrySet()) - { - list.add(enc.getKey().getFormattedName(enc.getValue())); - } - } - - int damage = this.item.getAttackDamageBonus(); - damage += EnchantmentHelper.getDamageModifier(this); - if(damage != 0) { - if(damage > 0) - list.add(TextColor.BLUE + String.format("+%d Angriffsschaden", damage)); - else - list.add(TextColor.RED + String.format("-%d Angriffsschaden", damage)); - } - - Map mods = this.getAttributeModifiers(null); - - if (!mods.isEmpty()) - { - list.add(""); - for (Entry entry : mods.entrySet()) - { - float amt = entry.getValue(); - if(this.size != 1) { - double total = amt * (double)this.size; - if (amt > 0.0D) - list.add(TextColor.BLUE + String.format("+%s %s [%dx +%s]", DECIMALFORMAT.format(total), entry.getKey(), this.size, DECIMALFORMAT.format(amt))); - else if (amt < 0.0D) - list.add(TextColor.RED + String.format("-%s %s [%dx -%s]", DECIMALFORMAT.format(total * -1.0), entry.getKey(), this.size, DECIMALFORMAT.format(amt * -1.0))); - } - else { - if (amt > 0.0D) - list.add(TextColor.BLUE + String.format("+%s %s", DECIMALFORMAT.format(amt), entry.getKey())); - else if (amt < 0.0D) - list.add(TextColor.RED + String.format("-%s %s", DECIMALFORMAT.format(amt * -1.0), entry.getKey())); - } - } - } - - if (this.item.getMaxDamage() > 0) - { - list.add(String.format("Haltbarkeit: %d" + (this.damage > 0 ? " / %d" : ""), - this.damage > 0 ? (this.item.getMaxDamage() - this.damage) : this.item.getMaxDamage(), this.item.getMaxDamage())); - } - - if(this.repairCost > 0) - list.add("Reparaturkosten: " + this.repairCost + " Mana"); - - if(this.item.getMaxAmount() == 1) - list.add("Nicht stapelbar"); - else - list.add("Stapelbar bis " + this.item.getMaxAmount()); - - list.add(TextColor.GRAY + ItemRegistry.getName(this.item)); - - return list; - } - - public boolean hasEffect() - { - return this.getItem().hasEffect(this); - } - - public TextColor getColor() - { - return this.getItem().getColor(this); - } - - public boolean isItemEnchantable() - { - return !this.getItem().canEnchant(this) ? false : !this.isItemEnchanted(); - } - - public Set> getEnchantments() - { - return this.enchantments == null ? null : this.enchantments.entrySet(); - } - - public Integer getEnchantment(Enchantment ench) - { - return this.enchantments == null ? null : this.enchantments.get(ench); - } - - public void addEnchantment(Enchantment ench, int level) - { - if (this.enchantments == null) - this.enchantments = Maps.newEnumMap(Enchantment.class); - this.enchantments.put(ench, level); - } - - public boolean removeEnchantment(Enchantment ench) { - if(this.enchantments == null || this.enchantments.remove(ench) == null) - return false; - if(this.enchantments.isEmpty()) - this.enchantments = null; - return true; - } - - public boolean clearEnchantments() { - if(this.enchantments != null) { - this.enchantments = null; - return true; - } - return false; - } - - public boolean isItemEnchanted() - { - return this.enchantments != null; - } - - public void setEnchantments(Map enchMap) - { - if(enchMap == null || enchMap.isEmpty()) { - this.enchantments = null; - return; - } - if(this.enchantments == null) - this.enchantments = Maps.newEnumMap(Enchantment.class); - else - this.enchantments.clear(); - this.enchantments.putAll(enchMap); - } - - public int getRepairCost() - { - return this.repairCost; - } - - public void setRepairCost(int cost) - { - this.repairCost = Math.max(0, cost); - } public Map getAttributeModifiers(UsageSlot slot) { Map map = Maps.newEnumMap(Attribute.class); - this.getItem().getModifiers(map, slot); + this.item.getModifiers(map, slot); return map; } - public void setItem(Item newItem) - { - this.item = newItem; - } + public boolean hasColor() { + return this.item.canBeDyed() && this.color != 0xffffffff; + } - public boolean canBeDyed() - { - return this.item.canBeDyed(); - } + public int getRawColor() { + if(!this.item.canBeDyed()) + return -1; + return this.color; + } - public boolean hasColor() - { - return this.item.canBeDyed() && this.color != 0xffffffff; - } + public int getDyeColor() { + if(!this.item.canBeDyed()) + return -1; + return this.color != 0xffffffff ? this.color : this.item.getDefaultColor(); + } - public int getRawColor() - { - if(!this.item.canBeDyed()) - return -1; - return this.color; - } - public int getDyeColor() - { - if(!this.item.canBeDyed()) - return -1; - return this.color != 0xffffffff ? this.color : this.item.getDefaultColor(); - } + public void setItemDamage(int damage) { + if(!this.isItemStackDamageable()) + return; + this.damage = Math.max(0, damage); + } - public void removeColor() - { - if(!this.item.canBeDyed()) - throw new UnsupportedOperationException("Kann diesen Gegenstand nicht entfärben!"); - this.color = 0xffffffff; - } + public void setStackDisplayName(String displayName) { + this.name = displayName != null && !displayName.isEmpty() ? displayName : null; + this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name; + } - public void setColor(int color) - { - if(!this.item.canBeDyed()) - throw new UnsupportedOperationException("Kann diesen Gegenstand nicht einfärben!"); - this.color = (color & 0xff000000) != 0 ? 0xffffffff : color; - } + public void clearCustomName() { + this.name = null; + } + + public void addEnchantment(Enchantment ench, int level) { + if(this.enchantments == null) + this.enchantments = Maps.newEnumMap(Enchantment.class); + this.enchantments.put(ench, level); + } + + public boolean removeEnchantment(Enchantment ench) { + if(this.enchantments == null || this.enchantments.remove(ench) == null) + return false; + if(this.enchantments.isEmpty()) + this.enchantments = null; + return true; + } + + public boolean clearEnchantments() { + if(this.enchantments != null) { + this.enchantments = null; + return true; + } + return false; + } + + public void setEnchantments(Map enchMap) { + if(enchMap == null || enchMap.isEmpty()) { + this.enchantments = null; + return; + } + if(this.enchantments == null) + this.enchantments = Maps.newEnumMap(Enchantment.class); + else + this.enchantments.clear(); + this.enchantments.putAll(enchMap); + } + + public void setRepairCost(int cost) { + this.repairCost = Math.max(0, cost); + } + + public void setItem(Item newItem) { + this.item = newItem; + } + + public void removeColor() { + if(!this.item.canBeDyed()) + throw new UnsupportedOperationException("Kann diesen Gegenstand nicht entfärben!"); + this.color = 0xffffffff; + } + + public void setColor(int color) { + if(!this.item.canBeDyed()) + throw new UnsupportedOperationException("Kann diesen Gegenstand nicht einfärben!"); + this.color = (color & 0xff000000) != 0 ? 0xffffffff : color; + } + + public void setSize(int size) { + this.size = Math.max(size, 0); + } + + public boolean decrSize() { + return (this.size = Math.max(this.size - 1, 0)) <= 0; + } + + public boolean decrSize(int amount) { + return (this.size = Math.max(this.size - amount, 0)) <= 0; + } + + public boolean incrSize() { + return (this.size += 1) >= this.getMaxStackSize(); + } + + public boolean incrSize(int amount) { + return (this.size += amount) >= this.getMaxStackSize(); + } + + public void damage(int amount, EntityLiving entity, Random rand) { + if(!this.isItemStackDamageable()) + return; + if(amount > 0) { + int unbreaking = EnchantmentHelper.getEnchantmentLevel(Enchantment.UNBREAKING, this); + int negated = 0; + for(int z = 0; unbreaking > 0 && z < amount; z++) { + if(Enchantment.negateDamage(this, unbreaking, rand)) + ++negated; + } + if((amount -= negated) <= 0) + return; + } + int damage = this.getItemDamage() + amount; + this.setItemDamage(damage); + if(damage > this.getMaxDamage()) { + if(entity != null) + entity.renderBrokenItemStack(this); + this.decrSize(); + if(entity != null && entity.isPlayer() && this.isEmpty() && this.item instanceof ItemBow) + ((EntityNPC)entity).destroyCurrentEquippedItem(); + this.setItemDamage(0); + } + } + + public void damage(int amount, EntityLiving entity) { + this.damage(amount, entity, entity.getRNG()); + } } diff --git a/common/src/main/java/common/item/RngLoot.java b/common/src/main/java/common/item/RngLoot.java index 1a61cd2e..d57585fa 100755 --- a/common/src/main/java/common/item/RngLoot.java +++ b/common/src/main/java/common/item/RngLoot.java @@ -33,9 +33,7 @@ public class RngLoot extends RngItem public ItemStack getItem(Random rand) { if(this.item == null) return null; - ItemStack stack = this.item.copy(); - stack.size = this.minStackSize + rand.zrange(this.maxStackSize - this.minStackSize + 1); - return stack; + return this.item.copy(this.minStackSize + rand.zrange(this.maxStackSize - this.minStackSize + 1)); } public static void generateChestContents(Random random, WeightedList list, IInventory inv, int max) @@ -47,17 +45,13 @@ public class RngLoot extends RngItem if (loot.item.getMaxStackSize() >= j) { - ItemStack itemstack1 = loot.item.copy(); - itemstack1.size = j; - inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), itemstack1); + inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(j)); } else { for (int k = 0; k < j; ++k) { - ItemStack itemstack = loot.item.copy(); - itemstack.size = 1; - inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), itemstack); + inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(1)); } } } @@ -72,17 +66,13 @@ public class RngLoot extends RngItem if (loot.item.getMaxStackSize() >= j) { - ItemStack itemstack1 = loot.item.copy(); - itemstack1.size = j; - dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), itemstack1); + dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), loot.item.copy(j)); } else { for (int k = 0; k < j; ++k) { - ItemStack itemstack = loot.item.copy(); - itemstack.size = 1; - dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), itemstack); + dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), loot.item.copy(1)); } } } diff --git a/common/src/main/java/common/item/block/ItemBed.java b/common/src/main/java/common/item/block/ItemBed.java index 904ed742..a4c20635 100755 --- a/common/src/main/java/common/item/block/ItemBed.java +++ b/common/src/main/java/common/item/block/ItemBed.java @@ -73,7 +73,7 @@ public class ItemBed extends Item worldIn.setState(blockpos, iblockstate2, 3); } - --stack.size; + stack.decrSize(); return true; } else diff --git a/common/src/main/java/common/item/block/ItemBlock.java b/common/src/main/java/common/item/block/ItemBlock.java index 483b6be4..1d1d77f1 100755 --- a/common/src/main/java/common/item/block/ItemBlock.java +++ b/common/src/main/java/common/item/block/ItemBlock.java @@ -61,7 +61,7 @@ public class ItemBlock extends Item pos = pos.offset(side); } - if (stack.size == 0) + if (stack.isEmpty()) { return false; } @@ -83,7 +83,7 @@ public class ItemBlock extends Item } worldIn.playSound(this.block.sound.getPlaceSound(), (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), 1.0F); - --stack.size; + stack.decrSize(); } return true; diff --git a/common/src/main/java/common/item/block/ItemDoor.java b/common/src/main/java/common/item/block/ItemDoor.java index c56ae605..65ebfe65 100755 --- a/common/src/main/java/common/item/block/ItemDoor.java +++ b/common/src/main/java/common/item/block/ItemDoor.java @@ -61,7 +61,7 @@ public class ItemDoor extends Item else { placeDoor(worldIn, pos, Facing.fromAngle((double)playerIn.rotYaw), this.block, true); - --stack.size; + stack.decrSize(); return true; } } diff --git a/common/src/main/java/common/item/block/ItemLilyPad.java b/common/src/main/java/common/item/block/ItemLilyPad.java index f95cb20a..b2335901 100755 --- a/common/src/main/java/common/item/block/ItemLilyPad.java +++ b/common/src/main/java/common/item/block/ItemLilyPad.java @@ -50,7 +50,7 @@ public class ItemLilyPad extends ItemColored // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); diff --git a/common/src/main/java/common/item/block/ItemMetalBlock.java b/common/src/main/java/common/item/block/ItemMetalBlock.java index b9df700b..47b04713 100755 --- a/common/src/main/java/common/item/block/ItemMetalBlock.java +++ b/common/src/main/java/common/item/block/ItemMetalBlock.java @@ -48,7 +48,7 @@ public class ItemMetalBlock extends ItemBlock { } public float getRadiation(ItemStack stack) { - return this.metal.radioactivity * (this.ore ? 0.5f : 2.0f) * (float)stack.size; + return this.metal.radioactivity * (this.ore ? 0.5f : 2.0f) * (float)stack.getSize(); } public boolean isMagnetic() { diff --git a/common/src/main/java/common/item/block/ItemRedstone.java b/common/src/main/java/common/item/block/ItemRedstone.java index 7ad6c44c..e93a5721 100755 --- a/common/src/main/java/common/item/block/ItemRedstone.java +++ b/common/src/main/java/common/item/block/ItemRedstone.java @@ -48,7 +48,7 @@ public class ItemRedstone extends Item } else if (this.block.canPlaceBlockAt(worldIn, blockpos)) { - --stack.size; + stack.decrSize(); worldIn.setState(blockpos, this.block.getState()); return true; } diff --git a/common/src/main/java/common/item/block/ItemSeedFood.java b/common/src/main/java/common/item/block/ItemSeedFood.java index 03878c6f..e9b7e0ab 100755 --- a/common/src/main/java/common/item/block/ItemSeedFood.java +++ b/common/src/main/java/common/item/block/ItemSeedFood.java @@ -44,7 +44,7 @@ public class ItemSeedFood extends ItemFood else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up())) { worldIn.setState(pos.up(), this.crops.getState()); - --stack.size; + stack.decrSize(); return true; } else diff --git a/common/src/main/java/common/item/block/ItemSeeds.java b/common/src/main/java/common/item/block/ItemSeeds.java index 9a35a1a7..434c40cb 100755 --- a/common/src/main/java/common/item/block/ItemSeeds.java +++ b/common/src/main/java/common/item/block/ItemSeeds.java @@ -44,7 +44,7 @@ public class ItemSeeds extends Item else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up())) { worldIn.setState(pos.up(), this.crops.getState()); - --stack.size; + stack.decrSize(); return true; } else diff --git a/common/src/main/java/common/item/block/ItemSign.java b/common/src/main/java/common/item/block/ItemSign.java index 5a9a5720..309cc7d8 100755 --- a/common/src/main/java/common/item/block/ItemSign.java +++ b/common/src/main/java/common/item/block/ItemSign.java @@ -71,7 +71,7 @@ public class ItemSign extends Item worldIn.setState(pos, Blocks.wall_sign.getState().withProperty(BlockWallSign.FACING, side), 3); } - --stack.size; + stack.decrSize(); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntitySign) diff --git a/common/src/main/java/common/item/block/ItemSlab.java b/common/src/main/java/common/item/block/ItemSlab.java index b9efc98c..2a4d04a8 100755 --- a/common/src/main/java/common/item/block/ItemSlab.java +++ b/common/src/main/java/common/item/block/ItemSlab.java @@ -18,7 +18,7 @@ public class ItemSlab extends ItemBlock { } public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) { - return stack.size != 0 && playerIn.canPlayerEdit(pos.offset(side), side, stack) && + return !stack.isEmpty() && playerIn.canPlayerEdit(pos.offset(side), side, stack) && (this.tryVerticalPlace(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ) || super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ)); } @@ -33,7 +33,7 @@ public class ItemSlab extends ItemBlock { if(worldIn.setState(pos, place, 3)) { worldIn.playSound(this.slab.sound.getPlaceSound(), (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), 1.0F); - --stack.size; + stack.decrSize(); } return true; } diff --git a/common/src/main/java/common/item/block/ItemSmallBlock.java b/common/src/main/java/common/item/block/ItemSmallBlock.java index 6ff50c0f..22e00536 100755 --- a/common/src/main/java/common/item/block/ItemSmallBlock.java +++ b/common/src/main/java/common/item/block/ItemSmallBlock.java @@ -31,7 +31,7 @@ public class ItemSmallBlock extends Item { else if(!block.isReplaceable(world, pos)) pos = pos.offset(side); - if(!player.canPlayerEdit(pos, side, stack) || stack.size == 0) + if(!player.canPlayerEdit(pos, side, stack) || stack.isEmpty()) return false; if(world.canBlockBePlaced(this.block, pos, false, side, null, stack)) { State newState = this.block.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, player); @@ -45,7 +45,7 @@ public class ItemSmallBlock extends Item { world.playSound(this.block.sound.getPlaceSound(), (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), 1.0F); - --stack.size; + stack.decrSize(); return true; } } diff --git a/common/src/main/java/common/item/block/ItemSnow.java b/common/src/main/java/common/item/block/ItemSnow.java index 68e70876..80feb27f 100755 --- a/common/src/main/java/common/item/block/ItemSnow.java +++ b/common/src/main/java/common/item/block/ItemSnow.java @@ -19,7 +19,7 @@ public class ItemSnow extends ItemBlock public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) { - if (stack.size == 0) + if (stack.isEmpty()) { return false; } @@ -52,7 +52,7 @@ public class ItemSnow extends ItemBlock if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setState(blockpos, iblockstate1, 2)) { worldIn.playSound(this.block.sound.getPlaceSound(), (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), 1.0F); - --stack.size; + stack.decrSize(); return true; } } diff --git a/common/src/main/java/common/item/block/ItemTNT.java b/common/src/main/java/common/item/block/ItemTNT.java index ea000439..3124e1e6 100644 --- a/common/src/main/java/common/item/block/ItemTNT.java +++ b/common/src/main/java/common/item/block/ItemTNT.java @@ -26,7 +26,7 @@ public class ItemTNT extends ItemBlock { EntityTnt entitytntprimed = new EntityTnt(world, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, (EntityLiving)null, this.power); world.spawnEntityInWorld(entitytntprimed); world.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F); - --stack.size; + stack.decrSize(); return stack; } } diff --git a/common/src/main/java/common/item/material/ItemBook.java b/common/src/main/java/common/item/material/ItemBook.java index 8b10506d..eaeb932f 100755 --- a/common/src/main/java/common/item/material/ItemBook.java +++ b/common/src/main/java/common/item/material/ItemBook.java @@ -3,15 +3,12 @@ package common.item.material; import common.item.Item; import common.item.ItemStack; -public class ItemBook extends Item -{ - public boolean canEnchant(ItemStack stack) - { - return stack.size == 1; - } +public class ItemBook extends Item { + public boolean canEnchant(ItemStack stack) { + return stack.getSize() == 1; + } - public int getItemEnchantability() - { - return 1; - } + public int getItemEnchantability() { + return 1; + } } diff --git a/common/src/main/java/common/item/material/ItemDye.java b/common/src/main/java/common/item/material/ItemDye.java index baf5d0c1..dc59930d 100755 --- a/common/src/main/java/common/item/material/ItemDye.java +++ b/common/src/main/java/common/item/material/ItemDye.java @@ -92,7 +92,7 @@ public class ItemDye extends Item { // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } } @@ -125,7 +125,7 @@ public class ItemDye extends Item { worldIn.setState(pos, iblockstate1, 2); } // if(!playerIn.creative) - --stack.size; + stack.decrSize(); return true; } } @@ -151,7 +151,7 @@ public class ItemDye extends Item { igrowable.grow((AWorldServer)worldIn, worldIn.rand, target, iblockstate); } - --stack.size; + stack.decrSize(); } return true; @@ -196,7 +196,7 @@ public class ItemDye extends Item { if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != this.color) { entitysheep.setFleeceColor(this.color); - --stack.size; + stack.decrSize(); } return true; diff --git a/common/src/main/java/common/item/material/ItemMetal.java b/common/src/main/java/common/item/material/ItemMetal.java index b8cff889..82020bc4 100755 --- a/common/src/main/java/common/item/material/ItemMetal.java +++ b/common/src/main/java/common/item/material/ItemMetal.java @@ -40,7 +40,7 @@ public class ItemMetal extends Item { } public float getRadiation(ItemStack stack) { - return this.metal.radioactivity * 0.25f * (float)stack.size; + return this.metal.radioactivity * 0.25f * (float)stack.getSize(); } public boolean isMagnetic() { diff --git a/common/src/main/java/common/item/spawner/ItemBoat.java b/common/src/main/java/common/item/spawner/ItemBoat.java index 3a2d0004..a1b1961f 100755 --- a/common/src/main/java/common/item/spawner/ItemBoat.java +++ b/common/src/main/java/common/item/spawner/ItemBoat.java @@ -106,7 +106,7 @@ public class ItemBoat extends Item // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); @@ -141,7 +141,7 @@ public class ItemBoat extends Item EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2); world.spawnEntityInWorld(entityboat); - stack.splitStack(1); + stack.split(1); return stack; } } diff --git a/common/src/main/java/common/item/spawner/ItemMinecart.java b/common/src/main/java/common/item/spawner/ItemMinecart.java index 6a073df3..f73a8824 100755 --- a/common/src/main/java/common/item/spawner/ItemMinecart.java +++ b/common/src/main/java/common/item/spawner/ItemMinecart.java @@ -67,7 +67,7 @@ public class ItemMinecart extends Item // ((EntityMinecartCommandBlock)entityminecart).getCommandBlockLogic().setEnabled(((EntityNPCMP)playerIn).canUse(Permissions.CMDBLOCK)); } - --stack.size; + stack.decrSize(); return true; } else @@ -128,7 +128,7 @@ public class ItemMinecart extends Item } world.spawnEntityInWorld(entityminecart); - stack.splitStack(1); + stack.split(1); return stack; } } diff --git a/common/src/main/java/common/item/spawner/ItemMonsterPlacer.java b/common/src/main/java/common/item/spawner/ItemMonsterPlacer.java index 27fbbf10..2fb56f75 100755 --- a/common/src/main/java/common/item/spawner/ItemMonsterPlacer.java +++ b/common/src/main/java/common/item/spawner/ItemMonsterPlacer.java @@ -108,7 +108,7 @@ public class ItemMonsterPlacer extends Item // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } } // } @@ -170,7 +170,7 @@ public class ItemMonsterPlacer extends Item // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } // if(z == 0) @@ -239,7 +239,7 @@ public class ItemMonsterPlacer extends Item Entity entity = spawnCreature(world, this.entityId, d0, d1, d2, false); if (entity instanceof EntityLiving && stack.hasDisplayName()) ((EntityLiving)entity).setCustomNameTag(stack.getDisplayName()); - stack.splitStack(1); + stack.split(1); return stack; } } diff --git a/common/src/main/java/common/item/spawner/ItemNpcSpawner.java b/common/src/main/java/common/item/spawner/ItemNpcSpawner.java index 357ff0ec..57db98c4 100755 --- a/common/src/main/java/common/item/spawner/ItemNpcSpawner.java +++ b/common/src/main/java/common/item/spawner/ItemNpcSpawner.java @@ -106,7 +106,7 @@ public class ItemNpcSpawner extends Item // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } } // } @@ -160,7 +160,7 @@ public class ItemNpcSpawner extends Item // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } // if(z == 0) @@ -228,7 +228,7 @@ public class ItemNpcSpawner extends Item Entity entity = spawnNpc(world, this.spawned, d0, d1, d2, false); if (entity instanceof EntityLiving && stack.hasDisplayName()) ((EntityLiving)entity).setCustomNameTag(stack.getDisplayName()); - stack.splitStack(1); + stack.split(1); return stack; } } diff --git a/common/src/main/java/common/item/tool/ItemArmor.java b/common/src/main/java/common/item/tool/ItemArmor.java index 187191c3..c872b4d4 100755 --- a/common/src/main/java/common/item/tool/ItemArmor.java +++ b/common/src/main/java/common/item/tool/ItemArmor.java @@ -97,7 +97,7 @@ public class ItemArmor extends Item if (itemstack == null) { playerIn.setItem(i, itemStackIn.copy()); - itemStackIn.size = 0; + itemStackIn.setSize(0); } return itemStackIn; @@ -180,11 +180,10 @@ public class ItemArmor extends Item EntityLiving entitylivingbase = (EntityLiving)list.get(0); int l = entitylivingbase.isPlayer() ? 1 : 0; int i1 = getArmorPosition(stack); - ItemStack itemstack = stack.copy(); - itemstack.size = 1; + ItemStack itemstack = stack.copy(1); entitylivingbase.setItem(i1 - l, itemstack); - --stack.size; + stack.decrSize(); return stack; } else diff --git a/common/src/main/java/common/item/tool/ItemBow.java b/common/src/main/java/common/item/tool/ItemBow.java index 44252f5c..9b94b8e3 100755 --- a/common/src/main/java/common/item/tool/ItemBow.java +++ b/common/src/main/java/common/item/tool/ItemBow.java @@ -70,7 +70,7 @@ public class ItemBow extends Item entityarrow.setFire(100); } - stack.damageItem(1, playerIn); + stack.damage(1, playerIn); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 1.0F); if (flag) diff --git a/common/src/main/java/common/item/tool/ItemBucket.java b/common/src/main/java/common/item/tool/ItemBucket.java index b9946d82..5e2e3b50 100755 --- a/common/src/main/java/common/item/tool/ItemBucket.java +++ b/common/src/main/java/common/item/tool/ItemBucket.java @@ -185,7 +185,7 @@ public class ItemBucket extends Item setRecursive((AWorldServer)worldIn, blockpos, 4, null); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // if(!playerIn.creative) - --itemStackIn.size; + itemStackIn.decrSize(); return itemStackIn; } } @@ -217,7 +217,7 @@ public class ItemBucket extends Item { // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); if(this.recursive) { - --itemStackIn.size; + itemStackIn.decrSize(); return itemStackIn; } return new ItemStack(Items.bucket); @@ -236,7 +236,7 @@ public class ItemBucket extends Item // return emptyBuckets; // } // else - if (--emptyBuckets.size <= 0) + if (emptyBuckets.decrSize()) { return fullBucket; } @@ -346,10 +346,10 @@ public class ItemBucket extends Item world.setBlockToAir(pos); - if (--stack.size == 0) + if (stack.decrSize()) { stack.setItem(item); - stack.size = 1; + stack.setSize(1); } else if (source instanceof TileEntityDispenser dispenser && dispenser.addItemStack(new ItemStack(item)) < 0) { @@ -364,7 +364,7 @@ public class ItemBucket extends Item if (this.tryPlaceContainedLiquid(world, pos)) { stack.setItem(Items.bucket); - stack.size = 1; + stack.setSize(1); return stack; } else diff --git a/common/src/main/java/common/item/tool/ItemBucketMilk.java b/common/src/main/java/common/item/tool/ItemBucketMilk.java index 237c4905..db1527e1 100755 --- a/common/src/main/java/common/item/tool/ItemBucketMilk.java +++ b/common/src/main/java/common/item/tool/ItemBucketMilk.java @@ -27,7 +27,7 @@ public class ItemBucketMilk extends Item { // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } if (!worldIn.client) @@ -36,7 +36,7 @@ public class ItemBucketMilk extends Item } // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); - return stack.size <= 0 ? new ItemStack(Items.bucket) : stack; + return stack.isEmpty() ? new ItemStack(Items.bucket) : stack; } /** diff --git a/common/src/main/java/common/item/tool/ItemCarrotOnAStick.java b/common/src/main/java/common/item/tool/ItemCarrotOnAStick.java index 0c099139..c0e90852 100755 --- a/common/src/main/java/common/item/tool/ItemCarrotOnAStick.java +++ b/common/src/main/java/common/item/tool/ItemCarrotOnAStick.java @@ -46,9 +46,9 @@ public class ItemCarrotOnAStick extends Item if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getItemDamage() >= 7) { entitypig.getAIControlledByPlayer().boostSpeed(); - itemStackIn.damageItem(7, playerIn); + itemStackIn.damage(7, playerIn); - if (itemStackIn.size == 0) + if (itemStackIn.isEmpty()) { ItemStack itemstack = new ItemStack(Items.fishing_rod); itemstack.copyData(itemStackIn); diff --git a/common/src/main/java/common/item/tool/ItemChargedOrb.java b/common/src/main/java/common/item/tool/ItemChargedOrb.java index 158e6d6c..328a6478 100755 --- a/common/src/main/java/common/item/tool/ItemChargedOrb.java +++ b/common/src/main/java/common/item/tool/ItemChargedOrb.java @@ -33,7 +33,7 @@ public class ItemChargedOrb extends ItemFragile // } if(itemStackIn.getItemDamage() >= this.getMaxDamage()) return itemStackIn; - itemStackIn.damageItem(1, playerIn); + itemStackIn.damage(1, playerIn); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); if (!worldIn.client) @@ -49,7 +49,7 @@ public class ItemChargedOrb extends ItemFragile { State iblockstate = worldIn.getState(pos); - if (stack.getItemDamage() == 0 && playerIn.canPlayerEdit(pos.offset(side), side, stack) /* && worldIn.dimension.getDimensionId() == 0 || worldIn.dimension.getDimensionId() == 1) */ && iblockstate.getBlock() == Blocks.portal_frame && !((Boolean)iblockstate.getValue(BlockPortalFrame.ORB)).booleanValue()) + if (!stack.isItemDamaged() && playerIn.canPlayerEdit(pos.offset(side), side, stack) /* && worldIn.dimension.getDimensionId() == 0 || worldIn.dimension.getDimensionId() == 1) */ && iblockstate.getBlock() == Blocks.portal_frame && !((Boolean)iblockstate.getValue(BlockPortalFrame.ORB)).booleanValue()) { if (worldIn.client) { @@ -59,7 +59,7 @@ public class ItemChargedOrb extends ItemFragile { worldIn.setState(pos, iblockstate.withProperty(BlockPortalFrame.ORB, Boolean.valueOf(true)), 2); worldIn.updateComparatorOutputLevel(pos, Blocks.portal_frame); - --stack.size; + stack.decrSize(); for (int i = 0; i < 16; ++i) { diff --git a/common/src/main/java/common/item/tool/ItemDie.java b/common/src/main/java/common/item/tool/ItemDie.java index 935f1849..5275d9b6 100755 --- a/common/src/main/java/common/item/tool/ItemDie.java +++ b/common/src/main/java/common/item/tool/ItemDie.java @@ -66,7 +66,7 @@ public class ItemDie extends Item { // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); diff --git a/common/src/main/java/common/item/tool/ItemDynamite.java b/common/src/main/java/common/item/tool/ItemDynamite.java index f1c78e76..16c7269c 100755 --- a/common/src/main/java/common/item/tool/ItemDynamite.java +++ b/common/src/main/java/common/item/tool/ItemDynamite.java @@ -33,7 +33,7 @@ public class ItemDynamite extends Item { } public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player) { - --stack.size; + stack.decrSize(); world.playSoundAtEntity(player, SoundEvent.THROW, 0.5F); if(!world.client) world.spawnEntityInWorld(new EntityDynamite(world, player, this.power)); diff --git a/common/src/main/java/common/item/tool/ItemEgg.java b/common/src/main/java/common/item/tool/ItemEgg.java index 7bde8249..939c24e8 100755 --- a/common/src/main/java/common/item/tool/ItemEgg.java +++ b/common/src/main/java/common/item/tool/ItemEgg.java @@ -26,7 +26,7 @@ public class ItemEgg extends Item { // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); diff --git a/common/src/main/java/common/item/tool/ItemExpBottle.java b/common/src/main/java/common/item/tool/ItemExpBottle.java index 7023df2b..0671a981 100755 --- a/common/src/main/java/common/item/tool/ItemExpBottle.java +++ b/common/src/main/java/common/item/tool/ItemExpBottle.java @@ -31,7 +31,7 @@ public class ItemExpBottle extends Item { // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); diff --git a/common/src/main/java/common/item/tool/ItemFireball.java b/common/src/main/java/common/item/tool/ItemFireball.java index 511440ec..cfa74ea7 100755 --- a/common/src/main/java/common/item/tool/ItemFireball.java +++ b/common/src/main/java/common/item/tool/ItemFireball.java @@ -47,7 +47,7 @@ public class ItemFireball extends Item // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } return true; @@ -63,7 +63,7 @@ public class ItemFireball extends Item double d4 = world.rand.gaussian() * 0.05D + (double)facing.getFrontOffsetY(); double d5 = world.rand.gaussian() * 0.05D + (double)facing.getFrontOffsetZ(); world.spawnEntityInWorld(new EntityFireCharge(world, d0, d1, d2, d3, d4, d5)); - stack.splitStack(1); + stack.split(1); return stack; } diff --git a/common/src/main/java/common/item/tool/ItemFirework.java b/common/src/main/java/common/item/tool/ItemFirework.java index 05d6880c..f9b2a9dd 100755 --- a/common/src/main/java/common/item/tool/ItemFirework.java +++ b/common/src/main/java/common/item/tool/ItemFirework.java @@ -21,7 +21,7 @@ public class ItemFirework extends Item // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } return true; @@ -38,7 +38,7 @@ public class ItemFirework extends Item double d2 = blockpos.getZ() + 0.5 + (double)facing.getFrontOffsetZ(); EntityFireworks entityfireworkrocket = new EntityFireworks(world, d0, d1, d2); world.spawnEntityInWorld(entityfireworkrocket); - stack.splitStack(1); + stack.split(1); return stack; } diff --git a/common/src/main/java/common/item/tool/ItemFishingRod.java b/common/src/main/java/common/item/tool/ItemFishingRod.java index 073dfd7b..5ef503cf 100755 --- a/common/src/main/java/common/item/tool/ItemFishingRod.java +++ b/common/src/main/java/common/item/tool/ItemFishingRod.java @@ -42,7 +42,7 @@ public class ItemFishingRod extends Item if (playerIn.fishEntity != null) { int i = playerIn.fishEntity.handleHookRetraction(); - itemStackIn.damageItem(i, playerIn); + itemStackIn.damage(i, playerIn); playerIn.swingItem(); } else diff --git a/common/src/main/java/common/item/tool/ItemFlintAndSteel.java b/common/src/main/java/common/item/tool/ItemFlintAndSteel.java index 461aa721..f236c36b 100755 --- a/common/src/main/java/common/item/tool/ItemFlintAndSteel.java +++ b/common/src/main/java/common/item/tool/ItemFlintAndSteel.java @@ -44,7 +44,7 @@ public class ItemFlintAndSteel extends Item worldIn.setState(pos, this.fireBlock.getState()); } - stack.damageItem(1, playerIn); + stack.damage(1, playerIn); return true; } } @@ -60,10 +60,7 @@ public class ItemFlintAndSteel extends Item { world.setState(pos, this.fireBlock.getState()); - if (stack.attemptDamageItem(1, world.rand)) - { - stack.size = 0; - } + stack.damage(1, null, world.rand); world.playAuxSFX(1000, blockpos, 0); } else if (world.getState(pos).getBlock() instanceof BlockTNT tnt) diff --git a/common/src/main/java/common/item/tool/ItemFood.java b/common/src/main/java/common/item/tool/ItemFood.java index bc2b2abd..ace52a0f 100755 --- a/common/src/main/java/common/item/tool/ItemFood.java +++ b/common/src/main/java/common/item/tool/ItemFood.java @@ -35,7 +35,7 @@ public class ItemFood extends Item public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) { // if(!playerIn.creative) - --stack.size; + stack.decrSize(); worldIn.playSoundAtEntity(playerIn, SoundEvent.EAT, 0.5F); playerIn.heal((int)((float)this.getHealAmount(stack) * 0.5f * (1.0f + worldIn.rand.floatv()))); this.onFoodEaten(stack, worldIn, playerIn); diff --git a/common/src/main/java/common/item/tool/ItemGlassBottle.java b/common/src/main/java/common/item/tool/ItemGlassBottle.java index 7c4d4581..8aea0084 100755 --- a/common/src/main/java/common/item/tool/ItemGlassBottle.java +++ b/common/src/main/java/common/item/tool/ItemGlassBottle.java @@ -48,10 +48,9 @@ public class ItemGlassBottle extends Item if (worldIn.getState(blockpos).getBlock().getMaterial() == Material.WATER) { - --itemStackIn.size; // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); - if (itemStackIn.size <= 0) + if (itemStackIn.decrSize()) { return new ItemStack(Items.potion); } diff --git a/common/src/main/java/common/item/tool/ItemGunBase.java b/common/src/main/java/common/item/tool/ItemGunBase.java index cc12b709..4b921e10 100755 --- a/common/src/main/java/common/item/tool/ItemGunBase.java +++ b/common/src/main/java/common/item/tool/ItemGunBase.java @@ -58,7 +58,7 @@ public abstract class ItemGunBase extends Item // entityarrow.setFire(100); // } - stack.damageItem(1, playerIn); + stack.damage(1, playerIn); worldIn.playSoundAtEntity(playerIn, SoundEvent.EXPLODE_ALT, 1.0F); if(!flag) diff --git a/common/src/main/java/common/item/tool/ItemHoe.java b/common/src/main/java/common/item/tool/ItemHoe.java index 3e995d79..57d16efb 100755 --- a/common/src/main/java/common/item/tool/ItemHoe.java +++ b/common/src/main/java/common/item/tool/ItemHoe.java @@ -74,7 +74,7 @@ public class ItemHoe extends Item else { worldIn.setState(target, newState); - stack.damageItem(1, player); + stack.damage(1, player); return true; } } diff --git a/common/src/main/java/common/item/tool/ItemNameTag.java b/common/src/main/java/common/item/tool/ItemNameTag.java index a8148e06..e5d18557 100755 --- a/common/src/main/java/common/item/tool/ItemNameTag.java +++ b/common/src/main/java/common/item/tool/ItemNameTag.java @@ -27,7 +27,7 @@ public class ItemNameTag extends Item EntityLiving entityliving = (EntityLiving)target; entityliving.setCustomNameTag(stack.getDisplayName()); // entityliving.disableDespawn(); - --stack.size; + stack.decrSize(); return true; } else diff --git a/common/src/main/java/common/item/tool/ItemPotion.java b/common/src/main/java/common/item/tool/ItemPotion.java index e8a72b44..8e0209ed 100755 --- a/common/src/main/java/common/item/tool/ItemPotion.java +++ b/common/src/main/java/common/item/tool/ItemPotion.java @@ -77,7 +77,7 @@ public class ItemPotion extends Item { // if (!playerIn.creative) // { - --stack.size; + stack.decrSize(); // } if (!worldIn.client) @@ -100,7 +100,7 @@ public class ItemPotion extends Item // if (!playerIn.creative) // { - if (stack.size <= 0) + if (stack.isEmpty()) { return new ItemStack(Items.glass_bottle); } @@ -136,7 +136,7 @@ public class ItemPotion extends Item { // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); diff --git a/common/src/main/java/common/item/tool/ItemSaddle.java b/common/src/main/java/common/item/tool/ItemSaddle.java index 018d02fd..7dca78c4 100755 --- a/common/src/main/java/common/item/tool/ItemSaddle.java +++ b/common/src/main/java/common/item/tool/ItemSaddle.java @@ -28,7 +28,7 @@ public class ItemSaddle extends Item { entitypig.setSaddled(true); // entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F); - --stack.size; + stack.decrSize(); } return true; diff --git a/common/src/main/java/common/item/tool/ItemShears.java b/common/src/main/java/common/item/tool/ItemShears.java index 314d095f..b33763a9 100755 --- a/common/src/main/java/common/item/tool/ItemShears.java +++ b/common/src/main/java/common/item/tool/ItemShears.java @@ -30,7 +30,7 @@ public class ItemShears extends Item } else { - stack.damageItem(1, playerIn); + stack.damage(1, playerIn); return true; } } diff --git a/common/src/main/java/common/item/tool/ItemSnowball.java b/common/src/main/java/common/item/tool/ItemSnowball.java index 451562e1..b4136cd3 100755 --- a/common/src/main/java/common/item/tool/ItemSnowball.java +++ b/common/src/main/java/common/item/tool/ItemSnowball.java @@ -26,7 +26,7 @@ public class ItemSnowball extends Item { // if (!playerIn.creative) // { - --itemStackIn.size; + itemStackIn.decrSize(); // } worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); diff --git a/common/src/main/java/common/item/tool/ItemSword.java b/common/src/main/java/common/item/tool/ItemSword.java index bc516388..26c16fbc 100755 --- a/common/src/main/java/common/item/tool/ItemSword.java +++ b/common/src/main/java/common/item/tool/ItemSword.java @@ -59,7 +59,7 @@ public class ItemSword extends Item */ public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { - stack.damageItem(1, attacker); + stack.damage(1, attacker); return true; } @@ -70,7 +70,7 @@ public class ItemSword extends Item { if ((double)blockIn.getBlockHardness(worldIn, pos) != 0.0D) { - stack.damageItem(2, playerIn); + stack.damage(2, playerIn); } return true; diff --git a/common/src/main/java/common/item/tool/ItemTool.java b/common/src/main/java/common/item/tool/ItemTool.java index de42b2c2..a1c6bb29 100755 --- a/common/src/main/java/common/item/tool/ItemTool.java +++ b/common/src/main/java/common/item/tool/ItemTool.java @@ -30,13 +30,13 @@ public abstract class ItemTool extends Item { } public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { - stack.damageItem(2, attacker); + stack.damage(2, attacker); return true; } public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLiving player) { if(block.getBlockHardness(world, pos) != 0.0f) - stack.damageItem(1, player); + stack.damage(1, player); return true; } diff --git a/common/src/main/java/common/item/tool/ItemWeatherToken.java b/common/src/main/java/common/item/tool/ItemWeatherToken.java index a67e589c..ed145aeb 100755 --- a/common/src/main/java/common/item/tool/ItemWeatherToken.java +++ b/common/src/main/java/common/item/tool/ItemWeatherToken.java @@ -23,7 +23,7 @@ public class ItemWeatherToken extends ItemMagnetic { { if(worldIn.dimension.getType().weather) { // if (!playerIn.creative) - --itemStackIn.size; + itemStackIn.decrSize(); worldIn.playSoundAtEntity(playerIn, SoundEvent.SPELL, 0.5F); if (!worldIn.client) { diff --git a/common/src/main/java/common/network/PacketBuffer.java b/common/src/main/java/common/network/PacketBuffer.java index b6dc6f1c..c68e702a 100755 --- a/common/src/main/java/common/network/PacketBuffer.java +++ b/common/src/main/java/common/network/PacketBuffer.java @@ -121,10 +121,10 @@ public class PacketBuffer { return; } this.writeShort(ItemRegistry.getId(stack.getItem())); - this.writeVarInt(stack.size); - if(stack.canBeDyed()) + this.writeVarInt(stack.getSize()); + if(stack.getItem().canBeDyed()) this.writeVarInt(stack.getRawColor()); - if(stack.isItemStackDamageable()) + if(stack.getItem().isDamageable()) this.writeVarInt(stack.getItemDamage()); this.writeVarInt(stack.getRepairCost()); this.writeString(stack.hasDisplayName() ? stack.getDisplayName() : ""); @@ -143,9 +143,9 @@ public class PacketBuffer { if(id < 0) return null; ItemStack stack = new ItemStack(ItemRegistry.byId(id), this.readVarInt()); - if(stack.canBeDyed()) + if(stack.getItem().canBeDyed()) stack.setColor(this.readVarInt()); - if(stack.isItemStackDamageable()) + if(stack.getItem().isDamageable()) stack.setItemDamage(this.readVarInt()); stack.setRepairCost(this.readVarInt()); stack.setStackDisplayName(this.readString(32)); diff --git a/common/src/main/java/common/tileentity/TileEntityBrewingStand.java b/common/src/main/java/common/tileentity/TileEntityBrewingStand.java index bc154978..d1285e20 100755 --- a/common/src/main/java/common/tileentity/TileEntityBrewingStand.java +++ b/common/src/main/java/common/tileentity/TileEntityBrewingStand.java @@ -129,7 +129,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka private boolean canBrew() { - if (this.brewingItemStacks[3] != null && this.brewingItemStacks[3].size > 0) + if (this.brewingItemStacks[3] != null && !this.brewingItemStacks[3].isEmpty()) { ItemStack itemstack = this.brewingItemStacks[3]; @@ -207,9 +207,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka } else { - --this.brewingItemStacks[3].size; - - if (this.brewingItemStacks[3].size <= 0) + if (this.brewingItemStacks[3].decrSize()) { this.brewingItemStacks[3] = null; } diff --git a/common/src/main/java/common/tileentity/TileEntityChest.java b/common/src/main/java/common/tileentity/TileEntityChest.java index 2e5357c7..5503c9e0 100755 --- a/common/src/main/java/common/tileentity/TileEntityChest.java +++ b/common/src/main/java/common/tileentity/TileEntityChest.java @@ -83,7 +83,7 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II { if (this.chestContents[index] != null) { - if (this.chestContents[index].size <= count) + if (this.chestContents[index].getSize() <= count) { ItemStack itemstack1 = this.chestContents[index]; this.chestContents[index] = null; @@ -92,9 +92,9 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II } else { - ItemStack itemstack = this.chestContents[index].splitStack(count); + ItemStack itemstack = this.chestContents[index].split(count); - if (this.chestContents[index].size == 0) + if (this.chestContents[index].isEmpty()) { this.chestContents[index] = null; } @@ -133,9 +133,9 @@ public class TileEntityChest extends TileEntityLockable implements ITickable, II { this.chestContents[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } this.markDirty(); diff --git a/common/src/main/java/common/tileentity/TileEntityDevice.java b/common/src/main/java/common/tileentity/TileEntityDevice.java index 56fe55f2..0b1fe6e4 100755 --- a/common/src/main/java/common/tileentity/TileEntityDevice.java +++ b/common/src/main/java/common/tileentity/TileEntityDevice.java @@ -142,15 +142,15 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo public ItemStack decrStackSize(int index, int count) { if(this.inventory[index] != null) { - if(this.inventory[index].size <= count) { + if(this.inventory[index].getSize() <= count) { ItemStack itemstack1 = this.inventory[index]; this.inventory[index] = null; return itemstack1; } else { - ItemStack itemstack = this.inventory[index].splitStack(count); + ItemStack itemstack = this.inventory[index].split(count); - if(this.inventory[index].size == 0) { + if(this.inventory[index].isEmpty()) { this.inventory[index] = null; } @@ -176,8 +176,8 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo public void setInventorySlotContents(int index, ItemStack stack) { this.inventory[index] = stack; - if(stack != null && stack.size > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + if(stack != null && stack.getSize() > this.getInventoryStackLimit()) { + stack.setSize(this.getInventoryStackLimit()); } } @@ -264,7 +264,7 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo return true; } else { - return this.inventory[slot] == null || this.inventory[slot].size <= 0; + return this.inventory[slot] == null || this.inventory[slot].isEmpty(); } } @@ -272,19 +272,19 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo if(slot == -1) { int n = 0; for(ItemStack itemstack : this.inventory) { - if(itemstack != null && itemstack.size >= 1) - n += itemstack.size; + if(itemstack != null && !itemstack.isEmpty()) + n += itemstack.getSize(); } return n >= amount; } else { - return this.inventory[slot] != null && this.inventory[slot].size >= amount; + return this.inventory[slot] != null && this.inventory[slot].getSize() >= amount; } } public boolean isFull() { for(ItemStack itemstack : this.inventory) { - if(itemstack == null || itemstack.size != itemstack.getMaxStackSize()) { + if(itemstack == null || !itemstack.isFull()) { return false; } } diff --git a/common/src/main/java/common/tileentity/TileEntityDispenser.java b/common/src/main/java/common/tileentity/TileEntityDispenser.java index 075f70e8..455df008 100755 --- a/common/src/main/java/common/tileentity/TileEntityDispenser.java +++ b/common/src/main/java/common/tileentity/TileEntityDispenser.java @@ -40,7 +40,7 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor { if (this.stacks[index] != null) { - if (this.stacks[index].size <= count) + if (this.stacks[index].getSize() <= count) { ItemStack itemstack1 = this.stacks[index]; this.stacks[index] = null; @@ -49,9 +49,9 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor } else { - ItemStack itemstack = this.stacks[index].splitStack(count); + ItemStack itemstack = this.stacks[index].split(count); - if (this.stacks[index].size == 0) + if (this.stacks[index].isEmpty()) { this.stacks[index] = null; } @@ -106,9 +106,9 @@ public class TileEntityDispenser extends TileEntityLockable implements IInventor { this.stacks[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } this.markDirty(); diff --git a/common/src/main/java/common/tileentity/TileEntityFurnace.java b/common/src/main/java/common/tileentity/TileEntityFurnace.java index 7079b1b6..1c0175f0 100755 --- a/common/src/main/java/common/tileentity/TileEntityFurnace.java +++ b/common/src/main/java/common/tileentity/TileEntityFurnace.java @@ -74,7 +74,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, { if (this.furnaceItemStacks[index] != null) { - if (this.furnaceItemStacks[index].size <= count) + if (this.furnaceItemStacks[index].getSize() <= count) { ItemStack itemstack1 = this.furnaceItemStacks[index]; this.furnaceItemStacks[index] = null; @@ -82,9 +82,9 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, } else { - ItemStack itemstack = this.furnaceItemStacks[index].splitStack(count); + ItemStack itemstack = this.furnaceItemStacks[index].split(count); - if (this.furnaceItemStacks[index].size == 0) + if (this.furnaceItemStacks[index].isEmpty()) { this.furnaceItemStacks[index] = null; } @@ -120,12 +120,12 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, */ public void setInventorySlotContents(int index, ItemStack stack) { - boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]); + boolean flag = stack != null && stack.itemEquals(this.furnaceItemStacks[index]) && ItemStack.dataEquals(stack, this.furnaceItemStacks[index]); this.furnaceItemStacks[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } if (index == 0 && !flag) @@ -260,9 +260,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, if (this.furnaceItemStacks[1] != null) { - --this.furnaceItemStacks[1].size; - - if (this.furnaceItemStacks[1].size == 0) + if (this.furnaceItemStacks[1].decrSize()) { Item item = this.furnaceItemStacks[1].getItem().getContainerItem(); this.furnaceItemStacks[1] = item != null ? new ItemStack(item) : null; @@ -323,7 +321,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, else { ItemStack itemstack = SmeltingRegistry.getResult(this.furnaceItemStacks[0]); - return itemstack == null ? false : (this.furnaceItemStacks[2] == null ? true : (!this.furnaceItemStacks[2].isItemEqual(itemstack) ? false : (this.furnaceItemStacks[2].size < this.getInventoryStackLimit() && this.furnaceItemStacks[2].size < this.furnaceItemStacks[2].getMaxStackSize() ? true : this.furnaceItemStacks[2].size < itemstack.getMaxStackSize()))); + return itemstack == null ? false : (this.furnaceItemStacks[2] == null ? true : (!this.furnaceItemStacks[2].itemEquals(itemstack) ? false : (this.furnaceItemStacks[2].getSize() < this.getInventoryStackLimit() && !this.furnaceItemStacks[2].isFull() ? true : this.furnaceItemStacks[2].getSize() < itemstack.getMaxStackSize()))); } } @@ -342,7 +340,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, } else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) { - ++this.furnaceItemStacks[2].size; + this.furnaceItemStacks[2].incrSize(); } // if (this.furnaceItemStacks[0].getItem() == Items.sponge && this.furnaceItemStacks[0].getMetadata() == 1 && this.furnaceItemStacks[1] != null && this.furnaceItemStacks[1].getItem() == Items.bucket) @@ -350,9 +348,7 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, // this.furnaceItemStacks[1] = new ItemStack(Items.water_bucket); // } - --this.furnaceItemStacks[0].size; - - if (this.furnaceItemStacks[0].size <= 0) + if (this.furnaceItemStacks[0].decrSize()) { this.furnaceItemStacks[0] = null; } diff --git a/common/src/main/java/common/tileentity/TileEntityHopper.java b/common/src/main/java/common/tileentity/TileEntityHopper.java index 23da1a3a..95f1657e 100755 --- a/common/src/main/java/common/tileentity/TileEntityHopper.java +++ b/common/src/main/java/common/tileentity/TileEntityHopper.java @@ -113,7 +113,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { if (this.inventory[index] != null) { - if (this.inventory[index].size <= count) + if (this.inventory[index].getSize() <= count) { ItemStack itemstack1 = this.inventory[index]; this.inventory[index] = null; @@ -121,9 +121,9 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi } else { - ItemStack itemstack = this.inventory[index].splitStack(count); + ItemStack itemstack = this.inventory[index].split(count); - if (this.inventory[index].size == 0) + if (this.inventory[index].isEmpty()) { this.inventory[index] = null; } @@ -161,9 +161,9 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { this.inventory[index] = stack; - if (stack != null && stack.size > this.getInventoryStackLimit()) + if (stack != null && stack.getSize() > this.getInventoryStackLimit()) { - stack.size = this.getInventoryStackLimit(); + stack.setSize(this.getInventoryStackLimit()); } } @@ -291,7 +291,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { for (ItemStack itemstack : this.inventory) { - if (itemstack == null || itemstack.size != itemstack.getMaxStackSize()) + if (itemstack == null || !itemstack.isFull()) { return false; } @@ -326,7 +326,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi ItemStack itemstack = this.getStackInSlot(i).copy(); ItemStack itemstack1 = putStackInInventoryAllSlots(iinventory, this.decrStackSize(i, 1), enumfacing); - if (itemstack1 == null || itemstack1.size == 0) + if (itemstack1 == null || itemstack1.isEmpty()) { iinventory.markDirty(); return true; @@ -355,7 +355,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[k]); - if (itemstack1 == null || itemstack1.size != itemstack1.getMaxStackSize()) + if (itemstack1 == null || !itemstack1.isFull()) { return false; } @@ -369,7 +369,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { ItemStack itemstack = inventoryIn.getStackInSlot(j); - if (itemstack == null || itemstack.size != itemstack.getMaxStackSize()) + if (itemstack == null || !itemstack.isFull()) { return false; } @@ -479,7 +479,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi ItemStack itemstack1 = itemstack.copy(); ItemStack itemstack2 = putStackInInventoryAllSlots(hopper, inventoryIn.decrStackSize(index, 1), (Facing)null); - if (itemstack2 == null || itemstack2.size == 0) + if (itemstack2 == null || itemstack2.isEmpty()) { inventoryIn.markDirty(); return true; @@ -508,7 +508,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi ItemStack itemstack = itemIn.getEntityItem().copy(); ItemStack itemstack1 = putStackInInventoryAllSlots(p_145898_0_, itemstack, (Facing)null); - if (itemstack1 != null && itemstack1.size != 0) + if (itemstack1 != null && !itemstack1.isEmpty()) { itemIn.setEntityItemStack(itemstack1); } @@ -532,7 +532,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi ISidedInventory isidedinventory = (ISidedInventory)inventoryIn; int[] aint = isidedinventory.getSlotsForFace(side); - for (int k = 0; k < aint.length && stack != null && stack.size > 0; ++k) + for (int k = 0; k < aint.length && stack != null && !stack.isEmpty(); ++k) { stack = insertStack(inventoryIn, stack, aint[k], side); } @@ -541,13 +541,13 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { int i = inventoryIn.getSizeInventory(); - for (int j = 0; j < i && stack != null && stack.size > 0; ++j) + for (int j = 0; j < i && stack != null && !stack.isEmpty(); ++j) { stack = insertStack(inventoryIn, stack, j, side); } } - if (stack != null && stack.size == 0) + if (stack != null && stack.isEmpty()) { stack = null; } @@ -590,10 +590,10 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi } else if (canCombine(itemstack, stack)) { - int i = stack.getMaxStackSize() - itemstack.size; - int j = Math.min(stack.size, i); - stack.size -= j; - itemstack.size += j; + int i = stack.getMaxStackSize() - itemstack.getSize(); + int j = Math.min(stack.getSize(), i); + stack.decrSize(j); + itemstack.incrSize(j); flag = j > 0; } @@ -691,7 +691,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi public static boolean canCombine(ItemStack stack1, ItemStack stack2) { - return stack1.getItem() != stack2.getItem() ? false : (stack1.size > stack1.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(stack1, stack2)); + return stack1.getItem() != stack2.getItem() ? false : (stack1.isOverLimit() ? false : ItemStack.dataEquals(stack1, stack2)); } /** diff --git a/common/src/main/java/common/village/MerchantRecipeList.java b/common/src/main/java/common/village/MerchantRecipeList.java index f0cd66c9..bfda56d0 100755 --- a/common/src/main/java/common/village/MerchantRecipeList.java +++ b/common/src/main/java/common/village/MerchantRecipeList.java @@ -14,16 +14,16 @@ public class MerchantRecipeList extends ArrayList { return !areItemsSimilar(stack1, recipe.first()) || (stack2 != null || recipe.both()) && (!recipe.both() || !areItemsSimilar(stack2, recipe.second())) - || stack1.size < recipe.first().size - || recipe.both() && stack2.size < recipe.second().size ? null : recipe; + || stack1.getSize() < recipe.first().getSize() + || recipe.both() && stack2.getSize() < recipe.second().getSize() ? null : recipe; } else { for(int z = 0; z < this.size(); z++) { MerchantRecipe recipe = this.get(z); - if(areItemsSimilar(stack1, recipe.first()) && stack1.size >= recipe.first().size + if(areItemsSimilar(stack1, recipe.first()) && stack1.getSize() >= recipe.first().getSize() && (!recipe.both() && stack2 == null || recipe.both() && areItemsSimilar(stack2, recipe.second()) - && stack2.size >= recipe.second().size)) { + && stack2.getSize() >= recipe.second().getSize())) { return recipe; } } @@ -32,7 +32,7 @@ public class MerchantRecipeList extends ArrayList { } private static boolean areItemsSimilar(ItemStack given, ItemStack offer) { - return ItemStack.areItemsEqual(given, offer) && given.dataEquals(offer); + return ItemStack.itemEquals(given, offer) && given.dataEquals(offer); } public void fromTags(List list) { diff --git a/server/src/main/java/server/command/commands/CommandItem.java b/server/src/main/java/server/command/commands/CommandItem.java index 32a1c536..a030848d 100644 --- a/server/src/main/java/server/command/commands/CommandItem.java +++ b/server/src/main/java/server/command/commands/CommandItem.java @@ -5,6 +5,7 @@ import java.util.List; import common.entity.npc.EntityNPC; import common.init.ItemRegistry; +import common.item.Item; import common.item.ItemStack; import common.tags.TagObject; import server.command.Command; @@ -31,20 +32,20 @@ public class CommandItem extends Command { } public Object exec(CommandEnvironment env, Executor exec, String item, int amount, TagObject tag, List players) { - ItemStack stack = ItemStack.getStack(item, null); - if(stack == null) + Item items = ItemRegistry.byName(item); + if(items == null) throw new RunException("Gegenstand '%s' existiert nicht", item); - stack.readTag(tag); + ItemStack stack = new ItemStack(items); + stack.readTags(tag); int done = 0; int given = 0; for(EntityNPC player : players) { int total = amount; while(total > 0) { int added = Math.min(total, stack.getMaxStackSize()); - ItemStack st = stack.copy(); - st.size = added; + ItemStack st = stack.copy(added); player.inventory.addItemStackToInventory(st); - added -= st.size; + added -= st.getSize(); if(added <= 0) break; total -= added; diff --git a/server/src/main/java/server/command/commands/CommandMore.java b/server/src/main/java/server/command/commands/CommandMore.java index 05c72b1b..2d6dff85 100644 --- a/server/src/main/java/server/command/commands/CommandMore.java +++ b/server/src/main/java/server/command/commands/CommandMore.java @@ -20,8 +20,8 @@ public class CommandMore extends Command { } private int addItems(ItemStack stack) { - int diff = stack.getMaxStackSize() - stack.size; - stack.size = stack.getMaxStackSize(); + int diff = stack.getMaxStackSize() - stack.getSize(); + stack.setSize(stack.getMaxStackSize()); return diff; } diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 31d4fbef..c85fa8bc 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -586,11 +586,11 @@ public class Player extends User implements ICrafting, Executor, IPlayer } public void sendThrowMessage(ItemStack stack) { - if(stack.size == 1) + if(stack.getSize() == 1) this.addFeed(TextColor.DRED + "* %s weg geworfen", stack.getColoredName(TextColor.DRED)); else - this.addFeed(TextColor.DRED + "* %d %s weg geworfen", stack.size, + this.addFeed(TextColor.DRED + "* %d %s weg geworfen", stack.getSize(), stack.getColoredName(TextColor.DRED)); } @@ -1231,9 +1231,9 @@ public class Player extends User implements ICrafting, Executor, IPlayer if (itemstack1 != null) { - itemstack1.onBlockDestroyed(this.entity.worldObj, iblockstate.getBlock(), pos, this.entity); + itemstack1.getItem().onBlockDestroyed(itemstack1, this.entity.worldObj, iblockstate.getBlock(), pos, this.entity); - if (itemstack1.size == 0) + if (itemstack1.isEmpty()) { this.entity.destroyCurrentEquippedItem(); } @@ -1254,11 +1254,11 @@ public class Player extends User implements ICrafting, Executor, IPlayer // if(this.onPlayerInteract(false, null)) { // return true; // } - int i = stack.size; + int i = stack.getSize(); int j = stack.getItemDamage(); - ItemStack itemstack = stack.useItemRightClick(this.entity.worldObj, this.entity); + ItemStack itemstack = stack.getItem().onItemRightClick(stack, this.entity.worldObj, this.entity); - if (itemstack != stack || itemstack != null && (itemstack.size != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getItemDamage() != j)) + if (itemstack != stack || itemstack != null && (itemstack.getSize() != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getItemDamage() != j)) { this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = itemstack; @@ -1272,7 +1272,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer // } // } - if (itemstack.size == 0) + if (itemstack.isEmpty()) { this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null; } @@ -1323,7 +1323,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer // } else { - return stack.onItemUse(this.entity, this.entity.worldObj, pos, side, offsetX, offsetY, offsetZ); + return stack.getItem().onItemUse(stack, this.entity, this.entity.worldObj, pos, side, offsetX, offsetY, offsetZ); } } @@ -2384,7 +2384,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer itemstack = this.entity.inventory.getCurrentItem(); - if (itemstack != null && itemstack.size == 0) + if (itemstack != null && itemstack.isEmpty()) { this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null; itemstack = null; @@ -2393,12 +2393,12 @@ public class Player extends User implements ICrafting, Executor, IPlayer if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) { this.isChangingQuantityOnly = true; - this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = ItemStack.copyItemStack(this.entity.inventory.mainInventory[this.entity.inventory.currentItem]); + this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = ItemStack.copy(this.entity.inventory.mainInventory[this.entity.inventory.currentItem]); Slot slot = this.entity.openContainer.getSlotFromInventory(this.entity.inventory, this.entity.inventory.currentItem); this.entity.openContainer.detectAndSendChanges(); this.isChangingQuantityOnly = false; - if (!ItemStack.areItemStacksEqual(this.entity.inventory.getCurrentItem(), packetIn.getStack())) + if (!ItemStack.allEquals(this.entity.inventory.getCurrentItem(), packetIn.getStack())) { this.sendPacket(new SPacketSetSlot(this.entity.openContainer.windowId, slot.slotNumber, this.entity.inventory.getCurrentItem())); } @@ -2724,8 +2724,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer case REPAIR: if(this.isAdmin() && this.entity.getCurrentEquippedItem() != null) { ItemStack itemstack = this.entity.getCurrentEquippedItem(); - int diff = itemstack.getMaxStackSize() - itemstack.size; - itemstack.size = itemstack.getMaxStackSize(); + int diff = itemstack.getMaxStackSize() - itemstack.getSize(); + itemstack.setSize(itemstack.getMaxStackSize()); itemstack.setRepairCost(0); if(itemstack.getItem().getMaxDamage() > 0) itemstack.setItemDamage(0); @@ -2866,7 +2866,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer // { ItemStack itemstack = this.entity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getMode(), this.entity); - if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack)) + if (ItemStack.allEquals(packetIn.getClickedItem(), itemstack)) { this.entity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true)); this.isChangingQuantityOnly = true; @@ -2901,12 +2901,12 @@ public class Player extends User implements ICrafting, Executor, IPlayer if(item == null) return; ItemStack stack = new ItemStack(item, packet.isStacked() ? item.getMaxAmount() : 1); - int amount = stack.size; + int amount = stack.getSize(); if(amount <= 0) return; if(packet.getSlot() == -1) { this.entity.inventory.addItemStackToInventory(stack); - amount -= stack.size; + amount -= stack.getSize(); if(amount <= 0) return; } @@ -2917,26 +2917,26 @@ public class Player extends User implements ICrafting, Executor, IPlayer Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(36 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot()); if(slot == null || !slot.canCheatItem()) return; - stack.size = Math.min(slot.getSlotStackLimit(), stack.size); - amount = stack.size; + stack.setSize(Math.min(slot.getSlotStackLimit(), stack.getSize())); + amount = stack.getSize(); if(amount <= 0) return; if(slot.getHasStack()) { ItemStack old = slot.getStack(); - if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) { - stack.size = Math.min(slot.getSlotStackLimit(), Math.min(stack.getMaxStackSize(), old.size + stack.size)); - amount = stack.size - old.size; + if(ItemStack.itemEquals(stack, old) && ItemStack.dataEquals(stack, old)) { + stack.setSize(Math.min(slot.getSlotStackLimit(), Math.min(stack.getMaxStackSize(), old.getSize() + stack.getSize()))); + amount = stack.getSize() - old.getSize(); if(amount <= 0 || !slot.isItemValid(stack)) return; } else { if(!slot.isItemValid(stack)) return; - if(old.size == 1) + if(old.getSize() == 1) this.addFeed(TextColor.DRED + "* %s zerstört", old.getColoredName(TextColor.DRED)); else - this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size, + this.addFeed(TextColor.DRED + "* %d %s zerstört", old.getSize(), old.getColoredName(TextColor.DRED)); } }