diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 15968cc..135071b 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1003,7 +1003,7 @@ public class Client implements IThreadListener { int absorb = entity.getAbsorptionAmount(); int armor = entity.getTotalArmorValue(); int stats = 1 + (absorb > 0 ? 1 : 0) + (armor > 0 ? 1 : 0) + (entity.vehicle instanceof EntityLiving ? 1 : 0) - + (entity instanceof EntityNPC && ((EntityNPC)entity).canUseMagic() ? 1 : 0); + + (entity instanceof EntityNPC npc && npc.getManaPoints() > 0 ? 1 : 0); for(Energy energy : Energy.values()) { if(entity.getEnergy(energy) > 0) stats += 1; @@ -1023,9 +1023,9 @@ public class Client implements IThreadListener { int vhMax = living.getMaxHealth(); y = stats(x, y, living.getDisplayName() /* + " (Reittier)" */, vh, vhMax, 0xff6060); } - if(entity instanceof EntityNPC && ((EntityNPC)entity).canUseMagic()) { - int mana = entity.getManaPoints(); - int maxm = entity.getMaxMana(); + if(entity instanceof EntityNPC npc && npc.getManaPoints() > 0) { + int mana = npc.getManaPoints(); + int maxm = npc.getMaxMana(); y = stats(x, y, TextColor.CYAN + "Mana", mana, maxm, 0x0000ff); } for(int z = 0; z < Energy.values().length; z++) { diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index 9540891..3671a57 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -26,10 +26,6 @@ import client.renderer.texture.EntityTexManager; import client.util.PlayerController; import client.world.ChunkClient; import client.world.WorldClient; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; -import common.attributes.AttributeMap; -import common.attributes.AttributeModifier; import common.block.Block; import common.block.tech.BlockWorkbench; import common.dimension.Dimension; @@ -68,7 +64,6 @@ import common.packet.SPacketEntityAttach; import common.packet.SPacketEntityMetadata; import common.packet.SPacketEntityEffect; import common.packet.SPacketRemoveEntityEffect; -import common.packet.SPacketEntityProperties; import common.packet.SPacketExplosion; import common.packet.SPacketEffect; import common.packet.SPacketSoundEffect; @@ -1874,42 +1869,6 @@ public class ClientPlayer implements IClientPlayer } } - /** - * Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player - * sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie - * maxHealth and knockback resistance as well as reinforcement spawning chance. - */ - public void handleEntityProperties(SPacketEntityProperties packetIn) - { - NetHandler.checkThread(packetIn, this, this.gm, this.world); - Entity entity = this.world.getEntityByID(packetIn.getEntityId()); - - if (entity != null) - { - if (!(entity instanceof EntityLiving living)) - throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")"); - AttributeMap baseattributemap = living.getAttributeMap(); - - for (SPacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d()) - { - AttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a()); - - if (iattributeinstance == null) - { - iattributeinstance = baseattributemap.registerAttribute(Attribute.getAttribute(s20packetentityproperties$snapshot.func_151409_a())); - } - - iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b()); - iattributeinstance.removeAllModifiers(); - - for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c()) - { - iattributeinstance.applyModifier(attributemodifier); - } - } - } - } - public void handleSkin(SPacketSkin packetIn) { NetHandler.checkThread(packetIn, this, this.gm, this.world); diff --git a/common/src/main/java/common/ai/EntityAIFindEntityNearest.java b/common/src/main/java/common/ai/EntityAIFindEntityNearest.java index d7e991d..5be7b82 100755 --- a/common/src/main/java/common/ai/EntityAIFindEntityNearest.java +++ b/common/src/main/java/common/ai/EntityAIFindEntityNearest.java @@ -4,8 +4,6 @@ import java.util.Collections; import java.util.List; import java.util.function.Predicate; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; import common.entity.types.EntityLiving; public class EntityAIFindEntityNearest extends EntityAIBase @@ -105,7 +103,6 @@ public class EntityAIFindEntityNearest extends EntityAIBase protected double getFollowRange() { - AttributeInstance iattributeinstance = this.mob.getEntityAttribute(Attribute.FOLLOW_RANGE); - return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue(); + return (double)this.mob.getPathingRange(); } } diff --git a/common/src/main/java/common/ai/EntityAITarget.java b/common/src/main/java/common/ai/EntityAITarget.java index bdd6484..fae31b0 100755 --- a/common/src/main/java/common/ai/EntityAITarget.java +++ b/common/src/main/java/common/ai/EntityAITarget.java @@ -1,7 +1,5 @@ package common.ai; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; import common.entity.types.EntityLiving; import common.entity.types.IEntityOwnable; import common.pathfinding.PathEntity; @@ -107,8 +105,7 @@ public abstract class EntityAITarget extends EntityAIBase protected double getTargetDistance() { - AttributeInstance iattributeinstance = this.taskOwner.getEntityAttribute(Attribute.FOLLOW_RANGE); - return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue(); + return (double)this.taskOwner.getPathingRange(); } /** diff --git a/common/src/main/java/common/ai/EntityMoveHelper.java b/common/src/main/java/common/ai/EntityMoveHelper.java index 03d7742..e5b5e08 100755 --- a/common/src/main/java/common/ai/EntityMoveHelper.java +++ b/common/src/main/java/common/ai/EntityMoveHelper.java @@ -1,6 +1,5 @@ package common.ai; -import common.attributes.Attribute; import common.entity.types.EntityLiving; import common.util.ExtMath; @@ -63,7 +62,7 @@ public class EntityMoveHelper { float f = (float)(ExtMath.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; this.entity.rotYaw = this.limitAngle(this.entity.rotYaw, f, 30.0F); - this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue())); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getMovementSpeed())); if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) { diff --git a/common/src/main/java/common/attributes/Attribute.java b/common/src/main/java/common/attributes/Attribute.java index 384430e..571529a 100755 --- a/common/src/main/java/common/attributes/Attribute.java +++ b/common/src/main/java/common/attributes/Attribute.java @@ -1,78 +1,17 @@ package common.attributes; -import java.util.Map; +public enum Attribute { + RADIATION("Strahlung"), + RADIATION_RESISTANCE("Strahlungsresistenz"), + MAGIC_RESISTANCE("Magieresistenz"); -import common.collect.Maps; -import common.util.Displayable; -import common.util.ExtMath; -import common.util.Identifyable; - -public enum Attribute implements Identifyable, Displayable { - MAX_HEALTH("generic.maxHealth", "Maximale Gesundheit", 20.0D, 0.0D, 1024.0D, true), - FOLLOW_RANGE("generic.followRange", "Kreaturen-Folgedistanz", 32.0D, 0.0D, 2048.0D, false), - KNOCKBACK_RESISTANCE("generic.knockbackResistance", "Standfestigkeit", 0.0D, 0.0D, 1.0D, false), - MOVEMENT_SPEED("generic.movementSpeed", "Geschwindigkeit", 0.699999988079071D, 0.0D, 1024.0D, true), - ATTACK_DAMAGE("generic.attackDamage", "Angriffsschaden", 2.0D, 0.0D, 2048.0D, false), - RADIATION("generic.radiation", "Strahlung", 0.0D, 0.0D, 16384.0D, false), - RADIATION_RESISTANCE("generic.radiationResistance", "Strahlungsresistenz", 10.0D, 0.0D, 16384.0D, false), - MANA_CAPACITY("generic.manaCapacity", "Mana-Kapazität", 0.0D, 0.0D, 2048.0D, false), - MAGIC_RESISTANCE("generic.magicResistance", "Magieresistenz", 0.0D, 0.0D, 4096.0D, false), - REINFORCEMENT_CHANCE("zombie.spawnReinforcements", "Zombie-Verstärkung", 0.0D, 0.0D, 1.0D, false), - HORSE_JUMP_STRENGTH("horse.jumpStrength", "Pferdesprungstärke", 0.7D, 0.0D, 2.0D, true); - - private static final Map ATTRIBUTES = Maps.newHashMap(); - - private final String name; private final String display; - private final double defValue; - private final double minValue; - private final double maxValue; - private final boolean watch; - static { - for(Attribute attr : values()) { - ATTRIBUTES.put(attr.name, attr); - } - } - - public static Attribute getAttribute(String name) { - return ATTRIBUTES.get(name); - } - - private Attribute(String name, String display, double def, double min, double max, boolean watch) { - if(name == null) - throw new IllegalArgumentException("Name kann nicht null sein"); - else if(min > max) - throw new IllegalArgumentException("Mindestwert kann nicht größer als Maximalwert sein"); - else if(def < min) - throw new IllegalArgumentException("Standardwert kann nicht kleiner als Mindestwert sein"); - else if(def > max) - throw new IllegalArgumentException("Standardwert kann nicht größer als Maximalwert sein"); - this.name = name; + private Attribute(String display) { this.display = display; - this.defValue = def; - this.minValue = min; - this.maxValue = max; - this.watch = watch; } - public String getName() { - return this.name; - } - - public String getDisplay() { + public String toString() { return this.display; } - - public double getDefault() { - return this.defValue; - } - - public boolean isWatched() { - return this.watch; - } - - public double clamp(double value) { - return ExtMath.clampd(value, this.minValue, this.maxValue); - } } diff --git a/common/src/main/java/common/attributes/AttributeInstance.java b/common/src/main/java/common/attributes/AttributeInstance.java deleted file mode 100755 index f6f1bb1..0000000 --- a/common/src/main/java/common/attributes/AttributeInstance.java +++ /dev/null @@ -1,191 +0,0 @@ -package common.attributes; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import common.collect.Lists; -import common.collect.Maps; -import common.collect.Sets; - -public class AttributeInstance -{ - private final AttributeMap attributeMap; - private final Attribute genericAttribute; - private final Set additions = Sets.newHashSet(); - private final Set multipliers = Sets.newHashSet(); - private final Map> mapByName = Maps.>newHashMap(); - private final Map mapByID = Maps.newHashMap(); - private double baseValue; - private boolean needsUpdate = true; - private double cachedValue; - - public AttributeInstance(AttributeMap attributeMapIn, Attribute genericAttributeIn) - { - this.attributeMap = attributeMapIn; - this.genericAttribute = genericAttributeIn; - this.baseValue = genericAttributeIn.getDefault(); - } - - public Attribute getAttribute() - { - return this.genericAttribute; - } - - public double getBaseValue() - { - return this.baseValue; - } - - public void setBaseValue(double baseValue) - { - if (baseValue != this.getBaseValue()) - { - this.baseValue = baseValue; - this.flagForUpdate(); - } - } - -// public Collection getModifiersByOperation(AttributeOp operation) -// { -// return (Collection)this.mapByOperation.get(operation); -// } - - public Collection getModifiers() - { - Set set = Sets.newHashSet(); - -// for (AttributeOp op : AttributeOp.values()) -// { -// set.addAll(this.getModifiersByOperation(op)); -// } - set.addAll(this.additions); - set.addAll(this.multipliers); - - return set; - } - - public AttributeModifier getModifier(long id) - { - return (AttributeModifier)this.mapByID.get(id); - } - - public boolean hasModifier(AttributeModifier modifier) - { - return this.mapByID.get(modifier.getID()) != null; - } - - public void applyModifier(AttributeModifier modifier) - { - if (this.getModifier(modifier.getID()) != null) - { - throw new IllegalArgumentException("Modifier is already applied on this attribute!"); - } - else - { - Set set = (Set)this.mapByName.get(modifier.getName()); - - if (set == null) - { - set = Sets.newHashSet(); - this.mapByName.put(modifier.getName(), set); - } - - (modifier.isMultiplied() ? this.multipliers : this.additions).add(modifier); - set.add(modifier); - this.mapByID.put(modifier.getID(), modifier); - this.flagForUpdate(); - } - } - - protected void flagForUpdate() - { - this.needsUpdate = true; - this.attributeMap.flagDirty(this); - } - - public void removeModifier(AttributeModifier modifier) - { -// for (AttributeOp op : AttributeOp.values()) -// { -// Set set = (Set)this.mapByOperation.get(op); -// set.remove(modifier); -// } - this.additions.remove(modifier); - this.multipliers.remove(modifier); - - Set set1 = (Set)this.mapByName.get(modifier.getName()); - - if (set1 != null) - { - set1.remove(modifier); - - if (set1.isEmpty()) - { - this.mapByName.remove(modifier.getName()); - } - } - - this.mapByID.remove(modifier.getID()); - this.flagForUpdate(); - } - - public void removeAllModifiers() - { - Collection collection = this.getModifiers(); - - if (collection != null) - { - for (AttributeModifier attributemodifier : Lists.newArrayList(collection)) - { - this.removeModifier(attributemodifier); - } - } - } - - public double getAttributeValue() - { - if (this.needsUpdate) - { - this.cachedValue = this.computeValue(); - this.needsUpdate = false; - } - - return this.cachedValue; - } - - private double computeValue() - { - double base = this.getBaseValue(); - - for (AttributeModifier attributemodifier : this.additions) - { - base += attributemodifier.getAmount(); - } - - for (AttributeModifier attributemodifier2 : this.multipliers) - { - base *= 1.0D + attributemodifier2.getAmount(); - } - - return this.genericAttribute.clamp(base); - } - -// private Collection getModifierList(AttributeOp operation) -// { -// // Set set = -// return Sets.newHashSet(this.getModifiersByOperation(operation)); -// -//// for (BaseAttribute iattribute = this.genericAttribute.func_180372_d(); iattribute != null; iattribute = iattribute.func_180372_d()) -//// { -//// ModifiableAttributeInstance iattributeinstance = this.attributeMap.getAttributeInstance(iattribute); -//// -//// if (iattributeinstance != null) -//// { -//// set.addAll(iattributeinstance.getModifiersByOperation(operation)); -//// } -//// } -// -// // return set; -// } -} diff --git a/common/src/main/java/common/attributes/AttributeMap.java b/common/src/main/java/common/attributes/AttributeMap.java index 408d465..dfa8512 100755 --- a/common/src/main/java/common/attributes/AttributeMap.java +++ b/common/src/main/java/common/attributes/AttributeMap.java @@ -1,163 +1,60 @@ package common.attributes; -import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import common.collect.Maps; -import common.collect.Sets; -import common.util.LowerStringMap; -import java.util.Set; +public class AttributeMap { + private class AttributeInstance { + private final Map slots = Maps.newHashMap(); -public class AttributeMap -{ - protected final Map attributes = Maps.newHashMap(); - protected final Map nameMap = new LowerStringMap(); - private final Set dirtyAttributes; - - public AttributeMap(boolean client) { - this.dirtyAttributes = client ? null : Sets.newHashSet(); - } + private boolean update = true; + private float value; - public AttributeInstance getAttributeInstance(Attribute attribute) - { - return (AttributeInstance)this.attributes.get(attribute); - } + public void applyModifier(int slot, float amount) { + this.slots.put(slot, amount); + this.update = true; + } - public AttributeInstance getAttributeInstanceByName(String attributeName) - { -// AttributeInstance iattributeinstance = - return (AttributeInstance)this.nameMap.get(attributeName); + public void removeModifier(int slot) { + if(this.slots.remove(slot) != null) + this.update = true; + } -// if (iattributeinstance == null) -// { -// iattributeinstance = (AttributeInstance)this.descMap.get(attributeName); -// } -// -// return (AttributeInstance)iattributeinstance; - } + 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; + } + } - public AttributeInstance registerAttribute(Attribute attribute) - { - if(this.nameMap.containsKey(attribute.getName())) - throw new IllegalArgumentException("Attribute is already registered!"); - AttributeInstance inst = new AttributeInstance(this, attribute); - this.nameMap.put(attribute.getName(), inst); - this.attributes.put(attribute, inst); -// for (BaseAttribute iattribute = attribute.func_180372_d(); iattribute != null; iattribute = iattribute.func_180372_d()) -// { -// this.field_180377_c.put(iattribute, attribute); -// } -// if(attribute.getDescription() != null) -// this.descMap.put(attribute.getDescription(), inst); - return inst; - } + private final Map attributes = Maps.newHashMap(); - public Collection getAllAttributes() - { - return this.nameMap.values(); - } + public AttributeMap() { + for(Attribute attribute : Attribute.values()) { + this.attributes.put(attribute, new AttributeInstance()); + } + } - public void flagDirty(AttributeInstance instance) - { - if (this.dirtyAttributes != null && instance.getAttribute().isWatched()) - { - this.dirtyAttributes.add(instance); - } + public float get(Attribute attribute) { + return this.attributes.get(attribute).getAttributeValue(); + } -// for (BaseAttribute iattribute : this.field_180377_c.get(instance.getAttribute())) -// { -// ModifiableAttributeInstance modifiableattributeinstance = this.getAttributeInstance(iattribute); -// -// if (modifiableattributeinstance != null) -// { -// modifiableattributeinstance.flagForUpdate(); -// } -// } - } + public void remove(Map modifiers, int slot) { + for(Entry entry : modifiers.entrySet()) { + this.attributes.get(entry.getKey()).removeModifier(slot); + } + } - public Set getDirty() - { - return this.dirtyAttributes; - } - - public Collection getWatchedAttributes() - { - Set set = Sets.newHashSet(); - - for (AttributeInstance iattributeinstance : this.getAllAttributes()) - { - if (iattributeinstance.getAttribute().isWatched()) - { - set.add(iattributeinstance); - } - } - - return set; - } - - public void removeAttributeModifiers(Map> modifiers) - { - for (Entry> entry : modifiers.entrySet()) - { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); - - if (iattributeinstance != null) - { - for(AttributeModifier mod : entry.getValue()) { - iattributeinstance.removeModifier(mod); - } - } - } - } - - public void applyAttributeModifiers(Map> modifiers) - { - for (Entry> entry : modifiers.entrySet()) - { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); - - if (iattributeinstance != null) - { - for(AttributeModifier mod : entry.getValue()) { - iattributeinstance.removeModifier(mod); - iattributeinstance.applyModifier(mod); - } - } - } - } - - public void removeAttributeModifiers(Map> modifiers, int slot, int amount) - { - for (Entry> entry : modifiers.entrySet()) - { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); - - if (iattributeinstance != null) - { - for(AttributeModifier mod : entry.getValue()) { - AttributeModifier nmod = new AttributeModifier(mod, slot+1, amount); - iattributeinstance.removeModifier(nmod); - } - } - } - } - - public void applyAttributeModifiers(Map> modifiers, int slot, int amount) - { - for (Entry> entry : modifiers.entrySet()) - { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); - - if (iattributeinstance != null) - { - for(AttributeModifier mod : entry.getValue()) { - AttributeModifier nmod = new AttributeModifier(mod, slot+1, amount); - iattributeinstance.removeModifier(nmod); - iattributeinstance.applyModifier(nmod); - } - } - } - } + public void add(Map modifiers, int slot, int amount) { + for(Entry entry : modifiers.entrySet()) { + this.attributes.get(entry.getKey()).applyModifier(slot, entry.getValue() * (float)amount); + } + } } diff --git a/common/src/main/java/common/attributes/AttributeModifier.java b/common/src/main/java/common/attributes/AttributeModifier.java deleted file mode 100755 index ba4d937..0000000 --- a/common/src/main/java/common/attributes/AttributeModifier.java +++ /dev/null @@ -1,134 +0,0 @@ -package common.attributes; - -import common.rng.Random; - -public class AttributeModifier -{ - private final double amount; - private final boolean multiply; - private final String name; - private final long id; - private final boolean isSaved; - private final boolean inventory; - - public static long getModifierId(String name) { - if(name.length() > 7) - throw new IllegalArgumentException("Name darf höchstens 7 Zeichen enthalten"); - long id = '@'; - for(int z = 0; z < name.length(); z++) { - id <<= 8; - char c = name.charAt(z); - if(c > 0xff) - throw new IllegalArgumentException("Name darf keine 16-Bit-Zeichen enthalten"); - id |= (long)c; - } -// Log.CONFIG.debug(String.format("Modifikator '%s' -> 0x%016x", name, id)); - return id; - } - - public AttributeModifier(String nameIn, double amountIn, boolean multiplyIn) - { - this(new Random().longv() | 0x8000000000000000L, nameIn, amountIn, multiplyIn, true, false); - } - - public AttributeModifier(long idIn, String nameIn, double amountIn, boolean multiplyIn) { - this(idIn, nameIn, amountIn, multiplyIn, true, false); - } - - public AttributeModifier(long idIn, String nameIn, double amountIn, boolean multiplyIn, boolean saved) { - this(idIn, nameIn, amountIn, multiplyIn, saved, false); - } - - public AttributeModifier(long idIn, String nameIn, double amountIn, boolean multiplyIn, boolean saved, boolean inv) - { - this.isSaved = saved; - this.inventory = inv; - this.id = idIn; - this.name = nameIn; - this.amount = amountIn; - this.multiply = multiplyIn; - if (nameIn == null) { - throw new NullPointerException("Modifier name cannot be empty"); - } - else if (nameIn.length() == 0) { - throw new IllegalArgumentException("Modifier name cannot be empty"); - } -// else if (operationIn == null) { -// throw new IllegalArgumentException("Invalid operation"); -// } - } - - public AttributeModifier(AttributeModifier attr, int slot, int amount) { - this(attr.id + (long)slot, attr.name, attr.amount * (double)amount, attr.multiply, attr.isSaved); - } - - public long getID() - { - return this.id; - } - - public String getName() - { - return this.name; - } - - public boolean isMultiplied() - { - return this.multiply; - } - - public double getAmount() - { - return this.amount; - } - - public boolean isSaved() - { - return this.isSaved; - } - - public boolean isInventory() - { - return this.inventory; - } - - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - else if (obj != null && this.getClass() == obj.getClass()) - { - AttributeModifier attributemodifier = (AttributeModifier)obj; - - if (this.id != 0L) - { - if (this.id != attributemodifier.id) - { - return false; - } - } - else if (attributemodifier.id != 0L) - { - return false; - } - - return true; - } - else - { - return false; - } - } - - public int hashCode() - { - return this.id != 0L ? Long.hashCode(this.id) : 0; - } - - public String toString() - { - return "AttributeModifier{amount=" + this.amount + ", multiply=" + this.multiply + ", name=\'" + this.name + '\'' + ", id=" + this.id + ", serialize=" + this.isSaved + '}'; - } -} diff --git a/common/src/main/java/common/attributes/Attributes.java b/common/src/main/java/common/attributes/Attributes.java deleted file mode 100755 index afc2cea..0000000 --- a/common/src/main/java/common/attributes/Attributes.java +++ /dev/null @@ -1,111 +0,0 @@ -package common.attributes; - -import java.util.Collection; - -import common.collect.Lists; -import common.log.Log; -import common.tags.TagObject; -import java.util.List; - -public class Attributes { - public static final AttributeModifier RUSHING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("RushSpd"), "Attacking speed boost", 0.05, false, false); - public static final AttributeModifier MAGE_POTSPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("MagePot"), "Drinking speed penalty", -0.25, false, false); - public static final AttributeModifier ZOMBIE_BABY_MOD = new AttributeModifier(AttributeModifier.getModifierId("ZombSpd"), "Baby speed boost", 0.5, true); - public static final AttributeModifier FLEEING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("FleeSpd"), "Fleeing speed bonus", 2.0, true, false); - public static final AttributeModifier SPRINT_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("Sprint"), "Sprinting speed boost", 0.3, true, false); - public static final AttributeModifier MOUSE_SPEEDY_MOD = new AttributeModifier(AttributeModifier.getModifierId("SpeedyG"), "Mouse speed boost", 1.0, true); - - public static final long ITEM_VAL_ID = AttributeModifier.getModifierId("ItemVal"); - public static final long ITEM_DMG_ID = AttributeModifier.getModifierId("ItemDmg"); - - public static List writeBaseAttributeMapToNBT(AttributeMap map) { - List attrs = Lists.newArrayList(); - - for(AttributeInstance instance : map.getAllAttributes()) { - attrs.add(writeAttributeInstanceToNBT(instance)); - } - - return attrs; - } - - private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance) { - TagObject tag = new TagObject(); - Attribute attr = instance.getAttribute(); - tag.setString("Name", attr.getName()); - tag.setDouble("Base", instance.getBaseValue()); - Collection modifiers = instance.getModifiers(); - - if(modifiers != null && !modifiers.isEmpty()) { - List mods = Lists.newArrayList(); - - for(AttributeModifier mod : modifiers) { - if(mod.isSaved()) { - mods.add(writeAttributeModifierToNBT(mod)); - } - } - - tag.setList("Modifiers", mods); - } - - return tag; - } - - private static TagObject writeAttributeModifierToNBT(AttributeModifier mod) { - TagObject tag = new TagObject(); - tag.setString("Name", mod.getName()); - tag.setDouble("Amount", mod.getAmount()); - tag.setBool("Multiply", mod.isMultiplied()); - tag.setLong("AttrId", mod.getID()); - return tag; - } - - public static void setAttributeModifiers(AttributeMap map, List mods) { - for(int i = 0; i < mods.size(); ++i) { - TagObject mod = mods.get(i); - AttributeInstance instance = map.getAttributeInstanceByName(mod.getString("Name")); - - if(instance != null) { - applyModifiersToAttributeInstance(instance, mod); - } - else { - Log.TICK.warn("Ignoriere unbekannte Attribute \'" + mod.getString("Name") + "\'"); - } - } - } - - private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject tag) { - instance.setBaseValue(tag.getDouble("Base")); - - if(tag.hasList("Modifiers")) { - List mods = tag.getList("Modifiers"); - - for(int i = 0; i < mods.size(); ++i) { - AttributeModifier mod = readAttributeModifierFromNBT(mods.get(i)); - - if(mod != null) { - AttributeModifier old = instance.getModifier(mod.getID()); - - if(old != null) { - instance.removeModifier(old); - } - - instance.applyModifier(mod); - } - } - } - } - - public static AttributeModifier readAttributeModifierFromNBT(TagObject tag) { - long id = tag.getLong("AttrId"); - if(id == 0L) - return null; - - try { - return new AttributeModifier(id, tag.getString("Name"), tag.getDouble("Amount"), tag.getBool("Multiply")); - } - catch(Exception e) { - Log.TICK.warn("Konnte Attribute nicht erstellen: " + e.getMessage()); - return null; - } - } -} diff --git a/common/src/main/java/common/attributes/UsageSlot.java b/common/src/main/java/common/attributes/UsageSlot.java new file mode 100644 index 0000000..2873075 --- /dev/null +++ b/common/src/main/java/common/attributes/UsageSlot.java @@ -0,0 +1,38 @@ +package common.attributes; + +public enum UsageSlot { + HAND(0), HEAD(4, 0), BODY(3, 1), LEGS(2, 2), FEET(1, 3), INVENTORY(-1); + + private static final UsageSlot[] LOOKUP = new UsageSlot[UsageSlot.values().length]; + + private final int index; + private final int armor; + + static { + for(UsageSlot slot : values()) { + if(slot.index >= 0) + LOOKUP[slot.index] = slot; + } + } + + private UsageSlot(int index, int armor) { + this.index = index; + this.armor = armor; + } + + private UsageSlot(int index) { + this(index, -1); + } + + public int getIndex() { + return this.index; + } + + public int getArmorSlot() { + return this.armor; + } + + public static UsageSlot getByIndex(int index) { + return index < 0 || index >= LOOKUP.length ? null : LOOKUP[index]; + } +} diff --git a/common/src/main/java/common/enchantment/EnumEnchantmentType.java b/common/src/main/java/common/enchantment/EnumEnchantmentType.java index 7c7e2c9..40675e2 100755 --- a/common/src/main/java/common/enchantment/EnumEnchantmentType.java +++ b/common/src/main/java/common/enchantment/EnumEnchantmentType.java @@ -1,5 +1,6 @@ package common.enchantment; +import common.attributes.UsageSlot; import common.item.Item; import common.item.ItemArmor; import common.item.ItemBow; @@ -43,7 +44,7 @@ public enum EnumEnchantmentType else { ItemArmor itemarmor = (ItemArmor)p_77557_1_; - return itemarmor.armorType == 0 ? this == ARMOR_HEAD : (itemarmor.armorType == 2 ? this == ARMOR_LEGS : (itemarmor.armorType == 1 ? this == ARMOR_TORSO : (itemarmor.armorType == 3 ? this == ARMOR_FEET : false))); + return itemarmor.armorType == UsageSlot.HEAD ? this == ARMOR_HEAD : (itemarmor.armorType == UsageSlot.LEGS ? this == ARMOR_LEGS : (itemarmor.armorType == UsageSlot.BODY ? this == ARMOR_TORSO : (itemarmor.armorType == UsageSlot.FEET ? this == ARMOR_FEET : false))); } } else diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index 5b12e44..6fcfe73 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -147,10 +147,7 @@ public abstract class Entity this.dataWatcher = new DataWatcher(this); this.dataWatcher.addObject(0, Byte.valueOf((byte)0)); -// this.dataWatcher.addObject(1, Short.valueOf((short)300)); -// this.dataWatcher.addObject(3, Byte.valueOf((byte)0)); this.dataWatcher.addObject(1, ""); -// this.dataWatcher.addObject(4, Byte.valueOf((byte)0)); this.entityInit(); } diff --git a/common/src/main/java/common/entity/EntityTrackerEntry.java b/common/src/main/java/common/entity/EntityTrackerEntry.java index 007b87d..1ed7535 100755 --- a/common/src/main/java/common/entity/EntityTrackerEntry.java +++ b/common/src/main/java/common/entity/EntityTrackerEntry.java @@ -1,11 +1,8 @@ package common.entity; -import java.util.Collection; import java.util.List; import java.util.Set; -import common.attributes.AttributeInstance; -import common.attributes.AttributeMap; import common.collect.Sets; import common.entity.npc.EntityNPC; import common.entity.projectile.EntityArrow; @@ -21,7 +18,6 @@ import common.packet.SPacketEntityHeadLook; import common.packet.SPacketEntityAttach; import common.packet.SPacketEntityMetadata; import common.packet.SPacketEntityEffect; -import common.packet.SPacketEntityProperties; import common.packet.SPacketUpdateEntityTags; import common.packet.SPacketEntityEquipment; import common.packet.SPacketEntityVelocity; @@ -243,17 +239,6 @@ public class EntityTrackerEntry { if(datawatcher.hasObjectChanged()) { this.sendPacketToTrackedAndSelf(new SPacketEntityMetadata(this.trackedEntity.getId(), datawatcher, false)); } - - if(this.trackedEntity instanceof EntityLiving) { - AttributeMap serversideattributemap = ((EntityLiving)this.trackedEntity).getAttributeMap(); - Set set = serversideattributemap.getDirty(); - - if(!set.isEmpty()) { - this.sendPacketToTrackedAndSelf(new SPacketEntityProperties(this.trackedEntity.getId(), set)); - } - - set.clear(); - } } public void sendPacketToTrackedPlayers(Packet packetIn) { @@ -302,15 +287,6 @@ public class EntityTrackerEntry { playerMP.connection.sendPacket(new SPacketUpdateEntityTags(this.trackedEntity.getId(), nbttagcompound)); } - if(this.trackedEntity instanceof EntityLiving) { - AttributeMap serversideattributemap = ((EntityLiving)this.trackedEntity).getAttributeMap(); - Collection collection = serversideattributemap.getWatchedAttributes(); - - if(!collection.isEmpty()) { - playerMP.connection.sendPacket(new SPacketEntityProperties(this.trackedEntity.getId(), collection)); - } - } - this.lastTrackedEntityMotionX = this.trackedEntity.motionX; this.lastTrackedEntityMotionY = this.trackedEntity.motionY; this.lastTrackedEntityMotionZ = this.trackedEntity.motionZ; diff --git a/common/src/main/java/common/entity/animal/EntityChicken.java b/common/src/main/java/common/entity/animal/EntityChicken.java index 98ff744..eeae971 100755 --- a/common/src/main/java/common/entity/animal/EntityChicken.java +++ b/common/src/main/java/common/entity/animal/EntityChicken.java @@ -10,7 +10,6 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.entity.DamageSource; import common.entity.Entity; import common.entity.npc.Alignment; @@ -65,7 +64,7 @@ public class EntityChicken extends EntityAnimal { protected void applyEntityAttributes() { super.applyEntityAttributes(); this.setMaxHealth(4); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); + this.setSpeedBase(0.25f); } public void onLivingUpdate() { diff --git a/common/src/main/java/common/entity/animal/EntityCow.java b/common/src/main/java/common/entity/animal/EntityCow.java index da35c3a..4e14119 100755 --- a/common/src/main/java/common/entity/animal/EntityCow.java +++ b/common/src/main/java/common/entity/animal/EntityCow.java @@ -8,7 +8,6 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.entity.npc.EntityNPC; import common.entity.types.EntityAnimal; import common.entity.types.EntityLiving; @@ -40,7 +39,7 @@ public class EntityCow extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(10); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); + this.setSpeedBase(0.20000000298023224f); } /** diff --git a/common/src/main/java/common/entity/animal/EntityFox.java b/common/src/main/java/common/entity/animal/EntityFox.java index ef58be6..568bf97 100644 --- a/common/src/main/java/common/entity/animal/EntityFox.java +++ b/common/src/main/java/common/entity/animal/EntityFox.java @@ -9,7 +9,6 @@ import common.ai.EntityAINearestAttackableTarget; import common.ai.EntityAISwimming; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.entity.DamageSource; import common.entity.Entity; import common.entity.npc.Alignment; @@ -44,7 +43,7 @@ public class EntityFox extends EntityAnimal protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.35D); + this.setSpeedBase(0.35f); this.setMaxHealth(6); } diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index bb46bf3..e58770d 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -10,8 +10,6 @@ import common.ai.EntityAIRunAroundLikeCrazy; import common.ai.EntityAISwimming; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; import common.block.Block; import common.block.SoundType; import common.collect.Lists; @@ -108,7 +106,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic this.dataWatcher.addObject(16, Integer.valueOf(0)); this.dataWatcher.addObject(19, Byte.valueOf((byte)0)); this.dataWatcher.addObject(20, Integer.valueOf(0)); -// this.dataWatcher.addObject(21, String.valueOf((Object)"")); + this.dataWatcher.addObject(21, 0.7f); this.dataWatcher.addObject(22, Integer.valueOf(0)); } @@ -551,9 +549,14 @@ public class EntityHorse extends EntityAnimal implements IInvBasic return (EntityHorse)entity; } - public double getHorseJumpStrength() + public float getHorseJumpStrength() { - return this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getAttributeValue(); + return this.dataWatcher.getWatchableObjectFloat(21); + } + + public void setHorseJumpStrength(float value) + { + this.dataWatcher.updateObject(21, value); } /** @@ -663,9 +666,8 @@ public class EntityHorse extends EntityAnimal implements IInvBasic protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getAttributeMap().registerAttribute(Attribute.HORSE_JUMP_STRENGTH); this.setMaxHealth(53); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.22499999403953552D); + this.setSpeedBase(0.22499999403953552f); } /** @@ -1354,7 +1356,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (!this.worldObj.client) { - this.setAIMoveSpeed((float)this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue()); + this.setAIMoveSpeed(this.getMovementSpeed()); super.moveEntityWithHeading(strafe, forward); } @@ -1399,6 +1401,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic tagCompound.setInt("Variant", this.getHorseVariant()); tagCompound.setInt("Temper", this.getTemper()); tagCompound.setBool("Tame", this.isTame()); + tagCompound.setFloat("JumpStrength", this.getHorseJumpStrength()); // tagCompound.setString("Owner", this.getOwnerId()); if (this.isChested()) @@ -1446,6 +1449,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic this.setHorseVariant(tagCompund.getInt("Variant")); this.setTemper(tagCompund.getInt("Temper")); this.setHorseTamed(tagCompund.getBool("Tame")); + this.setHorseJumpStrength(tagCompund.getFloat("JumpStrength")); // String s = ""; // // if (tagCompund.hasString("Owner")) @@ -1458,12 +1462,12 @@ public class EntityHorse extends EntityAnimal implements IInvBasic // this.setOwnerId(s); // } - AttributeInstance iattributeinstance = this.getAttributeMap().getAttributeInstanceByName("Speed"); - - if (iattributeinstance != null) - { - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(iattributeinstance.getBaseValue() * 0.25D); - } +// AttributeInstance iattributeinstance = this.getAttributeMap().getAttributeInstanceByName("Speed"); +// +// if (iattributeinstance != null) +// { +// this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(iattributeinstance.getBaseValue() * 0.25D); +// } if (this.isChested()) { @@ -1593,12 +1597,12 @@ public class EntityHorse extends EntityAnimal implements IInvBasic } entityhorse1.setHorseType(k); - int d1 = this.getRawMaxHealth() + ageable.getRawMaxHealth() + this.getModifiedMaxHealth(); + int d1 = this.getMaxHealth() + ageable.getMaxHealth() + this.getModifiedMaxHealth(); entityhorse1.setMaxHealth(d1 / 3); - double d2 = this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue() + ageable.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue() + this.getModifiedJumpStrength(); - entityhorse1.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(d2 / 3.0D); - double d0 = this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() + ageable.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() + this.getModifiedMovementSpeed(); - entityhorse1.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(d0 / 3.0D); + float d2 = this.getHorseJumpStrength() + entityhorse.getHorseJumpStrength() + this.getModifiedJumpStrength(); + entityhorse1.setHorseJumpStrength(d2 / 3.0f); + float d0 = this.getSpeedBase() + ageable.getSpeedBase() + this.getModifiedMovementSpeed(); + entityhorse1.setSpeedBase(d0 / 3.0f); return entityhorse1; } @@ -1648,26 +1652,26 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (i == 0) { - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(this.getModifiedMovementSpeed()); + this.setSpeedBase(this.getModifiedMovementSpeed()); } else { - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.17499999701976776D); + this.setSpeedBase(0.17499999701976776f); } } else { this.setMaxHealth(15); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); + this.setSpeedBase(0.20000000298023224f); } if (i != 2 && i != 1) { - this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(this.getModifiedJumpStrength()); + this.setHorseJumpStrength(this.getModifiedJumpStrength()); } else { - this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(0.5D); + this.setHorseJumpStrength(0.5f); } this.setHealth(this.getMaxHealth()); @@ -1776,17 +1780,17 @@ public class EntityHorse extends EntityAnimal implements IInvBasic /** * Returns randomized jump strength */ - private double getModifiedJumpStrength() + private float getModifiedJumpStrength() { - return 0.4000000059604645D + this.rand.doublev() * 0.2D + this.rand.doublev() * 0.2D + this.rand.doublev() * 0.2D; + return 0.4000000059604645f + this.rand.floatv() * 0.2f + this.rand.floatv() * 0.2f + this.rand.floatv() * 0.2f; } /** * Returns randomized movement speed */ - private double getModifiedMovementSpeed() + private float getModifiedMovementSpeed() { - return (0.44999998807907104D + this.rand.doublev() * 0.3D + this.rand.doublev() * 0.3D + this.rand.doublev() * 0.3D) * 0.25D; + return (0.44999998807907104f + this.rand.floatv() * 0.3f + this.rand.floatv() * 0.3f + this.rand.floatv() * 0.3f) * 0.25f; } /** diff --git a/common/src/main/java/common/entity/animal/EntityMouse.java b/common/src/main/java/common/entity/animal/EntityMouse.java index 2c42bf3..2564c4d 100755 --- a/common/src/main/java/common/entity/animal/EntityMouse.java +++ b/common/src/main/java/common/entity/animal/EntityMouse.java @@ -10,9 +10,6 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.block.Block; import common.entity.npc.EntityNPC; import common.entity.types.EntityAnimal; @@ -47,7 +44,7 @@ public class EntityMouse extends EntityAnimal { protected void applyEntityAttributes() { super.applyEntityAttributes(); this.setMaxHealth(1); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); + this.setSpeedBase(0.25f); } // protected String getLivingSound() { @@ -119,12 +116,8 @@ public class EntityMouse extends EntityAnimal { public void setCustomNameTag(String name) { super.setCustomNameTag(name); - if(this.worldObj != null && !this.worldObj.client) { - AttributeInstance speed = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); - speed.removeModifier(Attributes.MOUSE_SPEEDY_MOD); - if(name.equals("Gonzales") || name.equals("Gonzalez")) - speed.applyModifier(Attributes.MOUSE_SPEEDY_MOD); - } + if(this.worldObj != null && !this.worldObj.client) + this.setSpeedBase(name.equals("Gonzales") || name.equals("Gonzalez") ? 0.5f : 0.25f); } public int getColor() { diff --git a/common/src/main/java/common/entity/animal/EntityOcelot.java b/common/src/main/java/common/entity/animal/EntityOcelot.java index 0c900e0..67483ae 100755 --- a/common/src/main/java/common/entity/animal/EntityOcelot.java +++ b/common/src/main/java/common/entity/animal/EntityOcelot.java @@ -13,7 +13,6 @@ import common.ai.EntityAITargetNonTamed; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.entity.DamageSource; import common.entity.Entity; import common.entity.npc.Alignment; @@ -113,7 +112,7 @@ public class EntityOcelot extends EntityTameable { super.applyEntityAttributes(); this.setMaxHealth(10); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); + this.setSpeedBase(0.30000001192092896f); } public void fall(float distance, float damageMultiplier) diff --git a/common/src/main/java/common/entity/animal/EntityPig.java b/common/src/main/java/common/entity/animal/EntityPig.java index 1346e49..512e6f7 100755 --- a/common/src/main/java/common/entity/animal/EntityPig.java +++ b/common/src/main/java/common/entity/animal/EntityPig.java @@ -9,7 +9,6 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.entity.npc.EntityNPC; import common.entity.types.EntityAnimal; import common.entity.types.EntityLiving; @@ -47,7 +46,7 @@ public class EntityPig extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(10); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); + this.setSpeedBase(0.25f); } /** diff --git a/common/src/main/java/common/entity/animal/EntityRabbit.java b/common/src/main/java/common/entity/animal/EntityRabbit.java index 7ed813a..4b34e12 100755 --- a/common/src/main/java/common/entity/animal/EntityRabbit.java +++ b/common/src/main/java/common/entity/animal/EntityRabbit.java @@ -15,7 +15,6 @@ import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; import common.ai.EntityJumpHelper; import common.ai.EntityMoveHelper; -import common.attributes.Attribute; import common.block.Block; import common.block.foliage.BlockTallGrass; import common.entity.DamageSource; @@ -199,7 +198,7 @@ public class EntityRabbit extends EntityAnimal { protected void applyEntityAttributes() { super.applyEntityAttributes(); this.setMaxHealth(5); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); + this.setSpeedBase(0.30000001192092896f); } public void writeEntity(TagObject tagCompound) { diff --git a/common/src/main/java/common/entity/animal/EntitySheep.java b/common/src/main/java/common/entity/animal/EntitySheep.java index 054137a..a2250da 100755 --- a/common/src/main/java/common/entity/animal/EntitySheep.java +++ b/common/src/main/java/common/entity/animal/EntitySheep.java @@ -11,7 +11,6 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.biome.Biome; import common.collect.Maps; import common.color.DyeColor; @@ -104,7 +103,7 @@ public class EntitySheep extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(8); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); + this.setSpeedBase(0.23000000417232513f); } protected void entityInit() diff --git a/common/src/main/java/common/entity/animal/EntityWolf.java b/common/src/main/java/common/entity/animal/EntityWolf.java index 383b43e..cf694c0 100755 --- a/common/src/main/java/common/entity/animal/EntityWolf.java +++ b/common/src/main/java/common/entity/animal/EntityWolf.java @@ -15,7 +15,6 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITargetNonTamed; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attribute; import common.color.DyeColor; import common.entity.DamageSource; import common.entity.Entity; @@ -86,7 +85,7 @@ public class EntityWolf extends EntityTameable protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); + this.setSpeedBase(0.30000001192092896f); this.setMaxHealth(8); } diff --git a/common/src/main/java/common/entity/npc/EntityChaosMarine.java b/common/src/main/java/common/entity/npc/EntityChaosMarine.java index d8424a1..69966f5 100755 --- a/common/src/main/java/common/entity/npc/EntityChaosMarine.java +++ b/common/src/main/java/common/entity/npc/EntityChaosMarine.java @@ -2,7 +2,6 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attribute; import common.collect.Lists; import common.init.Items; import common.init.SpeciesRegistry; @@ -118,7 +117,7 @@ public class EntityChaosMarine extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D); + this.setAttackDamageBase(12); } protected ItemStack pickItem() { diff --git a/common/src/main/java/common/entity/npc/EntityFlyingNPC.java b/common/src/main/java/common/entity/npc/EntityFlyingNPC.java index 8692eb1..0218e90 100755 --- a/common/src/main/java/common/entity/npc/EntityFlyingNPC.java +++ b/common/src/main/java/common/entity/npc/EntityFlyingNPC.java @@ -2,7 +2,6 @@ package common.entity.npc; import common.ai.EntityAIBase; import common.ai.EntityMoveHelper; -import common.attributes.Attribute; import common.block.Block; import common.entity.types.EntityLiving; import common.potion.Potion; @@ -21,12 +20,10 @@ public abstract class EntityFlyingNPC extends EntityNPC this.tasks.addTask(5, new AIRandomFly(this)); this.tasks.addTask(7, new AILookAround(this)); } - - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(48.0D); - } + + public int getPathingRange() { + return 48; + } public float getArmRotation() { return 0.0f; @@ -129,10 +126,9 @@ public abstract class EntityFlyingNPC extends EntityNPC return false; } - public boolean isPotionApplicable(Potion potion, int amplifier) - { - return (potion != Potion.FLYING || amplifier > 0) && super.isPotionApplicable(potion, amplifier); - } + public boolean isPotionApplicable(Potion potion, int amplifier) { + return (potion != Potion.FLYING || amplifier > 0) && super.isPotionApplicable(potion, amplifier); + } static class AILookAround extends EntityAIBase { diff --git a/common/src/main/java/common/entity/npc/EntityGargoyle.java b/common/src/main/java/common/entity/npc/EntityGargoyle.java index e9b43eb..065e07e 100755 --- a/common/src/main/java/common/entity/npc/EntityGargoyle.java +++ b/common/src/main/java/common/entity/npc/EntityGargoyle.java @@ -1,7 +1,6 @@ package common.entity.npc; import common.ai.AIFlyingBoxAttack; -import common.attributes.Attribute; import common.entity.DamageSource; import common.item.ItemStack; import common.model.ParticleType; @@ -165,9 +164,12 @@ public class EntityGargoyle extends EntityFlyingNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.6000000238418579D); - this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(40.0D); + this.setSpeedBase(0.6000000238418579f); } + + public int getPathingRange() { + return 40; + } public int getInvulTime() { diff --git a/common/src/main/java/common/entity/npc/EntityGoblin.java b/common/src/main/java/common/entity/npc/EntityGoblin.java index e32df99..55a0ac8 100755 --- a/common/src/main/java/common/entity/npc/EntityGoblin.java +++ b/common/src/main/java/common/entity/npc/EntityGoblin.java @@ -1,6 +1,5 @@ package common.entity.npc; -import common.attributes.Attribute; import common.entity.types.EntityLiving; import common.rng.Random; import common.world.World; @@ -44,7 +43,7 @@ public class EntityGoblin extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(1.0D); + this.setAttackDamageBase(1); } public boolean canAmbush(EntityLiving entity) { diff --git a/common/src/main/java/common/entity/npc/EntityHaunter.java b/common/src/main/java/common/entity/npc/EntityHaunter.java index 2d51086..ad266ed 100755 --- a/common/src/main/java/common/entity/npc/EntityHaunter.java +++ b/common/src/main/java/common/entity/npc/EntityHaunter.java @@ -1,7 +1,6 @@ package common.entity.npc; import common.ai.EntityAIExplode; -import common.attributes.Attribute; import common.entity.Entity; import common.entity.effect.EntityLightning; import common.entity.types.EntityLiving; @@ -28,7 +27,7 @@ public class EntityHaunter extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); + this.setSpeedBase(0.25f); } public int getMaxFallHeight() diff --git a/common/src/main/java/common/entity/npc/EntityHoveringNPC.java b/common/src/main/java/common/entity/npc/EntityHoveringNPC.java index e021466..a4b0887 100755 --- a/common/src/main/java/common/entity/npc/EntityHoveringNPC.java +++ b/common/src/main/java/common/entity/npc/EntityHoveringNPC.java @@ -1,6 +1,5 @@ package common.entity.npc; -import common.attributes.Attribute; import common.entity.types.EntityLiving; import common.packet.CPacketAction; import common.world.World; @@ -30,12 +29,10 @@ public abstract class EntityHoveringNPC extends EntityNPC // { // return true; // } - - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(32.0D); - } + + public int getPathingRange() { + return 32; + } public boolean isSneakingVisually() { return false; diff --git a/common/src/main/java/common/entity/npc/EntityMage.java b/common/src/main/java/common/entity/npc/EntityMage.java index b93e083..4811eb2 100755 --- a/common/src/main/java/common/entity/npc/EntityMage.java +++ b/common/src/main/java/common/entity/npc/EntityMage.java @@ -2,9 +2,6 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.entity.effect.EntityLightning; import common.entity.types.EntityLiving; import common.init.Items; @@ -30,7 +27,7 @@ public class EntityMage extends EntityNPC public void onLivingUpdate() { - if (!this.worldObj.client) + if (!this.worldObj.client && !this.isPlayer()) { if (this.drinking) { @@ -56,7 +53,7 @@ public class EntityMage extends EntityNPC } } - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).removeModifier(Attributes.MAGE_POTSPEED_MOD); + this.setSpeedMod(1.0f); } } else @@ -90,9 +87,7 @@ public class EntityMage extends EntityNPC this.setItem(0, new ItemStack(Items.potion, 1, i)); this.attackTimer = this.getHeldItem().getMaxItemUseDuration(); this.drinking = true; - AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); - iattributeinstance.removeModifier(Attributes.MAGE_POTSPEED_MOD); - iattributeinstance.applyModifier(Attributes.MAGE_POTSPEED_MOD); + this.setSpeedMod(0.165f); } else if(this.rand.chance(80)) { boolean far = this.getAttackTarget() != null && this.getAttackTarget().getDistanceSqToEntity(this) >= 256.0; diff --git a/common/src/main/java/common/entity/npc/EntityMobNPC.java b/common/src/main/java/common/entity/npc/EntityMobNPC.java index 6f5d6aa..a8f1be8 100755 --- a/common/src/main/java/common/entity/npc/EntityMobNPC.java +++ b/common/src/main/java/common/entity/npc/EntityMobNPC.java @@ -1,9 +1,6 @@ package common.entity.npc; import common.ai.EntityAIHurtByTarget; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.entity.DamageSource; import common.entity.Entity; import common.entity.types.EntityLiving; @@ -63,20 +60,15 @@ public abstract class EntityMobNPC extends EntityNPC protected void updateAITasks() { - AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); - if (this.isAngry()) { - if (/* !this.isChild() && */ !iattributeinstance.hasModifier(Attributes.RUSHING_SPEED_MOD)) - { - iattributeinstance.applyModifier(Attributes.RUSHING_SPEED_MOD); - } + this.setSpeedMod(1.05f); --this.angerLevel; } - else if (iattributeinstance.hasModifier(Attributes.RUSHING_SPEED_MOD)) + else { - iattributeinstance.removeModifier(Attributes.RUSHING_SPEED_MOD); + this.setSpeedMod(1.0f); } // if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index ed401c9..0e2dc24 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -19,11 +19,11 @@ import common.ai.EntityAISwimming; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest2; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; +import common.attributes.UsageSlot; import common.block.Block; import common.block.artificial.BlockBed; import common.collect.Lists; +import common.color.TextColor; import common.dimension.Space; import common.enchantment.Enchantment; import common.enchantment.EnchantmentHelper; @@ -245,6 +245,7 @@ public abstract class EntityNPC extends EntityLiving private int horseJumpPowerCounter; private float horseJumpPower; private long movedDistance; + private int attackDamageBase = 2; public EntityNPC(World worldIn) { @@ -382,7 +383,7 @@ public abstract class EntityNPC extends EntityLiving this.fireResistance = 20; this.noPickup = true; // this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(1.0D); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() / 3.0); // 0.10000000149011612D); +// this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() / 3.0); // 0.10000000149011612D); } public final void setServerPlayer(IPlayer connection) { @@ -542,13 +543,15 @@ public abstract class EntityNPC extends EntityLiving protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(20.0D); - this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.3D); + this.setSpeedBase(0.3f); this.setMaxHealth(this.getBaseHealth(this.rand)); - this.getAttributeMap().registerAttribute(Attribute.MANA_CAPACITY); - this.getEntityAttribute(Attribute.MANA_CAPACITY).setBaseValue(20.0D); + if(this.canUseMagic()) + this.setMaxMana(20); } + + public int getPathingRange() { + return 20; + } public boolean isPotionApplicable(Potion potion, int amplifier) { return true; @@ -683,7 +686,7 @@ public abstract class EntityNPC extends EntityLiving { if(!this.worldObj.client && !Vars.damageMobs) return false; - int f = (int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue(); + int f = this.getAttackDamage(); int i = 0; if (entityIn instanceof EntityLiving) @@ -836,12 +839,12 @@ public abstract class EntityNPC extends EntityLiving public void setChar(String character) { - this.dataWatcher.updateObject(16, character); + this.dataWatcher.updateObject(9, character); } public String getChar() { - return this.dataWatcher.getWatchableObjectString(16); + return this.dataWatcher.getWatchableObjectString(9); } public void setCape(String cape) @@ -856,12 +859,12 @@ public abstract class EntityNPC extends EntityLiving public void setNpcClass(Enum type) { - this.dataWatcher.updateObject(22, (byte)(type == null ? -1 : type.ordinal())); + this.dataWatcher.updateObject(10, (byte)(type == null ? -1 : type.ordinal())); } public Enum getNpcClass() { - byte n = this.dataWatcher.getWatchableObjectByte(22); + byte n = this.dataWatcher.getWatchableObjectByte(10); return n < 0 || this.species == null || this.species.classEnum == null ? null : this.species.classEnum.getEnumConstants()[n % this.species.classEnum.getEnumConstants().length]; } @@ -869,22 +872,22 @@ public abstract class EntityNPC extends EntityLiving public void setAlignment(Alignment align) { this.alignment = align; - this.dataWatcher.updateObject(18, (byte)align.ordinal()); + this.dataWatcher.updateObject(8, (byte)align.ordinal()); } public Alignment getAlignment() { - return Alignment.values()[this.dataWatcher.getWatchableObjectByte(18) % Alignment.values().length]; + return Alignment.values()[this.dataWatcher.getWatchableObjectByte(8) % Alignment.values().length]; } public void setHeight(float height) { - this.dataWatcher.updateObject(29, ExtMath.clampf(height, 0.2f, 10.0f)); + this.dataWatcher.updateObject(11, ExtMath.clampf(height, 0.2f, 10.0f)); } public float getHeight() { - return this.dataWatcher.getWatchableObjectFloat(29); + return this.dataWatcher.getWatchableObjectFloat(11); } public SpeciesInfo getSpecies() { @@ -1077,11 +1080,11 @@ public abstract class EntityNPC extends EntityLiving } public int getManaPoints() { - return this.dataWatcher.getWatchableObjectInt(21); + return this.dataWatcher.getWatchableObjectInt(14); } public void setManaPoints(int pts) { - this.dataWatcher.updateObject(21, pts); + this.dataWatcher.updateObject(14, pts); } // public final boolean isAggressive() { @@ -1187,8 +1190,21 @@ public abstract class EntityNPC extends EntityLiving // return air; // } - public int getMaxMana() { - return (int)this.getEntityAttribute(Attribute.MANA_CAPACITY).getAttributeValue(); + public final int getMaxMana() { + return this.dataWatcher.getWatchableObjectInt(13); + } + + public final void setMaxMana(int mana) { + this.dataWatcher.updateObject(13, mana); + } + + public void healMana(int amount) { + if(this.client == null) + this.setManaPoints(ExtMath.clampi(this.getManaPoints() + amount, 0, this.getMaxMana())); + } + + public String formatStats() { + return super.formatStats() + (this.getManaPoints() == 0 ? "" : TextColor.GRAY + " [" + TextColor.MIDNIGHT + this.getManaPoints() + TextColor.GRAY + "]"); } public MerchantRecipeList getTrades(EntityNPC player) { @@ -1685,12 +1701,12 @@ public abstract class EntityNPC extends EntityLiving if (itemstack != null) { - this.getAttributeMap().removeAttributeModifiers(itemstack.getAttributeModifiers(1)); + this.attributes.remove(itemstack.getAttributeModifiers(UsageSlot.getByIndex(j)), -1 - j); } if (itemstack1 != null) { - this.getAttributeMap().applyAttributeModifiers(itemstack1.getAttributeModifiers(1)); + this.attributes.add(itemstack1.getAttributeModifiers(UsageSlot.getByIndex(j)), -1 - j, itemstack1.size); } this.prevEquipment[j] = itemstack1 == null ? null : itemstack1.copy(); @@ -1766,12 +1782,6 @@ public abstract class EntityNPC extends EntityLiving if(this.client == null) super.heal(healAmount); } - - public void healMana(int amount) - { - if(this.client == null) - super.healMana(amount); - } /** * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat. @@ -2538,7 +2548,6 @@ public abstract class EntityNPC extends EntityLiving this.prevCameraYaw = this.cameraYaw; // super.onLivingUpdate(); this.onNpcUpdate(); - AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); this.jumpMovement = this.speedInAir; @@ -2547,7 +2556,7 @@ public abstract class EntityNPC extends EntityLiving this.jumpMovement = (float)((double)this.jumpMovement + (double)this.speedInAir * 0.3D); } - this.setAIMoveSpeed((float)iattributeinstance.getAttributeValue()); + this.setAIMoveSpeed(this.getMovementSpeed() / 3.0f); float f = ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ); float f1 = (float)(Math.atan(-this.motionY * 0.20000000298023224D) * 15.0D); @@ -3003,17 +3012,16 @@ public abstract class EntityNPC extends EntityLiving protected void entityInit() { super.entityInit(); - this.dataWatcher.addObject(16, ""); - this.dataWatcher.addObject(17, ""); - this.dataWatcher.addObject(18, Byte.valueOf((byte)Alignment.NEUTRAL.ordinal())); -// this.dataWatcher.addObject(20, Byte.valueOf((byte)0)); - this.dataWatcher.addObject(21, 0); - this.dataWatcher.addObject(22, Byte.valueOf((byte)-1)); - this.dataWatcher.addObject(29, 1.0f); -// super.entityInit(); - this.dataWatcher.addObject(30, Integer.valueOf(0)); -// this.dataWatcher.addObject(10, Integer.valueOf(~ModelPart.ARMS_SLIM.getMask())); -// this.dataWatcher.addObject(11, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(8, (byte)Alignment.NEUTRAL.ordinal()); // alignment + this.dataWatcher.addObject(9, ""); // character + this.dataWatcher.addObject(10, (byte)-1); // class + this.dataWatcher.addObject(11, 1.0f); // height + this.dataWatcher.addObject(12, 0); // absorption + this.dataWatcher.addObject(13, 0); // max mana + this.dataWatcher.addObject(14, 0); // mana + this.dataWatcher.addObject(15, 0.7f); + + this.dataWatcher.addObject(17, ""); // TODO: remove capes } /** @@ -3171,7 +3179,7 @@ public abstract class EntityNPC extends EntityLiving } public void onDataWatcherUpdate(int data) { - if(this.isPlayer() && data == 29) // (data == 29 || data == 11)) // && this.worldObj.client) + if(this.isPlayer() && data == 11) // (data == 29 || data == 11)) // && this.worldObj.client) this.updateSize(); } @@ -3339,6 +3347,19 @@ public abstract class EntityNPC extends EntityLiving { return this.inventory.canHeldItemHarvest(blockToHarvest); } + + public int getAttackDamage() { + int damage = this.attackDamageBase + (this.getHeldItem() == null ? 0 : this.getHeldItem().getItem().getAttackDamageBonus()); + return Math.max(0, damage + (this.hasEffect(Potion.STRENGTH) ? (damage / 2) * (this.getEffect(Potion.STRENGTH).getAmplifier() + 1) : 0) - (this.hasEffect(Potion.WEAKNESS) ? (damage / 5) * (this.getEffect(Potion.WEAKNESS).getAmplifier() + 1) : 0)); + } + + public int getAttackDamageBase() { + return this.attackDamageBase; + } + + public void setAttackDamageBase(int value) { + this.attackDamageBase = value; + } /** * (abstract) Protected helper method to read subclass entity data from NBT. @@ -3372,7 +3393,9 @@ public abstract class EntityNPC extends EntityLiving // align = this.getNaturalAlign(this.rand); // } this.setAlignment(align); + this.setMaxMana(Math.max(0, tagCompund.getInt("MaxMana"))); this.setManaPoints(tagCompund.getInt("Mana")); + this.attackDamageBase = tagCompund.getInt("AttackDmg"); Enum type = null; if(tagCompund.hasString("ClassType") && this.species != null && this.species.classEnum != null) { type = this.species.classnames.get(tagCompund.getString("ClassType")); @@ -3485,16 +3508,6 @@ public abstract class EntityNPC extends EntityLiving */ public void writeEntity(TagObject tagCompound) { - if(this.isPlayer()) { - for (int z = 0; z < this.inventory.mainInventory.length; z++) - { - ItemStack itemstack = this.inventory.mainInventory[z]; - if (itemstack != null) - { - this.getAttributeMap().removeAttributeModifiers(itemstack.getAttributeModifiers(2), z, itemstack.size); - } - } - } // super.writeEntityToNBT(tagCompound); super.writeEntity(tagCompound); @@ -3519,7 +3532,9 @@ public abstract class EntityNPC extends EntityLiving tagCompound.setBool("Mating", this.isMating()); tagCompound.setString("Align", this.alignment.name); tagCompound.setFloat("Height", this.getHeight()); + tagCompound.setInt("MaxMana", this.getMaxMana()); tagCompound.setInt("Mana", this.getManaPoints()); + tagCompound.setInt("AttackDmg", this.attackDamageBase); Enum type = this.getNpcClass(); if(type != null) tagCompound.setString("ClassType", this.species.classnames.inverse().get(type)); @@ -3544,14 +3559,6 @@ public abstract class EntityNPC extends EntityLiving tagCompound.setByteArray("Skin", this.skin); if(this.isPlayer()) { - for (int z = 0; z < this.inventory.mainInventory.length; z++) - { - ItemStack itemstack = this.inventory.mainInventory[z]; - if (itemstack != null) - { - this.getAttributeMap().applyAttributeModifiers(itemstack.getAttributeModifiers(2), z, itemstack.size); - } - } tagCompound.setList("Inventory", this.inventory.writeToNBT(Lists.newArrayList())); tagCompound.setInt("SelectedItemSlot", this.inventory.currentItem); // tagCompound.setBoolean("Sleeping", this.sleeping); @@ -3715,7 +3722,7 @@ public abstract class EntityNPC extends EntityLiving { if (!targetEntity.hitByEntity(this)) { - int f = (int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue(); + int f = this.getAttackDamage(); int i = 0; int f1 = // 0; @@ -3940,13 +3947,22 @@ public abstract class EntityNPC extends EntityLiving if(!this.worldObj.client) this.addMovement(this.posX - d0, this.posY - d1, this.posZ - d2); } + + public float getSpeedBase() { + return this.worldObj.client ? this.dataWatcher.getWatchableObjectFloat(15) : super.getSpeedBase(); + } + + public void setSpeedBase(float value) { + super.setSpeedBase(value); + this.dataWatcher.updateObject(15, value); + } /** * the movespeed used for the new AI system */ public float getAIMoveSpeed() { - return this.isPlayer() ? (float)this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue() : super.getAIMoveSpeed(); + return this.isPlayer() ? this.getMovementSpeed() / 3.0f : super.getAIMoveSpeed(); } public void addMovement(double x, double y, double z) @@ -4246,13 +4262,13 @@ public abstract class EntityNPC extends EntityLiving amount = 0; } - this.getDataWatcher().updateObject(30, Integer.valueOf(amount)); + this.getDataWatcher().updateObject(12, Integer.valueOf(amount)); } } public int getAbsorptionAmount() { - return this.isPlayer() ? this.getDataWatcher().getWatchableObjectInt(30) : super.getAbsorptionAmount(); + return this.isPlayer() ? this.getDataWatcher().getWatchableObjectInt(12) : super.getAbsorptionAmount(); } public boolean canOpen(Passcode code) @@ -4352,7 +4368,7 @@ public abstract class EntityNPC extends EntityLiving if(info.items != null) { for(ItemStack stack : info.items) { if(stack.getItem() instanceof ItemArmor) - this.setItem(1 + ((ItemArmor)stack.getItem()).armorType, stack); + this.setItem(((ItemArmor)stack.getItem()).armorType.getIndex(), stack); else if(stack.getItem().canBeWielded()) this.setItem(0, stack); else diff --git a/common/src/main/java/common/entity/npc/EntityOrc.java b/common/src/main/java/common/entity/npc/EntityOrc.java index 654a7a5..b6a7bb3 100755 --- a/common/src/main/java/common/entity/npc/EntityOrc.java +++ b/common/src/main/java/common/entity/npc/EntityOrc.java @@ -1,6 +1,5 @@ package common.entity.npc; -import common.attributes.Attribute; import common.rng.Random; import common.world.World; @@ -72,6 +71,6 @@ public class EntityOrc extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(4.0D); + this.setAttackDamageBase(4); } } diff --git a/common/src/main/java/common/entity/npc/EntityPrimarch.java b/common/src/main/java/common/entity/npc/EntityPrimarch.java index 628944e..682d756 100755 --- a/common/src/main/java/common/entity/npc/EntityPrimarch.java +++ b/common/src/main/java/common/entity/npc/EntityPrimarch.java @@ -2,7 +2,6 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attribute; import common.collect.Lists; import common.rng.Random; import common.util.Identifyable; @@ -154,7 +153,7 @@ public class EntityPrimarch extends EntityMobNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(20.0D); + this.setAttackDamageBase(20); } // public TextComponent getPrefix() { diff --git a/common/src/main/java/common/entity/npc/EntitySlime.java b/common/src/main/java/common/entity/npc/EntitySlime.java index 6b1ec00..73fe074 100755 --- a/common/src/main/java/common/entity/npc/EntitySlime.java +++ b/common/src/main/java/common/entity/npc/EntitySlime.java @@ -2,7 +2,6 @@ package common.entity.npc; import common.ai.EntityAIBase; import common.ai.EntityMoveHelper; -import common.attributes.Attribute; import common.biome.Biome; import common.entity.DamageSource; import common.entity.Entity; @@ -661,7 +660,7 @@ public class EntitySlime extends EntityNPC if (this.entity.onGround) { - this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue())); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getMovementSpeed())); if (this.jumpDelay-- <= 0) { @@ -688,7 +687,7 @@ public class EntitySlime extends EntityNPC } else { - this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue())); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getMovementSpeed())); } } } diff --git a/common/src/main/java/common/entity/npc/EntitySpaceMarine.java b/common/src/main/java/common/entity/npc/EntitySpaceMarine.java index 82dd32e..841ee67 100755 --- a/common/src/main/java/common/entity/npc/EntitySpaceMarine.java +++ b/common/src/main/java/common/entity/npc/EntitySpaceMarine.java @@ -2,7 +2,6 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attribute; import common.collect.Lists; import common.init.Items; import common.init.SpeciesRegistry; @@ -118,7 +117,7 @@ public class EntitySpaceMarine extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D); + this.setAttackDamageBase(12); } protected ItemStack pickItem() { diff --git a/common/src/main/java/common/entity/npc/EntityTiefling.java b/common/src/main/java/common/entity/npc/EntityTiefling.java index 507d49c..fb52552 100755 --- a/common/src/main/java/common/entity/npc/EntityTiefling.java +++ b/common/src/main/java/common/entity/npc/EntityTiefling.java @@ -1,6 +1,5 @@ package common.entity.npc; -import common.attributes.Attribute; import common.rng.Random; import common.world.World; @@ -80,6 +79,6 @@ public class EntityTiefling extends EntityMobNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3.0D); + this.setAttackDamageBase(3); } } diff --git a/common/src/main/java/common/entity/npc/EntityUndead.java b/common/src/main/java/common/entity/npc/EntityUndead.java index 73441b1..b16db28 100755 --- a/common/src/main/java/common/entity/npc/EntityUndead.java +++ b/common/src/main/java/common/entity/npc/EntityUndead.java @@ -1,7 +1,6 @@ package common.entity.npc; import common.ai.EntityAIAvoidEntity; -import common.attributes.Attribute; import common.entity.animal.EntityWolf; import common.entity.types.EntityLiving; import common.init.Items; @@ -21,7 +20,7 @@ public class EntityUndead extends EntityNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); + this.setSpeedBase(0.25f); } // protected String getLivingSound() diff --git a/common/src/main/java/common/entity/npc/EntityVampire.java b/common/src/main/java/common/entity/npc/EntityVampire.java index 8972361..507976e 100755 --- a/common/src/main/java/common/entity/npc/EntityVampire.java +++ b/common/src/main/java/common/entity/npc/EntityVampire.java @@ -1,6 +1,5 @@ package common.entity.npc; -import common.attributes.Attribute; import common.entity.effect.EntityLightning; import common.rng.Random; import common.world.World; @@ -75,6 +74,6 @@ public class EntityVampire extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(5.0D); + this.setAttackDamageBase(5); } } diff --git a/common/src/main/java/common/entity/npc/EntityZombie.java b/common/src/main/java/common/entity/npc/EntityZombie.java index a816488..1378a88 100755 --- a/common/src/main/java/common/entity/npc/EntityZombie.java +++ b/common/src/main/java/common/entity/npc/EntityZombie.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.function.Predicate; import common.ai.EntityAIMoveThroughVillage; -import common.attributes.Attribute; -import common.attributes.AttributeModifier; import common.entity.DamageSource; import common.entity.animal.EntityChicken; import common.entity.types.EntityLiving; @@ -27,11 +25,13 @@ public class EntityZombie extends EntityNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(28.0D); - this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); - this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3.0D); - this.getAttributeMap().registerAttribute(Attribute.REINFORCEMENT_CHANCE).setBaseValue(this.rand.doublev() * 0.10000000149011612D); + this.setSpeedBase(0.23000000417232513f); + this.setAttackDamageBase(3); } + + public int getPathingRange() { + return 28; + } public void onLivingUpdate() { @@ -53,7 +53,7 @@ public class EntityZombie extends EntityNPC entitylivingbase = (EntityLiving)source.getEntity(); } - if (entitylivingbase != null && /* this.worldObj.getDifficulty() == Difficulty.HARD && */ (double)this.rand.floatv() < this.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).getAttributeValue() && Vars.mobs && Vars.spawnMoreZombie) + if (entitylivingbase != null && Vars.mobs && Vars.spawnMoreZombie > 0 && this.rand.chance(Vars.spawnMoreZombie)) { int i = ExtMath.floord(this.posX); int j = ExtMath.floord(this.posY); @@ -75,8 +75,6 @@ public class EntityZombie extends EntityNPC this.worldObj.spawnEntityInWorld(entityzombie); entityzombie.setAttackTarget(entitylivingbase); entityzombie.onInitialSpawn(null); - this.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, false)); - entityzombie.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, false)); break; } } @@ -250,24 +248,19 @@ public class EntityZombie extends EntityNPC // } // } - this.getEntityAttribute(Attribute.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.doublev() * 0.05000000074505806D, false)); - double d0 = this.rand.doublev() * 15.0; - - if (d0 > 1.0D) - { - this.getEntityAttribute(Attribute.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, false)); - } - if (this.rand.chance(30)) { - this.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.doublev() * 0.25D + 0.5D, false)); - this.getEntityAttribute(Attribute.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.roll(4), true)); + this.setMaxHealth(this.getMaxHealth() + this.rand.roll(12)); // this.setBreakDoorsAItask(true); } return livingdata; } + public double getKnockBackResistance() { + return 0.05; + } + public int getColor() { return 0xff0000; } diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index 69b4b42..032f859 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -14,10 +14,7 @@ import common.ai.EntityLookHelper; import common.ai.EntityMoveHelper; import common.ai.EntitySenses; import common.attributes.Attribute; -import common.attributes.AttributeInstance; import common.attributes.AttributeMap; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; import common.block.Block; import common.block.SoundType; import common.collect.Lists; @@ -70,7 +67,7 @@ public abstract class EntityLiving extends Entity { private static final ItemStack[] EMPTY_INV = new ItemStack[5]; - private AttributeMap attributes; + protected AttributeMap attributes = new AttributeMap(); private final List combat = Lists.newArrayList(); private final Map effects = Maps.newEnumMap(Potion.class); public int soundTimer; @@ -156,6 +153,8 @@ public abstract class EntityLiving extends Entity private float ageHeight; private EntityAIBase aiBase = new EntityAIMoveTowardsRestriction(this, 1.0D); private boolean isMovementAITaskSet; + private float baseSpeed = 0.7f; + private float modSpeed = 1.0f; public EntityLiving(World worldIn) { @@ -182,23 +181,16 @@ public abstract class EntityLiving extends Entity protected void entityInit() { - this.dataWatcher.addObject(7, Integer.valueOf(0)); - this.dataWatcher.addObject(8, Byte.valueOf((byte)0)); - this.dataWatcher.addObject(9, Byte.valueOf((byte)0)); - this.dataWatcher.addObject(6, Integer.valueOf(1)); - this.dataWatcher.addObject(12, Integer.valueOf(0)); -// this.dataWatcher.addObject(15, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(2, 0); // potion color + this.dataWatcher.addObject(3, (byte)0); // potion ambient + this.dataWatcher.addObject(4, (byte)0); // arrows + this.dataWatcher.addObject(5, 1); // max health + this.dataWatcher.addObject(6, 1); // health + this.dataWatcher.addObject(7, 0); // age } protected void applyEntityAttributes() { - this.getAttributeMap().registerAttribute(Attribute.MAX_HEALTH); - this.getAttributeMap().registerAttribute(Attribute.KNOCKBACK_RESISTANCE); - this.getAttributeMap().registerAttribute(Attribute.MOVEMENT_SPEED); - this.getAttributeMap().registerAttribute(Attribute.RADIATION); - this.getAttributeMap().registerAttribute(Attribute.RADIATION_RESISTANCE); - - this.getAttributeMap().registerAttribute(Attribute.FOLLOW_RANGE).setBaseValue(16.0D); } protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos) @@ -367,8 +359,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 + (float)this.attributes.getAttributeInstance(Attribute.RADIATION).getAttributeValue(); - radiation -= (float)this.attributes.getAttributeInstance(Attribute.RADIATION_RESISTANCE).getAttributeValue(); + float radiation = this.radiation + this.attributes.get(Attribute.RADIATION); + radiation -= 10.0f + this.attributes.get(Attribute.RADIATION_RESISTANCE); // if(this.isPlayer()) // Log.SERVER.info("rad:" + radiation); if(radiation >= 0.0f) { @@ -540,6 +532,7 @@ public abstract class EntityLiving extends Entity */ public void writeEntity(TagObject tagCompound) { + tagCompound.setInt("MaxHealth", this.getMaxHealth()); tagCompound.setInt("Health", this.getHealth()); // tagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth()))); tagCompound.setShort("HurtTime", (short)this.hurtTime); @@ -547,24 +540,7 @@ public abstract class EntityLiving extends Entity tagCompound.setFloat("Radiation", this.radiation); tagCompound.setShort("DeathTime", (short)this.deathTime); tagCompound.setInt("Absorption", this.getAbsorptionAmount()); - - for (ItemStack itemstack : this.getInventory()) - { - if (itemstack != null) - { - this.attributes.removeAttributeModifiers(itemstack.getAttributeModifiers(1)); - } - } - - tagCompound.setList("Attributes", Attributes.writeBaseAttributeMapToNBT(this.getAttributeMap())); - - for (ItemStack itemstack1 : this.getInventory()) - { - if (itemstack1 != null) - { - this.attributes.applyAttributeModifiers(itemstack1.getAttributeModifiers(1)); - } - } + tagCompound.setFloat("SpeedBase", this.getSpeedBase()); if (!this.effects.isEmpty()) { @@ -611,11 +587,7 @@ public abstract class EntityLiving extends Entity public void readEntity(TagObject tagCompund) { this.setAbsorptionAmount(tagCompund.getInt("Absorption")); - - if (tagCompund.hasList("Attributes") && this.worldObj != null && !this.worldObj.client) - { - Attributes.setAttributeModifiers(this.getAttributeMap(), tagCompund.getList("Attributes")); - } + this.setSpeedBase(tagCompund.getFloat("SpeedBase")); if (tagCompund.hasList("ActiveEffects")) { @@ -633,6 +605,7 @@ public abstract class EntityLiving extends Entity } } + this.setMaxHealth(Math.max(1, tagCompund.getInt("MaxHealth"))); if (tagCompund.hasInt("Health")) { this.setHealth(tagCompund.getInt("Health")); @@ -708,8 +681,8 @@ public abstract class EntityLiving extends Entity this.effectsDirty = false; } - int i = this.dataWatcher.getWatchableObjectInt(7); - boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0; + int i = this.dataWatcher.getWatchableObjectInt(2); + boolean flag1 = this.dataWatcher.getWatchableObjectByte(3) > 0; if (i > 0) { @@ -753,8 +726,8 @@ public abstract class EntityLiving extends Entity else { int i = PotionHelper.calcPotionLiquidColor(this.effects.values()); - this.dataWatcher.updateObject(8, Byte.valueOf((byte)(PotionHelper.getAreAmbient(this.effects.values()) ? 1 : 0))); - this.dataWatcher.updateObject(7, Integer.valueOf(i)); + this.dataWatcher.updateObject(3, Byte.valueOf((byte)(PotionHelper.getAreAmbient(this.effects.values()) ? 1 : 0))); + this.dataWatcher.updateObject(2, Integer.valueOf(i)); // this.setInvisible(this.hasEffect(Potion.invisibility.id)); } } @@ -764,8 +737,8 @@ public abstract class EntityLiving extends Entity */ protected void resetPotionEffectMetadata() { - this.dataWatcher.updateObject(8, Byte.valueOf((byte)0)); - this.dataWatcher.updateObject(7, Integer.valueOf(0)); + this.dataWatcher.updateObject(3, Byte.valueOf((byte)0)); + this.dataWatcher.updateObject(2, Integer.valueOf(0)); } public void clearEffects(boolean negative) @@ -864,7 +837,7 @@ public abstract class EntityLiving extends Entity if (!this.worldObj.client) { - id.getPotion().addModifiers(this, this.getAttributeMap(), id.getAmplifier()); + id.getPotion().addModifiers(this, id.getAmplifier()); } } @@ -874,8 +847,8 @@ public abstract class EntityLiving extends Entity if (added && !this.worldObj.client) { - id.getPotion().removeModifiers(this, this.getAttributeMap(), id.getAmplifier()); - id.getPotion().addModifiers(this, this.getAttributeMap(), id.getAmplifier()); + id.getPotion().removeModifiers(this, id.getAmplifier()); + id.getPotion().addModifiers(this, id.getAmplifier()); } } @@ -885,7 +858,7 @@ public abstract class EntityLiving extends Entity if (!this.worldObj.client) { - effect.getPotion().removeModifiers(this, this.getAttributeMap(), effect.getAmplifier()); + effect.getPotion().removeModifiers(this, effect.getAmplifier()); } } @@ -901,11 +874,6 @@ public abstract class EntityLiving extends Entity this.setHealth(f + healAmount); } } - - public void healMana(int amount) - { - this.setManaPoints(ExtMath.clampi(this.getManaPoints() + amount, 0, this.getMaxMana())); - } public final int getHealth() { @@ -1142,7 +1110,7 @@ public abstract class EntityLiving extends Entity */ public void knockBack(Entity source, float damage, double xfactor, double zfactor) { - if (this.rand.doublev() >= this.getEntityAttribute(Attribute.KNOCKBACK_RESISTANCE).getAttributeValue()) + if (!this.hasEffect(Potion.STABILITY) && this.rand.doublev() >= this.getKnockBackResistance()) { this.isAirBorne = true; float div = ExtMath.sqrtd(xfactor * xfactor + zfactor * zfactor); @@ -1368,21 +1336,12 @@ public abstract class EntityLiving extends Entity public final int getMaxHealth() { - return (int)this.getEntityAttribute(Attribute.MAX_HEALTH).getAttributeValue(); - } - - public final int getRawMaxHealth() - { - return (int)this.getEntityAttribute(Attribute.MAX_HEALTH).getBaseValue(); + return this.dataWatcher.getWatchableObjectInt(5); } public final void setMaxHealth(int max) { - this.getEntityAttribute(Attribute.MAX_HEALTH).setBaseValue((double)max); - } - - public int getMaxMana() { - return 0; + this.dataWatcher.updateObject(5, max); } /** @@ -1390,7 +1349,7 @@ public abstract class EntityLiving extends Entity */ public final int getArrowCountInEntity() { - return this.dataWatcher.getWatchableObjectByte(9); + return this.dataWatcher.getWatchableObjectByte(4); } /** @@ -1398,7 +1357,7 @@ public abstract class EntityLiving extends Entity */ public final void setArrowCountInEntity(int count) { - this.dataWatcher.updateObject(9, Byte.valueOf((byte)count)); + this.dataWatcher.updateObject(4, Byte.valueOf((byte)count)); } /** @@ -1500,18 +1459,8 @@ public abstract class EntityLiving extends Entity this.swingFactor = (float)this.swingTimer / (float)i; } - public AttributeInstance getEntityAttribute(Attribute attribute) + public final AttributeMap getAttributeMap() { - return this.getAttributeMap().getAttributeInstance(attribute); - } - - public AttributeMap getAttributeMap() - { - if (this.attributes == null) - { - this.attributes = new AttributeMap(this.worldObj == null || this.worldObj.client); - } - return this.attributes; } @@ -1533,25 +1482,6 @@ public abstract class EntityLiving extends Entity } // public abstract void setItem(int slot, ItemStack stack); - /** - * Set sprinting switch for Entity. - */ - public void setSprinting(boolean sprinting) - { - super.setSprinting(sprinting); - AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); - - if (iattributeinstance.hasModifier(Attributes.SPRINT_SPEED_MOD)) - { - iattributeinstance.removeModifier(Attributes.SPRINT_SPEED_MOD); - } - - if (sprinting) - { - iattributeinstance.applyModifier(Attributes.SPRINT_SPEED_MOD); - } - } - /** * returns the inventory of this entity (only used in EntityNPCMP it seems) */ @@ -1828,6 +1758,27 @@ public abstract class EntityLiving extends Entity { return this.landMovement; } + + public float getSpeedBase() { + return this.baseSpeed; + } + + public void setSpeedBase(float value) { + this.baseSpeed = value; + } + + public final void setSpeedMod(float value) { + this.modSpeed = value; + } + + public float getMovementSpeed() { + float speed = this.getSpeedBase() * (this.isSprinting() ? 1.3f : 1.0f); + if(this.hasEffect(Potion.SPEED)) + speed *= 1.0f + (float)(this.getEffect(Potion.SPEED).getAmplifier() + 1) * 0.2f; + if(this.hasEffect(Potion.SLOWNESS)) + speed *= Math.max(1.0f - (float)(this.getEffect(Potion.SLOWNESS).getAmplifier() + 1) * 0.15f, 0.0f); + return Math.max(this.modSpeed * speed, 0.0f); + } /** * set the movespeed used for the new AI system @@ -2293,13 +2244,17 @@ public abstract class EntityLiving extends Entity { return !this.dead; } + + public double getKnockBackResistance() { + return 0.0; + } /** * Sets that this entity has been attacked. */ protected void setBeenAttacked() { - this.veloChanged = this.rand.doublev() >= this.getEntityAttribute(Attribute.KNOCKBACK_RESISTANCE).getAttributeValue(); + this.veloChanged = !this.hasEffect(Potion.STABILITY) && this.rand.doublev() >= this.getKnockBackResistance(); } public float getRotationYawHead() @@ -2369,13 +2324,6 @@ public abstract class EntityLiving extends Entity return max >= 2000 ? TextColor.BLACK : (max >= 500 ? TextColor.DMAGENTA : (max >= 120 ? TextColor.MAGENTA : (max >= 40 ? TextColor.CYAN : (max >= 15 ? TextColor.NEON : (max >= 5 ? TextColor.BLUE : TextColor.LGRAY))))); } - - public int getManaPoints() { - return 0; - } - - public void setManaPoints(int pts) { - } public int getEnergy(Energy type) { return 0; @@ -2395,9 +2343,8 @@ public abstract class EntityLiving extends Entity public String formatStats() { return String.format(this.getAlignment().prefix + " " + getHealthColor(this.getHealth(), this.getMaxHealth()) + "%d" + - TextColor.GRAY + "/" + getMaxHpColor(this.getMaxHealth()) + - "%d" + (this.getManaPoints() == 0 ? "" : (TextColor.GRAY + " [" + TextColor.MIDNIGHT + "%d" + TextColor.GRAY + "]")), - this.getHealth(), this.getMaxHealth(), this.getManaPoints()); + TextColor.GRAY + "/" + getMaxHpColor(this.getMaxHealth()) + "%d", + this.getHealth(), this.getMaxHealth()); } public abstract int getColor(); @@ -2700,10 +2647,12 @@ public abstract class EntityLiving extends Entity // super.setAIMoveSpeed(speedIn); // this.setMoveForward(speedIn); // } + + public int getPathingRange() { + return 16; + } public Object onInitialSpawn(Object livingdata) { - this.getEntityAttribute(Attribute.FOLLOW_RANGE) - .applyModifier(new AttributeModifier("Random spawn bonus", this.rand.gaussian() * 0.05D, true)); return livingdata; } @@ -3231,7 +3180,7 @@ public abstract class EntityLiving extends Entity public int getGrowingAge() { - return this.worldObj.client ? this.dataWatcher.getWatchableObjectInt(12) : this.growingAge; + return this.worldObj.client ? this.dataWatcher.getWatchableObjectInt(7) : this.growingAge; } public void grow(int amount) @@ -3243,7 +3192,7 @@ public abstract class EntityLiving extends Entity public void setGrowingAge(int age) { - this.dataWatcher.updateObject(12, Integer.valueOf(ExtMath.clampi(age, -24000, 1))); + this.dataWatcher.updateObject(7, Integer.valueOf(ExtMath.clampi(age, -24000, 1))); this.growingAge = age; this.setScaleForAge(); } diff --git a/common/src/main/java/common/init/ItemRegistry.java b/common/src/main/java/common/init/ItemRegistry.java index 1729a49..df94f8a 100755 --- a/common/src/main/java/common/init/ItemRegistry.java +++ b/common/src/main/java/common/init/ItemRegistry.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; +import common.attributes.UsageSlot; import common.block.Block; import common.block.artificial.BlockBed; import common.block.artificial.BlockDoor; @@ -228,10 +229,10 @@ public abstract class ItemRegistry { registerItem(name + "_sword", (new ItemSword(material)).setDisplay(prefix + "schwert")); } if(material.hasArmor()) { - registerItem(name + "_helmet", (new ItemArmor(material, name, 0)).setDisplay(prefix == null ? "Kappe" : prefix + "helm")); - registerItem(name + "_chestplate", (new ItemArmor(material, name, 1)).setDisplay(prefix == null ? "Jacke" : prefix + "brustpanzer")); - registerItem(name + "_leggings", (new ItemArmor(material, name, 2)).setDisplay(prefix == null ? "Hose" : prefix + "beinschutz")); - registerItem(name + "_boots", (new ItemArmor(material, name, 3)).setDisplay(prefix == null ? "Stiefel" : prefix + "stiefel")); + registerItem(name + "_helmet", (new ItemArmor(material, name, UsageSlot.HEAD)).setDisplay(prefix == null ? "Kappe" : prefix + "helm")); + registerItem(name + "_chestplate", (new ItemArmor(material, name, UsageSlot.BODY)).setDisplay(prefix == null ? "Jacke" : prefix + "brustpanzer")); + registerItem(name + "_leggings", (new ItemArmor(material, name, UsageSlot.LEGS)).setDisplay(prefix == null ? "Hose" : prefix + "beinschutz")); + registerItem(name + "_boots", (new ItemArmor(material, name, UsageSlot.FEET)).setDisplay(prefix == null ? "Stiefel" : prefix + "stiefel")); } } diff --git a/common/src/main/java/common/init/ToolMaterial.java b/common/src/main/java/common/init/ToolMaterial.java index 5923f9a..5cf8dd3 100755 --- a/common/src/main/java/common/init/ToolMaterial.java +++ b/common/src/main/java/common/init/ToolMaterial.java @@ -2,6 +2,7 @@ package common.init; import java.util.Set; +import common.attributes.UsageSlot; import common.collect.Sets; import common.item.Item; @@ -120,20 +121,20 @@ public class ToolMaterial { return this.repair.contains(item); } - public int getDurability(int armorType) { - return MAX_DAMAGE[armorType] * this.maxDamageFactor; + public int getDurability(UsageSlot armorType) { + return armorType.getArmorSlot() < 0 ? 0 : MAX_DAMAGE[armorType.getArmorSlot()] * this.maxDamageFactor; } - public float getRadiationReduction(int armorType) { - return RAD_REDUCE[armorType] * this.radiationResistance; + public float getRadiationReduction(UsageSlot armorType) { + return armorType.getArmorSlot() < 0 ? 0.0f : RAD_REDUCE[armorType.getArmorSlot()] * this.radiationResistance; } - public float getMagicReduction(int armorType) { - return MAG_REDUCE[armorType] * this.magicResistance; + public float getMagicReduction(UsageSlot armorType) { + return armorType.getArmorSlot() < 0 ? 0.0f : MAG_REDUCE[armorType.getArmorSlot()] * this.magicResistance; } - public int getDamageReduction(int armorType) { - return this.damageReduction[armorType]; + public int getDamageReduction(UsageSlot armorType) { + return armorType.getArmorSlot() < 0 ? 0 : this.damageReduction[armorType.getArmorSlot()]; } public int getArmorEnchantability() { diff --git a/common/src/main/java/common/inventory/ContainerPlayer.java b/common/src/main/java/common/inventory/ContainerPlayer.java index 9c48af2..7db091b 100755 --- a/common/src/main/java/common/inventory/ContainerPlayer.java +++ b/common/src/main/java/common/inventory/ContainerPlayer.java @@ -3,6 +3,7 @@ package common.inventory; import java.util.List; import common.attributes.AttributeMap; +import common.attributes.UsageSlot; import common.collect.Lists; import common.entity.npc.EntityNPC; import common.init.CraftingRegistry; @@ -44,7 +45,7 @@ public class ContainerPlayer extends Container } public boolean isItemValid(ItemStack stack) { - return stack != null && stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType == k_f; // : (stack.getItem() != ItemRegistry.getItemFromBlock(Blocks.pumpkin) && stack.getItem() != Items.skull ? false : k_f == 0)); + return stack != null && stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType.getArmorSlot() == k_f; // : (stack.getItem() != ItemRegistry.getItemFromBlock(Blocks.pumpkin) && stack.getItem() != Items.skull ? false : k_f == 0)); } // public String getSlotTexture() // { @@ -90,12 +91,12 @@ public class ContainerPlayer extends Container { if (last != null) { - this.attributes.removeAttributeModifiers(last.getAttributeModifiers(2), slot.getIndex(), last.size); + this.attributes.remove(last.getAttributeModifiers(UsageSlot.INVENTORY), slot.getIndex()); } if (current != null) { - this.attributes.applyAttributeModifiers(current.getAttributeModifiers(2), slot.getIndex(), current.size); + this.attributes.add(current.getAttributeModifiers(UsageSlot.INVENTORY), slot.getIndex(), current.size); } last = current == null ? null : current.copy(); @@ -174,9 +175,9 @@ public class ContainerPlayer extends Container return null; } } - else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + ((ItemArmor)itemstack.getItem()).armorType)).getHasStack()) + else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot())).getHasStack()) { - int i = 5 + ((ItemArmor)itemstack.getItem()).armorType; + int i = 5 + ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot(); if (!this.mergeItemStack(itemstack1, i, i + 1, false)) { diff --git a/common/src/main/java/common/item/Item.java b/common/src/main/java/common/item/Item.java index faccb22..daa6b61 100755 --- a/common/src/main/java/common/item/Item.java +++ b/common/src/main/java/common/item/Item.java @@ -5,9 +5,8 @@ import java.util.Map; import java.util.Set; import common.attributes.Attribute; -import common.attributes.AttributeModifier; +import common.attributes.UsageSlot; import common.block.Block; -import common.collect.Maps; import common.collect.Sets; import common.color.TextColor; import common.entity.npc.EntityNPC; @@ -387,15 +386,13 @@ public class Item { return false; } - - public Map> getItemAttributeModifiers() - { - return Maps.newHashMap(); + + public int getAttackDamageBonus() { + return 0; } - public Map> getItemInventoryModifiers() + public void getModifiers(Map map, UsageSlot slot) { - return Maps.newHashMap(); } // public boolean canBeDyed() { diff --git a/common/src/main/java/common/item/ItemArmor.java b/common/src/main/java/common/item/ItemArmor.java index a0b2eae..3c5722c 100755 --- a/common/src/main/java/common/item/ItemArmor.java +++ b/common/src/main/java/common/item/ItemArmor.java @@ -2,14 +2,11 @@ package common.item; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.Predicate; import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; +import common.attributes.UsageSlot; import common.block.tech.BlockDispenser; -import common.collect.Sets; import common.dispenser.BehaviorDefaultDispenseItem; import common.dispenser.IBehaviorDispenseItem; import common.dispenser.IBlockSource; @@ -71,7 +68,7 @@ public class ItemArmor extends Item /** * Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots */ - public final int armorType; + public final UsageSlot armorType; /** Holds the amount of damage that the armor reduces at full durability. */ public final int damageReduceAmount; @@ -86,7 +83,7 @@ public class ItemArmor extends Item private final ToolMaterial material; private final String texture; - public ItemArmor(ToolMaterial material, String texture, int armorType) + public ItemArmor(ToolMaterial material, String texture, UsageSlot armorType) { this.material = material; this.texture = texture; @@ -256,18 +253,14 @@ public class ItemArmor extends Item // return this.material.canBeDyed(); // } - public Map> getItemAttributeModifiers() + public void getModifiers(Map map, UsageSlot slot) { - Map> multimap = super.getItemAttributeModifiers(); + if(slot != null && slot != this.armorType) + return; if(this.material.getRadiationReduction(this.armorType) > 0.0f) - multimap.put(Attribute.RADIATION_RESISTANCE, - Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID + (long)this.armorType + 1L, "Armor modifier " + (this.armorType + 1), - (double)this.material.getRadiationReduction(this.armorType), false))); + map.put(Attribute.RADIATION_RESISTANCE, this.material.getRadiationReduction(this.armorType)); if(this.material.getMagicReduction(this.armorType) > 0.0f) - multimap.put(Attribute.MAGIC_RESISTANCE, - Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID + (long)this.armorType + 1L, "Armor modifier " + (this.armorType + 1), - (double)this.material.getMagicReduction(this.armorType), false))); - return multimap; + map.put(Attribute.MAGIC_RESISTANCE, this.material.getMagicReduction(this.armorType)); } public boolean isMagnetic() { @@ -275,7 +268,7 @@ public class ItemArmor extends Item } public Transforms getTransform() { - return this.armorType == 0 ? Transforms.OFFSET2 : (this.armorType == 3 ? Transforms.OFFSET1 : + return this.armorType == UsageSlot.HEAD ? Transforms.OFFSET2 : (this.armorType == UsageSlot.FEET ? Transforms.OFFSET1 : super.getTransform()); } @@ -303,16 +296,16 @@ public class ItemArmor extends Item // if(stack.getItem() != ItemRegistry.getItemFromBlock(Blocks.pumpkin) && stack.getItem() != Items.skull) { if(stack.getItem() instanceof ItemArmor) { switch(((ItemArmor)stack.getItem()).armorType) { - case 0: + case HEAD: return 4; - case 1: + case BODY: return 3; - case 2: + case LEGS: return 2; - case 3: + case FEET: return 1; } } diff --git a/common/src/main/java/common/item/ItemBucketMilk.java b/common/src/main/java/common/item/ItemBucketMilk.java index 97e9cb6..90f2e49 100755 --- a/common/src/main/java/common/item/ItemBucketMilk.java +++ b/common/src/main/java/common/item/ItemBucketMilk.java @@ -1,12 +1,8 @@ package common.item; import java.util.Map; -import java.util.Set; - import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; -import common.collect.Sets; +import common.attributes.UsageSlot; import common.entity.npc.EntityNPC; import common.init.Items; import common.world.World; @@ -64,11 +60,10 @@ public class ItemBucketMilk extends Item return itemStackIn; } - public Map> getItemInventoryModifiers() + public void getModifiers(Map map, UsageSlot slot) { - Map> multimap = super.getItemInventoryModifiers(); - multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Milk modifier", -5.0, false, true, true))); - return multimap; + if(slot == null || slot == UsageSlot.INVENTORY) + map.put(Attribute.RADIATION, -5.0f); } public boolean isMagnetic() { diff --git a/common/src/main/java/common/item/ItemMetal.java b/common/src/main/java/common/item/ItemMetal.java index 92cb480..58656dc 100755 --- a/common/src/main/java/common/item/ItemMetal.java +++ b/common/src/main/java/common/item/ItemMetal.java @@ -2,12 +2,8 @@ package common.item; import java.util.List; import java.util.Map; -import java.util.Set; - import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; -import common.collect.Sets; +import common.attributes.UsageSlot; import common.color.TextColor; import common.entity.npc.EntityNPC; import common.init.MetalType; @@ -35,12 +31,10 @@ public class ItemMetal extends Item { // return this.metal.radioactivity > 0.0f ? ChatFormat.GREEN : super.getColor(stack); // } - public Map> getItemInventoryModifiers() + public void getModifiers(Map map, UsageSlot slot) { - Map> multimap = super.getItemInventoryModifiers(); - if(this.metal.radioactivity > 0.0f) - multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0, false, true, true))); - return multimap; + if((slot == null || slot == UsageSlot.INVENTORY) && this.metal.radioactivity > 0.0f) + map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f); } public float getRadiation(ItemStack stack) { diff --git a/common/src/main/java/common/item/ItemMetalBlock.java b/common/src/main/java/common/item/ItemMetalBlock.java index 89f45cd..a6531b2 100755 --- a/common/src/main/java/common/item/ItemMetalBlock.java +++ b/common/src/main/java/common/item/ItemMetalBlock.java @@ -2,13 +2,9 @@ package common.item; import java.util.List; import java.util.Map; -import java.util.Set; - import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; +import common.attributes.UsageSlot; import common.block.Block; -import common.collect.Sets; import common.color.TextColor; import common.entity.npc.EntityNPC; import common.init.MetalType; @@ -39,12 +35,10 @@ public class ItemMetalBlock extends ItemBlock { // return this.metal.radioactivity > 0.0f ? ChatFormat.GREEN : super.getColor(stack); // } - public Map> getItemInventoryModifiers() + public void getModifiers(Map map, UsageSlot slot) { - Map> multimap = super.getItemInventoryModifiers(); - if(this.metal.radioactivity > 0.0f) - multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0 * (this.ore ? 2.0 : 9.0), false, true, true))); - return multimap; + if((slot == null || slot == UsageSlot.INVENTORY) && this.metal.radioactivity > 0.0f) + map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f * (this.ore ? 2.0f : 9.0f)); } public float getRadiation(ItemStack stack) { diff --git a/common/src/main/java/common/item/ItemPotion.java b/common/src/main/java/common/item/ItemPotion.java index eeb5cfa..29a9c7b 100755 --- a/common/src/main/java/common/item/ItemPotion.java +++ b/common/src/main/java/common/item/ItemPotion.java @@ -3,12 +3,8 @@ package common.item; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; - -import common.attributes.Attribute; -import common.attributes.AttributeModifier; +import common.collect.Lists; import common.collect.Maps; -import common.collect.Sets; import common.color.TextColor; import common.entity.npc.EntityNPC; import common.entity.projectile.EntityPotion; @@ -22,8 +18,6 @@ import common.potion.PotionEffect; import common.potion.PotionHelper; import common.world.World; -import java.util.Set; - public class ItemPotion extends Item { private Map> effectCache = Maps.>newHashMap(); @@ -251,7 +245,7 @@ public class ItemPotion extends Item if ((stack.getMetadata() & 16383) != 0) { List list = Items.potion.getEffects(stack); - Map> multimap = Maps.newHashMap(); + List implications = Lists.newArrayList(); if (list != null && !list.isEmpty()) { @@ -259,30 +253,6 @@ public class ItemPotion extends Item { String s1 = potioneffect.getEffectName().trim(); Potion potion = potioneffect.getPotion(); - Map map = potion.getModifiers(); - - if (map != null && map.size() > 0) - { - for (Entry entry : map.entrySet()) - { - AttributeModifier attributemodifier = (AttributeModifier)entry.getValue(); - AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAmount(potioneffect.getAmplifier(), attributemodifier), attributemodifier.isMultiplied()); - Set set = multimap.get(entry.getKey()); - if(set == null) - multimap.put(entry.getKey(), set = Sets.newHashSet()); - set.add(attributemodifier1); -// multimap.put((Attribute)entry.getKey(), set); - } - } - -// if (potioneffect.getAmplifier() >= 1 && potioneffect.getAmplifier() <= 9) -// { -// s1 = s1 + " " + Strs.get("potion.potency." + potioneffect.getAmplifier()).trim(); -// } -// else if (potioneffect.getAmplifier() != 0) -// { -// s1 = s1 + " " + (potioneffect.getAmplifier() + 1); -// } if (potioneffect.getDuration() > 20) { @@ -297,6 +267,9 @@ public class ItemPotion extends Item { tooltip.add(TextColor.LGRAY + s1); } + String effectTip = potioneffect.getPotion().getTooltip(potioneffect.getAmplifier()); + if(effectTip != null) + implications.add(effectTip); } } else @@ -305,37 +278,11 @@ public class ItemPotion extends Item tooltip.add(TextColor.LGRAY + s); } - if (!multimap.isEmpty()) + if (!implications.isEmpty()) { tooltip.add(""); tooltip.add(TextColor.DMAGENTA + "Auswirkungen:"); - - for (Entry> entry1 : multimap.entrySet()) - { - for(AttributeModifier attributemodifier2 : entry1.getValue()) { - double d0 = attributemodifier2.getAmount(); - double d1; - - if (!attributemodifier2.isMultiplied()) - { - d1 = attributemodifier2.getAmount(); - } - else - { - d1 = attributemodifier2.getAmount() * 100.0D; - } - - if (d0 > 0.0D) - { - tooltip.add(TextColor.BLUE + String.format("+%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplay())); - } - else if (d0 < 0.0D) - { - d1 = d1 * -1.0D; - tooltip.add(TextColor.RED + String.format("-%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplay())); - } - } - } + tooltip.addAll(implications); } } } diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index 8285119..bae6da1 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -6,8 +6,7 @@ import java.util.Map; import java.util.Map.Entry; import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; +import common.attributes.UsageSlot; import common.block.Block; import common.collect.Lists; import common.collect.Maps; @@ -25,8 +24,6 @@ import common.util.BlockPos; import common.util.Facing; import common.world.World; -import java.util.Set; - public final class ItemStack { public static final int MAX_SIZE = 67108864; @@ -870,47 +867,36 @@ public final class ItemStack //// } // } } + + int damage = this.item.getAttackDamageBonus(); + damage += EnchantmentHelper.getDamageModifier(this); + if(damage != 0) { + if(damage > 0) + list.add(TextColor.BLUE + String.format("+%d Angriffsschaden", damage)); + else + list.add(TextColor.RED + String.format("-%d Angriffsschaden", damage)); + } - Map> multimap = this.getAttributeModifiers(3); + Map mods = this.getAttributeModifiers(null); - if (!multimap.isEmpty()) // && (i1 & 2) == 0) + if (!mods.isEmpty()) { list.add(""); - - for (Entry> entry : multimap.entrySet()) + for (Entry entry : mods.entrySet()) { - for(AttributeModifier mod : entry.getValue()) { - double amt = mod.getAmount(); - - if (mod.getID() == Attributes.ITEM_DMG_ID) - { - amt += (double)EnchantmentHelper.getDamageModifier(this); - } - - double num; - - if (!mod.isMultiplied()) - { - num = amt; - } - else - { - num = amt * 100.0D; - } - - if(mod.isInventory() && this.size != 1) { - double total = num * (double)this.size; - if (amt > 0.0D) - list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx +%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total), entry.getKey().getDisplay(), this.size, DECIMALFORMAT.format(num))); - else if (amt < 0.0D) - list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx -%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total * -1.0), entry.getKey().getDisplay(), this.size, DECIMALFORMAT.format(num * -1.0))); - } - else { - if (amt > 0.0D) - list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num), entry.getKey().getDisplay())); - else if (amt < 0.0D) - list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num * -1.0), entry.getKey().getDisplay())); - } + float amt = entry.getValue(); + if(this.size != 1) { + double total = amt * (double)this.size; + if (amt > 0.0D) + list.add(TextColor.BLUE + String.format("+%s %s [%dx +%s]", DECIMALFORMAT.format(total), entry.getKey(), this.size, DECIMALFORMAT.format(amt))); + else if (amt < 0.0D) + list.add(TextColor.RED + String.format("-%s %s [%dx -%s]", DECIMALFORMAT.format(total * -1.0), entry.getKey(), this.size, DECIMALFORMAT.format(amt * -1.0))); + } + else { + if (amt > 0.0D) + list.add(TextColor.BLUE + String.format("+%s %s", DECIMALFORMAT.format(amt), entry.getKey())); + else if (amt < 0.0D) + list.add(TextColor.RED + String.format("-%s %s", DECIMALFORMAT.format(amt * -1.0), entry.getKey())); } } } @@ -1174,41 +1160,11 @@ public final class ItemStack this.tag.setInt("RepairCost", cost); } - public Map> getAttributeModifiers(int type) - { - Map> multimap; - -// if ((type & 1) == 1 && this.hasTagCompound() && this.stackTagCompound.hasList("AttributeModifiers")) -// { -// multimap = HashMultimap.create(); -// NBTTagList nbttaglist = this.stackTagCompound.getTagList("AttributeModifiers", 10); -// -// for (int i = 0; i < nbttaglist.tagCount(); ++i) -// { -// NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); -// AttributeModifier attributemodifier = Attributes.readAttributeModifierFromNBT(nbttagcompound); -// -// if (attributemodifier != null && attributemodifier.getID() != 0L) -// { -// multimap.put(nbttagcompound.getString("AttributeName"), attributemodifier); -// } -// } -// } -// else - if((type & 1) == 1) - { - multimap = this.getItem().getItemAttributeModifiers(); - } - else { - multimap = Maps.newHashMap(); - } - - if((type & 2) == 2) { - multimap.putAll(this.getItem().getItemInventoryModifiers()); - } - - return multimap; - } + public Map getAttributeModifiers(UsageSlot slot) { + Map map = Maps.newEnumMap(Attribute.class); + this.getItem().getModifiers(map, slot); + return map; + } public void setItem(Item newItem) { diff --git a/common/src/main/java/common/item/ItemSword.java b/common/src/main/java/common/item/ItemSword.java index 85d992b..2a741fa 100755 --- a/common/src/main/java/common/item/ItemSword.java +++ b/common/src/main/java/common/item/ItemSword.java @@ -1,14 +1,7 @@ package common.item; -import java.util.Map; -import java.util.Set; - -import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; import common.block.Block; import common.block.Material; -import common.collect.Sets; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.init.Blocks; @@ -144,12 +137,9 @@ public class ItemSword extends Item { return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(toRepair, repair); } - - public Map> getItemAttributeModifiers() - { - Map> multimap = super.getItemAttributeModifiers(); - multimap.put(Attribute.ATTACK_DAMAGE, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_DMG_ID, "Weapon modifier", this.attackDamage, false))); - return multimap; + + public int getAttackDamageBonus() { + return this.attackDamage; } // public boolean canBreakBlocks() { diff --git a/common/src/main/java/common/item/ItemTool.java b/common/src/main/java/common/item/ItemTool.java index 89b658a..28e0768 100755 --- a/common/src/main/java/common/item/ItemTool.java +++ b/common/src/main/java/common/item/ItemTool.java @@ -1,13 +1,6 @@ package common.item; -import java.util.Map; -import java.util.Set; - -import common.attributes.Attribute; -import common.attributes.AttributeModifier; -import common.attributes.Attributes; import common.block.Block; -import common.collect.Sets; import common.entity.types.EntityLiving; import common.init.ToolMaterial; import common.model.Transforms; @@ -56,13 +49,10 @@ public abstract class ItemTool extends Item { public boolean getIsRepairable(ItemStack stack, ItemStack repair) { return this.material.isRepairItem(repair.getItem()) ? true : super.getIsRepairable(stack, repair); } - - public Map> getItemAttributeModifiers() { - Map> mods = super.getItemAttributeModifiers(); - mods.put(Attribute.ATTACK_DAMAGE, - Sets.newHashSet(new AttributeModifier(Attributes.ITEM_DMG_ID, "Tool modifier", this.damage, false))); - return mods; - } + + public int getAttackDamageBonus() { + return this.damage; + } public boolean isMagnetic() { return this.material.isMagnetic(); diff --git a/common/src/main/java/common/network/IClientPlayer.java b/common/src/main/java/common/network/IClientPlayer.java index eb4c55c..da6a2bc 100644 --- a/common/src/main/java/common/network/IClientPlayer.java +++ b/common/src/main/java/common/network/IClientPlayer.java @@ -10,7 +10,6 @@ import common.packet.SPacketEntityAttach; import common.packet.SPacketEntityMetadata; import common.packet.SPacketEntityEffect; import common.packet.SPacketRemoveEntityEffect; -import common.packet.SPacketEntityProperties; import common.packet.SPacketExplosion; import common.packet.SPacketEffect; import common.packet.SPacketSoundEffect; @@ -136,7 +135,6 @@ public interface IClientPlayer extends NetHandler { void handleSoundEffect(SPacketSoundEffect packet); void handleEntityTags(SPacketUpdateEntityTags packet); void handleParticles(SPacketParticles packet); - void handleEntityProperties(SPacketEntityProperties packet); void handleSkin(SPacketSkin packet); void handleTrades(SPacketTrades packet); void handleWorld(SPacketWorld packet); diff --git a/common/src/main/java/common/network/PacketRegistry.java b/common/src/main/java/common/network/PacketRegistry.java index be0ad70..7467719 100755 --- a/common/src/main/java/common/network/PacketRegistry.java +++ b/common/src/main/java/common/network/PacketRegistry.java @@ -46,7 +46,6 @@ import common.packet.SPacketEntityAttach; import common.packet.SPacketEntityMetadata; import common.packet.SPacketEntityEffect; import common.packet.SPacketRemoveEntityEffect; -import common.packet.SPacketEntityProperties; import common.packet.SPacketExplosion; import common.packet.SPacketEffect; import common.packet.SPacketSoundEffect; @@ -149,7 +148,6 @@ public enum PacketRegistry { this.server(SPacketEntityEffect.class); this.server(SPacketRemoveEntityEffect.class); this.server(SPacketSetExperience.class); - this.server(SPacketEntityProperties.class); this.server(SPacketChunkData.class); this.server(SPacketMultiBlockChange.class); this.server(SPacketBlockChange.class); diff --git a/common/src/main/java/common/packet/SPacketEntityProperties.java b/common/src/main/java/common/packet/SPacketEntityProperties.java deleted file mode 100755 index cb10fa6..0000000 --- a/common/src/main/java/common/packet/SPacketEntityProperties.java +++ /dev/null @@ -1,127 +0,0 @@ -package common.packet; - -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import common.attributes.AttributeInstance; -import common.attributes.AttributeModifier; -import common.collect.Lists; -import common.network.IClientPlayer; -import common.network.Packet; -import common.network.PacketBuffer; - -public class SPacketEntityProperties implements Packet -{ - private int entityId; - private final List field_149444_b = Lists.newArrayList(); - - public SPacketEntityProperties() - { - } - - public SPacketEntityProperties(int entityIdIn, Collection p_i45236_2_) - { - this.entityId = entityIdIn; - - for (AttributeInstance iattributeinstance : p_i45236_2_) - { - this.field_149444_b.add(new SPacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers())); - } - } - - /** - * Reads the raw packet data from the data stream. - */ - public void readPacketData(PacketBuffer buf) throws IOException - { - this.entityId = buf.readVarInt(); - int i = buf.readInt(); - - for (int j = 0; j < i; ++j) - { - String s = buf.readString(64); - double d0 = buf.readDouble(); - List list = Lists.newArrayList(); - int k = buf.readVarInt(); - - for (int l = 0; l < k; ++l) - { - long id = buf.readLong(); - list.add(new AttributeModifier(id, "Unknown synced attribute modifier", buf.readDouble(), buf.readBoolean())); - } - - this.field_149444_b.add(new SPacketEntityProperties.Snapshot(s, d0, list)); - } - } - - /** - * Writes the raw packet data to the data stream. - */ - public void writePacketData(PacketBuffer buf) throws IOException - { - buf.writeVarInt(this.entityId); - buf.writeInt(this.field_149444_b.size()); - - for (SPacketEntityProperties.Snapshot s20packetentityproperties$snapshot : this.field_149444_b) - { - buf.writeString(s20packetentityproperties$snapshot.func_151409_a()); - buf.writeDouble(s20packetentityproperties$snapshot.func_151410_b()); - buf.writeVarInt(s20packetentityproperties$snapshot.func_151408_c().size()); - - for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c()) - { - buf.writeLong(attributemodifier.getID()); - buf.writeDouble(attributemodifier.getAmount()); - buf.writeBoolean(attributemodifier.isMultiplied()); - } - } - } - - /** - * Passes this Packet on to the NetHandler for processing. - */ - public void processPacket(IClientPlayer handler) - { - handler.handleEntityProperties(this); - } - - public int getEntityId() - { - return this.entityId; - } - - public List func_149441_d() - { - return this.field_149444_b; - } - - public class Snapshot - { - private final String field_151412_b; - private final double field_151413_c; - private final Collection field_151411_d; - - public Snapshot(String p_i45235_2_, double p_i45235_3_, Collection p_i45235_5_) - { - this.field_151412_b = p_i45235_2_; - this.field_151413_c = p_i45235_3_; - this.field_151411_d = p_i45235_5_; - } - - public String func_151409_a() - { - return this.field_151412_b; - } - - public double func_151410_b() - { - return this.field_151413_c; - } - - public Collection func_151408_c() - { - return this.field_151411_d; - } - } -} diff --git a/common/src/main/java/common/pathfinding/PathNavigate.java b/common/src/main/java/common/pathfinding/PathNavigate.java index 98f9d0b..605a176 100755 --- a/common/src/main/java/common/pathfinding/PathNavigate.java +++ b/common/src/main/java/common/pathfinding/PathNavigate.java @@ -2,8 +2,6 @@ package common.pathfinding; import java.util.List; -import common.attributes.Attribute; -import common.attributes.AttributeInstance; import common.entity.Entity; import common.entity.types.EntityLiving; import common.util.BlockPos; @@ -21,11 +19,6 @@ public abstract class PathNavigate protected PathEntity currentPath; protected double speed; - /** - * The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space - */ - private final AttributeInstance pathSearchRange; - /** Time, in number of ticks, following the current path */ private int totalTicks; @@ -45,7 +38,6 @@ public abstract class PathNavigate { this.theEntity = entitylivingIn; this.worldObj = worldIn; - this.pathSearchRange = entitylivingIn.getEntityAttribute(Attribute.FOLLOW_RANGE); this.pathFinder = this.getPathFinder(); } @@ -64,7 +56,7 @@ public abstract class PathNavigate */ public float getPathSearchRange() { - return (float)this.pathSearchRange.getAttributeValue(); + return (float)this.theEntity.getPathingRange(); } /** diff --git a/common/src/main/java/common/potion/Potion.java b/common/src/main/java/common/potion/Potion.java index 5ccdb58..f711c42 100755 --- a/common/src/main/java/common/potion/Potion.java +++ b/common/src/main/java/common/potion/Potion.java @@ -1,33 +1,37 @@ package common.potion; import java.util.Map; -import java.util.Map.Entry; - -import common.attributes.Attribute; -import common.attributes.AttributeInstance; -import common.attributes.AttributeMap; -import common.attributes.AttributeModifier; import common.collect.Maps; +import common.color.TextColor; import common.entity.DamageSource; +import common.entity.npc.EntityNPC; import common.entity.projectile.EntityPotion; import common.entity.types.EntityLiving; import common.vars.Vars; public enum Potion { - SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attribute.MOVEMENT_SPEED, "PotSpd", 0.2, true)), - SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attribute.MOVEMENT_SPEED, "PotSlow", -0.15, true)), + SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462) { + public String getTooltip(int amp) { + return String.format(TextColor.BLUE + "+%d%% Geschwindigkeit", 20 * (amp + 1)); + } + }, + SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017) { + public String getTooltip(int amp) { + return String.format(TextColor.RED + "-%d%% Geschwindigkeit", 15 * (amp + 1)); + } + }, HASTE("haste", "Eile", "Trank der Eile", false, 14270531) { public double getEffectiveness() { return 1.5; } }, FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583), - STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043, new PotionModifier(Attribute.ATTACK_DAMAGE, "PotDmg", 2.5, true)) { - public double getAmount(int amp, AttributeModifier modifier) { - return 1.3D * (double)(amp + 1); - } + STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043) { + public String getTooltip(int amp) { + return String.format(TextColor.BLUE + "+%d%% Angriffsschaden", 50 * (amp + 1)); + } }, - HEAL("instant_health", "Direktheilung", "Trank der Heilung", false, 16262179) { + HEAL("health", "Direktheilung", "Trank der Heilung", false, 16262179) { public boolean isInstant() { return true; } @@ -47,7 +51,7 @@ public enum Potion { } } }, - DAMAGE("instant_damage", "Direktschaden", "Trank des Schadens", true, 4393481) { + DAMAGE("damage", "Direktschaden", "Trank des Schadens", true, 4393481) { public boolean isInstant() { return true; } @@ -86,11 +90,13 @@ public enum Potion { }, RESISTANCE("resistance", "Resistenz", "Trank des Widerstandes", false, 10044730), FIRE_RESISTANCE("fire_resistance", "Feuerschutz", "Trank der Feuerresistenz", false, 14981690), - MANA("mana_boost", "Manaschub", "Trank des Manaschubes", false, 3035801) { + MANA_GENERATION("mana_generation", "Manaschub", "Trank des Manaschubes", false, 3035801) { public void onUpdate(EntityLiving entity, int duration, int amp) { + if(!(entity instanceof EntityNPC npc)) + return; int k = 40 >> amp; - if((k <= 0 || duration % k == 0) && entity.getManaPoints() < entity.getMaxMana()) - entity.healMana(1); + if((k <= 0 || duration % k == 0) && npc.getManaPoints() < npc.getMaxMana()) + npc.healMana(1); } }, FLYING("flying", null, null, false, 8356754) { @@ -108,11 +114,11 @@ public enum Potion { } }, NIGHT_VISION("night_vision", "Nachtsicht", "Trank der Nachtsicht", false, 2039713), - STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459, new PotionModifier(Attribute.KNOCKBACK_RESISTANCE, "PotStbl", 1.0, false)), - WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376, new PotionModifier(Attribute.ATTACK_DAMAGE, "PotWeak", 2.0, false)) { - public double getAmount(int amp, AttributeModifier modifier) { - return (double)(-0.5F * (float)(amp + 1)); - } + STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459), + WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376) { + public String getTooltip(int amp) { + return String.format(TextColor.RED + "-%d%% Angriffsschaden", 20 * (amp + 1)); + } }, POISON("poison", "Vergiftung", "Trank der Vergiftung", true, 5149489) { public void onUpdate(EntityLiving entity, int duration, int amp) { @@ -125,22 +131,13 @@ public enum Potion { return 0.25; } }, - HEALTH("health_boost", "Extraenergie", "Trank der Extraenergie", false, 16284963, new PotionModifier(Attribute.MAX_HEALTH, "PotHp", 4.0, false)) { - public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) { - super.removeModifiers(entity, map, amp); - if(entity.getHealth() > entity.getMaxHealth()) - entity.setHealth(entity.getMaxHealth()); - } - }, ABSORPTION("absorption", "Absorption", "Trank der Absorption", false, 2445989) { - public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) { + public void removeModifiers(EntityLiving entity, int amp) { entity.setAbsorptionAmount(entity.getAbsorptionAmount() - (4 * (amp + 1))); - super.removeModifiers(entity, map, amp); } - public void addModifiers(EntityLiving entity, AttributeMap map, int amp) { + public void addModifiers(EntityLiving entity, int amp) { entity.setAbsorptionAmount(entity.getAbsorptionAmount() + (4 * (amp + 1))); - super.addModifiers(entity, map, amp); } }, RADIATION("radiation", "Strahlung", "Radioaktiver Trank", true, 0x00ff00) { @@ -148,25 +145,20 @@ public enum Potion { if(entity.ticksExisted % 20 == 0 && (entity.worldObj.client || Vars.damageRadiation)) // && entityLivingBaseIn.getHealth() > 1.0F) entity.attackEntityFrom(DamageSource.radiation, 1 + amp); } - }; - - private static class PotionModifier { - private final Attribute attribute; - private final String id; - private final double value; - private final boolean multiply; - - public PotionModifier(Attribute attr, String id, double value, boolean multiply) { - this.attribute = attr; - this.id = id; - this.value = value; - this.multiply = multiply; + }, + MANA("mana", "Mana", "Manatrank", false, 0x0000ff) { + public boolean isInstant() { + return true; } - } + + public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) { + if(entity instanceof EntityNPC npc) + npc.healMana(Math.max((int)(effect * (double)(4 << amp) + 0.5D), 0)); + } + }; private static final Map LOOKUP = Maps.newHashMap(); - private final Map modifiers = Maps.newHashMap(); private final String name; private final String effectDisplay; private final String potionDisplay; @@ -183,15 +175,12 @@ public enum Potion { return LOOKUP.get(name); } - private Potion(String name, String effectDisplay, String potionDisplay, boolean bad, int color, PotionModifier ... modifiers) { + private Potion(String name, String effectDisplay, String potionDisplay, boolean bad, int color) { this.name = name; this.bad = bad; this.color = color; this.effectDisplay = effectDisplay; this.potionDisplay = potionDisplay; - for(PotionModifier modifier : modifiers) { - this.modifiers.put(modifier.attribute, new AttributeModifier(AttributeModifier.getModifierId(modifier.id), "potion." + name, modifier.value, modifier.multiply)); - } } public String getName() { @@ -218,10 +207,6 @@ public enum Potion { return this.color; } - public Map getModifiers() { - return this.modifiers; - } - public void onUpdate(EntityLiving entity, int duration, int amp) { } @@ -231,31 +216,18 @@ public enum Potion { public boolean isInstant() { return false; } - - public double getAmount(int amp, AttributeModifier modifier) { - return modifier.getAmount() * (double)(amp + 1); + + public String getTooltip(int amp) { + return null; } public double getEffectiveness() { return this.bad ? 0.5 : 1.0; } - public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) { - for(Entry entry : this.modifiers.entrySet()) { - AttributeInstance attr = map.getAttributeInstance(entry.getKey()); - if(attr != null) - attr.removeModifier(entry.getValue()); - } + public void removeModifiers(EntityLiving entity, int amp) { } - public void addModifiers(EntityLiving entity, AttributeMap map, int amp) { - for(Entry entry : this.modifiers.entrySet()) { - AttributeInstance attr = map.getAttributeInstance(entry.getKey()); - if(attr != null) { - AttributeModifier mod = entry.getValue(); - attr.removeModifier(mod); - attr.applyModifier(new AttributeModifier(mod.getID(), "potion." + this.name + " " + amp, this.getAmount(amp, mod), mod.isMultiplied())); - } - } + public void addModifiers(EntityLiving entity, int amp) { } } diff --git a/common/src/main/java/common/util/LowerStringMap.java b/common/src/main/java/common/util/LowerStringMap.java deleted file mode 100755 index b445a3d..0000000 --- a/common/src/main/java/common/util/LowerStringMap.java +++ /dev/null @@ -1,75 +0,0 @@ -package common.util; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import common.collect.Maps; - -public class LowerStringMap implements Map -{ - private final Map internalMap = Maps.newLinkedHashMap(); - - public int size() - { - return this.internalMap.size(); - } - - public boolean isEmpty() - { - return this.internalMap.isEmpty(); - } - - public boolean containsKey(Object p_containsKey_1_) - { - return this.internalMap.containsKey(p_containsKey_1_.toString().toLowerCase()); - } - - public boolean containsValue(Object p_containsValue_1_) - { - return this.internalMap.containsKey(p_containsValue_1_); - } - - public V get(Object p_get_1_) - { - return this.internalMap.get(p_get_1_.toString().toLowerCase()); - } - - public V put(String p_put_1_, V p_put_2_) - { - return this.internalMap.put(p_put_1_.toLowerCase(), p_put_2_); - } - - public V remove(Object p_remove_1_) - { - return this.internalMap.remove(p_remove_1_.toString().toLowerCase()); - } - - public void putAll(Map p_putAll_1_) - { - for (Entry entry : p_putAll_1_.entrySet()) - { - this.put((String)entry.getKey(), entry.getValue()); - } - } - - public void clear() - { - this.internalMap.clear(); - } - - public Set keySet() - { - return this.internalMap.keySet(); - } - - public Collection values() - { - return this.internalMap.values(); - } - - public Set> entrySet() - { - return this.internalMap.entrySet(); - } -} diff --git a/common/src/main/java/common/vars/Vars.java b/common/src/main/java/common/vars/Vars.java index a3b25ad..a704e68 100755 --- a/common/src/main/java/common/vars/Vars.java +++ b/common/src/main/java/common/vars/Vars.java @@ -13,8 +13,6 @@ public abstract class Vars { public static boolean spawners = true; @Var(name = "spawnEggChickens") public static boolean spawnEggChicken = true; - @Var(name = "spawnMoreZombies") - public static boolean spawnMoreZombie = true; @Var(name = "spawnSplitSlimes") public static boolean spawnSplitSlime = true; @Var(name = "chargeHaunter") @@ -253,6 +251,8 @@ public abstract class Vars { public static int xpDelay = 0; // 2 @Var(name = "eggLayTime") public static int eggTimer = 6000; + @Var(name = "spawnMoreZombies") + public static int spawnMoreZombie = 25; @Var(name = "knockback") public static float knockback = 1.0f; diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 134abab..85338fd 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -459,6 +459,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer public void clonePlayer(EntityNPC oldPlayer) { + this.lastExperience = -1; + this.lastHealth = -1.0F; if(SVars.keepInventory) this.entity.inventory.copyInventory(oldPlayer.inventory); this.entity.experienceLevel = oldPlayer.experienceLevel; @@ -466,18 +468,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.entity.experience = oldPlayer.experience; this.entity.setEnchSeed(oldPlayer.getEnchSeed()); this.entity.setWarpChest(oldPlayer.getWarpChest()); -// this.entity.getDataWatcher().updateObject(10, Integer.valueOf(oldPlayer.getDataWatcher().getWatchableObjectInt(10))); - this.lastExperience = -1; - this.lastHealth = -1.0F; -// this.destroyedItemsNetCache.addAll(oldPlayer.connection.destroyedItemsNetCache); this.entity.setSkin(oldPlayer.getSkin()); - this.entity.getDataWatcher().updateObject(29, oldPlayer.getDataWatcher().getWatchableObjectFloat(29)); -// this.entity.getDataWatcher().updateObject(11, oldPlayer.getDataWatcher().getWatchableObjectByte(11)); - this.entity.getDataWatcher().updateObject(1, oldPlayer.getDataWatcher().getWatchableObjectString(1)); - this.entity.getDataWatcher().updateObject(18, oldPlayer.getDataWatcher().getWatchableObjectByte(18)); + this.entity.setHeight(oldPlayer.getHeight()); + this.entity.setCustomNameTag(oldPlayer.getCustomNameTag()); this.entity.setAlignment(oldPlayer.getAlignment()); -// this.stats.putAll(oldPlayer.stats); -// this.statsQueue.addAll(oldPlayer.statsQueue); } public void removeEntity(Entity p_152339_1_) @@ -2687,7 +2681,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.entity.removeEffect(Potion.RESISTANCE); this.entity.removeEffect(Potion.FIRE_RESISTANCE); this.entity.removeEffect(Potion.FLYING); - this.entity.removeEffect(Potion.MANA); + this.entity.removeEffect(Potion.MANA_GENERATION); this.addFeed(TextColor.RED + "Statuseffekte wurden entfernt"); } else { @@ -2699,7 +2693,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.entity.addEffect(new PotionEffect(Potion.RESISTANCE, Integer.MAX_VALUE, 255, false, false)); this.entity.addEffect(new PotionEffect(Potion.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, false, false)); this.entity.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 1, false, false)); - this.entity.addEffect(new PotionEffect(Potion.MANA, Integer.MAX_VALUE, 255, false, false)); + this.entity.addEffect(new PotionEffect(Potion.MANA_GENERATION, Integer.MAX_VALUE, 255, false, false)); this.addFeed(TextColor.GREEN + "Statuseffekte wurden hinzugefügt"); } } @@ -2956,7 +2950,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.entity.inventory.addItemStackToInventory(itemstack); amount -= itemstack.size; } - else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).armorType == packet.getSlot() - this.entity.inventory.mainInventory.length))) { + else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) { ItemStack old = this.entity.inventory.getStackInSlot(packet.getSlot()); if(old != null) { if(ItemStack.areItemsEqual(itemstack, old) && ItemStack.areItemStackTagsEqual(itemstack, old)) {