diff --git a/api b/api index 11dd08b63..b3c8d281a 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit 11dd08b6340aecf0d8d8003fa3cb2139f5961c1c +Subproject commit b3c8d281a3c0b0c6035ef215f38a7427bf70e75e diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index 2ae803b07..d302c8e2c 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -100,6 +100,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) { + if (getLeafTile(world, x, y, z).isDecorative()) + return; + int fortune = EnchantmentHelper.getFortuneModifier(player); float saplingModifier = 1.0f; @@ -133,10 +136,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv ArrayList prod = new ArrayList(); TileLeaves tile = getLeafTile(world, x, y, z); - if (tile == null) - return prod; - - if (tile.getTree() == null) + if (tile == null || tile.getTree() == null || tile.isDecorative()) return prod; // Add saplings @@ -178,6 +178,13 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv return ret; } + @Override + public void beginLeavesDecay(World world, int x, int y, int z) { + if (getLeafTile(world, x, y, z).isDecorative()) + return; + super.beginLeavesDecay(world, x, y, z); + } + /* RENDERING */ @Override public boolean isOpaqueCube() { diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 28c69d8f4..43aa22912 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -63,6 +63,9 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru private boolean isPollinatedState; private int ripeningTime; + // set true when placed by a player + private boolean isDecorative = false; + private int maturationTime; private int encumbrance; @@ -119,7 +122,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru if(biomeId < 0) updateBiome(); - if(getTree() == null) + if (isDecorative || getTree() == null) return; boolean isDestroyed = isDestroyed(); @@ -202,6 +205,16 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return ripeningTime; } + public void setDecorative() { + isDecorative = true; + ripeningTime = getTree().getGenome().getFruitProvider().getRipeningPeriod(); + colourFruits = determineFruitColour(); + } + + public boolean isDecorative() { + return isDecorative; + } + /* IPOLLINATABLE */ @Override public EnumSet getPlantType() { @@ -213,7 +226,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public boolean canMateWith(IIndividual individual) { - if (getTree() == null) + if (getTree() == null || isDecorative) return false; if (getTree().getMate() != null) return false; @@ -225,7 +238,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public void mateWith(IIndividual individual) { - if (getTree() == null) + if (getTree() == null || isDecorative) return; getTree().mate((ITree) individual); @@ -234,6 +247,8 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public IIndividual getPollen() { + if (isDecorative) + return null; return getTree(); } @@ -331,9 +346,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /* IFRUITBEARER */ @Override public Collection pickFruit(ItemStack tool) { - if (!hasFruit()) - return new ArrayList(); - if (getTree() == null) + if (!hasFruit() || isDecorative || getTree() == null) return new ArrayList(); ArrayList picked = new ArrayList(Arrays.asList(getTree().produceStacks(worldObj, xCoord, yCoord, zCoord, getRipeningTime()))); @@ -366,7 +379,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public void addRipeness(float add) { - if (getTree() == null) + if (getTree() == null || isDecorative) return; ripeningTime += getTree().getGenome().getFruitProvider().getRipeningPeriod() * add; sendNetworkUpdateRipening(); @@ -436,6 +449,8 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public void setCaterpillar(IButterfly butterfly) { + if (isDecorative) + return; maturationTime = 0; caterpillar = butterfly; sendNetworkUpdate(); @@ -443,7 +458,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public boolean canNurse(IButterfly butterfly) { - return !isDestroyed() && caterpillar == null; + return !isDecorative && !isDestroyed() && caterpillar == null; } /* IHousing */ diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index a6f022ff0..c417d3002 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -200,6 +200,11 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { @Override public boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z) { + return setLeaves(world, tree, owner, x, y, z, false); + } + + @Override + public boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z, boolean decorative) { boolean placed = ForestryBlock.leaves.setBlock(world, x, y, z, 0, Defaults.FLAG_BLOCK_SYNCH); if (!placed) @@ -211,6 +216,8 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { TileLeaves tileLeaves = new TileLeaves(); tileLeaves.setTree((ITree) tree.copy()); tileLeaves.setOwner(owner); + if (decorative) + tileLeaves.setDecorative(); world.setTileEntity(x, y, z, tileLeaves); diff --git a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java index d084da058..be05bcabb 100644 --- a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java @@ -55,7 +55,7 @@ public class ItemLeavesBlock extends ItemForestryBlock { if (tree == null) return false; GameProfile owner = player.getGameProfile(); - return PluginArboriculture.treeInterface.setLeaves(world, tree, owner, x, y, z); + return PluginArboriculture.treeInterface.setLeaves(world, tree, owner, x, y, z, true); } } diff --git a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java index e38de24d0..a2c9e5e27 100755 --- a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java @@ -161,6 +161,7 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I TileLeaves leaves = new TileLeaves(); leaves.setTree(tree); + leaves.setDecorative(); IIcon leavesIcon = leaves.getIcon(Proxies.render.fancyGraphicsEnabled()); int color = leaves.determineFoliageColour(); @@ -205,8 +206,7 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I if (!leaves.hasFruit()) return; - leaves.addRipeness(20); - int fruitColor = leaves.determineFruitColour(); + int fruitColor = leaves.getFruitColour(); IIcon fruitTexture = leaves.getFruitTexture(); if (fruitTexture == null) return;