1
0
Fork 0

alter item limiting

This commit is contained in:
Sen 2025-09-13 13:55:18 +02:00
parent cb88dc3a4f
commit 27bd576c6e
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
78 changed files with 234 additions and 933 deletions

View file

@ -169,17 +169,6 @@ public abstract class GuiContainer extends Gui
} }
} }
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("Stapelbar");
list.add("Gewicht: " + (stack.getSize() != 1 ? (stack.getSize() * stack.getItem().getWeight()) + " (" + stack.getSize() + "x " + stack.getItem().getWeight() + ")" : stack.getItem().getWeight())); list.add("Gewicht: " + (stack.getSize() != 1 ? (stack.getSize() * stack.getItem().getWeight()) + " (" + stack.getSize() + "x " + stack.getItem().getWeight() + ")" : stack.getItem().getWeight()));
if(stack.getItem().getCategory() != null) if(stack.getItem().getCategory() != null)
@ -615,7 +604,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.isStacked())); this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack.getItem(), slot.slotNumber, mouseButton == 0 && this.cheatStack.getSize() > 1));
if(mouseButton != 1 && !this.gm.ctrl()) if(mouseButton != 1 && !this.gm.ctrl())
this.cheatStack = null; this.cheatStack = null;
return; return;
@ -689,7 +678,7 @@ public abstract class GuiContainer extends Gui
{ {
for (Slot slot2 : this.inventorySlots.inventorySlots) for (Slot slot2 : this.inventorySlots.inventorySlots)
{ {
if (slot2 != null && slot2.canTakeStack(this.gm.player) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true)) if (slot2 != null && slot2.canTakeStack(this.gm.player) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot))
{ {
this.handleMouseClick(slot2, slot2.slotNumber, state, 1); this.handleMouseClick(slot2, slot2.slotNumber, state, 1);
} }
@ -802,7 +791,7 @@ public abstract class GuiContainer extends Gui
renderItemOverlay(stack, xPosition, yPosition, text, 0, 0); renderItemOverlay(stack, xPosition, yPosition, text, 0, 0);
} }
public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar2, int bar2max) public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar, int barMax)
{ {
if (stack != null) if (stack != null)
{ {
@ -819,19 +808,10 @@ public abstract class GuiContainer extends Gui
Font.unset(); Font.unset();
} }
if (stack.isItemDamaged()) if (bar > 0)
{ {
int j = (int)Math.round(28.0D - (double)stack.getItemDamage() * 28.0D / (double)stack.getMaxDamage()); int j = (int)Math.round(28.0D - (double)bar * 28.0D / (double)barMax);
int i = (int)Math.round(255.0D - (double)stack.getItemDamage() * 255.0D / (double)stack.getMaxDamage()); int i = (int)Math.round(255.0D - (double)bar * 255.0D / (double)barMax);
draw(xPosition + 2, yPosition + 26, 28, 4, 0, 0, 0);
draw(xPosition + 2, yPosition + 26, 26, 2, (255 - i) / 4, 64, 0);
draw(xPosition + 2, yPosition + 26, j, 2, 255 - i, i, 0);
}
if (bar2 > 0)
{
int j = (int)Math.round(28.0D - (double)bar2 * 28.0D / (double)bar2max);
int i = (int)Math.round(255.0D - (double)bar2 * 255.0D / (double)bar2max);
draw(xPosition + 2, yPosition + 4, 28, 4, 0, 0, 0); draw(xPosition + 2, yPosition + 4, 28, 4, 0, 0, 0);
draw(xPosition + 2, yPosition + 4, 26, 2, (255 - i) / 8, (255 - i) / 16, i / 4); draw(xPosition + 2, yPosition + 4, 26, 2, (255 - i) / 8, (255 - i) / 16, i / 4);
draw(xPosition + 2 + 28 - j, yPosition + 4, j, 2, (255 - i) / 2, (255 - i) / 4, i); draw(xPosition + 2 + 28 - j, yPosition + 4, j, 2, (255 - i) / 2, (255 - i) / 4, i);
@ -933,7 +913,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(full ? Math.min(ITEM_LIST.get(idx).getMaxStackSize(), 100) : 1); this.cheatStack = ITEM_LIST.get(idx).copy(full ? 100 : 1);
} }
return true; return true;
} }

View file

@ -2,19 +2,19 @@ package client.gui.container;
import client.gui.element.Label; import client.gui.element.Label;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.inventory.ContainerRepair; import common.inventory.ContainerMagicCombiner;
import common.util.Color; import common.util.Color;
import common.world.World; import common.world.World;
public class GuiRepair extends GuiContainer { public class GuiRepair extends GuiContainer {
private ContainerRepair anvil; private ContainerMagicCombiner anvil;
private Label info; private Label info;
private EntityNPC playerInv; private EntityNPC playerInv;
public GuiRepair(EntityNPC inv, World world) { public GuiRepair(EntityNPC inv, World world) {
super(new ContainerRepair(inv, world)); super(new ContainerMagicCombiner(inv, world));
this.playerInv = inv; this.playerInv = inv;
this.anvil = (ContainerRepair)this.inventorySlots; this.anvil = (ContainerMagicCombiner)this.inventorySlots;
} }
public int getControlAreaWidth() { public int getControlAreaWidth() {

View file

@ -23,7 +23,6 @@ import common.item.consumable.ItemPotion;
import common.rng.Random; import common.rng.Random;
import common.util.LocalPos; import common.util.LocalPos;
import common.util.ExtMath; import common.util.ExtMath;
import common.util.Facing;
import common.util.ParticleType; import common.util.ParticleType;
import common.world.State; import common.world.State;
import common.world.World; import common.world.World;

View file

@ -6,8 +6,6 @@ import common.block.artificial.BlockStairs;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items;
import common.item.ItemStack;
import common.pathfinding.WalkNodeProcessor; import common.pathfinding.WalkNodeProcessor;
import common.util.LocalPos; import common.util.LocalPos;
import common.util.ExtMath; import common.util.ExtMath;
@ -170,16 +168,6 @@ public class EntityAIControlledByPlayer extends EntityAIBase
} }
} }
if (/* !entityplayer.creative && */ this.currentSpeed >= this.maxSpeed * 0.5F && this.thisEntity.getRNG().floatv() < 0.006F && !this.speedBoosted)
{
ItemStack itemstack = entityplayer.getHeldItem();
if (itemstack != null && itemstack.getItem() == Items.whip)
{
itemstack.damage(1, entityplayer);
}
}
this.thisEntity.moveEntityWithHeading(0.0F, f1); this.thisEntity.moveEntityWithHeading(0.0F, f1);
} }

View file

@ -93,7 +93,7 @@ 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().isFull()))) (this.entity.getHeldItem() == null || (STEALABLE.get(state) == this.entity.getHeldItem().getItem())))
{ {
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());

View file

@ -35,7 +35,6 @@ import common.item.CheatTab;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.ItemWeight; import common.item.ItemWeight;
import common.log.Log;
import common.model.Model; import common.model.Model;
import common.model.Model.ModelProvider; import common.model.Model.ModelProvider;
import common.model.GuiPosition; import common.model.GuiPosition;

View file

@ -2,7 +2,6 @@ package common.block.natural;
import common.block.Block; import common.block.Block;
import common.block.Material; import common.block.Material;
import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;

View file

@ -8,7 +8,7 @@ import common.entity.item.EntityFalling;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.ContainerRepair; import common.inventory.ContainerMagicCombiner;
import common.item.CheatTab; import common.item.CheatTab;
import common.model.Model; import common.model.Model;
import common.model.Model.ModelProvider; import common.model.Model.ModelProvider;
@ -16,7 +16,6 @@ import common.model.ModelRotation;
import common.properties.Property; import common.properties.Property;
import common.util.LocalPos; import common.util.LocalPos;
import common.util.BoundingBox; import common.util.BoundingBox;
import common.util.Clientside;
import common.util.ExtMath; import common.util.ExtMath;
import common.util.Facing; import common.util.Facing;
import common.world.IWorldAccess; import common.world.IWorldAccess;
@ -153,7 +152,7 @@ public class BlockAnvil extends BlockFalling implements Rotatable
public Container createContainer(EntityNPC playerInventory) public Container createContainer(EntityNPC playerInventory)
{ {
return new ContainerRepair(playerInventory, this.world, this.position); return new ContainerMagicCombiner(playerInventory, this.world, this.position);
} }
public Block getBlock() public Block getBlock()

View file

@ -96,11 +96,7 @@ public class BlockTNT extends Block
this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn); this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn);
worldIn.setBlockToAir(pos); worldIn.setBlockToAir(pos);
if (item == Items.lighter) if (item == Items.fireball)
{
playerIn.getHeldItem().damage(1, playerIn);
}
else // if (!playerIn.creative)
{ {
playerIn.getHeldItem().decrSize(); playerIn.getHeldItem().decrSize();
} }

View file

@ -32,9 +32,7 @@ public class BlockToggleableLight extends Block {
Item item = player.getHeldItem().getItem(); Item item = player.getHeldItem().getItem();
if(item != Items.lighter && item != Items.fireball) if(item != Items.lighter && item != Items.fireball)
return super.onUse(worldIn, pos, state, player, side, hitX, hitY, hitZ); return super.onUse(worldIn, pos, state, player, side, hitX, hitY, hitZ);
if(item == Items.lighter) if(item == Items.fireball)
player.getHeldItem().damage(1, player);
else
player.getHeldItem().decrSize(); player.getHeldItem().decrSize();
} }
this.toggle(worldIn, pos); this.toggle(worldIn, pos);

View file

@ -35,12 +35,8 @@ public class BlockUnlitTorch extends BlockTorch {
worldIn.setState(pos, this.lit.getState().withProperty(FACING, state.getValue(FACING)).withProperty(BlockLitTorch.FUEL, 7), 3); worldIn.setState(pos, this.lit.getState().withProperty(FACING, state.getValue(FACING)).withProperty(BlockLitTorch.FUEL, 7), 3);
worldIn.playEffect(playerIn, 1007, pos, 0); worldIn.playEffect(playerIn, 1007, pos, 0);
if(item == Items.lighter) { if(item == Items.fireball)
playerIn.getHeldItem().damage(1, playerIn);
}
else {
playerIn.getHeldItem().decrSize(); playerIn.getHeldItem().decrSize();
}
return true; return true;
} }

View file

@ -147,33 +147,16 @@ public enum Effect {
int k = 40 >> amp; int k = 40 >> amp;
if(k > 0 && duration % k != 0) if(k > 0 && duration % k != 0)
return; return;
for(ItemStack stack : npc.getInventory()) { int n = entity.worldObj.rand.zrange(npc.getInventory().length);
for(int z = 0; z < npc.getInventory().length; z++) {
ItemStack stack = npc.getInventory()[n];
if(++n >= npc.getInventory().length)
n = 0;
if(stack != null && !stack.isEmpty()) { if(stack != null && !stack.isEmpty()) {
if(!stack.isFull()) if(stack.getSize() < 100) {
stack.incrSize(); stack.incrSize();
if(stack.getRepairCost() > 0) break;
stack.setRepairCost(stack.getRepairCost() - 1); }
if(stack.isItemStackDamageable() && stack.getItemDamage() > 0)
stack.setItemDamage(stack.getItemDamage() - 1);
}
}
if(!npc.isPlayer() && npc.getHeldItem() != null && !npc.getHeldItem().isEmpty()) {
ItemStack stack = npc.getHeldItem();
if(!stack.isFull())
stack.incrSize();
if(stack.getRepairCost() > 0)
stack.setRepairCost(stack.getRepairCost() - 1);
if(stack.isItemStackDamageable() && stack.getItemDamage() > 0)
stack.setItemDamage(stack.getItemDamage() - 1);
}
for(ItemStack stack : npc.getArmor()) {
if(stack != null && !stack.isEmpty()) {
if(!stack.isFull())
stack.incrSize();
if(stack.getRepairCost() > 0)
stack.setRepairCost(stack.getRepairCost() - 1);
if(stack.isItemStackDamageable() && stack.getItemDamage() > 0)
stack.setItemDamage(stack.getItemDamage() - 1);
} }
} }
} }

View file

@ -196,15 +196,6 @@ public enum Enchantment implements Displayable, Identifyable
attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), getThornsDamage(level, random)); attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), getThornsDamage(level, random));
// attacker.playSound("damage.thorns", 0.5F, 1.0F); // attacker.playSound("damage.thorns", 0.5F, 1.0F);
} }
if (itemstack != null)
{
itemstack.damage(3, user);
}
}
else if (itemstack != null)
{
itemstack.damage(1, user);
} }
} }
}, },
@ -320,27 +311,6 @@ public enum Enchantment implements Displayable, Identifyable
return super.canApplyTogether(ench) && ench != FORTUNE; return super.canApplyTogether(ench) && ench != FORTUNE;
} }
}, },
UNBREAKING("unbreaking", 5, EnchantmentType.BREAKABLE, "Haltbarkeit") {
public int getMinEnchantability(int enchantmentLevel)
{
return 5 + (enchantmentLevel - 1) * 8;
}
public int getMaxEnchantability(int enchantmentLevel)
{
return super.getMinEnchantability(enchantmentLevel) + 50;
}
public int getMaxLevel()
{
return 3;
}
public boolean canApply(ItemStack stack)
{
return stack.isItemStackDamageable() || super.canApply(stack);
}
},
FORTUNE("fortune", 2, EnchantmentType.DIGGER, "Glück") { FORTUNE("fortune", 2, EnchantmentType.DIGGER, "Glück") {
public int getMinEnchantability(int enchantmentLevel) public int getMinEnchantability(int enchantmentLevel)
{ {

View file

@ -20,7 +20,6 @@ public enum EnchantmentType
WEAPON, WEAPON,
DIGGER, DIGGER,
FISHING_ROD, FISHING_ROD,
BREAKABLE,
BOW; BOW;
public boolean canEnchantItem(Item item) public boolean canEnchantItem(Item item)
@ -29,10 +28,6 @@ public enum EnchantmentType
{ {
return true; return true;
} }
else if (this == BREAKABLE && item.isDamageable())
{
return true;
}
else if (item instanceof ItemArmor armor) else if (item instanceof ItemArmor armor)
{ {
return (this == ARMOR && armor.getArmorType().isMainArmor()) || armor.getArmorType().getEnchantmentType() == this; return (this == ARMOR && armor.getArmorType().isMainArmor()) || armor.getArmorType().getEnchantmentType() == this;

View file

@ -7,7 +7,6 @@ import common.entity.EntityType;
import common.entity.npc.Alignment; import common.entity.npc.Alignment;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.tags.TagObject; import common.tags.TagObject;
import common.util.LocalPos; import common.util.LocalPos;
import common.util.ExtMath; import common.util.ExtMath;

View file

@ -21,7 +21,6 @@ import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.entity.types.EntityTameable; import common.entity.types.EntityTameable;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.consumable.ItemFishFood; import common.item.consumable.ItemFishFood;

View file

@ -12,7 +12,6 @@ import common.entity.npc.EntityNPC;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.pathfinding.PathNavigateGround; import common.pathfinding.PathNavigateGround;

View file

@ -15,7 +15,6 @@ import common.entity.npc.Alignment;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.pathfinding.PathNavigateGround; import common.pathfinding.PathNavigateGround;

View file

@ -10,7 +10,6 @@ import common.ai.EntityAIRunAroundLikeCrazy;
import common.ai.EntityAISwimming; import common.ai.EntityAISwimming;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.block.Block;
import common.collect.Lists; import common.collect.Lists;
import common.effect.Effect; import common.effect.Effect;
import common.entity.DamageSource; import common.entity.DamageSource;

View file

@ -10,13 +10,11 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.block.Block;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.ItemStack; import common.item.ItemStack;
import common.util.LocalPos; import common.util.LocalPos;
import common.world.World; import common.world.World;

View file

@ -13,7 +13,6 @@ import common.entity.npc.EntityNPC;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.pathfinding.PathNavigateGround; import common.pathfinding.PathNavigateGround;

View file

@ -28,7 +28,6 @@ import common.entity.types.EntityLiving;
import common.init.BlockRegistry; import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.pathfinding.PathEntity; import common.pathfinding.PathEntity;

View file

@ -172,7 +172,6 @@ public class EntitySheep extends EntityAnimal
} }
} }
itemstack.damage(1, player);
this.playSound(SoundEvent.POP, 0.25F); this.playSound(SoundEvent.POP, 0.25F);
} }

View file

@ -23,7 +23,6 @@ import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.entity.types.EntityTameable; import common.entity.types.EntityTameable;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.consumable.ItemFood; import common.item.consumable.ItemFood;

View file

@ -219,10 +219,6 @@ public class EntityItem extends Entity
{ {
return other.combineItems(this); return other.combineItems(this);
} }
else if (otherStack.getSize() + stack.getSize() > otherStack.getMaxStackSize())
{
return false;
}
else else
{ {
otherStack.incrSize(stack.getSize()); otherStack.incrSize(stack.getSize());
@ -431,7 +427,7 @@ public class EntityItem extends Entity
public String getName() public String getName()
{ {
ItemStack stack = this.getEntityItem(); ItemStack stack = this.getEntityItem();
return this.getTypeName() + " (" + (stack.isStacked() ? stack.getSize() + " * " : "") + stack.getItem().getDisplay() + ")"; return this.getTypeName() + " (" + (stack.getSize() > 1 ? stack.getSize() + " * " : "") + stack.getItem().getDisplay() + ")";
} }
/** /**
@ -577,7 +573,7 @@ public class EntityItem extends Entity
public String getLabel() public String getLabel()
{ {
ItemStack stack = this.getEntityItem(); ItemStack stack = this.getEntityItem();
if(!stack.isStacked()) if(stack.getSize() <= 1)
return null; return null;
return Color.DARK_GREEN + "" + stack.getSize(); return Color.DARK_GREEN + "" + stack.getSize();
} }

View file

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

View file

@ -1313,7 +1313,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
accept = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old); accept = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old);
} }
else { else {
accept = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted(); accept = stack.isItemEnchanted() && !old.isItemEnchanted();
} }
} }
else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) { else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) {
@ -1340,7 +1340,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
accept = itemarmor.getArmorValue() > itemarmor1.getArmorValue(); accept = itemarmor.getArmorValue() > itemarmor1.getArmorValue();
} }
else { else {
accept = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted(); accept = stack.isItemEnchanted() && !old.isItemEnchanted();
} }
} }
else { else {
@ -2566,7 +2566,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
{ {
for (int i = 0; i < Equipment.INVENTORY_SLOTS; ++i) for (int i = 0; i < Equipment.INVENTORY_SLOTS; ++i)
{ {
if (this.getInventory()[i] != null && this.getInventory()[i].getItem() == itemStackIn.getItem() && this.getInventory()[i].isStackable() && !this.getInventory()[i].isFull() && ItemStack.dataEquals(this.getInventory()[i], itemStackIn)) if (this.getInventory()[i] != null && this.getInventory()[i].getItem() == itemStackIn.getItem() && ItemStack.dataEquals(this.getInventory()[i], itemStackIn))
{ {
return i; return i;
} }
@ -2614,11 +2614,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
int k = i; int k = i;
if (i > this.getInventory()[j].getMaxStackSize() - this.getInventory()[j].getSize())
{
k = this.getInventory()[j].getMaxStackSize() - this.getInventory()[j].getSize();
}
if (k == 0) if (k == 0)
{ {
return i; return i;
@ -2661,38 +2656,20 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
{ {
if (itemStackIn != null && !itemStackIn.isEmpty() && itemStackIn.getItem() != null) if (itemStackIn != null && !itemStackIn.isEmpty() && itemStackIn.getItem() != null)
{ {
if (itemStackIn.isItemDamaged()) int i;
{
int j = this.getFirstEmptyStack();
if (j >= 0) while (true)
{
i = itemStackIn.getSize();
itemStackIn.setSize(this.storePartialItemStack(itemStackIn));
if (itemStackIn.isEmpty() || itemStackIn.getSize() >= i)
{ {
this.getInventory()[j] = ItemStack.copy(itemStackIn); break;
itemStackIn.setSize(0);
return true;
}
else
{
return false;
} }
} }
else
{
int i;
while (true) return itemStackIn.getSize() < i;
{
i = itemStackIn.getSize();
itemStackIn.setSize(this.storePartialItemStack(itemStackIn));
if (itemStackIn.isEmpty() || itemStackIn.getSize() >= i)
{
break;
}
}
return itemStackIn.getSize() < i;
}
} }
else else
{ {
@ -2715,8 +2692,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
if (ItemStack.itemEquals(itemstack1, itemstack)) if (ItemStack.itemEquals(itemstack1, itemstack))
{ {
int j = itemstack1.getMaxStackSize(); int k = itemstack.getSize();
int k = Math.min(itemstack.getSize(), j - itemstack1.getSize());
if (k > 0) if (k > 0)
{ {
@ -3445,25 +3421,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
} }
} }
protected void damageArmor(int damage)
{
if(this.isPlayer() || this.dummy) {
damage = damage / 4;
if (damage < 1)
damage = 1;
for (Equipment slot : Equipment.ARMOR)
{
ItemStack stack = this.getArmor(slot);
if (stack != null && stack.getItem() instanceof ItemArmor && stack.isItemStackDamageable())
{
stack.damage(damage, this);
if (stack.isEmpty())
this.setArmor(slot, null);
}
}
}
}
public int getTotalArmorValue() public int getTotalArmorValue()
{ {
int value = 0; int value = 0;

View file

@ -6,16 +6,16 @@ import common.rng.WeightedList;
public abstract class FishConstants { public abstract class FishConstants {
public static final WeightedList<RngFishable> FISHING_JUNK = new WeightedList<RngFishable>( public static final WeightedList<RngFishable> FISHING_JUNK = new WeightedList<RngFishable>(
(new RngFishable(new ItemStack(Items.leather_boots), 10)).setMaxDamagePercent(0.9F), new RngFishable(new ItemStack(Items.leather), 10), (new RngFishable(new ItemStack(Items.leather_boots), 10)), new RngFishable(new ItemStack(Items.leather), 10),
new RngFishable(new ItemStack(Items.bone), 10), new RngFishable(new ItemStack(Items.water_bottle), 10), new RngFishable(new ItemStack(Items.bone), 10), new RngFishable(new ItemStack(Items.water_bottle), 10),
new RngFishable(new ItemStack(Items.string), 5), (new RngFishable(new ItemStack(Items.fishing_rod), 2)).setMaxDamagePercent(0.9F), new RngFishable(new ItemStack(Items.string), 5), (new RngFishable(new ItemStack(Items.fishing_rod), 2)),
new RngFishable(new ItemStack(Items.stick), 5), new RngFishable(new ItemStack(Items.ink_sack, 10), 1), new RngFishable(new ItemStack(Items.stick), 5), new RngFishable(new ItemStack(Items.ink_sack, 10), 1),
new RngFishable(new ItemStack(Items.hook), 10), new RngFishable(new ItemStack(Items.rotten_flesh), 10)); new RngFishable(new ItemStack(Items.hook), 10), new RngFishable(new ItemStack(Items.rotten_flesh), 10));
public static final WeightedList<RngFishable> FISHING_TREASURE = new WeightedList<RngFishable>( public static final WeightedList<RngFishable> FISHING_TREASURE = new WeightedList<RngFishable>(
new RngFishable(new ItemStack(Items.waterlily), 1), new RngFishable(new ItemStack(Items.name_tag), 1), new RngFishable(new ItemStack(Items.waterlily), 1), new RngFishable(new ItemStack(Items.name_tag), 1),
new RngFishable(new ItemStack(Items.saddle), 1), new RngFishable(new ItemStack(Items.saddle), 1),
(new RngFishable(new ItemStack(Items.bow), 1)).setMaxDamagePercent(0.25F).setEnchantable(), (new RngFishable(new ItemStack(Items.bow), 1)).setEnchantable(),
(new RngFishable(new ItemStack(Items.fishing_rod), 1)).setMaxDamagePercent(0.25F).setEnchantable(), (new RngFishable(new ItemStack(Items.fishing_rod), 1)).setEnchantable(),
(new RngFishable(new ItemStack(Items.book), 1)).setEnchantable()); (new RngFishable(new ItemStack(Items.book), 1)).setEnchantable());
public static final WeightedList<RngFishable> FISH_TYPES = new WeightedList<RngFishable>( public static final WeightedList<RngFishable> FISH_TYPES = new WeightedList<RngFishable>(
new RngFishable(new ItemStack(Items.cod), 60), new RngFishable(new ItemStack(Items.cod), 60),

View file

@ -8,7 +8,6 @@ import common.rng.RngItem;
public class RngFishable extends RngItem public class RngFishable extends RngItem
{ {
private final ItemStack returnStack; private final ItemStack returnStack;
private float maxDamagePercent;
private boolean enchantable; private boolean enchantable;
public RngFishable(ItemStack returnStackIn, int itemWeightIn) public RngFishable(ItemStack returnStackIn, int itemWeightIn)
@ -21,24 +20,6 @@ public class RngFishable extends RngItem
{ {
ItemStack itemstack = this.returnStack.copy(); ItemStack itemstack = this.returnStack.copy();
if (this.maxDamagePercent > 0.0F)
{
int i = (int)(this.maxDamagePercent * (float)this.returnStack.getMaxDamage());
int j = itemstack.getMaxDamage() - random.zrange(random.zrange(i) + 1);
if (j > i)
{
j = i;
}
if (j < 1)
{
j = 1;
}
itemstack.setItemDamage(j);
}
if (this.enchantable) if (this.enchantable)
{ {
EnchantmentHelper.addRandomEnchantment(random, itemstack, 30); EnchantmentHelper.addRandomEnchantment(random, itemstack, 30);
@ -47,12 +28,6 @@ public class RngFishable extends RngItem
return itemstack; return itemstack;
} }
public RngFishable setMaxDamagePercent(float maxDamagePercentIn)
{
this.maxDamagePercent = maxDamagePercentIn;
return this;
}
public RngFishable setEnchantable() public RngFishable setEnchantable()
{ {
this.enchantable = true; this.enchantable = true;

View file

@ -33,7 +33,6 @@ import common.entity.projectile.EntityArrow;
import common.init.BlockRegistry; import common.init.BlockRegistry;
import common.init.Blocks; import common.init.Blocks;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.ItemRegistry;
import common.init.Items; import common.init.Items;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.item.Item; import common.item.Item;
@ -51,7 +50,6 @@ import common.util.LocalPos;
import common.util.BoundingBox; import common.util.BoundingBox;
import common.util.Clientside; import common.util.Clientside;
import common.util.ExtMath; import common.util.ExtMath;
import common.util.Equipment;
import common.util.ParticleType; import common.util.ParticleType;
import common.util.Serverside; import common.util.Serverside;
import common.util.Color; import common.util.Color;
@ -871,12 +869,6 @@ public abstract class EntityLiving extends Entity
} }
else else
{ {
if (this instanceof EntityNPC npc && (source == DamageSource.anvil || source == DamageSource.fallingBlock) && npc.getArmor(Equipment.HELMET) != null)
{
npc.getArmor(Equipment.HELMET).damage((int)(amount * 4.0F + this.rand.floatv() * (float)amount * 2.0F), this);
amount = (int)((float)amount * 0.75F);
}
this.lswingAmount = 1.5F; this.lswingAmount = 1.5F;
boolean flag = true; boolean flag = true;
@ -980,27 +972,6 @@ public abstract class EntityLiving extends Entity
} }
} }
/**
* Renders broken item particles using the given ItemStack
*/
public void renderBrokenItemStack(ItemStack stack)
{
this.playSound(SoundEvent.BREAK, 0.8F);
for (int i = 0; i < 5; ++i)
{
Vec3 vec3 = new Vec3(((double)this.rand.floatv() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3 = vec3.pitch(-this.rotPitch * (float)Math.PI / 180.0F);
vec3 = vec3.yaw(-this.rotYaw * (float)Math.PI / 180.0F);
double d0 = (double)(-this.rand.floatv()) * 0.6D - 0.3D;
Vec3 vec31 = new Vec3(((double)this.rand.floatv() - 0.5D) * 0.3D, d0, 0.6D);
vec31 = vec31.pitch(-this.rotPitch * (float)Math.PI / 180.0F);
vec31 = vec31.yaw(-this.rotYaw * (float)Math.PI / 180.0F);
vec31 = vec31.add(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
this.worldObj.clientParticle(ParticleType.ITEM_CRACK, vec31.x, vec31.y, vec31.z, ItemRegistry.getId(stack.getItem()));
}
}
/** /**
* Called when the mob's health reaches 0. * Called when the mob's health reaches 0.
*/ */

View file

@ -329,12 +329,8 @@ public abstract class CraftingRegistry
break; break;
} }
else if(current != null && stack.itemEquals(current) && stack.dataEquals(current)) { else if(current != null && stack.itemEquals(current) && stack.dataEquals(current)) {
int incr = Math.min(amount, current.getMaxStackSize() - current.getSize()); amount = 0;
if(incr > 0) { break;
amount -= incr;
if(amount <= 0)
break;
}
} }
} }
if(amount > 0) if(amount > 0)
@ -392,14 +388,10 @@ public abstract class CraftingRegistry
break; break;
} }
else if(current != null && stack.itemEquals(current) && stack.dataEquals(current)) { else if(current != null && stack.itemEquals(current) && stack.dataEquals(current)) {
int incr = Math.min(amount, current.getMaxStackSize() - current.getSize()); current.incrSize(amount);
if(incr > 0) { output.setInventorySlotContents(z, current);
current.incrSize(incr); amount = 0;
output.setInventorySlotContents(z, current); break;
amount -= incr;
if(amount <= 0)
break;
}
} }
} }
if(amount > 0 && output instanceof EntityNPC entity) if(amount > 0 && output instanceof EntityNPC entity)

View file

@ -139,8 +139,6 @@ public abstract class ItemRegistry {
if(item != null) { if(item != null) {
if(item.getTab() == null || !item.getTab().isBlockTab()) if(item.getTab() == null || !item.getTab().isBlockTab())
throw new IllegalArgumentException("Gegenstand für " + BlockRegistry.getName(block) + " muss einen Block-Tab besitzen"); throw new IllegalArgumentException("Gegenstand für " + BlockRegistry.getName(block) + " muss einen Block-Tab besitzen");
if(item.getMaxAmount() == 1)
throw new IllegalArgumentException("Gegenstand für " + BlockRegistry.getName(block) + " muss stapelbar sein");
ITEMS.add(item); ITEMS.add(item);
ITEM_MAP.put(BlockRegistry.getName(block), item); ITEM_MAP.put(BlockRegistry.getName(block), item);
ITEM_IDS.put(item, ITEMS.size()); ITEM_IDS.put(item, ITEMS.size());
@ -286,11 +284,11 @@ public abstract class ItemRegistry {
register("whip", (new ItemWhip()).setDisplay("Peitsche")); register("whip", (new ItemWhip()).setDisplay("Peitsche"));
register("charge_crystal", (new Item()).setDisplay("Energiekristall").setTab(CheatTab.MATERIALS).setColor(Color.DARK_MAGENTA).setFuelAmount(120000)); register("charge_crystal", (new Item()).setDisplay("Energiekristall").setTab(CheatTab.MATERIALS).setColor(Color.DARK_MAGENTA).setFuelAmount(120000));
for(Enchantment ench : Enchantment.values()) { for(Enchantment ench : Enchantment.values()) {
register("enchanted_book_" + ench.getName(), (new ItemEnchantedBook(ench, 1)).setUnstackable().setDisplay("Verzaubertes Buch mit " + ench.getFormattedName(1)).setTab(CheatTab.ENCHANTMENTS)); register("enchanted_book_" + ench.getName(), (new ItemEnchantedBook(ench, 1)).setDisplay("Verzaubertes Buch mit " + ench.getFormattedName(1)).setTab(CheatTab.ENCHANTMENTS));
int max = ench.getMaxLevel(); int max = ench.getMaxLevel();
for(int level = 2; level <= max; level++) { for(int level = 2; level <= max; level++) {
if((level % 2 == 1 || level == max) && (level != max - 1)) if((level % 2 == 1 || level == max) && (level != max - 1))
register("enchanted_book_" + ench.getName() + "_" + level, (new ItemEnchantedBook(ench, level)).setUnstackable().setDisplay("Verzaubertes Buch mit " + ench.getFormattedName(level)).setTab(CheatTab.ENCHANTMENTS)); register("enchanted_book_" + ench.getName() + "_" + level, (new ItemEnchantedBook(ench, level)).setDisplay("Verzaubertes Buch mit " + ench.getFormattedName(level)).setTab(CheatTab.ENCHANTMENTS));
} }
} }
register("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS)); register("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS));

View file

@ -858,8 +858,6 @@ public abstract class Items {
public static final ItemEnchantedBook enchanted_book_silk_touch = get("enchanted_book_silk_touch"); public static final ItemEnchantedBook enchanted_book_silk_touch = get("enchanted_book_silk_touch");
public static final ItemEnchantedBook enchanted_book_thorns = get("enchanted_book_thorns"); public static final ItemEnchantedBook enchanted_book_thorns = get("enchanted_book_thorns");
public static final ItemEnchantedBook enchanted_book_thorns_3 = get("enchanted_book_thorns_3"); public static final ItemEnchantedBook enchanted_book_thorns_3 = get("enchanted_book_thorns_3");
public static final ItemEnchantedBook enchanted_book_unbreaking = get("enchanted_book_unbreaking");
public static final ItemEnchantedBook enchanted_book_unbreaking_3 = get("enchanted_book_unbreaking_3");
public static final ItemEnchantedBook enchanted_book_vanity = get("enchanted_book_vanity"); public static final ItemEnchantedBook enchanted_book_vanity = get("enchanted_book_vanity");
public static final ItemRocketLauncher rocket_launcher = get("rocket_launcher"); public static final ItemRocketLauncher rocket_launcher = get("rocket_launcher");
public static final ItemAmmo rocket = get("rocket"); public static final ItemAmmo rocket = get("rocket");

View file

@ -8,12 +8,10 @@ import common.util.Equipment;
public class ToolMaterial { public class ToolMaterial {
private final int harvestLevel; private final int harvestLevel;
private final int durability;
private final int damage; private final int damage;
private final float radiationResistance; private final float radiationResistance;
private final float magicResistance; private final float magicResistance;
private final int enchantability; private final int enchantability;
private final int maxDamageFactor;
private final int[] damageReduction; private final int[] damageReduction;
private final int armorEnchantability; private final int armorEnchantability;
private final Set<Item> repair = Sets.newHashSet(); private final Set<Item> repair = Sets.newHashSet();
@ -23,10 +21,8 @@ public class ToolMaterial {
protected ToolMaterial(int level, float rad, float mag, int uses, int d, int damage, int ench, int auses, int aench, int r1, int r2, int r3, int r4) { protected ToolMaterial(int level, float rad, float mag, int uses, int d, int damage, int ench, int auses, int aench, int r1, int r2, int r3, int r4) {
this.harvestLevel = level; this.harvestLevel = level;
this.durability = uses;
this.damage = damage; this.damage = damage;
this.enchantability = ench; this.enchantability = ench;
this.maxDamageFactor = auses;
this.damageReduction = new int[] {r1, r2, r3, r4}; this.damageReduction = new int[] {r1, r2, r3, r4};
this.armorEnchantability = aench; this.armorEnchantability = aench;
this.radiationResistance = rad; this.radiationResistance = rad;
@ -47,10 +43,6 @@ public class ToolMaterial {
this.repair.add(item); this.repair.add(item);
} }
public int getDurability() {
return this.durability;
}
public int getDamage() { public int getDamage() {
return this.damage; return this.damage;
} }
@ -67,10 +59,6 @@ public class ToolMaterial {
return this.repair.contains(item); return this.repair.contains(item);
} }
public int getDurability(Equipment armorType) {
return armorType.getDamage() * this.maxDamageFactor;
}
public float getRadiationReduction(Equipment armorType) { public float getRadiationReduction(Equipment armorType) {
return armorType.getPhysicalResistance() * this.radiationResistance; return armorType.getPhysicalResistance() * this.radiationResistance;
} }

View file

@ -284,11 +284,6 @@ public abstract class Container
i2 = slot7.getItemStackLimit(itemstack10) - itemstack9.getSize(); i2 = slot7.getItemStackLimit(itemstack10) - itemstack9.getSize();
} }
if (i2 > itemstack10.getMaxStackSize() - itemstack9.getSize())
{
i2 = itemstack10.getMaxStackSize() - itemstack9.getSize();
}
itemstack10.split(i2); itemstack10.split(i2);
if (itemstack10.isEmpty()) if (itemstack10.isEmpty())
@ -304,11 +299,11 @@ public abstract class Container
playerIn.setMouseItem(itemstack9); playerIn.setMouseItem(itemstack9);
} }
} }
else if (itemstack9.getItem() == itemstack10.getItem() && itemstack10.getMaxStackSize() > 1 && ItemStack.dataEquals(itemstack9, itemstack10)) else if (itemstack9.getItem() == itemstack10.getItem() && ItemStack.dataEquals(itemstack9, itemstack10))
{ {
int l1 = itemstack9.getSize(); int l1 = itemstack9.getSize();
if (l1 > 0 && l1 + itemstack10.getSize() <= itemstack10.getMaxStackSize()) if (l1 > 0)
{ {
itemstack10.incrSize(l1); itemstack10.incrSize(l1);
itemstack9 = slot7.decrStackSize(l1); itemstack9 = slot7.decrStackSize(l1);
@ -404,15 +399,15 @@ public abstract class Container
int i1 = clickedButton == 0 ? 0 : this.inventorySlots.size() - 1; int i1 = clickedButton == 0 ? 0 : this.inventorySlots.size() - 1;
int j1 = clickedButton == 0 ? 1 : -1; int j1 = clickedButton == 0 ? 1 : -1;
for (int l2 = 0; l2 < 2; ++l2) for (int l2 = 0; l2 < 2; ++l2) //TODO: check if still necessary
{ {
for (int i3 = i1; i3 >= 0 && i3 < this.inventorySlots.size() && !itemstack4.isFull(); i3 += j1) for (int i3 = i1; i3 >= 0 && i3 < this.inventorySlots.size(); 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().isFull())) if (slot8.getHasStack() && canAddItemToSlot(slot8, itemstack4) && slot8.canTakeStack(playerIn) && this.canMergeSlot(itemstack4, slot8))
{ {
int l = Math.min(itemstack4.getMaxStackSize() - itemstack4.getSize(), slot8.getStack().getSize()); int l = slot8.getStack().getSize();
ItemStack itemstack2 = slot8.decrStackSize(l); ItemStack itemstack2 = slot8.decrStackSize(l);
itemstack4.incrSize(l); itemstack4.incrSize(l);
@ -603,35 +598,22 @@ public abstract class Container
boolean flag = false; boolean flag = false;
int i = startIndex; int i = startIndex;
if (stack.isStackable()) while (!stack.isEmpty() && i < endIndex)
{ {
while (!stack.isEmpty() && i < endIndex) Slot slot = (Slot)this.inventorySlots.get(i);
ItemStack itemstack = slot.getStack();
if (itemstack != null && itemstack.getItem() == stack.getItem() && ItemStack.dataEquals(stack, itemstack))
{ {
Slot slot = (Slot)this.inventorySlots.get(i); int j = itemstack.getSize() + stack.getSize();
ItemStack itemstack = slot.getStack();
if (itemstack != null && itemstack.getItem() == stack.getItem() && ItemStack.dataEquals(stack, itemstack)) stack.setSize(0);
{ itemstack.setSize(j);
int j = itemstack.getSize() + stack.getSize(); slot.onSlotChanged();
flag = true;
if (j <= stack.getMaxStackSize())
{
stack.setSize(0);
itemstack.setSize(j);
slot.onSlotChanged();
flag = true;
}
else if (itemstack.getSize() < stack.getMaxStackSize())
{
stack.decrSize(stack.getMaxStackSize() - itemstack.getSize());
itemstack.setSize(stack.getMaxStackSize());
slot.onSlotChanged();
flag = true;
}
}
++i;
} }
++i;
} }
if (!stack.isEmpty()) if (!stack.isEmpty())
@ -663,16 +645,13 @@ public abstract class Container
return true; return true;
} }
/** public static boolean canAddItemToSlot(Slot slotIn, ItemStack stack)
* Checks if it's possible to add the given itemstack to the given slot.
*/
public static boolean canAddItemToSlot(Slot slotIn, ItemStack stack, boolean stackSizeMatters)
{ {
boolean flag = slotIn == null || !slotIn.getHasStack(); boolean flag = slotIn == null || !slotIn.getHasStack();
if (slotIn != null && slotIn.getHasStack() && stack != null && stack.itemEquals(slotIn.getStack()) && ItemStack.dataEquals(slotIn.getStack(), stack)) if (slotIn != null && slotIn.getHasStack() && stack != null && stack.itemEquals(slotIn.getStack()) && ItemStack.dataEquals(slotIn.getStack(), stack))
{ {
flag |= slotIn.getStack().getSize() + (stackSizeMatters ? 0 : stack.getSize()) <= stack.getMaxStackSize(); flag = true;
} }
return flag; return flag;

View file

@ -129,7 +129,7 @@ public class ContainerEnchantment extends Container
{ {
ItemStack itemstack = inventoryIn.getStackInSlot(0); ItemStack itemstack = inventoryIn.getStackInSlot(0);
if (itemstack != null && itemstack.isItemEnchantable()) if (itemstack != null && itemstack.getSize() == 1 && !itemstack.isItemEnchanted())
{ {
if (!this.world.client) if (!this.world.client)
{ {

View file

@ -22,6 +22,10 @@ public class ContainerEntityInventory extends Container
final EntityHorse horse = (EntityHorse)this.entity; final EntityHorse horse = (EntityHorse)this.entity;
this.addSlotToContainer(new Slot(entityInv, 0, false) this.addSlotToContainer(new Slot(entityInv, 0, false)
{ {
public boolean canStackItems() {
return false;
}
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack)
{ {
return super.isItemValid(stack) && stack.getItem() == Items.saddle && !this.getHasStack(); return super.isItemValid(stack) && stack.getItem() == Items.saddle && !this.getHasStack();
@ -29,6 +33,10 @@ public class ContainerEntityInventory extends Container
}); });
this.addSlotToContainer(new Slot(entityInv, 1, false) this.addSlotToContainer(new Slot(entityInv, 1, false)
{ {
public boolean canStackItems() {
return false;
}
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack)
{ {
return super.isItemValid(stack) && horse.canWearArmor() && EntityHorse.isArmorItem(stack.getItem()); return super.isItemValid(stack) && horse.canWearArmor() && EntityHorse.isArmorItem(stack.getItem());

View file

@ -15,7 +15,7 @@ import common.vars.Vars;
import common.world.State; import common.world.State;
import common.world.World; import common.world.World;
public class ContainerRepair extends Container public class ContainerMagicCombiner extends Container
{ {
private class InventoryCraftResult implements IInventory private class InventoryCraftResult implements IInventory
{ {
@ -96,12 +96,12 @@ public class ContainerRepair extends Container
public int maximumCost; public int maximumCost;
private int materialCost; private int materialCost;
public ContainerRepair(EntityNPC playerInventory, World worldIn) public ContainerMagicCombiner(EntityNPC playerInventory, World worldIn)
{ {
this(playerInventory, worldIn, LocalPos.ORIGIN); this(playerInventory, worldIn, LocalPos.ORIGIN);
} }
public ContainerRepair(EntityNPC playerInventory, final World worldIn, final LocalPos blockPosIn) public ContainerMagicCombiner(EntityNPC playerInventory, final World worldIn, final LocalPos blockPosIn)
{ {
this.outputSlot = new InventoryCraftResult(); this.outputSlot = new InventoryCraftResult();
this.inputSlots = new InventoryBasic(2) this.inputSlots = new InventoryBasic(2)
@ -109,17 +109,25 @@ public class ContainerRepair extends Container
public void markDirty() public void markDirty()
{ {
super.markDirty(); super.markDirty();
ContainerRepair.this.onChanged(this); ContainerMagicCombiner.this.onChanged();
} }
}; };
this.selfPosition = blockPosIn; this.selfPosition = blockPosIn;
this.theWorld = worldIn; this.theWorld = worldIn;
this.addSlotToContainer(new Slot(this.inputSlots, 0, false) { this.addSlotToContainer(new Slot(this.inputSlots, 0, false) {
public boolean canStackItems() {
return false;
}
public boolean canEditItem() { public boolean canEditItem() {
return false; return false;
} }
}); });
this.addSlotToContainer(new Slot(this.inputSlots, 1, false) { this.addSlotToContainer(new Slot(this.inputSlots, 1, false) {
public boolean canStackItems() {
return false;
}
public boolean canEditItem() { public boolean canEditItem() {
return false; return false;
} }
@ -132,38 +140,38 @@ public class ContainerRepair extends Container
} }
public boolean canTakeStack(EntityNPC playerIn) public boolean canTakeStack(EntityNPC playerIn)
{ {
return /* (playerIn.creative || */ playerIn.getManaPoints() >= ContainerRepair.this.maximumCost /* ) */ && ContainerRepair.this.maximumCost > 0 && this.getHasStack(); return /* (playerIn.creative || */ (playerIn.getManaPoints() >= ContainerMagicCombiner.this.maximumCost || !Vars.magicComboMana) /* ) */ && ContainerMagicCombiner.this.maximumCost > 0 && this.getHasStack();
} }
public void onPickupFromSlot(EntityNPC playerIn, ItemStack stack) public void onPickupFromSlot(EntityNPC playerIn, ItemStack stack)
{ {
// if (!playerIn.creative) // if (!playerIn.creative)
// { // {
if(!playerIn.worldObj.client) if(!playerIn.worldObj.client && Vars.magicComboMana)
playerIn.useMana(ContainerRepair.this.maximumCost); playerIn.useMana(ContainerMagicCombiner.this.maximumCost);
// } // }
ContainerRepair.this.inputSlots.setInventorySlotContents(0, (ItemStack)null); ContainerMagicCombiner.this.inputSlots.setInventorySlotContents(0, (ItemStack)null);
if (ContainerRepair.this.materialCost > 0) if (ContainerMagicCombiner.this.materialCost > 0)
{ {
ItemStack itemstack = ContainerRepair.this.inputSlots.getStackInSlot(1); ItemStack itemstack = ContainerMagicCombiner.this.inputSlots.getStackInSlot(1);
if (itemstack != null && itemstack.getSize() > ContainerRepair.this.materialCost) if (itemstack != null && itemstack.getSize() > ContainerMagicCombiner.this.materialCost)
{ {
itemstack.decrSize(ContainerRepair.this.materialCost); itemstack.decrSize(ContainerMagicCombiner.this.materialCost);
ContainerRepair.this.inputSlots.setInventorySlotContents(1, itemstack); ContainerMagicCombiner.this.inputSlots.setInventorySlotContents(1, itemstack);
} }
else else
{ {
ContainerRepair.this.inputSlots.setInventorySlotContents(1, (ItemStack)null); ContainerMagicCombiner.this.inputSlots.setInventorySlotContents(1, (ItemStack)null);
} }
} }
else else
{ {
ContainerRepair.this.inputSlots.setInventorySlotContents(1, (ItemStack)null); ContainerMagicCombiner.this.inputSlots.setInventorySlotContents(1, (ItemStack)null);
} }
ContainerRepair.this.maximumCost = 0; ContainerMagicCombiner.this.maximumCost = 0;
State iblockstate = worldIn.getState(blockPosIn); State iblockstate = worldIn.getState(blockPosIn);
if (/* !playerIn.creative && */ !worldIn.client && Vars.anvilRepairDecay && iblockstate.getBlock() instanceof BlockAnvil anvil && playerIn.getRNG().floatv() < 0.12F) if (/* !playerIn.creative && */ !worldIn.client && Vars.anvilRepairDecay && iblockstate.getBlock() instanceof BlockAnvil anvil && playerIn.getRNG().floatv() < 0.12F)
@ -196,17 +204,9 @@ public class ContainerRepair extends Container
this.addPlayerSlots(playerInventory); this.addPlayerSlots(playerInventory);
} }
private void onChanged(IInventory inventoryIn) private void onChanged()
{ {
this.detectAndSendChanges(); this.detectAndSendChanges();
this.updateRepairOutput();
}
/**
* called when the Anvil Input Slot changes, calculates the new result and puts it in the output slot
*/
public void updateRepairOutput()
{
// int i = 0; // int i = 0;
// int j = 1; // int j = 1;
// int k = 1; // int k = 1;
@ -217,8 +217,6 @@ public class ContainerRepair extends Container
ItemStack stack = this.inputSlots.getStackInSlot(0); ItemStack stack = this.inputSlots.getStackInSlot(0);
this.maximumCost = 1; this.maximumCost = 1;
int totalCost = 0; int totalCost = 0;
int repairCost = 0;
int renameCost = 0;
if (stack == null) if (stack == null)
{ {
@ -231,152 +229,105 @@ public class ContainerRepair extends Container
ItemStack repStack = this.inputSlots.getStackInSlot(1); ItemStack repStack = this.inputSlots.getStackInSlot(1);
Map<Enchantment, Integer> newEnch = EnchantmentHelper.getEnchantments(newStack); Map<Enchantment, Integer> newEnch = EnchantmentHelper.getEnchantments(newStack);
boolean isBook = false; boolean isBook = false;
repairCost = repairCost + stack.getRepairCost() + (repStack == null ? 0 : repStack.getRepairCost());
this.materialCost = 0; this.materialCost = 0;
if (repStack != null) if (repStack != null)
{ {
isBook = repStack.getItem() instanceof ItemEnchantedBook; isBook = repStack.getItem() instanceof ItemEnchantedBook;
if (newStack.isItemStackDamageable() && newStack.getItem().getIsRepairable(stack, repStack)) if (!isBook && (newStack.getItem() != repStack.getItem()))
{ {
int damage = Math.min(newStack.getItemDamage(), newStack.getMaxDamage() / 4); this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
this.maximumCost = 0;
if (damage <= 0) return;
{
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
this.maximumCost = 0;
return;
}
int cost;
for (cost = 0; damage > 0 && cost < repStack.getSize(); ++cost)
{
int j5 = newStack.getItemDamage() - damage;
newStack.setItemDamage(j5);
++totalCost;
damage = Math.min(newStack.getItemDamage(), newStack.getMaxDamage() / 4);
}
this.materialCost = cost;
} }
else
Map<Enchantment, Integer> ench = EnchantmentHelper.getEnchantments(repStack);
Iterator<Enchantment> enchs = ench.keySet().iterator();
while (enchs.hasNext())
{ {
if (!isBook && (newStack.getItem() != repStack.getItem() || !newStack.isItemStackDamageable())) Enchantment enchantment = enchs.next();
{
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
this.maximumCost = 0;
return;
}
if (newStack.isItemStackDamageable() && !isBook) if (enchantment != null)
{ {
int mainDmg = stack.getMaxDamage() - stack.getItemDamage(); int newLevel = newEnch.containsKey(enchantment) ? newEnch.get(enchantment) : 0;
int repDmg = repStack.getMaxDamage() - repStack.getItemDamage(); int level = ench.get(enchantment);
int repair = repDmg + newStack.getMaxDamage() * 12 / 100; int diff;
int newDmg = mainDmg + repair;
int damage = newStack.getMaxDamage() - newDmg;
if (damage < 0) if (newLevel == level)
{ {
damage = 0; ++level;
diff = level;
}
else
{
diff = Math.max(level, newLevel);
} }
if (damage < newStack.getItemDamage()) level = diff;
boolean applies = enchantment.canApply(stack);
if (/* this.thePlayer.creative || */ stack.getItem() instanceof ItemEnchantedBook)
{ {
newStack.setItemDamage(damage); applies = true;
totalCost += 2;
} }
}
Map<Enchantment, Integer> ench = EnchantmentHelper.getEnchantments(repStack); Iterator<Enchantment> newEnchs = newEnch.keySet().iterator();
Iterator<Enchantment> enchs = ench.keySet().iterator();
while (enchs.hasNext()) while (newEnchs.hasNext())
{
Enchantment enchantment = enchs.next();
if (enchantment != null)
{ {
int newLevel = newEnch.containsKey(enchantment) ? newEnch.get(enchantment) : 0; Enchantment nEid = newEnchs.next();
int level = ench.get(enchantment);
int diff;
if (newLevel == level) if (nEid != enchantment && !enchantment.canApplyTogether(nEid))
{ {
++level; applies = false;
diff = level; ++totalCost;
} }
else }
if (applies)
{
if (level > enchantment.getMaxLevel())
{ {
diff = Math.max(level, newLevel); level = enchantment.getMaxLevel();
} }
level = diff; newEnch.put(enchantment, level);
boolean applies = enchantment.canApply(stack); int cost = 0;
if (/* this.thePlayer.creative || */ stack.getItem() instanceof ItemEnchantedBook) switch (enchantment.getWeight())
{ {
applies = true; case 1:
cost = 8;
break;
case 2:
cost = 4;
case 3:
case 4:
case 6:
case 7:
case 8:
case 9:
default:
break;
case 5:
cost = 2;
break;
case 10:
cost = 1;
} }
Iterator<Enchantment> newEnchs = newEnch.keySet().iterator(); if (isBook)
while (newEnchs.hasNext())
{ {
Enchantment nEid = newEnchs.next(); cost = Math.max(1, cost / 2);
if (nEid != enchantment && !enchantment.canApplyTogether(nEid))
{
applies = false;
++totalCost;
}
} }
if (applies) totalCost += cost * level;
{
if (level > enchantment.getMaxLevel())
{
level = enchantment.getMaxLevel();
}
newEnch.put(enchantment, level);
int cost = 0;
switch (enchantment.getWeight())
{
case 1:
cost = 8;
break;
case 2:
cost = 4;
case 3:
case 4:
case 6:
case 7:
case 8:
case 9:
default:
break;
case 5:
cost = 2;
break;
case 10:
cost = 1;
}
if (isBook)
{
cost = Math.max(1, cost / 2);
}
totalCost += cost * level;
}
} }
} }
} }
@ -398,18 +349,13 @@ public class ContainerRepair extends Container
// newStack.setStackDisplayName(this.repairedItemName); // newStack.setStackDisplayName(this.repairedItemName);
// } // }
this.maximumCost = repairCost + totalCost; this.maximumCost = totalCost;
if (totalCost <= 0) if (totalCost <= 0)
{ {
newStack = null; newStack = null;
} }
if (renameCost == totalCost && renameCost > 0 && this.maximumCost >= 40)
{
this.maximumCost = 39;
}
if (/* Config.repairExperience && */ this.maximumCost >= 40) // && !this.thePlayer.creative) if (/* Config.repairExperience && */ this.maximumCost >= 40) // && !this.thePlayer.creative)
{ {
newStack = null; newStack = null;
@ -417,17 +363,6 @@ public class ContainerRepair extends Container
if (newStack != null) if (newStack != null)
{ {
if(!this.theWorld.client && Vars.repairXP) {
int cost = newStack.getRepairCost();
if (repStack != null && cost < repStack.getRepairCost())
{
cost = repStack.getRepairCost();
}
cost = cost * 2 + 1;
newStack.setRepairCost(cost);
}
EnchantmentHelper.setEnchantments(newEnch, newStack); EnchantmentHelper.setEnchantments(newEnch, newStack);
} }
@ -529,42 +464,4 @@ public class ContainerRepair extends Container
return itemstack; return itemstack;
} }
/**
* used by the Anvil GUI to update the Item Name being typed by the player
*/
// public void updateItemName(String newName)
// {
// this.repairedItemName = newName;
//
// if (this.getSlot(2).getHasStack())
// {
// ItemStack itemstack = this.getSlot(2).getStack();
//
// if (isBlank(newName))
// {
// itemstack.clearCustomName();
// }
// else
// {
// itemstack.setStackDisplayName(this.repairedItemName);
// }
// }
//
// this.updateRepairOutput();
// }
// private static boolean isBlank(String s) {
// if(s != null && !s.isEmpty()) {
// for(int i = 0; i < s.length(); ++i) {
// if(!Character.isWhitespace(s.charAt(i))) {
// return false;
// }
// }
// return true;
// }
// else {
// return true;
// }
// }
} }

View file

@ -52,7 +52,7 @@ public class ContainerPlayer extends Container {
return null; return null;
} }
} }
else if(itemstack.getItem() instanceof ItemArmor armor && (idx = this.getFreeSlotFor(playerIn, armor.getArmorType())) >= 0) { else if(itemstack.getItem() instanceof ItemArmor armor && itemstack.getSize() == 1 && (idx = this.getFreeSlotFor(playerIn, armor.getArmorType())) >= 0) {
if(!this.mergeItemStack(itemstack1, idx, idx + 1)) { if(!this.mergeItemStack(itemstack1, idx, idx + 1)) {
return null; return null;
} }

View file

@ -78,9 +78,9 @@ public class Slot
return true; return true;
} }
public int getItemStackLimit(ItemStack stack) public final int getItemStackLimit(ItemStack stack)
{ {
return this.canStackItems() ? 1000000000 : 1; return this.canStackItems() ? Integer.MAX_VALUE : 1;
} }
public ItemStack decrStackSize(int amount) public ItemStack decrStackSize(int amount)

View file

@ -99,7 +99,7 @@ public enum CheatTab {
}, },
ENCHANTMENTS("Verzauberungen", false) { ENCHANTMENTS("Verzauberungen", false) {
protected Item getIconItem() { protected Item getIconItem() {
return Items.enchanted_book_unbreaking; return Items.enchanted_book_protection;
} }
}, },
MAGIC("Magie", false) { MAGIC("Magie", false) {

View file

@ -25,9 +25,7 @@ import common.world.World;
public class Item { public class Item {
private final Block block; private final Block block;
private boolean stackable = true;
private int weight = ItemWeight.M.getWeight(); private int weight = ItemWeight.M.getWeight();
private int maxDamage = 0;
private Item containerItem; private Item containerItem;
private String display; private String display;
private String[] description; private String[] description;
@ -59,12 +57,6 @@ public class Item {
this.setFuelAmount(this.block.getFuelAmount()); this.setFuelAmount(this.block.getFuelAmount());
} }
public final Item setUnstackable() {
this.stackable = false;
this.maxDamage = 0;
return this;
}
public final Item setWeight(int weight) { public final Item setWeight(int weight) {
this.weight = weight; this.weight = weight;
return this; return this;
@ -74,12 +66,6 @@ public class Item {
return this.setWeight(size.getWeight()); return this.setWeight(size.getWeight());
} }
public final Item setMaxDamage(int max) {
this.stackable = false;
this.maxDamage = max;
return this;
}
public final Item setDisplay(String name) { public final Item setDisplay(String name) {
this.display = name; this.display = name;
return this; return this;
@ -135,18 +121,6 @@ public class Item {
return this.weight; return this.weight;
} }
public final int getMaxAmount() {
return this.stackable ? 67108864 : 1;
}
public final int getMaxDamage() {
return this.maxDamage;
}
public final boolean isDamageable() {
return this.maxDamage > 0;
}
public final int getFuelAmount() { public final int getFuelAmount() {
return this.fuelAmount; return this.fuelAmount;
} }
@ -241,12 +215,10 @@ public class Item {
return stack; return stack;
} }
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { public void hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) {
return false;
} }
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, LocalPos pos, EntityLiving playerIn) { public void onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, LocalPos pos, EntityLiving playerIn) {
return false;
} }
public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target) { public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target) {
@ -264,10 +236,6 @@ public class Item {
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft) { public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft) {
} }
public boolean canEnchant(ItemStack stack) {
return this.getMaxAmount() == 1 && this.isDamageable();
}
public int getItemEnchantability() { public int getItemEnchantability() {
return 0; return 0;
} }

View file

@ -8,52 +8,27 @@ import java.util.Set;
import common.collect.Lists; import common.collect.Lists;
import common.collect.Maps; import common.collect.Maps;
import common.enchantment.Enchantment; import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper;
import common.entity.npc.Attribute; import common.entity.npc.Attribute;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.item.material.ItemArmor; import common.item.material.ItemArmor;
import common.item.weapon.ItemBow;
import common.rng.Random;
import common.tags.TagObject; import common.tags.TagObject;
import common.util.Color; import common.util.Color;
import common.util.Equipment; import common.util.Equipment;
public final class ItemStack { public final class ItemStack {
public class ItemKey {
public ItemStack getStack() {
return ItemStack.this;
}
public int hashCode() {
return ItemStack.this.item.hashCode();
}
public boolean equals(Object other) {
if(other == this)
return true;
if(other instanceof ItemKey key)
return ItemStack.this == key.getStack() || (ItemStack.this.isStackable() && key.getStack().isStackable() && ItemStack.this.itemEquals(key.getStack()) && ItemStack.this.dataEquals(key.getStack()));
return false;
}
}
private Item item; private Item item;
private int size; private int size;
private String name; private String name;
private int color = 0xffffffff; private int color = 0xffffffff;
private int damage;
private int repairCost;
private Map<Enchantment, Integer> enchantments; private Map<Enchantment, Integer> enchantments;
private ItemKey key;
public static ItemStack readFromTag(TagObject tag) { 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, size);
stack.readTags(tag); stack.readTags(tag);
return stack; return stack;
} }
@ -90,10 +65,6 @@ public final class ItemStack {
tag.setInt("size", this.size); tag.setInt("size", this.size);
if(this.color != 0xffffffff) if(this.color != 0xffffffff)
tag.setInt("color", this.color); tag.setInt("color", this.color);
if(this.damage != 0)
tag.setInt("dmg", this.damage);
if(this.repairCost != 0)
tag.setInt("cost", this.repairCost);
if(this.name != null) if(this.name != null)
tag.setString("name", this.name); tag.setString("name", this.name);
if(this.enchantments != null) { if(this.enchantments != null) {
@ -113,8 +84,6 @@ public final class ItemStack {
public void readTags(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.repairCost = tag.hasInt("cost") ? Math.max(0, tag.getInt("cost")) : 0;
this.name = tag.hasString("name") ? tag.getString("name") : null; this.name = tag.hasString("name") ? tag.getString("name") : null;
this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name; this.name = this.name != null && this.name.length() > 32 ? this.name.substring(0, 32) : this.name;
this.enchantments = tag.hasList("ench") ? Maps.newEnumMap(Enchantment.class) : null; this.enchantments = tag.hasList("ench") ? Maps.newEnumMap(Enchantment.class) : null;
@ -138,7 +107,7 @@ public final class ItemStack {
} }
public boolean dataEquals(ItemStack other) { public boolean dataEquals(ItemStack other) {
if(this.color != other.color || this.damage != other.damage || this.repairCost != other.repairCost if(this.color != other.color
|| (this.name != null) != (other.name != null) || (this.name != null && !this.name.equals(other.name)) || (this.name != null) != (other.name != null) || (this.name != null && !this.name.equals(other.name))
|| (this.enchantments != null) != (other.enchantments != null) || (this.enchantments != null) != (other.enchantments != null)
|| (this.enchantments != null && this.enchantments.size() != other.enchantments.size())) || (this.enchantments != null && this.enchantments.size() != other.enchantments.size()))
@ -158,8 +127,6 @@ public final class ItemStack {
public void copyData(ItemStack stack) { public void copyData(ItemStack stack) {
this.color = stack.color; this.color = stack.color;
this.damage = stack.damage;
this.repairCost = stack.repairCost;
this.name = stack.name; this.name = stack.name;
this.enchantments = stack.enchantments == null ? null : Maps.newEnumMap(Enchantment.class); this.enchantments = stack.enchantments == null ? null : Maps.newEnumMap(Enchantment.class);
if(this.enchantments != null) if(this.enchantments != null)
@ -198,38 +165,6 @@ public final class ItemStack {
return this.size <= 0; 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() { public int getMaxItemUseDuration() {
return this.item.getMaxItemUseDuration(this); return this.item.getMaxItemUseDuration(this);
} }
@ -238,10 +173,6 @@ public final class ItemStack {
return this.item.getItemUseAction(); return this.item.getItemUseAction();
} }
public int getItemDamage() {
return this.isItemStackDamageable() ? this.damage : 0;
}
public String getDisplayName() { public String getDisplayName() {
return this.name != null ? this.name : this.item.getDisplay(); return this.name != null ? this.name : this.item.getDisplay();
} }
@ -262,10 +193,6 @@ public final class ItemStack {
return this.item.getColor(this); return this.item.getColor(this);
} }
public boolean isItemEnchantable() {
return !this.item.canEnchant(this) ? false : !this.isItemEnchanted();
}
public Set<Entry<Enchantment, Integer>> getEnchantments() { public Set<Entry<Enchantment, Integer>> getEnchantments() {
return this.enchantments == null ? null : this.enchantments.entrySet(); return this.enchantments == null ? null : this.enchantments.entrySet();
} }
@ -278,10 +205,6 @@ public final class ItemStack {
return this.enchantments != null; return this.enchantments != null;
} }
public int getRepairCost() {
return this.repairCost;
}
public Map<Attribute, Float> getAttributeModifiers() { public Map<Attribute, Float> getAttributeModifiers() {
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class); Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class);
this.item.getModifiers(map); this.item.getModifiers(map);
@ -312,12 +235,6 @@ public final class ItemStack {
} }
public void setItemDamage(int damage) {
if(!this.isItemStackDamageable())
return;
this.damage = Math.max(0, damage);
}
public void setStackDisplayName(String displayName) { 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;
@ -361,10 +278,6 @@ public final class ItemStack {
this.enchantments.putAll(enchMap); this.enchantments.putAll(enchMap);
} }
public void setRepairCost(int cost) {
this.repairCost = Math.max(0, cost);
}
public void setItem(Item newItem) { public void setItem(Item newItem) {
this.item = newItem; this.item = newItem;
} }
@ -393,46 +306,11 @@ public final class ItemStack {
return (this.size = Math.max(this.size - amount, 0)) <= 0; return (this.size = Math.max(this.size - amount, 0)) <= 0;
} }
public boolean incrSize() { public void incrSize() {
return (this.size += 1) >= this.getMaxStackSize(); this.size += 1;
} }
public boolean incrSize(int amount) { public void incrSize(int amount) {
return (this.size += amount) >= this.getMaxStackSize(); this.size += amount;
}
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).clearHeldItem();
this.setItemDamage(0);
}
}
public void damage(int amount, EntityLiving entity) {
this.damage(amount, entity, entity.getRNG());
}
public ItemKey getKey() {
if(this.key == null)
this.key = new ItemKey();
return this.key;
} }
} }

View file

@ -42,17 +42,7 @@ public class RngLoot extends RngItem
RngLoot loot = (RngLoot)list.pick(random); RngLoot loot = (RngLoot)list.pick(random);
int j = loot.minStackSize + random.zrange(loot.maxStackSize - loot.minStackSize + 1); int j = loot.minStackSize + random.zrange(loot.maxStackSize - loot.minStackSize + 1);
if (loot.item.getMaxStackSize() >= j) inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(j));
{
inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(j));
}
else
{
for (int k = 0; k < j; ++k)
{
inv.setInventorySlotContents(random.zrange(inv.getSizeInventory()), loot.item.copy(1));
}
}
} }
} }

View file

@ -14,7 +14,6 @@ import common.world.World;
public class ItemMilkBottle extends Item { public class ItemMilkBottle extends Item {
public ItemMilkBottle() { public ItemMilkBottle() {
this.setUnstackable();
this.setTab(CheatTab.FOOD); this.setTab(CheatTab.FOOD);
this.setMagnetic(); this.setMagnetic();
} }

View file

@ -12,7 +12,6 @@ import common.init.Items;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item; import common.item.Item;
import common.item.ItemAction;
import common.item.ItemControl; import common.item.ItemControl;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.ItemCategory; import common.item.ItemCategory;

View file

@ -21,7 +21,6 @@ public class ItemAnimalArmor extends Item {
this.material = material; this.material = material;
this.texture = texture; this.texture = texture;
this.type = type; this.type = type;
this.setUnstackable();
this.setTab(CheatTab.ARMOR); this.setTab(CheatTab.ARMOR);
if(this.material.isMagnetic()) if(this.material.isMagnetic())
this.setMagnetic(); this.setMagnetic();

View file

@ -31,11 +31,6 @@ public class ItemArmor extends Item {
this.material = material; this.material = material;
this.texture = texture; this.texture = texture;
this.type = armorType; this.type = armorType;
int dmg = material.getDurability(armorType);
if(dmg <= 0)
this.setUnstackable();
else
this.setMaxDamage(dmg);
this.setTab(CheatTab.ARMOR); this.setTab(CheatTab.ARMOR);
if(this.material.canBeDyed()) if(this.material.canBeDyed())
this.setDefaultColor(this.material.getDefaultColor()); this.setDefaultColor(this.material.getDefaultColor());
@ -67,7 +62,7 @@ public class ItemArmor extends Item {
} }
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(toRepair, repair); return this.material.isRepairItem(repair.getItem());
} }
/* /*

View file

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

View file

@ -115,13 +115,10 @@ public class ItemBucket extends Item
public ItemBucket(BlockDynamicLiquid liquid, boolean recursive) public ItemBucket(BlockDynamicLiquid liquid, boolean recursive)
{ {
if(liquid != null) { if(liquid != null)
this.setUnstackable();
this.setDisplay((recursive ? "Flutender " : "") + "Eimer mit " + liquid.getDisplay(), liquid.getDescription()); this.setDisplay((recursive ? "Flutender " : "") + "Eimer mit " + liquid.getDisplay(), liquid.getDescription());
} else
else {
this.setDisplay((recursive ? "Unendlicher " : "") + "Eimer"); this.setDisplay((recursive ? "Unendlicher " : "") + "Eimer");
}
this.liquid = liquid; this.liquid = liquid;
this.recursive = recursive; this.recursive = recursive;
this.setTab(liquid == null ? CheatTab.TOOLS : CheatTab.LIQUIDS); this.setTab(liquid == null ? CheatTab.TOOLS : CheatTab.LIQUIDS);

View file

@ -4,7 +4,6 @@ import common.block.artificial.BlockPortalFrame;
import common.entity.item.EntityOrb; import common.entity.item.EntityOrb;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.Item; import common.item.Item;
@ -22,7 +21,6 @@ public class ItemChargedOrb extends Item
public ItemChargedOrb() public ItemChargedOrb()
{ {
this.setTab(CheatTab.MAGIC); this.setTab(CheatTab.MAGIC);
this.setMaxDamage(16);
this.setColor(Color.DARK_MAGENTA); this.setColor(Color.DARK_MAGENTA);
this.setFragile(); this.setFragile();
} }
@ -37,9 +35,7 @@ public class ItemChargedOrb extends Item
// { // {
// --itemStackIn.stackSize; // --itemStackIn.stackSize;
// } // }
if(itemStackIn.getItemDamage() >= this.getMaxDamage()) itemStackIn.decrSize();
return itemStackIn;
itemStackIn.damage(1, playerIn);
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);
if (!worldIn.client) if (!worldIn.client)
@ -48,14 +44,14 @@ public class ItemChargedOrb extends Item
} }
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
return itemStackIn.getItemDamage() >= this.getMaxDamage() ? new ItemStack(Items.orb) : itemStackIn; return itemStackIn;
} }
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, LocalPos pos, Facing side, float hitX, float hitY, float hitZ) public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, LocalPos pos, Facing side, float hitX, float hitY, float hitZ)
{ {
State iblockstate = worldIn.getState(pos); State iblockstate = worldIn.getState(pos);
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 (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)
{ {

View file

@ -26,7 +26,6 @@ public class ItemBoat extends Item
{ {
public ItemBoat() public ItemBoat()
{ {
this.setUnstackable();
this.setTab(CheatTab.VEHICLES); this.setTab(CheatTab.VEHICLES);
} }

View file

@ -22,7 +22,6 @@ public class ItemMinecart extends Item
{ {
public ItemMinecart() public ItemMinecart()
{ {
this.setUnstackable();
this.setTab(CheatTab.VEHICLES); this.setTab(CheatTab.VEHICLES);
this.setMagnetic(); this.setMagnetic();
} }

View file

@ -11,7 +11,6 @@ import common.world.World;
public class ItemCamera extends Item { public class ItemCamera extends Item {
public ItemCamera() { public ItemCamera() {
this.setUnstackable();
this.setMagnetic(); this.setMagnetic();
} }

View file

@ -11,7 +11,6 @@ import common.world.World;
public class ItemEditor extends Item { public class ItemEditor extends Item {
public ItemEditor() { public ItemEditor() {
this.setUnstackable();
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
} }

View file

@ -26,7 +26,6 @@ public class ItemFire extends Item
public ItemFire(BlockFire fireBlock) public ItemFire(BlockFire fireBlock)
{ {
this.fireBlock = fireBlock; this.fireBlock = fireBlock;
this.setMaxDamage(64);
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
this.setMagnetic(); this.setMagnetic();
} }
@ -58,7 +57,6 @@ public class ItemFire extends Item
worldIn.setState(pos, this.fireBlock.getState()); worldIn.setState(pos, this.fireBlock.getState());
} }
stack.damage(1, playerIn);
return true; return true;
} }
} }
@ -71,7 +69,6 @@ public class ItemFire extends Item
{ {
world.setState(pos, this.fireBlock.getState()); world.setState(pos, this.fireBlock.getState());
stack.damage(1, null, world.rand);
world.playEffect(1000, blockpos, 0); world.playEffect(1000, blockpos, 0);
} }
else if (world.getState(pos).getBlock() instanceof BlockTNT tnt) else if (world.getState(pos).getBlock() instanceof BlockTNT tnt)

View file

@ -15,7 +15,6 @@ public class ItemFishingRod extends Item
{ {
public ItemFishingRod() public ItemFishingRod()
{ {
this.setMaxDamage(64);
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
} }
@ -48,7 +47,6 @@ public class ItemFishingRod extends Item
if (playerIn.fishEntity != null) if (playerIn.fishEntity != null)
{ {
int i = playerIn.fishEntity.handleHookRetraction(); int i = playerIn.fishEntity.handleHookRetraction();
itemStackIn.damage(i, playerIn);
playerIn.swingItem(); playerIn.swingItem();
} }
else else

View file

@ -18,7 +18,6 @@ public class ItemHoe extends Item
{ {
public ItemHoe() public ItemHoe()
{ {
this.setMaxDamage(131);
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
} }
@ -70,7 +69,6 @@ public class ItemHoe extends Item
else else
{ {
worldIn.setState(target, newState); worldIn.setState(target, newState);
stack.damage(1, player);
return true; return true;
} }
} }

View file

@ -20,7 +20,6 @@ public class ItemMagnet extends Item {
public <T extends Entity> ItemMagnet(boolean chicken) { public <T extends Entity> ItemMagnet(boolean chicken) {
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
this.setUnstackable();
this.setMagnetic(); this.setMagnetic();
this.chicken = chicken; this.chicken = chicken;
} }

View file

@ -12,7 +12,6 @@ public class ItemSaddle extends Item
{ {
public ItemSaddle() public ItemSaddle()
{ {
this.setUnstackable();
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
} }
@ -43,14 +42,4 @@ public class ItemSaddle extends Item
return false; return false;
} }
} }
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker)
{
this.itemInteractionForEntity(stack, (EntityNPC)null, target);
return true;
}
} }

View file

@ -19,7 +19,6 @@ public class ItemSpaceNavigator extends Item {
private boolean local = true; private boolean local = true;
public ItemSpaceNavigator() { public ItemSpaceNavigator() {
this.setUnstackable();
this.setColor(Color.DARK_GREEN); this.setColor(Color.DARK_GREEN);
this.setMagnetic(); this.setMagnetic();
} }

View file

@ -2,10 +2,8 @@ package common.item.tool;
import java.util.List; import java.util.List;
import common.block.Block;
import common.enchantment.EnchantmentHelper; import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.ToolMaterial; import common.init.ToolMaterial;
import common.init.ToolType; import common.init.ToolType;
import common.item.CheatTab; import common.item.CheatTab;
@ -14,7 +12,6 @@ import common.item.ItemAction;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.ItemCategory; import common.item.ItemCategory;
import common.item.WieldType; import common.item.WieldType;
import common.util.LocalPos;
import common.util.Clientside; import common.util.Clientside;
import common.util.Color; import common.util.Color;
import common.util.Equipment; import common.util.Equipment;
@ -27,7 +24,6 @@ public class ItemTool extends Item {
public ItemTool(ToolMaterial material, Equipment type) { public ItemTool(ToolMaterial material, Equipment type) {
this.material = material; this.material = material;
this.type = type; this.type = type;
this.setMaxDamage(material.getDurability());
this.setTab(this.type.isWeapon() ? CheatTab.WEAPONS : CheatTab.TOOLS); this.setTab(this.type.isWeapon() ? CheatTab.WEAPONS : CheatTab.TOOLS);
if(this.material.isMagnetic()) if(this.material.isMagnetic())
this.setMagnetic(); this.setMagnetic();
@ -53,17 +49,6 @@ public class ItemTool extends Item {
return this.type.getDamage() >= 0 ? (this.material.getDamage() + this.type.getDamage() + EnchantmentHelper.getDamageModifier(stack)) : 0; return this.type.getDamage() >= 0 ? (this.material.getDamage() + this.type.getDamage() + EnchantmentHelper.getDamageModifier(stack)) : 0;
} }
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) {
stack.damage(this.type.isWeapon() ? 1 : 2, attacker);
return true;
}
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, LocalPos pos, EntityLiving player) {
if(block.getHardness() != 0)
stack.damage(1, player);
return true;
}
public Equipment getToolType() { public Equipment getToolType() {
return this.type; return this.type;
} }

View file

@ -20,7 +20,6 @@ import common.world.AWorldServer;
public abstract class ItemWand extends Item { public abstract class ItemWand extends Item {
public ItemWand() { public ItemWand() {
this.setUnstackable();
this.setTab(CheatTab.TOOLS); this.setTab(CheatTab.TOOLS);
} }

View file

@ -15,7 +15,6 @@ public class ItemWeatherToken extends Item {
public ItemWeatherToken(Weather weather) { public ItemWeatherToken(Weather weather) {
this.weather = weather; this.weather = weather;
this.setUnstackable();
this.setColor(Color.VIOLET); this.setColor(Color.VIOLET);
this.setDisplay("Wetterkristall (" + this.weather.getDisplay() + ")"); this.setDisplay("Wetterkristall (" + this.weather.getDisplay() + ")");
this.setMagnetic(); this.setMagnetic();

View file

@ -9,33 +9,20 @@ import common.item.ItemCategory;
import common.item.WieldType; import common.item.WieldType;
import common.world.World; import common.world.World;
public class ItemWhip extends Item public class ItemWhip extends Item {
{ public ItemWhip() {
public ItemWhip() this.setTab(CheatTab.TOOLS);
{ }
this.setTab(CheatTab.TOOLS);
this.setMaxDamage(35);
}
public ItemCategory getCategory() { public ItemCategory getCategory() {
return ItemCategory.USEABLE; return ItemCategory.USEABLE;
} }
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player) {
{ if(player.isRiding() && player.vehicle instanceof EntityPig pig && pig.getAIControlledByPlayer().isControlledByPlayer())
if (playerIn.isRiding() && playerIn.vehicle instanceof EntityPig) pig.getAIControlledByPlayer().boostSpeed();
{ return stack;
EntityPig entitypig = (EntityPig)playerIn.vehicle; }
if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getItemDamage() >= 7)
{
entitypig.getAIControlledByPlayer().boostSpeed();
itemStackIn.damage(7, playerIn);
}
}
return itemStackIn;
}
public WieldType getWieldType() { public WieldType getWieldType() {
return WieldType.TOOL_FLIP; return WieldType.TOOL_FLIP;

View file

@ -19,7 +19,6 @@ public class ItemBow extends Item
{ {
public ItemBow() public ItemBow()
{ {
this.setMaxDamage(384);
this.setTab(CheatTab.WEAPONS); this.setTab(CheatTab.WEAPONS);
} }
@ -76,7 +75,6 @@ public class ItemBow extends Item
entityarrow.setFire(100); entityarrow.setFire(100);
} }
stack.damage(1, playerIn);
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 1.0F); worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 1.0F);
if (flag) if (flag)

View file

@ -13,7 +13,6 @@ import common.world.AWorldServer;
public class ItemExterminator extends Item { public class ItemExterminator extends Item {
public ItemExterminator() { public ItemExterminator() {
this.setUnstackable();
this.setColor(Color.DARK_RED); this.setColor(Color.DARK_RED);
this.setTab(CheatTab.WEAPONS); this.setTab(CheatTab.WEAPONS);
this.setMagnetic(); this.setMagnetic();

View file

@ -23,7 +23,6 @@ public abstract class ItemGunBase extends Item
public ItemGunBase(int durability) public ItemGunBase(int durability)
{ {
this.setMaxDamage(durability);
this.setTab(CheatTab.WEAPONS); this.setTab(CheatTab.WEAPONS);
} }
@ -39,8 +38,6 @@ public abstract class ItemGunBase extends Item
public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player) public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player)
{ {
if(stack.getItemDamage() >= this.getMaxDamage())
return stack;
boolean flag = EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY, stack) > 0; boolean flag = EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY, stack) > 0;
if (flag || player.hasItem(this.getAmmo())) if (flag || player.hasItem(this.getAmmo()))
{ {
@ -54,7 +51,6 @@ public abstract class ItemGunBase extends Item
bullet.setDamage(bullet.getDamage() + j); bullet.setDamage(bullet.getDamage() + j);
} }
stack.damage(1, player);
world.playSoundAtEntity(player, this.getLaunchSound(), 1.0F); world.playSoundAtEntity(player, this.getLaunchSound(), 1.0F);
if(!flag) if(!flag)

View file

@ -124,9 +124,6 @@ public class PacketBuffer {
this.writeVarInt(stack.getSize()); this.writeVarInt(stack.getSize());
if(stack.getItem().canBeDyed()) if(stack.getItem().canBeDyed())
this.writeVarInt(stack.getRawColor()); this.writeVarInt(stack.getRawColor());
if(stack.getItem().isDamageable())
this.writeVarInt(stack.getItemDamage());
this.writeVarInt(stack.getRepairCost());
this.writeString(stack.hasDisplayName() ? stack.getDisplayName() : ""); this.writeString(stack.hasDisplayName() ? stack.getDisplayName() : "");
Set<Entry<Enchantment, Integer>> ench = stack.getEnchantments(); Set<Entry<Enchantment, Integer>> ench = stack.getEnchantments();
this.writeVarInt(ench == null ? 0 : ench.size()); this.writeVarInt(ench == null ? 0 : ench.size());
@ -145,9 +142,6 @@ public class PacketBuffer {
ItemStack stack = new ItemStack(ItemRegistry.byId(id), this.readVarInt()); ItemStack stack = new ItemStack(ItemRegistry.byId(id), this.readVarInt());
if(stack.getItem().canBeDyed()) if(stack.getItem().canBeDyed())
stack.setColor(this.readVarInt()); stack.setColor(this.readVarInt());
if(stack.getItem().isDamageable())
stack.setItemDamage(this.readVarInt());
stack.setRepairCost(this.readVarInt());
stack.setStackDisplayName(this.readString(32)); stack.setStackDisplayName(this.readString(32));
int num = this.readVarInt(); int num = this.readVarInt();
for(int z = 0; z < num; z++) { for(int z = 0; z < num; z++) {

View file

@ -323,10 +323,6 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
return this.inventory[slot] != null && this.inventory[slot].getSize() >= amount; return this.inventory[slot] != null && this.inventory[slot].getSize() >= amount;
} }
public boolean isOutputFull(int slot) {
return this.inventory[slot - this.inputs] != null && this.inventory[slot - this.inputs].isFull();
}
public void clear() { public void clear() {
for(int i = 0; i < this.inventory.length; ++i) { for(int i = 0; i < this.inventory.length; ++i) {
this.inventory[i] = null; this.inventory[i] = null;

View file

@ -142,7 +142,7 @@ public class DeviceFurnace extends Device
{ {
ItemStack itemstack = SmeltingRegistry.getResult(this.getStackInSlot(0)); ItemStack itemstack = SmeltingRegistry.getResult(this.getStackInSlot(0));
ItemStack out = this.getStackInSlot(2); ItemStack out = this.getStackInSlot(2);
return itemstack == null ? false : (out == null ? true : (!out.itemEquals(itemstack) ? false : (!out.isFull() ? true : out.getSize() < itemstack.getMaxStackSize()))); return itemstack != null && (out == null || out.itemEquals(itemstack));
} }
} }

View file

@ -157,7 +157,7 @@ public class TileEntityItemPipe extends TileEntity implements IInventory, ITicka
} }
if(--this.inCooldown <= 0) { if(--this.inCooldown <= 0) {
this.inCooldown = 0; this.inCooldown = 0;
if((this.stack == null || !this.stack.isFull()) && this.transferIn()) { if(this.transferIn()) {
this.inCooldown = Vars.pipeInDelay; this.inCooldown = Vars.pipeInDelay;
changed = true; changed = true;
} }
@ -192,29 +192,13 @@ public class TileEntityItemPipe extends TileEntity implements IInventory, ITicka
// out // out
private static boolean isInventoryFull(IInventory inv, Facing side) { private static boolean canTransfer(IInventory inv, Facing side) {
if(inv instanceof ISidedInventory sided) { if(inv instanceof ISidedInventory sided) {
int slot = sided.getSlotForFace(side); return sided.getSlotForFace(side) >= 0;
if(slot >= 0) {
ItemStack stack = sided.getStackInSlot(slot);
if(stack == null || !stack.isFull())
return false;
}
} }
else { else {
int i = inv.getSizeInventory(); return inv.getSizeInventory() > 0;
for(int j = 0; j < i; ++j) {
ItemStack stack = inv.getStackInSlot(j);
if(stack == null || !stack.isFull()) {
return false;
}
}
} }
return true;
} }
protected boolean transferOut() { protected boolean transferOut() {
@ -223,7 +207,7 @@ public class TileEntityItemPipe extends TileEntity implements IInventory, ITicka
if(iinventory == null) if(iinventory == null)
return false; return false;
Facing dir = state.getValue(BlockPipe.FACING).getOpposite(); Facing dir = state.getValue(BlockPipe.FACING).getOpposite();
if(isInventoryFull(iinventory, dir)) if(!canTransfer(iinventory, dir))
return false; return false;
for(int i = 0; i < this.getSizeInventory(); ++i) { for(int i = 0; i < this.getSizeInventory(); ++i) {
if(this.getStackInSlot(i) != null) { if(this.getStackInSlot(i) != null) {
@ -362,10 +346,9 @@ public class TileEntityItemPipe extends TileEntity implements IInventory, ITicka
add = null; add = null;
flag = true; flag = true;
} }
else if(current.getItem() == add.getItem() && !current.isOverLimit() && ItemStack.dataEquals(current, add)) { else if(current.getItem() == add.getItem() && ItemStack.dataEquals(current, add)) {
int i = add.getMaxStackSize() - current.getSize(); int j = add.getSize();
int j = Math.min(add.getSize(), i); add.setSize(0);
add.decrSize(j);
current.incrSize(j); current.incrSize(j);
flag = j > 0; flag = j > 0;
} }

View file

@ -39,8 +39,8 @@ public abstract class Vars {
public static boolean seasonLeaves = true; public static boolean seasonLeaves = true;
@Var(name = "leavesDecay") @Var(name = "leavesDecay")
public static boolean leavesDecay = true; public static boolean leavesDecay = true;
@Var(name = "repairExperience") @Var(name = "magicCombinationUsesMana")
public static boolean repairXP = true; public static boolean magicComboMana = true;
@Var(name = "mobTick") @Var(name = "mobTick")
public static boolean mobTick = true; public static boolean mobTick = true;
@Var(name = "mobAttacks") @Var(name = "mobAttacks")

View file

@ -265,7 +265,6 @@ public class CommandEnvironment {
this.registerExecutable(new CommandGod()); this.registerExecutable(new CommandGod());
this.registerExecutable(new CommandNoclip()); this.registerExecutable(new CommandNoclip());
this.registerExecutable(new CommandRename()); this.registerExecutable(new CommandRename());
this.registerExecutable(new CommandRepair());
this.registerExecutable(new CommandMore()); this.registerExecutable(new CommandMore());
this.registerExecutable(new CommandReturn()); this.registerExecutable(new CommandReturn());
this.registerExecutable(new CommandDeathspot()); this.registerExecutable(new CommandDeathspot());

View file

@ -25,7 +25,7 @@ public class CommandItem extends Command {
} }
}); });
this.setParamsOptional(); this.setParamsOptional();
this.addInt("amount", 1, 100000000, 1); this.addInt("amount", 1, 10000, 1);
this.addTag("tag", 't'); this.addTag("tag", 't');
this.setParamsRequired(); this.setParamsRequired();
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF); this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);
@ -41,22 +41,15 @@ public class CommandItem extends Command {
int done = 0; int done = 0;
int given = 0; int given = 0;
for(EntityNPC player : players) { for(EntityNPC player : players) {
int total = amount; int added = amount;
while(total > 0) { ItemStack st = stack.copy(added);
int added = Math.min(total, stack.getMaxStackSize()); player.addItemStackToInventory(st);
ItemStack st = stack.copy(added); added -= st.getSize();
player.addItemStackToInventory(st); if(added <= 0)
added -= st.getSize();
if(added <= 0)
break;
total -= added;
}
total = amount - total;
if(total <= 0)
continue; continue;
exec.log("%d * %s zum Inventar von %s hinzugefügt", total, stack.getDisplayName(), player.getRawName()); exec.log("%d * %s zum Inventar von %s hinzugefügt", added, stack.getDisplayName(), player.getRawName());
done++; done++;
given += total; given += added;
} }
if(done > 1) if(done > 1)
exec.log("%d * %s an %d Spieler verteilt", given, stack.getDisplayName(), done); exec.log("%d * %s an %d Spieler verteilt", given, stack.getDisplayName(), done);

View file

@ -4,6 +4,7 @@ import java.util.List;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.item.ItemStack; import common.item.ItemStack;
import common.util.Equipment;
import server.command.Command; import server.command.Command;
import server.command.CommandEnvironment; import server.command.CommandEnvironment;
import server.command.Executor; import server.command.Executor;
@ -15,17 +16,16 @@ public class CommandMore extends Command {
this.setParamsOptional(); this.setParamsOptional();
this.addFlag("all", 'a'); this.addFlag("all", 'a');
this.addInt("amount", 'n', 2, 100000000, 100); this.addInt("amount", 'n', 2, 10000, 100);
this.setParamsRequired(); this.setParamsRequired();
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF); this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);
} }
private int addItems(ItemStack stack, int amount) { private int addItems(ItemStack stack, int amount) {
int max = Math.min(stack.getMaxStackSize(), amount); if(stack.getSize() >= amount)
if(stack.getSize() >= max)
return 0; return 0;
int diff = max - stack.getSize(); int diff = amount - stack.getSize();
stack.setSize(max); stack.setSize(amount);
return diff; return diff;
} }
@ -35,7 +35,7 @@ public class CommandMore extends Command {
for(EntityNPC player : players) { for(EntityNPC player : players) {
int add = 0; int add = 0;
if(all) { if(all) {
for(int z = 0; z < player.getSizeInventory(); z++) { for(int z = 0; z < Equipment.INVENTORY_SLOTS; z++) {
ItemStack item = player.getStackInSlot(z); ItemStack item = player.getStackInSlot(z);
if(item != null) if(item != null)
add += this.addItems(item, amount); add += this.addItems(item, amount);

View file

@ -1,59 +0,0 @@
package server.command.commands;
import java.util.List;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import server.command.Command;
import server.command.CommandEnvironment;
import server.command.Executor;
import server.command.UserPolicy;
public class CommandRepair extends Command {
public CommandRepair() {
super("repair");
this.setParamsOptional();
this.addFlag("all", 'a');
this.setParamsRequired();
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);
}
private boolean fixItem(ItemStack stack) {
boolean flag = false;
if(stack.getRepairCost() != 0) {
stack.setRepairCost(0);
flag = true;
}
if(stack.getItem().getMaxDamage() > 0 && stack.getItemDamage() != 0) {
stack.setItemDamage(0);
flag = true;
}
return flag;
}
public void exec(CommandEnvironment env, Executor exec, boolean all, List<EntityNPC> players) {
int done = 0;
int repaired = 0;
for(EntityNPC player : players) {
int rep = 0;
if(all) {
for(int z = 0; z < player.getSizeInventory(); z++) {
ItemStack item = player.getStackInSlot(z);
if(item != null && this.fixItem(item))
rep++;
}
}
else if(player.getHeldItem() != null && this.fixItem(player.getHeldItem())) {
rep++;
}
if(rep > 0) {
exec.log("%d " + (rep == 1 ? "Gegenstand" : "Gegenstände") + " im Inventar von %s wurde" + (rep == 1 ? "" : "n") + " repariert", rep, player.getRawName());
done++;
}
repaired += rep;
}
if(done > 1)
exec.log("%d Gegenstände im Inventar von %d Spielern wurden repariert", repaired, done);
}
}

View file

@ -1119,11 +1119,10 @@ public class Player extends User implements Executor, IPlayer
if(this.itemUseCooldown > 0) if(this.itemUseCooldown > 0)
return; return;
int i = stack.getSize(); int i = stack.getSize();
int j = stack.getItemDamage();
this.itemUseCooldown = stack.getItem().getUseCooldown(stack, this.entity.worldObj, this.entity); this.itemUseCooldown = stack.getItem().getUseCooldown(stack, this.entity.worldObj, this.entity);
ItemStack itemstack = stack.getItem().onItemRightClick(stack, this.entity.worldObj, this.entity); ItemStack itemstack = stack.getItem().onItemRightClick(stack, this.entity.worldObj, this.entity);
if (itemstack != stack || itemstack != null && (itemstack.getSize() != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getItemDamage() != j)) if (itemstack != stack || itemstack != null && (itemstack.getSize() != i || itemstack.getMaxItemUseDuration() > 0))
{ {
this.entity.setHeldItem(itemstack); this.entity.setHeldItem(itemstack);
@ -2566,26 +2565,18 @@ public class Player extends User implements Executor, IPlayer
case REPAIR: case REPAIR:
if(this.isAdmin()) { if(this.isAdmin()) {
if(packetIn.getAuxData() != 0) { if(packetIn.getAuxData() != 0) {
for(int z = 0; z < this.entity.getSizeInventory(); z++) { for(int z = 0; z < Equipment.INVENTORY_SLOTS; z++) {
ItemStack stack = this.entity.getStackInSlot(z); ItemStack stack = this.entity.getStackInSlot(z);
if(stack != null) { if(stack != null) {
int max = Math.min(stack.getMaxStackSize(), 100); if(stack.getSize() < 100)
if(stack.getSize() < max) stack.setSize(100);
stack.setSize(max);
stack.setRepairCost(0);
if(stack.getItem().getMaxDamage() > 0)
stack.setItemDamage(0);
} }
} }
} }
else if(this.entity.getHeldItem() != null) { else if(this.entity.getHeldItem() != null) {
ItemStack stack = this.entity.getHeldItem(); ItemStack stack = this.entity.getHeldItem();
int max = Math.min(stack.getMaxStackSize(), 100); if(stack.getSize() < 100)
if(stack.getSize() < max) stack.setSize(100);
stack.setSize(max);
stack.setRepairCost(0);
if(stack.getItem().getMaxDamage() > 0)
stack.setItemDamage(0);
} }
} }
break; break;
@ -2765,7 +2756,7 @@ public class Player extends User implements Executor, IPlayer
Item item = packet.getItem(); Item item = packet.getItem();
if(item == null) if(item == null)
return; return;
ItemStack stack = new ItemStack(item, packet.isStacked() ? Math.min(item.getMaxAmount(), 100) : 1); ItemStack stack = new ItemStack(item, packet.isStacked() ? 100 : 1);
int amount = stack.getSize(); int amount = stack.getSize();
if(amount <= 0) if(amount <= 0)
return; return;
@ -2789,7 +2780,7 @@ public class Player extends User implements Executor, IPlayer
if(slot.getHasStack()) { if(slot.getHasStack()) {
ItemStack old = slot.getStack(); ItemStack old = slot.getStack();
if(ItemStack.itemEquals(stack, old) && ItemStack.dataEquals(stack, old)) { if(ItemStack.itemEquals(stack, old) && ItemStack.dataEquals(stack, old)) {
stack.setSize(Math.min(slot.getItemStackLimit(stack), Math.min(stack.getMaxStackSize(), old.getSize() + stack.getSize()))); stack.setSize(Math.min(slot.getItemStackLimit(stack), old.getSize() + stack.getSize()));
amount = stack.getSize() - old.getSize(); amount = stack.getSize() - old.getSize();
if(amount <= 0 || !slot.isItemValid(stack)) if(amount <= 0 || !slot.isItemValid(stack))
return; return;