diff --git a/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java b/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java index c00c43e8c..dffdb3f6c 100644 --- a/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java +++ b/src/main/java/wayoftime/bloodmagic/common/item/ItemLivingArmor.java @@ -15,13 +15,11 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.extensions.IForgeItem; -import wayoftime.bloodmagic.BloodMagic; import wayoftime.bloodmagic.core.LivingArmorRegistrar; import wayoftime.bloodmagic.core.living.ILivingContainer; import wayoftime.bloodmagic.core.living.LivingStats; @@ -165,7 +163,12 @@ public void damageArmor(LivingEntity livingEntity, ItemStack stack, DamageSource // stack.damage((int) damage, livingEntity, entity -> {}); } - @Override + @Override + public boolean canLivingEvolve() { + return true; + } + + @Override @OnlyIn(Dist.CLIENT) public void appendHoverText(ItemStack stack, Level world, List tooltip, TooltipFlag flag) { diff --git a/src/main/java/wayoftime/bloodmagic/core/living/ILivingContainer.java b/src/main/java/wayoftime/bloodmagic/core/living/ILivingContainer.java index 9143e5e86..c600ad9aa 100644 --- a/src/main/java/wayoftime/bloodmagic/core/living/ILivingContainer.java +++ b/src/main/java/wayoftime/bloodmagic/core/living/ILivingContainer.java @@ -82,4 +82,8 @@ static void appendLivingTooltip(ItemStack stack, LivingStats stats, List upgrades; protected int maxPoints = DEFAULT_UPGRADE_POINTS; + protected boolean evolved = false; public LivingStats(Map upgrades) { @@ -97,6 +99,18 @@ public LivingStats setMaxPoints(int maxPoints) return this; } + public boolean isEvolved() + { + return evolved; + } + + public LivingStats setEvolved() + { + this.evolved = true; + this.setMaxPoints(DEFAULT_EVOLVED_UPGRADE_POINTS); + return this; + } + public CompoundTag serialize() { CompoundTag compound = new CompoundTag(); @@ -108,8 +122,8 @@ public CompoundTag serialize() statList.add(upgrade); }); compound.put("upgrades", statList); - compound.putInt("maxPoints", maxPoints); + compound.putBoolean("evolved", evolved); return compound; } @@ -129,6 +143,7 @@ public void deserialize(CompoundTag nbt) }); maxPoints = nbt.getInt("maxPoints"); + evolved = nbt.getBoolean("evolved"); } public static LivingStats fromNBT(CompoundTag statTag) diff --git a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java index 348535bd1..f81798c1f 100644 --- a/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java +++ b/src/main/java/wayoftime/bloodmagic/ritual/types/RitualArmourEvolve.java @@ -7,10 +7,10 @@ import net.minecraft.world.entity.LightningBolt; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.ItemStack; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import wayoftime.bloodmagic.BloodMagic; +import wayoftime.bloodmagic.core.living.ILivingContainer; import wayoftime.bloodmagic.core.living.LivingStats; import wayoftime.bloodmagic.core.living.LivingUtil; import wayoftime.bloodmagic.ritual.AreaDescriptor; @@ -51,12 +51,12 @@ public void performRitual(IMasterRitualStone masterRitualStone) { if (LivingUtil.hasFullSet(player)) { - ItemStack chestStack = player.getItemBySlot(EquipmentSlot.CHEST); + ILivingContainer chestpiece = (ILivingContainer) player.getItemBySlot(EquipmentSlot.CHEST).getItem(); LivingStats stats = LivingStats.fromPlayer(player); - if (stats != null && stats.getMaxPoints() < 300) + if (stats != null && chestpiece.canLivingEvolve() && !stats.isEvolved()) { - stats.setMaxPoints(300); + stats.setEvolved(); LivingStats.toPlayer(player, stats); // ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);