diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java index e39cb02f22..7003938741 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java @@ -37,7 +37,7 @@ public abstract class FluidGeneratorBlockEntity extends GeneratingFlowerBlockEnt public static final int DECAY_TIME = 72000; protected int burnTime, cooldown; private final TagKey consumedFluid; - private final int startBurnTime, manaPerTick; + protected final int startBurnTime, manaPerTick; protected FluidGeneratorBlockEntity(BlockEntityType type, BlockPos pos, BlockState state, TagKey consumedFluid, int startBurnTime, int manaPerTick) { super(type, pos, state); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java index d6ab4d86a2..8b814f1ddb 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java @@ -13,27 +13,24 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.tags.FluidTags; import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.block.BotaniaFlowerBlocks; import vazkii.botania.common.handler.BotaniaSounds; +import java.util.Arrays; + public class ThermalilyBlockEntity extends FluidGeneratorBlockEntity { public static final int COOLDOWN_TICKS_MULTIPLER = 400; public static final String TAG_COOLDOWN_MAGNITUDE = "cooldownStrength"; + public static final int FAST_PROVIDE_TICKS = 200; private int cooldownStrength = 15; public static final int[] COOLDOWN_ROLL_PDF = { 10, 5, 3, 2, 1, 1, 3, 3, 3, 2, 1, 1, 1, 2, 2 }; - public static final int COOLDOWN_ROLL_TOTAL; - - static { - int acc = 0; - for (var i : COOLDOWN_ROLL_PDF) { - acc += i; - } - COOLDOWN_ROLL_TOTAL = acc; - } + private int ticksSinceFueled = 0; + private int heat; public ThermalilyBlockEntity(BlockPos pos, BlockState state) { super(BotaniaFlowerBlocks.THERMALILY, pos, state, FluidTags.LAVA, 600, 45); @@ -42,21 +39,45 @@ public ThermalilyBlockEntity(BlockPos pos, BlockState state) { @Override public int getCooldownTime(boolean finishedPrevious) { if (finishedPrevious) { - cooldownStrength = rollNewCooldownStrength(getLevel().getRandom()); + cooldownStrength = rollNewCooldownStrength(getLevel().getRandom(), heat); } return COOLDOWN_TICKS_MULTIPLER * cooldownStrength; } - public static int rollNewCooldownStrength(RandomSource random) { - var total = random.nextInt(COOLDOWN_ROLL_TOTAL); + public static int rollNewCooldownStrength(RandomSource random, int bias) { + int[] weights = weightCooldown(COOLDOWN_ROLL_PDF, bias); + var total = random.nextInt(Arrays.stream(weights).sum()); var index = 0; - while (total >= COOLDOWN_ROLL_PDF[index]) { - total -= COOLDOWN_ROLL_PDF[index]; + while (total >= weights[index]) { + total -= weights[index]; index++; } return index + 1; } + public static int[] weightCooldown(int[] originalWeights, int amount) { + int[] result = new int[originalWeights.length]; + for (int i = 0; i < originalWeights.length; i++) { + result[i] = (int) Math.max(Math.ceil(originalWeights[i] * (12 - amount - Math.sqrt(originalWeights[i]))), 0); + } + return result; + } + + @Override + public void tickFlower() { + super.tickFlower(); + if (burnTime == 0 && cooldown == 0) { + ticksSinceFueled++; + } else if (burnTime == startBurnTime) { + if (ticksSinceFueled <= FAST_PROVIDE_TICKS) { + heat = heat < 10 ? heat + 1 : heat; + } else { + heat = 0; + } + ticksSinceFueled = 0; + } + } + @Override public int getColor() { return 0xD03C00;