Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ramping heat to the Thermalily #4665

Open
wants to merge 3 commits into
base: 1.20.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BucketPickup;
import net.minecraft.world.level.block.entity.BlockEntityType;
Expand All @@ -37,15 +38,24 @@ public abstract class FluidGeneratorBlockEntity extends GeneratingFlowerBlockEnt
public static final int DECAY_TIME = 72000;
protected int burnTime, cooldown;
private final TagKey<Fluid> consumedFluid;
private final int startBurnTime, manaPerTick;
protected final int startBurnTime;
private final Block allowedCaldron;

protected FluidGeneratorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, TagKey<Fluid> consumedFluid, int startBurnTime, int manaPerTick) {
protected FluidGeneratorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, TagKey<Fluid> consumedFluid, int startBurnTime) {
super(type, pos, state);
this.consumedFluid = consumedFluid;
this.startBurnTime = startBurnTime;
this.manaPerTick = manaPerTick;
if (consumedFluid.equals(FluidTags.WATER)) {
allowedCaldron = Blocks.WATER_CAULDRON;
} else if (consumedFluid.equals(FluidTags.LAVA)) {
allowedCaldron = Blocks.LAVA_CAULDRON;
} else {
allowedCaldron = null;
}
}

public abstract int manaPerTick();

@Override
public void tickFlower() {
super.tickFlower();
Expand All @@ -60,7 +70,7 @@ public void tickFlower() {

if (!getLevel().isClientSide) {
if (burnTime > 0 && ticksExisted % getGenerationDelay() == 0) {
addMana(manaPerTick);
addMana(manaPerTick());
sync();
}
}
Expand All @@ -75,8 +85,10 @@ public void tickFlower() {

BlockState bstate = getLevel().getBlockState(pos);
FluidState fstate = getLevel().getFluidState(pos);
if (fstate.is(consumedFluid) && fstate.isSource()) {
if (consumedFluid != FluidTags.WATER) {
if ((fstate.is(consumedFluid) && fstate.isSource()) || bstate.is(allowedCaldron)) {
if (bstate.is(allowedCaldron)) {
getLevel().setBlockAndUpdate(pos, Blocks.CAULDRON.defaultBlockState());
} else if (consumedFluid != FluidTags.WATER) {
getLevel().setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
} else {
int waterAround = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ public class HydroangeasBlockEntity extends FluidGeneratorBlockEntity {
private int passiveDecayTicks;

public HydroangeasBlockEntity(BlockPos pos, BlockState state) {
super(BotaniaFlowerBlocks.HYDROANGEAS, pos, state, FluidTags.WATER, 40, 1);
super(BotaniaFlowerBlocks.HYDROANGEAS, pos, state, FluidTags.WATER, 40);
}

@Override
public int manaPerTick() {
return 1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState;

Expand All @@ -22,39 +23,47 @@
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 = 10;
public static final int MAX_HEAT = 25;

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;
private int ticksSinceFueled = 0;
private int heat;

static {
int acc = 0;
for (var i : COOLDOWN_ROLL_PDF) {
acc += i;
}
COOLDOWN_ROLL_TOTAL = acc;
public ThermalilyBlockEntity(BlockPos pos, BlockState state) {
super(BotaniaFlowerBlocks.THERMALILY, pos, state, FluidTags.LAVA, 600);
}

public ThermalilyBlockEntity(BlockPos pos, BlockState state) {
super(BotaniaFlowerBlocks.THERMALILY, pos, state, FluidTags.LAVA, 600, 45);
@Override
public int manaPerTick() {
return 45 + heat * 2;
}

@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);
var index = 0;
while (total >= COOLDOWN_ROLL_PDF[index]) {
total -= COOLDOWN_ROLL_PDF[index];
index++;
public static int rollNewCooldownStrength(RandomSource random, int bias) {
return Math.min(Math.max(Math.round(Mth.normal(random, 10 - bias / 3, 4 - bias / 10)), 1), 15);
}

@Override
public void tickFlower() {
super.tickFlower();
if (burnTime == 0 && cooldown == 0) {
ticksSinceFueled++;
} else if (burnTime == startBurnTime) {
if (ticksSinceFueled <= FAST_PROVIDE_TICKS) {
heat = heat < MAX_HEAT ? heat + 1 : heat;
} else {
heat = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, this is the only place where heat is reset. If lava is provided before the end of the cooldown, the cooldown restarts (as intended), but heat does not reset. I'm not sure if that's a bad thing, as lava is still wasted, so fine by me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would have made it so that providing lava before the end of the cooldown would cause the thermalily to "burn" into a dead bush, but that would require either changing the logic in FluidGeneratingFlower (doable, requires some refactoring and moving of code), or use the call to getCooldownTime(false), (janky and prone to errors if other mods/addons/code calls that).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think just resetting the heat is an ok penalty here

}
ticksSinceFueled = 0;
}
return index + 1;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions Xplat/src/main/resources/assets/botania/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2440,11 +2440,11 @@

"botania.entry.thermalily": "Thermalily",
"botania.tagline.thermalily": "Mana from lava",
"botania.page.thermalily0": "The $(item)Thermalily$(0) is a $(item)Lava$(0)-flavoured counterpart to the $(l:generating_flowers/hydroangeas)$(item)Hydroangeas$(0)$(/l). The flower absorbs $(item)Lava$(0) around it (at the same altitude) to generate $(thing)Mana$(0).$(p)After absorbing one block of $(item)Lava$(0), the flower will produce $(thing)Mana$(0) continually for around 30 seconds. Afterwards, though, it needs a bit of time to cool down before it can produce any more.",
"botania.page.thermalily0": "The $(item)Thermalily$(0) is a $(item)Lava$(0)-flavoured counterpart to the $(l:generating_flowers/hydroangeas)$(item)Hydroangeas$(0)$(/l). The flower absorbs $(item)Lava$(0) at the same altitude around it (as well as lava from cauldrons) to generate $(thing)Mana$(0).$(p)After absorbing one block of $(item)Lava$(0), the flower will produce $(thing)Mana$(0) continually for around 30 seconds. Afterwards, though, it needs a bit of time to cool down before it can produce any more.",
"botania.page.thermalily1": "As temperamental as its drink of choice, though, it tends to randomly vary how long a cooldown period lasts-- anywhere from 20 seconds to a full 5 minutes!$(p)You can tell how long its most recent cooldown period lasts with a $(item)Redstone Comparator$(0): twenty seconds for each level of strength.",
"botania.page.thermalily2": "The $(thing)Mana$(0) throughput the $(item)Thermalily$(0) produces during its active phase is extremely high; it's an ideal flower for a quick boost in stores.$(p)However, during its \"cooldown\" period, any adjacent $(thing)Lava$(0) will be absorbed and reset the cooldown without yielding any $(thing)Mana$(0).",
"botania.page.thermalily3": "While placing $(item)Lava$(0) in the world is definitely possible via $(item)Dispensers$(0), automatically gathering it and carrying it from the $(thing)Nether$(0) or deep underground is not.$(p)As such, the $(item)Thermalily$(0) is classified as a \"semi-automatable\" flower.",
"botania.page.thermalily4": "$(o)The hardest flower in the game$().",
"botania.page.thermalily3": "If you supply the Thermalily with lava in a timely manner, the flower will begin to burn hotter and hotter. The average cooldown is proportional to the heat of the flower, with higher heat resulting in lower cooldowns",
"botania.page.thermalily4": "$(o)Burn baby burn$().",

"botania.entry.arcanerose": "Rosa Arcana",
"botania.tagline.arcanerose": "Mana from experience",
Expand Down