Fix #431 Leaves become invisible when they start to decay

This commit is contained in:
mezz committed 2015-01-04 22:58:10 -08:00
1 parent 960b322e86
commit e5979367ee
18 files changed
+265 -199

No files matched your search

@@ -50,7 +50,7 @@ public class ItemBeeGE extends ItemGE {
}
@Override
protected IIndividual getIndividual(ItemStack itemstack) {
public IBee getIndividual(ItemStack itemstack) {
return new Bee(itemstack.getTagCompound());
}
@@ -12,9 +12,12 @@ package forestry.arboriculture;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.arboriculture.network.PacketLeafUpdate;
import forestry.arboriculture.network.PacketRipeningUpdate;
import forestry.core.interfaces.IPacketHandler;
import forestry.core.network.PacketIds;
import forestry.core.proxy.Proxies;
import forestry.storage.proxy.ProxyStorage;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
@@ -26,11 +29,18 @@ public class PacketHandlerArboriculture implements IPacketHandler {
try {
switch (packetID) {
case PacketIds.LEAF_UPDATE:
PacketLeafUpdate packet = new PacketLeafUpdate();
packet.readData(data);
onLeafUpdate(packet);
break;
case PacketIds.LEAF_UPDATE: {
PacketLeafUpdate packet = new PacketLeafUpdate();
packet.readData(data);
onLeafUpdate(packet);
break;
}
case PacketIds.RIPENING_UPDATE: {
PacketRipeningUpdate packet = new PacketRipeningUpdate();
packet.readData(data);
onRipeningUpdate(packet);
break;
}
}
} catch(Exception ex) {
@@ -46,5 +56,12 @@ public class PacketHandlerArboriculture implements IPacketHandler {
}
private void onRipeningUpdate(PacketRipeningUpdate packet) {
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileLeaves)
((TileLeaves) tile).fromRipeningPacket(packet);
}
}
@@ -181,6 +181,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
if (getLeafTile(world, x, y, z).isDecorative())
return;
super.beginLeavesDecay(world, x, y, z);
world.markBlockForUpdate(x, y, z);
}
@Override
@@ -191,6 +192,11 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
super.updateTick(world, x, y, z, random);
// check leaves tile again because they can decay in super.updateTick
tileLeaves = getLeafTile(world, x, y, z);
if (tileLeaves == null)
return;
if (world.rand.nextFloat() > 0.1)
return;
tileLeaves.onBlockTick();
@@ -48,6 +48,7 @@ import forestry.api.lepidopterology.IButterfly;
import forestry.api.lepidopterology.IButterflyNursery;
import forestry.api.lepidopterology.IButterflyRoot;
import forestry.arboriculture.network.PacketLeafUpdate;
import forestry.arboriculture.network.PacketRipeningUpdate;
import forestry.core.utils.GeneticsUtil;
import forestry.core.EnumErrorCode;
import forestry.core.genetics.Allele;
@@ -312,27 +313,26 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
}
private void sendNetworkUpdateRipening() {
Proxies.net.sendNetworkPacket(new PacketLeafUpdate(this, determineFruitColour()), xCoord, yCoord, zCoord);
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this, determineFruitColour()), xCoord, yCoord, zCoord);
}
@Override
public void fromPacket(ForestryPacket packetRaw) {
super.fromPacket(packetRaw);
PacketLeafUpdate packet = (PacketLeafUpdate)packetRaw;
if(packet.isRipeningUpdate()) {
colourFruits = packet.colourFruits;
} else {
readFromNBT(packet.getTagCompound());
isFruitLeaf = packet.isFruitLeaf();
isPollinatedState = packet.isPollinated();
textureIndexFancy = packet.textureIndexFancy;
textureIndexPlain = packet.textureIndexPlain;
textureIndexFruits = packet.textureIndexFruit;
colourLeaves = packet.colourLeaves;
colourFruits = packet.colourFruits;
}
worldObj.func_147479_m(xCoord, yCoord, zCoord);
isFruitLeaf = packet.isFruitLeaf();
isPollinatedState = packet.isPollinated();
textureIndexFancy = packet.textureIndexFancy;
textureIndexPlain = packet.textureIndexPlain;
textureIndexFruits = packet.textureIndexFruit;
colourLeaves = packet.colourLeaves;
colourFruits = packet.colourFruits;
}
public void fromRipeningPacket(PacketRipeningUpdate packet) {
colourFruits = packet.colourFruits;
}
/**
@@ -45,6 +45,7 @@ import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.arboriculture.gadgets.BlockFruitPod;
import forestry.arboriculture.gadgets.ForestryBlockLeaves;
import forestry.arboriculture.gadgets.TileFruitPod;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.arboriculture.gadgets.TileSapling;
@@ -214,20 +215,19 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
if (!ForestryBlock.leaves.isBlockEqual(world, x, y, z))
return false;
TileLeaves tileLeaves = new TileLeaves();
tileLeaves.setTree((ITree) tree.copy());
tileLeaves.setOwner(owner);
if (decorative)
tileLeaves.setDecorative();
world.setTileEntity(x, y, z, tileLeaves);
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileLeaves)) {
TileEntity tile = ForestryBlockLeaves.getLeafTile(world, x, y, z);
if (tile == null) {
world.setBlockToAir(x, y, z);
return false;
}
TileLeaves tileLeaves = (TileLeaves) tile;
tileLeaves.setOwner(owner);
tileLeaves.setTree((ITree) tree.copy());
if (decorative)
tileLeaves.setDecorative();
world.markBlockForUpdate(x, y, z);
return true;
}
@@ -51,7 +51,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable {
}
@Override
protected IIndividual getIndividual(ItemStack itemstack) {
public ITree getIndividual(ItemStack itemstack) {
return new Tree(itemstack.getTagCompound());
}
@@ -18,7 +18,6 @@ import net.minecraft.world.World;
import forestry.api.arboriculture.ITree;
import forestry.api.core.ForestryAPI;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.interfaces.IErrorSource;
@@ -28,7 +27,6 @@ import forestry.core.items.ItemInventoried;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginArboriculture;
public class ItemTreealyzer extends ItemInventoried {
@@ -42,7 +40,7 @@ public class ItemTreealyzer extends ItemInventoried {
@Override
protected boolean isSpecimen(ItemStack itemStack) {
return StackUtils.containsItemStack(AlleleManager.ersatzSaplings.keySet(), itemStack) || PluginArboriculture.treeInterface.isMember(itemStack);
return GeneticsUtil.getGeneticEquivalent(itemStack) instanceof ITree;
}
private void tryAnalyze() {
@@ -10,17 +10,21 @@
******************************************************************************/
package forestry.arboriculture.network;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketTileNBT;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.world.World;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketTileNBT;
public class PacketLeafUpdate extends PacketTileNBT {
public byte isRipeningUpdate = 0;
private static short hasFruitFlag = 1;
private static short isPollinatedFlag = 1 << 1;
private byte leafState = 0;
public short textureIndexFancy;
public short textureIndexPlain;
@@ -37,9 +41,9 @@ public class PacketLeafUpdate extends PacketTileNBT {
leafState = 0;
if(leaves.hasFruit())
leafState |= 1 << 0;
leafState |= hasFruitFlag;
if(leaves.isPollinated())
leafState |= 1 << 1;
leafState |= isPollinatedFlag;
textureIndexFancy = leaves.determineTextureIndex(true);
textureIndexPlain = leaves.determineTextureIndex(false);
textureIndexFruit = leaves.determineOverlayIndex();
@@ -47,56 +51,35 @@ public class PacketLeafUpdate extends PacketTileNBT {
colourFruits = leaves.determineFruitColour();
}
public PacketLeafUpdate(TileLeaves leaves, int fruitColour) {
super(PacketIds.LEAF_UPDATE, leaves);
isRipeningUpdate = 1;
colourFruits = fruitColour;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
super.writeData(data);
data.writeByte(isRipeningUpdate);
if(isRipeningUpdate()) {
data.writeInt(colourFruits);
} else {
data.writeByte(leafState);
data.writeShort(textureIndexFancy);
data.writeShort(textureIndexPlain);
data.writeShort(textureIndexFruit);
data.writeInt(colourLeaves);
data.writeInt(colourFruits);
}
data.writeByte(leafState);
data.writeShort(textureIndexFancy);
data.writeShort(textureIndexPlain);
data.writeShort(textureIndexFruit);
data.writeInt(colourLeaves);
data.writeInt(colourFruits);
}
@Override
public void readData(DataInputStream data) throws IOException {
super.readData(data);
isRipeningUpdate = data.readByte();
if(isRipeningUpdate()) {
colourFruits = data.readInt();
} else {
leafState = data.readByte();
textureIndexFancy = data.readShort();
textureIndexPlain = data.readShort();
textureIndexFruit = data.readShort();
colourLeaves = data.readInt();
colourFruits = data.readInt();
}
leafState = data.readByte();
textureIndexFancy = data.readShort();
textureIndexPlain = data.readShort();
textureIndexFruit = data.readShort();
colourLeaves = data.readInt();
colourFruits = data.readInt();
}
public boolean isRipeningUpdate() {
return isRipeningUpdate != 0;
}
public boolean isFruitLeaf() {
return (leafState & (1 << 0)) > 0;
return (leafState & hasFruitFlag) > 0;
}
public boolean isPollinated() {
return (leafState & (1 << 1)) > 0;
return (leafState & isPollinatedFlag) > 0;
}
}
@@ -0,0 +1,63 @@
/*******************************************************************************
* 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.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.core.network.ForestryPacket;
import forestry.core.network.PacketIds;
public class PacketRipeningUpdate extends ForestryPacket {
public int colourFruits;
private int posX, posY, posZ;
public PacketRipeningUpdate() {
}
public PacketRipeningUpdate(TileLeaves leaves, int fruitColour) {
super(PacketIds.RIPENING_UPDATE);
posX = leaves.xCoord;
posY = leaves.yCoord;
posZ = leaves.zCoord;
colourFruits = fruitColour;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
super.writeData(data);
data.writeInt(posX);
data.writeInt(posY);
data.writeInt(posZ);
data.writeInt(colourFruits);
}
@Override
public void readData(DataInputStream data) throws IOException {
super.readData(data);
posX = data.readInt();
posY = data.readInt();
posZ = data.readInt();
colourFruits = data.readInt();
}
public TileEntity getTarget(World world) {
return world.getTileEntity(posX, posY, posZ);
}
}
@@ -24,8 +24,6 @@ public class BlockTypeVoid extends BlockType {
@Override
public void setBlock(World world, ITreeGenData tree, int x, int y, int z) {
world.setBlockToAir(x, y, z);
if (world.getTileEntity(x, y, z) != null)
world.removeTileEntity(x, y, z);
}
}
@@ -88,20 +88,14 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
protected void generateTreeTrunk(int height, int girth, float vines) {
int offset = (girth - 1) / 2;
for (int x = 0; x < girth; x++)
for (int y = 0; y < girth; y++)
for (int i = 0; i < height; i++) {
addWood(x - offset, i, y - offset, EnumReplaceMode.ALL);
if (rand.nextFloat() < vines)
addVine(x - offset - 1, i, y - offset);
if (rand.nextFloat() < vines)
addVine(x - offset + 1, i, y - offset);
if (rand.nextFloat() < vines)
addVine(x - offset, i, y - offset - 1);
if (rand.nextFloat() < vines)
addVine(x - offset, i, y - offset + 1);
for (int x = 0; x < girth; x++) {
for (int z = 0; z < girth; z++) {
for (int y = 0; y < height; y++) {
addWood(x - offset, y, z - offset, EnumReplaceMode.ALL);
addVines(x - offset, y, z - offset, vines);
}
}
}
if (!spawnPods)
return;
@@ -148,7 +142,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
@Override
protected void addBlock(int x, int y, int z, BlockType type, EnumReplaceMode replace) {
if (replace == EnumReplaceMode.ALL
|| replace == EnumReplaceMode.SOFT && Utils.isReplaceableBlock(world, startX + x, startY + y, startZ + z)
|| (replace == EnumReplaceMode.SOFT && Utils.isReplaceableBlock(world, startX + x, startY + y, startZ + z))
|| world.isAirBlock(startX + x, startY + y, startZ + z))
type.setBlock(world, tree, startX + x, startY + y, startZ + z);
}
@@ -179,4 +173,18 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
addBlock(x, y, z, vine, EnumReplaceMode.NONE);
}
protected final void addVines(int x, int y, int z, float chance) {
if (chance <= 0)
return;
if (rand.nextFloat() < chance)
addVine(x - 1, y, z);
if (rand.nextFloat() < chance)
addVine(x + 1, y, z);
if (rand.nextFloat() < chance)
addVine(x, y, z - 1);
if (rand.nextFloat() < chance)
addVine(x, y, z + 1);
}
}
@@ -35,7 +35,7 @@ public abstract class ItemGE extends Item {
protected abstract int getDefaultSecondaryColour();
protected abstract IIndividual getIndividual(ItemStack itemstack);
public abstract IIndividual getIndividual(ItemStack itemstack);
protected abstract IAlleleSpecies getSpecies(ItemStack itemStack);
@@ -1,62 +1,63 @@
/*******************************************************************************
* 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.core.network;
/**
* Valid ids: 0 - 127
*/
public class PacketIds {
public static final int TILE_FORESTRY_UPDATE = 0;
public static final int TILE_UPDATE = 1;
public static final int TILE_DESCRIPTION = 2;
public static final int IINVENTORY_STACK = 3;
public static final int FX_SIGNAL = 4;
public static final int TILE_NBT = 5;
public static final int HABITAT_BIOME_POINTER = 20;
public static final int GUI_SELECTION_CHANGE = 30;
public static final int IMPRINT_SELECTION_GET = 31;
public static final int GUI_SELECTION = 32;
public static final int PIPETTE_CLICK = 40;
public static final int ACCESS_SWITCH = 50;
public static final int GENOME_TRACKER_UPDATE = 60;
public static final int GAME_TOKEN_SET = 61;
public static final int CHIPSET_CLICK = 70;
public static final int SOLDERING_IRON_CLICK = 71;
public static final int SOCKET_UPDATE = 72;
public static final int LETTER_RECIPIENT = 80;
public static final int LETTER_TEXT = 81;
public static final int TRADING_ADDRESS_SET = 82;
public static final int LETTER_INFO = 83;
public static final int POBOX_INFO = 85;
public static final int POBOX_INFO_REQUEST = 86;
public static final int LEAF_UPDATE = 90;
public static final int GUI_INTEGER = 92;
// Propolis pipe
public static final int PROP_SEND_FILTER_SET = 100;
public static final int PROP_REQUEST_FILTER_SET = 101;
public static final int PROP_SEND_FILTER_CHANGE_GENOME = 102;
public static final int PROP_SEND_FILTER_CHANGE_TYPE = 103;
}
/*******************************************************************************
* 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.core.network;
/**
* Valid ids: 0 - 127
*/
public class PacketIds {
public static final int TILE_FORESTRY_UPDATE = 0;
public static final int TILE_UPDATE = 1;
public static final int TILE_DESCRIPTION = 2;
public static final int IINVENTORY_STACK = 3;
public static final int FX_SIGNAL = 4;
public static final int TILE_NBT = 5;
public static final int HABITAT_BIOME_POINTER = 20;
public static final int GUI_SELECTION_CHANGE = 30;
public static final int IMPRINT_SELECTION_GET = 31;
public static final int GUI_SELECTION = 32;
public static final int PIPETTE_CLICK = 40;
public static final int ACCESS_SWITCH = 50;
public static final int GENOME_TRACKER_UPDATE = 60;
public static final int GAME_TOKEN_SET = 61;
public static final int CHIPSET_CLICK = 70;
public static final int SOLDERING_IRON_CLICK = 71;
public static final int SOCKET_UPDATE = 72;
public static final int LETTER_RECIPIENT = 80;
public static final int LETTER_TEXT = 81;
public static final int TRADING_ADDRESS_SET = 82;
public static final int LETTER_INFO = 83;
public static final int POBOX_INFO = 85;
public static final int POBOX_INFO_REQUEST = 86;
public static final int LEAF_UPDATE = 90;
public static final int RIPENING_UPDATE = 91;
public static final int GUI_INTEGER = 92;
// Propolis pipe
public static final int PROP_SEND_FILTER_SET = 100;
public static final int PROP_REQUEST_FILTER_SET = 101;
public static final int PROP_SEND_FILTER_CHANGE_GENOME = 102;
public static final int PROP_SEND_FILTER_CHANGE_TYPE = 103;
}
@@ -18,6 +18,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -30,6 +31,7 @@ import forestry.api.core.IArmorNaturalist;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.genetics.ItemGE;
import forestry.plugins.PluginArboriculture;
public class GeneticsUtil {
@@ -65,7 +67,7 @@ public class GeneticsUtil {
return (IPollinatable) tile;
}
IIndividual pollen = getErsatzPollen(world, x, y, z);
ITree pollen = getErsatzPollen(world, x, y, z);
if (pollen != null) {
PluginArboriculture.treeInterface.setLeaves(world, pollen, owner, x, y, z);
return (IPollinatable) world.getTileEntity(x, y, z);
@@ -74,7 +76,7 @@ public class GeneticsUtil {
return null;
}
public static IIndividual getErsatzPollen(World world, final int x, final int y, final int z) {
public static ITree getErsatzPollen(World world, final int x, final int y, final int z) {
Block block = world.getBlock(x, y, z);
if (!isErsatzMaterial(block))
return null;
@@ -89,35 +91,33 @@ public class GeneticsUtil {
}
meta %= 3;
}
// Find the matching ersatz genome
for (ItemStack ersatzSpecimen : AlleleManager.ersatzSpecimen.keySet()) {
if (StackUtils.equals(block, meta, ersatzSpecimen)) {
return AlleleManager.ersatzSpecimen.get(ersatzSpecimen).copy();
}
}
ItemStack itemStack = new ItemStack(block, meta);
IIndividual tree = getGeneticEquivalent(itemStack);
if (tree instanceof ITree)
return (ITree) tree;
return null;
}
public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) {
ItemStack ersatz = null;
ITree tree = null;
public static IIndividual getGeneticEquivalent(ItemStack itemStack) {
Item item = itemStack.getItem();
if (item instanceof ItemGE)
return ((ItemGE) item).getIndividual(itemStack);
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSaplings.entrySet()) {
if (entry.getKey().getItem() != foreign.getItem())
continue;
if (entry.getKey().getItemDamage() != foreign.getItemDamage())
continue;
if (entry.getValue() instanceof ITree)
tree = (ITree) entry.getValue();
ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal());
ersatz.stackSize = foreign.stackSize;
if (StackUtils.isIdenticalItem(itemStack, entry.getKey()))
return entry.getValue().copy();
}
return null;
}
public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) {
IIndividual tree = getGeneticEquivalent(foreign);
if (!(tree instanceof ITree))
return null;
ItemStack ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal());
ersatz.stackSize = foreign.stackSize;
return ersatz;
}
}
@@ -33,8 +33,6 @@ public class BlockType {
public void setBlock(World world, ITreeGenData tree, int x, int y, int z) {
world.setBlock(x, y, z, block, meta, Defaults.FLAG_BLOCK_SYNCH);
if (world.getTileEntity(x, y, z) != null)
world.removeTileEntity(x, y, z);
}
public int getMeta() {
@@ -36,7 +36,7 @@ public class FarmableGE implements IFarmable {
public ICrop getCropAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block.isAir(world, x, y, z) || !block.isWood(world, x, y, z))
if (!block.isWood(world, x, y, z))
return null;
return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
@@ -10,17 +10,17 @@
******************************************************************************/
package forestry.farming.logic;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.plugins.PluginArboriculture;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.GeneticsUtil;
import forestry.plugins.PluginArboriculture;
public class FarmableVanillaSapling extends FarmableGenericSapling {
public FarmableVanillaSapling() {
@@ -29,17 +29,11 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
ITree tree = null;
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSaplings.entrySet())
if (entry.getKey().isItemEqual(germling) && entry.getValue() instanceof ITree) {
tree = (ITree) entry.getValue();
break;
}
if (tree == null)
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
if (!(tree instanceof ITree))
return false;
return PluginArboriculture.treeInterface.plantSapling(world, tree, player.getGameProfile(), x, y, z);
return PluginArboriculture.treeInterface.plantSapling(world, (ITree)tree, player.getGameProfile(), x, y, z);
}
}
@@ -60,7 +60,7 @@ public class ItemButterflyGE extends ItemGE {
}
@Override
protected IIndividual getIndividual(ItemStack itemstack) {
public IButterfly getIndividual(ItemStack itemstack) {
return PluginLepidopterology.butterflyInterface.getMember(itemstack);
}