diff --git a/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java b/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java index 6cc1c934a..8dcb85d92 100644 --- a/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java +++ b/src/main/java/com/github/elenterius/biomancy/block/cradle/PrimordialCradleBlockEntity.java @@ -142,11 +142,14 @@ protected void setChangedSilent() { public void onSacrifice(ServerLevel level) { BlockPos pos = getBlockPos(); + + float spreadChargeMultiplier = sacrificeHandler.getLifeEnergyPct(); + if (level.random.nextFloat() < sacrificeHandler.getSuccessChance()) { if (level.random.nextFloat() < sacrificeHandler.getAnomalyChance()) { spawnPrimordialFleshBlob(level, pos, sacrificeHandler); - primalSpreadCharge += 2048; + primalSpreadCharge += Math.round(2048 * spreadChargeMultiplier); SoundUtil.broadcastBlockSound(level, pos, SoundEvents.FOX_SCREECH, 2f, 0.5f); } else { @@ -157,7 +160,7 @@ public void onSacrifice(ServerLevel level) { spawnFleshBlob(level, pos, sacrificeHandler); } - primalSpreadCharge += 512; + primalSpreadCharge += Math.round(512 * spreadChargeMultiplier); SoundUtil.broadcastBlockSound(level, pos, ModSoundEvents.CREATOR_SPAWN_MOB); } @@ -174,7 +177,7 @@ public void onSacrifice(ServerLevel level) { PrimordialEcosystem.tryToReplaceBlock(level, pos.below(), ModBlocks.PRIMAL_FLESH.get().defaultBlockState()); } - primalSpreadCharge += 1024; + primalSpreadCharge += Math.round(1024 * spreadChargeMultiplier); SoundUtil.broadcastBlockSound(level, pos, ModSoundEvents.FLESH_BLOCK_STEP.get(), 1f, 0.15f + level.random.nextFloat() * 0.5f); } diff --git a/src/main/java/com/github/elenterius/biomancy/block/cradle/SacrificeHandler.java b/src/main/java/com/github/elenterius/biomancy/block/cradle/SacrificeHandler.java index f45e4bceb..61c490681 100644 --- a/src/main/java/com/github/elenterius/biomancy/block/cradle/SacrificeHandler.java +++ b/src/main/java/com/github/elenterius/biomancy/block/cradle/SacrificeHandler.java @@ -11,10 +11,10 @@ public class SacrificeHandler implements INBTSerializable { - private static final int MAX_VALUE = 100; + private static final int MAX_BIOMASS_VALUE = 100; private byte biomass; - private byte lifeEnergy; + private int lifeEnergy; private int successValue; private int diseaseValue; private int hostileValue; @@ -39,11 +39,11 @@ public void reset() { } public boolean isFull() { - return lifeEnergy >= MAX_VALUE && biomass >= MAX_VALUE; + return lifeEnergy >= MAX_BIOMASS_VALUE && biomass >= MAX_BIOMASS_VALUE; } public void setBiomass(int amount) { - biomass = (byte) Mth.clamp(amount, 0, MAX_VALUE); + biomass = (byte) Mth.clamp(amount, 0, MAX_BIOMASS_VALUE); } public boolean addBiomass(int amount) { @@ -54,7 +54,7 @@ public boolean addBiomass(int amount) { return true; } - if (amount > 0 && biomass < MAX_VALUE) { + if (amount > 0 && biomass < MAX_BIOMASS_VALUE) { setBiomass(biomass + amount); return true; } @@ -67,11 +67,11 @@ public int getBiomassAmount() { } public float getBiomassPct() { - return biomass / (float) MAX_VALUE; + return biomass / 100f; } public void setLifeEnergy(int amount) { - lifeEnergy = (byte) Mth.clamp(amount, 0, MAX_VALUE); + lifeEnergy = (byte) Mth.clamp(amount, 0, Integer.MAX_VALUE); } public boolean addLifeEnergy(int amount) { @@ -82,7 +82,7 @@ public boolean addLifeEnergy(int amount) { return true; } - if (amount > 0 && lifeEnergy < MAX_VALUE) { + if (amount > 0) { setLifeEnergy(lifeEnergy + amount); return true; } @@ -95,7 +95,7 @@ public int getLifeEnergyAmount() { } public float getLifeEnergyPct() { - return lifeEnergy / (float) MAX_VALUE; + return lifeEnergy / 100f; } public float getSuccessChance() { @@ -184,7 +184,7 @@ public boolean addTribute(Tribute tribute) { public CompoundTag serializeNBT() { CompoundTag tag = new CompoundTag(); tag.putByte("Biomass", biomass); - tag.putByte("LifeEnergy", lifeEnergy); + tag.putInt("LifeEnergy", lifeEnergy); tag.putInt("Success", successValue); @@ -199,7 +199,7 @@ public CompoundTag serializeNBT() { @Override public void deserializeNBT(CompoundTag tag) { biomass = tag.getByte("Biomass"); - lifeEnergy = tag.getByte("LifeEnergy"); + lifeEnergy = tag.getInt("LifeEnergy"); successValue = tag.getInt("Success");