First stab at Living Armour reimplementation.
Added a lot of the upgrades, but there's still more testing/upgrades to be done/reimplemented.
This commit is contained in:
parent
06faa916c3
commit
2075fa5be3
42 changed files with 2352 additions and 2 deletions
|
@ -0,0 +1,59 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ArmorMaterial;
|
||||
import net.minecraft.item.IArmorMaterial;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
||||
public class ArmorMaterialLiving implements IArmorMaterial
|
||||
{
|
||||
public static final IArmorMaterial INSTANCE = new ArmorMaterialLiving();
|
||||
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slot)
|
||||
{
|
||||
return ArmorMaterial.IRON.getDurability(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slot)
|
||||
{
|
||||
return ArmorMaterial.IRON.getDamageReductionAmount(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability()
|
||||
{
|
||||
return ArmorMaterial.IRON.getEnchantability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getSoundEvent()
|
||||
{
|
||||
return ArmorMaterial.IRON.getSoundEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial()
|
||||
{
|
||||
return ArmorMaterial.IRON.getRepairMaterial();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "livingarmour";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness()
|
||||
{
|
||||
return ArmorMaterial.IRON.getToughness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getKnockbackResistance()
|
||||
{
|
||||
return ArmorMaterial.IRON.getKnockbackResistance();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -7,6 +8,7 @@ import net.minecraftforge.fml.RegistryObject;
|
|||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.arc.ItemARCToolBase;
|
||||
import wayoftime.bloodmagic.common.item.block.ItemBlockAlchemyTable;
|
||||
|
@ -32,7 +34,6 @@ import wayoftime.bloodmagic.common.registration.impl.BloodOrbDeferredRegister;
|
|||
import wayoftime.bloodmagic.common.registration.impl.BloodOrbRegistryObject;
|
||||
import wayoftime.bloodmagic.ritual.EnumRuneType;
|
||||
import wayoftime.bloodmagic.structures.ItemDungeonTester;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
|
||||
public class BloodMagicItems
|
||||
{
|
||||
|
@ -129,6 +130,13 @@ public class BloodMagicItems
|
|||
public static final RegistryObject<Item> WEAK_BLOOD_SHARD = BASICITEMS.register("weakbloodshard", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> EXPERIENCE_TOME = BASICITEMS.register("experiencebook", () -> new ItemExperienceBook());
|
||||
|
||||
public static final RegistryObject<Item> LIVING_HELMET = BASICITEMS.register("livinghelmet", () -> new ItemLivingArmor(EquipmentSlotType.HEAD));
|
||||
public static final RegistryObject<Item> LIVING_PLATE = BASICITEMS.register("livingplate", () -> new ItemLivingArmor(EquipmentSlotType.CHEST));
|
||||
public static final RegistryObject<Item> LIVING_LEGGINGS = BASICITEMS.register("livingleggings", () -> new ItemLivingArmor(EquipmentSlotType.LEGS));
|
||||
public static final RegistryObject<Item> LIVING_BOOTS = BASICITEMS.register("livingboots", () -> new ItemLivingArmor(EquipmentSlotType.FEET));
|
||||
|
||||
public static final RegistryObject<Item> LIVING_TOME = BASICITEMS.register("upgradetome", () -> new ItemLivingTome());
|
||||
|
||||
// Ritual stuffs
|
||||
public static final RegistryObject<Item> WEAK_ACTIVATION_CRYSTAL = BASICITEMS.register("activationcrystalweak", () -> new ItemActivationCrystal(ItemActivationCrystal.CrystalType.WEAK));
|
||||
public static final RegistryObject<Item> AWAKENED_ACTIVATION_CRYSTAL = BASICITEMS.register("activationcrystalawakened", () -> new ItemActivationCrystal(ItemActivationCrystal.CrystalType.AWAKENED));
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public interface ExpandedArmor
|
||||
{
|
||||
|
||||
// Multimap<String, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack);
|
||||
|
||||
void damageArmor(LivingEntity livingEntity, ItemStack stack, DamageSource source, float damage, EquipmentSlotType slot);
|
||||
|
||||
Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.core.living.ILivingContainer;
|
||||
import wayoftime.bloodmagic.core.living.LivingStats;
|
||||
|
||||
public class ItemLivingArmor extends ArmorItem implements ILivingContainer, ExpandedArmor
|
||||
{
|
||||
|
||||
private static final int MAX_ABSORPTION = 100000;
|
||||
|
||||
public ItemLivingArmor(EquipmentSlotType slot)
|
||||
{
|
||||
super(ArmorMaterialLiving.INSTANCE, slot, new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, String type)
|
||||
{
|
||||
if (this == BloodMagicItems.LIVING_PLATE.get() || this == BloodMagicItems.LIVING_HELMET.get() || this == BloodMagicItems.LIVING_BOOTS.get())
|
||||
{
|
||||
return "bloodmagic:models/armor/livingarmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == BloodMagicItems.LIVING_LEGGINGS.get())
|
||||
{
|
||||
return "bloodmagic:models/armor/livingarmour_layer_2.png";
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
|
||||
{
|
||||
// Multimap<Attribute, AttributeModifier> modifiers = super.getAttributeModifiers(slot, stack);
|
||||
Multimap<Attribute, AttributeModifier> modifiers = HashMultimap.create();
|
||||
modifiers.putAll(super.getAttributeModifiers(slot, stack));
|
||||
if (slot != EquipmentSlotType.CHEST)
|
||||
return modifiers;
|
||||
|
||||
LivingStats stats = getLivingStats(stack);
|
||||
if (stats == null)
|
||||
return modifiers;
|
||||
|
||||
stats.getUpgrades().forEach((k, v) -> {
|
||||
if (k.getAttributeProvider() != null)
|
||||
k.getAttributeProvider().handleAttributes(stats, modifiers, UUID.nameUUIDFromBytes(k.getKey().toString().getBytes()), k, k.getLevel(v.intValue()));
|
||||
});
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
// if (source == DamageSource.DROWN || source == DamageSource.OUT_OF_WORLD)
|
||||
// return new ArmorProperties(-1, 0D, 0);
|
||||
//
|
||||
// double armorReduction;
|
||||
// double damageAmount = 0.25;
|
||||
// double armorPenetrationReduction = 0;
|
||||
//
|
||||
// if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_FEET || armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_HEAD)
|
||||
// damageAmount = 3d / 20d * 0.6;
|
||||
// else if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_LEGS)
|
||||
// damageAmount = 6d / 20d * 0.6;
|
||||
// else if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_CHEST)
|
||||
// damageAmount = 0.64;
|
||||
//
|
||||
// if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_CHEST) {
|
||||
// armorReduction = 0.24 / 0.64; // This values puts it at iron level
|
||||
//
|
||||
// if (!LivingUtil.hasFullSet((EntityPlayer) player))
|
||||
// return new ArmorProperties(-1, damageAmount * armorReduction, MAX_ABSORPTION);
|
||||
//
|
||||
// LivingStats stats = getLivingStats(armor);
|
||||
// double protection = 1.0D;
|
||||
// if (stats != null)
|
||||
// for (Map.Entry<LivingUpgrade, Integer> entry : stats.getUpgrades().entrySet())
|
||||
// if (entry.getKey().getArmorProvider() != null)
|
||||
// protection *= 1 - entry.getKey().getArmorProvider().getProtection((EntityPlayer) player, stats, source, entry.getKey().getLevel(entry.getValue()));
|
||||
//
|
||||
// armorReduction += (1 - protection) * (1 - armorReduction);
|
||||
// damageAmount *= armorReduction;
|
||||
// return new ArmorProperties(-1, source.isUnblockable() ? 1 - protection : damageAmount, MAX_ABSORPTION);
|
||||
// } else if (source.isUnblockable())
|
||||
// return new ArmorProperties(-1, damageAmount * armorPenetrationReduction, MAX_ABSORPTION);
|
||||
//
|
||||
// return new ArmorProperties(-1, damageAmount, MAX_ABSORPTION);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
|
||||
{
|
||||
if (!isInGroup(group))
|
||||
return;
|
||||
|
||||
ItemStack stack = new ItemStack(this);
|
||||
if (slot == EquipmentSlotType.CHEST)
|
||||
updateLivingStats(stack, new LivingStats());
|
||||
|
||||
items.add(stack);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
|
||||
// {
|
||||
// if (this.isInGroup(group))
|
||||
// {
|
||||
// for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
// {
|
||||
// ItemStack stack = new ItemStack(this);
|
||||
// this.setCurrentType(type, stack);
|
||||
// this.setWill(type, stack, maxWill);
|
||||
// items.add(stack);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void damageArmor(LivingEntity livingEntity, ItemStack stack, DamageSource source, float damage, EquipmentSlotType slot)
|
||||
{
|
||||
if (slot == EquipmentSlotType.CHEST && damage > getMaxDamage() - stack.getDamage())
|
||||
{
|
||||
// livingEntity.attackEntityFrom(source, amount)
|
||||
// }
|
||||
livingEntity.attackEntityFrom(DamageSource.MAGIC, 2.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
// stack.damage((int) damage, livingEntity, entity -> {});
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
ILivingContainer.appendLivingTooltip(getLivingStats(stack), tooltip, true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.core.LivingArmorRegistrar;
|
||||
import wayoftime.bloodmagic.core.living.ILivingContainer;
|
||||
import wayoftime.bloodmagic.core.living.LivingStats;
|
||||
import wayoftime.bloodmagic.core.living.LivingUpgrade;
|
||||
import wayoftime.bloodmagic.core.living.LivingUtil;
|
||||
|
||||
public class ItemLivingTome extends Item implements ILivingContainer
|
||||
{
|
||||
|
||||
public ItemLivingTome()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack held = player.getHeldItem(hand);
|
||||
|
||||
LivingStats armorStats = LivingStats.fromPlayer(player, true);
|
||||
if (armorStats == null)
|
||||
return ActionResult.resultPass(held);
|
||||
|
||||
LivingStats tomeStats = getLivingStats(held);
|
||||
if (tomeStats == null)
|
||||
return ActionResult.resultPass(held);
|
||||
|
||||
boolean[] flag = new boolean[] { false };
|
||||
tomeStats.getUpgrades().forEach((k, v) -> {
|
||||
if (armorStats.getLevel(k.getKey()) >= tomeStats.getLevel(k.getKey()))
|
||||
return;
|
||||
|
||||
LivingUtil.applyNewExperience(player, k, v); // FIXME set levels directly, don't add experience
|
||||
flag[0] = true;
|
||||
});
|
||||
// LivingStats.toPlayer(player, armorStats);
|
||||
if (flag[0])
|
||||
{
|
||||
held.shrink(1);
|
||||
return ActionResult.resultSuccess(held);
|
||||
} else
|
||||
return ActionResult.resultPass(held);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
|
||||
{
|
||||
if (!isInGroup(group))
|
||||
return;
|
||||
|
||||
for (Entry<ResourceLocation, LivingUpgrade> entry : LivingArmorRegistrar.UPGRADE_MAP.entrySet())
|
||||
{
|
||||
LivingUpgrade upgrade = entry.getValue();
|
||||
int exp = 0;
|
||||
|
||||
while ((exp = upgrade.getNextRequirement(exp)) != 0)
|
||||
{
|
||||
ItemStack tome = new ItemStack(this);
|
||||
updateLivingStats(tome, new LivingStats().setMaxPoints(upgrade.getLevelCost(exp)).addExperience(upgrade.getKey(), exp));
|
||||
items.add(tome);
|
||||
}
|
||||
}
|
||||
|
||||
// LivingArmorRegistrar.UPGRADE_MAP.forEach(upgrade -> {
|
||||
// int exp = 0;
|
||||
//
|
||||
// while ((exp = upgrade.getNextRequirement(exp)) != 0)
|
||||
// {
|
||||
// ItemStack tome = new ItemStack(this);
|
||||
// updateLivingStats(tome, new LivingStats().setMaxPoints(upgrade.getLevelCost(exp)).addExperience(upgrade.getKey(), exp));
|
||||
// display.add(tome);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
ILivingContainer.appendLivingTooltip(getLivingStats(stack), tooltip, false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.core.living.ILivingContainer;
|
||||
|
||||
public class ItemLivingTrainer extends Item implements ILivingContainer
|
||||
{
|
||||
public ItemLivingTrainer()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
ILivingContainer.appendLivingTooltip(getLivingStats(stack), tooltip, false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue