diff --git a/gradle.properties b/gradle.properties index cb505068b..266f12eea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ mcversion=1.7.10 forgeversion=10.13.4.1566-1.7.10 version_major=4 version_minor=2 -version_patch=3 +version_patch=4 diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index c18120df0..8de528579 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -225,7 +225,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe if (PluginManager.Module.AGRICRAFT.isEnabled()) { Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops"); if (block == cropBlock) { - if(block instanceof IPlantable) { + if (block instanceof IPlantable) { //For agricraft versions which implement IPlantable in the BlockCrop class block = ((IPlantable) block).getPlant(world, x, y, z); } else { diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index 6832199e3..98f37bbc3 100644 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -21,7 +21,7 @@ import forestry.core.items.ItemWithGui; public class ItemBeealyzer extends ItemWithGui { public ItemBeealyzer() { - super(Tabs.tabApiculture); + setCreativeTab(Tabs.tabApiculture); } @Override diff --git a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java index 413b5ef92..b4b5b99de 100644 --- a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java +++ b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java @@ -41,7 +41,7 @@ public class ItemHabitatLocator extends ItemWithGui { private final HabitatLocatorLogic locatorLogic; public ItemHabitatLocator() { - super(Tabs.tabApiculture); + setCreativeTab(Tabs.tabApiculture); setMaxStackSize(1); locatorLogic = new HabitatLocatorLogic(); } diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 57ab2a15f..76176c2c0 100644 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -21,7 +21,7 @@ import forestry.core.items.ItemWithGui; public class ItemImprinter extends ItemWithGui { public ItemImprinter() { - super(Tabs.tabApiculture); + setCreativeTab(Tabs.tabApiculture); } @Override diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index 89a044ddf..7ec9e3de1 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -36,6 +36,7 @@ public class FruitProviderPod extends FruitProviderNone { PAPAYA((short) 2013, (short) 2014, (short) 2015);//, COCONUT((short)2016, (short)2017, (short)2018); public final short[] uids; + EnumPodType(short stage1, short stage2, short stage3) { uids = new short[]{stage1, stage2, stage3}; } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java b/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java index 7960f035c..e728b556f 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockArboricultureType.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.arboriculture.blocks; -import javax.annotation.Nullable; - import forestry.arboriculture.tiles.TileArboristChest; import forestry.core.blocks.IMachinePropertiesTESR; import forestry.core.proxy.Proxies; diff --git a/src/main/java/forestry/arboriculture/blocks/BlockPlanks.java b/src/main/java/forestry/arboriculture/blocks/BlockPlanks.java index ade5fce00..c51e264bb 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockPlanks.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockPlanks.java @@ -46,8 +46,9 @@ public class BlockPlanks extends BlockWood { @Override public IIcon getIcon(int side, int meta) { EnumWoodType woodType = EnumWoodType.LARCH; - if (meta > 0 && meta < EnumWoodType.VALUES.length) + if (meta > 0 && meta < EnumWoodType.VALUES.length) { woodType = EnumWoodType.VALUES[meta]; + } return IconProviderWood.getPlankIcon(woodType); } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockRegistryArboriculture.java b/src/main/java/forestry/arboriculture/blocks/BlockRegistryArboriculture.java index e3b5edae2..f44eb61ff 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockRegistryArboriculture.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockRegistryArboriculture.java @@ -12,6 +12,7 @@ package forestry.arboriculture.blocks; import forestry.arboriculture.items.ItemBlockLeaves; import forestry.arboriculture.items.ItemBlockWood; +import forestry.arboriculture.items.ItemBlockWoodSlab; import forestry.core.blocks.BlockRegistry; import forestry.core.items.ItemBlockForestry; @@ -19,11 +20,13 @@ public class BlockRegistryArboriculture extends BlockRegistry { public final BlockLog logs; public final BlockPlanks planks; public final BlockSlab slabs; + public final BlockSlab slabsDouble; public final BlockArbFence fences; public final BlockArbStairs stairs; public final BlockLog logsFireproof; public final BlockPlanks planksFireproof; public final BlockSlab slabsFireproof; + public final BlockSlab slabsDoubleFireproof; public final BlockArbFence fencesFireproof; public final BlockArbStairs stairsFireproof; @@ -40,9 +43,13 @@ public class BlockRegistryArboriculture extends BlockRegistry { planks = registerBlock(new BlockPlanks(false), ItemBlockWood.class, "planks"); registerOreDictWildcard("plankWood", planks); - - slabs = registerBlock(new BlockSlab(false), ItemBlockWood.class, "slabs"); + + BlockSlab blockSlab = new BlockSlab(false, false); + BlockSlab blockSlabDouble = new BlockSlab(true, false); + slabs = registerBlock(blockSlab, ItemBlockWoodSlab.class, "slabs", blockSlabDouble, blockSlab); registerOreDictWildcard("slabWood", slabs); + + slabsDouble = registerBlock(blockSlabDouble, ItemBlockWoodSlab.class, "slabsDouble", blockSlabDouble, blockSlab); fences = registerBlock(new BlockArbFence(false), ItemBlockWood.class, "fences"); registerOreDictWildcard("fenceWood", fences); @@ -55,9 +62,13 @@ public class BlockRegistryArboriculture extends BlockRegistry { planksFireproof = registerBlock(new BlockPlanks(true), ItemBlockWood.class, "planksFireproof"); registerOreDictWildcard("plankWood", planksFireproof); - - slabsFireproof = registerBlock(new BlockSlab(true), ItemBlockWood.class, "slabsFireproof"); + + BlockSlab blockSlabFireproof = new BlockSlab(false, true); + BlockSlab blockSlabDoubleFireproof = new BlockSlab(true, true); + slabsFireproof = registerBlock(blockSlabFireproof, ItemBlockWoodSlab.class, "slabsFireproof", blockSlabDoubleFireproof, blockSlabFireproof); registerOreDictWildcard("slabWood", slabsFireproof); + + slabsDoubleFireproof = registerBlock(blockSlabDoubleFireproof, ItemBlockWoodSlab.class, "slabsDoubleFireproof", blockSlabDoubleFireproof, blockSlabFireproof); fencesFireproof = registerBlock(new BlockArbFence(true), ItemBlockWood.class, "fencesFireproof"); registerOreDictWildcard("fenceWood", fencesFireproof); diff --git a/src/main/java/forestry/arboriculture/blocks/BlockSlab.java b/src/main/java/forestry/arboriculture/blocks/BlockSlab.java index 0bb34a181..b11c31f08 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockSlab.java @@ -46,8 +46,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp private final ParticleHelper.Callback particleCallback; private final boolean fireproof; - public BlockSlab(boolean fireproof) { - super(false, Material.wood); + public BlockSlab(boolean doubleSlab, boolean fireproof) { + super(doubleSlab, Material.wood); this.fireproof = fireproof; @@ -61,9 +61,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp this.particleCallback = new ParticleHelper.DefaultCallback(this); } - @Override - public boolean isOpaqueCube() { - return false; + public boolean isDoubleSlab() { + return field_150004_a; } /* ICONS */ @@ -100,8 +99,10 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) { - for (EnumWoodType woodType : EnumWoodType.VALUES) { - list.add(TreeManager.woodItemAccess.getSlab(woodType, fireproof)); + if (!isDoubleSlab()) { + for (EnumWoodType woodType : EnumWoodType.VALUES) { + list.add(TreeManager.woodItemAccess.getSlab(woodType, fireproof)); + } } } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java index 078cd91e8..82a8d8679 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java @@ -45,7 +45,6 @@ import forestry.arboriculture.genetics.alleles.AlleleFruit; import forestry.arboriculture.genetics.alleles.AlleleGrowth; import forestry.arboriculture.render.IconProviderGermling; import forestry.arboriculture.render.IconProviderGermlingVanilla; -import forestry.arboriculture.render.IconProviderLeaves; import forestry.arboriculture.tiles.TileLeaves; import forestry.arboriculture.worldgen.BlockTypeLog; import forestry.arboriculture.worldgen.WorldGenAcacia; @@ -462,7 +461,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { // only available by rare villager trade } }, - Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x539d12), 3, new ItemStack(Blocks.log, 1, 3)) { + Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x658917), 3, new ItemStack(Blocks.log, 1, 3)) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenJungle(tree); @@ -868,7 +867,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { .restrictHumidity(EnumHumidity.DAMP); } }, - Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x9ee67f), EnumWoodType.PAPAYA) { + Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x75E675), EnumWoodType.PAPAYA) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenPapaya(tree); @@ -893,7 +892,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { registerMutation(Jungle, Cherry, 5); } }, - Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xf0f38f), EnumWoodType.PALM) { + Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xB3F370), EnumWoodType.PALM) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { return new WorldGenDate(tree); @@ -963,7 +962,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { this.branch = branch; - ILeafIconProvider leafIconProvider = new IconProviderLeaves(leafType, primary, secondary); + ILeafIconProvider leafIconProvider = TreeManager.treeFactory.getLeafIconProvider(leafType, primary, secondary); IGermlingIconProvider germlingIconProvider = new IconProviderGermlingVanilla(vanillaMeta); this.species = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, leafIconProvider, germlingIconProvider, this); @@ -979,7 +978,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { this.branch = branch; - ILeafIconProvider leafIconProvider = new IconProviderLeaves(leafType, primary, secondary); + ILeafIconProvider leafIconProvider = TreeManager.treeFactory.getLeafIconProvider(leafType, primary, secondary); IGermlingIconProvider germlingIconProvider = new IconProviderGermling(uid); this.species = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, leafIconProvider, germlingIconProvider, this); diff --git a/src/main/java/forestry/arboriculture/items/ItemBlockWood.java b/src/main/java/forestry/arboriculture/items/ItemBlockWood.java index ccf265a59..b798f562f 100644 --- a/src/main/java/forestry/arboriculture/items/ItemBlockWood.java +++ b/src/main/java/forestry/arboriculture/items/ItemBlockWood.java @@ -44,6 +44,10 @@ public class ItemBlockWood extends ItemBlockForestry { EnumWoodType woodType = getWoodType(stack); Block block = Block.getBlockFromItem(stack.getItem()); + return placeWood(stack, woodType, block, player, world, x, y, z, metadata); + } + + public static boolean placeWood(ItemStack stack, EnumWoodType woodType, Block block, @Nullable EntityPlayer player, World world, int x, int y, int z, int metadata) { boolean placed = world.setBlock(x, y, z, block, metadata, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE); if (!placed) { return false; @@ -120,6 +124,11 @@ public class ItemBlockWood extends ItemBlockForestry { return null; } + @Override + public int getMetadata(int i) { + return 0; + } + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { return placeWood(stack, player, world, x, y, z, metadata); diff --git a/src/main/java/forestry/arboriculture/items/ItemBlockWoodSlab.java b/src/main/java/forestry/arboriculture/items/ItemBlockWoodSlab.java new file mode 100644 index 000000000..4d28b3c7b --- /dev/null +++ b/src/main/java/forestry/arboriculture/items/ItemBlockWoodSlab.java @@ -0,0 +1,173 @@ +package forestry.arboriculture.items; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.arboriculture.EnumWoodType; +import forestry.arboriculture.blocks.BlockSlab; +import forestry.arboriculture.tiles.TileWood; +import forestry.core.tiles.TileUtil; + +public class ItemBlockWoodSlab extends ItemBlockWood { + private final BlockSlab slab; + private final BlockSlab doubleSlab; + private final boolean isDoubleSlab; + + public ItemBlockWoodSlab(Block block, BlockSlab doubleSlab, BlockSlab slab) { + super(block); + this.doubleSlab = doubleSlab; + this.slab = slab; + this.isDoubleSlab = (block == doubleSlab); + } + + @Override + public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + if (isDoubleSlab) { + return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ); + } else if (itemStack.stackSize == 0) { + return false; + } else if (!player.canPlayerEdit(x, y, z, side, itemStack)) { + return false; + } else { + Block block = world.getBlock(x, y, z); + int i1 = world.getBlockMetadata(x, y, z); + boolean flag = (i1 & 8) != 0; + + EnumWoodType blockWoodType = null; + EnumWoodType stackWoodType = getWoodType(itemStack); + TileWood tile = TileUtil.getTile(world, x, y, z, TileWood.class); + if (tile != null) { + blockWoodType = tile.getWoodType(); + } + + if ((side == 1 && !flag || side == 0 && flag) && block == this.slab && blockWoodType == stackWoodType) { + if (world.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBoxFromPool(world, x, y, z))) { + if (placeWood(itemStack, stackWoodType, doubleSlab, player, world, x, y, z, 0)) { + world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.doubleSlab.stepSound.func_150496_b(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getPitch() * 0.8F); + --itemStack.stackSize; + } + } + + return true; + } else { + if (this.func_150946_a(itemStack, player, world, x, y, z, side)) { + return true; + } else { + return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack itemStack) { + int i1 = x; + int j1 = y; + int k1 = z; + Block block = world.getBlock(x, y, z); + int l1 = world.getBlockMetadata(x, y, z); + boolean flag = (l1 & 8) != 0; + + EnumWoodType blockWoodType = null; + EnumWoodType stackWoodType = getWoodType(itemStack); + TileWood tile = TileUtil.getTile(world, x, y, z, TileWood.class); + if (tile != null) { + blockWoodType = tile.getWoodType(); + } + + if ((side == 1 && !flag || side == 0 && flag) && block == this.slab && stackWoodType == blockWoodType) { + return true; + } else { + if (side == 0) { + --y; + } + + if (side == 1) { + ++y; + } + + if (side == 2) { + --z; + } + + if (side == 3) { + ++z; + } + + if (side == 4) { + --x; + } + + if (side == 5) { + ++x; + } + + Block block1 = world.getBlock(x, y, z); + tile = TileUtil.getTile(world, x, y, z, TileWood.class); + if (tile == null) { + blockWoodType = null; + } else { + blockWoodType = tile.getWoodType(); + } + + if (block1 == this.slab && stackWoodType == blockWoodType) { + return true; + } else { + return super.func_150936_a(world, i1, j1, k1, side, player, itemStack); + } + } + } + + private boolean func_150946_a(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side) { + if (side == 0) { + --y; + } + + if (side == 1) { + ++y; + } + + if (side == 2) { + --z; + } + + if (side == 3) { + ++z; + } + + if (side == 4) { + --x; + } + + if (side == 5) { + ++x; + } + + Block block = world.getBlock(x, y, z); + EnumWoodType blockWoodType = null; + EnumWoodType stackWoodType = getWoodType(itemStack); + TileWood tile = TileUtil.getTile(world, x, y, z, TileWood.class); + if (tile != null) { + blockWoodType = tile.getWoodType(); + } + + if (block == this.slab && blockWoodType == stackWoodType) { + if (world.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBoxFromPool(world, x, y, z))) { + if (placeWood(itemStack, stackWoodType, doubleSlab, player, world, x, y, z, 0)) { + world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.doubleSlab.stepSound.func_150496_b(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getPitch() * 0.8F); + --itemStack.stackSize; + } + } + + return true; + } else { + return false; + } + } +} diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index 6f20a9943..19a56d175 100644 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -21,7 +21,7 @@ import forestry.core.items.ItemWithGui; public class ItemTreealyzer extends ItemWithGui { public ItemTreealyzer() { - super(Tabs.tabArboriculture); + setCreativeTab(Tabs.tabArboriculture); } @Override diff --git a/src/main/java/forestry/arboriculture/tiles/TileWood.java b/src/main/java/forestry/arboriculture/tiles/TileWood.java index 61bb37bd2..d6aacc894 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileWood.java +++ b/src/main/java/forestry/arboriculture/tiles/TileWood.java @@ -23,12 +23,14 @@ import net.minecraft.world.World; import forestry.api.arboriculture.EnumWoodType; import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.blocks.BlockSlab; import forestry.arboriculture.items.ItemBlockWood; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamable; import forestry.core.network.packets.PacketTileStream; import forestry.core.tiles.TileUtil; +import forestry.plugins.PluginArboriculture; public class TileWood extends TileEntity implements IStreamable { private EnumWoodType woodType; @@ -93,7 +95,16 @@ public class TileWood extends TileEntity implements IStreamable { } EnumWoodType woodType = wood.getWoodType(); - ItemStack itemStack = new ItemStack(block); + int amount = 1; + if (block instanceof BlockSlab) { + BlockSlab blockSlab = (BlockSlab) block; + if (blockSlab.isDoubleSlab()) { + amount = 2; + block = PluginArboriculture.blocks.slabs; + } + } + + ItemStack itemStack = new ItemStack(block, amount); ItemBlockWood.saveToItemStack(woodType, itemStack); return itemStack; } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index 2125ce16b..cfc2c624c 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -285,8 +285,11 @@ public abstract class WorldGenArboriculture extends WorldGenBase { wood.setDirection(branchDirection); } } - addWood(world, x, y, z, EnumReplaceMode.SOFT); - branchEnds.add(new ChunkCoordinates(x, y, z)); + if (addWood(world, x, y, z, EnumReplaceMode.SOFT)) { + branchEnds.add(new ChunkCoordinates(x, y, z)); + } else { + break; + } } } } @@ -295,28 +298,30 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } @Override - protected void addBlock(World world, int x, int y, int z, ITreeBlockType type, EnumReplaceMode replace) { + protected boolean addBlock(World world, int x, int y, int z, ITreeBlockType type, EnumReplaceMode replace) { if (replace == EnumReplaceMode.ALL || (replace == EnumReplaceMode.SOFT && BlockUtil.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); + return true; } + return false; } protected final void clearBlock(World world, int x, int y, int z) { air.setBlock(world, startX + x, startY + y, startZ + z); } - protected final void addWood(World world, int x, int y, int z, EnumReplaceMode replace) { - addBlock(world, x, y, z, wood, replace); + protected final boolean addWood(World world, int x, int y, int z, EnumReplaceMode replace) { + return addBlock(world, x, y, z, wood, replace); } - protected final void addLeaf(World world, int x, int y, int z, EnumReplaceMode replace) { - addBlock(world, x, y, z, leaf, replace); + protected final boolean addLeaf(World world, int x, int y, int z, EnumReplaceMode replace) { + return addBlock(world, x, y, z, leaf, replace); } - protected final void addVine(World world, int x, int y, int z, ITreeBlockType vine) { - addBlock(world, x, y, z, vine, EnumReplaceMode.NONE); + protected final boolean addVine(World world, int x, int y, int z, ITreeBlockType vine) { + return addBlock(world, x, y, z, vine, EnumReplaceMode.NONE); } protected final void addVines(World world, int x, int y, int z, float chance) { diff --git a/src/main/java/forestry/core/access/IRestrictedAccess.java b/src/main/java/forestry/core/access/IRestrictedAccess.java index 248444d0d..c30fca22d 100644 --- a/src/main/java/forestry/core/access/IRestrictedAccess.java +++ b/src/main/java/forestry/core/access/IRestrictedAccess.java @@ -12,5 +12,6 @@ package forestry.core.access; public interface IRestrictedAccess { IAccessHandler getAccessHandler(); + void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess); } diff --git a/src/main/java/forestry/core/blocks/BlockRegistry.java b/src/main/java/forestry/core/blocks/BlockRegistry.java index 14d4af07f..56d0165bd 100644 --- a/src/main/java/forestry/core/blocks/BlockRegistry.java +++ b/src/main/java/forestry/core/blocks/BlockRegistry.java @@ -22,12 +22,12 @@ import forestry.core.utils.StringUtil; import forestry.plugins.PluginManager; public abstract class BlockRegistry { - protected static T registerBlock(T block, Class itemClass, String name) { + protected static T registerBlock(T block, Class itemClass, String name, Object... itemCtorArgs) { if (PluginManager.getStage() != PluginManager.Stage.SETUP) { throw new RuntimeException("Tried to register Block outside of Setup"); } block.setBlockName("for." + name); - GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); + GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block), itemCtorArgs); return block; } diff --git a/src/main/java/forestry/core/gui/buttons/IButtonTextureSet.java b/src/main/java/forestry/core/gui/buttons/IButtonTextureSet.java index 1813ce7b3..ddb88d9a0 100755 --- a/src/main/java/forestry/core/gui/buttons/IButtonTextureSet.java +++ b/src/main/java/forestry/core/gui/buttons/IButtonTextureSet.java @@ -16,9 +16,11 @@ package forestry.core.gui.buttons; public interface IButtonTextureSet { int getX(); + int getY(); int getHeight(); + int getWidth(); } diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index d07d10d6d..e40354391 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -16,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import forestry.core.config.Constants; import forestry.core.network.DataInputStreamForestry; diff --git a/src/main/java/forestry/core/inventory/InventoryPlain.java b/src/main/java/forestry/core/inventory/InventoryPlain.java index f9605e759..17e7117fc 100644 --- a/src/main/java/forestry/core/inventory/InventoryPlain.java +++ b/src/main/java/forestry/core/inventory/InventoryPlain.java @@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import forestry.api.core.INBTTagable; import forestry.core.utils.InventoryUtil; diff --git a/src/main/java/forestry/core/items/ItemOverlay.java b/src/main/java/forestry/core/items/ItemOverlay.java index 677960b56..6fbe74050 100755 --- a/src/main/java/forestry/core/items/ItemOverlay.java +++ b/src/main/java/forestry/core/items/ItemOverlay.java @@ -28,8 +28,11 @@ import forestry.core.utils.StringUtil; public class ItemOverlay extends ItemForestry { public interface IOverlayInfo { String getName(); + int getPrimaryColor(); + int getSecondaryColor(); + boolean isSecret(); } diff --git a/src/main/java/forestry/core/items/ItemWithGui.java b/src/main/java/forestry/core/items/ItemWithGui.java index 0058120fd..2ceadba53 100644 --- a/src/main/java/forestry/core/items/ItemWithGui.java +++ b/src/main/java/forestry/core/items/ItemWithGui.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.core.items; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -22,11 +21,7 @@ import forestry.core.gui.IGuiHandlerItem; public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerItem { public ItemWithGui() { - - } - - public ItemWithGui(CreativeTabs creativeTabs) { - super(creativeTabs); + setMaxStackSize(1); } @Override diff --git a/src/main/java/forestry/core/network/IStreamableGui.java b/src/main/java/forestry/core/network/IStreamableGui.java index 471bd6da7..d71587008 100644 --- a/src/main/java/forestry/core/network/IStreamableGui.java +++ b/src/main/java/forestry/core/network/IStreamableGui.java @@ -14,5 +14,6 @@ import java.io.IOException; public interface IStreamableGui { void writeGuiData(DataOutputStreamForestry data) throws IOException; + void readGuiData(DataInputStreamForestry data) throws IOException; } diff --git a/src/main/java/forestry/core/tiles/TileEngine.java b/src/main/java/forestry/core/tiles/TileEngine.java index 8090af34b..944f707f9 100644 --- a/src/main/java/forestry/core/tiles/TileEngine.java +++ b/src/main/java/forestry/core/tiles/TileEngine.java @@ -34,8 +34,10 @@ import forestry.energy.EnergyManager; import cofh.api.energy.IEnergyConnection; public abstract class TileEngine extends TileBase implements IEnergyConnection, IActivatable { + private static final int CANT_SEND_ENERGY_TIME = 20; private boolean active = false; // Used for smp. + private int cantSendEnergyCountdown = CANT_SEND_ENERGY_TIME; /** * Indicates whether the piston is receding from or approaching the * combustion chamber @@ -147,8 +149,14 @@ public abstract class TileEngine extends TileBase implements IEnergyConnection, if (energyManager.canSendEnergy(getOrientation(), tile)) { stagePiston = 1; // If we can transfer energy, start running setActive(true); + cantSendEnergyCountdown = CANT_SEND_ENERGY_TIME; } else { - setActive(false); + if (isActive()) { + cantSendEnergyCountdown--; + if (cantSendEnergyCountdown <= 0) { + setActive(false); + } + } } } else { setActive(false); diff --git a/src/main/java/forestry/core/utils/EntityUtil.java b/src/main/java/forestry/core/utils/EntityUtil.java index 3c246c6b1..b8268a749 100644 --- a/src/main/java/forestry/core/utils/EntityUtil.java +++ b/src/main/java/forestry/core/utils/EntityUtil.java @@ -12,7 +12,6 @@ package forestry.core.utils; import java.util.List; -import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; diff --git a/src/main/java/forestry/core/utils/InventoryUtil.java b/src/main/java/forestry/core/utils/InventoryUtil.java index b3a4c09a7..101a46623 100644 --- a/src/main/java/forestry/core/utils/InventoryUtil.java +++ b/src/main/java/forestry/core/utils/InventoryUtil.java @@ -466,7 +466,7 @@ public abstract class InventoryUtil { int added = addStack(inventory, stack, startSlot, slots, false); boolean success = all ? (added == stack.stackSize) : (added > 0); - if (success && doAdd) { + if (success && doAdd) { addStack(inventory, stack, startSlot, slots, true); } diff --git a/src/main/java/forestry/core/worldgen/WorldGenBase.java b/src/main/java/forestry/core/worldgen/WorldGenBase.java index 76764e222..a83cca5c5 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenBase.java +++ b/src/main/java/forestry/core/worldgen/WorldGenBase.java @@ -66,7 +66,7 @@ public abstract class WorldGenBase extends WorldGenerator { return false; } - protected abstract void addBlock(World world, int x, int y, int z, ITreeBlockType type, EnumReplaceMode replace); + protected abstract boolean addBlock(World world, int x, int y, int z, ITreeBlockType type, EnumReplaceMode replace); protected final void generateCuboid(World world, Vector start, Vector area, ITreeBlockType block, EnumReplaceMode replace) { for (int x = (int) start.x; x < (int) start.x + area.x; x++) { diff --git a/src/main/java/forestry/energy/tiles/EngineDefinition.java b/src/main/java/forestry/energy/tiles/EngineDefinition.java index c48733871..23b74d231 100644 --- a/src/main/java/forestry/energy/tiles/EngineDefinition.java +++ b/src/main/java/forestry/energy/tiles/EngineDefinition.java @@ -12,12 +12,9 @@ package forestry.energy.tiles; import net.minecraft.world.IBlockAccess; -import forestry.core.blocks.IMachineProperties; import forestry.core.blocks.IMachinePropertiesTESR; -import forestry.core.render.IBlockRenderer; import forestry.core.tiles.MachineDefinition; import forestry.core.tiles.TileEngine; -import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileUtil; public class EngineDefinition extends MachineDefinition { diff --git a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java new file mode 100644 index 000000000..ca0d5014e --- /dev/null +++ b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java @@ -0,0 +1,28 @@ +package forestry.farming.logic; + +import forestry.core.utils.vect.Vect; +import forestry.plugins.compat.PluginIC2; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import java.util.Collection; + +public class CropBasicIC2Crop extends Crop { + private final TileEntity tileEntity; + + public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) { + super(world, position); + this.tileEntity = tileEntity; + } + + @Override + protected boolean isCrop(Vect pos) { + return PluginIC2.instance.canHarvestCrop(this.tileEntity); + } + + @Override + protected Collection harvestBlock(Vect pos) { + return PluginIC2.instance.getCropDrops(this.tileEntity); + } +} diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index b6cbe9217..d7f47c7a2 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -40,6 +40,7 @@ import forestry.core.utils.vect.VectUtil; import forestry.plugins.PluginCore; public class FarmLogicArboreal extends FarmLogicHomogeneous { + private static final int BRANCH_RANGE = 20; public FarmLogicArboreal(IFarmHousing housing, ItemStack resource, ItemStack ground, Iterable germlings) { super(housing, resource, ground, germlings); @@ -172,10 +173,10 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { if (candidate.equals(position)) { continue; } - if (Math.abs(candidate.x - start.x) > 10) { + if (Math.abs(candidate.x - start.x) > BRANCH_RANGE) { continue; } - if (Math.abs(candidate.z - start.z) > 10) { + if (Math.abs(candidate.z - start.z) > BRANCH_RANGE) { continue; } diff --git a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java new file mode 100644 index 000000000..7f867df9f --- /dev/null +++ b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java @@ -0,0 +1,52 @@ +package forestry.farming.logic; + +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.vect.Vect; +import forestry.plugins.compat.PluginIC2; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class FarmableBasicIC2Crop implements IFarmable { + @Override + public boolean isSaplingAt(World world, int x, int y, int z) { + TileEntity crop = world.getTileEntity(x, y, z); + if(PluginIC2.instance.isIC2Crop(crop)) { + PluginIC2.instance.babysitCrop(crop); + return true; + } + return false; + } + + @Override + public ICrop getCropAt(World world, int x, int y, int z) { + TileEntity crop = world.getTileEntity(x, y, z); + if (crop == null) { + return null; + } + if (!PluginIC2.instance.isIC2Crop(crop)) { + return null; + } + if (!PluginIC2.instance.canHarvestCrop(crop)) { + return null; + } + return new CropBasicIC2Crop(world, crop, new Vect(x, y, z)); + } + + @Override + public boolean isGermling(ItemStack itemstack) { + return false; + } + + @Override + public boolean isWindfall(ItemStack itemstack) { + return false; + } + + @Override + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { + return false; + } +} diff --git a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java index 9d38224e0..8245ab483 100644 --- a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java @@ -21,7 +21,7 @@ import forestry.lepidopterology.inventory.ItemInventoryFlutterlyzer; public class ItemFlutterlyzer extends ItemWithGui { public ItemFlutterlyzer() { - super(Tabs.tabLepidopterology); + setCreativeTab(Tabs.tabLepidopterology); } @Override diff --git a/src/main/java/forestry/plugins/compat/PluginHarvestCraft.java b/src/main/java/forestry/plugins/compat/PluginHarvestCraft.java index 9e238c3cf..5cf44a59a 100644 --- a/src/main/java/forestry/plugins/compat/PluginHarvestCraft.java +++ b/src/main/java/forestry/plugins/compat/PluginHarvestCraft.java @@ -303,9 +303,9 @@ public class PluginHarvestCraft extends ForestryPlugin { } plants.add(cropName); } - ItemStack mustardCropSeed = GameRegistry.findItemStack(HC,"mustard" + "seedItem",1); - Block mustardCropBlock = GameRegistry.findBlock(HC,"pam"+"mustardseeds" + "Crop"); - ItemStack mustardFruit = GameRegistry.findItemStack(HC,"mustard" + "seedsItem",1); + ItemStack mustardCropSeed = GameRegistry.findItemStack(HC, "mustard" + "seedItem", 1); + Block mustardCropBlock = GameRegistry.findBlock(HC, "pam" + "mustardseeds" + "Crop"); + ItemStack mustardFruit = GameRegistry.findItemStack(HC, "mustard" + "seedsItem", 1); if (mustardCropSeed != null) { RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{mustardCropSeed}, Fluids.SEEDOIL.getFluid(seedamount)); } diff --git a/src/main/java/forestry/plugins/compat/PluginIC2.java b/src/main/java/forestry/plugins/compat/PluginIC2.java index 2a0cc6351..a9f6f89da 100644 --- a/src/main/java/forestry/plugins/compat/PluginIC2.java +++ b/src/main/java/forestry/plugins/compat/PluginIC2.java @@ -12,11 +12,19 @@ package forestry.plugins.compat; import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumSet; +import cpw.mods.fml.common.registry.GameRegistry; +import forestry.api.farming.Farmables; +import forestry.farming.logic.FarmableBasicIC2Crop; +import ic2.api.crops.ICropTile; +import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -300,6 +308,11 @@ public class PluginIC2 extends ForestryPlugin { ChipsetManager.solderManager.addRecipe(layoutManual, PluginCore.items.tubes.get(EnumElectronTube.RUBBER, 1), Circuit.farmRubberManual); } + Block ic2Crop = GameRegistry.findBlock("IC2", "blockCrop"); + if (PluginManager.Module.FARMING.isEnabled() && ic2Crop != null) { + Farmables.farmables.get("farmOrchard").add(new FarmableBasicIC2Crop()); + } + BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; if (energyBlocks != null) { RecipeUtil.addRecipe(energyBlocks.engine.get(BlockEngineType.GENERATOR), @@ -320,4 +333,78 @@ public class PluginIC2 extends ForestryPlugin { 'V', Blocks.piston); } } + + /** + * Check if there is an instance of ICropTile. + * @param tileEntity tile entity to be checked. + * @return true if there is an IC2 crop and false otherwise. + */ + @Optional.Method(modid = "IC2") + public boolean isIC2Crop(TileEntity tileEntity) { + if (tileEntity != null && tileEntity instanceof ICropTile) { + return true; + } + return false; + } + + /** + * Check if an IC2 crop is ready to be harvested. + * @param tileEntity tile entity to be checked. + * @return true if crop size is optimal for harvest and false otherwise. + */ + @Optional.Method(modid = "IC2") + public boolean canHarvestCrop(TileEntity tileEntity) { + if (isIC2Crop(tileEntity)) { + ICropTile crop = (ICropTile)tileEntity; + if (crop.getCrop() == null) { + return false; + } + if (crop.getSize() == crop.getCrop().getOptimalHavestSize(crop)) { + return true; + } + } + return false; + } + + /** + * Perform some of the actions of the crop-matron. + * @param tileEntity + */ + @Optional.Method(modid = "IC2") + public void babysitCrop(TileEntity tileEntity) { + if (isIC2Crop(tileEntity)) { + ICropTile crop = (ICropTile)tileEntity; + /* + This part might be unbalanced until a custom farm logic is added and makes use of weed-ex. + if (crop.getCrop() != null) { + if (crop.getCrop().isWeed(crop)) { + crop.reset(); + } + }*/ + if (crop.getHydrationStorage() <= 200) { + crop.setHydrationStorage(200); + } + if (crop.getNutrientStorage() <= 100) { + crop.setNutrientStorage(crop.getNutrientStorage() + 100); + } + } + } + + /** + * This function takes care of everything related to the harvesting of the + * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). + * @param tileEntity tile entity to be checked. + * @return arraylist containing the drops. + */ + @Optional.Method(modid = "IC2") + public ArrayList getCropDrops(TileEntity tileEntity) { + if (isIC2Crop(tileEntity)) { + ICropTile crop = (ICropTile)tileEntity; + ItemStack[] cropDrops = crop.harvest_automated(true); + if (cropDrops != null) { + return new ArrayList<>(Arrays.asList(cropDrops)); + } + } + return null; + } } diff --git a/src/main/java/forestry/plugins/compat/PluginPlantMegaPack.java b/src/main/java/forestry/plugins/compat/PluginPlantMegaPack.java index 51b4cd816..ec6848656 100644 --- a/src/main/java/forestry/plugins/compat/PluginPlantMegaPack.java +++ b/src/main/java/forestry/plugins/compat/PluginPlantMegaPack.java @@ -158,7 +158,7 @@ public class PluginPlantMegaPack extends ForestryPlugin { .put("cropRice", 4) .put("cropWaterSpinach", 4) .put("cropWildRice", 4) - + .put("immersedArrowArum", 4) .put("immersedCommonReed", 4) .put("immersedDuckPotato", 4) diff --git a/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java b/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java index ddb3f135f..f5828253a 100644 --- a/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java +++ b/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java @@ -47,7 +47,7 @@ public class PluginRotaryCraft extends ForestryPlugin { ItemStack canolaSeed = GameRegistry.findItemStack(RC, "rotarycraft_item_canola", 1); Block canolaCrop = GameRegistry.findBlock(RC, "rotarycraft_block_canola"); - int seedAmount = (ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed")/16); + int seedAmount = (ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed") / 16); seedAmount = Math.max(seedAmount, 1); // Produce at least 1 mb. if (canolaSeed != null && canolaCrop != null) { RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{canolaSeed}, Fluids.SEEDOIL.getFluid(seedAmount));