clean up enchantments
This commit is contained in:
parent
89e5775632
commit
38d29ba9c8
32 changed files with 708 additions and 961 deletions
|
@ -9,72 +9,553 @@ import common.collect.Maps;
|
|||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemArmor;
|
||||
import common.item.ItemAxe;
|
||||
import common.item.ItemShears;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.util.Displayable;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Identifyable;
|
||||
import common.vars.Vars;
|
||||
|
||||
public abstract class Enchantment implements Displayable, Identifyable
|
||||
public enum Enchantment implements Displayable, Identifyable
|
||||
{
|
||||
PROTECTION(0, "protection", 10, EnumEnchantmentType.ARMOR, "Schutz") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + (enchantmentLevel - 1) * 11;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 20;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.outOfWorld)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)(6 + level * level) / 3.0F;
|
||||
return ExtMath.floorf(f * 0.75F);
|
||||
}
|
||||
}
|
||||
},
|
||||
FIRE_PROTECTION(1, "fire_protection", 5, EnumEnchantmentType.ARMOR, "Feuerschutz") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 10 + (enchantmentLevel - 1) * 8;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 12;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.outOfWorld)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)(6 + level * level) / 3.0F;
|
||||
return source.isFireDamage() ? ExtMath.floorf(f * 1.25F) : 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
FEATHER_FALLING(2, "feather_falling", 5, EnumEnchantmentType.ARMOR_FEET, "Federfall") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 5 + (enchantmentLevel - 1) * 6;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 10;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.outOfWorld)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)(6 + level * level) / 3.0F;
|
||||
return source == DamageSource.fall ? ExtMath.floorf(f * 2.5F) : 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
BLAST_PROTECTION(3, "blast_protection", 2, EnumEnchantmentType.ARMOR, "Explosionsschutz") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 5 + (enchantmentLevel - 1) * 8;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 12;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.outOfWorld)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)(6 + level * level) / 3.0F;
|
||||
return source.isExplosion() ? ExtMath.floorf(f * 1.5F) : 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
PROJECTILE_PROTECTION(4, "projectile_protection", 5, EnumEnchantmentType.ARMOR, "Schusssicher") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 3 + (enchantmentLevel - 1) * 6;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 15;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.outOfWorld)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)(6 + level * level) / 3.0F;
|
||||
return source.isProjectile() ? ExtMath.floorf(f * 1.5F) : 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
THORNS(7, "thorns", 1, EnumEnchantmentType.ARMOR_TORSO, "Dornen") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 10 + 20 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemArmor ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
public void onUserHurt(EntityLiving user, Entity attacker, int level)
|
||||
{
|
||||
Random random = user.getRNG();
|
||||
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.THORNS, user);
|
||||
|
||||
if ((user.worldObj.client || Vars.damageThorns) && isThornsHurting(level, random))
|
||||
{
|
||||
if (attacker != null)
|
||||
{
|
||||
attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), getThornsDamage(level, random));
|
||||
// attacker.playSound("damage.thorns", 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
itemstack.damageItem(3, user);
|
||||
}
|
||||
}
|
||||
else if (itemstack != null)
|
||||
{
|
||||
itemstack.damageItem(1, user);
|
||||
}
|
||||
}
|
||||
},
|
||||
SHARPNESS(16, "sharpness", 10, EnumEnchantmentType.WEAPON, "Schärfe") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + (enchantmentLevel - 1) * 11;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 20;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public int calcAdditionalDamage(int level)
|
||||
{
|
||||
return (int)(/*this.damageType == 0 ? */ (float)level * 1.25F); // : (this.damageType == 1 && creatureType == CreatureType.UNDEAD ? (float)level * 2.5F : (this.damageType == 2 && creatureType == CreatureType.ARTHROPOD ? (float)level * 2.5F : 0.0F)));
|
||||
}
|
||||
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Called whenever a mob is damaged with an item that has this enchantment on it.
|
||||
// */
|
||||
// public void onEntityDamaged(EntityLivingBase user, Entity target, int level)
|
||||
// {
|
||||
// if (target instanceof EntityLivingBase)
|
||||
// {
|
||||
// EntityLivingBase entitylivingbase = (EntityLivingBase)target;
|
||||
//
|
||||
// if (this.damageType == 2 && entitylivingbase.getCreatureType() == CreatureType.ARTHROPOD)
|
||||
// {
|
||||
// int i = 20 + user.getRNG().zrange(10 * level);
|
||||
// entitylivingbase.addEffect(new PotionEffect(Potion.moveSlowdown.id, i, 3));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
},
|
||||
KNOCKBACK(19, "knockback", 5, EnumEnchantmentType.WEAPON, "Rückstoß") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 5 + 20 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
FIRE_ASPECT(20, "fire_aspect", 2, EnumEnchantmentType.WEAPON, "Verbrennung") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 10 + 20 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
LOOTING(21, "looting", 2, EnumEnchantmentType.WEAPON, "Plünderung") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15 + (enchantmentLevel - 1) * 9;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return super.canApplyTogether(ench) && ench.id != SILK_TOUCH.id;
|
||||
}
|
||||
},
|
||||
EFFICIENCY(32, "efficiency", 10, EnumEnchantmentType.DIGGER, "Effizienz") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + 10 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemShears ? true : super.canApply(stack);
|
||||
}
|
||||
},
|
||||
SILK_TOUCH(33, "silk_touch", 1, EnumEnchantmentType.DIGGER, "Behutsamkeit") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return super.canApplyTogether(ench) && ench.id != FORTUNE.id;
|
||||
}
|
||||
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemShears ? true : super.canApply(stack);
|
||||
}
|
||||
},
|
||||
UNBREAKING(34, "unbreaking", 5, EnumEnchantmentType.BREAKABLE, "Haltbarkeit") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 5 + (enchantmentLevel - 1) * 8;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.isItemStackDamageable() ? true : super.canApply(stack);
|
||||
}
|
||||
},
|
||||
FORTUNE(35, "fortune", 2, EnumEnchantmentType.DIGGER, "Glück") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15 + (enchantmentLevel - 1) * 9;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return super.canApplyTogether(ench) && ench.id != SILK_TOUCH.id;
|
||||
}
|
||||
},
|
||||
POWER(48, "power", 10, EnumEnchantmentType.BOW, "Stärke") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + (enchantmentLevel - 1) * 10;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 15;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
},
|
||||
PUNCH(49, "punch", 2, EnumEnchantmentType.BOW, "Schlag") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 12 + (enchantmentLevel - 1) * 20;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 25;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
FLAME(50, "flame", 2, EnumEnchantmentType.BOW, "Flamme") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
INFINITY(51, "infinity", 1, EnumEnchantmentType.BOW, "Unendlich") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
LUCK_OF_THE_SEA(61, "luck_of_the_sea", 2, EnumEnchantmentType.FISHING_ROD, "Glück des Meeres") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15 + (enchantmentLevel - 1) * 9;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return super.canApplyTogether(ench) && ench.id != SILK_TOUCH.id;
|
||||
}
|
||||
},
|
||||
LURE(62, "lure", 2, EnumEnchantmentType.FISHING_ROD, "Köder") {
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15 + (enchantmentLevel - 1) * 9;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
},
|
||||
DRAINING(64, "draining", 1, EnumEnchantmentType.WEAPON, "Seelenentzug") {
|
||||
public int getMinEnchantability(int enchantmentLevel) {
|
||||
return 2 + (enchantmentLevel - 1) * 11;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel) {
|
||||
return this.getMinEnchantability(enchantmentLevel) + 20;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
public boolean canApply(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
public void onEntityDamaged(EntityLiving user, Entity target, int level) {
|
||||
if(target instanceof EntityLiving) {
|
||||
EntityLiving entity = (EntityLiving)target;
|
||||
entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(user, user), (int)((float)level * 1.25F));
|
||||
user.heal((int)((entity.arePotionsInverted() ? 0.2f : 1.0f) * (float)level));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static final String[] LEVELS = new String[] {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"};
|
||||
private static final Enchantment[] LOOKUP = new Enchantment[256];
|
||||
public static final Enchantment[] ENCHANTMENTS;
|
||||
private static final Map<String, Enchantment> NAME_LOOKUP = Maps.<String, Enchantment>newHashMap();
|
||||
|
||||
public static final Enchantment protection = new EnchantmentProtection(0, "protection", 10, 0);
|
||||
public static final Enchantment fireProtection = new EnchantmentProtection(1, "fire_protection", 5, 1);
|
||||
public static final Enchantment featherFalling = new EnchantmentProtection(2, "feather_falling", 5, 2);
|
||||
public static final Enchantment blastProtection = new EnchantmentProtection(3, "blast_protection", 2, 3);
|
||||
public static final Enchantment projectileProtection = new EnchantmentProtection(4, "projectile_protection", 5, 4);
|
||||
public static final Enchantment thorns = new EnchantmentThorns(7, "thorns", 1);
|
||||
public static final Enchantment sharpness = new EnchantmentDamage(16, "sharpness", 10);
|
||||
public static final Enchantment knockback = new EnchantmentKnockback(19, "knockback", 5);
|
||||
public static final Enchantment fireAspect = new EnchantmentFireAspect(20, "fire_aspect", 2);
|
||||
public static final Enchantment looting = new EnchantmentLootBonus(21, "looting", 2, EnumEnchantmentType.WEAPON);
|
||||
public static final Enchantment efficiency = new EnchantmentDigging(32, "efficiency", 10);
|
||||
public static final Enchantment silkTouch = new EnchantmentUntouching(33, "silk_touch", 1);
|
||||
public static final Enchantment unbreaking = new EnchantmentDurability(34, "unbreaking", 5);
|
||||
public static final Enchantment fortune = new EnchantmentLootBonus(35, "fortune", 2, EnumEnchantmentType.DIGGER);
|
||||
public static final Enchantment power = new EnchantmentArrowDamage(48, "power", 10);
|
||||
public static final Enchantment punch = new EnchantmentArrowKnockback(49, "punch", 2);
|
||||
public static final Enchantment flame = new EnchantmentArrowFire(50, "flame", 2);
|
||||
public static final Enchantment infinity = new EnchantmentArrowInfinite(51, "infinity", 1);
|
||||
public static final Enchantment luckOfTheSea = new EnchantmentLootBonus(61, "luck_of_the_sea", 2, EnumEnchantmentType.FISHING_ROD);
|
||||
public static final Enchantment lure = new EnchantmentFishingSpeed(62, "lure", 2, EnumEnchantmentType.FISHING_ROD);
|
||||
public static final Enchantment draining = new EnchantmentDraining(64, "draining", 1);
|
||||
|
||||
public final int effectId;
|
||||
private final String id;
|
||||
public final int id;
|
||||
private final String name;
|
||||
private final int weight;
|
||||
public final EnumEnchantmentType type;
|
||||
private final String display;
|
||||
|
||||
public EnumEnchantmentType type;
|
||||
protected String name;
|
||||
static {
|
||||
for(Enchantment ench : values()) {
|
||||
if(LOOKUP[ench.id] != null)
|
||||
throw new IllegalArgumentException("Verzauberung mit id " + ench.id + " ist bereits registriert");
|
||||
if(NAME_LOOKUP.get(ench.name) != null)
|
||||
throw new IllegalArgumentException("Verzauberung mit name " + ench.name + " ist bereits registriert");
|
||||
LOOKUP[ench.id] = ench;
|
||||
NAME_LOOKUP.put(ench.name, ench);
|
||||
}
|
||||
List<Enchantment> list = Lists.<Enchantment>newArrayList();
|
||||
for(Enchantment enchantment : LOOKUP) {
|
||||
if(enchantment != null)
|
||||
list.add(enchantment);
|
||||
}
|
||||
ENCHANTMENTS = list.toArray(new Enchantment[list.size()]);
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantmentById(int enchID)
|
||||
{
|
||||
return enchID >= 0 && enchID < LOOKUP.length ? LOOKUP[enchID] : null;
|
||||
}
|
||||
|
||||
protected Enchantment(int enchID, String enchName, int enchWeight, EnumEnchantmentType enchType)
|
||||
{
|
||||
this.effectId = enchID;
|
||||
this.id = enchName;
|
||||
this.weight = enchWeight;
|
||||
this.type = enchType;
|
||||
|
||||
if (LOOKUP[enchID] != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Duplicate enchantment id!");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOOKUP[enchID] = this;
|
||||
NAME_LOOKUP.put(enchName, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an enchantment by using its location name.
|
||||
*/
|
||||
public static Enchantment getEnchantmentByLocation(String location)
|
||||
{
|
||||
return NAME_LOOKUP.get(location);
|
||||
|
@ -85,88 +566,62 @@ public abstract class Enchantment implements Displayable, Identifyable
|
|||
return NAME_LOOKUP.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the weight value of an Enchantment. This weight value is used within vanilla to determine how rare an
|
||||
* enchantment is.
|
||||
*/
|
||||
private Enchantment(int enchID, String enchName, int enchWeight, EnumEnchantmentType enchType, String display)
|
||||
{
|
||||
this.id = enchID;
|
||||
this.name = enchName;
|
||||
this.weight = enchWeight;
|
||||
this.type = enchType;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public int getWeight()
|
||||
{
|
||||
return this.weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum level that the enchantment can have.
|
||||
*/
|
||||
public int getMinLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + enchantmentLevel * 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the damage protection of the enchantment based on level and damage source passed.
|
||||
*/
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the additional damage that will be dealt by an item with this enchantment. This alternative to
|
||||
* calcModifierDamage is sensitive to the targets EnumCreatureAttribute.
|
||||
*/
|
||||
public int calcAdditionalDamage(int level)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the enchantment passed can be applyied together with this enchantment.
|
||||
*/
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return this != ench;
|
||||
}
|
||||
|
||||
public Enchantment setDisplay(String enchName)
|
||||
{
|
||||
this.name = enchName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return this.id;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of key of this enchantment.
|
||||
*/
|
||||
public String getDisplay()
|
||||
{
|
||||
return this.name;
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public String getFormattedName(int level)
|
||||
|
@ -174,41 +629,55 @@ public abstract class Enchantment implements Displayable, Identifyable
|
|||
return this.getDisplay() + " " + ((level >= 1 && level <= LEVELS.length) ? LEVELS[level - 1] : "" + level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this enchantment can be applied to a specific ItemStack.
|
||||
*/
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return this.type.canEnchantItem(stack.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever a mob is damaged with an item that has this enchantment on it.
|
||||
*/
|
||||
public void onEntityDamaged(EntityLiving user, Entity target, int level)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Whenever an entity that has this enchantment on one of its associated items is damaged this method will be
|
||||
* called.
|
||||
*/
|
||||
public void onUserHurt(EntityLiving user, Entity attacker, int level)
|
||||
{
|
||||
}
|
||||
|
||||
static
|
||||
public static int getFireTimeForEntity(Entity entity, int duration)
|
||||
{
|
||||
List<Enchantment> list = Lists.<Enchantment>newArrayList();
|
||||
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.FIRE_PROTECTION.id, entity.getInventory());
|
||||
|
||||
for (Enchantment enchantment : LOOKUP)
|
||||
if (i > 0)
|
||||
{
|
||||
if (enchantment != null)
|
||||
{
|
||||
list.add(enchantment);
|
||||
}
|
||||
duration -= ExtMath.floorf((float)duration * (float)i * 0.15F);
|
||||
}
|
||||
|
||||
ENCHANTMENTS = (Enchantment[])list.toArray(new Enchantment[list.size()]);
|
||||
return duration;
|
||||
}
|
||||
|
||||
public static double getKnockbackFactor(Entity entity, double strength)
|
||||
{
|
||||
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.BLAST_PROTECTION.id, entity.getInventory());
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
strength -= (double)ExtMath.floord(strength * (double)((float)i * 0.15F));
|
||||
}
|
||||
|
||||
return strength;
|
||||
}
|
||||
|
||||
public static boolean negateDamage(ItemStack stack, int level, Random rand)
|
||||
{
|
||||
return stack.getItem() instanceof ItemArmor && rand.floatv() < 0.6F ? false : rand.rarity(level + 1);
|
||||
}
|
||||
|
||||
public static boolean isThornsHurting(int level, Random rand)
|
||||
{
|
||||
return level <= 0 ? false : rand.floatv() < 0.15F * (float)level;
|
||||
}
|
||||
|
||||
public static int getThornsDamage(int level, Random rand)
|
||||
{
|
||||
return level > 10 ? level - 10 : rand.roll(4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentArrowDamage extends Enchantment
|
||||
{
|
||||
public EnchantmentArrowDamage(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.BOW);
|
||||
this.setDisplay("Stärke");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + (enchantmentLevel - 1) * 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 15;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentArrowFire extends Enchantment
|
||||
{
|
||||
public EnchantmentArrowFire(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.BOW);
|
||||
this.setDisplay("Flamme");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentArrowInfinite extends Enchantment
|
||||
{
|
||||
public EnchantmentArrowInfinite(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.BOW);
|
||||
this.setDisplay("Unendlich");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentArrowKnockback extends Enchantment
|
||||
{
|
||||
public EnchantmentArrowKnockback(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.BOW);
|
||||
this.setDisplay("Schlag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 12 + (enchantmentLevel - 1) * 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 25;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.item.ItemAxe;
|
||||
import common.item.ItemStack;
|
||||
|
||||
|
||||
public class EnchantmentDamage extends Enchantment
|
||||
{
|
||||
public EnchantmentDamage(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.WEAPON);
|
||||
this.setDisplay("Schärfe");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + (enchantmentLevel - 1) * 11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the additional damage that will be dealt by an item with this enchantment. This alternative to
|
||||
* calcModifierDamage is sensitive to the targets EnumCreatureAttribute.
|
||||
*/
|
||||
public int calcAdditionalDamage(int level)
|
||||
{
|
||||
return (int)(/*this.damageType == 0 ? */ (float)level * 1.25F); // : (this.damageType == 1 && creatureType == CreatureType.UNDEAD ? (float)level * 2.5F : (this.damageType == 2 && creatureType == CreatureType.ARTHROPOD ? (float)level * 2.5F : 0.0F)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the enchantment passed can be applyied together with this enchantment.
|
||||
*/
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return !(ench instanceof EnchantmentDamage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this enchantment can be applied to a specific ItemStack.
|
||||
*/
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Called whenever a mob is damaged with an item that has this enchantment on it.
|
||||
// */
|
||||
// public void onEntityDamaged(EntityLivingBase user, Entity target, int level)
|
||||
// {
|
||||
// if (target instanceof EntityLivingBase)
|
||||
// {
|
||||
// EntityLivingBase entitylivingbase = (EntityLivingBase)target;
|
||||
//
|
||||
// if (this.damageType == 2 && entitylivingbase.getCreatureType() == CreatureType.ARTHROPOD)
|
||||
// {
|
||||
// int i = 20 + user.getRNG().zrange(10 * level);
|
||||
// entitylivingbase.addEffect(new PotionEffect(Potion.moveSlowdown.id, i, 3));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.item.ItemShears;
|
||||
import common.item.ItemStack;
|
||||
|
||||
|
||||
public class EnchantmentDigging extends Enchantment
|
||||
{
|
||||
protected EnchantmentDigging(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.DIGGER);
|
||||
this.setDisplay("Effizienz");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 1 + 10 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this enchantment can be applied to a specific ItemStack.
|
||||
*/
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemShears ? true : super.canApply(stack);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemAxe;
|
||||
import common.item.ItemStack;
|
||||
|
||||
|
||||
public class EnchantmentDraining extends Enchantment {
|
||||
public EnchantmentDraining(int enchID, String enchName, int enchWeight) {
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.WEAPON);
|
||||
this.setDisplay("Seelenentzug");
|
||||
}
|
||||
|
||||
public int getMinEnchantability(int enchantmentLevel) {
|
||||
return 2 + (enchantmentLevel - 1) * 11;
|
||||
}
|
||||
|
||||
public int getMaxEnchantability(int enchantmentLevel) {
|
||||
return this.getMinEnchantability(enchantmentLevel) + 20;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
// public boolean canApplyTogether(Enchantment ench)
|
||||
// {
|
||||
// return !(ench instanceof EnchantmentDraining);
|
||||
// }
|
||||
|
||||
public boolean canApply(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
public void onEntityDamaged(EntityLiving user, Entity target, int level) {
|
||||
if(target instanceof EntityLiving) {
|
||||
EntityLiving entity = (EntityLiving)target;
|
||||
entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(user, user), (int)((float)level * 1.25F));
|
||||
user.heal((int)((entity.arePotionsInverted() ? 0.2f : 1.0f) * (float)level));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.item.ItemArmor;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
|
||||
|
||||
public class EnchantmentDurability extends Enchantment
|
||||
{
|
||||
protected EnchantmentDurability(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.BREAKABLE);
|
||||
this.setDisplay("Haltbarkeit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 5 + (enchantmentLevel - 1) * 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this enchantment can be applied to a specific ItemStack.
|
||||
*/
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.isItemStackDamageable() ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by ItemStack.attemptDamageItem. Randomly determines if a point of damage should be negated using the
|
||||
* enchantment level (par1). If the ItemStack is Armor then there is a flat 60% chance for damage to be negated no
|
||||
* matter the enchantment level, otherwise there is a 1-(par/1) chance for damage to be negated.
|
||||
*/
|
||||
public static boolean negateDamage(ItemStack stack, int level, Random rand)
|
||||
{
|
||||
return stack.getItem() instanceof ItemArmor && rand.floatv() < 0.6F ? false : rand.rarity(level + 1);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentFireAspect extends Enchantment
|
||||
{
|
||||
protected EnchantmentFireAspect(int enchID, String enchName, int enchWeight)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, EnumEnchantmentType.WEAPON);
|
||||
this.setDisplay("Verbrennung");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 10 + 20 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentFishingSpeed extends Enchantment
|
||||
{
|
||||
protected EnchantmentFishingSpeed(int enchID, String enchName, int enchWeight, EnumEnchantmentType enchType)
|
||||
{
|
||||
super(enchID, enchName, enchWeight, enchType);
|
||||
this.setDisplay("Köder");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15 + (enchantmentLevel - 1) * 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
|
@ -18,24 +18,12 @@ import common.tags.TagObject;
|
|||
|
||||
public class EnchantmentHelper
|
||||
{
|
||||
/** Is the random seed of enchantment effects. */
|
||||
private static final Random enchantmentRand = new Random();
|
||||
|
||||
/**
|
||||
* Used to calculate the extra armor of enchantments on armors equipped on player.
|
||||
*/
|
||||
private static final EnchantmentHelper.ModifierDamage enchantmentModifierDamage = new EnchantmentHelper.ModifierDamage();
|
||||
|
||||
/**
|
||||
* Used to calculate the (magic) extra damage done by enchantments on current equipped item of player.
|
||||
*/
|
||||
private static final EnchantmentHelper.ModifierLiving enchantmentModifierLiving = new EnchantmentHelper.ModifierLiving();
|
||||
private static final EnchantmentHelper.HurtIterator ENCHANTMENT_ITERATOR_HURT = new EnchantmentHelper.HurtIterator();
|
||||
private static final EnchantmentHelper.DamageIterator ENCHANTMENT_ITERATOR_DAMAGE = new EnchantmentHelper.DamageIterator();
|
||||
|
||||
/**
|
||||
* Returns the level of enchantment on the ItemStack passed.
|
||||
*/
|
||||
public static int getEnchantmentLevel(int enchID, ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
|
@ -86,9 +74,6 @@ public class EnchantmentHelper
|
|||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the enchantments for the specified stack.
|
||||
*/
|
||||
public static void setEnchantments(Map<Integer, Integer> enchMap, ItemStack stack)
|
||||
{
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
|
@ -254,7 +239,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getKnockbackModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.knockback.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.KNOCKBACK.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,7 +247,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getFireAspectModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.fireAspect.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.FIRE_ASPECT.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -286,7 +271,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getEfficiencyModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.efficiency.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.EFFICIENCY.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,7 +279,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static boolean getSilkTouchModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.silkTouch.effectId, player.getHeldItem()) > 0;
|
||||
return getEnchantmentLevel(Enchantment.SILK_TOUCH.id, player.getHeldItem()) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -302,7 +287,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getFortuneModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.fortune.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.FORTUNE.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,7 +295,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getLuckOfSeaModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.luckOfTheSea.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.LUCK_OF_THE_SEA.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -318,7 +303,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getLureModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.lure.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.LURE.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -326,7 +311,7 @@ public class EnchantmentHelper
|
|||
*/
|
||||
public static int getLootingModifier(EntityLiving player)
|
||||
{
|
||||
return getEnchantmentLevel(Enchantment.looting.effectId, player.getHeldItem());
|
||||
return getEnchantmentLevel(Enchantment.LOOTING.id, player.getHeldItem());
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -341,7 +326,7 @@ public class EnchantmentHelper
|
|||
{
|
||||
for (ItemStack itemstack : p_92099_1_.getInventory())
|
||||
{
|
||||
if (itemstack != null && getEnchantmentLevel(p_92099_0_.effectId, itemstack) > 0)
|
||||
if (itemstack != null && getEnchantmentLevel(p_92099_0_.id, itemstack) > 0)
|
||||
{
|
||||
return itemstack;
|
||||
}
|
||||
|
@ -496,7 +481,7 @@ public class EnchantmentHelper
|
|||
map = Maps.<Integer, RngEnchantment>newHashMap();
|
||||
}
|
||||
|
||||
map.put(enchantment.effectId, new RngEnchantment(enchantment, i));
|
||||
map.put(enchantment.id, new RngEnchantment(enchantment, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentKnockback extends Enchantment
|
||||
{
|
||||
protected EnchantmentKnockback(int p_i45768_1_, String p_i45768_2_, int p_i45768_3_)
|
||||
{
|
||||
super(p_i45768_1_, p_i45768_2_, p_i45768_3_, EnumEnchantmentType.WEAPON);
|
||||
this.setDisplay("Rückstoß");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 5 + 20 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
|
||||
|
||||
public class EnchantmentLootBonus extends Enchantment
|
||||
{
|
||||
protected EnchantmentLootBonus(int p_i45767_1_, String p_i45767_2_, int p_i45767_3_, EnumEnchantmentType p_i45767_4_)
|
||||
{
|
||||
super(p_i45767_1_, p_i45767_2_, p_i45767_3_, p_i45767_4_);
|
||||
|
||||
if (p_i45767_4_ == EnumEnchantmentType.DIGGER)
|
||||
{
|
||||
this.setDisplay("Glück");
|
||||
}
|
||||
else if (p_i45767_4_ == EnumEnchantmentType.FISHING_ROD)
|
||||
{
|
||||
this.setDisplay("Glück des Meeres");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setDisplay("Plünderung");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15 + (enchantmentLevel - 1) * 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the enchantment passed can be applyied together with this enchantment.
|
||||
*/
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return super.canApplyTogether(ench) && ench.effectId != silkTouch.effectId;
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.util.ExtMath;
|
||||
|
||||
|
||||
public class EnchantmentProtection extends Enchantment
|
||||
{
|
||||
private static final String[] NAMES = new String[] {"Schutz", "Feuerschutz", "Federfall", "Explosionsschutz", "Schusssicher"};
|
||||
|
||||
/**
|
||||
* Holds the base factor of enchantability needed to be able to use the enchant.
|
||||
*/
|
||||
private static final int[] baseEnchantability = new int[] {1, 10, 5, 5, 3};
|
||||
|
||||
/**
|
||||
* Holds how much each level increased the enchantability factor to be able to use this enchant.
|
||||
*/
|
||||
private static final int[] levelEnchantability = new int[] {11, 8, 6, 8, 6};
|
||||
|
||||
/**
|
||||
* Used on the formula of base enchantability, this is the 'window' factor of values to be able to use thing
|
||||
* enchant.
|
||||
*/
|
||||
private static final int[] thresholdEnchantability = new int[] {20, 12, 10, 12, 15};
|
||||
|
||||
/**
|
||||
* Defines the type of protection of the enchantment, 0 = all, 1 = fire, 2 = fall (feather fall), 3 = explosion and
|
||||
* 4 = projectile.
|
||||
*/
|
||||
public final int protectionType;
|
||||
|
||||
public EnchantmentProtection(int id, String name, int weight, int type)
|
||||
{
|
||||
super(id, name, weight, type == 2 ? EnumEnchantmentType.ARMOR_FEET : EnumEnchantmentType.ARMOR);
|
||||
this.protectionType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return baseEnchantability[this.protectionType] + (enchantmentLevel - 1) * levelEnchantability[this.protectionType];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return this.getMinEnchantability(enchantmentLevel) + thresholdEnchantability[this.protectionType];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the damage protection of the enchantment based on level and damage source passed.
|
||||
*/
|
||||
public int calcDamageReduction(int level, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.outOfWorld)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)(6 + level * level) / 3.0F;
|
||||
return this.protectionType == 0 ? ExtMath.floorf(f * 0.75F) : (this.protectionType == 1 && source.isFireDamage() ? ExtMath.floorf(f * 1.25F) : (this.protectionType == 2 && source == DamageSource.fall ? ExtMath.floorf(f * 2.5F) : (this.protectionType == 3 && source.isExplosion() ? ExtMath.floorf(f * 1.5F) : (this.protectionType == 4 && source.isProjectile() ? ExtMath.floorf(f * 1.5F) : 0))));
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return NAMES[this.protectionType];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the enchantment passed can be applyied together with this enchantment.
|
||||
*/
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
if (ench instanceof EnchantmentProtection)
|
||||
{
|
||||
EnchantmentProtection enchantmentprotection = (EnchantmentProtection)ench;
|
||||
return enchantmentprotection.protectionType == this.protectionType ? false : this.protectionType == 2 || enchantmentprotection.protectionType == 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.canApplyTogether(ench);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of ticks an entity should be set fire, adjusted for fire protection.
|
||||
*/
|
||||
public static int getFireTimeForEntity(Entity entity, int duration)
|
||||
{
|
||||
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.fireProtection.effectId, entity.getInventory());
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
duration -= ExtMath.floorf((float)duration * (float)i * 0.15F);
|
||||
}
|
||||
|
||||
return duration;
|
||||
}
|
||||
|
||||
public static double getKnockbackFactor(Entity entity, double strength)
|
||||
{
|
||||
int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.blastProtection.effectId, entity.getInventory());
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
strength -= (double)ExtMath.floord(strength * (double)((float)i * 0.15F));
|
||||
}
|
||||
|
||||
return strength;
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemArmor;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.vars.Vars;
|
||||
|
||||
public class EnchantmentThorns extends Enchantment
|
||||
{
|
||||
public EnchantmentThorns(int p_i45764_1_, String p_i45764_2_, int p_i45764_3_)
|
||||
{
|
||||
super(p_i45764_1_, p_i45764_2_, p_i45764_3_, EnumEnchantmentType.ARMOR_TORSO);
|
||||
this.setDisplay("Dornen");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 10 + 20 * (enchantmentLevel - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this enchantment can be applied to a specific ItemStack.
|
||||
*/
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemArmor ? true : super.canApply(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whenever an entity that has this enchantment on one of its associated items is damaged this method will be
|
||||
* called.
|
||||
*/
|
||||
public void onUserHurt(EntityLiving user, Entity attacker, int level)
|
||||
{
|
||||
Random random = user.getRNG();
|
||||
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.thorns, user);
|
||||
|
||||
if ((user.worldObj.client || Vars.damageThorns) && isHurting(level, random))
|
||||
{
|
||||
if (attacker != null)
|
||||
{
|
||||
attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), getDamage(level, random));
|
||||
// attacker.playSound("damage.thorns", 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
itemstack.damageItem(3, user);
|
||||
}
|
||||
}
|
||||
else if (itemstack != null)
|
||||
{
|
||||
itemstack.damageItem(1, user);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isHurting(int level, Random rand)
|
||||
{
|
||||
return level <= 0 ? false : rand.floatv() < 0.15F * (float)level;
|
||||
}
|
||||
|
||||
public static int getDamage(int level, Random rand)
|
||||
{
|
||||
return level > 10 ? level - 10 : rand.roll(4);
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package common.enchantment;
|
||||
|
||||
import common.item.ItemShears;
|
||||
import common.item.ItemStack;
|
||||
|
||||
|
||||
public class EnchantmentUntouching extends Enchantment
|
||||
{
|
||||
protected EnchantmentUntouching(int p_i45763_1_, String p_i45763_2_, int p_i45763_3_)
|
||||
{
|
||||
super(p_i45763_1_, p_i45763_2_, p_i45763_3_, EnumEnchantmentType.DIGGER);
|
||||
this.setDisplay("Behutsamkeit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal value of enchantability needed on the enchantment level passed.
|
||||
*/
|
||||
public int getMinEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value of enchantability nedded on the enchantment level passed.
|
||||
*/
|
||||
public int getMaxEnchantability(int enchantmentLevel)
|
||||
{
|
||||
return super.getMinEnchantability(enchantmentLevel) + 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum level that the enchantment can have.
|
||||
*/
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the enchantment passed can be applyied together with this enchantment.
|
||||
*/
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return super.canApplyTogether(ench) && ench.effectId != fortune.effectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this enchantment can be applied to a specific ItemStack.
|
||||
*/
|
||||
public boolean canApply(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemShears ? true : super.canApply(stack);
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ import common.block.artificial.BlockWall;
|
|||
import common.block.liquid.BlockLiquid;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.DimType;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.enchantment.EnchantmentProtection;
|
||||
import common.entity.effect.EntityLightning;
|
||||
import common.entity.item.EntityItem;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -422,7 +422,7 @@ public abstract class Entity
|
|||
public void setFire(int seconds)
|
||||
{
|
||||
int i = seconds * 20;
|
||||
i = EnchantmentProtection.getFireTimeForEntity(this, i);
|
||||
i = Enchantment.getFireTimeForEntity(this, i);
|
||||
|
||||
if (this.fire < i)
|
||||
{
|
||||
|
|
|
@ -726,8 +726,8 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return;
|
||||
if(stack.getItem() == Items.bow) {
|
||||
EntityArrow entityarrow = new EntityArrow(this.worldObj, this, target, 1.6F, 2.0f);
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.POWER.id, this.getHeldItem());
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.PUNCH.id, this.getHeldItem());
|
||||
entityarrow.setDamage((double)(range * 2.0F) + this.rand.gaussian() * 0.25D + (double)(/* (float)this.worldObj.getDifficulty().getId() */ 3.0f * 0.11F));
|
||||
|
||||
if (i > 0)
|
||||
|
@ -740,7 +740,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
entityarrow.setKnockbackStrength(j);
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0)
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.FLAME.id, this.getHeldItem()) > 0)
|
||||
{
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
else if(stack.getItem() instanceof ItemGunBase) {
|
||||
EntityBullet bullet = new EntityBullet(this.worldObj, this, target, ((ItemGunBase)stack.getItem()).getVelocity(), 0.75f);
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.POWER.id, this.getHeldItem());
|
||||
// int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
|
||||
bullet.setDamage(((ItemGunBase)stack.getItem()).getAmmo().getDamage(stack));
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public class ContainerEnchantment extends Container
|
|||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
RngEnchantment enchantmentdata = (RngEnchantment)list.get(this.rand.zrange(list.size()));
|
||||
this.ids[j1] = enchantmentdata.enchantment.effectId | enchantmentdata.level << 8;
|
||||
this.ids[j1] = enchantmentdata.enchantment.id | enchantmentdata.level << 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ItemBow extends Item
|
|||
*/
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft)
|
||||
{
|
||||
boolean flag = /* playerIn.creative || */ EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
|
||||
boolean flag = /* playerIn.creative || */ EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY.id, stack) > 0;
|
||||
|
||||
if (flag || playerIn.inventory.hasItem(Items.arrow))
|
||||
{
|
||||
|
@ -52,21 +52,21 @@ public class ItemBow extends Item
|
|||
entityarrow.setIsCritical(true);
|
||||
}
|
||||
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.POWER.id, stack);
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D);
|
||||
}
|
||||
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.PUNCH.id, stack);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
entityarrow.setKnockbackStrength(k);
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.FLAME.id, stack) > 0)
|
||||
{
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ItemEnchantedBook extends Item
|
|||
{
|
||||
TagObject nbttagcompound = nbttaglist.get(i);
|
||||
|
||||
if (nbttagcompound.getShort("id") == enchantment.enchantment.effectId)
|
||||
if (nbttagcompound.getShort("id") == enchantment.enchantment.id)
|
||||
{
|
||||
if (nbttagcompound.getShort("lvl") < enchantment.level)
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ public class ItemEnchantedBook extends Item
|
|||
if (flag)
|
||||
{
|
||||
TagObject nbttagcompound1 = new TagObject();
|
||||
nbttagcompound1.setShort("id", (short)enchantment.enchantment.effectId);
|
||||
nbttagcompound1.setShort("id", (short)enchantment.enchantment.id);
|
||||
nbttagcompound1.setShort("lvl", (short)enchantment.level);
|
||||
nbttaglist.add(nbttagcompound1);
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ public abstract class ItemGunBase extends Item
|
|||
if(stack.getItemDamage() >= this.getMaxDamage())
|
||||
return stack;
|
||||
boolean flag = // playerIn.creative ||
|
||||
EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
|
||||
EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY.id, stack) > 0;
|
||||
if (flag || playerIn.inventory.hasItem(this.getAmmo()))
|
||||
{
|
||||
EntityBullet bullet = new EntityBullet(worldIn, playerIn, this.getVelocity());
|
||||
bullet.setDamage(this.getAmmo().getDamage(stack));
|
||||
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.POWER.id, stack);
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,6 @@ import common.collect.Lists;
|
|||
import common.collect.Maps;
|
||||
import common.color.TextColor;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentDurability;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
|
@ -320,12 +319,12 @@ public final class ItemStack
|
|||
{
|
||||
if (amount > 0)
|
||||
{
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.UNBREAKING.id, this);
|
||||
int j = 0;
|
||||
|
||||
for (int k = 0; i > 0 && k < amount; ++k)
|
||||
{
|
||||
if (EnchantmentDurability.negateDamage(this, i, rand))
|
||||
if (Enchantment.negateDamage(this, i, rand))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
@ -1008,7 +1007,7 @@ public final class ItemStack
|
|||
|
||||
List<TagObject> nbttaglist = this.tag.getList("ench");
|
||||
TagObject nbttagcompound = new TagObject();
|
||||
nbttagcompound.setShort("id", (short)ench.effectId);
|
||||
nbttagcompound.setShort("id", (short)ench.id);
|
||||
nbttagcompound.setShort("lvl", (short)(/* (byte) */ level));
|
||||
nbttaglist.add(nbttagcompound);
|
||||
}
|
||||
|
@ -1029,7 +1028,7 @@ public final class ItemStack
|
|||
TagObject tag;
|
||||
for(int z = 0; z < oldEnch.size(); z++) {
|
||||
tag = oldEnch.get(z);
|
||||
if(tag.getShort("id") != ench.effectId) {
|
||||
if(tag.getShort("id") != ench.id) {
|
||||
newEnch.add(tag);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -8,7 +8,7 @@ import common.block.Block;
|
|||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
import common.enchantment.EnchantmentProtection;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.entity.DamageSource;
|
||||
import common.entity.Entity;
|
||||
import common.entity.item.EntityTnt;
|
||||
|
@ -246,7 +246,7 @@ public class Explosion
|
|||
double d10 = (1.0D - d12) * d14;
|
||||
if(this.worldObj.client || Vars.damageExplosion)
|
||||
entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), ((int)((d10 * d10 + d10) / 2.0D * 8.0D * (double)f3 + 1.0D)));
|
||||
double d11 = EnchantmentProtection.getKnockbackFactor(entity, d10);
|
||||
double d11 = Enchantment.getKnockbackFactor(entity, d10);
|
||||
entity.motionX += d5 * d11;
|
||||
entity.motionY += d7 * d11;
|
||||
entity.motionZ += d9 * d11;
|
||||
|
|
|
@ -188,6 +188,10 @@ public abstract class Command implements Executable {
|
|||
return this.addParameter(new PlayerParser(name, defaulted, policy));
|
||||
}
|
||||
|
||||
protected Command addPlayerList(String name, boolean defaulted, UserPolicy policy) {
|
||||
return this.addParameter(new PlayerListParser(name, defaulted, policy));
|
||||
}
|
||||
|
||||
protected Command addPlayerEntity(String name, boolean defaulted, UserPolicy policy) {
|
||||
return this.addParameter(new PlayerEntityParser(name, defaulted, policy));
|
||||
}
|
||||
|
|
|
@ -268,5 +268,7 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandRename());
|
||||
this.registerExecutable(new CommandRepair());
|
||||
this.registerExecutable(new CommandMore());
|
||||
this.registerExecutable(new CommandReturn());
|
||||
this.registerExecutable(new CommandDeathspot());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
import server.command.UserPolicy;
|
||||
import server.network.Player;
|
||||
|
||||
public class CommandDeathspot extends Command {
|
||||
public CommandDeathspot() {
|
||||
super("deathspot");
|
||||
|
||||
this.addPlayerEntity("player", true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
|
||||
this.addEntityList("entities", 'e', true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, EntityNPC player, List<Entity> entities) {
|
||||
Position pos = ((Player)player.connection).getLastDeath();
|
||||
if(pos == null)
|
||||
throw new RunException("%s hat keinen letzten Todespunkt", player.getCommandName());
|
||||
for(Entity entity : entities) {
|
||||
entity.teleport(pos);
|
||||
exec.log("%s zum Todespunkt von %s (%d, %d, %d in %s) teleportiert", entity.getCommandName(), player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
|
||||
}
|
||||
return entities.size();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
|
@ -10,13 +12,15 @@ public class CommandKick extends Command {
|
|||
public CommandKick() {
|
||||
super("kick");
|
||||
|
||||
this.addPlayer("player", false, UserPolicy.NON_ADMINS_NOT_SELF);
|
||||
this.addPlayerList("player", false, UserPolicy.NON_ADMINS_NOT_SELF);
|
||||
this.setParamsOptional();
|
||||
this.addString("message", "Du wurdest vom Server geworfen", false);
|
||||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, Player player, String message) {
|
||||
public void exec(CommandEnvironment env, Executor exec, List<Player> players, String message) {
|
||||
for(Player player : players) {
|
||||
player.disconnect(message);
|
||||
exec.log("%s wurde vom Server geworfen", player.getUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class CommandMagic extends Command {
|
|||
|
||||
public void exec(CommandEnvironment env, Executor exec, Enchantment ench, Integer level, boolean remove, boolean force, ItemStack stack) {
|
||||
if(remove) {
|
||||
int current = EnchantmentHelper.getEnchantmentLevel(ench.effectId, stack);
|
||||
int current = EnchantmentHelper.getEnchantmentLevel(ench.id, stack);
|
||||
if(current == 0)
|
||||
throw new RunException("%s hat die Verzauberung %s nicht", stack.getDisplayName(), ench.getDisplay());
|
||||
stack.removeEnchantment(ench);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.util.Position;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.UserPolicy;
|
||||
import server.network.Player;
|
||||
|
||||
public class CommandReturn extends Command {
|
||||
public CommandReturn() {
|
||||
super("return");
|
||||
|
||||
this.addPlayerEntityList("players", 'p', true, UserPolicy.NON_ADMINS_OR_SELF);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, List<EntityNPC> players) {
|
||||
int done = 0;
|
||||
for(EntityNPC player : players) {
|
||||
Position pos = ((Player)player.connection).getLastTeleport();
|
||||
if(pos != null) {
|
||||
player.teleport(pos);
|
||||
exec.log("%s zum letzten Punkt (%d, %d, %d in %s) teleportiert", player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
|
||||
done++;
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
}
|
|
@ -207,6 +207,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
|
||||
private Position forcedPos;
|
||||
private Executor forcedExec;
|
||||
private Position deathPos;
|
||||
private Position teleportPos;
|
||||
|
||||
public Player(Server server, NetConnection connection, String user)
|
||||
{
|
||||
|
@ -274,6 +276,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
}
|
||||
|
||||
public void onEntityDeath() {
|
||||
this.deathPos = this.entity.getPos();
|
||||
this.entity.sendDeathMessage();
|
||||
|
||||
if (!SVars.keepInventory && SVars.playerDrop)
|
||||
|
@ -635,6 +638,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
|
||||
this.teleportPos = this.entity.getPos();
|
||||
x = ExtMath.clampd(x, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
|
||||
z = ExtMath.clampd(z, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
|
||||
// this.setLastTeleport(this.getLocation());
|
||||
|
@ -2454,6 +2458,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.characters.set(this.selected, tag);
|
||||
int last = this.selected;
|
||||
this.selected = -1;
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(!this.characters.isEmpty() && last >= 0 ? new SPacketCharacterList(this.selected, last, this.getCharacterInfo(tag)) : new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
@ -2469,6 +2474,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.entity.setOrigin(origin);
|
||||
Position pos = this.server.getRandomSpawnPosition(origin);
|
||||
this.entity.teleport(pos);
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getFormattedName(false), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel)));
|
||||
// if(this.local)
|
||||
// this.server.setDone();
|
||||
|
@ -2482,6 +2488,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.charEditor = false;
|
||||
this.server.swapPlayer(this, this.characters.get(index), null);
|
||||
this.selected = index;
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
@ -2495,6 +2502,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.characters.set(this.selected, etag);
|
||||
int last = this.selected;
|
||||
this.selected = index;
|
||||
this.teleportPos = this.deathPos = null;
|
||||
this.sendPacket(!this.characters.isEmpty() && last >= 0 ? new SPacketCharacterList(this.selected, last, this.getCharacterInfo(etag)) : new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
@ -3071,6 +3079,18 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.managedPosZ = z;
|
||||
}
|
||||
|
||||
public Position getLastTeleport() {
|
||||
return this.teleportPos;
|
||||
}
|
||||
|
||||
public Position getLastDeath() {
|
||||
return this.deathPos;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return this.getPresentEntity() == null ? this.getUser() : this.getPresentEntity().getCommandName();
|
||||
}
|
||||
|
||||
// public void processCmdBlock(CPacketCmdBlock packetIn) {
|
||||
// NetHandler.checkThread(packetIn, this, this.serverController);
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue