Disallow quick regeneration

This commit is contained in:
DBotThePony 2021-08-24 14:50:48 +07:00
parent 64d41e450a
commit c45c7045d9
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -11,6 +11,7 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
import ru.dbotthepony.mc.otm.Registry;
import ru.dbotthepony.mc.otm.android.AndroidResearch;
import ru.dbotthepony.mc.otm.android.AndroidResearchType;
@ -199,13 +200,16 @@ public class AndroidCapabilityPlayer extends AndroidCapability {
var stats = ply.getFoodData();
while (stats.getFoodLevel() < 20) {
if (this.extractEnergyInner(ENERGY_FOR_HUNGER_POINT, true).compareTo(ENERGY_FOR_HUNGER_POINT) == 0) {
this.extractEnergyInner(ENERGY_FOR_HUNGER_POINT, false);
stats.setFoodLevel(stats.getFoodLevel() + 1);
} else {
break;
}
while (stats.getFoodLevel() < 17 && this.extractEnergyInner(ENERGY_FOR_HUNGER_POINT, true).compareTo(ENERGY_FOR_HUNGER_POINT) == 0) {
this.extractEnergyInner(ENERGY_FOR_HUNGER_POINT, false);
stats.setFoodLevel(stats.getFoodLevel() + 1);
}
// "block" quick regeneration
// also cause power to generate while in peaceful
while (stats.getFoodLevel() > 17 && this.receiveEnergyInner(ENERGY_FOR_HUNGER_POINT, true).compareTo(ENERGY_FOR_HUNGER_POINT) == 0) {
this.receiveEnergyInner(ENERGY_FOR_HUNGER_POINT, false);
stats.setFoodLevel(stats.getFoodLevel() - 1);
}
var food_level = (float) stats.getFoodLevel();