Skip to content

Commit

Permalink
make evolution configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
dphaldes committed Jan 25, 2024
1 parent f41d1e0 commit 1a0c9bb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Component> tooltip, TooltipFlag flag)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ static void appendLivingTooltip(ItemStack stack, LivingStats stats, List<Compone
});
}
}

default boolean canLivingEvolve(){
return false;
}
}
17 changes: 16 additions & 1 deletion src/main/java/wayoftime/bloodmagic/core/living/LivingStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class LivingStats
{

public static final int DEFAULT_UPGRADE_POINTS = 100;
public static final int DEFAULT_EVOLVED_UPGRADE_POINTS = 300;

protected final Map<LivingUpgrade, Double> upgrades;
protected int maxPoints = DEFAULT_UPGRADE_POINTS;
protected boolean evolved = false;

public LivingStats(Map<LivingUpgrade, Double> upgrades)
{
Expand Down Expand Up @@ -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();
Expand All @@ -108,8 +122,8 @@ public CompoundTag serialize()
statList.add(upgrade);
});
compound.put("upgrades", statList);

compound.putInt("maxPoints", maxPoints);
compound.putBoolean("evolved", evolved);

return compound;
}
Expand All @@ -129,6 +143,7 @@ public void deserialize(CompoundTag nbt)
});

maxPoints = nbt.getInt("maxPoints");
evolved = nbt.getBoolean("evolved");
}

public static LivingStats fromNBT(CompoundTag statTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1a0c9bb

Please sign in to comment.