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; package techreborn.init;
import java.util.function.Supplier;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.IArmorMaterial; import net.minecraft.item.IArmorMaterial;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.LazyLoadBase;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
/* //TODO move values over public enum TRArmorMaterial implements IArmorMaterial {
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);
*/ BRONZE(17, new int[] { 3, 6, 5, 2 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0.0F, () -> {
public enum TRArmorMaterial implements IArmorMaterial { 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, private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
RUBY, private final int maxDamageFactor;
SAPPHIRE, private final int[] damageReductionAmountArray;
PERIDOT, private final int enchantability;
CLOAKING; private final SoundEvent soundEvent;
private final float toughness;
private final LazyLoadBase<Ingredient> repairMaterial;
@Override private TRArmorMaterial(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
public int getDurability(EntityEquipmentSlot entityEquipmentSlot) { SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterialIn) {
return 0; this.maxDamageFactor = maxDamageFactor;
this.damageReductionAmountArray = damageReductionAmountArray;
this.enchantability = enchantability;
this.soundEvent = soundEvent;
this.toughness = toughness;
this.repairMaterial = new LazyLoadBase<>(repairMaterialIn);
} }
@Override @Override
public int getDamageReductionAmount(EntityEquipmentSlot entityEquipmentSlot) { public int getDurability(EntityEquipmentSlot slotIn) {
return 0; return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * maxDamageFactor;
}
@Override
public int getDamageReductionAmount(EntityEquipmentSlot slotIn) {
return damageReductionAmountArray[slotIn.getIndex()];
} }
@Override @Override
public int getEnchantability() { public int getEnchantability() {
return 0; return enchantability;
} }
@Override @Override
public SoundEvent getSoundEvent() { public SoundEvent getSoundEvent() {
return null; return soundEvent;
} }
@Override @Override
public Ingredient getRepairMaterial() { public Ingredient getRepairMaterial() {
if (repairMaterial != null) {
return repairMaterial.getValue();
}
return null; return null;
} }
@ -59,6 +79,6 @@ public enum TRArmorMaterial implements IArmorMaterial {
@Override @Override
public float getToughness() { 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.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects; import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -46,6 +45,7 @@ import reborncore.common.registration.RebornRegister;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.TRArmorMaterial;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -60,9 +60,7 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo
// 40M FE capacity with 10k FE\t charge rate // 40M FE capacity with 10k FE\t charge rate
public ItemCloakingDevice() { public ItemCloakingDevice() {
//TODO: Update ArmorMaterial super(TRArmorMaterial.CLOAKING, EntityEquipmentSlot.CHEST);
super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST);
//setMaxStackSize(1);
} }
// Item // Item
@ -73,7 +71,6 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo
} }
@Override @Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (entityIn instanceof EntityPlayer) { if (entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn; EntityPlayer player = (EntityPlayer) entityIn;