This commit is contained in:
Marcel Konrad
2018-02-17 18:57:33 +01:00
parent 9ba0331404
commit 9552b91665
38 changed files with 549 additions and 297 deletions

View File

@@ -2,6 +2,7 @@ package exopandora.worldhandler.builder.component.abstr;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import exopandora.worldhandler.builder.component.IBuilderComponent;
@@ -12,7 +13,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public abstract class ComponentAttribute implements IBuilderComponent
{
protected Map<EnumAttributes, Float> attributes = new HashMap<EnumAttributes, Float>();
protected Map<EnumAttributes, Double> attributes = new HashMap<EnumAttributes, Double>();
protected Function<EnumAttributes, Boolean> applyable;
public ComponentAttribute(Function<EnumAttributes, Boolean> applyable)
@@ -20,13 +21,28 @@ public abstract class ComponentAttribute implements IBuilderComponent
this.applyable = applyable;
}
public void set(EnumAttributes attribute, float ammount)
public void set(EnumAttributes attribute, double ammount)
{
this.attributes.put(attribute, ammount);
}
public double getAmmount(EnumAttributes attribute)
{
if(this.attributes.containsKey(attribute))
{
return this.attributes.get(attribute);
}
return 0;
}
public void remove(EnumAttributes attribute)
{
this.attributes.remove(attribute);
}
public Set<EnumAttributes> getAttributes()
{
return this.attributes.keySet();
}
}

View File

@@ -2,6 +2,7 @@ package exopandora.worldhandler.builder.component.abstr;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -169,6 +170,11 @@ public abstract class ComponentPotion implements IBuilderComponent
return false;
}
public Set<Potion> getPotions()
{
return this.potions.keySet();
}
@Nullable
public PotionMetadata get(Potion potion)
{

View File

@@ -28,7 +28,7 @@ public class ComponentAttributeItem extends ComponentAttribute
{
NBTTagList attributes = new NBTTagList();
for(Entry<EnumAttributes, Float> entry : this.attributes.entrySet())
for(Entry<EnumAttributes, Double> entry : this.attributes.entrySet())
{
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
{

View File

@@ -27,7 +27,7 @@ public class ComponentAttributeMob extends ComponentAttribute
{
NBTTagList attributes = new NBTTagList();
for(Entry<EnumAttributes, Float> entry : this.attributes.entrySet())
for(Entry<EnumAttributes, Double> entry : this.attributes.entrySet())
{
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
{

View File

@@ -2,6 +2,7 @@ package exopandora.worldhandler.builder.component.impl;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -51,11 +52,16 @@ public class ComponentEnchantment implements IBuilderComponent
this.enchantments.put(enchantment, level);
}
public int getLevel(Enchantment enchantment)
public short getLevel(Enchantment enchantment)
{
return this.enchantments.get(enchantment);
}
public Set<Enchantment> getEnchantments()
{
return this.enchantments.keySet();
}
@Override
public String getTag()
{

View File

@@ -1,5 +1,7 @@
package exopandora.worldhandler.builder.impl;
import java.util.Set;
import exopandora.worldhandler.builder.component.impl.ComponentAttributeItem;
import exopandora.worldhandler.builder.component.impl.ComponentDisplay;
import exopandora.worldhandler.builder.component.impl.ComponentEnchantment;
@@ -39,7 +41,17 @@ public class BuilderCustomItem extends BuilderGive
this.enchantment.setLevel(enchantment, level);
}
public void setAttribute(EnumAttributes attribute, float ammount)
public short getEnchantmentLevel(Enchantment enchantment)
{
return this.enchantment.getLevel(enchantment);
}
public Set<Enchantment> getEnchantments()
{
return this.enchantment.getEnchantments();
}
public void setAttribute(EnumAttributes attribute, double ammount)
{
this.attribute.set(attribute, ammount);
}
@@ -49,6 +61,16 @@ public class BuilderCustomItem extends BuilderGive
this.attribute.remove(attribute);
}
public double getAttributeAmmount(EnumAttributes attribute)
{
return this.attribute.getAmmount(attribute);
}
public Set<EnumAttributes> getAttributes()
{
return this.attribute.getAttributes();
}
public void setName(ColoredString name)
{
this.display.setName(name);

View File

@@ -1,5 +1,7 @@
package exopandora.worldhandler.builder.impl;
import java.util.Set;
import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
@@ -85,6 +87,11 @@ public class BuilderPotionItem extends BuilderGive
return this.potion.get(potion).getAmbient();
}
public Set<Potion> getPotions()
{
return this.potion.getPotions();
}
public BuilderPotionItem getBuilderForPotion(Item item)
{
return new BuilderPotionItem(item.getRegistryName(), this.getPlayer(), this.potion);

View File

@@ -1,5 +1,6 @@
package exopandora.worldhandler.builder.impl;
import java.util.Set;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
@@ -131,7 +132,7 @@ public class BuilderSummon extends CommandBuilderNBT
return this.getNodeAsCoordinate(3);
}
public void setAttribute(EnumAttributes attribute, float ammount)
public void setAttribute(EnumAttributes attribute, double ammount)
{
this.attribute.set(attribute, ammount);
}
@@ -141,6 +142,16 @@ public class BuilderSummon extends CommandBuilderNBT
this.attribute.remove(attribute);
}
public double getAttributeAmmount(EnumAttributes attribute)
{
return this.attribute.getAmmount(attribute);
}
public Set<EnumAttributes> getAttributes()
{
return this.attribute.getAttributes();
}
public void setCustomName(ColoredString name)
{
this.customName.setValue(name);
@@ -291,7 +302,7 @@ public class BuilderSummon extends CommandBuilderNBT
{
this.potion.get(potion).setAmplifier(amplifier);
}
public void setSeconds(Potion potion, int seconds)
{
this.potion.get(potion).setSeconds(seconds);
@@ -347,6 +358,11 @@ public class BuilderSummon extends CommandBuilderNBT
return this.potion.get(potion).getAmbient();
}
public Set<Potion> getPotions()
{
return this.potion.getPotions();
}
private NBTBase itemListSerializer(NBTTagList list)
{
for(int x = 0; x < list.tagCount(); x++)

View File

@@ -12,23 +12,20 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public enum EnumAttributes
{
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
FOLLOW_RANGE("generic.followRange", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.MOB),
KNOCKBACK_RESISTANCE("generic.knockbackResistance", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
MOVEMENT_SPEED("generic.movementSpeed", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
ATTACK_DAMAGE("generic.attackDamage", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
ARMOR("generic.armor", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
ARMOR_TOUGHNESS("generic.armorToughness", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
ATTACK_SPEED("generic.attackSpeed", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
LUCK("generic.luck", EnumOperation.PERCENTAGE, -100, 100, 0, Applyable.PLAYER),
HORSE_JUMP_STRENGTH("horse.jumpStrength", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.MOB),
ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawnReinforcements", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.MOB);
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, Applyable.BOTH),
FOLLOW_RANGE("generic.followRange", EnumOperation.ADDITIVE, Applyable.MOB),
KNOCKBACK_RESISTANCE("generic.knockbackResistance", EnumOperation.PERCENTAGE, Applyable.BOTH),
MOVEMENT_SPEED("generic.movementSpeed", EnumOperation.PERCENTAGE, Applyable.BOTH),
ATTACK_DAMAGE("generic.attackDamage", EnumOperation.ADDITIVE, Applyable.BOTH),
ARMOR("generic.armor", EnumOperation.ADDITIVE, Applyable.BOTH),
ARMOR_TOUGHNESS("generic.armorToughness", EnumOperation.ADDITIVE, Applyable.BOTH),
ATTACK_SPEED("generic.attackSpeed", EnumOperation.PERCENTAGE, Applyable.BOTH),
LUCK("generic.luck", EnumOperation.PERCENTAGE, Applyable.PLAYER),
HORSE_JUMP_STRENGTH("horse.jumpStrength", EnumOperation.PERCENTAGE, Applyable.MOB),
ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawnReinforcements", EnumOperation.PERCENTAGE, Applyable.MOB);
private String attribute;
private EnumOperation operation;
private float min;
private float max;
private float start;
private Applyable applyable;
public enum Applyable
@@ -38,13 +35,10 @@ public enum EnumAttributes
MOB
}
private EnumAttributes(String attribute, EnumOperation operation, float min, float max, float start, Applyable applyable)
private EnumAttributes(String attribute, EnumOperation operation, Applyable applyable)
{
this.attribute = attribute;
this.operation = operation;
this.min = min;
this.max = max;
this.start = start;
this.applyable = applyable;
}
@@ -68,29 +62,14 @@ public enum EnumAttributes
return this.operation;
}
public float getMin()
{
return this.min;
}
public float getMax()
{
return this.max;
}
public float getStart()
{
return this.start;
}
public Applyable getApplyable()
{
return this.applyable;
}
public double calculate(Float value)
public double calculate(Double value)
{
return this.operation.getOperation().apply(value.doubleValue());
return this.operation.getOperation().apply(value);
}
public enum EnumOperation