diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index caa19ac5a..354378f7e 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Botania", apiVersion = "62", provides = "BotaniaAPI") +@API(owner = "Botania", apiVersion = "63", provides = "BotaniaAPI") package vazkii.botania.api; import cpw.mods.fml.common.API; diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java b/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java index fa584661c..a5af0acc3 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileEntity.java @@ -39,6 +39,11 @@ public class SubTileEntity { protected TileEntity supertile; public int ticksExisted = 0; + + /** true if this flower is working on Enchanted Soil **/ + public boolean overgrowth = false; + /** true if this flower is working on Enchanted Soil and this is the second tick **/ + public boolean overgrowthBoost = false; /** The Tag items should use to store which sub tile they are. **/ public static final String TAG_TYPE = "type"; @@ -213,6 +218,13 @@ public class SubTileEntity { public int getPowerLevel(int side) { return 0; } + + /** + * Gets if this SubTileEntity is affected by Enchanted Soil's speed boost. + */ + public boolean isOvergrowthAffected() { + return true; + } } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java index f85ab0735..0cabcb68b 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java @@ -11,10 +11,13 @@ package vazkii.botania.api.subtile; import java.awt.Color; +import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -22,10 +25,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.StatCollector; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IManaNetwork; import vazkii.botania.api.mana.IManaCollector; +import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.core.helper.ItemNBTHelper; /** * The basic class for a Generating Flower. @@ -39,6 +45,7 @@ public class SubTileGenerating extends SubTileEntity { private static final String TAG_COLLECTOR_X = "collectorX"; private static final String TAG_COLLECTOR_Y = "collectorY"; private static final String TAG_COLLECTOR_Z = "collectorZ"; + private static final String TAG_PASSIVE_DECAY_TICKS = "passiveDecayTicks"; protected int mana; @@ -47,6 +54,7 @@ public class SubTileGenerating extends SubTileEntity { int sizeLastCheck = -1; protected TileEntity linkedCollector = null; public int knownMana = -1; + public int passiveDecayTicks; ChunkCoordinates cachedCollectorCoordinates = null; @@ -87,17 +95,21 @@ public class SubTileGenerating extends SubTileEntity { if(Math.random() > particleChance) BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); } - + + boolean passive = isPassiveFlower(); if(!supertile.getWorldObj().isRemote) { int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); - if(isPassiveFlower() && muhBalance > 0 && ticksExisted > muhBalance) { + if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { supertile.getWorldObj().playAuxSFX(2001, supertile.xCoord, supertile.yCoord, supertile.zCoord, Block.getIdFromBlock(supertile.getBlockType())); if(supertile.getWorldObj().getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord).isSideSolid(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 1, supertile.zCoord, ForgeDirection.UP)) supertile.getWorldObj().setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush); else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); } } + + if(!overgrowth && passive) + passiveDecayTicks++; } public void linkCollector() { @@ -172,6 +184,26 @@ public class SubTileGenerating extends SubTileEntity { public int getValueForPassiveGeneration() { return 1; } + + @Override + public ArrayList getDrops(ArrayList list) { + ArrayList drops = super.getDrops(list); + if(isPassiveFlower()) + populateDropStackNBTs(drops); + return drops; + } + + public void populateDropStackNBTs(List drops) { + if(isPassiveFlower() && ticksExisted > 0 && ConfigHandler.hardcorePassiveGeneration > 0) + ItemNBTHelper.setInt(drops.get(0), TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + super.onBlockPlacedBy(world, x, y, z, entity, stack); + if(isPassiveFlower()) + passiveDecayTicks = ItemNBTHelper.getInt(stack, TAG_PASSIVE_DECAY_TICKS, 0); + } @Override public boolean onWanded(EntityPlayer player, ItemStack wand) { @@ -198,11 +230,12 @@ public class SubTileGenerating extends SubTileEntity { @Override public void readFromPacketNBT(NBTTagCompound cmp) { mana = cmp.getInteger(TAG_MANA); + passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); int x = cmp.getInteger(TAG_COLLECTOR_X); int y = cmp.getInteger(TAG_COLLECTOR_Y); int z = cmp.getInteger(TAG_COLLECTOR_Z); - + cachedCollectorCoordinates = y < 0 ? null : new ChunkCoordinates(x, y, z); } @@ -210,7 +243,8 @@ public class SubTileGenerating extends SubTileEntity { public void writeToPacketNBT(NBTTagCompound cmp) { cmp.setInteger(TAG_MANA, mana); cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); - + cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); + if(cachedCollectorCoordinates != null) { cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX); cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY); @@ -266,5 +300,10 @@ public class SubTileGenerating extends SubTileEntity { int color = getColor(); BotaniaAPI.internalHandler.drawComplexManaHUD(color, knownMana, getMaxMana(), name, res, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding()); } + + @Override + public boolean isOvergrowthAffected() { + return !isPassiveFlower(); + } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java index 4bdfa95b0..f2a4f2804 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTilePassiveGenerating.java @@ -27,22 +27,4 @@ public class SubTilePassiveGenerating extends SubTileGenerating { return true; } - @Override - public ArrayList getDrops(ArrayList list) { - ArrayList drops = super.getDrops(list); - populateDropStackNBTs(drops); - return drops; - } - - public void populateDropStackNBTs(List drops) { - if(isPassiveFlower() && ticksExisted > 0 && ConfigHandler.hardcorePassiveGeneration > 0) - ItemNBTHelper.setInt(drops.get(0), TAG_TICKS_EXISTED, ticksExisted); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - super.onBlockPlacedBy(world, x, y, z, entity, stack); - ticksExisted = ItemNBTHelper.getInt(stack, TAG_TICKS_EXISTED, 0); - } - } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java index 43a802f74..8363ca33e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpecialFlower.java @@ -89,9 +89,17 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil } } + boolean special = isOnSpecialSoil(); + if(special) { + subTile.overgrowth = true; + if(subTile.isOvergrowthAffected()) { + subTile.onUpdate(); + subTile.overgrowthBoost = true; + } + } subTile.onUpdate(); - if(isOnSpecialSoil()) - subTile.onUpdate(); + subTile.overgrowth = false; + subTile.overgrowthBoost = false; } } diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 0c6ad09b4..fe0c2d39e 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -759,7 +759,7 @@ public final class LexiconData { fireChakram.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFireChakram)); overgrowthSeed = new BLexiconEntry(LibLexicon.TOOL_OVERGROWTH_SEED, categoryTools); - overgrowthSeed.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.overgrowthSeed)); + overgrowthSeed.setLexiconPages(new PageText("0"), new PageText("1")).setIcon(new ItemStack(ModItems.overgrowthSeed)); livingwoodBow = new BLexiconEntry(LibLexicon.TOOL_LIVINGWOOD_BOW, categoryTools); livingwoodBow.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingwoodBow)); diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index b1ade8927..f723f56f2 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -2852,7 +2852,8 @@ botania.page.fireChakram1=As fire as fenn's mixtape # -- OVERGROWTH SEED botania.entry.overgrowthSeed=Overgrowth Seed -botania.page.overgrowthSeed0=An &1Overgrowth Seed&0 is an elusive item, which can be used to enchant a piece of &1Grass&0, via right clicking on it in the world, creating &1Enchanted Soil&0. Flowers that are rooted on this &1Enchanted Soil&0 will function at double the normal speed.
There's one problem, though. No known method of creating these exists, but they have been spotted in ancient structures and the like. +botania.page.overgrowthSeed0=An &1Overgrowth Seed&0 is an elusive item, which can be used to enchant a piece of &1Grass&0, via right clicking on it in the world, creating &1Enchanted Soil&0. Flowers that are rooted on this &1Enchanted Soil&0 will function at double the normal speed.
&4Passive flowers&0 planted on this soil won't get the speed boost, instead, they will simply not decay. +botania.page.overgrowthSeed1=There's one problem, though.
No known method of creating these exists. They have however, been allegedly spotted by historians in ancient structures and temples. Perhaps that would be a wise guess as to where to find these. # -- LIVINGWOOD BOW botania.entry.livingwoodBow=Livingwood Bow