diff --git a/client/src/main/java/client/renderer/entity/RenderItem.java b/client/src/main/java/client/renderer/entity/RenderItem.java index bb6412c3..a3f86ae1 100755 --- a/client/src/main/java/client/renderer/entity/RenderItem.java +++ b/client/src/main/java/client/renderer/entity/RenderItem.java @@ -128,6 +128,12 @@ public class RenderItem case BOOTS: offset = 1.7f; break; + case CROWN: + offset = 0.0f; + break; + case SHIELD: + offset = 0.0f; + break; } GL11.glTranslatef(1.0f, offset, 0.0f); GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f); @@ -135,7 +141,12 @@ public class RenderItem boolean cull = GlState.isCullEnabled(); if(cull) GlState.disableCull(); - this.armor.doRenderLayer(null, 0.0f, 0.0f, 0.0f, 0, 0, 0.0f, 0.0625F); + if(armor.getArmorType().isMainArmor()) + this.armor.doRenderLayer(null, 0.0f, 0.0f, 0.0f, 0, 0, 0.0f, 0.0625F); +// else if(armor.getArmorType() == Equipment.CROWN) +// +// else if(armor.getArmorType() == Equipment.SHIELD) +// if(cull) GlState.enableCull(); GL11.glPopMatrix(); diff --git a/client/src/main/java/client/renderer/layers/LayerArachnoidArmor.java b/client/src/main/java/client/renderer/layers/LayerArachnoidArmor.java index 60d36c80..7e9f2eec 100755 --- a/client/src/main/java/client/renderer/layers/LayerArachnoidArmor.java +++ b/client/src/main/java/client/renderer/layers/LayerArachnoidArmor.java @@ -1,7 +1,7 @@ package client.renderer.layers; import client.renderer.entity.RendererLivingEntity; -import client.renderer.model.ModelBiped; +import client.renderer.model.ModelArmor; import common.util.Equipment; public class LayerArachnoidArmor extends LayerArmor { @@ -9,12 +9,10 @@ public class LayerArachnoidArmor extends LayerArmor { super(rendererIn, 12, 12); } - protected void setModelPartVisible(ModelBiped model, Equipment slot) { + protected void setModelPartVisible(ModelArmor model, Equipment slot) { switch(slot) { case CHESTPLATE: case HELMET: - super.setModelPartVisible(model, slot); - break; default: model.setVisible(false); break; diff --git a/client/src/main/java/client/renderer/layers/LayerArmor.java b/client/src/main/java/client/renderer/layers/LayerArmor.java index 1202038f..bf748b57 100755 --- a/client/src/main/java/client/renderer/layers/LayerArmor.java +++ b/client/src/main/java/client/renderer/layers/LayerArmor.java @@ -8,7 +8,6 @@ import client.Client; import client.renderer.GlState; import client.renderer.entity.RendererLivingEntity; import client.renderer.model.ModelArmor; -import client.renderer.model.ModelBiped; import common.collect.Lists; import common.enchantment.Enchantment; import common.enchantment.EnchantmentHelper; @@ -182,7 +181,7 @@ public class LayerArmor implements LayerRenderer // this.modelArmor = new ModelBiped(1.0F); // } - protected void setModelPartVisible(ModelBiped model, Equipment slot) + protected void setModelPartVisible(ModelArmor model, Equipment slot) { model.setVisible(false); @@ -208,6 +207,7 @@ public class LayerArmor implements LayerRenderer case HELMET: model.bipedHead.showModel = true; model.bipedHeadwear.showModel = true; + break; } } diff --git a/common/src/main/java/common/enchantment/EnchantmentType.java b/common/src/main/java/common/enchantment/EnchantmentType.java index 7013cb50..9089c930 100755 --- a/common/src/main/java/common/enchantment/EnchantmentType.java +++ b/common/src/main/java/common/enchantment/EnchantmentType.java @@ -14,6 +14,9 @@ public enum EnchantmentType ARMOR_LEGS, ARMOR_TORSO, ARMOR_HEAD, + NECKLACE, + RING, + SHIELD, WEAPON, DIGGER, FISHING_ROD, @@ -35,7 +38,7 @@ public enum EnchantmentType return (this == ARMOR && armor.getArmorType().isMainArmor()) || armor.getArmorType().getEnchantmentType() == this; } else if(item instanceof ItemTool tool) { - return this == DIGGER || (tool.getToolType().isMelee() && this == WEAPON); + return this == DIGGER || (tool.getToolType().isWeapon() && this == WEAPON); } else { diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index f69d037a..42476cfc 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -1353,78 +1353,82 @@ public abstract class EntityNPC extends EntityLiving implements IInventory ItemStack stack = itemEntity.getEntityItem(); if(stack.getItem().getRadiation(stack) > 0.0f) return; - Equipment slot = stack.getItem() instanceof ItemArmor armor ? armor.getArmorType() : null; + Equipment[] slots = stack.getItem() instanceof ItemArmor armor ? armor.getArmorType().getPossibleSlots() : new Equipment[] {null}; - boolean flag = true; - ItemStack old = slot == null ? this.getHeldItem() : this.getArmor(slot); - - if(old != null) { - if(slot == null) { - if(stack.getItem() instanceof ItemTool t1 && t1.getToolType().isMelee() && !(old.getItem() instanceof ItemTool t2 && t2.getToolType().isMelee())) { + for(Equipment slot : slots) { + boolean flag = true; + ItemStack old = slot == null ? this.getHeldItem() : this.getArmor(slot); + + if(old != null) { + if(slot == null) { + if(stack.getItem() instanceof ItemTool t1 && t1.getToolType().isWeapon() && !(old.getItem() instanceof ItemTool t2 && t2.getToolType().isWeapon())) { + flag = true; + } + else if(stack.getItem() instanceof ItemTool itemsword && itemsword.getToolType().isWeapon() && old.getItem() instanceof ItemTool itemsword1 && itemsword1.getToolType().isWeapon()) { + if(itemsword.getAttackDamageBonus(stack) != itemsword1.getAttackDamageBonus(old)) { + flag = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old); + } + else { + flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted(); + } + } + else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) { + flag = stack.isItemEnchanted() && !old.isItemEnchanted(); + } + else if(stack.getItem() instanceof ItemGunBase && !(old.getItem() instanceof ItemBow)) { + flag = true; + } + else if(stack.getItem() instanceof ItemBow && !(old.getItem() instanceof ItemBow) && !(old.getItem() instanceof ItemTool tool && tool.getToolType().isWeapon())) { + flag = true; + } + else { + flag = false; + } + } + else if(stack.getItem() instanceof ItemArmor && !(old.getItem() instanceof ItemArmor)) { flag = true; } - else if(stack.getItem() instanceof ItemTool itemsword && itemsword.getToolType().isMelee() && old.getItem() instanceof ItemTool itemsword1 && itemsword1.getToolType().isMelee()) { - if(itemsword.getAttackDamageBonus(stack) != itemsword1.getAttackDamageBonus(old)) { - flag = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old); + else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) { + ItemArmor itemarmor = (ItemArmor)stack.getItem(); + ItemArmor itemarmor1 = (ItemArmor)old.getItem(); + + if(itemarmor.getArmorValue() != itemarmor1.getArmorValue()) { + flag = itemarmor.getArmorValue() > itemarmor1.getArmorValue(); } else { flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted(); } } - else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) { - flag = stack.isItemEnchanted() && !old.isItemEnchanted(); - } - else if(stack.getItem() instanceof ItemGunBase && !(old.getItem() instanceof ItemBow)) { - flag = true; - } - else if(stack.getItem() instanceof ItemBow && !(old.getItem() instanceof ItemBow) && !(old.getItem() instanceof ItemTool tool && tool.getToolType().isMelee())) { - flag = true; - } else { flag = false; } } - else if(stack.getItem() instanceof ItemArmor && !(old.getItem() instanceof ItemArmor)) { - flag = true; - } - else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) { - ItemArmor itemarmor = (ItemArmor)stack.getItem(); - ItemArmor itemarmor1 = (ItemArmor)old.getItem(); - - if(itemarmor.getArmorValue() != itemarmor1.getArmorValue()) { - flag = itemarmor.getArmorValue() > itemarmor1.getArmorValue(); + + if(flag) { // && this.canPickUpItem(stack)) { + if(old != null) { // && this.rand.floatv() - 0.1F < this.dropChances[slot]) { + this.entityDropItem(old, 0.0F); } - else { - flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted(); - } - } - else { - flag = false; + + // if(stack.getItem() == Items.diamond && itemEntity.getThrower() != null) { + // EntityNPC entityplayer = this.worldObj.getPlayer(itemEntity.getThrower()); + // + // if(entityplayer != null) { + // entityplayer.triggerAchievement(AchievementList.diamondsToYou); + // } + // } + + if(slot == null) + this.setHeldItem(stack); + else + this.setArmor(slot, stack); + // this.dropChances[slot] = 2.0F; + // this.noDespawn = true; + this.onItemPickup(itemEntity, 1); + itemEntity.setDead(); + break; } } - - if(flag) { // && this.canPickUpItem(stack)) { - if(old != null) { // && this.rand.floatv() - 0.1F < this.dropChances[slot]) { - this.entityDropItem(old, 0.0F); - } - -// if(stack.getItem() == Items.diamond && itemEntity.getThrower() != null) { -// EntityNPC entityplayer = this.worldObj.getPlayer(itemEntity.getThrower()); -// -// if(entityplayer != null) { -// entityplayer.triggerAchievement(AchievementList.diamondsToYou); -// } -// } - - if(slot == null) - this.setHeldItem(stack); - else - this.setArmor(slot, stack); -// this.dropChances[slot] = 2.0F; -// this.noDespawn = true; - this.onItemPickup(itemEntity, 1); - itemEntity.setDead(); - } + if(!itemEntity.dead) { stack = itemEntity.getEntityItem(); Item item = stack.getItem(); @@ -3802,7 +3806,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory for (Equipment slot : Equipment.ARMOR) { ItemStack stack = this.getArmor(slot); - if (stack != null && stack.getItem() instanceof ItemArmor) + if (stack != null && stack.getItem() instanceof ItemArmor && stack.isItemStackDamageable()) { stack.damage(damage, this); if (stack.isEmpty()) @@ -4498,12 +4502,20 @@ public abstract class EntityNPC extends EntityLiving implements IInventory if(!this.isPlayer()) { if(info.items != null) { for(ItemStack stack : info.items) { - if(stack.getItem() instanceof ItemArmor) - this.setArmor(((ItemArmor)stack.getItem()).getArmorType(), stack); - else if(stack.getItem().getWieldType() != null) + if(stack.getItem() instanceof ItemArmor armor) { + for(Equipment slot : armor.getArmorType().getPossibleSlots()) { + if(this.getArmor(slot) == null) { + this.setArmor(slot, stack); + break; + } + } + } + else if(stack.getItem().getWieldType() != null) { this.setHeldItem(stack); - else + } + else { this.addStack(stack); + } } } else { diff --git a/common/src/main/java/common/inventory/ContainerPlayer.java b/common/src/main/java/common/inventory/ContainerPlayer.java index faf8c1db..00064d97 100755 --- a/common/src/main/java/common/inventory/ContainerPlayer.java +++ b/common/src/main/java/common/inventory/ContainerPlayer.java @@ -44,7 +44,7 @@ public class ContainerPlayer extends Container { } public boolean isItemValid(ItemStack stack) { - return stack != null && stack.getItem() instanceof ItemArmor armor && armor.getArmorType() == type; + return stack != null && stack.getItem() instanceof ItemArmor armor && armor.getArmorType().canUseInSlot(type); } }); } @@ -112,14 +112,20 @@ public class ContainerPlayer extends Container { { return true; } + + private int getFreeSlotFor(Equipment type) { + for(Equipment slot : type.getPossibleSlots()) { + if(!this.inventorySlots.get(5 + slot.getIndex()).getHasStack()) + return 5 + slot.getIndex(); + } + return -1; + } - /** - * Take a stack from the specified inventory slot. - */ public ItemStack transferStackInSlot(EntityNPC playerIn, int index) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(index); + int idx; if (slot != null && slot.getHasStack()) { @@ -149,10 +155,8 @@ public class ContainerPlayer extends Container { return null; } } - else if (itemstack.getItem() instanceof ItemArmor armor && !((Slot)this.inventorySlots.get(5 + armor.getArmorType().getIndex())).getHasStack()) + else if (itemstack.getItem() instanceof ItemArmor armor && (idx = this.getFreeSlotFor(armor.getArmorType())) >= 0) { - int idx = 5 + armor.getArmorType().getIndex(); - if (!this.mergeItemStack(itemstack1, idx, idx + 1, false)) { return null; diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index 592b71d9..99ec03f9 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -273,7 +273,7 @@ public final class ItemStack { public Map getArmorModifiers(Equipment slot) { Map map = Maps.newEnumMap(Attribute.class); - if(this.item instanceof ItemArmor armor && (slot == null || armor.getArmorType() == slot)) + if(this.item instanceof ItemArmor armor && (slot == null || armor.getArmorType().canUseInSlot(slot))) armor.getArmorModifiers(map); return map; } diff --git a/common/src/main/java/common/item/material/ItemArmor.java b/common/src/main/java/common/item/material/ItemArmor.java index 9573a137..2bf188eb 100755 --- a/common/src/main/java/common/item/material/ItemArmor.java +++ b/common/src/main/java/common/item/material/ItemArmor.java @@ -76,11 +76,12 @@ public class ItemArmor extends Item { } 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(); + for(Equipment slot : this.type.getPossibleSlots()) { + if(playerIn.getArmor(slot) == null) { + playerIn.setArmor(slot, itemStackIn.copy(1)); + itemStackIn.decrSize(); + return itemStackIn; + } } return itemStackIn; @@ -95,7 +96,7 @@ public class ItemArmor extends Item { @Clientside public boolean hasBuiltinModel() { - return this.type.isMainArmor(); + return this.type.isRenderedLayer(); } @Serverside @@ -107,18 +108,26 @@ public class ItemArmor extends Item { BoundingBox axisalignedbb = new BoundingBox((double)i, (double)j, (double)k, (double)(i + 1), (double)(j + 1), (double)(k + 1)); List list = world.getEntitiesWithinAABB(EntityNPC.class, axisalignedbb, new Predicate() { public boolean test(EntityNPC entity) { - return entity.isEntityAlive() && entity.getArmor(ItemArmor.this.type) == null; + if(!entity.isEntityAlive()) + return false; + for(Equipment slot : ItemArmor.this.type.getPossibleSlots()) { + if(entity.getArmor(slot) == null) + return true; + } + return false; } }); 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); + for(Equipment slot : this.type.getPossibleSlots()) { + if(entitylivingbase.getArmor(slot) == null) { + entitylivingbase.setArmor(slot, stack.copy(1)); + stack.decrSize(); + return stack; + } + } } + return super.dispenseStack(world, source, position, blockpos, facing, stack); } } diff --git a/common/src/main/java/common/item/tool/ItemTool.java b/common/src/main/java/common/item/tool/ItemTool.java index 22caea09..261cfa8f 100755 --- a/common/src/main/java/common/item/tool/ItemTool.java +++ b/common/src/main/java/common/item/tool/ItemTool.java @@ -26,7 +26,7 @@ public class ItemTool extends Item { this.material = material; this.type = type; this.setMaxDamage(material.getDurability()); - this.setTab(this.type.isMelee() ? CheatTab.WEAPONS : CheatTab.TOOLS); + this.setTab(this.type.isWeapon() ? CheatTab.WEAPONS : CheatTab.TOOLS); if(this.material.isMagnetic()) this.setMagnetic(); } @@ -47,7 +47,7 @@ public class ItemTool extends Item { } public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { - stack.damage(this.type.isMelee() ? 1 : 2, attacker); + stack.damage(this.type.isWeapon() ? 1 : 2, attacker); return true; } @@ -78,15 +78,15 @@ public class ItemTool extends Item { } public ItemAction getItemUseAction() { - return this.type.isMelee() ? ItemAction.BLOCK : super.getItemUseAction(); + return this.type.isWeapon() ? ItemAction.BLOCK : super.getItemUseAction(); } public int getMaxItemUseDuration(ItemStack stack) { - return this.type.isMelee() ? 72000 : super.getMaxItemUseDuration(stack); + return this.type.isWeapon() ? 72000 : super.getMaxItemUseDuration(stack); } public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { - if(this.type.isMelee()) + if(this.type.isWeapon()) playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); return itemStackIn; } diff --git a/common/src/main/java/common/util/Equipment.java b/common/src/main/java/common/util/Equipment.java index 0c27f1c9..9d9477a0 100644 --- a/common/src/main/java/common/util/Equipment.java +++ b/common/src/main/java/common/util/Equipment.java @@ -6,17 +6,26 @@ import common.entity.types.EntityLiving; import common.init.ToolMaterial; public enum Equipment implements Identifyable, Displayable { - PICKAXE("pickaxe", "Spitzhacke", ItemType.LEVELLED, 2, "XXX", " # ", " # "), - AXE("axe", "Axt", ItemType.TOOL, 3, "XX", "X#", " #"), - SHOVEL("shovel", "Schaufel", ItemType.TOOL, 1, "X", "#", "#"), - SHEARS("shears", "Schere", ItemType.OPTIONAL, " X", "X "), + PICKAXE("pickaxe", "Spitzhacke", ItemType.HARVEST_LEVELLED, 2, "XXX", " # ", " # "), + AXE("axe", "Axt", ItemType.HARVEST_BASIC, 3, "XX", "X#", " #"), + SHOVEL("shovel", "Schaufel", ItemType.HARVEST_BASIC, 1, "X", "#", "#"), + SHEARS("shears", "Schere", ItemType.HARVEST_OPTIONAL, " X", "X "), - SWORD("sword", "Schwert", ItemType.MELEE, 4, "X", "X", "#"), + SWORD("sword", "Schwert", ItemType.MELEE_WEAPON, 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"), + + CROWN("crown", "Krone", 0, 4, null, 0.3f, 1.0f), + RING_LEFT_A("ring_left_A", "Linker Ring 1", 0, 5, EnchantmentType.RING, 1.0f), + RING_LEFT_B("ring_left_b", "Linker Ring 2", 0, 6, EnchantmentType.RING, 1.0f), + SHIELD("shield", "Schild", 12, 7, EnchantmentType.SHIELD, 0.7f, 1.0f), + NECKLACE("necklace", "Halskette", 0, 8, EnchantmentType.NECKLACE, 1.0f), + RING_RIGHT_A("ring_right_a", "Rechter Ring 1", 0, 9, EnchantmentType.RING, 1.0f), + RING_RIGHT_B("ring_right_a", "Rechter Ring 2", 0, 10, EnchantmentType.RING, 1.0f), + BELT("belt", "Gürtel", 0, 11, null, 1.0f), HORSE_ARMOR("horse_armor", "Pferderüstung", EntityHorse.class, "X X", "XXX", "XXX"); @@ -72,15 +81,19 @@ public enum Equipment implements Identifyable, Displayable { } private Equipment(String name, String display, Class clazz, String... recipe) { - this(name, display, null, ItemType.ANIMAL, -1, -1, null, 0.0f, 0.0f, clazz, recipe); + this(name, display, null, ItemType.ANIMAL_ARMOR, -1, -1, null, 0.0f, 0.0f, clazz, 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); + this(name, display, altDisplay, ItemType.MAIN_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); + private Equipment(String name, String display, int damage, int index, EnchantmentType ench, float mag) { + this(name, display, null, ItemType.ACCESSORY, damage, index, ench, 0.0f, mag, null); + } + + private Equipment(String name, String display, int damage, int index, EnchantmentType ench, float phy, float mag) { + this(name, display, null, ItemType.RENDERED_ACCESSORY, damage, index, ench, phy, mag, null); } public String toString() { @@ -101,8 +114,8 @@ public enum Equipment implements Identifyable, Displayable { } 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.isAccessory() && (this.isArmor() ? material.hasArmor() && (!this.isAnimalArmor() || material.hasExtras()) + : (this.isWeapon() ? material.hasWeapons() : (this.isOptional() ? material.hasExtras() : material.hasTools()))); } public ItemType getType() { @@ -110,27 +123,39 @@ public enum Equipment implements Identifyable, Displayable { } public boolean isLevelled() { - return this.type == ItemType.LEVELLED; + return this.type == ItemType.HARVEST_LEVELLED; } - public boolean isMelee() { - return this.type == ItemType.MELEE; + public boolean isWeapon() { + return this.type == ItemType.MELEE_WEAPON; } public boolean isOptional() { - return this.type == ItemType.OPTIONAL; + return this.type == ItemType.HARVEST_OPTIONAL; } public boolean isArmor() { - return this.type == ItemType.ARMOR || this.type == ItemType.AUX || this.type == ItemType.ANIMAL; + return this.type == ItemType.MAIN_ARMOR || this.type == ItemType.ACCESSORY || this.type == ItemType.RENDERED_ACCESSORY || this.type == ItemType.ANIMAL_ARMOR; } public boolean isMainArmor() { - return this.type == ItemType.ARMOR || this.type == ItemType.ANIMAL; + return this.type == ItemType.MAIN_ARMOR || this.type == ItemType.ANIMAL_ARMOR; + } + + public boolean isRenderedLayer() { + return this.type == ItemType.MAIN_ARMOR || this.type == ItemType.ANIMAL_ARMOR || this.type == ItemType.RENDERED_ACCESSORY; } public boolean isAnimalArmor() { - return this.type == ItemType.ANIMAL; + return this.type == ItemType.ANIMAL_ARMOR; + } + + public boolean isAccessory() { + return this.type == ItemType.ACCESSORY || this.type == ItemType.RENDERED_ACCESSORY; + } + + public boolean isRing() { + return this == RING_LEFT_A || this == RING_LEFT_B || this == RING_RIGHT_A || this == RING_RIGHT_B; } public int getDamage() { @@ -160,4 +185,12 @@ public enum Equipment implements Identifyable, Displayable { public Class getAnimalType() { return this.animalType; } + + public Equipment[] getPossibleSlots() { + return this.isRing() ? new Equipment[] {RING_LEFT_A, RING_LEFT_B, RING_RIGHT_A, RING_RIGHT_B} : new Equipment[] {this}; + } + + public boolean canUseInSlot(Equipment slot) { + return slot == null || !slot.isArmor() || this == slot || (this.isRing() && slot.isRing()); + } } diff --git a/common/src/main/java/common/util/ItemType.java b/common/src/main/java/common/util/ItemType.java index d7ec275d..e65ee37f 100644 --- a/common/src/main/java/common/util/ItemType.java +++ b/common/src/main/java/common/util/ItemType.java @@ -1,5 +1,5 @@ package common.util; public enum ItemType { - TOOL, LEVELLED, OPTIONAL, MELEE, ARMOR, AUX, ANIMAL; + HARVEST_BASIC, HARVEST_LEVELLED, HARVEST_OPTIONAL, MELEE_WEAPON, MAIN_ARMOR, ACCESSORY, RENDERED_ACCESSORY, ANIMAL_ARMOR; }