item slot refactor
This commit is contained in:
parent
c3f9655338
commit
6fb9ded711
90 changed files with 1177 additions and 1622 deletions
|
@ -40,7 +40,7 @@ public class AIFireballAttack extends EntityAIBase
|
|||
|
||||
public void resetTask()
|
||||
{
|
||||
this.parentEntity.setItemNoUpdate(null);
|
||||
this.parentEntity.setHeldNoUpdate(null);
|
||||
}
|
||||
|
||||
public void updateTask()
|
||||
|
@ -56,13 +56,13 @@ public class AIFireballAttack extends EntityAIBase
|
|||
if (this.attackTimer == this.delay)
|
||||
{
|
||||
world.playEffect(1007, new BlockPos(this.parentEntity), 0);
|
||||
this.parentEntity.setItemNoUpdate(new ItemStack(Items.orb));
|
||||
this.parentEntity.setHeldNoUpdate(new ItemStack(Items.orb));
|
||||
}
|
||||
|
||||
if (this.attackTimer == this.delay * 2)
|
||||
{
|
||||
this.parentEntity.swingItem();
|
||||
this.parentEntity.setItemNoUpdate(null);
|
||||
this.parentEntity.setHeldNoUpdate(null);
|
||||
double d1 = 1.0D;
|
||||
Vec3 vec3 = this.parentEntity.getLook(1.0F);
|
||||
double d2 = target.posX - (this.parentEntity.posX + vec3.xCoord * d1);
|
||||
|
@ -91,6 +91,6 @@ public class AIFireballAttack extends EntityAIBase
|
|||
--this.attackTimer;
|
||||
}
|
||||
|
||||
this.parentEntity.setItemNoUpdate(this.attackTimer > this.delay ? new ItemStack(Items.orb) : null);
|
||||
this.parentEntity.setHeldNoUpdate(this.attackTimer > this.delay ? new ItemStack(Items.orb) : null);
|
||||
}
|
||||
}
|
|
@ -71,7 +71,7 @@ public class EntityAIBeg extends EntityAIBase
|
|||
*/
|
||||
private boolean hasPlayerGotBoneInHand(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
return itemstack == null ? false : (!this.theWolf.isTamed() && itemstack.getItem() == Items.bone ? true : this.theWolf.isBreedingItem(itemstack));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package common.ai;
|
|||
import common.entity.item.EntityItem;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.Items;
|
||||
import common.inventory.InventoryBasic;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.util.ExtMath;
|
||||
|
@ -49,11 +48,9 @@ public class EntityAIShareItems extends EntityAIWatchClosest2
|
|||
|
||||
if (this.interactionDelay == 0)
|
||||
{
|
||||
InventoryBasic inventorybasic = this.entity.getExtendedInventory();
|
||||
|
||||
for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
|
||||
for (int i = 0; i < this.entity.getInventoryCapacity(); ++i)
|
||||
{
|
||||
ItemStack itemstack = inventorybasic.getStackInSlot(i);
|
||||
ItemStack itemstack = this.entity.getStackInSlot(i);
|
||||
ItemStack itemstack1 = null;
|
||||
|
||||
if (itemstack != null)
|
||||
|
@ -76,7 +73,7 @@ public class EntityAIShareItems extends EntityAIWatchClosest2
|
|||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
inventorybasic.setInventorySlotContents(i, (ItemStack)null);
|
||||
this.entity.setInventorySlotContents(i, (ItemStack)null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public class EntityAITakePlace extends EntityAIBase
|
|||
this.entity.swingItem();
|
||||
world.setState(blockpos, state, 3);
|
||||
if(stack.decrSize())
|
||||
this.entity.setItemNoUpdate(null);
|
||||
this.entity.setHeldNoUpdate(null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -102,7 +102,7 @@ public class EntityAITakePlace extends EntityAIBase
|
|||
if(this.entity.getHeldItem() != null)
|
||||
this.entity.getHeldItem().incrSize();
|
||||
else
|
||||
this.entity.setItemNoUpdate(new ItemStack(STEALABLE.get(state)));
|
||||
this.entity.setHeldNoUpdate(new ItemStack(STEALABLE.get(state)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package common.attributes;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import common.collect.Maps;
|
||||
|
||||
public class AttributeMap {
|
||||
private class AttributeInstance {
|
||||
private final Map<Integer, Float> slots = Maps.<Integer, Float>newHashMap();
|
||||
|
||||
private boolean update = true;
|
||||
private float value;
|
||||
|
||||
public void applyModifier(int slot, float amount) {
|
||||
this.slots.put(slot, amount);
|
||||
this.update = true;
|
||||
}
|
||||
|
||||
public void removeModifier(int slot) {
|
||||
if(this.slots.remove(slot) != null)
|
||||
this.update = true;
|
||||
}
|
||||
|
||||
public float getAttributeValue() {
|
||||
if(this.update) {
|
||||
this.value = 0.0f;
|
||||
for(Float mod : this.slots.values()) {
|
||||
this.value += mod;
|
||||
}
|
||||
this.update = false;
|
||||
}
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<Attribute, AttributeInstance> attributes = Maps.<Attribute, AttributeInstance>newHashMap();
|
||||
|
||||
public AttributeMap() {
|
||||
for(Attribute attribute : Attribute.values()) {
|
||||
this.attributes.put(attribute, new AttributeInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public float get(Attribute attribute) {
|
||||
return this.attributes.get(attribute).getAttributeValue();
|
||||
}
|
||||
|
||||
public void remove(Map<Attribute, Float> modifiers, int slot) {
|
||||
for(Entry<Attribute, Float> entry : modifiers.entrySet()) {
|
||||
this.attributes.get(entry.getKey()).removeModifier(slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Map<Attribute, Float> modifiers, int slot, int amount) {
|
||||
for(Entry<Attribute, Float> entry : modifiers.entrySet()) {
|
||||
this.attributes.get(entry.getKey()).applyModifier(slot, entry.getValue() * (float)amount);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ import java.util.Set;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.block.artificial.BlockSlab;
|
||||
import common.block.natural.BlockSnow;
|
||||
import common.collect.ImmutableList;
|
||||
|
@ -27,6 +26,7 @@ import common.enchantment.EnchantmentHelper;
|
|||
import common.entity.Entity;
|
||||
import common.entity.item.EntityItem;
|
||||
import common.entity.item.EntityXp;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.Blocks;
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BlockFlowerPot extends Block
|
|||
|
||||
public boolean onUse(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
ItemStack itemstack = playerIn.inventory.getCurrentItem();
|
||||
ItemStack itemstack = playerIn.getHeldItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem().getBlock() != null)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public class BlockFlowerPot extends Block
|
|||
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
|
||||
playerIn.setHeldItem(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -3,10 +3,10 @@ package common.block.artificial;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.SoundType;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.MetalType;
|
||||
import common.item.CheatTab;
|
||||
|
|
|
@ -3,8 +3,8 @@ package common.block.natural;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.block.SoundType;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.MetalType;
|
||||
import common.item.ItemStack;
|
||||
|
|
|
@ -9,7 +9,7 @@ import common.entity.npc.EntityNPC;
|
|||
import common.entity.types.EntityLiving;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerRepair;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.CheatTab;
|
||||
import common.model.Model;
|
||||
import common.model.Model.ModelProvider;
|
||||
|
@ -142,7 +142,7 @@ public class BlockAnvil extends BlockFalling implements Rotatable
|
|||
this.position = pos;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerRepair(playerInventory, this.world, this.position);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class BlockCauldron extends Block
|
|||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = playerIn.inventory.getCurrentItem();
|
||||
ItemStack itemstack = playerIn.getHeldItem();
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ public class BlockCauldron extends Block
|
|||
{
|
||||
// if (!playerIn.creative)
|
||||
// {
|
||||
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, new ItemStack(Items.bucket));
|
||||
playerIn.setHeldItem(new ItemStack(Items.bucket));
|
||||
// }
|
||||
|
||||
// playerIn.triggerAchievement(StatRegistry.cauldronFilledStat);
|
||||
|
@ -122,7 +122,7 @@ public class BlockCauldron extends Block
|
|||
// {
|
||||
ItemStack itemstack2 = new ItemStack(Items.water_bottle);
|
||||
|
||||
if (!playerIn.inventory.addItemStackToInventory(itemstack2))
|
||||
if (!playerIn.addItemStackToInventory(itemstack2))
|
||||
{
|
||||
worldIn.spawnEntityInWorld(new EntityItem(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.5D, (double)pos.getZ() + 0.5D, itemstack2));
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class BlockCauldron extends Block
|
|||
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
|
||||
playerIn.setHeldItem(null);
|
||||
}
|
||||
// }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import common.block.Material;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerEnchantment;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.CheatTab;
|
||||
import common.model.Model;
|
||||
import common.model.Model.ModelProvider;
|
||||
|
@ -69,7 +69,7 @@ public class BlockEnchantmentTable extends Block
|
|||
this.position = pos;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerEnchantment(playerInventory, this.world, this.position);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import common.entity.types.EntityLiving;
|
|||
import common.init.Items;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerChest;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.model.Model;
|
||||
|
@ -130,9 +130,9 @@ public class BlockWarpChest extends Block implements Rotatable
|
|||
|
||||
public class WarpChest implements InteractionObject
|
||||
{
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerChest(playerIn.inventory, playerIn.getWarpChest(), playerIn);
|
||||
return new ContainerChest(playerInventory, playerInventory.getWarpChest());
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
|
|
|
@ -5,7 +5,7 @@ import common.block.Material;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerWorkbench;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.CheatTab;
|
||||
import common.model.Model;
|
||||
import common.model.Model.ModelProvider;
|
||||
|
@ -58,7 +58,7 @@ public class BlockWorkbench extends Block
|
|||
this.position = pos;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerWorkbench(playerInventory, this.world, this.position, BlockWorkbench.this);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,8 @@ package common.block.tech;
|
|||
import common.block.Block;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.InventoryPlayer;
|
||||
|
||||
public interface InteractionObject {
|
||||
Container createContainer(InventoryPlayer inv, EntityNPC player);
|
||||
Container createContainer(EntityNPC inv);
|
||||
Block getBlock();
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public enum Effect {
|
|||
int k = 40 >> amp;
|
||||
if(k > 0 && duration % k != 0)
|
||||
return;
|
||||
for(ItemStack stack : npc.inventory.mainInventory) {
|
||||
for(ItemStack stack : npc.getInventory()) {
|
||||
if(stack != null && !stack.isEmpty()) {
|
||||
if(!stack.isFull())
|
||||
stack.incrSize();
|
||||
|
@ -162,7 +162,16 @@ public enum Effect {
|
|||
stack.setItemDamage(stack.getItemDamage() - 1);
|
||||
}
|
||||
}
|
||||
for(ItemStack stack : npc.inventory.armorInventory) {
|
||||
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();
|
||||
|
|
|
@ -32,7 +32,7 @@ public enum EnchantmentType
|
|||
}
|
||||
else if (item instanceof ItemArmor armor)
|
||||
{
|
||||
return this == ARMOR || armor.getArmorType().getEnchantmentType() == this;
|
||||
return (this == ARMOR && armor.getArmorType().isMainArmor()) || armor.getArmorType().getEnchantmentType() == this;
|
||||
}
|
||||
else if(item instanceof ItemTool tool) {
|
||||
return this == DIGGER || (tool.getToolType().isMelee() && this == WEAPON);
|
||||
|
|
|
@ -208,7 +208,7 @@ public class EntityCat extends EntityTameable
|
|||
*/
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (this.isTamed())
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ public class EntityCat extends EntityTameable
|
|||
{
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
|
||||
if (!this.worldObj.client)
|
||||
|
|
|
@ -120,17 +120,17 @@ public class EntityCow extends EntityAnimal
|
|||
*/
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() == Items.bucket /* && !player.creative */ && !this.isChild())
|
||||
{
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.milk_bucket));
|
||||
player.setHeldItem(new ItemStack(Items.milk_bucket));
|
||||
}
|
||||
else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
|
||||
else if (!player.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket), false);
|
||||
player.dropItem(new ItemStack(Items.milk_bucket), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -266,7 +266,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
public ItemAnimalArmor getHorseArmorItem()
|
||||
{
|
||||
Item item = ItemRegistry.byId(this.dataWatcher.getWatchableObjectInt(22));
|
||||
return item instanceof ItemAnimalArmor armor ? armor : null;
|
||||
return item instanceof ItemAnimalArmor armor && armor.getArmorType().getAnimalType() == EntityHorse.class ? armor : null;
|
||||
}
|
||||
|
||||
public boolean isEatingHaystack()
|
||||
|
@ -292,7 +292,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
@Serverside
|
||||
public void setHorseArmorStack(ItemStack itemStackIn)
|
||||
{
|
||||
this.dataWatcher.updateObject(22, itemStackIn != null && itemStackIn.getItem() instanceof ItemAnimalArmor armor ? ItemRegistry.getId(armor) : 0);
|
||||
this.dataWatcher.updateObject(22, itemStackIn != null && itemStackIn.getItem() instanceof ItemAnimalArmor armor && armor.getArmorType().getAnimalType() == EntityHorse.class ? ItemRegistry.getId(armor) : 0);
|
||||
}
|
||||
|
||||
public void setBreeding(boolean breeding)
|
||||
|
@ -765,7 +765,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
*/
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemMobTemplate)
|
||||
{
|
||||
|
@ -788,7 +788,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
|
||||
if (this.canWearArmor())
|
||||
{
|
||||
if (itemstack.getItem() instanceof ItemAnimalArmor)
|
||||
if (itemstack.getItem() instanceof ItemAnimalArmor armor && armor.getArmorType().getAnimalType() == EntityHorse.class)
|
||||
{
|
||||
if (!this.isTame())
|
||||
{
|
||||
|
@ -909,7 +909,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
{
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1718,7 +1718,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
|
|||
*/
|
||||
public static boolean isArmorItem(Item p_146085_0_)
|
||||
{
|
||||
return p_146085_0_ instanceof ItemAnimalArmor;
|
||||
return p_146085_0_ instanceof ItemAnimalArmor armor && armor.getArmorType().getAnimalType() == EntityHorse.class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -174,7 +174,7 @@ public class EntitySheep extends EntityAnimal
|
|||
*/
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemTool tool && tool.getToolType() == Equipment.SHEARS && !this.getSheared() && !this.isChild())
|
||||
{
|
||||
|
|
|
@ -349,7 +349,7 @@ public class EntityWolf extends EntityTameable
|
|||
*/
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (this.isTamed())
|
||||
{
|
||||
|
@ -365,7 +365,7 @@ public class EntityWolf extends EntityTameable
|
|||
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -381,7 +381,7 @@ public class EntityWolf extends EntityTameable
|
|||
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -401,7 +401,7 @@ public class EntityWolf extends EntityTameable
|
|||
{
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
|
||||
if (!this.worldObj.client)
|
||||
|
|
|
@ -391,7 +391,7 @@ public class EntityItem extends Entity
|
|||
int i = itemstack.getSize();
|
||||
|
||||
if (this.delayBeforeCanPickup == 0 // && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getUser()))
|
||||
&& entityIn.inventory.addItemStackToInventory(itemstack))
|
||||
&& entityIn.addItemStackToInventory(itemstack))
|
||||
{
|
||||
// if (itemstack.getItem() == Items.log)
|
||||
// {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package common.attributes;
|
||||
package common.entity.npc;
|
||||
|
||||
public enum Attribute {
|
||||
RADIATION("Strahlung"),
|
|
@ -39,12 +39,12 @@ public class EntityCultivator extends EntityNPC {
|
|||
|
||||
public void startExecuting() {
|
||||
super.startExecuting();
|
||||
EntityCultivator.this.setItemNoUpdate(new ItemStack(Items.camera));
|
||||
EntityCultivator.this.setHeldNoUpdate(new ItemStack(Items.camera));
|
||||
}
|
||||
|
||||
public void resetTask() {
|
||||
super.resetTask();
|
||||
EntityCultivator.this.setItemNoUpdate(null);
|
||||
EntityCultivator.this.setHeldNoUpdate(null);
|
||||
}
|
||||
});
|
||||
this.tasks.addTask(10, new EntityAITakePlace(this));
|
||||
|
|
|
@ -227,7 +227,7 @@ public class EntityHaunter extends EntityNPC {
|
|||
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() == Items.lighter)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -512,7 +512,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
|
|||
{
|
||||
boolean flag = this.canBePickedUp == 1; // || this.canBePickedUp == 2 && entityIn.creative;
|
||||
|
||||
if (this.canBePickedUp == 1 && !entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
|
||||
if (this.canBePickedUp == 1 && !entityIn.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class EntityDie extends EntityThrowable implements IObjectData
|
|||
{
|
||||
if(this.noPickup)
|
||||
this.setDead();
|
||||
else if(player.inventory.addItemStackToInventory(this.getStack())) {
|
||||
else if(player.addItemStackToInventory(this.getStack())) {
|
||||
this.setDead();
|
||||
player.worldObj.playSoundAtEntity(player, SoundEvent.POP, 0.2F);
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
|
|
|
@ -163,14 +163,14 @@ public abstract class EntityAnimal extends EntityLiving
|
|||
*/
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack stack = player.inventory.getCurrentItem();
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (this.isBreedingItem(stack) && this.getGrowingAge() == 0 && !this.isInLove())
|
||||
{
|
||||
if(stack.decrSize())
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
player.setHeldItem(null);
|
||||
this.setInLove(player);
|
||||
return true;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public abstract class EntityAnimal extends EntityLiving
|
|||
if (this.isChild() && this.isBreedingItem(stack))
|
||||
{
|
||||
if(stack.decrSize())
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
player.setHeldItem(null);
|
||||
if(!this.worldObj.client)
|
||||
this.grow((int)((float)(-this.getGrowingAge() / 20) * 0.1F));
|
||||
return true;
|
||||
|
|
|
@ -13,8 +13,6 @@ import common.ai.EntityJumpHelper;
|
|||
import common.ai.EntityLookHelper;
|
||||
import common.ai.EntityMoveHelper;
|
||||
import common.ai.EntitySenses;
|
||||
import common.attributes.Attribute;
|
||||
import common.attributes.AttributeMap;
|
||||
import common.block.Block;
|
||||
import common.block.SoundType;
|
||||
import common.collect.Lists;
|
||||
|
@ -66,7 +64,6 @@ import common.world.AWorldServer;
|
|||
|
||||
public abstract class EntityLiving extends Entity
|
||||
{
|
||||
protected AttributeMap attributes = new AttributeMap();
|
||||
private final List<CombatEntry> combat = Lists.<CombatEntry>newArrayList();
|
||||
private final Map<Effect, StatusEffect> effects = Maps.<Effect, StatusEffect>newEnumMap(Effect.class);
|
||||
public int soundTimer;
|
||||
|
@ -358,8 +355,8 @@ public abstract class EntityLiving extends Entity
|
|||
if(!this.worldObj.client) {
|
||||
if(!this.firstEffectUpdate && Vars.radiation) { // &&
|
||||
// (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) {
|
||||
float radiation = this.radiation + this.attributes.get(Attribute.RADIATION);
|
||||
radiation -= 10.0f + this.attributes.get(Attribute.RADIATION_RESISTANCE);
|
||||
float radiation = this.radiation + this.getBaseRadiation();
|
||||
radiation -= this.getRadiationResistance();
|
||||
// if(this.isPlayer())
|
||||
// Log.SERVER.info("rad:" + radiation);
|
||||
if(radiation >= 0.0f) {
|
||||
|
@ -400,6 +397,14 @@ public abstract class EntityLiving extends Entity
|
|||
// this.target = null; // FIX Creative
|
||||
// }
|
||||
}
|
||||
|
||||
public float getBaseRadiation() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public float getRadiationResistance() {
|
||||
return 10.0f;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * If Animal, checks if the age timer is negative
|
||||
|
@ -1358,11 +1363,6 @@ public abstract class EntityLiving extends Entity
|
|||
this.swingFactor = (float)this.swingTimer / (float)i;
|
||||
}
|
||||
|
||||
public final AttributeMap getAttributeMap()
|
||||
{
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
// public CreatureType getCreatureType()
|
||||
// {
|
||||
// return CreatureType.UNDEFINED;
|
||||
|
@ -2595,11 +2595,11 @@ public abstract class EntityLiving extends Entity
|
|||
this.clearLeashed(true, true);
|
||||
return true;
|
||||
}
|
||||
ItemStack stack = player.inventory.getCurrentItem();
|
||||
ItemStack stack = player.getHeldItem();
|
||||
if(stack != null && stack.getItem() == Items.lead && this.allowLeashing() && (!(this instanceof EntityTameable tameable) || !tameable.isTamed() || tameable.isOwner(player))) {
|
||||
this.setLeashedTo(player, true);
|
||||
if(stack.decrSize())
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
player.setHeldItem(null);
|
||||
return true;
|
||||
}
|
||||
return this.interact(player) || super.interactFirst(player);
|
||||
|
@ -2998,7 +2998,7 @@ public abstract class EntityLiving extends Entity
|
|||
|
||||
public boolean interact(EntityNPC player)
|
||||
{
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemMobTemplate)
|
||||
{
|
||||
|
@ -3028,7 +3028,7 @@ public abstract class EntityLiving extends Entity
|
|||
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public abstract class ItemRegistry {
|
|||
private static void registerTools(ToolMaterial material, String name, String prefix) {
|
||||
for(Equipment tool : Equipment.values()) {
|
||||
if(tool.canRegister(material))
|
||||
register(name + "_" + tool.getName(), (tool.isArmor() ? (tool.isAnimalArmor() ? new ItemAnimalArmor(material, name) : new ItemArmor(material, name, tool)) : new ItemTool(material, tool)).setDisplay(tool.getDisplay(prefix, prefix == null)));
|
||||
register(name + "_" + tool.getName(), (tool.isArmor() ? (tool.isAnimalArmor() ? new ItemAnimalArmor(material, name, tool) : new ItemArmor(material, name, tool)) : new ItemTool(material, tool)).setDisplay(tool.getDisplay(prefix, prefix == null)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,6 @@ public abstract class Container
|
|||
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityNPC playerIn)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
InventoryPlayer inventoryplayer = playerIn.inventory;
|
||||
|
||||
if (mode == 5)
|
||||
{
|
||||
|
@ -156,7 +155,7 @@ public abstract class Container
|
|||
{
|
||||
this.resetDrag();
|
||||
}
|
||||
else if (inventoryplayer.getItemStack() == null)
|
||||
else if (playerIn.getMouseItem() == null)
|
||||
{
|
||||
this.resetDrag();
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ public abstract class Container
|
|||
{
|
||||
Slot slot = (Slot)this.inventorySlots.get(slotId);
|
||||
|
||||
if (slot != null && canAddItemToSlot(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().getSize() > this.dragSlots.size() && this.canDragIntoSlot(slot))
|
||||
if (slot != null && canAddItemToSlot(slot, playerIn.getMouseItem(), true) && slot.isItemValid(playerIn.getMouseItem()) && playerIn.getMouseItem().getSize() > this.dragSlots.size() && this.canDragIntoSlot(slot))
|
||||
{
|
||||
this.dragSlots.add(slot);
|
||||
}
|
||||
|
@ -187,12 +186,12 @@ public abstract class Container
|
|||
{
|
||||
if (!this.dragSlots.isEmpty())
|
||||
{
|
||||
ItemStack itemstack3 = inventoryplayer.getItemStack().copy();
|
||||
int j = inventoryplayer.getItemStack().getSize();
|
||||
ItemStack itemstack3 = playerIn.getMouseItem().copy();
|
||||
int j = playerIn.getMouseItem().getSize();
|
||||
|
||||
for (Slot slot1 : this.dragSlots)
|
||||
{
|
||||
if (slot1 != null && canAddItemToSlot(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().getSize() >= this.dragSlots.size() && this.canDragIntoSlot(slot1))
|
||||
if (slot1 != null && canAddItemToSlot(slot1, playerIn.getMouseItem(), true) && slot1.isItemValid(playerIn.getMouseItem()) && playerIn.getMouseItem().getSize() >= this.dragSlots.size() && this.canDragIntoSlot(slot1))
|
||||
{
|
||||
ItemStack itemstack1 = itemstack3.copy();
|
||||
int k = slot1.getHasStack() ? slot1.getStack().getSize() : 0;
|
||||
|
@ -220,7 +219,7 @@ public abstract class Container
|
|||
itemstack3 = null;
|
||||
}
|
||||
|
||||
inventoryplayer.setItemStack(itemstack3);
|
||||
playerIn.setMouseItem(itemstack3);
|
||||
}
|
||||
|
||||
this.resetDrag();
|
||||
|
@ -238,21 +237,21 @@ public abstract class Container
|
|||
{
|
||||
if (slotId == -999)
|
||||
{
|
||||
if (inventoryplayer.getItemStack() != null)
|
||||
if (playerIn.getMouseItem() != null)
|
||||
{
|
||||
if (clickedButton == 0)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true);
|
||||
inventoryplayer.setItemStack((ItemStack)null);
|
||||
playerIn.dropItem(playerIn.getMouseItem(), true);
|
||||
playerIn.setMouseItem((ItemStack)null);
|
||||
}
|
||||
|
||||
if (clickedButton == 1)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().split(1), true);
|
||||
playerIn.dropItem(playerIn.getMouseItem().split(1), true);
|
||||
|
||||
if (inventoryplayer.getItemStack().isEmpty())
|
||||
if (playerIn.getMouseItem().isEmpty())
|
||||
{
|
||||
inventoryplayer.setItemStack((ItemStack)null);
|
||||
playerIn.setMouseItem((ItemStack)null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +293,7 @@ public abstract class Container
|
|||
if (slot7 != null)
|
||||
{
|
||||
ItemStack itemstack9 = slot7.getStack();
|
||||
ItemStack itemstack10 = inventoryplayer.getItemStack();
|
||||
ItemStack itemstack10 = playerIn.getMouseItem();
|
||||
|
||||
if (itemstack9 != null)
|
||||
{
|
||||
|
@ -319,7 +318,7 @@ public abstract class Container
|
|||
|
||||
if (itemstack10.isEmpty())
|
||||
{
|
||||
inventoryplayer.setItemStack((ItemStack)null);
|
||||
playerIn.setMouseItem((ItemStack)null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -329,14 +328,14 @@ public abstract class Container
|
|||
{
|
||||
int j2 = clickedButton == 0 ? itemstack9.getSize() : (itemstack9.getSize() + 1) / 2;
|
||||
ItemStack itemstack12 = slot7.decrStackSize(j2);
|
||||
inventoryplayer.setItemStack(itemstack12);
|
||||
playerIn.setMouseItem(itemstack12);
|
||||
|
||||
if (itemstack9.isEmpty())
|
||||
{
|
||||
slot7.putStack((ItemStack)null);
|
||||
}
|
||||
|
||||
slot7.onPickupFromSlot(playerIn, inventoryplayer.getItemStack());
|
||||
slot7.onPickupFromSlot(playerIn, playerIn.getMouseItem());
|
||||
}
|
||||
else if (slot7.isItemValid(itemstack10))
|
||||
{
|
||||
|
@ -358,7 +357,7 @@ public abstract class Container
|
|||
|
||||
if (itemstack10.isEmpty())
|
||||
{
|
||||
inventoryplayer.setItemStack((ItemStack)null);
|
||||
playerIn.setMouseItem((ItemStack)null);
|
||||
}
|
||||
|
||||
itemstack9.incrSize(i2);
|
||||
|
@ -366,7 +365,7 @@ public abstract class Container
|
|||
else if (itemstack10.getSize() <= slot7.getItemStackLimit(itemstack10))
|
||||
{
|
||||
slot7.putStack(itemstack10);
|
||||
inventoryplayer.setItemStack(itemstack9);
|
||||
playerIn.setMouseItem(itemstack9);
|
||||
}
|
||||
}
|
||||
else if (itemstack9.getItem() == itemstack10.getItem() && itemstack10.getMaxStackSize() > 1 && ItemStack.dataEquals(itemstack9, itemstack10))
|
||||
|
@ -383,7 +382,7 @@ public abstract class Container
|
|||
slot7.putStack((ItemStack)null);
|
||||
}
|
||||
|
||||
slot7.onPickupFromSlot(playerIn, inventoryplayer.getItemStack());
|
||||
slot7.onPickupFromSlot(playerIn, playerIn.getMouseItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,26 +397,26 @@ public abstract class Container
|
|||
|
||||
if (slot5.canTakeStack(playerIn))
|
||||
{
|
||||
ItemStack itemstack7 = inventoryplayer.getStackInSlot(clickedButton);
|
||||
boolean flag = itemstack7 == null || slot5.inventory == inventoryplayer && slot5.isItemValid(itemstack7);
|
||||
ItemStack itemstack7 = playerIn.getStackInSlot(clickedButton);
|
||||
boolean flag = itemstack7 == null || slot5.inventory == playerIn && slot5.isItemValid(itemstack7);
|
||||
int k1 = -1;
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
k1 = inventoryplayer.getFirstEmptyStack();
|
||||
k1 = playerIn.getFirstEmptyStack();
|
||||
flag |= k1 > -1;
|
||||
}
|
||||
|
||||
if (slot5.getHasStack() && flag)
|
||||
{
|
||||
ItemStack itemstack11 = slot5.getStack();
|
||||
inventoryplayer.setInventorySlotContents(clickedButton, itemstack11.copy());
|
||||
playerIn.setInventorySlotContents(clickedButton, itemstack11.copy());
|
||||
|
||||
if ((slot5.inventory != inventoryplayer || !slot5.isItemValid(itemstack7)) && itemstack7 != null)
|
||||
if ((slot5.inventory != playerIn || !slot5.isItemValid(itemstack7)) && itemstack7 != null)
|
||||
{
|
||||
if (k1 > -1)
|
||||
{
|
||||
inventoryplayer.addItemStackToInventory(itemstack7);
|
||||
playerIn.addItemStackToInventory(itemstack7);
|
||||
slot5.decrStackSize(itemstack11.getSize());
|
||||
slot5.putStack((ItemStack)null);
|
||||
slot5.onPickupFromSlot(playerIn, itemstack11);
|
||||
|
@ -432,7 +431,7 @@ public abstract class Container
|
|||
}
|
||||
else if (!slot5.getHasStack() && itemstack7 != null && slot5.isItemValid(itemstack7))
|
||||
{
|
||||
inventoryplayer.setInventorySlotContents(clickedButton, (ItemStack)null);
|
||||
playerIn.setInventorySlotContents(clickedButton, (ItemStack)null);
|
||||
slot5.putStack(itemstack7);
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +447,7 @@ public abstract class Container
|
|||
// inventoryplayer.setItemStack(itemstack6);
|
||||
// }
|
||||
// }
|
||||
else if (mode == 4 && inventoryplayer.getItemStack() == null && slotId >= 0)
|
||||
else if (mode == 4 && playerIn.getMouseItem() == null && slotId >= 0)
|
||||
{
|
||||
Slot slot3 = (Slot)this.inventorySlots.get(slotId);
|
||||
|
||||
|
@ -456,13 +455,13 @@ public abstract class Container
|
|||
{
|
||||
ItemStack itemstack5 = slot3.decrStackSize(clickedButton == 0 ? 1 : slot3.getStack().getSize());
|
||||
slot3.onPickupFromSlot(playerIn, itemstack5);
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack5, true);
|
||||
playerIn.dropItem(itemstack5, true);
|
||||
}
|
||||
}
|
||||
else if (mode == 6 && slotId >= 0)
|
||||
{
|
||||
Slot slot2 = (Slot)this.inventorySlots.get(slotId);
|
||||
ItemStack itemstack4 = inventoryplayer.getItemStack();
|
||||
ItemStack itemstack4 = playerIn.getMouseItem();
|
||||
|
||||
if (itemstack4 != null && (slot2 == null || !slot2.getHasStack() || !slot2.canTakeStack(playerIn)))
|
||||
{
|
||||
|
@ -520,12 +519,10 @@ public abstract class Container
|
|||
*/
|
||||
public void onContainerClosed(EntityNPC playerIn)
|
||||
{
|
||||
InventoryPlayer inventoryplayer = playerIn.inventory;
|
||||
|
||||
if (inventoryplayer.getItemStack() != null)
|
||||
if (playerIn.getMouseItem() != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true);
|
||||
inventoryplayer.setItemStack((ItemStack)null);
|
||||
playerIn.dropItem(playerIn.getMouseItem(), true);
|
||||
playerIn.setMouseItem(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,7 +560,7 @@ public abstract class Container
|
|||
/**
|
||||
* Gets a unique transaction ID. Parameter is unused.
|
||||
*/
|
||||
public short getNextTransactionID(InventoryPlayer p_75136_1_)
|
||||
public short getNextTransactionID(EntityNPC p_75136_1_)
|
||||
{
|
||||
++this.transactionID;
|
||||
return this.transactionID;
|
||||
|
|
|
@ -15,12 +15,12 @@ public class ContainerBrewingStand extends Container
|
|||
private final Slot theSlot;
|
||||
private int brewTime;
|
||||
|
||||
public ContainerBrewingStand(InventoryPlayer playerInventory, IInventory tileBrewingStandIn)
|
||||
public ContainerBrewingStand(EntityNPC playerInventory, IInventory tileBrewingStandIn)
|
||||
{
|
||||
this.tileBrewingStand = tileBrewingStandIn;
|
||||
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 0, 56, 46));
|
||||
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 1, 79, 53));
|
||||
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 2, 102, 46));
|
||||
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory, tileBrewingStandIn, 0, 56, 46));
|
||||
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory, tileBrewingStandIn, 1, 79, 53));
|
||||
this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory, tileBrewingStandIn, 2, 102, 46));
|
||||
this.theSlot = this.addSlotToContainer(new ContainerBrewingStand.Ingredient(tileBrewingStandIn, 3, 79, 17));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
|
|
|
@ -11,7 +11,7 @@ public class ContainerChest extends Container
|
|||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public ContainerChest(IInventory inv, IInventory chest, EntityNPC player)
|
||||
public ContainerChest(EntityNPC player, IInventory chest)
|
||||
{
|
||||
this.chest = chest;
|
||||
this.chestSize = chest.getSizeInventory();
|
||||
|
@ -34,13 +34,13 @@ public class ContainerChest extends Container
|
|||
{
|
||||
for (int j1 = 0; j1 < 9; ++j1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inv, j1 + l * 9 + 9, 8 + j1 * 18 + xOffset, 103 + l * 18 + yoffset));
|
||||
this.addSlotToContainer(new Slot(player, j1 + l * 9 + 9, 8 + j1 * 18 + xOffset, 103 + l * 18 + yoffset));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; ++i1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inv, i1, 8 + i1 * 18 + xOffset, 161 + yoffset));
|
||||
this.addSlotToContainer(new Slot(player, i1, 8 + i1 * 18 + xOffset, 161 + yoffset));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,12 +26,12 @@ public class ContainerEnchantment extends Container
|
|||
public int[] mana;
|
||||
public Pair<Enchantment, Integer>[] ench;
|
||||
|
||||
public ContainerEnchantment(InventoryPlayer playerInv, World worldIn)
|
||||
public ContainerEnchantment(EntityNPC playerInv, World worldIn)
|
||||
{
|
||||
this(playerInv, worldIn, BlockPos.ORIGIN);
|
||||
}
|
||||
|
||||
public ContainerEnchantment(InventoryPlayer playerInv, World worldIn, BlockPos pos)
|
||||
public ContainerEnchantment(EntityNPC playerInv, World worldIn, BlockPos pos)
|
||||
{
|
||||
this.table = new InventoryBasic(1)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ public class ContainerEnchantment extends Container
|
|||
this.ench = new Pair[] {null, null, null};
|
||||
this.world = worldIn;
|
||||
this.position = pos;
|
||||
this.seed = playerInv.player.getEnchSeed();
|
||||
this.seed = playerInv.getEnchSeed();
|
||||
this.addSlotToContainer(new Slot(this.table, 0, 25, 47)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
|
@ -296,7 +296,7 @@ public class ContainerEnchantment extends Container
|
|||
|
||||
if (itemstack != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public class ContainerEntityInventory extends Container
|
|||
private IInventory entityInventory;
|
||||
private Entity entity;
|
||||
|
||||
public ContainerEntityInventory(IInventory playerInventory, final IInventory entityInv, final Entity entity, EntityNPC player)
|
||||
public ContainerEntityInventory(EntityNPC player, final IInventory entityInv, final Entity entity)
|
||||
{
|
||||
this.entityInventory = entityInv;
|
||||
this.entity = entity;
|
||||
|
@ -54,13 +54,13 @@ public class ContainerEntityInventory extends Container
|
|||
{
|
||||
for (int k1 = 0; k1 < 9; ++k1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, k1 + i1 * 9 + 9, 8 + k1 * 18, 102 + i1 * 18 + j));
|
||||
this.addSlotToContainer(new Slot(player, k1 + i1 * 9 + 9, 8 + k1 * 18, 102 + i1 * 18 + j));
|
||||
}
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < 9; ++j1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j1, 8 + j1 * 18, 160 + j));
|
||||
this.addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 160 + j));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ public class ContainerFurnace extends Container
|
|||
private int furnaceBurnTime;
|
||||
private int currentItemBurnTime;
|
||||
|
||||
public ContainerFurnace(InventoryPlayer playerInventory, IInventory furnaceInventory)
|
||||
public ContainerFurnace(EntityNPC playerInventory, IInventory furnaceInventory)
|
||||
{
|
||||
this.tileFurnace = furnaceInventory;
|
||||
this.addSlotToContainer(new Slot(furnaceInventory, 0, 56, 17));
|
||||
this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 1, 56, 53));
|
||||
this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, furnaceInventory, 2, 116, 35));
|
||||
this.addSlotToContainer(new SlotFurnaceOutput(playerInventory, furnaceInventory, 2, 116, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ public class ContainerHopper extends Container
|
|||
{
|
||||
private final IInventory hopperInventory;
|
||||
|
||||
public ContainerHopper(InventoryPlayer playerInventory, IInventory hopperInventoryIn, EntityNPC player)
|
||||
public ContainerHopper(EntityNPC playerInventory, IInventory hopperInventoryIn, EntityNPC player)
|
||||
{
|
||||
this.hopperInventory = hopperInventoryIn;
|
||||
hopperInventoryIn.openInventory(player);
|
||||
|
|
|
@ -11,11 +11,11 @@ public class ContainerMerchant extends Container
|
|||
private InventoryMerchant merchantInventory;
|
||||
private final World theWorld;
|
||||
|
||||
public ContainerMerchant(InventoryPlayer playerInventory, EntityNPC merchant, World worldIn)
|
||||
public ContainerMerchant(EntityNPC playerInventory, EntityNPC merchant, World worldIn)
|
||||
{
|
||||
this.theMerchant = merchant;
|
||||
this.theWorld = worldIn;
|
||||
this.merchantInventory = new InventoryMerchant(playerInventory.player, merchant);
|
||||
this.merchantInventory = new InventoryMerchant(playerInventory, merchant);
|
||||
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53) {
|
||||
public boolean canEditItem() {
|
||||
return false;
|
||||
|
@ -26,7 +26,7 @@ public class ContainerMerchant extends Container
|
|||
return false;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new SlotMerchantResult(playerInventory.player, this.merchantInventory, 2, 120, 53));
|
||||
this.addSlotToContainer(new SlotMerchantResult(playerInventory, this.merchantInventory, 2, 120, 53));
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
|
@ -160,14 +160,14 @@ public class ContainerMerchant extends Container
|
|||
|
||||
if (itemstack != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
|
||||
itemstack = this.merchantInventory.removeStackFromSlot(1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package common.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.attributes.AttributeMap;
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.CraftingRegistry;
|
||||
import common.item.ItemStack;
|
||||
|
@ -18,17 +14,12 @@ public class ContainerPlayer extends Container {
|
|||
}, 1, 1);
|
||||
private final InventoryCrafting craftMatrix = new InventoryCrafting(this, 2, 2);
|
||||
private final IInventory craftResult = new InventoryCraftResult();
|
||||
private final boolean isLocalWorld;
|
||||
private final EntityNPC thePlayer;
|
||||
private final AttributeMap attributes;
|
||||
private final List<ItemStack> lastStacks = Lists.<ItemStack>newArrayList();
|
||||
|
||||
public ContainerPlayer(final InventoryPlayer playerInventory, boolean localWorld, EntityNPC player)
|
||||
public ContainerPlayer(EntityNPC player)
|
||||
{
|
||||
this.isLocalWorld = localWorld;
|
||||
this.thePlayer = player;
|
||||
this.attributes = player.getAttributeMap();
|
||||
this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 144, 36));
|
||||
this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 144, 36));
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
|
@ -45,7 +36,7 @@ public class ContainerPlayer extends Container {
|
|||
for (Equipment slot : Equipment.ARMOR)
|
||||
{
|
||||
final Equipment type = slot;
|
||||
this.addSlotToContainer(new Slot(playerInventory, 27 + 9 + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
|
||||
this.addSlotToContainer(new Slot(player, 27 + 9 + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
|
||||
{
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
|
@ -62,53 +53,17 @@ public class ContainerPlayer extends Container {
|
|||
{
|
||||
for (int j1 = 0; j1 < 9; ++j1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, j1 + (l + 1) * 9, 8 + j1 * 18, 84 + l * 18));
|
||||
this.addSlotToContainer(new Slot(player, j1 + (l + 1) * 9, 8 + j1 * 18, 84 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; ++i1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142));
|
||||
this.addSlotToContainer(new Slot(player, i1, 8 + i1 * 18, 142));
|
||||
}
|
||||
|
||||
this.onCraftMatrixChanged(this.craftMatrix);
|
||||
}
|
||||
|
||||
protected Slot addSlotToContainer(Slot slotIn)
|
||||
{
|
||||
slotIn = super.addSlotToContainer(slotIn);
|
||||
if(slotIn.slotNumber >= 5 + Equipment.ARMOR_SLOTS)
|
||||
this.lastStacks.add((ItemStack)null);
|
||||
return slotIn;
|
||||
}
|
||||
|
||||
public void detectAttributeChanges()
|
||||
{
|
||||
for (int i = 0; i < this.inventorySlots.size(); ++i)
|
||||
{
|
||||
Slot slot = this.inventorySlots.get(i);
|
||||
if(slot.slotNumber >= 5 + Equipment.ARMOR_SLOTS) {
|
||||
ItemStack current = slot.getStack();
|
||||
ItemStack last = (ItemStack)this.lastStacks.get(i - (5 + Equipment.ARMOR_SLOTS));
|
||||
|
||||
if (!ItemStack.allEquals(last, current))
|
||||
{
|
||||
if (last != null)
|
||||
{
|
||||
this.attributes.remove(last.getAttributeModifiers(Equipment.PICKAXE), slot.getIndex());
|
||||
}
|
||||
|
||||
if (current != null)
|
||||
{
|
||||
this.attributes.add(current.getAttributeModifiers(Equipment.PICKAXE), slot.getIndex(), current.getSize());
|
||||
}
|
||||
|
||||
last = current == null ? null : current.copy();
|
||||
this.lastStacks.set(i - (5 + Equipment.ARMOR_SLOTS), last);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for when the crafting matrix is changed.
|
||||
|
@ -146,7 +101,7 @@ public class ContainerPlayer extends Container {
|
|||
|
||||
if (itemstack != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,9 +149,9 @@ public class ContainerPlayer extends Container {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + Equipment.ARMOR_SLOTS + ((ItemArmor)itemstack.getItem()).getArmorType().getIndex())).getHasStack())
|
||||
else if (itemstack.getItem() instanceof ItemArmor armor && !((Slot)this.inventorySlots.get(5 + armor.getArmorType().getIndex())).getHasStack())
|
||||
{
|
||||
int idx = 5 + Equipment.ARMOR_SLOTS + ((ItemArmor)itemstack.getItem()).getArmorType().getIndex();
|
||||
int idx = 5 + armor.getArmorType().getIndex();
|
||||
|
||||
if (!this.mergeItemStack(itemstack1, idx, idx + 1, false))
|
||||
{
|
||||
|
|
|
@ -24,12 +24,12 @@ public class ContainerRepair extends Container
|
|||
public int maximumCost;
|
||||
private int materialCost;
|
||||
|
||||
public ContainerRepair(InventoryPlayer playerInventory, World worldIn)
|
||||
public ContainerRepair(EntityNPC playerInventory, World worldIn)
|
||||
{
|
||||
this(playerInventory, worldIn, BlockPos.ORIGIN);
|
||||
}
|
||||
|
||||
public ContainerRepair(InventoryPlayer playerInventory, final World worldIn, final BlockPos blockPosIn)
|
||||
public ContainerRepair(EntityNPC playerInventory, final World worldIn, final BlockPos blockPosIn)
|
||||
{
|
||||
this.outputSlot = new InventoryCraftResult();
|
||||
this.inputSlots = new InventoryBasic(2)
|
||||
|
@ -411,7 +411,7 @@ public class ContainerRepair extends Container
|
|||
|
||||
if (itemstack != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class ContainerTile extends Container
|
|||
private Status status = Status.OFF;
|
||||
private final int[] resources;
|
||||
|
||||
public ContainerTile(InventoryPlayer playerInv, Device tile, IInventory tileInv, EntityNPC player)
|
||||
public ContainerTile(EntityNPC player, Device tile, IInventory tileInv)
|
||||
{
|
||||
this.tileInv = tileInv;
|
||||
this.tile = tile;
|
||||
|
@ -37,13 +37,13 @@ public class ContainerTile extends Container
|
|||
{
|
||||
for (int k = 0; k < 9; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInv, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
|
||||
this.addSlotToContainer(new Slot(player, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; ++i1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(playerInv, i1, 8 + i1 * 18, 58 + i));
|
||||
this.addSlotToContainer(new Slot(player, i1, 8 + i1 * 18, 58 + i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ContainerWorkbench extends Container
|
|||
private final BlockPos pos;
|
||||
private final BlockWorkbench block;
|
||||
|
||||
public ContainerWorkbench(InventoryPlayer playerInventory, World worldIn, BlockPos posIn, BlockWorkbench block)
|
||||
public ContainerWorkbench(EntityNPC playerInventory, World worldIn, BlockPos posIn, BlockWorkbench block)
|
||||
{
|
||||
int size = block.getSize();
|
||||
this.block = block;
|
||||
|
@ -24,7 +24,7 @@ public class ContainerWorkbench extends Container
|
|||
this.pos = posIn;
|
||||
this.craftSlots = size * size;
|
||||
this.craftMatrix = new InventoryCrafting(this, size, size);
|
||||
this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 134, 17 + ((size - 1) * 18) / 2));
|
||||
this.addSlotToContainer(new SlotCrafting(playerInventory, this.craftMatrix, this.craftResult, 0, 134, 17 + ((size - 1) * 18) / 2));
|
||||
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ public class ContainerWorkbench extends Container
|
|||
|
||||
if (itemstack != null)
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
playerIn.dropItem(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,5 @@ package common.inventory;
|
|||
|
||||
public interface IInvBasic
|
||||
{
|
||||
/**
|
||||
* Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
|
||||
*/
|
||||
void onInventoryChanged(InventoryBasic p_76316_1_);
|
||||
}
|
||||
|
|
|
@ -84,46 +84,6 @@ public class InventoryBasic implements IInventory
|
|||
}
|
||||
}
|
||||
|
||||
public ItemStack addStack(ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = stack.copy();
|
||||
|
||||
for (int i = 0; i < this.slotsCount; ++i)
|
||||
{
|
||||
ItemStack itemstack1 = this.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 == null)
|
||||
{
|
||||
this.setInventorySlotContents(i, itemstack);
|
||||
this.markDirty();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ItemStack.itemEquals(itemstack1, itemstack))
|
||||
{
|
||||
int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize());
|
||||
int k = Math.min(itemstack.getSize(), j - itemstack1.getSize());
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
itemstack1.incrSize(k);
|
||||
if (itemstack.decrSize(k))
|
||||
{
|
||||
this.markDirty();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack.getSize() != stack.getSize())
|
||||
{
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
|
|
|
@ -1,712 +0,0 @@
|
|||
package common.inventory;
|
||||
|
||||
import common.block.Block;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.tool.ItemTool;
|
||||
import common.tags.TagObject;
|
||||
import common.util.Equipment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryPlayer implements IInventory
|
||||
{
|
||||
/**
|
||||
* An array of 36 item stacks indicating the main player inventory (including the visible bar).
|
||||
*/
|
||||
public ItemStack[] mainInventory = new ItemStack[36];
|
||||
|
||||
/** An array of 4 item stacks containing the currently worn armor pieces. */
|
||||
public ItemStack[] armorInventory = new ItemStack[Equipment.ARMOR_SLOTS];
|
||||
|
||||
/** The index of the currently held item (0-8). */
|
||||
public int currentItem;
|
||||
|
||||
/** The player whose inventory this is. */
|
||||
public EntityNPC player;
|
||||
private ItemStack itemStack;
|
||||
|
||||
/**
|
||||
* Set true whenever the inventory changes. Nothing sets it false so you will have to write your own code to check
|
||||
* it and reset the value.
|
||||
*/
|
||||
public boolean inventoryChanged;
|
||||
|
||||
public InventoryPlayer(EntityNPC playerIn)
|
||||
{
|
||||
this.player = playerIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item stack currently held by the player.
|
||||
*/
|
||||
public ItemStack getCurrentItem()
|
||||
{
|
||||
return this.currentItem < 9 && this.currentItem >= 0 ? this.mainInventory[this.currentItem] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the player hotbar inventory
|
||||
*/
|
||||
public static int getHotbarSize()
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
private int getInventorySlotContainItem(Item itemIn)
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemIn)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* stores an itemstack in the users inventory
|
||||
*/
|
||||
private int storeItemStack(ItemStack itemStackIn)
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && !this.mainInventory[i].isFull() && this.mainInventory[i].getSize() < this.getInventoryStackLimit() && ItemStack.dataEquals(this.mainInventory[i], itemStackIn))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first item stack that is empty.
|
||||
*/
|
||||
public int getFirstEmptyStack()
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
if (this.mainInventory[i] == null)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean setCurrentItem(Item itemIn) // , boolean p_146030_4_)
|
||||
{
|
||||
// ItemStack itemstack = this.getCurrentItem();
|
||||
int i = this.getInventorySlotContainItem(itemIn);
|
||||
|
||||
if (i >= 0 && i < 9)
|
||||
{
|
||||
this.currentItem = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// else if (p_146030_4_ && itemIn != null)
|
||||
// {
|
||||
// int j = this.getFirstEmptyStack();
|
||||
//
|
||||
// if (j >= 0 && j < 9)
|
||||
// {
|
||||
// this.currentItem = j;
|
||||
// }
|
||||
//
|
||||
// if (itemstack == null || !itemstack.isItemEnchantable() || this.getInventorySlotContainItemAndDamage(itemstack.getItem(), itemstack.getItemDamage()) != this.currentItem)
|
||||
// {
|
||||
// int k = this.getInventorySlotContainItemAndDamage(itemIn, metadataIn);
|
||||
// int l;
|
||||
//
|
||||
// if (k >= 0)
|
||||
// {
|
||||
// l = this.mainInventory[k].stackSize;
|
||||
// this.mainInventory[k] = this.mainInventory[this.currentItem];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// l = 1;
|
||||
// }
|
||||
//
|
||||
// this.mainInventory[this.currentItem] = new ItemStack(itemIn, l, metadataIn);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the current item to the next one or the previous one
|
||||
*
|
||||
* @param direction Direction to switch (1, 0, -1). 1 (any > 0) to select item left of current (decreasing
|
||||
* currentItem index), -1 (any < 0) to select item right of current (increasing currentItem index). 0 has no effect.
|
||||
*/
|
||||
public void changeCurrentItem(int direction)
|
||||
{
|
||||
// if (direction > 0)
|
||||
// {
|
||||
// direction = 1;
|
||||
// }
|
||||
//
|
||||
// if (direction < 0)
|
||||
// {
|
||||
// direction = -1;
|
||||
// }
|
||||
|
||||
for (this.currentItem -= direction; this.currentItem < 0; this.currentItem += 9)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (this.currentItem >= 9)
|
||||
{
|
||||
this.currentItem -= 9;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
for(int z = 0; z < this.mainInventory.length; z++) {
|
||||
this.mainInventory[z] = null;
|
||||
}
|
||||
for(int z = 0; z < this.armorInventory.length; z++) {
|
||||
this.armorInventory[z] = null;
|
||||
}
|
||||
this.itemStack = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function stores as many items of an ItemStack as possible in a matching slot and returns the quantity of
|
||||
* left over items.
|
||||
*/
|
||||
private int storePartialItemStack(ItemStack itemStackIn)
|
||||
{
|
||||
Item item = itemStackIn.getItem();
|
||||
int i = itemStackIn.getSize();
|
||||
int j = this.storeItemStack(itemStackIn);
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
j = this.getFirstEmptyStack();
|
||||
}
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.mainInventory[j] == null)
|
||||
{
|
||||
this.mainInventory[j] = new ItemStack(item, 0);
|
||||
|
||||
this.mainInventory[j].copyData(itemStackIn);
|
||||
}
|
||||
|
||||
int k = i;
|
||||
|
||||
if (i > this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].getSize())
|
||||
{
|
||||
k = this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].getSize();
|
||||
}
|
||||
|
||||
if (k > this.getInventoryStackLimit() - this.mainInventory[j].getSize())
|
||||
{
|
||||
k = this.getInventoryStackLimit() - this.mainInventory[j].getSize();
|
||||
}
|
||||
|
||||
if (k == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = i - k;
|
||||
this.mainInventory[j].incrSize(k);
|
||||
// this.mainInventory[j].animationsToGo = 5;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the number of animations remaining. Only called on client side. This is used to handle the animation of
|
||||
* receiving a block.
|
||||
*/
|
||||
// public void decrementAnimations()
|
||||
// {
|
||||
// for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
// {
|
||||
// if (this.mainInventory[i] != null)
|
||||
// {
|
||||
// this.mainInventory[i].updateAnimation(this.player.worldObj, this.player, i, this.currentItem == i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* removed one item of specified Item from inventory (if it is in a stack, the stack size will reduce with 1)
|
||||
*/
|
||||
public boolean consumeInventoryItem(Item itemIn)
|
||||
{
|
||||
int i = this.getInventorySlotContainItem(itemIn);
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.mainInventory[i].decrSize())
|
||||
{
|
||||
this.mainInventory[i] = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specified Item is inside the inventory
|
||||
*/
|
||||
public boolean hasItem(Item itemIn)
|
||||
{
|
||||
int i = this.getInventorySlotContainItem(itemIn);
|
||||
return i >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the item stack to the inventory, returns false if it is impossible.
|
||||
*/
|
||||
public boolean addItemStackToInventory(final ItemStack itemStackIn)
|
||||
{
|
||||
if (itemStackIn != null && !itemStackIn.isEmpty() && itemStackIn.getItem() != null)
|
||||
{
|
||||
if (itemStackIn.isItemDamaged())
|
||||
{
|
||||
int j = this.getFirstEmptyStack();
|
||||
|
||||
if (j >= 0)
|
||||
{
|
||||
this.mainInventory[j] = ItemStack.copy(itemStackIn);
|
||||
// this.mainInventory[j].animationsToGo = 5;
|
||||
itemStackIn.setSize(0);
|
||||
return true;
|
||||
}
|
||||
// else if (this.player.creative)
|
||||
// {
|
||||
// itemStackIn.stackSize = 0;
|
||||
// return true;
|
||||
// }
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
while (true)
|
||||
{
|
||||
i = itemStackIn.getSize();
|
||||
itemStackIn.setSize(this.storePartialItemStack(itemStackIn));
|
||||
|
||||
if (itemStackIn.isEmpty() || itemStackIn.getSize() >= i)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if (itemStackIn.stackSize == i && this.player.creative)
|
||||
// {
|
||||
// itemStackIn.stackSize = 0;
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
return itemStackIn.getSize() < i;
|
||||
// }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
ItemStack[] aitemstack = this.mainInventory;
|
||||
|
||||
if (index >= this.mainInventory.length)
|
||||
{
|
||||
aitemstack = this.armorInventory;
|
||||
index -= this.mainInventory.length;
|
||||
}
|
||||
|
||||
if (aitemstack[index] != null)
|
||||
{
|
||||
if (aitemstack[index].getSize() <= count)
|
||||
{
|
||||
ItemStack itemstack1 = aitemstack[index];
|
||||
aitemstack[index] = null;
|
||||
return itemstack1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = aitemstack[index].split(count);
|
||||
|
||||
if (aitemstack[index].isEmpty())
|
||||
{
|
||||
aitemstack[index] = null;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
ItemStack[] aitemstack = this.mainInventory;
|
||||
|
||||
if (index >= this.mainInventory.length)
|
||||
{
|
||||
aitemstack = this.armorInventory;
|
||||
index -= this.mainInventory.length;
|
||||
}
|
||||
|
||||
if (aitemstack[index] != null)
|
||||
{
|
||||
ItemStack itemstack = aitemstack[index];
|
||||
aitemstack[index] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
ItemStack[] aitemstack = this.mainInventory;
|
||||
|
||||
if (index >= aitemstack.length)
|
||||
{
|
||||
index -= aitemstack.length;
|
||||
aitemstack = this.armorInventory;
|
||||
}
|
||||
|
||||
aitemstack[index] = stack;
|
||||
}
|
||||
|
||||
public float getStrVsBlock(Block blockIn)
|
||||
{
|
||||
float f = 1.0F;
|
||||
|
||||
if (this.mainInventory[this.currentItem] != null && this.mainInventory[this.currentItem].getItem() instanceof ItemTool tool && blockIn.getMiningTool() == tool.getToolType())
|
||||
{
|
||||
f *= tool.getToolMaterial().getEfficiency();
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public List<TagObject> toTag(List<TagObject> list)
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
if (this.mainInventory[i] != null)
|
||||
{
|
||||
TagObject tag = new TagObject();
|
||||
tag.setByte("Slot", (byte)i);
|
||||
this.mainInventory[i].writeTags(tag);
|
||||
list.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < this.armorInventory.length; ++j)
|
||||
{
|
||||
if (this.armorInventory[j] != null)
|
||||
{
|
||||
TagObject tag = new TagObject();
|
||||
tag.setByte("Slot", (byte)(j + 100));
|
||||
this.armorInventory[j].writeTags(tag);
|
||||
list.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void fromTag(List<TagObject> list)
|
||||
{
|
||||
this.mainInventory = new ItemStack[36];
|
||||
this.armorInventory = new ItemStack[Equipment.ARMOR_SLOTS];
|
||||
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
TagObject tag = list.get(i);
|
||||
int j = tag.getByte("Slot") & 255;
|
||||
ItemStack stack = ItemStack.readFromTag(tag);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (j >= 0 && j < this.mainInventory.length)
|
||||
{
|
||||
this.mainInventory[j] = stack;
|
||||
}
|
||||
|
||||
if (j >= 100 && j < this.armorInventory.length + 100)
|
||||
{
|
||||
this.armorInventory[j - 100] = stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.mainInventory.length + this.armorInventory.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
ItemStack[] aitemstack = this.mainInventory;
|
||||
|
||||
if (index >= aitemstack.length)
|
||||
{
|
||||
index -= aitemstack.length;
|
||||
aitemstack = this.armorInventory;
|
||||
}
|
||||
|
||||
return aitemstack[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return ItemStack.MAX_SIZE;
|
||||
}
|
||||
|
||||
public boolean canHeldItemHarvest(Block block) {
|
||||
if(!block.getMaterial().isToolRequired())
|
||||
return true;
|
||||
ItemStack stack = this.getStackInSlot(this.currentItem);
|
||||
return stack != null && stack.getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() && (!tool.getToolType().isLevelled() || tool.getToolMaterial().getHarvestLevel() >= block.getMiningLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the damage values and maximum damage values of each armor item, returns the current armor value.
|
||||
*/
|
||||
public int getTotalArmorValue()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (int j = 0; j < this.armorInventory.length; ++j)
|
||||
{
|
||||
if (this.armorInventory[j] != null && this.armorInventory[j].getItem() instanceof ItemArmor)
|
||||
{
|
||||
int k = ((ItemArmor)this.armorInventory[j].getItem()).getArmorValue();
|
||||
i += k;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Damages armor in each slot by the specified amount.
|
||||
*/
|
||||
public void damageArmor(int damage)
|
||||
{
|
||||
damage = damage / 4;
|
||||
|
||||
if (damage < 1)
|
||||
{
|
||||
damage = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.armorInventory.length; ++i)
|
||||
{
|
||||
if (this.armorInventory[i] != null && this.armorInventory[i].getItem() instanceof ItemArmor)
|
||||
{
|
||||
this.armorInventory[i].damage(damage, this.player);
|
||||
|
||||
if (this.armorInventory[i].isEmpty())
|
||||
{
|
||||
this.armorInventory[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop all armor and main inventory items.
|
||||
*/
|
||||
public void dropAllItems()
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
if (this.mainInventory[i] != null)
|
||||
{
|
||||
this.player.dropItem(this.mainInventory[i], true, false);
|
||||
this.mainInventory[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < this.armorInventory.length; ++j)
|
||||
{
|
||||
if (this.armorInventory[j] != null)
|
||||
{
|
||||
this.player.dropItem(this.armorInventory[j], true, false);
|
||||
this.armorInventory[j] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
|
||||
* hasn't changed and skip it.
|
||||
*/
|
||||
public void markDirty()
|
||||
{
|
||||
this.inventoryChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stack helds by mouse, used in GUI/Container
|
||||
*/
|
||||
public void setItemStack(ItemStack itemStackIn)
|
||||
{
|
||||
this.itemStack = itemStackIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stack helds by mouse, used in GUI and Containers
|
||||
*/
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not make give this method the name canInteractWith because it clashes with Container
|
||||
*/
|
||||
public boolean isUseableByPlayer(EntityNPC player)
|
||||
{
|
||||
return this.player.dead ? false : player.getDistanceSqToEntity(this.player) <= 64.0D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the specified ItemStack exists in the inventory.
|
||||
*/
|
||||
public boolean hasItemStack(ItemStack itemStackIn)
|
||||
{
|
||||
for (int i = 0; i < this.armorInventory.length; ++i)
|
||||
{
|
||||
if (this.armorInventory[i] != null && this.armorInventory[i].itemEquals(itemStackIn))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < this.mainInventory.length; ++j)
|
||||
{
|
||||
if (this.mainInventory[j] != null && this.mainInventory[j].itemEquals(itemStackIn))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openInventory(EntityNPC player)
|
||||
{
|
||||
}
|
||||
|
||||
public void closeInventory(EntityNPC player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
|
||||
*/
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the ItemStack contents from another InventoryPlayer instance
|
||||
*/
|
||||
public void copyInventory(InventoryPlayer playerInventory)
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
this.mainInventory[i] = ItemStack.copy(playerInventory.mainInventory[i]);
|
||||
}
|
||||
|
||||
for (int j = 0; j < this.armorInventory.length; ++j)
|
||||
{
|
||||
this.armorInventory[j] = ItemStack.copy(playerInventory.armorInventory[j]);
|
||||
}
|
||||
|
||||
this.currentItem = playerInventory.currentItem;
|
||||
}
|
||||
|
||||
public int getField(int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
}
|
||||
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
{
|
||||
this.mainInventory[i] = null;
|
||||
}
|
||||
|
||||
for (int j = 0; j < this.armorInventory.length; ++j)
|
||||
{
|
||||
this.armorInventory[j] = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,9 +28,9 @@ public class SlotCrafting extends Slot
|
|||
{
|
||||
craftMatrix.setInventorySlotContents(i, itemstack1);
|
||||
}
|
||||
else if (!thePlayer.inventory.addItemStackToInventory(itemstack1))
|
||||
else if (!thePlayer.addItemStackToInventory(itemstack1))
|
||||
{
|
||||
thePlayer.dropPlayerItemWithRandomChoice(itemstack1, false);
|
||||
thePlayer.dropItem(itemstack1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ package common.item;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import common.attributes.Attribute;
|
||||
|
||||
import common.block.Block;
|
||||
import common.block.tech.BlockDispenser;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.entity.types.IProjectile;
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.ItemRegistry;
|
||||
|
@ -265,10 +265,16 @@ public final class ItemStack {
|
|||
return this.repairCost;
|
||||
}
|
||||
|
||||
public Map<Attribute, Float> getAttributeModifiers(Equipment slot) {
|
||||
public Map<Attribute, Float> getAttributeModifiers() {
|
||||
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class);
|
||||
if(slot == null || (slot.isArmor() ? (this.item instanceof ItemArmor armor && armor.getArmorType() == slot) : !(this.item instanceof ItemArmor)))
|
||||
this.item.getModifiers(map);
|
||||
this.item.getModifiers(map);
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<Attribute, Float> getArmorModifiers(Equipment slot) {
|
||||
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class);
|
||||
if(this.item instanceof ItemArmor armor && (slot == null || armor.getArmorType() == slot))
|
||||
armor.getArmorModifiers(map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -398,7 +404,7 @@ public final class ItemStack {
|
|||
entity.renderBrokenItemStack(this);
|
||||
this.decrSize();
|
||||
if(entity != null && entity.isPlayer() && this.isEmpty() && this.item instanceof ItemBow)
|
||||
((EntityNPC)entity).destroyCurrentEquippedItem();
|
||||
((EntityNPC)entity).setHeldItem(null);
|
||||
this.setItemDamage(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package common.item.consumable;
|
||||
|
||||
import java.util.Map;
|
||||
import common.attributes.Attribute;
|
||||
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
|
|
|
@ -122,7 +122,9 @@ public class ItemPotion extends Item
|
|||
return new ItemStack(Items.bottle);
|
||||
}
|
||||
|
||||
playerIn.inventory.addItemStackToInventory(new ItemStack(Items.bottle));
|
||||
if (!playerIn.addItemStackToInventory(new ItemStack(Items.bottle))) {
|
||||
playerIn.dropItem(new ItemStack(Items.bottle), false);
|
||||
}
|
||||
// }
|
||||
|
||||
return stack;
|
||||
|
|
|
@ -13,18 +13,28 @@ import common.util.Equipment;
|
|||
|
||||
public class ItemAnimalArmor extends Item {
|
||||
private final ToolMaterial material;
|
||||
private final Equipment type;
|
||||
@Clientside
|
||||
private final String texture;
|
||||
|
||||
public ItemAnimalArmor(ToolMaterial material, String texture) {
|
||||
public ItemAnimalArmor(ToolMaterial material, String texture, Equipment type) {
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
this.type = type;
|
||||
this.setUnstackable();
|
||||
this.setTab(CheatTab.ARMOR);
|
||||
if(this.material.isMagnetic())
|
||||
this.setMagnetic();
|
||||
}
|
||||
|
||||
public Equipment getArmorType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public ToolMaterial getArmorMaterial() {
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public int getArmorValue() {
|
||||
return this.material.getDamageReduction(Equipment.CHESTPLATE);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.ToolMaterial;
|
||||
import common.item.CheatTab;
|
||||
|
@ -22,124 +22,103 @@ import common.util.Vec3;
|
|||
import common.world.AWorldServer;
|
||||
import common.world.World;
|
||||
|
||||
public class ItemArmor extends Item
|
||||
{
|
||||
private final ToolMaterial material;
|
||||
public class ItemArmor extends Item {
|
||||
private final ToolMaterial material;
|
||||
private final Equipment type;
|
||||
@Clientside
|
||||
private final String texture;
|
||||
private final String texture;
|
||||
|
||||
public ItemArmor(ToolMaterial material, String texture, Equipment armorType)
|
||||
{
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
this.type = armorType;
|
||||
this.setMaxDamage(material.getDurability(armorType));
|
||||
this.setTab(CheatTab.ARMOR);
|
||||
if(this.material.canBeDyed())
|
||||
this.setDefaultColor(this.material.getDefaultColor());
|
||||
if(this.material.isMagnetic())
|
||||
this.setMagnetic();
|
||||
}
|
||||
public ItemArmor(ToolMaterial material, String texture, Equipment armorType) {
|
||||
this.material = material;
|
||||
this.texture = texture;
|
||||
this.type = armorType;
|
||||
int dmg = material.getDurability(armorType);
|
||||
if(dmg <= 0)
|
||||
this.setUnstackable();
|
||||
else
|
||||
this.setMaxDamage(dmg);
|
||||
this.setTab(CheatTab.ARMOR);
|
||||
if(this.material.canBeDyed())
|
||||
this.setDefaultColor(this.material.getDefaultColor());
|
||||
if(this.material.isMagnetic())
|
||||
this.setMagnetic();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enchantability factor of the item, most of the time is based on material.
|
||||
*/
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return this.material.getArmorEnchantability();
|
||||
}
|
||||
|
||||
public Equipment getArmorType() {
|
||||
return this.type;
|
||||
}
|
||||
public int getItemEnchantability() {
|
||||
return this.material.getArmorEnchantability();
|
||||
}
|
||||
|
||||
public Equipment getArmorType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public ToolMaterial getArmorMaterial() {
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public ToolMaterial getArmorMaterial()
|
||||
{
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public int getArmorValue() {
|
||||
return this.material.getDamageReduction(this.type);
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public String getArmorTexture()
|
||||
{
|
||||
return this.texture;
|
||||
}
|
||||
public String getArmorTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
|
||||
{
|
||||
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip) {
|
||||
if(this.material.getDamageReduction(this.type) > 0)
|
||||
tooltip.add(Color.BLUE + "+" + this.material.getDamageReduction(this.type) + " Rüstungspunkte");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this item is repairable in an anvil.
|
||||
*/
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
|
||||
{
|
||||
ItemStack itemstack = playerIn.getArmor(this.type);
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) {
|
||||
ItemStack itemstack = playerIn.getArmor(this.type);
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
playerIn.setArmor(this.type, itemStackIn.copy());
|
||||
itemStackIn.decrSize();
|
||||
}
|
||||
if(itemstack == null) {
|
||||
playerIn.setArmor(this.type, itemStackIn.copy());
|
||||
itemStackIn.decrSize();
|
||||
}
|
||||
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
// public boolean canBeDyed() {
|
||||
// return this.material.canBeDyed();
|
||||
// }
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
public void getModifiers(Map<Attribute, Float> map)
|
||||
{
|
||||
if(this.material.getRadiationReduction(this.type) > 0.0f)
|
||||
map.put(Attribute.RADIATION_RESISTANCE, this.material.getRadiationReduction(this.type));
|
||||
if(this.material.getMagicReduction(this.type) > 0.0f)
|
||||
map.put(Attribute.MAGIC_RESISTANCE, this.material.getMagicReduction(this.type));
|
||||
}
|
||||
public void getArmorModifiers(Map<Attribute, Float> map) {
|
||||
if(this.material.getRadiationReduction(this.type) > 0.0f)
|
||||
map.put(Attribute.RADIATION_RESISTANCE, this.material.getRadiationReduction(this.type));
|
||||
if(this.material.getMagicReduction(this.type) > 0.0f)
|
||||
map.put(Attribute.MAGIC_RESISTANCE, this.material.getMagicReduction(this.type));
|
||||
}
|
||||
|
||||
@Clientside
|
||||
public boolean hasBuiltinModel() {
|
||||
return this.type.isArmorRendered();
|
||||
return this.type.isMainArmor();
|
||||
}
|
||||
|
||||
@Serverside
|
||||
public ItemStack dispenseStack(AWorldServer world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) {
|
||||
BlockPos pos = blockpos.offset(facing);
|
||||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
BoundingBox axisalignedbb = new BoundingBox((double)i, (double)j, (double)k, (double)(i + 1), (double)(j + 1), (double)(k + 1));
|
||||
List<EntityNPC> list = world.<EntityNPC>getEntitiesWithinAABB(EntityNPC.class, axisalignedbb, new Predicate<EntityNPC>() {
|
||||
BlockPos pos = blockpos.offset(facing);
|
||||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
BoundingBox axisalignedbb = new BoundingBox((double)i, (double)j, (double)k, (double)(i + 1), (double)(j + 1), (double)(k + 1));
|
||||
List<EntityNPC> list = world.<EntityNPC>getEntitiesWithinAABB(EntityNPC.class, axisalignedbb, new Predicate<EntityNPC>() {
|
||||
public boolean test(EntityNPC entity) {
|
||||
return entity.isEntityAlive() && entity.getArmor(ItemArmor.this.type) == null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (list.size() > 0)
|
||||
{
|
||||
EntityNPC entitylivingbase = list.get(0);
|
||||
entitylivingbase.setArmor(this.type, stack.copy(1));
|
||||
stack.decrSize();
|
||||
return stack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.dispenseStack(world, source, position, blockpos, facing, stack);
|
||||
}
|
||||
}
|
||||
if(list.size() > 0) {
|
||||
EntityNPC entitylivingbase = list.get(0);
|
||||
entitylivingbase.setArmor(this.type, stack.copy(1));
|
||||
stack.decrSize();
|
||||
return stack;
|
||||
}
|
||||
else {
|
||||
return super.dispenseStack(world, source, position, blockpos, facing, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,9 +53,9 @@ public class ItemBottle extends Item
|
|||
return new ItemStack(Items.water_bottle);
|
||||
}
|
||||
|
||||
if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.water_bottle)))
|
||||
if (!playerIn.addItemStackToInventory(new ItemStack(Items.water_bottle)))
|
||||
{
|
||||
playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.water_bottle), false);
|
||||
playerIn.dropItem(new ItemStack(Items.water_bottle), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.util.Map;
|
|||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
import common.attributes.Attribute;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.liquid.BlockDynamicLiquid;
|
||||
|
@ -16,6 +15,7 @@ import common.block.liquid.BlockLiquid;
|
|||
import common.block.liquid.BlockStaticLiquid;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.Blocks;
|
||||
import common.init.Items;
|
||||
|
@ -249,9 +249,9 @@ public class ItemBucket extends Item
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!player.inventory.addItemStackToInventory(fullBucket))
|
||||
if (!player.addItemStackToInventory(fullBucket))
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(fullBucket, false);
|
||||
player.dropItem(fullBucket, false);
|
||||
}
|
||||
|
||||
return emptyBuckets;
|
||||
|
|
|
@ -2,7 +2,8 @@ package common.item.material;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import common.attributes.Attribute;
|
||||
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.MetalType;
|
||||
import common.item.Item;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ItemBow extends Item
|
|||
{
|
||||
boolean flag = /* playerIn.creative || */ EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY, stack) > 0;
|
||||
|
||||
if (flag || playerIn.inventory.hasItem(Items.arrow))
|
||||
if (flag || playerIn.hasItem(Items.arrow))
|
||||
{
|
||||
int i = this.getMaxItemUseDuration(stack) - timeLeft;
|
||||
float f = (float)i / 20.0F;
|
||||
|
@ -80,7 +80,7 @@ public class ItemBow extends Item
|
|||
}
|
||||
else
|
||||
{
|
||||
playerIn.inventory.consumeInventoryItem(Items.arrow);
|
||||
playerIn.consumeInventoryItem(Items.arrow);
|
||||
}
|
||||
|
||||
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
|
||||
|
@ -122,7 +122,7 @@ public class ItemBow extends Item
|
|||
*/
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
|
||||
{
|
||||
if (/* playerIn.creative || */ playerIn.inventory.hasItem(Items.arrow))
|
||||
if (/* playerIn.creative || */ playerIn.hasItem(Items.arrow))
|
||||
{
|
||||
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class ItemGunBase extends Item
|
|||
if(stack.getItemDamage() >= this.getMaxDamage())
|
||||
return stack;
|
||||
boolean flag = EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY, stack) > 0;
|
||||
if (flag || player.inventory.hasItem(this.getAmmo()))
|
||||
if (flag || player.hasItem(this.getAmmo()))
|
||||
{
|
||||
EntityBullet bullet = this.createBullet(world, player);
|
||||
bullet.setDamage(this.getAmmo().getDamage(stack));
|
||||
|
@ -53,7 +53,7 @@ public abstract class ItemGunBase extends Item
|
|||
world.playSoundAtEntity(player, this.getLaunchSound(), 1.0F);
|
||||
|
||||
if(!flag)
|
||||
player.inventory.consumeInventoryItem(this.getAmmo());
|
||||
player.consumeInventoryItem(this.getAmmo());
|
||||
|
||||
if (!world.client)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SPacketSpawnPlayer implements Packet<IClientPlayer>
|
|||
this.z = ExtMath.floord(player.posZ * 32.0D);
|
||||
this.yaw = (byte)((int)(player.rotYaw * 256.0F / 360.0F));
|
||||
this.pitch = (byte)((int)(player.rotPitch * 256.0F / 360.0F));
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
ItemStack itemstack = player.getHeldItem();
|
||||
this.currentItem = itemstack == null ? 0 : ItemRegistry.getId(itemstack.getItem());
|
||||
this.watcher = player.getDataWatcher();
|
||||
this.texture = player.getSkin();
|
||||
|
|
|
@ -10,7 +10,7 @@ import common.init.Items;
|
|||
import common.inventory.Container;
|
||||
import common.inventory.ContainerBrewingStand;
|
||||
import common.inventory.ISidedInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.item.consumable.ItemPotion;
|
||||
|
@ -305,7 +305,7 @@ public class TileEntityBrewingStand extends TileEntityInventory implements ITick
|
|||
return true;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerBrewingStand(playerInventory, this);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import common.collect.Lists;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.ContainerDispenser;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
|
@ -209,7 +209,7 @@ public class TileEntityDispenser extends TileEntityInventory implements ITickabl
|
|||
return true;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerDispenser(playerInventory, this);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import common.inventory.Container;
|
|||
import common.inventory.ContainerFurnace;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.ISidedInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.SlotFurnaceFuel;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
|
@ -432,7 +432,7 @@ public class TileEntityFurnace extends TileEntityInventory implements ITickable,
|
|||
return true;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerFurnace(playerInventory, this);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import common.inventory.Container;
|
|||
import common.inventory.ContainerHopper;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.ISidedInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.tags.TagObject;
|
||||
import common.util.BlockPos;
|
||||
|
@ -702,9 +702,9 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
|
|||
return this.transferCooldown <= 1;
|
||||
}
|
||||
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
|
||||
public Container createContainer(EntityNPC playerInventory)
|
||||
{
|
||||
return new ContainerHopper(playerInventory, this, playerIn);
|
||||
return new ContainerHopper(playerInventory, this, playerInventory);
|
||||
}
|
||||
|
||||
public int getField(int id)
|
||||
|
|
|
@ -3,8 +3,7 @@ package common.tileentity;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.inventory.Container;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
|
||||
public abstract class TileEntityInventory extends TileEntity implements IInventory {
|
||||
public abstract Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn);
|
||||
public abstract Container createContainer(EntityNPC player);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package common.util;
|
||||
|
||||
import common.enchantment.EnchantmentType;
|
||||
import common.entity.animal.EntityHorse;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.ToolMaterial;
|
||||
|
||||
public enum Equipment implements Identifyable, Displayable {
|
||||
|
@ -8,13 +10,16 @@ public enum Equipment implements Identifyable, Displayable {
|
|||
AXE("axe", "Axt", ItemType.TOOL, 3, "XX", "X#", " #"),
|
||||
SHOVEL("shovel", "Schaufel", ItemType.TOOL, 1, "X", "#", "#"),
|
||||
SHEARS("shears", "Schere", ItemType.OPTIONAL, " X", "X "),
|
||||
|
||||
SWORD("sword", "Schwert", ItemType.MELEE, 4, "X", "X", "#"),
|
||||
|
||||
HELMET("helmet", "Helm", "Kappe", 11, 0, EnchantmentType.ARMOR_HEAD, 1.0f, 1.0f, "XXX", "X X"),
|
||||
CHESTPLATE("chestplate", "Brustpanzer", "Jacke", 16, 1, EnchantmentType.ARMOR_TORSO, 1.7f, 1.2f, "X X", "XXX", "XXX"),
|
||||
LEGGINGS("leggings", "Beinschutz", "Hose", 15, 2, EnchantmentType.ARMOR_LEGS, 1.6f, 1.1f, "XXX", "X X", "X X"),
|
||||
BOOTS("boots", "Stiefel", "Stiefel", 13, 3, EnchantmentType.ARMOR_FEET, 1.4f, 1.0f, "X X", "X X"),
|
||||
HORSE_ARMOR("horse_armor", "Pferderüstung", ItemType.ANIMAL, 16, "X X", "XXX", "XXX");
|
||||
|
||||
HORSE_ARMOR("horse_armor", "Pferderüstung", EntityHorse.class, "X X", "XXX", "XXX");
|
||||
|
||||
public static final int ARMOR_SLOTS;
|
||||
public static final Equipment[] ARMOR;
|
||||
|
||||
|
@ -28,7 +33,8 @@ public enum Equipment implements Identifyable, Displayable {
|
|||
private final float phyResist;
|
||||
private final float magicResist;
|
||||
private final EnchantmentType enchType;
|
||||
|
||||
private final Class<? extends EntityLiving> animalType;
|
||||
|
||||
static {
|
||||
int slots = 0;
|
||||
for(Equipment slot : values()) {
|
||||
|
@ -43,33 +49,38 @@ public enum Equipment implements Identifyable, Displayable {
|
|||
}
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, String altDisplay, ItemType type, int damage, int index, EnchantmentType ench, float phy, float mag, String ... recipe) {
|
||||
private Equipment(String name, String display, String alt, ItemType type, int dmg, int index, EnchantmentType ench, float phy, float mag, Class<? extends EntityLiving> clazz, String... recipe) {
|
||||
this.name = name;
|
||||
this.display = display;
|
||||
this.altDisplay = altDisplay;
|
||||
this.altDisplay = alt;
|
||||
this.type = type;
|
||||
this.damage = damage;
|
||||
this.damage = dmg;
|
||||
this.recipe = recipe;
|
||||
this.index = index;
|
||||
this.phyResist = phy;
|
||||
this.magicResist = mag;
|
||||
this.enchType = ench;
|
||||
this.animalType = clazz;
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, ItemType type, int damage, String ... recipe) {
|
||||
this(name, display, null, type, damage, -1, null, 0.0f, 0.0f, recipe);
|
||||
private Equipment(String name, String display, ItemType type, int damage, String... recipe) {
|
||||
this(name, display, null, type, damage, -1, null, 0.0f, 0.0f, null, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, ItemType type, String ... recipe) {
|
||||
private Equipment(String name, String display, ItemType type, String... recipe) {
|
||||
this(name, display, type, -1, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, String altDisplay, int damage, int index, EnchantmentType ench, float rad, float mag, String ... recipe) {
|
||||
this(name, display, altDisplay, ItemType.ARMOR, damage, index, ench, rad, mag, recipe);
|
||||
private Equipment(String name, String display, Class<? extends EntityLiving> clazz, String... recipe) {
|
||||
this(name, display, null, ItemType.ANIMAL, -1, -1, null, 0.0f, 0.0f, clazz, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, int damage, int index, EnchantmentType ench, float rad, float mag, String ... recipe) {
|
||||
this(name, display, null, ItemType.AUX, damage, index, ench, rad, mag, recipe);
|
||||
private Equipment(String name, String display, String altDisplay, int damage, int index, EnchantmentType ench, float phy, float mag, String... recipe) {
|
||||
this(name, display, altDisplay, ItemType.ARMOR, damage, index, ench, phy, mag, null, recipe);
|
||||
}
|
||||
|
||||
private Equipment(String name, String display, int damage, int index, EnchantmentType ench, float mag, String... recipe) {
|
||||
this(name, display, null, ItemType.AUX, damage, index, ench, 0.0f, mag, null, recipe);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -88,47 +99,48 @@ public enum Equipment implements Identifyable, Displayable {
|
|||
String display = alt && this.altDisplay != null ? this.altDisplay : this.display;
|
||||
return prefix == null ? display : prefix + display.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
public boolean canRegister(ToolMaterial material) {
|
||||
return this.isArmor() ? material.hasArmor() && (!this.isAnimalArmor() || material.hasExtras()) : (this.isMelee() ? material.hasWeapons() : (this.isOptional() ? material.hasExtras() : material.hasTools()));
|
||||
return this.isArmor() ? material.hasArmor() && (!this.isAnimalArmor() || material.hasExtras())
|
||||
: (this.isMelee() ? material.hasWeapons() : (this.isOptional() ? material.hasExtras() : material.hasTools()));
|
||||
}
|
||||
|
||||
|
||||
public ItemType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
public boolean isLevelled() {
|
||||
return this.type == ItemType.LEVELLED;
|
||||
}
|
||||
|
||||
|
||||
public boolean isMelee() {
|
||||
return this.type == ItemType.MELEE;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOptional() {
|
||||
return this.type == ItemType.OPTIONAL;
|
||||
}
|
||||
|
||||
|
||||
public boolean isArmor() {
|
||||
return this.type == ItemType.ARMOR || this.type == ItemType.AUX || this.type == ItemType.ANIMAL;
|
||||
}
|
||||
|
||||
public boolean isArmorRendered() {
|
||||
|
||||
public boolean isMainArmor() {
|
||||
return this.type == ItemType.ARMOR || this.type == ItemType.ANIMAL;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAnimalArmor() {
|
||||
return this.type == ItemType.ANIMAL;
|
||||
}
|
||||
|
||||
|
||||
public int getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
|
||||
public String[] getRecipe() {
|
||||
return this.recipe;
|
||||
}
|
||||
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
@ -140,8 +152,12 @@ public enum Equipment implements Identifyable, Displayable {
|
|||
public float getMagicalResistance() {
|
||||
return this.magicResist;
|
||||
}
|
||||
|
||||
|
||||
public EnchantmentType getEnchantmentType() {
|
||||
return this.enchType;
|
||||
}
|
||||
|
||||
public Class<? extends EntityLiving> getAnimalType() {
|
||||
return this.animalType;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue