Added ArmorMaterials

This commit is contained in:
drcrazy 2019-02-27 17:58:00 +03:00
parent eb51e07998
commit 59b0633353
2 changed files with 48 additions and 31 deletions

View file

@ -1,54 +1,74 @@
package techreborn.init;
import java.util.function.Supplier;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.LazyLoadBase;
import net.minecraft.util.SoundEvent;
/* //TODO move values over
public static ArmorMaterial BRONZE_ARMOUR = EnumHelper.addEnum(ArmorMaterial.class, "BRONZE", ARMOR_PARAMETERS, "techreborn:bronze", 17, new int[] { 3, 6, 5,
2 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0F);
public static ArmorMaterial RUBY_ARMOUR = EnumHelper.addEnum(ArmorMaterial.class, "RUBY", ARMOR_PARAMETERS, "techreborn:ruby", 16, new int[] { 2, 7, 5,
2 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0F);
public static ArmorMaterial SAPPHIRE_ARMOUR = EnumHelper.addEnum(ArmorMaterial.class, "SAPPHIRE", ARMOR_PARAMETERS, "techreborn:sapphire", 19, new int[] { 4, 4, 4,
4 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0F);
public static ArmorMaterial PERIDOT_ARMOUR = EnumHelper.addEnum(ArmorMaterial.class, "PERIDOT", ARMOR_PARAMETERS, "techreborn:peridot", 17, new int[] { 3, 8, 3,
2 }, 16, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0F);
public static ArmorMaterial CLOAKING_ARMOR = EnumHelper.addEnum(ArmorMaterial.class, "CLOAKING", ARMOR_PARAMETERS, "techreborn:cloaking", 5, new int[] { 1, 2, 3,
1 }, 0, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0F);
public enum TRArmorMaterial implements IArmorMaterial {
*/
public enum TRArmorMaterial implements IArmorMaterial {
BRONZE(17, new int[] { 3, 6, 5, 2 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0.0F, () -> {
return Ingredient.fromItems(TRContent.Ingots.BRONZE.asItem());
}),
RUBY(16, new int[] { 2, 7, 5, 2 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> {
return Ingredient.fromItems(TRContent.Gems.RUBY.asItem());
}),
SAPPHIRE(19, new int[] { 4, 4, 4, 4 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> {
return Ingredient.fromItems(TRContent.Gems.SAPPHIRE.asItem());
}),
PERIDOT(17, new int[] { 3, 8, 3, 2 }, 16, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> {
return Ingredient.fromItems(TRContent.Gems.PERIDOT.asItem());
}),
CLOAKING(5, new int[] { 1, 2, 3, 1 }, 0, SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 0.0F, null);
BRONZE,
RUBY,
SAPPHIRE,
PERIDOT,
CLOAKING;
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
private final int maxDamageFactor;
private final int[] damageReductionAmountArray;
private final int enchantability;
private final SoundEvent soundEvent;
private final float toughness;
private final LazyLoadBase<Ingredient> repairMaterial;
@Override
public int getDurability(EntityEquipmentSlot entityEquipmentSlot) {
return 0;
private TRArmorMaterial(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterialIn) {
this.maxDamageFactor = maxDamageFactor;
this.damageReductionAmountArray = damageReductionAmountArray;
this.enchantability = enchantability;
this.soundEvent = soundEvent;
this.toughness = toughness;
this.repairMaterial = new LazyLoadBase<>(repairMaterialIn);
}
@Override
public int getDamageReductionAmount(EntityEquipmentSlot entityEquipmentSlot) {
return 0;
public int getDurability(EntityEquipmentSlot slotIn) {
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * maxDamageFactor;
}
@Override
public int getDamageReductionAmount(EntityEquipmentSlot slotIn) {
return damageReductionAmountArray[slotIn.getIndex()];
}
@Override
public int getEnchantability() {
return 0;
return enchantability;
}
@Override
public SoundEvent getSoundEvent() {
return null;
return soundEvent;
}
@Override
public Ingredient getRepairMaterial() {
if (repairMaterial != null) {
return repairMaterial.getValue();
}
return null;
}
@ -59,6 +79,6 @@ public enum TRArmorMaterial implements IArmorMaterial {
@Override
public float getToughness() {
return 0;
return toughness;
}
}

View file

@ -28,7 +28,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -46,6 +45,7 @@ import reborncore.common.registration.RebornRegister;
import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.config.ConfigTechReborn;
import techreborn.init.TRArmorMaterial;
import techreborn.init.TRContent;
import javax.annotation.Nullable;
@ -60,9 +60,7 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo
// 40M FE capacity with 10k FE\t charge rate
public ItemCloakingDevice() {
//TODO: Update ArmorMaterial
super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST);
//setMaxStackSize(1);
super(TRArmorMaterial.CLOAKING, EntityEquipmentSlot.CHEST);
}
// Item
@ -73,7 +71,6 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo
}
@Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;