add slots

This commit is contained in:
Sen 2025-08-02 12:39:17 +02:00
parent 3396dd73b2
commit ad83255833
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
11 changed files with 185 additions and 115 deletions

View file

@ -128,6 +128,12 @@ public class RenderItem
case BOOTS: case BOOTS:
offset = 1.7f; offset = 1.7f;
break; break;
case CROWN:
offset = 0.0f;
break;
case SHIELD:
offset = 0.0f;
break;
} }
GL11.glTranslatef(1.0f, offset, 0.0f); GL11.glTranslatef(1.0f, offset, 0.0f);
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f); GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
@ -135,7 +141,12 @@ public class RenderItem
boolean cull = GlState.isCullEnabled(); boolean cull = GlState.isCullEnabled();
if(cull) if(cull)
GlState.disableCull(); 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) if(cull)
GlState.enableCull(); GlState.enableCull();
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -1,7 +1,7 @@
package client.renderer.layers; package client.renderer.layers;
import client.renderer.entity.RendererLivingEntity; import client.renderer.entity.RendererLivingEntity;
import client.renderer.model.ModelBiped; import client.renderer.model.ModelArmor;
import common.util.Equipment; import common.util.Equipment;
public class LayerArachnoidArmor extends LayerArmor { public class LayerArachnoidArmor extends LayerArmor {
@ -9,12 +9,10 @@ public class LayerArachnoidArmor extends LayerArmor {
super(rendererIn, 12, 12); super(rendererIn, 12, 12);
} }
protected void setModelPartVisible(ModelBiped model, Equipment slot) { protected void setModelPartVisible(ModelArmor model, Equipment slot) {
switch(slot) { switch(slot) {
case CHESTPLATE: case CHESTPLATE:
case HELMET: case HELMET:
super.setModelPartVisible(model, slot);
break;
default: default:
model.setVisible(false); model.setVisible(false);
break; break;

View file

@ -8,7 +8,6 @@ import client.Client;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.entity.RendererLivingEntity; import client.renderer.entity.RendererLivingEntity;
import client.renderer.model.ModelArmor; import client.renderer.model.ModelArmor;
import client.renderer.model.ModelBiped;
import common.collect.Lists; import common.collect.Lists;
import common.enchantment.Enchantment; import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper; import common.enchantment.EnchantmentHelper;
@ -182,7 +181,7 @@ public class LayerArmor implements LayerRenderer<EntityNPC>
// this.modelArmor = new ModelBiped(1.0F); // this.modelArmor = new ModelBiped(1.0F);
// } // }
protected void setModelPartVisible(ModelBiped model, Equipment slot) protected void setModelPartVisible(ModelArmor model, Equipment slot)
{ {
model.setVisible(false); model.setVisible(false);
@ -208,6 +207,7 @@ public class LayerArmor implements LayerRenderer<EntityNPC>
case HELMET: case HELMET:
model.bipedHead.showModel = true; model.bipedHead.showModel = true;
model.bipedHeadwear.showModel = true; model.bipedHeadwear.showModel = true;
break;
} }
} }

View file

@ -14,6 +14,9 @@ public enum EnchantmentType
ARMOR_LEGS, ARMOR_LEGS,
ARMOR_TORSO, ARMOR_TORSO,
ARMOR_HEAD, ARMOR_HEAD,
NECKLACE,
RING,
SHIELD,
WEAPON, WEAPON,
DIGGER, DIGGER,
FISHING_ROD, FISHING_ROD,
@ -35,7 +38,7 @@ public enum EnchantmentType
return (this == ARMOR && armor.getArmorType().isMainArmor()) || armor.getArmorType().getEnchantmentType() == this; return (this == ARMOR && armor.getArmorType().isMainArmor()) || armor.getArmorType().getEnchantmentType() == this;
} }
else if(item instanceof ItemTool tool) { else if(item instanceof ItemTool tool) {
return this == DIGGER || (tool.getToolType().isMelee() && this == WEAPON); return this == DIGGER || (tool.getToolType().isWeapon() && this == WEAPON);
} }
else else
{ {

View file

@ -1353,78 +1353,82 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
ItemStack stack = itemEntity.getEntityItem(); ItemStack stack = itemEntity.getEntityItem();
if(stack.getItem().getRadiation(stack) > 0.0f) if(stack.getItem().getRadiation(stack) > 0.0f)
return; 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; for(Equipment slot : slots) {
ItemStack old = slot == null ? this.getHeldItem() : this.getArmor(slot); boolean flag = true;
ItemStack old = slot == null ? this.getHeldItem() : this.getArmor(slot);
if(old != null) {
if(slot == null) { if(old != null) {
if(stack.getItem() instanceof ItemTool t1 && t1.getToolType().isMelee() && !(old.getItem() instanceof ItemTool t2 && t2.getToolType().isMelee())) { 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; flag = true;
} }
else if(stack.getItem() instanceof ItemTool itemsword && itemsword.getToolType().isMelee() && old.getItem() instanceof ItemTool itemsword1 && itemsword1.getToolType().isMelee()) { else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) {
if(itemsword.getAttackDamageBonus(stack) != itemsword1.getAttackDamageBonus(old)) { ItemArmor itemarmor = (ItemArmor)stack.getItem();
flag = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old); ItemArmor itemarmor1 = (ItemArmor)old.getItem();
if(itemarmor.getArmorValue() != itemarmor1.getArmorValue()) {
flag = itemarmor.getArmorValue() > itemarmor1.getArmorValue();
} }
else { else {
flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted(); 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 { else {
flag = false; flag = false;
} }
} }
else if(stack.getItem() instanceof ItemArmor && !(old.getItem() instanceof ItemArmor)) {
flag = true; if(flag) { // && this.canPickUpItem(stack)) {
} if(old != null) { // && this.rand.floatv() - 0.1F < this.dropChances[slot]) {
else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) { this.entityDropItem(old, 0.0F);
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(); // if(stack.getItem() == Items.diamond && itemEntity.getThrower() != null) {
} // EntityNPC entityplayer = this.worldObj.getPlayer(itemEntity.getThrower());
} //
else { // if(entityplayer != null) {
flag = false; // 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) { if(!itemEntity.dead) {
stack = itemEntity.getEntityItem(); stack = itemEntity.getEntityItem();
Item item = stack.getItem(); Item item = stack.getItem();
@ -3802,7 +3806,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
for (Equipment slot : Equipment.ARMOR) for (Equipment slot : Equipment.ARMOR)
{ {
ItemStack stack = this.getArmor(slot); 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); stack.damage(damage, this);
if (stack.isEmpty()) if (stack.isEmpty())
@ -4498,12 +4502,20 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
if(!this.isPlayer()) { if(!this.isPlayer()) {
if(info.items != null) { if(info.items != null) {
for(ItemStack stack : info.items) { for(ItemStack stack : info.items) {
if(stack.getItem() instanceof ItemArmor) if(stack.getItem() instanceof ItemArmor armor) {
this.setArmor(((ItemArmor)stack.getItem()).getArmorType(), stack); for(Equipment slot : armor.getArmorType().getPossibleSlots()) {
else if(stack.getItem().getWieldType() != null) if(this.getArmor(slot) == null) {
this.setArmor(slot, stack);
break;
}
}
}
else if(stack.getItem().getWieldType() != null) {
this.setHeldItem(stack); this.setHeldItem(stack);
else }
else {
this.addStack(stack); this.addStack(stack);
}
} }
} }
else { else {

View file

@ -44,7 +44,7 @@ public class ContainerPlayer extends Container {
} }
public boolean isItemValid(ItemStack stack) 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; 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) public ItemStack transferStackInSlot(EntityNPC playerIn, int index)
{ {
ItemStack itemstack = null; ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index); Slot slot = (Slot)this.inventorySlots.get(index);
int idx;
if (slot != null && slot.getHasStack()) if (slot != null && slot.getHasStack())
{ {
@ -149,10 +155,8 @@ public class ContainerPlayer extends Container {
return null; 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)) if (!this.mergeItemStack(itemstack1, idx, idx + 1, false))
{ {
return null; return null;

View file

@ -273,7 +273,7 @@ public final class ItemStack {
public Map<Attribute, Float> getArmorModifiers(Equipment slot) { public Map<Attribute, Float> getArmorModifiers(Equipment slot) {
Map<Attribute, Float> map = Maps.newEnumMap(Attribute.class); Map<Attribute, Float> 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); armor.getArmorModifiers(map);
return map; return map;
} }

View file

@ -76,11 +76,12 @@ public class ItemArmor extends Item {
} }
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) {
ItemStack itemstack = playerIn.getArmor(this.type); for(Equipment slot : this.type.getPossibleSlots()) {
if(playerIn.getArmor(slot) == null) {
if(itemstack == null) { playerIn.setArmor(slot, itemStackIn.copy(1));
playerIn.setArmor(this.type, itemStackIn.copy()); itemStackIn.decrSize();
itemStackIn.decrSize(); return itemStackIn;
}
} }
return itemStackIn; return itemStackIn;
@ -95,7 +96,7 @@ public class ItemArmor extends Item {
@Clientside @Clientside
public boolean hasBuiltinModel() { public boolean hasBuiltinModel() {
return this.type.isMainArmor(); return this.type.isRenderedLayer();
} }
@Serverside @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)); 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>() { List<EntityNPC> list = world.<EntityNPC>getEntitiesWithinAABB(EntityNPC.class, axisalignedbb, new Predicate<EntityNPC>() {
public boolean test(EntityNPC entity) { 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) { if(list.size() > 0) {
EntityNPC entitylivingbase = list.get(0); EntityNPC entitylivingbase = list.get(0);
entitylivingbase.setArmor(this.type, stack.copy(1)); for(Equipment slot : this.type.getPossibleSlots()) {
stack.decrSize(); if(entitylivingbase.getArmor(slot) == null) {
return stack; entitylivingbase.setArmor(slot, stack.copy(1));
} stack.decrSize();
else { return stack;
return super.dispenseStack(world, source, position, blockpos, facing, stack); }
}
} }
return super.dispenseStack(world, source, position, blockpos, facing, stack);
} }
} }

View file

@ -26,7 +26,7 @@ public class ItemTool extends Item {
this.material = material; this.material = material;
this.type = type; this.type = type;
this.setMaxDamage(material.getDurability()); 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()) if(this.material.isMagnetic())
this.setMagnetic(); this.setMagnetic();
} }
@ -47,7 +47,7 @@ public class ItemTool extends Item {
} }
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { 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; return true;
} }
@ -78,15 +78,15 @@ public class ItemTool extends Item {
} }
public ItemAction getItemUseAction() { public ItemAction getItemUseAction() {
return this.type.isMelee() ? ItemAction.BLOCK : super.getItemUseAction(); return this.type.isWeapon() ? ItemAction.BLOCK : super.getItemUseAction();
} }
public int getMaxItemUseDuration(ItemStack stack) { 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) { public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) {
if(this.type.isMelee()) if(this.type.isWeapon())
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn)); playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn; return itemStackIn;
} }

View file

@ -6,17 +6,26 @@ import common.entity.types.EntityLiving;
import common.init.ToolMaterial; import common.init.ToolMaterial;
public enum Equipment implements Identifyable, Displayable { public enum Equipment implements Identifyable, Displayable {
PICKAXE("pickaxe", "Spitzhacke", ItemType.LEVELLED, 2, "XXX", " # ", " # "), PICKAXE("pickaxe", "Spitzhacke", ItemType.HARVEST_LEVELLED, 2, "XXX", " # ", " # "),
AXE("axe", "Axt", ItemType.TOOL, 3, "XX", "X#", " #"), AXE("axe", "Axt", ItemType.HARVEST_BASIC, 3, "XX", "X#", " #"),
SHOVEL("shovel", "Schaufel", ItemType.TOOL, 1, "X", "#", "#"), SHOVEL("shovel", "Schaufel", ItemType.HARVEST_BASIC, 1, "X", "#", "#"),
SHEARS("shears", "Schere", ItemType.OPTIONAL, " X", "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"), 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"), 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"), 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"), 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"); 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<? extends EntityLiving> clazz, String... 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); 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) { 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) { private Equipment(String name, String display, int damage, int index, EnchantmentType ench, float mag) {
this(name, display, null, ItemType.AUX, damage, index, ench, 0.0f, mag, null, recipe); 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() { public String toString() {
@ -101,8 +114,8 @@ public enum Equipment implements Identifyable, Displayable {
} }
public boolean canRegister(ToolMaterial material) { public boolean canRegister(ToolMaterial material) {
return this.isArmor() ? material.hasArmor() && (!this.isAnimalArmor() || material.hasExtras()) return !this.isAccessory() && (this.isArmor() ? material.hasArmor() && (!this.isAnimalArmor() || material.hasExtras())
: (this.isMelee() ? material.hasWeapons() : (this.isOptional() ? material.hasExtras() : material.hasTools())); : (this.isWeapon() ? material.hasWeapons() : (this.isOptional() ? material.hasExtras() : material.hasTools())));
} }
public ItemType getType() { public ItemType getType() {
@ -110,27 +123,39 @@ public enum Equipment implements Identifyable, Displayable {
} }
public boolean isLevelled() { public boolean isLevelled() {
return this.type == ItemType.LEVELLED; return this.type == ItemType.HARVEST_LEVELLED;
} }
public boolean isMelee() { public boolean isWeapon() {
return this.type == ItemType.MELEE; return this.type == ItemType.MELEE_WEAPON;
} }
public boolean isOptional() { public boolean isOptional() {
return this.type == ItemType.OPTIONAL; return this.type == ItemType.HARVEST_OPTIONAL;
} }
public boolean isArmor() { 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() { 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() { 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() { public int getDamage() {
@ -160,4 +185,12 @@ public enum Equipment implements Identifyable, Displayable {
public Class<? extends EntityLiving> getAnimalType() { public Class<? extends EntityLiving> getAnimalType() {
return this.animalType; 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());
}
} }

View file

@ -1,5 +1,5 @@
package common.util; package common.util;
public enum ItemType { 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;
} }