mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Fix #738 plain leaf blocks accept fertilizer and fruit pods do not grow
This commit is contained in:
1 parent
7b05cfd2f7
commit
1b7d64a7b5
8 files changed
+80
-68
No files matched your search
@@ -1,48 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.arboriculture.gadgets.TileFruitPod;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class EventHandlerArboriculture {
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleBonemeal(BonemealEvent event) {
|
||||
|
||||
if (!Proxies.common.isSimulating(event.world)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (tile instanceof TileFruitPod) {
|
||||
if (((TileFruitPod) tile).canMature()) {
|
||||
((TileFruitPod) tile).mature();
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
} else if (tile instanceof IFruitBearer) {
|
||||
IFruitBearer bearer = (IFruitBearer) tile;
|
||||
if (bearer.getRipeness() < 1.0f) {
|
||||
bearer.addRipeness(1.0f);
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -139,4 +139,30 @@ public class BlockFruitPod extends BlockCocoa {
|
||||
return PluginArboriculture.modelIdPods;
|
||||
}
|
||||
|
||||
/* IGrowable */
|
||||
|
||||
@Override
|
||||
// canFertilize
|
||||
public boolean func_149851_a(World world, int x, int y, int z, boolean isClient) {
|
||||
TileFruitPod podTile = getPodTile(world, x, y, z);
|
||||
if (podTile != null) {
|
||||
return podTile.canMature();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
// shouldFertilize
|
||||
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
// fertilize
|
||||
public void func_149853_b(World world, Random random, int x, int y, int z) {
|
||||
TileFruitPod podTile = getPodTile(world, x, y, z);
|
||||
if (podTile != null) {
|
||||
podTile.mature();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockNewLeaf;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -49,7 +50,7 @@ import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import forestry.plugins.PluginLepidopterology;
|
||||
|
||||
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider {
|
||||
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider, IGrowable {
|
||||
|
||||
public ForestryBlockLeaves() {
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
@@ -328,4 +329,30 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
|
||||
return super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
/* IGrowable */
|
||||
|
||||
@Override
|
||||
// canFertilize
|
||||
public boolean func_149851_a(World world, int x, int y, int z, boolean isClient) {
|
||||
TileLeaves leafTile = getLeafTile(world, x, y, z);
|
||||
if (leafTile != null) {
|
||||
return leafTile.hasFruit() && leafTile.getRipeness() < 1.0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
// shouldFertilize
|
||||
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
// fertilize
|
||||
public void func_149853_b(World world, Random random, int x, int y, int z) {
|
||||
TileLeaves leafTile = getLeafTile(world, x, y, z);
|
||||
if (leafTile != null) {
|
||||
leafTile.addRipeness(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,6 +138,14 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this));
|
||||
}
|
||||
|
||||
public void fromRipeningPacket(int newMaturity) {
|
||||
if (newMaturity == maturity) {
|
||||
return;
|
||||
}
|
||||
maturity = (short) newMaturity;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* IFRUITBEARER */
|
||||
@Override
|
||||
public boolean hasFruit() {
|
||||
|
||||
@@ -421,8 +421,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
}
|
||||
|
||||
public void fromRipeningPacket(PacketRipeningUpdate packet) {
|
||||
int newColourFruits = packet.getValue();
|
||||
public void fromRipeningPacket(int newColourFruits) {
|
||||
if (newColourFruits == colourFruits) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,10 @@ package forestry.arboriculture.network;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.arboriculture.gadgets.TileLeaves;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketHandlerArboriculture implements IPacketHandler {
|
||||
|
||||
@@ -28,8 +25,7 @@ public class PacketHandlerArboriculture implements IPacketHandler {
|
||||
|
||||
switch (packetID) {
|
||||
case RIPENING_UPDATE: {
|
||||
PacketRipeningUpdate packet = new PacketRipeningUpdate(data);
|
||||
onRipeningUpdate(packet);
|
||||
PacketRipeningUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -37,10 +33,4 @@ public class PacketHandlerArboriculture implements IPacketHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void onRipeningUpdate(PacketRipeningUpdate packet) {
|
||||
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof TileLeaves) {
|
||||
((TileLeaves) tile).fromRipeningPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,17 +12,24 @@ package forestry.arboriculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.arboriculture.gadgets.TileFruitPod;
|
||||
import forestry.arboriculture.gadgets.TileLeaves;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketRipeningUpdate extends PacketCoordinates {
|
||||
|
||||
private int value;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketRipeningUpdate(data);
|
||||
}
|
||||
|
||||
public PacketRipeningUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
@@ -40,13 +47,20 @@ public class PacketRipeningUpdate extends PacketCoordinates {
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(value);
|
||||
data.writeVarInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
value = data.readInt();
|
||||
value = data.readVarInt();
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof TileLeaves) {
|
||||
((TileLeaves) tile).fromRipeningPacket(value);
|
||||
} else if (tile instanceof TileFruitPod) {
|
||||
((TileFruitPod) tile).fromRipeningPacket(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
@@ -48,7 +47,6 @@ import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.arboriculture.EventHandlerArboriculture;
|
||||
import forestry.arboriculture.FruitProviderNone;
|
||||
import forestry.arboriculture.FruitProviderPod;
|
||||
import forestry.arboriculture.FruitProviderPod.EnumPodType;
|
||||
@@ -338,8 +336,6 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
GameRegistry.registerTileEntity(TileFruitPod.class, "forestry.Pods");
|
||||
definitionChest.register();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerArboriculture());
|
||||
|
||||
if (Config.enableVillager) {
|
||||
VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_LUMBERJACK);
|
||||
Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_LUMBERJACK, Defaults.TEXTURE_SKIN_LUMBERJACK);
|
||||
|
||||
Reference in new issue
Block a user