fix itemstack sizes

This commit is contained in:
Sen 2025-07-07 15:20:52 +02:00
parent 4e94a660ff
commit c376d92790
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
111 changed files with 983 additions and 1353 deletions

View file

@ -1477,7 +1477,7 @@ public class Client implements IThreadListener {
if (this.world.getState(blockpos).getBlock() != Blocks.air) 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)) 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; return;
} }
if (itemstack.size == 0) if (itemstack.isEmpty())
{ {
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null; 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)) 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() (((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" + : "Rüstung: n/a, Pfeile: n/a") + "\n" +
(held != null ? (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" : "") "Eigens.: " + (entity.dead ? "D" : "") + (entity.noClip ? "N" : "") + (entity.onGround ? "G" : "")
+ (entity.canBeCollidedWith() ? "C" : "") + (entity.canBePushed() ? "P" : "") + (entity.canBeCollidedWith() ? "C" : "") + (entity.canBePushed() ? "P" : "")
+ (entity.isBurning() ? "B" : "") + (entity.isPlayer() ? "S" : "") + (entity.isBurning() ? "B" : "") + (entity.isPlayer() ? "S" : "")

View file

@ -1,8 +1,11 @@
package client.gui.container; package client.gui.container;
import java.text.DecimalFormat;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL13;
@ -22,9 +25,13 @@ import client.renderer.ItemRenderer;
import client.renderer.entity.RenderItem; import client.renderer.entity.RenderItem;
import client.window.Bind; import client.window.Bind;
import client.window.Button; import client.window.Button;
import common.attributes.Attribute;
import common.collect.Lists; import common.collect.Lists;
import common.collect.Sets; import common.collect.Sets;
import common.color.TextColor; import common.color.TextColor;
import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper;
import common.init.ItemRegistry;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.inventory.Slot; 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<ItemStack> ITEM_LIST = Lists.<ItemStack>newArrayList(); private static final List<ItemStack> ITEM_LIST = Lists.<ItemStack>newArrayList();
private static CheatTab selectedTab = CheatTab.ALL; private static CheatTab selectedTab = CheatTab.ALL;
@ -94,6 +102,91 @@ public abstract class GuiContainer extends Gui
private Field cheatSearch; private Field cheatSearch;
private String cheatLast; 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<String> getTooltip(ItemStack stack) {
List<String> list = Lists.<String>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<Enchantment, Integer> 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<Attribute, Float> mods = stack.getAttributeModifiers(null);
if(!mods.isEmpty()) {
list.add("");
for(Entry<Attribute, Float> 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) { public Label label(String text, int x, int y) {
x = x * 2 + this.container_x; x = x * 2 + this.container_x;
y = y * 2 + this.container_y; y = y * 2 + this.container_y;
@ -315,15 +408,15 @@ public abstract class GuiContainer extends Gui
if (this.dragSplitting && this.dragSplittingSlots.size() > 1) if (this.dragSplitting && this.dragSplittingSlots.size() > 1)
{ {
stack = stack.copy(); stack = stack.copy();
stack.size = this.dragSplittingRemnant; stack.setSize(this.dragSplittingRemnant);
if (stack.size == 0) if (stack.isEmpty())
{ {
s = "" + TextColor.YELLOW + "0"; s = "" + TextColor.YELLOW + "0";
} }
} }
else if(stack == this.cheatStack) { 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); 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) { protected void renderToolTip(ItemStack stack, int x, int y) {
List<String> list = stack.getTooltip(this.gm.player); List<String> list = this.getTooltip(stack);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for(int i = 0; i < list.size(); ++i) { for(int i = 0; i < list.size(); ++i) {
if(i != 0) if(i != 0)
@ -426,18 +519,18 @@ public abstract class GuiContainer extends Gui
{ {
itemstack = itemstack1.copy(); itemstack = itemstack1.copy();
flag = true; 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()); s = TextColor.YELLOW + formatAmount(itemstack.getMaxStackSize());
itemstack.size = 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)); s = TextColor.YELLOW + formatAmount(slotIn.getItemStackLimit(itemstack));
itemstack.size = slotIn.getItemStackLimit(itemstack); itemstack.setSize(slotIn.getItemStackLimit(itemstack));
} }
} }
else else
@ -462,25 +555,25 @@ public abstract class GuiContainer extends Gui
if (itemstack != null && this.dragSplitting) if (itemstack != null && this.dragSplitting)
{ {
this.dragSplittingRemnant = itemstack.size; this.dragSplittingRemnant = itemstack.getSize();
for (Slot slot : this.dragSplittingSlots) for (Slot slot : this.dragSplittingSlots)
{ {
ItemStack itemstack1 = itemstack.copy(); 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); 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) { if(this.cheatStack != null) {
Slot slot = this.getSlotAtPosition(mouseX, mouseY); Slot slot = this.getSlotAtPosition(mouseX, mouseY);
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.canCheatItem()) 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()) if(mouseButton != 1 && !this.gm.ctrl())
this.cheatStack = null; this.cheatStack = null;
return; return;
@ -605,7 +698,7 @@ public abstract class GuiContainer extends Gui
Slot slot = this.getSlotAtPosition(mouseX, mouseY); Slot slot = this.getSlotAtPosition(mouseX, mouseY);
ItemStack itemstack = this.gm.player.inventory.getItemStack(); 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.dragSplittingSlots.add(slot);
this.updateDragSplitting(); this.updateDragSplitting();
@ -772,13 +865,13 @@ public abstract class GuiContainer extends Gui
{ {
if (stack != null) 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); 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) { if(!this.cheatLast.isBlank() && this.gm.player != null) {
for(Iterator<ItemStack> iter = ITEM_LIST.iterator(); iter.hasNext();) { for(Iterator<ItemStack> iter = ITEM_LIST.iterator(); iter.hasNext();) {
ItemStack stack = iter.next(); 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())) { if(line.toLowerCase().contains(this.cheatLast.toLowerCase())) {
stack = null; stack = null;
break; 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)); this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(idx).getItem(), slot < 0 ? slot : -2 - slot, full));
} }
else { else {
this.cheatStack = ITEM_LIST.get(idx).copy(); this.cheatStack = ITEM_LIST.get(idx).copy(full ? ITEM_LIST.get(idx).getMaxStackSize() : 1);
this.cheatStack.size = full ? this.cheatStack.getMaxStackSize() : 1;
} }
return true; return true;
} }

View file

@ -139,7 +139,7 @@ public class EntityRenderer {
float shift = light * (1.0F - dist) + dist; float shift = light * (1.0F - dist) + dist;
this.fogMult += (shift - this.fogMult) * 0.1F; this.fogMult += (shift - this.fogMult) * 0.1F;
++this.rendererUpdateCount; ++this.rendererUpdateCount;
this.itemRenderer.updateEquippedItem(); this.itemRenderer.update();
this.addRainParticles(); this.addRainParticles();
// this.bossColorModifierPrev = this.bossColorModifier; // this.bossColorModifierPrev = this.bossColorModifier;
// //

View file

@ -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 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(); 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 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 RenderManager renderManager;
private final RenderItem itemRenderer; 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 int equippedItemSlot = -1;
private static FloatBuffer setColorBuffer(float r, float g, float b, float a) 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) private boolean isBlockTranslucent(Block blockIn)
{ {
return blockIn != null && blockIn.getBlockLayer() == BlockLayer.TRANSLUCENT; 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) private void rotateArroundXAndY(float angle, float angleY)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -158,9 +144,6 @@ public class ItemRenderer
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
/**
* Set the OpenGL LightMapTextureCoords based on the EntityNPCClient
*/
private void setLightMapFromPlayer(EntityNPC clientPlayer) private void setLightMapFromPlayer(EntityNPC clientPlayer)
{ {
int i = this.gm.world.getCombinedLight(new BlockPos(clientPlayer.posX, clientPlayer.posY + (double)clientPlayer.getEyeHeight(), clientPlayer.posZ), 0); 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); 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) private void rotateWithPlayerRotations(EntityNPC entityplayerspIn, float partialTicks)
{ {
float f = entityplayerspIn.prevRenderArmPitch + (entityplayerspIn.renderArmPitch - entityplayerspIn.prevRenderArmPitch) * 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); 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) private float getMapAngleFromPitch(float pitch)
{ {
float f = 1.0F - pitch / 45.0F + 0.1F; 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) private void renderPlayerArm(EntityNPC clientPlayer, float equipProgress, float swingProgress)
{ {
float f = -0.3F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI); float f = -0.3F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
@ -305,11 +274,6 @@ public class ItemRenderer
GlState.enableCull(); GlState.enableCull();
} }
/**
* Rotate and translate render to show item consumption
*
* @param swingProgress The swing movement progress
*/
private void doItemUsedTransformations(float swingProgress) private void doItemUsedTransformations(float swingProgress)
{ {
float f = -0.4F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI); float f = -0.4F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
@ -318,33 +282,25 @@ public class ItemRenderer
GL11.glTranslatef(f, f1, f2); GL11.glTranslatef(f, f1, f2);
} }
// /** private void performDrinking(EntityNPC clientPlayer, float partialTicks)
// * Perform the drinking animation movement {
// * float f = (float)clientPlayer.getItemInUseCount() - partialTicks + 1.0F;
// * @param partialTicks Partials ticks float f1 = f / (float)this.itemToRender.getMaxItemUseDuration();
// */ float f2 = ExtMath.absf(ExtMath.cos(f / 4.0F * (float)Math.PI) * 0.1F);
// private void performDrinking(EntityNPCSP clientPlayer, float partialTicks)
// { if (f1 >= 0.8F)
// float f = (float)clientPlayer.getItemInUseCount() - partialTicks + 1.0F; {
// float f1 = f / (float)this.itemToRender.getMaxItemUseDuration(); f2 = 0.0F;
// float f2 = ExtMath.absf(ExtMath.cos(f / 4.0F * (float)Math.PI) * 0.1F); }
//
// if (f1 >= 0.8F) GL11.glTranslatef(0.0F, f2, 0.0F);
// { float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D);
// f2 = 0.0F; 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);
// SKC.glTranslatef(0.0F, f2, 0.0F); GL11.glRotatef(f3 * 30.0F, 0.0F, 0.0F, 1.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);
// }
/**
* Performs transformations prior to the rendering of a held item in first person.
*/
private void transformFirstPersonItem(float equipProgress, float swingProgress) private void transformFirstPersonItem(float equipProgress, float swingProgress)
{ {
GL11.glTranslatef(0.56F, -0.52F, -0.71999997F); GL11.glTranslatef(0.56F, -0.52F, -0.71999997F);
@ -358,11 +314,6 @@ public class ItemRenderer
GL11.glScalef(0.4F, 0.4F, 0.4F); 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) private void doBowTransformations(float partialTicks, EntityNPC clientPlayer)
{ {
GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); 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); GL11.glScalef(1.0F, 1.0F, 1.0F + f1 * 0.2F);
} }
/**
* Translate and rotate the render for holding a block
*/
private void doBlockTransformations() private void doBlockTransformations()
{ {
GL11.glTranslatef(-0.5F, 0.2F, 0.0F); 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); 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) public void renderItemInFirstPerson(float partialTicks)
{ {
float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * 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 != null)
{ {
// if (this.itemToRender.getItem() == Items.filled_map)
// {
// this.renderItemMap(clientplayer, f2, f, f1);
// }
// else
if (clientplayer.getItemInUseCount() > 0) if (clientplayer.getItemInUseCount() > 0)
{ {
ItemAction enumaction = this.itemToRender.getItemUseAction(); ItemAction enumaction = this.itemToRender.getItemUseAction();
@ -436,9 +376,9 @@ public class ItemRenderer
case EAT: case EAT:
case DRINK: case DRINK:
// this.performDrinking(clientplayer, partialTicks); this.performDrinking(clientplayer, partialTicks);
// this.transformFirstPersonItem(f, 0.0F); this.transformFirstPersonItem(f, 0.0F);
// break; break;
case BLOCK: case BLOCK:
this.transformFirstPersonItem(f, 0.0F); this.transformFirstPersonItem(f, 0.0F);
@ -458,7 +398,7 @@ public class ItemRenderer
this.renderItem(clientplayer, this.itemToRender, Transforms.Camera.FIRST_PERSON); this.renderItem(clientplayer, this.itemToRender, Transforms.Camera.FIRST_PERSON);
} }
else // if (!clientplayer.isInvisible()) else
{ {
this.renderPlayerArm(clientplayer, f, f1); this.renderPlayerArm(clientplayer, f, f1);
} }
@ -468,9 +408,6 @@ public class ItemRenderer
ItemRenderer.disableStandardItemLighting(); ItemRenderer.disableStandardItemLighting();
} }
/**
* Renders all the overlays that are in first person mode. Args: partialTickTime
*/
public void renderOverlays(float partialTicks) public void renderOverlays(float partialTicks)
{ {
GlState.disableAlpha(); GlState.disableAlpha();
@ -496,27 +433,20 @@ public class ItemRenderer
if (iblockstate.getBlock().getRenderType() != -1) 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()) { if(this.gm.player.isBurning()) {
this.renderFireInFirstPerson(partialTicks); this.renderFireOverlay(partialTicks);
} }
GlState.enableAlpha(); GlState.enableAlpha();
} }
/** private void renderBlockInside(float partialTicks, TextureAtlasSprite atlas)
* 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)
{ {
this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS); this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS);
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer(); RenderBuffer worldrenderer = Tessellator.getBuffer();
float f = 0.1F; float f = 0.1F;
GlState.color(0.1F, 0.1F, 0.1F, 0.5F); 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); GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
} }
/** private void renderFireOverlay(float partialTicks)
* Renders the fire on the screen for first person mode. Arg: partialTickTime
*
* @param partialTicks Partial ticks
*/
private void renderFireInFirstPerson(float partialTicks)
{ {
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer(); RenderBuffer worldrenderer = Tessellator.getBuffer();
GlState.color(1.0F, 1.0F, 1.0F, 0.9F); GlState.color(1.0F, 1.0F, 1.0F, 0.9F);
GlState.depthFunc(GL11.GL_ALWAYS); GlState.depthFunc(GL11.GL_ALWAYS);
@ -587,7 +511,7 @@ public class ItemRenderer
GlState.depthFunc(GL11.GL_LEQUAL); GlState.depthFunc(GL11.GL_LEQUAL);
} }
public void updateEquippedItem() public void update()
{ {
this.prevEquippedProgress = this.equippedProgress; this.prevEquippedProgress = this.equippedProgress;
EntityNPC entityplayer = this.gm.player; EntityNPC entityplayer = this.gm.player;
@ -596,7 +520,7 @@ public class ItemRenderer
if (this.itemToRender != null && itemstack != null) if (this.itemToRender != null && itemstack != null)
{ {
if (!this.itemToRender.getIsItemStackEqual(itemstack)) if (!this.itemToRender.allEquals(itemstack))
{ {
flag = true; flag = true;
} }
@ -622,18 +546,7 @@ public class ItemRenderer
} }
} }
/** public void resetProgress()
* Resets equippedProgress
*/
public void resetEquippedProgress()
{
this.equippedProgress = 0.0F;
}
/**
* Resets equippedProgress
*/
public void resetEquippedProgress2()
{ {
this.equippedProgress = 0.0F; this.equippedProgress = 0.0F;
} }

View file

@ -37,7 +37,7 @@ public class RenderEntityItem extends Render<EntityItem>
else else
{ {
boolean flag = p_177077_9_.isGui3d(); boolean flag = p_177077_9_.isGui3d();
int i = this.func_177078_a(itemstack); int i = this.getMultiplier(itemstack);
float f = 0.25F; float f = 0.25F;
float f1 = ExtMath.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F; 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(); float f2 = p_177077_9_.getTransforms().get(Transforms.Camera.GROUND).scale();
@ -62,23 +62,23 @@ public class RenderEntityItem extends Render<EntityItem>
} }
} }
private int func_177078_a(ItemStack stack) private int getMultiplier(ItemStack stack)
{ {
int i = 1; int i = 1;
if (stack.size > 48) if (stack.getSize() > 48)
{ {
i = 5; i = 5;
} }
else if (stack.size > 32) else if (stack.getSize() > 32)
{ {
i = 4; i = 4;
} }
else if (stack.size > 16) else if (stack.getSize() > 16)
{ {
i = 3; i = 3;
} }
else if (stack.size > 1) else if (stack.getSize() > 1)
{ {
i = 2; i = 2;
} }

View file

@ -62,9 +62,9 @@ public class PlayerController {
ItemStack stack = this.gm.player.getCurrentEquippedItem(); ItemStack stack = this.gm.player.getCurrentEquippedItem();
if(stack != null) { 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(); this.gm.player.destroyCurrentEquippedItem();
} }
} }
@ -189,7 +189,7 @@ public class PlayerController {
if(this.stack != null && stack != null) { if(this.stack != null && stack != null) {
flag = stack.getItem() == this.stack.getItem() flag = stack.getItem() == this.stack.getItem()
&& ItemStack.areItemStackTagsEqual(stack, this.stack); && ItemStack.dataEquals(stack, this.stack);
} }
return pos.equals(this.position) && flag; return pos.equals(this.position) && flag;
@ -243,7 +243,7 @@ public class PlayerController {
return false; return false;
} }
else { else {
return stack.onItemUse(player, world, pos, side, f, f1, f2); return stack.getItem().onItemUse(stack, player, world, pos, side, f, f1, f2);
} }
} }
else { else {
@ -255,13 +255,13 @@ public class PlayerController {
public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) { public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) {
this.syncItem(); this.syncItem();
this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem())); this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem()));
int size = stack.size; int size = stack.getSize();
ItemStack changed = stack.useItemRightClick(world, player); 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; player.inventory.mainInventory[player.inventory.currentItem] = changed;
if(changed.size == 0) { if(changed.isEmpty()) {
player.inventory.mainInventory[player.inventory.currentItem] = null; player.inventory.mainInventory[player.inventory.currentItem] = null;
} }

View file

@ -176,9 +176,9 @@ public class EntityAIControlledByPlayer extends EntityAIBase
if (itemstack != null && itemstack.getItem() == Items.carrot_on_a_stick) 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); ItemStack itemstack1 = new ItemStack(Items.fishing_rod);
itemstack1.copyData(itemstack); itemstack1.copyData(itemstack);

View file

@ -60,21 +60,21 @@ public class EntityAIShareItems extends EntityAIWatchClosest2
{ {
Item item = itemstack.getItem(); 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; int l = itemstack.getSize() / 2;
itemstack.size -= l; itemstack.decrSize(l);
itemstack1 = new ItemStack(item, 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; int k = j / 3;
itemstack.size -= j; itemstack.decrSize(j);
itemstack1 = new ItemStack(Items.bread, k); itemstack1 = new ItemStack(Items.bread, k);
} }
if (itemstack.size <= 0) if (itemstack.isEmpty())
{ {
inventorybasic.setInventorySlotContents(i, (ItemStack)null); inventorybasic.setInventorySlotContents(i, (ItemStack)null);
} }

View file

@ -84,8 +84,7 @@ public class EntityAITakePlace extends EntityAIBase
(float)this.entity.getVerticalFaceSpeed()); (float)this.entity.getVerticalFaceSpeed());
this.entity.swingItem(); this.entity.swingItem();
world.setState(blockpos, state, 3); world.setState(blockpos, state, 3);
--stack.size; if(stack.decrSize())
if(stack.size <= 0)
this.entity.setItemNoUpdate(0, null); this.entity.setItemNoUpdate(0, null);
} }
} }
@ -94,14 +93,14 @@ public class EntityAITakePlace extends EntityAIBase
Block block = state.getBlock(); Block block = state.getBlock();
if (STEALABLE.containsKey(state) && 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, this.entity.getLookHelper().setLookPosition((double)i + 0.5, (double)j + 0.5, (double)k + 0.5, 10.0F,
(float)this.entity.getVerticalFaceSpeed()); (float)this.entity.getVerticalFaceSpeed());
this.entity.swingItem(); this.entity.swingItem();
world.setState(blockpos, Blocks.air.getState()); world.setState(blockpos, Blocks.air.getState());
if(this.entity.getHeldItem() != null) if(this.entity.getHeldItem() != null)
++this.entity.getHeldItem().size; this.entity.getHeldItem().incrSize();
else else
this.entity.setItemNoUpdate(0, new ItemStack(STEALABLE.get(state))); this.entity.setItemNoUpdate(0, new ItemStack(STEALABLE.get(state)));
} }

View file

@ -163,7 +163,7 @@ public class BlockFlowerPot extends Block
// worldIn.markBlockForUpdate(pos); // worldIn.markBlockForUpdate(pos);
// playerIn.triggerAchievement(StatRegistry.flowerPottedStat); // playerIn.triggerAchievement(StatRegistry.flowerPottedStat);
if (/* !playerIn.creative && */ --itemstack.size <= 0) if (itemstack.decrSize())
{ {
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null); playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
} }

View file

@ -59,7 +59,7 @@ public class BlockOre extends Block
public int quantityDropped(Random random) 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; // this == Blocks.lapis_ore ? 4 + random.nextInt(5) : 1;
} }

View file

@ -522,9 +522,8 @@ public class BlockCauldron extends Block
} }
// playerIn.triggerAchievement(StatRegistry.cauldronUsedStat); // playerIn.triggerAchievement(StatRegistry.cauldronUsedStat);
--itemstack.size;
if (itemstack.size <= 0) if (itemstack.decrSize())
{ {
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null); playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
} }

View file

@ -143,7 +143,7 @@ public class BlockDispenser extends BlockContainer implements Directional
ItemStack itemstack = tileentitydispenser.getStackInSlot(i); ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if(itemstack != null) { if(itemstack != null) {
ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos); ItemStack itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
tileentitydispenser.setInventorySlotContents(i, itemstack1.size <= 0 ? null : itemstack1); tileentitydispenser.setInventorySlotContents(i, itemstack1.isEmpty() ? null : itemstack1);
} }
} }
} }

View file

@ -15,7 +15,7 @@ public class BlockDropper extends BlockDispenser
protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos) protected ItemStack dispenseStack(ItemStack stack, World world, BlockPos pos)
{ {
Facing facing = world.getState(pos).getValue(FACING); 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(1000, pos, 0);
world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3); world.playAuxSFX(2000, pos, facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3);
return stack; return stack;
@ -56,20 +56,20 @@ public class BlockDropper extends BlockDispenser
{ {
itemstack1 = this.dispenseStack(itemstack, worldIn, pos); itemstack1 = this.dispenseStack(itemstack, worldIn, pos);
if (itemstack1 != null && itemstack1.size <= 0) if (itemstack1 != null && itemstack1.isEmpty())
{ {
itemstack1 = null; itemstack1 = null;
} }
} }
else else
{ {
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite()); itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().split(1), enumfacing.getOpposite());
if (itemstack1 == null) if (itemstack1 == null)
{ {
itemstack1 = itemstack.copy(); itemstack1 = itemstack.copy();
if (--itemstack1.size <= 0) if (itemstack1.decrSize())
{ {
itemstack1 = null; itemstack1 = null;
} }

View file

@ -119,11 +119,11 @@ public class BlockTNT extends Block
if (item == Items.flint_and_steel) if (item == Items.flint_and_steel)
{ {
playerIn.getCurrentEquippedItem().damageItem(1, playerIn); playerIn.getCurrentEquippedItem().damage(1, playerIn);
} }
else // if (!playerIn.creative) else // if (!playerIn.creative)
{ {
--playerIn.getCurrentEquippedItem().size; playerIn.getCurrentEquippedItem().decrSize();
} }
return true; return true;

View file

@ -198,12 +198,12 @@ public enum Enchantment implements Displayable, Identifyable
if (itemstack != null) if (itemstack != null)
{ {
itemstack.damageItem(3, user); itemstack.damage(3, user);
} }
} }
else if (itemstack != null) else if (itemstack != null)
{ {
itemstack.damageItem(1, user); itemstack.damage(1, user);
} }
} }
}, },

View file

@ -1638,7 +1638,7 @@ public abstract class Entity
*/ */
public EntityItem entityDropItem(ItemStack itemStackIn, float offsetY) 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 entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)offsetY, this.posZ, itemStackIn);
entityitem.setDefaultPickupDelay(); entityitem.setDefaultPickupDelay();

View file

@ -124,7 +124,7 @@ public class EntityCow extends EntityAnimal
if (itemstack != null && itemstack.getItem() == Items.bucket /* && !player.creative */ && !this.isChild()) 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)); player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.milk_bucket));
} }

View file

@ -935,7 +935,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (!this.isTame() && !flag) if (!this.isTame() && !flag)
{ {
if (itemstack != null && itemstack.interactWithEntity(player, this)) if (itemstack != null && itemstack.getItem().itemInteractionForEntity(itemstack, player, this))
{ {
return true; return true;
} }
@ -960,7 +960,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (flag) if (flag)
{ {
if (/* !player.creative && */ --itemstack.size == 0) if (itemstack.decrSize())
{ {
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); 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 (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; return true;
} }

View file

@ -30,7 +30,7 @@ public class EntityMooshroom extends EntityCow
if (itemstack != null && itemstack.getItem() == Items.bowl && !this.isChild()) 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)); player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.mushroom_stew));
return true; 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))); 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); this.playSound(SoundEvent.CUT, 1.0F);
} }

View file

@ -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) else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() instanceof ItemFishFood fish && !fish.isCooked() && player.getDistanceSqToEntity(this) < 9.0D)
{ {
// if (!player.creative) if (itemstack.decrSize())
// {
--itemstack.size;
// }
if (itemstack.size <= 0)
{ {
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
} }

View file

@ -199,7 +199,7 @@ public class EntitySheep extends EntityAnimal
} }
} }
itemstack.damageItem(1, player); itemstack.damage(1, player);
this.playSound(SoundEvent.CUT, 1.0F); this.playSound(SoundEvent.CUT, 1.0F);
} }

View file

@ -360,14 +360,9 @@ public class EntityWolf extends EntityTameable
if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectInt(18) < 20) if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectInt(18) < 20)
{ {
// if (!player.creative)
// {
--itemstack.size;
// }
this.heal(itemfood.getHealAmount(itemstack)); this.heal(itemfood.getHealAmount(itemstack));
if (itemstack.size <= 0) if (itemstack.decrSize())
{ {
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
} }
@ -383,7 +378,7 @@ public class EntityWolf extends EntityTameable
{ {
this.setCollarColor(enumdyecolor); this.setCollarColor(enumdyecolor);
if (/* !player.creative && */ --itemstack.size <= 0) if (itemstack.decrSize())
{ {
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); 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()) else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry())
{ {
// if (!player.creative) if (itemstack.decrSize())
// {
--itemstack.size;
// }
if (itemstack.size <= 0)
{ {
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
} }

View file

@ -62,7 +62,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
{ {
if (this.minecartContainerItems[index] != null) if (this.minecartContainerItems[index] != null)
{ {
if (this.minecartContainerItems[index].size <= count) if (this.minecartContainerItems[index].getSize() <= count)
{ {
ItemStack itemstack1 = this.minecartContainerItems[index]; ItemStack itemstack1 = this.minecartContainerItems[index];
this.minecartContainerItems[index] = null; this.minecartContainerItems[index] = null;
@ -70,9 +70,9 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
} }
else 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; this.minecartContainerItems[index] = null;
} }
@ -110,9 +110,9 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
{ {
this.minecartContainerItems[index] = stack; 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());
} }
} }

View file

@ -212,39 +212,39 @@ public class EntityItem extends Entity
} }
else if (other.isEntityAlive() && this.isEntityAlive()) else if (other.isEntityAlive() && this.isEntityAlive())
{ {
ItemStack itemstack = this.getEntityItem(); ItemStack stack = this.getEntityItem();
ItemStack itemstack1 = other.getEntityItem(); ItemStack otherStack = other.getEntityItem();
if (this.delayBeforeCanPickup != 32767 && other.delayBeforeCanPickup != 32767) if (this.delayBeforeCanPickup != 32767 && other.delayBeforeCanPickup != 32767)
{ {
if (this.age != -32768 && other.age != -32768) if (this.age != -32768 && other.age != -32768)
{ {
if (itemstack1.getItem() != itemstack.getItem()) if (otherStack.getItem() != stack.getItem())
{ {
return false; return false;
} }
else if (!itemstack1.dataEquals(itemstack)) else if (!otherStack.dataEquals(stack))
{ {
return false; return false;
} }
else if (itemstack1.getItem() == null) else if (otherStack.getItem() == null)
{ {
return false; return false;
} }
else if (itemstack1.size < itemstack.size) else if (otherStack.getSize() < stack.getSize())
{ {
return other.combineItems(this); return other.combineItems(this);
} }
else if (itemstack1.size + itemstack.size > itemstack1.getMaxStackSize()) else if (otherStack.getSize() + stack.getSize() > otherStack.getMaxStackSize())
{ {
return false; return false;
} }
else else
{ {
itemstack1.size += itemstack.size; otherStack.incrSize(stack.getSize());
other.delayBeforeCanPickup = Math.max(other.delayBeforeCanPickup, this.delayBeforeCanPickup); other.delayBeforeCanPickup = Math.max(other.delayBeforeCanPickup, this.delayBeforeCanPickup);
other.age = Math.min(other.age, this.age); other.age = Math.min(other.age, this.age);
other.setEntityItemStack(itemstack1); other.setEntityItemStack(otherStack);
this.setDead(); this.setDead();
return true; return true;
} }
@ -389,7 +389,7 @@ public class EntityItem extends Entity
if (!this.worldObj.client) if (!this.worldObj.client)
{ {
ItemStack itemstack = this.getEntityItem(); 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())) if (this.delayBeforeCanPickup == 0 // && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getUser()))
&& entityIn.inventory.addItemStackToInventory(itemstack)) && entityIn.inventory.addItemStackToInventory(itemstack))
@ -436,7 +436,7 @@ public class EntityItem extends Entity
entityIn.onItemPickup(this, i); entityIn.onItemPickup(this, i);
if (itemstack.size <= 0) if (itemstack.isEmpty())
{ {
this.setDead(); this.setDead();
} }
@ -451,10 +451,8 @@ public class EntityItem extends Entity
{ {
if(this.hasCustomName()) if(this.hasCustomName())
return this.getCustomNameTag(); return this.getCustomNameTag();
String comp = super.getTypeName(); ItemStack stack = this.getEntityItem();
comp += " (" + this.getEntityItem().size + " * " + return super.getTypeName() + " (" + (stack.isStacked() ? stack.getSize() + " * " : "") + stack.getItem().getDisplay() + ")";
ItemRegistry.getName(this.getEntityItem().getItem()) + ")";
return comp;
} }
/** /**
@ -600,9 +598,9 @@ public class EntityItem extends Entity
public String getDisplayName() public String getDisplayName()
{ {
ItemStack stack = this.getEntityItem(); ItemStack stack = this.getEntityItem();
if(stack.size <= 1) if(!stack.isStacked())
return null; return null;
return TextColor.DGREEN + "" + stack.size; return TextColor.DGREEN + "" + stack.getSize();
} }
public EntityType getType() { public EntityType getType() {

View file

@ -237,7 +237,7 @@ public class EntityHaunter extends EntityNPC {
if (!this.worldObj.client) if (!this.worldObj.client)
{ {
this.ignite(); this.ignite();
itemstack.damageItem(1, player); itemstack.damage(1, player);
return true; return true;
} }
} }

View file

@ -564,19 +564,6 @@ public abstract class EntityNPC extends EntityLiving
// return ; // 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() // protected boolean canDropLoot()
// { // {
// return true; // return true;
@ -636,13 +623,14 @@ public abstract class EntityNPC extends EntityLiving
public boolean interact(EntityNPC player) public boolean interact(EntityNPC player)
{ {
ItemStack itemstack = player.inventory.getCurrentItem(); ItemStack stack = player.inventory.getCurrentItem();
boolean flag = itemstack != null && !(itemstack.getItem() instanceof ItemTool || itemstack.getItem() instanceof ItemSword || boolean flag = stack != null && !(stack.getItem() instanceof ItemTool || stack.getItem() instanceof ItemSword ||
itemstack.getItem() instanceof ItemHoe || itemstack.getItem() instanceof ItemShears); 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) if (!this.worldObj.client)
{ {
this.setIsWillingToMate(true); this.setIsWillingToMate(true);
@ -651,9 +639,10 @@ public abstract class EntityNPC extends EntityLiving
} }
return true; 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) if (!this.worldObj.client)
{ {
this.grow(this.rand.range(200, 250)); this.grow(this.rand.range(200, 250));
@ -1437,7 +1426,7 @@ public abstract class EntityNPC extends EntityLiving
} }
else 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 itemstack = this.prevEquipment[j];
ItemStack itemstack1 = this.getItem(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)); ((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityEquipment(this.getId(), j, itemstack1));
@ -1681,7 +1670,7 @@ public abstract class EntityNPC extends EntityLiving
if (itemstack1 != null) 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(); 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)); this.client.addToSendQueue(new CPacketBreak(c07packetplayerdigging$action, BlockPos.ORIGIN, Facing.DOWN));
return null; 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) if (this.itemInUse != null)
{ {
this.updateItemUse(this.itemInUse, 16); this.updateItemUse(this.itemInUse, 16);
int i = this.itemInUse.size; int i = this.itemInUse.getSize();
ItemStack itemstack = this.itemInUse.onItemUseFinish(this.worldObj, this); 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; this.inventory.mainInventory[this.inventory.currentItem] = itemstack;
if (itemstack.size == 0) if (itemstack.isEmpty())
{ {
this.inventory.mainInventory[this.inventory.currentItem] = null; this.inventory.mainInventory[this.inventory.currentItem] = null;
} }
@ -3035,7 +3024,7 @@ public abstract class EntityNPC extends EntityLiving
{ {
if (this.itemInUse != null) 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(); this.clearItemInUse();
@ -3210,7 +3199,7 @@ public abstract class EntityNPC extends EntityLiving
{ {
return null; return null;
} }
else if (droppedItem.size == 0) else if (droppedItem.isEmpty())
{ {
return null; return null;
} }
@ -3622,9 +3611,9 @@ public abstract class EntityNPC extends EntityLiving
// itemstack = itemstack1; // 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(); this.destroyCurrentEquippedItem();
} }
@ -3639,7 +3628,7 @@ public abstract class EntityNPC extends EntityLiving
{ {
if (itemstack != null && itemstack == this.getCurrentEquippedItem()) if (itemstack != null && itemstack == this.getCurrentEquippedItem())
{ {
if (itemstack.size <= 0) // && !this.creative) if (itemstack.isEmpty()) // && !this.creative)
{ {
this.destroyCurrentEquippedItem(); this.destroyCurrentEquippedItem();
} }
@ -3790,9 +3779,9 @@ public abstract class EntityNPC extends EntityLiving
if (itemstack != null && entity instanceof 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(); this.destroyCurrentEquippedItem();
} }

View file

@ -164,20 +164,22 @@ public abstract class EntityAnimal extends EntityLiving
*/ */
public boolean interact(EntityNPC player) 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); this.setInLove(player);
return true; 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) if(!this.worldObj.client)
this.grow((int)((float)(-this.getGrowingAge() / 20) * 0.1F)); this.grow((int)((float)(-this.getGrowingAge() / 20) * 0.1F));
return true; return true;
@ -187,22 +189,6 @@ public abstract class EntityAnimal extends EntityLiving
return super.interact(player); 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) public void setInLove(EntityNPC player)
{ {
if(!this.worldObj.client) { if(!this.worldObj.client) {

View file

@ -900,7 +900,7 @@ public abstract class EntityLiving extends Entity
{ {
if ((source == DamageSource.anvil || source == DamageSource.fallingBlock) && this.getItem(4) != null) 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); amount = (int)((float)amount * 0.75F);
} }
@ -2684,33 +2684,17 @@ public abstract class EntityLiving extends Entity
public boolean interactFirst(EntityNPC player) { public boolean interactFirst(EntityNPC player) {
if(this.getLeashed() && this.getLeashedTo() == player) { if(this.getLeashed() && this.getLeashedTo() == player) {
this.clearLeashed(true, true); // !player.creative); this.clearLeashed(true, true);
return true; return true;
} }
else {
ItemStack stack = player.inventory.getCurrentItem(); ItemStack stack = player.inventory.getCurrentItem();
if(stack != null && stack.getItem() == Items.lead && this.allowLeashing() && (!(this instanceof EntityTameable tameable) || !tameable.isTamed() || tameable.isOwner(player))) {
if(stack != null && stack.getItem() == Items.lead && this.allowLeashing()) {
if(!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed()) {
this.setLeashedTo(player, true); this.setLeashedTo(player, true);
--stack.size; if(stack.decrSize())
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true; return true;
} }
return this.interact(player) || super.interactFirst(player);
if(((EntityTameable)this).isOwner(player)) {
this.setLeashedTo(player, true);
--stack.size;
return true;
}
}
if(this.interact(player)) {
return true;
}
else {
return super.interactFirst(player);
}
}
} }
// protected boolean interact(EntityNPC player) { // protected boolean interact(EntityNPC player) {
@ -3140,9 +3124,8 @@ public abstract class EntityLiving extends Entity
// if (!player.creative) // if (!player.creative)
// { // {
--itemstack.size;
if (itemstack.size <= 0) if (itemstack.decrSize())
{ {
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
} }

View file

@ -527,7 +527,7 @@ public abstract class CraftingRegistry
{ {
ItemStack itemstack1 = (ItemStack)list.get(0); 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; return false;
} }
@ -557,7 +557,7 @@ public abstract class CraftingRegistry
{ {
ItemStack itemstack1 = (ItemStack)list.get(0); 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; return null;
} }
@ -570,7 +570,7 @@ public abstract class CraftingRegistry
ItemStack itemstack2 = (ItemStack)list.get(0); ItemStack itemstack2 = (ItemStack)list.get(0);
ItemStack itemstack3 = (ItemStack)list.get(1); 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(); Item item = itemstack2.getItem();
int j = item.getMaxDamage() - itemstack2.getItemDamage(); int j = item.getMaxDamage() - itemstack2.getItemDamage();
@ -686,8 +686,7 @@ public abstract class CraftingRegistry
return null; return null;
} }
itemstack = itemstack1.copy(); itemstack = itemstack1.copy(1);
itemstack.size = 1;
if (itemstack1.hasColor()) if (itemstack1.hasColor())
{ {

View file

@ -84,7 +84,7 @@ public abstract class Container
ItemStack current = ((Slot)this.inventorySlots.get(i)).getStack(); ItemStack current = ((Slot)this.inventorySlots.get(i)).getStack();
ItemStack last = (ItemStack)this.inventoryItemStacks.get(i); ItemStack last = (ItemStack)this.inventoryItemStacks.get(i);
if (!ItemStack.areItemStacksEqual(last, current)) if (!ItemStack.allEquals(last, current))
{ {
last = current == null ? null : current.copy(); last = current == null ? null : current.copy();
this.inventoryItemStacks.set(i, last); this.inventoryItemStacks.set(i, last);
@ -178,7 +178,7 @@ public abstract class Container
{ {
Slot slot = (Slot)this.inventorySlots.get(slotId); 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); this.dragSlots.add(slot);
} }
@ -188,34 +188,34 @@ public abstract class Container
if (!this.dragSlots.isEmpty()) if (!this.dragSlots.isEmpty())
{ {
ItemStack itemstack3 = inventoryplayer.getItemStack().copy(); ItemStack itemstack3 = inventoryplayer.getItemStack().copy();
int j = inventoryplayer.getItemStack().size; int j = inventoryplayer.getItemStack().getSize();
for (Slot slot1 : this.dragSlots) 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(); 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); 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); slot1.putStack(itemstack1);
} }
} }
itemstack3.size = j; itemstack3.setSize(j);
if (itemstack3.size <= 0) if (itemstack3.isEmpty())
{ {
itemstack3 = null; itemstack3 = null;
} }
@ -248,9 +248,9 @@ public abstract class Container
if (clickedButton == 1) 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); inventoryplayer.setItemStack((ItemStack)null);
} }
@ -305,19 +305,19 @@ public abstract class Container
{ {
if (itemstack10 != null && slot7.isItemValid(itemstack10)) 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)) if (k2 > slot7.getItemStackLimit(itemstack10))
{ {
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); inventoryplayer.setItemStack((ItemStack)null);
} }
@ -327,11 +327,11 @@ public abstract class Container
{ {
if (itemstack10 == null) 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); ItemStack itemstack12 = slot7.decrStackSize(j2);
inventoryplayer.setItemStack(itemstack12); inventoryplayer.setItemStack(itemstack12);
if (itemstack9.size == 0) if (itemstack9.isEmpty())
{ {
slot7.putStack((ItemStack)null); slot7.putStack((ItemStack)null);
} }
@ -340,45 +340,45 @@ public abstract class Container
} }
else if (slot7.isItemValid(itemstack10)) 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); 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); slot7.putStack(itemstack10);
inventoryplayer.setItemStack(itemstack9); 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); itemstack9 = slot7.decrStackSize(l1);
if (itemstack9.size == 0) if (itemstack9.isEmpty())
{ {
slot7.putStack((ItemStack)null); slot7.putStack((ItemStack)null);
} }
@ -418,14 +418,14 @@ public abstract class Container
if (k1 > -1) if (k1 > -1)
{ {
inventoryplayer.addItemStackToInventory(itemstack7); inventoryplayer.addItemStackToInventory(itemstack7);
slot5.decrStackSize(itemstack11.size); slot5.decrStackSize(itemstack11.getSize());
slot5.putStack((ItemStack)null); slot5.putStack((ItemStack)null);
slot5.onPickupFromSlot(playerIn, itemstack11); slot5.onPickupFromSlot(playerIn, itemstack11);
} }
} }
else else
{ {
slot5.decrStackSize(itemstack11.size); slot5.decrStackSize(itemstack11.getSize());
slot5.putStack(itemstack7); slot5.putStack(itemstack7);
slot5.onPickupFromSlot(playerIn, itemstack11); slot5.onPickupFromSlot(playerIn, itemstack11);
} }
@ -454,7 +454,7 @@ public abstract class Container
if (slot3 != null && slot3.getHasStack() && slot3.canTakeStack(playerIn)) 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); slot3.onPickupFromSlot(playerIn, itemstack5);
playerIn.dropPlayerItemWithRandomChoice(itemstack5, true); playerIn.dropPlayerItemWithRandomChoice(itemstack5, true);
} }
@ -471,17 +471,17 @@ public abstract class Container
for (int l2 = 0; l2 < 2; ++l2) 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); 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); ItemStack itemstack2 = slot8.decrStackSize(l);
itemstack4.size += l; itemstack4.incrSize(l);
if (itemstack2.size <= 0) if (itemstack2.isEmpty())
{ {
slot8.putStack((ItemStack)null); slot8.putStack((ItemStack)null);
} }
@ -611,26 +611,26 @@ public abstract class Container
if (stack.isStackable()) 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); Slot slot = (Slot)this.inventorySlots.get(i);
ItemStack itemstack = slot.getStack(); 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()) if (j <= stack.getMaxStackSize())
{ {
stack.size = 0; stack.setSize(0);
itemstack.size = j; itemstack.setSize(j);
slot.onSlotChanged(); slot.onSlotChanged();
flag = true; flag = true;
} }
else if (itemstack.size < stack.getMaxStackSize()) else if (itemstack.getSize() < stack.getMaxStackSize())
{ {
stack.size -= stack.getMaxStackSize() - itemstack.size; stack.decrSize(stack.getMaxStackSize() - itemstack.getSize());
itemstack.size = stack.getMaxStackSize(); itemstack.setSize(stack.getMaxStackSize());
slot.onSlotChanged(); slot.onSlotChanged();
flag = true; flag = true;
} }
@ -647,7 +647,7 @@ public abstract class Container
} }
} }
if (stack.size > 0) if (!stack.isEmpty())
{ {
if (reverseDirection) if (reverseDirection)
{ {
@ -667,7 +667,7 @@ public abstract class Container
{ {
slot1.putStack(stack.copy()); slot1.putStack(stack.copy());
slot1.onSlotChanged(); slot1.onSlotChanged();
stack.size = 0; stack.setSize(0);
flag = true; flag = true;
break; break;
} }
@ -732,9 +732,9 @@ public abstract class Container
{ {
boolean flag = slotIn == null || !slotIn.getHasStack(); 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; return flag;
@ -749,18 +749,18 @@ public abstract class Container
switch (p_94525_1_) switch (p_94525_1_)
{ {
case 0: 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; break;
case 1: case 1:
p_94525_2_.size = 1; p_94525_2_.setSize(1);
break; break;
case 2: 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) 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; ++i;
} }
} }

View file

@ -128,7 +128,7 @@ public class ContainerBrewingStand extends Container
slot.onSlotChange(itemstack1, itemstack); slot.onSlotChange(itemstack1, itemstack);
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -137,7 +137,7 @@ public class ContainerBrewingStand extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -67,7 +67,7 @@ public class ContainerChest extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }

View file

@ -63,7 +63,7 @@ public class ContainerDispenser extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -72,7 +72,7 @@ public class ContainerDispenser extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -330,16 +330,15 @@ public class ContainerEnchantment extends Container
return null; return null;
} }
if (itemstack1.size >= 1) if (!itemstack1.isEmpty())
{ {
ItemStack st = itemstack1.copy(); ItemStack st = itemstack1.copy(1);
st.size = 1;
((Slot)this.inventorySlots.get(0)).putStack(st); ((Slot)this.inventorySlots.get(0)).putStack(st);
--itemstack1.size; itemstack1.decrSize();
} }
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -348,7 +347,7 @@ public class ContainerEnchantment extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -108,7 +108,7 @@ public class ContainerEntityInventory extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }

View file

@ -143,7 +143,7 @@ public class ContainerFurnace extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -152,7 +152,7 @@ public class ContainerFurnace extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -62,7 +62,7 @@ public class ContainerHopper extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }

View file

@ -123,7 +123,7 @@ public class ContainerMerchant extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -132,7 +132,7 @@ public class ContainerMerchant extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -95,7 +95,7 @@ public class ContainerPlayer extends Container {
ItemStack current = slot.getStack(); ItemStack current = slot.getStack();
ItemStack last = (ItemStack)this.lastStacks.get(i - 9); ItemStack last = (ItemStack)this.lastStacks.get(i - 9);
if (!ItemStack.areItemStacksEqual(last, current)) if (!ItemStack.allEquals(last, current))
{ {
if (last != null) if (last != null)
{ {
@ -104,7 +104,7 @@ public class ContainerPlayer extends Container {
if (current != null) 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(); last = current == null ? null : current.copy();
@ -226,7 +226,7 @@ public class ContainerPlayer extends Container {
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -235,7 +235,7 @@ public class ContainerPlayer extends Container {
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -89,9 +89,9 @@ public class ContainerRepair extends Container
{ {
ItemStack itemstack = ContainerRepair.this.inputSlots.getStackInSlot(1); 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); ContainerRepair.this.inputSlots.setInventorySlotContents(1, itemstack);
} }
else else
@ -210,7 +210,7 @@ public class ContainerRepair extends Container
int cost; 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; int j5 = newStack.getItemDamage() - damage;
newStack.setItemDamage(j5); newStack.setItemDamage(j5);
@ -469,7 +469,7 @@ public class ContainerRepair extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -478,7 +478,7 @@ public class ContainerRepair extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -77,7 +77,7 @@ public class ContainerTile extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }

View file

@ -129,7 +129,7 @@ public class ContainerWorkbench extends Container
return null; return null;
} }
if (itemstack1.size == 0) if (itemstack1.isEmpty())
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack)null);
} }
@ -138,7 +138,7 @@ public class ContainerWorkbench extends Container
slot.onSlotChanged(); slot.onSlotChanged();
} }
if (itemstack1.size == itemstack.size) if (itemstack1.getSize() == itemstack.getSize())
{ {
return null; return null;
} }

View file

@ -68,7 +68,7 @@ public class InventoryBasic implements IInventory
{ {
if (this.inventoryContents[index] != null) if (this.inventoryContents[index] != null)
{ {
if (this.inventoryContents[index].size <= count) if (this.inventoryContents[index].getSize() <= count)
{ {
ItemStack itemstack1 = this.inventoryContents[index]; ItemStack itemstack1 = this.inventoryContents[index];
this.inventoryContents[index] = null; this.inventoryContents[index] = null;
@ -77,9 +77,9 @@ public class InventoryBasic implements IInventory
} }
else 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; this.inventoryContents[index] = null;
} }
@ -109,17 +109,15 @@ public class InventoryBasic implements IInventory
return null; return null;
} }
if (ItemStack.areItemsEqual(itemstack1, itemstack)) if (ItemStack.itemEquals(itemstack1, itemstack))
{ {
int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize()); 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) if (k > 0)
{ {
itemstack1.size += k; itemstack1.incrSize(k);
itemstack.size -= k; if (itemstack.decrSize(k))
if (itemstack.size <= 0)
{ {
this.markDirty(); this.markDirty();
return null; return null;
@ -128,7 +126,7 @@ public class InventoryBasic implements IInventory
} }
} }
if (itemstack.size != stack.size) if (itemstack.getSize() != stack.getSize())
{ {
this.markDirty(); this.markDirty();
} }
@ -160,9 +158,9 @@ public class InventoryBasic implements IInventory
{ {
this.inventoryContents[index] = stack; 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(); this.markDirty();

View file

@ -98,7 +98,7 @@ public class InventoryCrafting implements IInventory
{ {
if (this.stackList[index] != null) if (this.stackList[index] != null)
{ {
if (this.stackList[index].size <= count) if (this.stackList[index].getSize() <= count)
{ {
ItemStack itemstack1 = this.stackList[index]; ItemStack itemstack1 = this.stackList[index];
this.stackList[index] = null; this.stackList[index] = null;
@ -107,9 +107,9 @@ public class InventoryCrafting implements IInventory
} }
else 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; this.stackList[index] = null;
} }

View file

@ -40,16 +40,16 @@ public class InventoryHelper
float f1 = RANDOM.floatv() * 0.8F + 0.1F; float f1 = RANDOM.floatv() * 0.8F + 0.1F;
float f2 = 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 entityitem = new EntityItem(worldIn, x + (double)f, y + (double)f1, z + (double)f2, new ItemStack(stack.getItem(), i));
entityitem.getEntityItem().copyData(stack); entityitem.getEntityItem().copyData(stack);

View file

@ -59,7 +59,7 @@ public class InventoryMerchant implements IInventory
this.theInventory[index] = null; this.theInventory[index] = null;
return itemstack2; return itemstack2;
} }
else if (this.theInventory[index].size <= count) else if (this.theInventory[index].getSize() <= count)
{ {
ItemStack itemstack1 = this.theInventory[index]; ItemStack itemstack1 = this.theInventory[index];
this.theInventory[index] = null; this.theInventory[index] = null;
@ -73,9 +73,9 @@ public class InventoryMerchant implements IInventory
} }
else 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; this.theInventory[index] = null;
} }
@ -126,9 +126,9 @@ public class InventoryMerchant implements IInventory
{ {
this.theInventory[index] = stack; 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)) if (this.inventoryResetNeededOnSlotChange(index))

View file

@ -72,7 +72,7 @@ public class InventoryPlayer implements IInventory
{ {
for (int i = 0; i < this.mainInventory.length; ++i) 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; return i;
} }
@ -183,7 +183,7 @@ public class InventoryPlayer implements IInventory
private int storePartialItemStack(ItemStack itemStackIn) private int storePartialItemStack(ItemStack itemStackIn)
{ {
Item item = itemStackIn.getItem(); Item item = itemStackIn.getItem();
int i = itemStackIn.size; int i = itemStackIn.getSize();
int j = this.storeItemStack(itemStackIn); int j = this.storeItemStack(itemStackIn);
if (j < 0) if (j < 0)
@ -206,14 +206,14 @@ public class InventoryPlayer implements IInventory
int k = i; 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) if (k == 0)
@ -223,7 +223,7 @@ public class InventoryPlayer implements IInventory
else else
{ {
i = i - k; i = i - k;
this.mainInventory[j].size += k; this.mainInventory[j].incrSize(k);
// this.mainInventory[j].animationsToGo = 5; // this.mainInventory[j].animationsToGo = 5;
return i; return i;
} }
@ -258,7 +258,7 @@ public class InventoryPlayer implements IInventory
} }
else else
{ {
if (--this.mainInventory[i].size <= 0) if (this.mainInventory[i].decrSize())
{ {
this.mainInventory[i] = null; this.mainInventory[i] = null;
} }
@ -281,7 +281,7 @@ public class InventoryPlayer implements IInventory
*/ */
public boolean addItemStackToInventory(final ItemStack itemStackIn) 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()) if (itemStackIn.isItemDamaged())
{ {
@ -289,9 +289,9 @@ public class InventoryPlayer implements IInventory
if (j >= 0) if (j >= 0)
{ {
this.mainInventory[j] = ItemStack.copyItemStack(itemStackIn); this.mainInventory[j] = ItemStack.copy(itemStackIn);
// this.mainInventory[j].animationsToGo = 5; // this.mainInventory[j].animationsToGo = 5;
itemStackIn.size = 0; itemStackIn.setSize(0);
return true; return true;
} }
// else if (this.player.creative) // else if (this.player.creative)
@ -310,10 +310,10 @@ public class InventoryPlayer implements IInventory
while (true) while (true)
{ {
i = itemStackIn.size; i = itemStackIn.getSize();
itemStackIn.size = this.storePartialItemStack(itemStackIn); itemStackIn.setSize(this.storePartialItemStack(itemStackIn));
if (itemStackIn.size <= 0 || itemStackIn.size >= i) if (itemStackIn.isEmpty() || itemStackIn.getSize() >= i)
{ {
break; break;
} }
@ -326,7 +326,7 @@ public class InventoryPlayer implements IInventory
// } // }
// else // 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] != null)
{ {
if (aitemstack[index].size <= count) if (aitemstack[index].getSize() <= count)
{ {
ItemStack itemstack1 = aitemstack[index]; ItemStack itemstack1 = aitemstack[index];
aitemstack[index] = null; aitemstack[index] = null;
@ -359,9 +359,9 @@ public class InventoryPlayer implements IInventory
} }
else 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; aitemstack[index] = null;
} }
@ -422,7 +422,7 @@ public class InventoryPlayer implements IInventory
if (this.mainInventory[this.currentItem] != null) 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; return f;
@ -541,7 +541,7 @@ public class InventoryPlayer implements IInventory
if(!block.getMaterial().isToolRequired()) if(!block.getMaterial().isToolRequired())
return true; return true;
ItemStack stack = this.getStackInSlot(this.currentItem); 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) 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; this.armorInventory[i] = null;
} }
@ -663,7 +663,7 @@ public class InventoryPlayer implements IInventory
{ {
for (int i = 0; i < this.armorInventory.length; ++i) 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; return true;
} }
@ -671,7 +671,7 @@ public class InventoryPlayer implements IInventory
for (int j = 0; j < this.mainInventory.length; ++j) 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; return true;
} }
@ -703,12 +703,12 @@ public class InventoryPlayer implements IInventory
{ {
for (int i = 0; i < this.mainInventory.length; ++i) 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) 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; this.currentItem = playerInventory.currentItem;

View file

@ -37,7 +37,7 @@ public class Slot
{ {
if (p_75220_1_.getItem() == p_75220_2_.getItem()) 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) if (i > 0)
{ {

View file

@ -35,7 +35,7 @@ public class SlotFurnaceOutput extends Slot
{ {
if (this.getHasStack()) if (this.getHasStack())
{ {
this.smelted += Math.min(amount, this.getStack().size); this.smelted += Math.min(amount, this.getStack().getSize());
} }
return super.decrStackSize(amount); return super.decrStackSize(amount);

View file

@ -35,7 +35,7 @@ public class SlotMerchantResult extends Slot
{ {
if (this.getHasStack()) if (this.getHasStack())
{ {
this.traded += Math.min(amount, this.getStack().size); this.traded += Math.min(amount, this.getStack().getSize());
} }
return super.decrStackSize(amount); return super.decrStackSize(amount);
@ -76,12 +76,12 @@ public class SlotMerchantResult extends Slot
// this.theMerchant.useRecipe(merchantrecipe); // this.theMerchant.useRecipe(merchantrecipe);
// playerIn.triggerAchievement(StatRegistry.timesTradedWithNpcStat); // playerIn.triggerAchievement(StatRegistry.timesTradedWithNpcStat);
if (itemstack != null && itemstack.size <= 0) if (itemstack != null && itemstack.isEmpty())
{ {
itemstack = null; itemstack = null;
} }
if (itemstack1 != null && itemstack1.size <= 0) if (itemstack1 != null && itemstack1.isEmpty())
{ {
itemstack1 = null; itemstack1 = null;
} }
@ -101,14 +101,14 @@ public class SlotMerchantResult extends Slot
{ {
if (itemstack1 != null && secondItem != null && itemstack1.getItem() == secondItem.getItem()) if (itemstack1 != null && secondItem != null && itemstack1.getItem() == secondItem.getItem())
{ {
firstItem.size -= itemstack.size; firstItem.decrSize(itemstack.getSize());
secondItem.size -= itemstack1.size; secondItem.decrSize(itemstack1.getSize());
return true; return true;
} }
if (itemstack1 == null && secondItem == null) if (itemstack1 == null && secondItem == null)
{ {
firstItem.size -= itemstack.size; firstItem.decrSize(itemstack.getSize());
return true; return true;
} }
} }

View file

@ -141,7 +141,7 @@ public class Item {
entity.setThrowableHeading((double)facing.getFrontOffsetX(), (double)((float)facing.getFrontOffsetY() + 0.1F), entity.setThrowableHeading((double)facing.getFrontOffsetX(), (double)((float)facing.getFrontOffsetY() + 0.1F),
(double)facing.getFrontOffsetZ(), velocity, inaccuracy); (double)facing.getFrontOffsetZ(), velocity, inaccuracy);
world.spawnEntityInWorld((Entity)entity); world.spawnEntityInWorld((Entity)entity);
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }
@ -274,7 +274,7 @@ public class Item {
} }
public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) { 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; return stack;
} }

View file

@ -1,6 +1,5 @@
package common.item; package common.item;
import java.text.DecimalFormat;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -8,7 +7,6 @@ import java.util.Set;
import common.attributes.Attribute; import common.attributes.Attribute;
import common.attributes.UsageSlot; import common.attributes.UsageSlot;
import common.block.Block;
import common.collect.Lists; import common.collect.Lists;
import common.collect.Maps; import common.collect.Maps;
import common.color.TextColor; import common.color.TextColor;
@ -20,152 +18,54 @@ import common.init.ItemRegistry;
import common.item.tool.ItemBow; import common.item.tool.ItemBow;
import common.rng.Random; import common.rng.Random;
import common.tags.TagObject; import common.tags.TagObject;
import common.util.BlockPos;
import common.util.Facing;
import common.world.World;
public final class ItemStack public final class ItemStack {
{
public static final int MAX_SIZE = 67108864; public static final int MAX_SIZE = 67108864;
private static final DecimalFormat DECIMALFORMAT = new DecimalFormat("#.###");
public int size;
private Item item; private Item item;
private int size;
private String name; private String name;
private int color = 0xffffffff; private int color = 0xffffffff;
private int damage; private int damage;
private int repairCost; private int repairCost;
private Map<Enchantment, Integer> enchantments; private Map<Enchantment, Integer> enchantments;
public ItemStack(Item item) public static ItemStack readFromTag(TagObject tag) {
{
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; Item item = tag.hasString("id") ? ItemRegistry.byName(tag.getString("id")) : null;
int size = tag.hasInt("size") ? tag.getInt("size") : 1; int size = tag.hasInt("size") ? tag.getInt("size") : 1;
if(item == null || size < 1) if(item == null || size < 1)
return null; return null;
ItemStack stack = new ItemStack(item, Math.min(item.getMaxAmount(), size)); ItemStack stack = new ItemStack(item, Math.min(item.getMaxAmount(), size));
stack.readTag(tag); stack.readTags(tag);
return stack; return stack;
} }
public static ItemStack getStack(String name, ItemStack def) { public static boolean itemEquals(ItemStack stackA, ItemStack stackB) {
if(name == null) return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.itemEquals(stackB) : false);
return def;
Item item = ItemRegistry.byName(name);
return item == null ? def : new ItemStack(item);
} }
public boolean dataEquals(ItemStack other) { public static boolean dataEquals(ItemStack stackA, ItemStack stackB) {
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 stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.dataEquals(stackB) : false);
return false;
if(this.enchantments == null)
return true;
for(Entry<Enchantment, Integer> ench : this.enchantments.entrySet()) {
if(!ench.getValue().equals(other.enchantments.get(ench.getKey())))
return false;
}
return true;
} }
public void copyData(ItemStack stack) { public static boolean allEquals(ItemStack stackA, ItemStack stackB) {
this.color = stack.color; return stackA == null && stackB == null ? true : (stackA != null && stackB != null ? stackA.allEquals(stackB) : false);
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 static ItemStack copy(ItemStack stack) {
* Splits off a stack of the given amount of this stack and reduces this stack by the amount. return stack == null ? null : stack.copy();
*/
public ItemStack splitStack(int amount)
{
ItemStack itemstack = new ItemStack(this.item, amount);
itemstack.copyData(this);
this.size -= amount;
return itemstack;
} }
/** public ItemStack(Item item) {
* Returns the object corresponding to the stack. this(item, 1);
*/
public Item getItem()
{
return this.item;
} }
/** public ItemStack(Item item, int amount) {
* Called when the player uses this ItemStack on a Block (right-click). Places blocks, etc. (Legacy name: this.item = item;
* tryPlaceItemIntoWorld) this.size = amount;
*/
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) public TagObject writeTags(TagObject tag) {
{
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) if(this.item != null)
tag.setString("id", ItemRegistry.getName(this.item)); tag.setString("id", ItemRegistry.getName(this.item));
if(this.size != 1) if(this.size != 1)
@ -192,8 +92,7 @@ public final class ItemStack
return tag; return tag;
} }
public void readTag(TagObject tag) public void readTags(TagObject tag) {
{
this.color = tag.hasInt("color") ? tag.getInt("color") : 0xffffffff; this.color = tag.hasInt("color") ? tag.getInt("color") : 0xffffffff;
this.color = (this.color & 0xff000000) != 0 ? 0xffffffff : this.color; this.color = (this.color & 0xff000000) != 0 ? 0xffffffff : this.color;
this.damage = tag.hasInt("dmg") ? Math.max(0, tag.getInt("dmg")) : 0; this.damage = tag.hasInt("dmg") ? Math.max(0, tag.getInt("dmg")) : 0;
@ -207,276 +106,130 @@ public final class ItemStack
if(!enc.hasString("id")) if(!enc.hasString("id"))
continue; continue;
Enchantment ench = Enchantment.getEnchantment(enc.getString("id")); Enchantment ench = Enchantment.getEnchantment(enc.getString("id"));
if(ench != null) int level = enc.hasShort("lvl") ? (int)enc.getShort("lvl") : 1;
this.enchantments.put(ench, enc.hasShort("lvl") ? (int)enc.getShort("lvl") : 1); if(ench != null && level > 0)
this.enchantments.put(ench, level);
} }
if(this.enchantments.isEmpty()) if(this.enchantments.isEmpty())
this.enchantments = null; this.enchantments = null;
} }
} }
public int getMaxStackSize() public boolean itemEquals(ItemStack other) {
{
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; return other != null && this.item == other.item;
} }
// public String getUnlocalizedName() public boolean dataEquals(ItemStack other) {
// { if(this.color != other.color || this.damage != other.damage || this.repairCost != other.repairCost
// return this.item.getUnlocalizedName(this); || (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;
* Creates a copy of a ItemStack, a null parameters will return a null. if(this.enchantments == null)
*/ return true;
public static ItemStack copyItemStack(ItemStack stack) for(Entry<Enchantment, Integer> ench : this.enchantments.entrySet()) {
{ if(!ench.getValue().equals(other.enchantments.get(ench.getKey())))
return stack == null ? null : stack.copy(); return false;
}
return true;
} }
// public String toString() public boolean allEquals(ItemStack other) {
// { return this.size == other.size && this.item == other.item && this.dataEquals(other);
// 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() public void copyData(ItemStack stack) {
{ this.color = stack.color;
return this.getItem().getMaxItemUseDuration(this); 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 ItemAction getItemUseAction() public ItemStack copy() {
{ ItemStack stack = new ItemStack(this.item, this.size);
return this.getItem().getItemUseAction(this); stack.copyData(this);
return stack;
} }
public ItemAction getItemPosition() public ItemStack copy(int size) {
{ ItemStack stack = new ItemStack(this.item, size);
return this.getItem().getItemPosition(this); stack.copyData(this);
return stack;
} }
/** public ItemStack split(int amount) {
* Called when the player releases the use item button. Args: world, entityplayer, itemInUseCount ItemStack stack = new ItemStack(this.item, amount);
*/ stack.copyData(this);
public void onPlayerStoppedUsing(World worldIn, EntityNPC playerIn, int timeLeft) this.size = Math.max(this.size - amount, 0);
{ return stack;
this.getItem().onPlayerStoppedUsing(this, worldIn, playerIn, timeLeft);
} }
public int getItemDamage()
{ 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; return this.isItemStackDamageable() ? this.damage : 0;
} }
public void setItemDamage(int damage) public String getDisplayName() {
{ return this.name != null ? this.name : this.item.getDisplay();
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() { public String getColoredName() {
@ -487,121 +240,77 @@ public final class ItemStack
return TextColor.DGRAY + "[" + this.getColor() + this.getDisplayName() + TextColor.DGRAY + "]" + reset; return TextColor.DGRAY + "[" + this.getColor() + this.getDisplayName() + TextColor.DGRAY + "]" + reset;
} }
public void setStackDisplayName(String displayName) 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<Entry<Enchantment, Integer>> 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 Map<Attribute, Float> getAttributeModifiers(UsageSlot slot) {
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class);
this.item.getModifiers(map, slot);
return map;
}
public boolean hasColor() {
return this.item.canBeDyed() && this.color != 0xffffffff;
}
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 setStackDisplayName(String displayName) {
this.name = displayName != null && !displayName.isEmpty() ? displayName : null; this.name = displayName != null && !displayName.isEmpty() ? displayName : null;
this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name; this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name;
} }
public void clearCustomName() public void clearCustomName() {
{
this.name = null; this.name = null;
} }
public boolean hasDisplayName() public void addEnchantment(Enchantment ench, int level) {
{
return this.name != null;
}
public List<String> getTooltip(EntityNPC playerIn)
{
List<String> list = Lists.<String>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<Enchantment, Integer> 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<Attribute, Float> mods = this.getAttributeModifiers(null);
if (!mods.isEmpty())
{
list.add("");
for (Entry<Attribute, Float> 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<Entry<Enchantment, Integer>> 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) if(this.enchantments == null)
this.enchantments = Maps.newEnumMap(Enchantment.class); this.enchantments = Maps.newEnumMap(Enchantment.class);
this.enchantments.put(ench, level); this.enchantments.put(ench, level);
@ -623,13 +332,7 @@ public final class ItemStack
return false; return false;
} }
public boolean isItemEnchanted() public void setEnchantments(Map<Enchantment, Integer> enchMap) {
{
return this.enchantments != null;
}
public void setEnchantments(Map<Enchantment, Integer> enchMap)
{
if(enchMap == null || enchMap.isEmpty()) { if(enchMap == null || enchMap.isEmpty()) {
this.enchantments = null; this.enchantments = null;
return; return;
@ -641,62 +344,72 @@ public final class ItemStack
this.enchantments.putAll(enchMap); this.enchantments.putAll(enchMap);
} }
public int getRepairCost() public void setRepairCost(int cost) {
{
return this.repairCost;
}
public void setRepairCost(int cost)
{
this.repairCost = Math.max(0, cost); this.repairCost = Math.max(0, cost);
} }
public Map<Attribute, Float> getAttributeModifiers(UsageSlot slot) { public void setItem(Item newItem) {
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class);
this.getItem().getModifiers(map, slot);
return map;
}
public void setItem(Item newItem)
{
this.item = newItem; this.item = newItem;
} }
public boolean canBeDyed() public void removeColor() {
{
return this.item.canBeDyed();
}
public boolean hasColor()
{
return this.item.canBeDyed() && this.color != 0xffffffff;
}
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 removeColor()
{
if(!this.item.canBeDyed()) if(!this.item.canBeDyed())
throw new UnsupportedOperationException("Kann diesen Gegenstand nicht entfärben!"); throw new UnsupportedOperationException("Kann diesen Gegenstand nicht entfärben!");
this.color = 0xffffffff; this.color = 0xffffffff;
} }
public void setColor(int color) public void setColor(int color) {
{
if(!this.item.canBeDyed()) if(!this.item.canBeDyed())
throw new UnsupportedOperationException("Kann diesen Gegenstand nicht einfärben!"); throw new UnsupportedOperationException("Kann diesen Gegenstand nicht einfärben!");
this.color = (color & 0xff000000) != 0 ? 0xffffffff : color; 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());
}
} }

View file

@ -33,9 +33,7 @@ public class RngLoot extends RngItem
public ItemStack getItem(Random rand) { public ItemStack getItem(Random rand) {
if(this.item == null) if(this.item == null)
return null; return null;
ItemStack stack = this.item.copy(); return this.item.copy(this.minStackSize + rand.zrange(this.maxStackSize - this.minStackSize + 1));
stack.size = this.minStackSize + rand.zrange(this.maxStackSize - this.minStackSize + 1);
return stack;
} }
public static void generateChestContents(Random random, WeightedList<RngLoot> list, IInventory inv, int max) public static void generateChestContents(Random random, WeightedList<RngLoot> list, IInventory inv, int max)
@ -47,17 +45,13 @@ public class RngLoot extends RngItem
if (loot.item.getMaxStackSize() >= j) if (loot.item.getMaxStackSize() >= j)
{ {
ItemStack itemstack1 = loot.item.copy(); inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(j));
itemstack1.size = j;
inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), itemstack1);
} }
else else
{ {
for (int k = 0; k < j; ++k) for (int k = 0; k < j; ++k)
{ {
ItemStack itemstack = loot.item.copy(); inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(1));
itemstack.size = 1;
inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), itemstack);
} }
} }
} }
@ -72,17 +66,13 @@ public class RngLoot extends RngItem
if (loot.item.getMaxStackSize() >= j) if (loot.item.getMaxStackSize() >= j)
{ {
ItemStack itemstack1 = loot.item.copy(); dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), loot.item.copy(j));
itemstack1.size = j;
dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), itemstack1);
} }
else else
{ {
for (int k = 0; k < j; ++k) for (int k = 0; k < j; ++k)
{ {
ItemStack itemstack = loot.item.copy(); dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), loot.item.copy(1));
itemstack.size = 1;
dispenser.setInventorySlotContents(random.zrange(dispenser.getSizeInventory()), itemstack);
} }
} }
} }

View file

@ -73,7 +73,7 @@ public class ItemBed extends Item
worldIn.setState(blockpos, iblockstate2, 3); worldIn.setState(blockpos, iblockstate2, 3);
} }
--stack.size; stack.decrSize();
return true; return true;
} }
else else

View file

@ -61,7 +61,7 @@ public class ItemBlock extends Item
pos = pos.offset(side); pos = pos.offset(side);
} }
if (stack.size == 0) if (stack.isEmpty())
{ {
return false; 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); 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; return true;

View file

@ -61,7 +61,7 @@ public class ItemDoor extends Item
else else
{ {
placeDoor(worldIn, pos, Facing.fromAngle((double)playerIn.rotYaw), this.block, true); placeDoor(worldIn, pos, Facing.fromAngle((double)playerIn.rotYaw), this.block, true);
--stack.size; stack.decrSize();
return true; return true;
} }
} }

View file

@ -50,7 +50,7 @@ public class ItemLilyPad extends ItemColored
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);

View file

@ -48,7 +48,7 @@ public class ItemMetalBlock extends ItemBlock {
} }
public float getRadiation(ItemStack stack) { 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() { public boolean isMagnetic() {

View file

@ -48,7 +48,7 @@ public class ItemRedstone extends Item
} }
else if (this.block.canPlaceBlockAt(worldIn, blockpos)) else if (this.block.canPlaceBlockAt(worldIn, blockpos))
{ {
--stack.size; stack.decrSize();
worldIn.setState(blockpos, this.block.getState()); worldIn.setState(blockpos, this.block.getState());
return true; return true;
} }

View file

@ -44,7 +44,7 @@ public class ItemSeedFood extends ItemFood
else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up())) else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up()))
{ {
worldIn.setState(pos.up(), this.crops.getState()); worldIn.setState(pos.up(), this.crops.getState());
--stack.size; stack.decrSize();
return true; return true;
} }
else else

View file

@ -44,7 +44,7 @@ public class ItemSeeds extends Item
else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up())) else if (worldIn.getState(pos).getBlock() == this.soil && worldIn.isAirBlock(pos.up()))
{ {
worldIn.setState(pos.up(), this.crops.getState()); worldIn.setState(pos.up(), this.crops.getState());
--stack.size; stack.decrSize();
return true; return true;
} }
else else

View file

@ -71,7 +71,7 @@ public class ItemSign extends Item
worldIn.setState(pos, Blocks.wall_sign.getState().withProperty(BlockWallSign.FACING, side), 3); worldIn.setState(pos, Blocks.wall_sign.getState().withProperty(BlockWallSign.FACING, side), 3);
} }
--stack.size; stack.decrSize();
TileEntity tileentity = worldIn.getTileEntity(pos); TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntitySign) if (tileentity instanceof TileEntitySign)

View file

@ -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) { 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)); (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)) { if(worldIn.setState(pos, place, 3)) {
worldIn.playSound(this.slab.sound.getPlaceSound(), (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), 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); (double)((float)pos.getZ() + 0.5F), 1.0F);
--stack.size; stack.decrSize();
} }
return true; return true;
} }

View file

@ -31,7 +31,7 @@ public class ItemSmallBlock extends Item {
else if(!block.isReplaceable(world, pos)) else if(!block.isReplaceable(world, pos))
pos = pos.offset(side); pos = pos.offset(side);
if(!player.canPlayerEdit(pos, side, stack) || stack.size == 0) if(!player.canPlayerEdit(pos, side, stack) || stack.isEmpty())
return false; return false;
if(world.canBlockBePlaced(this.block, pos, false, side, null, stack)) { if(world.canBlockBePlaced(this.block, pos, false, side, null, stack)) {
State newState = this.block.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, player); 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), 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); (double)((float)pos.getZ() + 0.5F), 1.0F);
--stack.size; stack.decrSize();
return true; return true;
} }
} }

View file

@ -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) 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; return false;
} }
@ -52,7 +52,7 @@ public class ItemSnow extends ItemBlock
if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setState(blockpos, iblockstate1, 2)) 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); 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; return true;
} }
} }

View file

@ -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); 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.spawnEntityInWorld(entitytntprimed);
world.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F); world.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F);
--stack.size; stack.decrSize();
return stack; return stack;
} }
} }

View file

@ -3,15 +3,12 @@ package common.item.material;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
public class ItemBook extends Item public class ItemBook extends Item {
{ public boolean canEnchant(ItemStack stack) {
public boolean canEnchant(ItemStack stack) return stack.getSize() == 1;
{
return stack.size == 1;
} }
public int getItemEnchantability() public int getItemEnchantability() {
{
return 1; return 1;
} }
} }

View file

@ -92,7 +92,7 @@ public class ItemDye extends Item {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
} }
@ -125,7 +125,7 @@ public class ItemDye extends Item {
worldIn.setState(pos, iblockstate1, 2); worldIn.setState(pos, iblockstate1, 2);
} }
// if(!playerIn.creative) // if(!playerIn.creative)
--stack.size; stack.decrSize();
return true; return true;
} }
} }
@ -151,7 +151,7 @@ public class ItemDye extends Item {
igrowable.grow((AWorldServer)worldIn, worldIn.rand, target, iblockstate); igrowable.grow((AWorldServer)worldIn, worldIn.rand, target, iblockstate);
} }
--stack.size; stack.decrSize();
} }
return true; return true;
@ -196,7 +196,7 @@ public class ItemDye extends Item {
if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != this.color) if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != this.color)
{ {
entitysheep.setFleeceColor(this.color); entitysheep.setFleeceColor(this.color);
--stack.size; stack.decrSize();
} }
return true; return true;

View file

@ -40,7 +40,7 @@ public class ItemMetal extends Item {
} }
public float getRadiation(ItemStack stack) { 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() { public boolean isMagnetic() {

View file

@ -106,7 +106,7 @@ public class ItemBoat extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // 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); EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
world.spawnEntityInWorld(entityboat); world.spawnEntityInWorld(entityboat);
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }
} }

View file

@ -67,7 +67,7 @@ public class ItemMinecart extends Item
// ((EntityMinecartCommandBlock)entityminecart).getCommandBlockLogic().setEnabled(((EntityNPCMP)playerIn).canUse(Permissions.CMDBLOCK)); // ((EntityMinecartCommandBlock)entityminecart).getCommandBlockLogic().setEnabled(((EntityNPCMP)playerIn).canUse(Permissions.CMDBLOCK));
} }
--stack.size; stack.decrSize();
return true; return true;
} }
else else
@ -128,7 +128,7 @@ public class ItemMinecart extends Item
} }
world.spawnEntityInWorld(entityminecart); world.spawnEntityInWorld(entityminecart);
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }
} }

View file

@ -108,7 +108,7 @@ public class ItemMonsterPlacer extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
} }
// } // }
@ -170,7 +170,7 @@ public class ItemMonsterPlacer extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
// if(z == 0) // if(z == 0)
@ -239,7 +239,7 @@ public class ItemMonsterPlacer extends Item
Entity entity = spawnCreature(world, this.entityId, d0, d1, d2, false); Entity entity = spawnCreature(world, this.entityId, d0, d1, d2, false);
if (entity instanceof EntityLiving && stack.hasDisplayName()) if (entity instanceof EntityLiving && stack.hasDisplayName())
((EntityLiving)entity).setCustomNameTag(stack.getDisplayName()); ((EntityLiving)entity).setCustomNameTag(stack.getDisplayName());
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }
} }

View file

@ -106,7 +106,7 @@ public class ItemNpcSpawner extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
} }
// } // }
@ -160,7 +160,7 @@ public class ItemNpcSpawner extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
// if(z == 0) // if(z == 0)
@ -228,7 +228,7 @@ public class ItemNpcSpawner extends Item
Entity entity = spawnNpc(world, this.spawned, d0, d1, d2, false); Entity entity = spawnNpc(world, this.spawned, d0, d1, d2, false);
if (entity instanceof EntityLiving && stack.hasDisplayName()) if (entity instanceof EntityLiving && stack.hasDisplayName())
((EntityLiving)entity).setCustomNameTag(stack.getDisplayName()); ((EntityLiving)entity).setCustomNameTag(stack.getDisplayName());
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }
} }

View file

@ -97,7 +97,7 @@ public class ItemArmor extends Item
if (itemstack == null) if (itemstack == null)
{ {
playerIn.setItem(i, itemStackIn.copy()); playerIn.setItem(i, itemStackIn.copy());
itemStackIn.size = 0; itemStackIn.setSize(0);
} }
return itemStackIn; return itemStackIn;
@ -180,11 +180,10 @@ public class ItemArmor extends Item
EntityLiving entitylivingbase = (EntityLiving)list.get(0); EntityLiving entitylivingbase = (EntityLiving)list.get(0);
int l = entitylivingbase.isPlayer() ? 1 : 0; int l = entitylivingbase.isPlayer() ? 1 : 0;
int i1 = getArmorPosition(stack); int i1 = getArmorPosition(stack);
ItemStack itemstack = stack.copy(); ItemStack itemstack = stack.copy(1);
itemstack.size = 1;
entitylivingbase.setItem(i1 - l, itemstack); entitylivingbase.setItem(i1 - l, itemstack);
--stack.size; stack.decrSize();
return stack; return stack;
} }
else else

View file

@ -70,7 +70,7 @@ public class ItemBow extends Item
entityarrow.setFire(100); entityarrow.setFire(100);
} }
stack.damageItem(1, playerIn); stack.damage(1, playerIn);
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 1.0F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 1.0F);
if (flag) if (flag)

View file

@ -185,7 +185,7 @@ public class ItemBucket extends Item
setRecursive((AWorldServer)worldIn, blockpos, 4, null); setRecursive((AWorldServer)worldIn, blockpos, 4, null);
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
// if(!playerIn.creative) // if(!playerIn.creative)
--itemStackIn.size; itemStackIn.decrSize();
return itemStackIn; return itemStackIn;
} }
} }
@ -217,7 +217,7 @@ public class ItemBucket extends Item
{ {
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
if(this.recursive) { if(this.recursive) {
--itemStackIn.size; itemStackIn.decrSize();
return itemStackIn; return itemStackIn;
} }
return new ItemStack(Items.bucket); return new ItemStack(Items.bucket);
@ -236,7 +236,7 @@ public class ItemBucket extends Item
// return emptyBuckets; // return emptyBuckets;
// } // }
// else // else
if (--emptyBuckets.size <= 0) if (emptyBuckets.decrSize())
{ {
return fullBucket; return fullBucket;
} }
@ -346,10 +346,10 @@ public class ItemBucket extends Item
world.setBlockToAir(pos); world.setBlockToAir(pos);
if (--stack.size == 0) if (stack.decrSize())
{ {
stack.setItem(item); stack.setItem(item);
stack.size = 1; stack.setSize(1);
} }
else if (source instanceof TileEntityDispenser dispenser && dispenser.addItemStack(new ItemStack(item)) < 0) 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)) if (this.tryPlaceContainedLiquid(world, pos))
{ {
stack.setItem(Items.bucket); stack.setItem(Items.bucket);
stack.size = 1; stack.setSize(1);
return stack; return stack;
} }
else else

View file

@ -27,7 +27,7 @@ public class ItemBucketMilk extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
if (!worldIn.client) if (!worldIn.client)
@ -36,7 +36,7 @@ public class ItemBucketMilk extends Item
} }
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
return stack.size <= 0 ? new ItemStack(Items.bucket) : stack; return stack.isEmpty() ? new ItemStack(Items.bucket) : stack;
} }
/** /**

View file

@ -46,9 +46,9 @@ public class ItemCarrotOnAStick extends Item
if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getItemDamage() >= 7) if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getItemDamage() >= 7)
{ {
entitypig.getAIControlledByPlayer().boostSpeed(); 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 itemstack = new ItemStack(Items.fishing_rod);
itemstack.copyData(itemStackIn); itemstack.copyData(itemStackIn);

View file

@ -33,7 +33,7 @@ public class ItemChargedOrb extends ItemFragile
// } // }
if(itemStackIn.getItemDamage() >= this.getMaxDamage()) if(itemStackIn.getItemDamage() >= this.getMaxDamage())
return itemStackIn; return itemStackIn;
itemStackIn.damageItem(1, playerIn); itemStackIn.damage(1, playerIn);
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);
if (!worldIn.client) if (!worldIn.client)
@ -49,7 +49,7 @@ public class ItemChargedOrb extends ItemFragile
{ {
State iblockstate = worldIn.getState(pos); 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) if (worldIn.client)
{ {
@ -59,7 +59,7 @@ public class ItemChargedOrb extends ItemFragile
{ {
worldIn.setState(pos, iblockstate.withProperty(BlockPortalFrame.ORB, Boolean.valueOf(true)), 2); worldIn.setState(pos, iblockstate.withProperty(BlockPortalFrame.ORB, Boolean.valueOf(true)), 2);
worldIn.updateComparatorOutputLevel(pos, Blocks.portal_frame); worldIn.updateComparatorOutputLevel(pos, Blocks.portal_frame);
--stack.size; stack.decrSize();
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
{ {

View file

@ -66,7 +66,7 @@ public class ItemDie extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

View file

@ -33,7 +33,7 @@ public class ItemDynamite extends Item {
} }
public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player) { public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player) {
--stack.size; stack.decrSize();
world.playSoundAtEntity(player, SoundEvent.THROW, 0.5F); world.playSoundAtEntity(player, SoundEvent.THROW, 0.5F);
if(!world.client) if(!world.client)
world.spawnEntityInWorld(new EntityDynamite(world, player, this.power)); world.spawnEntityInWorld(new EntityDynamite(world, player, this.power));

View file

@ -26,7 +26,7 @@ public class ItemEgg extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

View file

@ -31,7 +31,7 @@ public class ItemExpBottle extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

View file

@ -47,7 +47,7 @@ public class ItemFireball extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
return true; return true;
@ -63,7 +63,7 @@ public class ItemFireball extends Item
double d4 = world.rand.gaussian() * 0.05D + (double)facing.getFrontOffsetY(); double d4 = world.rand.gaussian() * 0.05D + (double)facing.getFrontOffsetY();
double d5 = world.rand.gaussian() * 0.05D + (double)facing.getFrontOffsetZ(); double d5 = world.rand.gaussian() * 0.05D + (double)facing.getFrontOffsetZ();
world.spawnEntityInWorld(new EntityFireCharge(world, d0, d1, d2, d3, d4, d5)); world.spawnEntityInWorld(new EntityFireCharge(world, d0, d1, d2, d3, d4, d5));
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }

View file

@ -21,7 +21,7 @@ public class ItemFirework extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
return true; return true;
@ -38,7 +38,7 @@ public class ItemFirework extends Item
double d2 = blockpos.getZ() + 0.5 + (double)facing.getFrontOffsetZ(); double d2 = blockpos.getZ() + 0.5 + (double)facing.getFrontOffsetZ();
EntityFireworks entityfireworkrocket = new EntityFireworks(world, d0, d1, d2); EntityFireworks entityfireworkrocket = new EntityFireworks(world, d0, d1, d2);
world.spawnEntityInWorld(entityfireworkrocket); world.spawnEntityInWorld(entityfireworkrocket);
stack.splitStack(1); stack.split(1);
return stack; return stack;
} }

View file

@ -42,7 +42,7 @@ public class ItemFishingRod extends Item
if (playerIn.fishEntity != null) if (playerIn.fishEntity != null)
{ {
int i = playerIn.fishEntity.handleHookRetraction(); int i = playerIn.fishEntity.handleHookRetraction();
itemStackIn.damageItem(i, playerIn); itemStackIn.damage(i, playerIn);
playerIn.swingItem(); playerIn.swingItem();
} }
else else

View file

@ -44,7 +44,7 @@ public class ItemFlintAndSteel extends Item
worldIn.setState(pos, this.fireBlock.getState()); worldIn.setState(pos, this.fireBlock.getState());
} }
stack.damageItem(1, playerIn); stack.damage(1, playerIn);
return true; return true;
} }
} }
@ -60,10 +60,7 @@ public class ItemFlintAndSteel extends Item
{ {
world.setState(pos, this.fireBlock.getState()); world.setState(pos, this.fireBlock.getState());
if (stack.attemptDamageItem(1, world.rand)) stack.damage(1, null, world.rand);
{
stack.size = 0;
}
world.playAuxSFX(1000, blockpos, 0); world.playAuxSFX(1000, blockpos, 0);
} }
else if (world.getState(pos).getBlock() instanceof BlockTNT tnt) else if (world.getState(pos).getBlock() instanceof BlockTNT tnt)

View file

@ -35,7 +35,7 @@ public class ItemFood extends Item
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn)
{ {
// if(!playerIn.creative) // if(!playerIn.creative)
--stack.size; stack.decrSize();
worldIn.playSoundAtEntity(playerIn, SoundEvent.EAT, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.EAT, 0.5F);
playerIn.heal((int)((float)this.getHealAmount(stack) * 0.5f * (1.0f + worldIn.rand.floatv()))); playerIn.heal((int)((float)this.getHealAmount(stack) * 0.5f * (1.0f + worldIn.rand.floatv())));
this.onFoodEaten(stack, worldIn, playerIn); this.onFoodEaten(stack, worldIn, playerIn);

View file

@ -48,10 +48,9 @@ public class ItemGlassBottle extends Item
if (worldIn.getState(blockpos).getBlock().getMaterial() == Material.WATER) if (worldIn.getState(blockpos).getBlock().getMaterial() == Material.WATER)
{ {
--itemStackIn.size;
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
if (itemStackIn.size <= 0) if (itemStackIn.decrSize())
{ {
return new ItemStack(Items.potion); return new ItemStack(Items.potion);
} }

View file

@ -58,7 +58,7 @@ public abstract class ItemGunBase extends Item
// entityarrow.setFire(100); // entityarrow.setFire(100);
// } // }
stack.damageItem(1, playerIn); stack.damage(1, playerIn);
worldIn.playSoundAtEntity(playerIn, SoundEvent.EXPLODE_ALT, 1.0F); worldIn.playSoundAtEntity(playerIn, SoundEvent.EXPLODE_ALT, 1.0F);
if(!flag) if(!flag)

View file

@ -74,7 +74,7 @@ public class ItemHoe extends Item
else else
{ {
worldIn.setState(target, newState); worldIn.setState(target, newState);
stack.damageItem(1, player); stack.damage(1, player);
return true; return true;
} }
} }

View file

@ -27,7 +27,7 @@ public class ItemNameTag extends Item
EntityLiving entityliving = (EntityLiving)target; EntityLiving entityliving = (EntityLiving)target;
entityliving.setCustomNameTag(stack.getDisplayName()); entityliving.setCustomNameTag(stack.getDisplayName());
// entityliving.disableDespawn(); // entityliving.disableDespawn();
--stack.size; stack.decrSize();
return true; return true;
} }
else else

View file

@ -77,7 +77,7 @@ public class ItemPotion extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--stack.size; stack.decrSize();
// } // }
if (!worldIn.client) if (!worldIn.client)
@ -100,7 +100,7 @@ public class ItemPotion extends Item
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
if (stack.size <= 0) if (stack.isEmpty())
{ {
return new ItemStack(Items.glass_bottle); return new ItemStack(Items.glass_bottle);
} }
@ -136,7 +136,7 @@ public class ItemPotion extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

View file

@ -28,7 +28,7 @@ public class ItemSaddle extends Item
{ {
entitypig.setSaddled(true); entitypig.setSaddled(true);
// entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F); // entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
--stack.size; stack.decrSize();
} }
return true; return true;

View file

@ -30,7 +30,7 @@ public class ItemShears extends Item
} }
else else
{ {
stack.damageItem(1, playerIn); stack.damage(1, playerIn);
return true; return true;
} }
} }

View file

@ -26,7 +26,7 @@ public class ItemSnowball extends Item
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
--itemStackIn.size; itemStackIn.decrSize();
// } // }
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);

View file

@ -59,7 +59,7 @@ public class ItemSword extends Item
*/ */
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker)
{ {
stack.damageItem(1, attacker); stack.damage(1, attacker);
return true; return true;
} }
@ -70,7 +70,7 @@ public class ItemSword extends Item
{ {
if ((double)blockIn.getBlockHardness(worldIn, pos) != 0.0D) if ((double)blockIn.getBlockHardness(worldIn, pos) != 0.0D)
{ {
stack.damageItem(2, playerIn); stack.damage(2, playerIn);
} }
return true; return true;

View file

@ -30,13 +30,13 @@ public abstract class ItemTool extends Item {
} }
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) {
stack.damageItem(2, attacker); stack.damage(2, attacker);
return true; return true;
} }
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLiving player) { public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLiving player) {
if(block.getBlockHardness(world, pos) != 0.0f) if(block.getBlockHardness(world, pos) != 0.0f)
stack.damageItem(1, player); stack.damage(1, player);
return true; return true;
} }

View file

@ -23,7 +23,7 @@ public class ItemWeatherToken extends ItemMagnetic {
{ {
if(worldIn.dimension.getType().weather) { if(worldIn.dimension.getType().weather) {
// if (!playerIn.creative) // if (!playerIn.creative)
--itemStackIn.size; itemStackIn.decrSize();
worldIn.playSoundAtEntity(playerIn, SoundEvent.SPELL, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.SPELL, 0.5F);
if (!worldIn.client) if (!worldIn.client)
{ {

Some files were not shown because too many files have changed in this diff Show more