#216 make placed leaves decorative and nonfunctional

This commit is contained in:
mezz committed 2014-09-25 22:41:34 -07:00
1 parent 05abf550b9
commit 5219092a7d
6 files changed
+45 -16

No files matched your search

@@ -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<ItemStack> prod = new ArrayList<ItemStack>();
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() {
@@ -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<EnumPlantType> 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<ItemStack> pickFruit(ItemStack tool) {
if (!hasFruit())
return new ArrayList<ItemStack>();
if (getTree() == null)
if (!hasFruit() || isDecorative || getTree() == null)
return new ArrayList<ItemStack>();
ArrayList<ItemStack> picked = new ArrayList<ItemStack>(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 */
@@ -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);
@@ -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);
}
}
@@ -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;