diff --git a/api b/api index d9dd92783..90d78e084 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit d9dd927830e9449d441f823bee5ece662b3615c7 +Subproject commit 90d78e084c2002bd4ebd86ab4e5162c9561450f9 diff --git a/lang b/lang index a3176f1e3..24178af2c 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit a3176f1e3920498f7d97f9360b4bc0bf48eb94f6 +Subproject commit 24178af2cfb1859a0ff9971e688bcc12907ff7a7 diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/BlockLeaves.java index 3452d5474..f0052ec42 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockLeaves.java @@ -18,8 +18,10 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -35,6 +37,8 @@ import forestry.api.arboriculture.ITree; import forestry.api.core.IToolScoop; import forestry.api.lepidopterology.EnumFlutterType; import forestry.api.lepidopterology.IButterfly; +import forestry.arboriculture.items.ItemLeavesBlock; +import forestry.core.config.ForestryBlock; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; @@ -147,6 +151,20 @@ public class BlockLeaves extends BlockTreeContainer { return prod; } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + TileLeaves leaves = getLeafTile(world, x, y, z); + + NBTTagCompound nbttagcompound = new NBTTagCompound(); + leaves.getTree().writeToNBT(nbttagcompound); + + ItemLeavesBlock leavesItem = (ItemLeavesBlock)ForestryBlock.leaves.item(); + ItemStack leavesStack = new ItemStack(leavesItem); + leavesStack.setTagCompound(nbttagcompound); + + return leavesStack; + } + /* RENDERING */ @Override public boolean isOpaqueCube() { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java index 83443a9a6..31ae5d07b 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java @@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -145,6 +146,12 @@ public class BlockSapling extends BlockTreeContainer { return new ArrayList(); } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + TileSapling sapling = getSaplingTile(world, x, y, z); + return PluginArboriculture.treeInterface.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal()); + } + @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { if (Proxies.common.isSimulating(world) && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index c4cc844f1..83f2d81a3 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -277,16 +277,16 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru /* NETWORK */ @Override public Packet getDescriptionPacket() { - return new PacketLeafUpdate(xCoord, yCoord, zCoord, this).getPacket(); + return new PacketLeafUpdate(this).getPacket(); } @Override public void sendNetworkUpdate() { - Proxies.net.sendNetworkPacket(new PacketLeafUpdate(xCoord, yCoord, zCoord, this), xCoord, yCoord, zCoord); + Proxies.net.sendNetworkPacket(new PacketLeafUpdate(this), xCoord, yCoord, zCoord); } private void sendNetworkUpdateRipening() { - Proxies.net.sendNetworkPacket(new PacketLeafUpdate(xCoord, yCoord, zCoord, determineFruitColour()), xCoord, yCoord, zCoord); + Proxies.net.sendNetworkPacket(new PacketLeafUpdate(this, determineFruitColour()), xCoord, yCoord, zCoord); } @Override @@ -296,6 +296,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru if(packet.isRipeningUpdate()) { colourFruits = packet.colourFruits; } else { + readFromNBT(packet.getTagCompound()); isFruitLeaf = packet.isFruitLeaf(); isPollinatedState = packet.isPollinated(); textureIndexFancy = packet.textureIndexFancy; diff --git a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java new file mode 100644 index 000000000..da1cda956 --- /dev/null +++ b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java @@ -0,0 +1,43 @@ +package forestry.arboriculture.items; + +import forestry.api.arboriculture.ITree; +import forestry.arboriculture.genetics.Tree; +import forestry.core.items.ItemForestryBlock; +import forestry.core.utils.StringUtil; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +public class ItemLeavesBlock extends ItemForestryBlock { + + public ItemLeavesBlock(Block block) { + super(block); + } + + @Override + public String getItemStackDisplayName(ItemStack itemstack) { + String type = StringUtil.localize("trees.grammar.leaves.type"); + if (!itemstack.hasTagCompound()) + return type; + ITree tree = getTree(itemstack); + String customTreeKey = "trees.custom.leaves." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.",""); + if(StatCollector.canTranslate("for." + customTreeKey)){ + return StringUtil.localize(customTreeKey); + } + String grammar = StringUtil.localize("trees.grammar.leaves"); + + return grammar.replaceAll("%SPECIES", tree.getDisplayName()).replaceAll("%TYPE", type); + } + + @Override + public int getColorFromItemStack(ItemStack itemstack, int renderPass) { + ITree tree = getTree(itemstack); + return tree.getGenome().getPrimary().getLeafColour(tree); + } + + private ITree getTree(ItemStack itemStack) { + return new Tree(itemStack.getTagCompound()); + } + +} diff --git a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java index 8367fa9d1..abcff5967 100755 --- a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java +++ b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java @@ -15,10 +15,10 @@ import java.io.DataOutputStream; import java.io.IOException; import forestry.arboriculture.gadgets.TileLeaves; -import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; +import forestry.core.network.PacketTileNBT; -public class PacketLeafUpdate extends PacketCoordinates { +public class PacketLeafUpdate extends PacketTileNBT { public byte isRipeningUpdate = 0; @@ -33,8 +33,8 @@ public class PacketLeafUpdate extends PacketCoordinates { public PacketLeafUpdate() { } - public PacketLeafUpdate(int posX, int posY, int posZ, TileLeaves leaves) { - super(PacketIds.LEAF_UPDATE, posX, posY, posZ); + public PacketLeafUpdate(TileLeaves leaves) { + super(PacketIds.LEAF_UPDATE, leaves); leafState = 0; if(leaves.hasFruit()) @@ -48,8 +48,8 @@ public class PacketLeafUpdate extends PacketCoordinates { colourFruits = leaves.determineFruitColour(); } - public PacketLeafUpdate(int posX, int posY, int posZ, int fruitColour) { - super(PacketIds.LEAF_UPDATE, posX, posY, posZ); + public PacketLeafUpdate(TileLeaves leaves, int fruitColour) { + super(PacketIds.LEAF_UPDATE, leaves); isRipeningUpdate = 1; colourFruits = fruitColour; diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index f896efb4f..31f51f179 100755 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -89,6 +89,7 @@ import forestry.arboriculture.genetics.TreeTemplates; import forestry.arboriculture.genetics.TreekeepingMode; import forestry.arboriculture.items.ItemGermlingGE; import forestry.arboriculture.items.ItemGrafter; +import forestry.arboriculture.items.ItemLeavesBlock; import forestry.arboriculture.items.ItemStairs; import forestry.arboriculture.items.ItemTreealyzer; import forestry.arboriculture.items.ItemWoodBlock; @@ -233,7 +234,7 @@ public class PluginArboriculture extends NativePlugin implements IFuelHandler { ForestryBlock.saplingGE.registerBlock(new BlockSapling(), ItemForestryBlock.class, "saplingGE"); // Leaves - ForestryBlock.leaves.registerBlock(new BlockLeaves(), ItemForestryBlock.class, "leaves"); + ForestryBlock.leaves.registerBlock(new BlockLeaves(), ItemLeavesBlock.class, "leaves"); // Pods ForestryBlock.pods.registerBlock(new BlockFruitPod(), ItemForestryBlock.class, "pods");