mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Gourmaryllis now is healthy and likes balanced diets
This commit is contained in:
1 parent
6c76aa0117
commit
d897138d90
1 file changed
+27
-7
+27
-7
@@ -20,6 +20,7 @@ import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
@@ -30,10 +31,15 @@ import java.util.List;
|
||||
public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
|
||||
private static final String TAG_COOLDOWN = "cooldown";
|
||||
private static final String TAG_DIGESTING_MANA = "digestingMana";
|
||||
private static final String TAG_LAST_FOOD = "lastFood";
|
||||
private static final String TAG_LAST_FOOD_COUNT = "lastFoodCount";
|
||||
private static final int RANGE = 1;
|
||||
|
||||
int cooldown = 0;
|
||||
int storedMana = 0;
|
||||
private int cooldown = 0;
|
||||
private int digestingMana = 0;
|
||||
private ItemStack lastFood = ItemStack.EMPTY;
|
||||
private int lastFoodCount = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
@@ -44,9 +50,9 @@ public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
|
||||
if(cooldown > -1)
|
||||
cooldown--;
|
||||
if(cooldown == 0 && storedMana != 0) {
|
||||
mana = Math.min(getMaxMana(), mana + storedMana);
|
||||
storedMana = 0;
|
||||
if(cooldown == 0 && digestingMana != 0) {
|
||||
mana = Math.min(getMaxMana(), mana + digestingMana);
|
||||
digestingMana = 0;
|
||||
getWorld().playSound(null, supertile.getPos(), SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.BLOCKS, 1, 1);
|
||||
sync();
|
||||
}
|
||||
@@ -60,8 +66,17 @@ public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
|
||||
if(!stack.isEmpty() && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) {
|
||||
if(cooldown <= 0) {
|
||||
if(ItemHandlerHelper.canItemStacksStack(lastFood, stack)) {
|
||||
lastFoodCount++;
|
||||
} else {
|
||||
lastFood = stack.copy();
|
||||
lastFood.setCount(1);
|
||||
lastFoodCount = 1;
|
||||
}
|
||||
|
||||
int val = Math.min(12, ((ItemFood) stack.getItem()).getHealAmount(stack));
|
||||
storedMana = val * val * 64;
|
||||
digestingMana = val * val * 64;
|
||||
digestingMana *= 1F / lastFoodCount;
|
||||
cooldown = val * 10;
|
||||
item.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.2F, 0.5F + (float) Math.random() * 0.5F);
|
||||
sync();
|
||||
@@ -77,13 +92,18 @@ public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
public void writeToPacketNBT(NBTTagCompound cmp) {
|
||||
super.writeToPacketNBT(cmp);
|
||||
cmp.setInteger(TAG_COOLDOWN, cooldown);
|
||||
cmp.setInteger(TAG_COOLDOWN, cooldown);
|
||||
cmp.setInteger(TAG_DIGESTING_MANA, digestingMana);
|
||||
cmp.setTag(TAG_LAST_FOOD, lastFood.writeToNBT(new NBTTagCompound()));
|
||||
cmp.setInteger(TAG_LAST_FOOD_COUNT, lastFoodCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromPacketNBT(NBTTagCompound cmp) {
|
||||
super.readFromPacketNBT(cmp);
|
||||
cooldown = cmp.getInteger(TAG_COOLDOWN);
|
||||
digestingMana = cmp.getInteger(TAG_DIGESTING_MANA);
|
||||
lastFood = new ItemStack(cmp.getCompoundTag(TAG_LAST_FOOD));
|
||||
lastFoodCount = cmp.getInteger(TAG_LAST_FOOD_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user