mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 04:52:26 +00:00
Close #624 Make Forestry saplings IGrowable
This commit is contained in:
1 parent
821cfb4987
commit
8d9a0090ec
2 files changed
+25
-8
No files matched your search
@@ -19,7 +19,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.arboriculture.gadgets.TileFruitPod;
|
||||
import forestry.arboriculture.gadgets.TileSapling;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class EventHandlerArboriculture {
|
||||
@@ -32,12 +31,7 @@ public class EventHandlerArboriculture {
|
||||
}
|
||||
|
||||
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (tile instanceof TileSapling) {
|
||||
int result = ((TileSapling) tile).tryGrow(true);
|
||||
if (result == 1 || result == 2) {
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
} else if (tile instanceof TileFruitPod) {
|
||||
if (tile instanceof TileFruitPod) {
|
||||
if (((TileFruitPod) tile).canMature()) {
|
||||
((TileFruitPod) tile).mature();
|
||||
event.setResult(Result.ALLOW);
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -37,7 +39,7 @@ import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class BlockSapling extends BlockTreeContainer {
|
||||
public class BlockSapling extends BlockTreeContainer implements IGrowable {
|
||||
|
||||
public static TileSapling getSaplingTile(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
@@ -186,4 +188,25 @@ public class BlockSapling extends BlockTreeContainer {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
/** canFertilize */
|
||||
public boolean func_149851_a(World worldIn, int x, int y, int z, boolean isClient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
/** shouldFertilize */
|
||||
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
|
||||
return (double) world.rand.nextFloat() < 0.45D;
|
||||
}
|
||||
|
||||
@Override
|
||||
/** fertilize */
|
||||
public void func_149853_b(World world, Random random, int x, int y, int z) {
|
||||
TileSapling saplingTile = getSaplingTile(world, x, y, z);
|
||||
if (saplingTile != null) {
|
||||
saplingTile.tryGrow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user