From 58f6d55b0d3bc092782c542073ebac412c54d442 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sun, 20 Dec 2020 23:29:05 +0000 Subject: [PATCH] Add timeout when crystal flower charm's effect activates to prevent infinite looping when mod plants don't behave, fixes #488 --- src/main/java/electroblob/wizardry/spell/GrowthAura.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/electroblob/wizardry/spell/GrowthAura.java b/src/main/java/electroblob/wizardry/spell/GrowthAura.java index 678ccd44..e98e7381 100644 --- a/src/main/java/electroblob/wizardry/spell/GrowthAura.java +++ b/src/main/java/electroblob/wizardry/spell/GrowthAura.java @@ -17,6 +17,8 @@ import java.util.List; public class GrowthAura extends Spell { + private static final int FULL_GROWTH_TIMEOUT = 100; + public GrowthAura(){ super("growth_aura", SpellActions.POINT_DOWN, false); addProperties(EFFECT_RADIUS); @@ -49,7 +51,8 @@ public class GrowthAura extends Spell { if(!world.isRemote){ if(plant.canUseBonemeal(world, world.rand, pos, state)){ if(world.rand.nextFloat() < 0.35f && ItemArtefact.isArtefactActive(caster, WizardryItems.charm_growth)){ - while(plant.canGrow(world, pos, state, false)){ + int i = 0; + while(plant.canGrow(world, pos, state, false) && i++ < FULL_GROWTH_TIMEOUT){ plant.grow(world, world.rand, pos, state); state = world.getBlockState(pos); // Update the state with the new one plant = (IGrowable)state.getBlock(); // Update the block with the new one