diff --git a/api/forestry b/api/forestry index 9189ad7be..bc09d990a 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 9189ad7be65a709f4407c0d15ea4372ec220880f +Subproject commit bc09d990a7f87586ba1720fca735ecfed7469039 diff --git a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java index 9508de3ce..762056fe9 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java @@ -36,12 +36,11 @@ import forestry.api.apiculture.IBeeIconProvider; import forestry.api.apiculture.IBeeRoot; import forestry.api.apiculture.IJubilanceProvider; import forestry.api.core.IIconProvider; -import forestry.api.genetics.IAllele; import forestry.api.genetics.IClassification; import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IMutation; import forestry.core.genetics.alleles.AlleleSpecies; import forestry.core.render.TextureManager; +import forestry.core.utils.GeneticsUtil; import forestry.core.utils.StackUtils; public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpeciesCustom { @@ -51,8 +50,8 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies private final int primaryColour; private final int secondaryColour; - private IBeeIconProvider beeIconProvider; - private IJubilanceProvider jubilanceProvider; + private IBeeIconProvider beeIconProvider = DefaultBeeIconProvider.instance; + private IJubilanceProvider jubilanceProvider = JubilanceDefault.instance; private boolean nocturnal = false; public AlleleBeeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) { @@ -60,9 +59,6 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies this.primaryColour = primaryColor; this.secondaryColour = secondaryColor; - - setCustomBeeIconProvider(DefaultBeeIconProvider.getInstance()); - setJubilanceProvider(JubilanceDefault.getInstance()); } @Override @@ -115,31 +111,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies /* RESEARCH */ @Override public int getComplexity() { - return 1 + getGeneticAdvancement(this, new ArrayList()); - } - - private int getGeneticAdvancement(IAllele species, ArrayList exclude) { - - int own = 1; - int highest = 0; - exclude.add(species); - - for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { - if (!exclude.contains(mutation.getAllele0())) { - int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude); - if (otherAdvance > highest) { - highest = otherAdvance; - } - } - if (!exclude.contains(mutation.getAllele1())) { - int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude); - if (otherAdvance > highest) { - highest = otherAdvance; - } - } - } - - return own + (highest < 0 ? 0 : highest); + return GeneticsUtil.getResearchComplexity(this, EnumBeeChromosome.SPECIES); } @Override @@ -228,15 +200,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies private static class DefaultBeeIconProvider implements IBeeIconProvider { - private static final String iconType = "default"; - private static DefaultBeeIconProvider instance; - - public static DefaultBeeIconProvider getInstance() { - if (instance == null) { - instance = new DefaultBeeIconProvider(); - } - return instance; - } + public static final DefaultBeeIconProvider instance = new DefaultBeeIconProvider(); private DefaultBeeIconProvider() { @@ -244,20 +208,28 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3]; - @SideOnly(Side.CLIENT) @Override + @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { - IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1"); + String beeIconDir = "bees/default/"; + TextureManager textureManager = TextureManager.getInstance(); + IIcon body1 = textureManager.registerTex(register, beeIconDir + "body1"); for (int i = 0; i < EnumBeeType.values().length; i++) { - if (EnumBeeType.values()[i] == EnumBeeType.NONE) { + EnumBeeType beeType = EnumBeeType.values()[i]; + if (beeType == EnumBeeType.NONE) { continue; } - icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline"); - icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1 - : TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body"); - icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2"); + String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH); + + icons[i][0] = textureManager.registerTex(register, beeTypeNameBase + ".outline"); + if (beeType == EnumBeeType.LARVAE) { + icons[i][1] = textureManager.registerTex(register, beeTypeNameBase + ".body"); + } else { + icons[i][1] = body1; + } + icons[i][2] = textureManager.registerTex(register, beeTypeNameBase + ".body2"); } } diff --git a/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java b/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java index c75630d87..d10e033c3 100644 --- a/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java +++ b/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java @@ -6,10 +6,11 @@ import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.genetics.IAllele; import forestry.api.genetics.IClassification; +import forestry.core.genetics.IBranchDefinition; import forestry.core.genetics.alleles.Allele; import forestry.core.genetics.alleles.EnumAllele; -public enum BeeBranchDefinition { +public enum BeeBranchDefinition implements IBranchDefinition { HONEY("Apis"), NOBLE("Probapis"), INDUSTRIOUS("Industrapis"), @@ -120,12 +121,14 @@ public enum BeeBranchDefinition { } + @Override public final IAllele[] getTemplate() { IAllele[] template = getDefaultTemplate(); setBranchProperties(template); return template; } + @Override public final IClassification getBranch() { return branch; } diff --git a/src/main/java/forestry/apiculture/genetics/BeeDefinition.java b/src/main/java/forestry/apiculture/genetics/BeeDefinition.java index 65e2c8e44..503a16cc1 100644 --- a/src/main/java/forestry/apiculture/genetics/BeeDefinition.java +++ b/src/main/java/forestry/apiculture/genetics/BeeDefinition.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * 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.apiculture.genetics; import java.awt.Color; diff --git a/src/main/java/forestry/apiculture/genetics/IBeeDefinition.java b/src/main/java/forestry/apiculture/genetics/IBeeDefinition.java index 858591732..71c30aa1c 100644 --- a/src/main/java/forestry/apiculture/genetics/IBeeDefinition.java +++ b/src/main/java/forestry/apiculture/genetics/IBeeDefinition.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * 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.apiculture.genetics; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java index fced9cdaa..9f91162f0 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java @@ -19,14 +19,7 @@ import forestry.api.core.EnumTemperature; public class JubilanceDefault implements IJubilanceProvider { - private static JubilanceDefault instance; - - public static JubilanceDefault getInstance() { - if (instance == null) { - instance = new JubilanceDefault(); - } - return instance; - } + public static final JubilanceDefault instance = new JubilanceDefault(); protected JubilanceDefault() { diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceFactory.java b/src/main/java/forestry/apiculture/genetics/JubilanceFactory.java index a795548f3..f65c15cf6 100644 --- a/src/main/java/forestry/apiculture/genetics/JubilanceFactory.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceFactory.java @@ -18,7 +18,7 @@ import forestry.api.apiculture.IJubilanceProvider; public class JubilanceFactory implements IJubilanceFactory { @Override public IJubilanceProvider getDefault() { - return JubilanceDefault.getInstance(); + return JubilanceDefault.instance; } @Override diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index a0c98ea22..ef8f14379 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -25,6 +25,7 @@ import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.util.ForgeDirection; import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; @@ -37,26 +38,32 @@ import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IFlower; import forestry.apiculture.gadgets.TileApiary; -import forestry.arboriculture.gadgets.BlockFireproofLog; -import forestry.arboriculture.gadgets.BlockFireproofPlanks; -import forestry.arboriculture.gadgets.BlockLog; -import forestry.arboriculture.gadgets.BlockPlanks; +import forestry.arboriculture.WoodType; +import forestry.arboriculture.worldgen.BlockTypeLog; +import forestry.arboriculture.worldgen.BlockTypeVanillaStairs; +import forestry.arboriculture.worldgen.BlockTypeWood; +import forestry.arboriculture.worldgen.BlockTypeWoodStairs; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; -import forestry.core.utils.StackUtils; +import forestry.core.worldgen.BlockType; +import forestry.core.worldgen.BlockTypeTileForestry; +import forestry.core.worldgen.IBlockType; import forestry.plugins.PluginManager; public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { private static final Random random = new Random(); - protected final ItemStack[] buildingBlocks; + protected int averageGroundLevel = -1; protected boolean isInDesert = false; - protected boolean hasChest = false; + protected IBlockType planks; + protected IBlockType logs; + protected IBlockType stairs; + protected IBlockType fence; public ComponentVillageBeeHouse() { - buildingBlocks = createBuildingBlocks(random); + createBuildingBlocks(random); } public ComponentVillageBeeHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, int coordBaseMode) { @@ -64,84 +71,62 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { isInDesert = startPiece.inDesert; - buildingBlocks = createBuildingBlocks(random); + createBuildingBlocks(random); } - private static ItemStack[] createBuildingBlocks(Random random) { - int plankMeta = random.nextInt(16); - int blockMeta = random.nextInt(4); - Block plankBlock = Blocks.planks; - Block woodBlock = Blocks.log; - + private void createBuildingBlocks(Random random) { if (PluginManager.Module.ARBORICULTURE.isEnabled()) { - switch (random.nextInt(4)) { - case 1: - woodBlock = ForestryBlock.log2.block(); - break; - case 2: - woodBlock = ForestryBlock.log3.block(); - break; - case 3: - woodBlock = ForestryBlock.log4.block(); - break; - default: - woodBlock = ForestryBlock.log1.block(); - break; - } - plankBlock = ForestryBlock.planks1.block(); + boolean fireproof = (random.nextInt(4) == 0); - // chance for the house to have fireproof components - if (random.nextInt(4) == 0) { - woodBlock = BlockFireproofLog.getFireproofLog((BlockLog) woodBlock).block(); - plankBlock = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks) plankBlock).block(); - } + WoodType roofWood = WoodType.getRandom(random); + + logs = new BlockTypeLog(WoodType.getRandom(random).getLog(fireproof)); + planks = new BlockTypeWood(roofWood.getPlanks(fireproof)); + stairs = new BlockTypeWoodStairs(roofWood.getStairs(fireproof)); + fence = new BlockTypeWood(WoodType.getRandom(random).getFence(fireproof)); + } else { + int roofMeta = random.nextInt(16); + + logs = new BlockType(Blocks.log, random.nextInt(4)); + planks = new BlockType(Blocks.planks, roofMeta); + stairs = new BlockTypeVanillaStairs(Blocks.oak_stairs, roofMeta); + fence = new BlockType(Blocks.fence, 0); + } + } + + @SuppressWarnings("rawtypes") + public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List par1List, Random random, int par3, int par4, int par5, int par6, int par7) { + StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 10, 9, 11, par6); + if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(par1List, bbox) != null) { + return null; } - return new ItemStack[]{new ItemStack(plankBlock, 1, plankMeta), new ItemStack(woodBlock, 1, blockMeta)}; - } - - /*@Override - protected void func_143012_a(NBTTagCompound par1nbtTagCompound) { - super.func_143012_a(par1nbtTagCompound); - par1nbtTagCompound.setBoolean("Chest", this.hasChest); - } - - @Override - protected void func_143011_b(NBTTagCompound par1nbtTagCompound) { - super.func_143011_b(par1nbtTagCompound); - this.hasChest = par1nbtTagCompound.getBoolean("Chest"); - }*/ - @SuppressWarnings("rawtypes") - public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List par1List, Random random, int par3, int par4, int par5, - int par6, int par7) { - StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 9, 9, 10, par6); - return canVillageGoDeeper(bbox) && StructureComponent.findIntersecting(par1List, bbox) == null ? new ComponentVillageBeeHouse(startPiece, par7, random, - bbox, par6) : null; + return new ComponentVillageBeeHouse(startPiece, par7, random, bbox, par6); } @Override public boolean addComponentParts(World world, Random random, StructureBoundingBox structBoundingBox) { - if (this.averageGroundLevel < 0) { - this.averageGroundLevel = this.getAverageGroundLevel(world, structBoundingBox); - if (this.averageGroundLevel < 0) { + if (averageGroundLevel < 0) { + averageGroundLevel = getAverageGroundLevel(world, structBoundingBox); + if (averageGroundLevel < 0) { return true; } - this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 8 - 1, 0); + boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 8 - 1, 0); } - this.fillWithBlocks(world, structBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.air, Blocks.air, false); - this.fillWithBlocks(world, structBoundingBox, 2, 1, 6, 8, 4, 10, Blocks.air, Blocks.air, false); + fillWithBlocks(world, structBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.air, Blocks.air, false); + fillWithBlocks(world, structBoundingBox, 2, 1, 6, 8, 4, 10, Blocks.air, Blocks.air, false); // Garden buildGarden(world, structBoundingBox); // Garden fence - this.fillWithBlocks(world, structBoundingBox, 1, 1, 6, 1, 1, 10, Blocks.fence, Blocks.fence, false); - this.fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, Blocks.fence, Blocks.fence, false); - this.fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, Blocks.fence, Blocks.fence, false); + fillBoxWith(world, structBoundingBox, 1, 1, 6, 1, 1, 10, fence, false); + fillBoxWith(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, false); + fillBoxWith(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, false); // Flowers plantFlowerGarden(world, structBoundingBox, 2, 1, 5, 7, 1, 9); @@ -150,81 +135,79 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { buildApiaries(world, structBoundingBox, 3, 1, 4, 6, 1, 8); // Floor - this.fillWithBlocks(world, structBoundingBox, 1, 0, 1, 7, 0, 4, Blocks.planks, Blocks.planks, false); + fillWithBlocks(world, structBoundingBox, 1, 0, 1, 7, 0, 4, Blocks.planks, Blocks.planks, false); - this.fillWithBlocks(world, structBoundingBox, 0, 0, 0, 0, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); - this.fillWithBlocks(world, structBoundingBox, 8, 0, 0, 8, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); - this.fillWithBlocks(world, structBoundingBox, 1, 0, 0, 7, 1, 0, Blocks.cobblestone, Blocks.cobblestone, false); - this.fillWithBlocks(world, structBoundingBox, 1, 0, 5, 7, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, structBoundingBox, 0, 0, 0, 0, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, structBoundingBox, 8, 0, 0, 8, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, structBoundingBox, 1, 0, 0, 7, 1, 0, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, structBoundingBox, 1, 0, 5, 7, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false); - this.fillBoxWith(world, structBoundingBox, 1, 2, 0, 7, 3, 0, buildingBlocks[0], false); - this.fillBoxWith(world, structBoundingBox, 1, 2, 5, 7, 3, 5, buildingBlocks[0], false); - this.fillBoxWith(world, structBoundingBox, 0, 4, 1, 8, 4, 1, buildingBlocks[0], false); - this.fillBoxWith(world, structBoundingBox, 0, 4, 4, 8, 4, 4, buildingBlocks[0], false); - this.fillBoxWith(world, structBoundingBox, 0, 5, 2, 8, 5, 3, buildingBlocks[0], false); + fillBoxWith(world, structBoundingBox, 1, 2, 0, 7, 3, 0, planks, false); + fillBoxWith(world, structBoundingBox, 1, 2, 5, 7, 3, 5, planks, false); + fillBoxWith(world, structBoundingBox, 0, 4, 1, 8, 4, 1, planks, false); + fillBoxWith(world, structBoundingBox, 0, 4, 4, 8, 4, 4, planks, false); + fillBoxWith(world, structBoundingBox, 0, 5, 2, 8, 5, 3, planks, false); - this.placeBlockAtCurrentPosition(world, buildingBlocks[0], 0, 4, 2, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[0], 0, 4, 3, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[0], 8, 4, 2, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[0], 8, 4, 3, structBoundingBox); + placeBlockAtCurrentPosition(world, planks, 0, 4, 2, structBoundingBox); + placeBlockAtCurrentPosition(world, planks, 0, 4, 3, structBoundingBox); + placeBlockAtCurrentPosition(world, planks, 8, 4, 2, structBoundingBox); + placeBlockAtCurrentPosition(world, planks, 8, 4, 3, structBoundingBox); buildRoof(world, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[1], 0, 2, 1, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[1], 0, 2, 4, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[1], 8, 2, 1, structBoundingBox); - this.placeBlockAtCurrentPosition(world, buildingBlocks[1], 8, 2, 4, structBoundingBox); + placeBlockAtCurrentPosition(world, logs, 0, 2, 1, structBoundingBox); + placeBlockAtCurrentPosition(world, logs, 0, 2, 4, structBoundingBox); + placeBlockAtCurrentPosition(world, logs, 8, 2, 1, structBoundingBox); + placeBlockAtCurrentPosition(world, logs, 8, 2, 4, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 0, 2, 2, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 0, 2, 3, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 0, 2, 2, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 0, 2, 3, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 3, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 3, structBoundingBox); // Windows garden side - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 5, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 5, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 5, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 5, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 5, 2, 0, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 6, 2, 5, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 5, 2, 0, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 6, 2, 5, structBoundingBox); - // Table/Bench - if (random.nextInt(10) < 1) { - this.placeBlockAtCurrentPosition(world, ForestryBlock.core.getItemStack(1, Defaults.DEFINITION_ESCRITOIRE_META), 1, 1, 3, structBoundingBox); - } else { - this.placeBlockAtCurrentPosition(world, buildingBlocks[0], 1, 1, 3, structBoundingBox); + // Escritoire + if (random.nextInt(2) == 0) { + IBlockType escritoireBlock = new BlockTypeTileForestry(ForestryBlock.core, Defaults.DEFINITION_ESCRITOIRE_META); + escritoireBlock.setDirection(getRotatedDirection(ForgeDirection.EAST)); + placeBlockAtCurrentPosition(world, escritoireBlock, 1, 1, 3, structBoundingBox); } - this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 1, 0, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 2, 0, structBoundingBox); - this.placeDoorAtCurrentPosition(world, structBoundingBox, random, 2, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 1, 0, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.air, 0, 2, 2, 0, structBoundingBox); + placeDoorAtCurrentPosition(world, structBoundingBox, random, 2, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1)); - if (isAirBlockAtCurrentPosition(world, 2, 0, -1, structBoundingBox) - && !isAirBlockAtCurrentPosition(world, 2, -1, -1, structBoundingBox)) { - this.placeBlockAtCurrentPosition(world, Blocks.stone_stairs, - this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, structBoundingBox); + if (isAirBlockAtCurrentPosition(world, 2, 0, -1, structBoundingBox) && !isAirBlockAtCurrentPosition(world, 2, -1, -1, structBoundingBox)) { + placeBlockAtCurrentPosition(world, Blocks.stone_stairs, getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, structBoundingBox); } - this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 1, 5, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 2, 5, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 1, 5, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.air, 0, 6, 2, 5, structBoundingBox); // Candles / Lighting - this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 2, 3, 4, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 4, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 2, 3, 1, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 2, 3, 4, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 4, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 2, 3, 1, structBoundingBox); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, structBoundingBox); - this.placeDoorAtCurrentPosition(world, structBoundingBox, random, 6, 1, 5, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + placeDoorAtCurrentPosition(world, structBoundingBox, random, 6, 1, 5, getMetadataWithOffset(Blocks.wooden_door, 1)); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 9; ++j) { - this.clearCurrentPositionBlocksUpwards(world, j, 7, i, structBoundingBox); - this.func_151554_b(world, Blocks.cobblestone, 0, j, -1, i, structBoundingBox); + clearCurrentPositionBlocksUpwards(world, j, 7, i, structBoundingBox); + func_151554_b(world, Blocks.cobblestone, 0, j, -1, i, structBoundingBox); } } - this.generateStructureChestContents(world, structBoundingBox, random, 7, 1, 4, + generateStructureChestContents(world, structBoundingBox, random, 7, 1, 4, ChestGenHooks.getItems(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, random), random.nextInt(4) + random.nextInt(4) + 5); @@ -234,13 +217,13 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { } private void buildRoof(World world, StructureBoundingBox structBoundingBox) { - int rotatedMetaDoor = this.getMetadataWithOffset(Blocks.oak_stairs, 3); - int rotatedMetaGarden = this.getMetadataWithOffset(Blocks.oak_stairs, 2); - for (int i = -1; i <= 2; ++i) { for (int j = 0; j <= 8; ++j) { - this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, rotatedMetaDoor, j, 4 + i, i, structBoundingBox); - this.placeBlockAtCurrentPosition(world, Blocks.oak_stairs, rotatedMetaGarden, j, 4 + i, 5 - i, structBoundingBox); + stairs.setDirection(getRotatedDirection(ForgeDirection.NORTH)); + placeBlockAtCurrentPosition(world, stairs, j, 4 + i, i, structBoundingBox); + + stairs.setDirection(getRotatedDirection(ForgeDirection.SOUTH)); + placeBlockAtCurrentPosition(world, stairs, j, 4 + i, 5 - i, structBoundingBox); } } } @@ -270,16 +253,16 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { for (int j = minX; j <= maxX; ++j) { for (int k = minZ; k <= maxZ; ++k) { if (world.rand.nextBoolean()) { - int xCoord = this.getXWithOffset(j, k); - int yCoord = this.getYWithOffset(i); - int zCoord = this.getZWithOffset(j, k); + int xCoord = getXWithOffset(j, k); + int yCoord = getYWithOffset(i); + int zCoord = getZWithOffset(j, k); if (!Blocks.red_flower.canBlockStay(world, xCoord, yCoord, zCoord)) { continue; } IFlower flower = FlowerManager.flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand); - this.placeBlockAtCurrentPosition(world, flower.getBlock(), flower.getMeta(), j, i, k, box); + placeBlockAtCurrentPosition(world, flower.getBlock(), flower.getMeta(), j, i, k, box); } } } @@ -292,9 +275,9 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { } private void populateApiary(World world, StructureBoundingBox box, int x, int y, int z) { - int xCoord = this.getXWithOffset(x, z); - int yCoord = this.getYWithOffset(y); - int zCoord = this.getZWithOffset(x, z); + int xCoord = getXWithOffset(x, z); + int yCoord = getYWithOffset(y); + int zCoord = getZWithOffset(x, z); if (!box.isVecInside(xCoord, yCoord, zCoord) || ForestryBlock.apiculture.isBlockEqual(world, xCoord, yCoord, zCoord) || !world.blockExists(xCoord, yCoord - 1, zCoord)) { @@ -379,31 +362,26 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { species.getHumidity(), genome.getToleranceHumid()); } - protected void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, ItemStack buildingBlock, - boolean replace) { + protected void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, IBlockType block, boolean replace) { for (int var14 = par4; var14 <= par7; ++var14) { for (int var15 = par3; var15 <= par6; ++var15) { for (int var16 = par5; var16 <= par8; ++var16) { if (!replace || !isAirBlockAtCurrentPosition(world, var15, var14, var16, box)) { - this.placeBlockAtCurrentPosition(world, buildingBlock, var15, var14, var16, box); + placeBlockAtCurrentPosition(world, block, var15, var14, var16, box); } } } } } - protected void placeBlockAtCurrentPosition(World world, ItemStack itemStack, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { - placeBlockAtCurrentPosition(world, StackUtils.getBlock(itemStack), itemStack.getItemDamage(), par4, par5, par6, par7StructureBoundingBox); - } + protected void placeBlockAtCurrentPosition(World world, IBlockType block, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { + int x = getXWithOffset(par4, par6); + int y = getYWithOffset(par5); + int z = getZWithOffset(par4, par6); - protected void placeBlockAtCurrentPosition(World world, Block block, int blockMeta, int par4, int par5, int par6, StructureBoundingBox par7StructureBoundingBox) { - int var8 = this.getXWithOffset(par4, par6); - int var9 = this.getYWithOffset(par5); - int var10 = this.getZWithOffset(par4, par6); - - if (par7StructureBoundingBox.isVecInside(var8, var9, var10)) { - world.setBlock(var8, var9, var10, block, blockMeta, Defaults.FLAG_BLOCK_SYNCH); + if (par7StructureBoundingBox.isVecInside(x, y, z)) { + block.setBlock(world, x, y, z); } } @@ -420,4 +398,11 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { return getBlockAtCurrentPosition(world, x, y, z, box).isAir(world, x, y, z); } + /** rotates a direction according to the way the structure is facing **/ + private ForgeDirection getRotatedDirection(ForgeDirection direction) { + int stairDirection = 5 - direction.ordinal(); + int meta = getMetadataWithOffset(Blocks.oak_stairs, stairDirection); + return ForgeDirection.getOrientation(5 - meta); + } + } diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index 8918788f5..3e7e272ce 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -24,10 +24,10 @@ import cpw.mods.fml.relauncher.SideOnly; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IFruitFamily; import forestry.core.render.TextureManager; import forestry.core.utils.BlockUtil; -import forestry.plugins.PluginArboriculture; public class FruitProviderPod extends FruitProviderNone { @@ -85,7 +85,7 @@ public class FruitProviderPod extends FruitProviderNone { if (type == EnumPodType.COCOA) { return BlockUtil.tryPlantPot(world, x, y, z, Blocks.cocoa); } else { - return PluginArboriculture.treeInterface.setFruitBlock(world, (IAlleleFruit) genome.getActiveAllele(EnumTreeChromosome.FRUITS), + return TreeManager.treeRoot.setFruitBlock(world, (IAlleleFruit) genome.getActiveAllele(EnumTreeChromosome.FRUITS), genome.getSappiness(), type.uids, x, y, z); } } diff --git a/src/main/java/forestry/arboriculture/FruitProviderRandom.java b/src/main/java/forestry/arboriculture/FruitProviderRandom.java index e1479cd24..998f616a1 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderRandom.java +++ b/src/main/java/forestry/arboriculture/FruitProviderRandom.java @@ -20,8 +20,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IFruitFamily; -import forestry.plugins.PluginArboriculture; /** * Simple fruit provider which drops from any leaf block according to yield and either marks all leave blocks as fruit leaves or none. @@ -50,7 +50,7 @@ public class FruitProviderRandom extends FruitProviderNone { public ItemStack[] getFruits(ITreeGenome genome, World world, int x, int y, int z, int ripeningTime) { ArrayList product = new ArrayList(); - float modeYieldMod = PluginArboriculture.treeInterface.getTreekeepingMode(world).getYieldModifier(genome, 1f); + float modeYieldMod = TreeManager.treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1f); for (Map.Entry entry : products.entrySet()) { if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry.getValue()) { diff --git a/src/main/java/forestry/arboriculture/FruitProviderRipening.java b/src/main/java/forestry/arboriculture/FruitProviderRipening.java index b3e894361..b8ac992fb 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderRipening.java +++ b/src/main/java/forestry/arboriculture/FruitProviderRipening.java @@ -20,8 +20,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IFruitFamily; -import forestry.plugins.PluginArboriculture; public class FruitProviderRipening extends FruitProviderNone { @@ -70,7 +70,7 @@ public class FruitProviderRipening extends FruitProviderNone { return new ItemStack[0]; } - float modeYieldMod = PluginArboriculture.treeInterface.getTreekeepingMode(world).getYieldModifier(genome, 1f); + float modeYieldMod = TreeManager.treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1f); for (Map.Entry entry : products.entrySet()) { if (world.rand.nextFloat() <= genome.getYield() * entry.getValue() * modeYieldMod * 5.0f * stage) { diff --git a/src/main/java/forestry/arboriculture/IWoodTyped.java b/src/main/java/forestry/arboriculture/IWoodTyped.java index e78eec2dd..70b509857 100755 --- a/src/main/java/forestry/arboriculture/IWoodTyped.java +++ b/src/main/java/forestry/arboriculture/IWoodTyped.java @@ -11,7 +11,7 @@ package forestry.arboriculture; public interface IWoodTyped { - WoodType getWoodType(int meta); - String getBlockKind(); + + boolean isFireproof(); } diff --git a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java index 6f3a93e66..d5d2381f3 100755 --- a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java @@ -12,7 +12,6 @@ package forestry.arboriculture; import java.util.Random; -import net.minecraft.block.Block; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -22,34 +21,30 @@ import net.minecraft.village.MerchantRecipeList; import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; import forestry.api.arboriculture.EnumGermlingType; -import forestry.core.config.ForestryBlock; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.TreeManager; +import forestry.api.genetics.IAllele; import forestry.core.config.ForestryItem; -import forestry.plugins.PluginArboriculture; public class VillageHandlerArboriculture implements IVillageTradeHandler { @SuppressWarnings("unchecked") @Override public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) { - recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 8), PluginArboriculture.treeInterface.getMemberStack( - PluginArboriculture.treeInterface.getTree(villager.worldObj, - PluginArboriculture.treeInterface.templateAsGenome(PluginArboriculture.treeInterface.getRandomTemplate(random))), - EnumGermlingType.SAPLING.ordinal()))); + IAllele[] randomTemplate = TreeManager.treeRoot.getRandomTemplate(random); + ITreeGenome randomGenome = TreeManager.treeRoot.templateAsGenome(randomTemplate); + ITree randomTree = TreeManager.treeRoot.getTree(villager.worldObj, randomGenome); + ItemStack randomTreeStack = TreeManager.treeRoot.getMemberStack(randomTree, EnumGermlingType.SAPLING.ordinal()); + recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 8), randomTreeStack)); recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 2), ForestryItem.grafterProven.getItemStack())); - WoodType sells = WoodType.VALUES[random.nextInt(WoodType.VALUES.length)]; - Block plankBlock; - int meta; - if (sells.ordinal() > 15) { - plankBlock = ForestryBlock.planks2.block(); - meta = sells.ordinal() - 16; - } else { - plankBlock = ForestryBlock.planks1.block(); - meta = sells.ordinal(); - } + WoodType randomWoodType = WoodType.VALUES[random.nextInt(WoodType.VALUES.length)]; + ItemStack planks = randomWoodType.getPlanks(false); + planks.stackSize = 32; - recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), new ItemStack(plankBlock, 32, meta))); + recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), planks)); } } diff --git a/src/main/java/forestry/arboriculture/WoodType.java b/src/main/java/forestry/arboriculture/WoodType.java index 43a927a5c..dcf8265c8 100755 --- a/src/main/java/forestry/arboriculture/WoodType.java +++ b/src/main/java/forestry/arboriculture/WoodType.java @@ -11,8 +11,11 @@ package forestry.arboriculture; import java.util.Locale; +import java.util.Random; +import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; @@ -28,14 +31,28 @@ public enum WoodType { WILLOW, WALNUT, GREENHEART(7.5f), CHERRY, MAHOE, POPLAR, PALM, PAPAYA, PINE(3.0f), PLUM, MAPLE, CITRUS, - GIGANTEUM(2.0f), IPE, PADAUK, COCOBOLO, + GIGANTEUM, IPE, PADAUK, COCOBOLO, ZEBRAWOOD; + public static final float DEFAULT_HARDNESS = 2.0f; + public static final WoodType[] VALUES = values(); + private final float hardness; + private ItemStack log; + private ItemStack logFireproof; + private ItemStack planks; + private ItemStack planksFireproof; + private ItemStack slab; + private ItemStack slabFireproof; + private ItemStack fence; + private ItemStack fenceFireproof; + private ItemStack stairs; + private ItemStack stairsFireproof; + WoodType() { - this(2.0f); + this(DEFAULT_HARDNESS); } WoodType(float hardness) { @@ -43,11 +60,10 @@ public enum WoodType { } @SideOnly(Side.CLIENT) - private static IIcon[][] icons; + private static final IIcon[][] icons = new IIcon[3][VALUES.length]; @SideOnly(Side.CLIENT) public static void registerIcons(IIconRegister register) { - icons = new IIcon[3][VALUES.length]; for (int i = 0; i < VALUES.length; i++) { WoodType woodType = VALUES[i]; String woodName = woodType.toString().toLowerCase(Locale.ENGLISH); @@ -73,6 +89,32 @@ public enum WoodType { return icons[2][ordinal()]; } + @SideOnly(Side.CLIENT) + public IIcon getIcon(int meta, int side) { + int oriented = meta & 12; + switch (oriented) { + case 4: + if (side > 3) { + return getHeartIcon(); + } else { + return getBarkIcon(); + } + case 8: + if (side == 2 || side == 3) { + return getHeartIcon(); + } else { + return getBarkIcon(); + } + case 0: + default: + if (side < 2) { + return getHeartIcon(); + } else { + return getBarkIcon(); + } + } + } + public float getHardness() { return hardness; } @@ -98,4 +140,101 @@ public enum WoodType { return super.toString().toLowerCase(Locale.ENGLISH); } + private ItemStack getStack(Block block) { + NBTTagCompound woodNBT = new NBTTagCompound(); + saveToCompound(woodNBT); + + ItemStack itemStack = new ItemStack(block); + itemStack.setTagCompound(woodNBT); + return itemStack; + } + + public void registerLog(Block block, boolean fireproof) { + ItemStack itemStack = getStack(block); + if (fireproof) { + this.logFireproof = itemStack; + } else { + this.log = itemStack; + } + } + + public void registerPlanks(Block block, boolean fireproof) { + ItemStack itemStack = getStack(block); + if (fireproof) { + this.planksFireproof = itemStack; + } else { + this.planks = itemStack; + } + } + + public void registerSlab(Block block, boolean fireproof) { + ItemStack itemStack = getStack(block); + if (fireproof) { + this.slabFireproof = itemStack; + } else { + this.slab = itemStack; + } + } + + public void registerFence(Block block, boolean fireproof) { + ItemStack itemStack = getStack(block); + if (fireproof) { + this.fenceFireproof = itemStack; + } else { + this.fence = itemStack; + } + } + + public void registerStairs(Block block, boolean fireproof) { + ItemStack itemStack = getStack(block); + if (fireproof) { + this.stairsFireproof = itemStack; + } else { + this.stairs = itemStack; + } + } + + public ItemStack getPlanks(boolean fireproof) { + if (fireproof) { + return planksFireproof.copy(); + } else { + return planks.copy(); + } + } + + public ItemStack getLog(boolean fireproof) { + if (fireproof) { + return logFireproof.copy(); + } else { + return log.copy(); + } + } + + public ItemStack getSlab(boolean fireproof) { + if (fireproof) { + return slabFireproof.copy(); + } else { + return slab.copy(); + } + } + + public ItemStack getFence(boolean fireproof) { + if (fireproof) { + return fenceFireproof.copy(); + } else { + return fence.copy(); + } + } + + public ItemStack getStairs(boolean fireproof) { + if (fireproof) { + return stairsFireproof.copy(); + } else { + return stairs.copy(); + } + } + + public static WoodType getRandom(Random random) { + return VALUES[random.nextInt(VALUES.length)]; + } } diff --git a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java index a989d80db..9565a7f2b 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java @@ -16,12 +16,12 @@ import net.minecraft.world.gen.feature.WorldGenerator; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.TemplateNotFoundException; import forestry.core.worldgen.WorldGenBase; -import forestry.plugins.PluginArboriculture; public final class TreeGenHelper { @@ -31,7 +31,7 @@ public final class TreeGenHelper { return null; } - ITree tree = PluginArboriculture.treeInterface.getTree(player.worldObj, treeGenome); + ITree tree = TreeManager.treeRoot.getTree(player.worldObj, treeGenome); return tree.getTreeGenerator(player.worldObj, x, y, z, true); } @@ -72,12 +72,12 @@ public final class TreeGenHelper { throw new SpeciesNotFoundException(speciesName); } - IAllele[] template = PluginArboriculture.treeInterface.getTemplate(species.getUID()); + IAllele[] template = TreeManager.treeRoot.getTemplate(species.getUID()); if (template == null) { throw new TemplateNotFoundException(species); } - return PluginArboriculture.treeInterface.templateAsGenome(template); + return TreeManager.treeRoot.templateAsGenome(template); } } diff --git a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java index a96f41781..a2044b5f3 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java @@ -16,14 +16,14 @@ import java.util.List; import net.minecraft.world.World; import forestry.api.arboriculture.ITreekeepingMode; +import forestry.api.arboriculture.TreeManager; import forestry.core.commands.ICommandModeHelper; -import forestry.plugins.PluginArboriculture; public class TreeModeHelper implements ICommandModeHelper { @Override public String[] getModeNames() { - ArrayList treekeepingModes = PluginArboriculture.treeInterface.getTreekeepingModes(); + ArrayList treekeepingModes = TreeManager.treeRoot.getTreekeepingModes(); int modeStringCount = treekeepingModes.size(); List modeStrings = new ArrayList(modeStringCount); for (ITreekeepingMode mode : treekeepingModes) { @@ -35,7 +35,7 @@ public class TreeModeHelper implements ICommandModeHelper { @Override public String getModeNameMatching(String desired) { - ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(desired); + ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(desired); if (mode == null) { return null; } @@ -44,17 +44,17 @@ public class TreeModeHelper implements ICommandModeHelper { @Override public String getModeName(World world) { - return PluginArboriculture.treeInterface.getTreekeepingMode(world).getName(); + return TreeManager.treeRoot.getTreekeepingMode(world).getName(); } @Override public void setMode(World world, String modeName) { - PluginArboriculture.treeInterface.setTreekeepingMode(world, modeName); + TreeManager.treeRoot.setTreekeepingMode(world, modeName); } @Override public Iterable getDescription(String modeName) { - ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(modeName); + ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(modeName); return mode.getDescription(); } diff --git a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java index 4a1fa6d9c..fb3718495 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java @@ -18,12 +18,12 @@ import net.minecraft.world.World; import com.mojang.authlib.GameProfile; import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IBreedingTracker; import forestry.core.commands.IStatsSaveHelper; -import forestry.plugins.PluginArboriculture; public class TreeStatsSaveHelper implements IStatsSaveHelper { @@ -54,7 +54,7 @@ public class TreeStatsSaveHelper implements IStatsSaveHelper { @Override public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) { - return PluginArboriculture.treeInterface.getBreedingTracker(world, gameProfile); + return TreeManager.treeRoot.getBreedingTracker(world, gameProfile); } } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index a66b41b83..9b293fe48 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -10,17 +10,23 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFenceGate; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; 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.IBlockAccess; import net.minecraft.world.World; @@ -34,39 +40,30 @@ import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; import forestry.plugins.PluginArboriculture; -public class BlockArbFence extends BlockFence implements IWoodTyped { +public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntityProvider { - public enum FenceCat { - CAT0, CAT1 - } + private final boolean fireproof; - public static final int fencesPerCat = 16; - private final FenceCat cat; - - public BlockArbFence(FenceCat cat) { + public BlockArbFence(boolean fireproof) { super("", Material.wood); - this.cat = cat; + + this.fireproof = fireproof; + setHardness(2.0F); setResistance(5.0F); + setHarvestLevel("axe", 0); setStepSound(soundTypeWood); setCreativeTab(Tabs.tabArboriculture); } @SuppressWarnings({"rawtypes", "unchecked"}) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - int totalWoods = WoodType.values().length; - int count = Math.min(totalWoods - (cat.ordinal() * fencesPerCat), fencesPerCat); - for (int i = 0; i < count; i++) { - itemList.add(new ItemStack(this, 1, i)); + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) { + for (WoodType woodType : WoodType.VALUES) { + list.add(woodType.getFence(fireproof)); } } - @Override - public int damageDropped(int meta) { - return meta; - } - @Override public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { return true; @@ -101,51 +98,82 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int meta) { - WoodType woodType = getWoodType(meta); - if (woodType == null) { - return null; - } - return woodType.getPlankIcon(); + return WoodType.ACACIA.getPlankIcon(); } - public boolean isFence(IBlockAccess world, int x, int y, int z) { + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileWood wood = BlockWood.getWoodTile(world, x, y, z); + WoodType type = wood.getWoodType(); + return type.getPlankIcon(); + } + + public static boolean isFence(IBlockAccess world, int x, int y, int z) { Block block = world.getBlock(x, y, z); return PluginArboriculture.validFences.contains(block); } + @Override + public final TileEntity createNewTileEntity(World world, int meta) { + return new TileWood(); + } + /* PROPERTIES */ @Override - public boolean isWood(IBlockAccess world, int x, int y, int z) { - return true; + public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + ItemStack itemStack = new ItemStack(this); + NBTTagCompound nbt = BlockWood.getTagCompound(world, x, y, z); + itemStack.setTagCompound(nbt); + return itemStack; + } + + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { + return TileWood.blockRemovedByPlayer(this, world, player, x, y, z); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + world.removeTileEntity(x, y, z); + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public final float getBlockHardness(World world, int x, int y, int z) { + TileWood wood = BlockWood.getWoodTile(world, x, y, z); + if (wood == null) { + return WoodType.DEFAULT_HARDNESS; + } + return wood.getWoodType().getHardness(); + } + + @Override + public final boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return !isFireproof(); } @Override public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 20; - } - - @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return true; + return isFireproof() ? 0 : 20; } @Override public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 5; - } - - @Override - public WoodType getWoodType(int meta) { - int woodOrdinal = cat.ordinal() * fencesPerCat + meta; - if (woodOrdinal < WoodType.VALUES.length) { - return WoodType.VALUES[woodOrdinal]; - } else { - return null; - } + return isFireproof() ? 0 : 5; } @Override public String getBlockKind() { return "fences"; } + + @Override + public boolean isFireproof() { + return fireproof; + } } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java index 1896a1a54..aaa992095 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java @@ -15,6 +15,7 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -31,62 +32,36 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; -public class BlockArbStairs extends BlockStairs { +public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEntityProvider { - public BlockArbStairs(Block par2Block, int par3) { + private final boolean fireproof; + + public BlockArbStairs(Block par2Block, int par3, boolean fireproof) { super(par2Block, par3); + + this.fireproof = fireproof; + setCreativeTab(Tabs.tabArboriculture); setHardness(2.0F); setResistance(5.0F); - } - - public static TileStairs getStairTile(IBlockAccess world, int x, int y, int z) { - TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileStairs)) { - return null; - } - - return (TileStairs) tile; + setHarvestLevel("axe", 0); } @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (WoodType type : WoodType.VALUES) { - ItemStack stack = new ItemStack(item, 1, 0); - NBTTagCompound compound = new NBTTagCompound(); - type.saveToCompound(compound); - stack.setTagCompound(compound); - list.add(stack); + for (WoodType woodType : WoodType.VALUES) { + list.add(woodType.getStairs(fireproof)); } } @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - if (Proxies.common.isSimulating(world) && canHarvestBlock(player, meta)) { - if (!player.capabilities.isCreativeMode) { - // Handle TE'd beehives - TileEntity tile = world.getTileEntity(x, y, z); - - if (tile instanceof TileStairs) { - TileStairs stairs = (TileStairs) tile; - - ItemStack stack = new ItemStack(this, 1, 0); - NBTTagCompound compound = new NBTTagCompound(); - stairs.getWoodType().saveToCompound(compound); - stack.setTagCompound(compound); - StackUtils.dropItemStackAsEntity(stack, world, x, y, z); - } - } - } - - return world.setBlockToAir(x, y, z); + return TileWood.blockRemovedByPlayer(this, world, player, x, y, z); } @Override @@ -100,36 +75,14 @@ public class BlockArbStairs extends BlockStairs { return new ArrayList(); } - @Override - public boolean hasTileEntity(int meta) { - return true; - } - - @Override - public TileEntity createTileEntity(World world, int meta) { - return new TileStairs(); - } - @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { ItemStack itemStack = super.getPickBlock(target, world, x, y, z); - NBTTagCompound stairsNBT = getTagCompoundForStairs(world, x, y, z); + NBTTagCompound stairsNBT = BlockWood.getTagCompound(world, x, y, z); itemStack.setTagCompound(stairsNBT); return itemStack; } - private static NBTTagCompound getTagCompoundForStairs(IBlockAccess world, int x, int y, int z) { - TileStairs stairs = getStairTile(world, x, y, z); - - NBTTagCompound nbttagcompound = new NBTTagCompound(); - if (stairs == null || stairs.getWoodType() == null) { - return nbttagcompound; - } - - stairs.getWoodType().saveToCompound(nbttagcompound); - return nbttagcompound; - } - /* ICONS */ @SideOnly(Side.CLIENT) @Override @@ -137,19 +90,37 @@ public class BlockArbStairs extends BlockStairs { WoodType.registerIcons(register); } + /* ICONS */ @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int side, int meta) { + return WoodType.ACACIA.getPlankIcon(); + } + @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - TileStairs stairs = getStairTile(world, x, y, z); - if (stairs != null && stairs.getWoodType() != null) { - return stairs.getWoodType().getPlankIcon(); - } else { - return WoodType.LARCH.getPlankIcon(); - } + TileWood wood = BlockWood.getWoodTile(world, x, y, z); + WoodType type = wood.getWoodType(); + return type.getPlankIcon(); } @Override public boolean getUseNeighborBrightness() { return true; } + + @Override + public String getBlockKind() { + return "stairs"; + } + + @Override + public boolean isFireproof() { + return fireproof; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileWood(); + } } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java b/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java deleted file mode 100644 index 0ddb39cf6..000000000 --- a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofLog.java +++ /dev/null @@ -1,70 +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.gadgets; - -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.world.IBlockAccess; - -import net.minecraftforge.common.util.ForgeDirection; - -import forestry.arboriculture.IWoodFireproof; -import forestry.core.config.ForestryBlock; - -public class BlockFireproofLog extends BlockLog implements IWoodFireproof { - - private static final Material fireproofWood = new Material(MapColor.woodColor); - - public BlockFireproofLog(LogCat cat) { - super(cat, fireproofWood); - } - - public static ForestryBlock getFireproofLog(BlockLog log) { - return getFireproofLog(log.cat); - } - - private static ForestryBlock getFireproofLog(BlockLog.LogCat logCat) { - switch (logCat) { - case CAT0: - return ForestryBlock.fireproofLog1; - case CAT1: - return ForestryBlock.fireproofLog2; - case CAT2: - return ForestryBlock.fireproofLog3; - case CAT3: - return ForestryBlock.fireproofLog4; - case CAT4: - return ForestryBlock.fireproofLog5; - case CAT5: - return ForestryBlock.fireproofLog6; - case CAT6: - return ForestryBlock.fireproofLog7; - case CAT7: - return ForestryBlock.fireproofLog8; - } - throw new IllegalArgumentException("No fireproof log for this category: " + logCat); - } - - @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 0; - } - - @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return false; - } - - @Override - public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 0; - } -} diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java b/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java deleted file mode 100644 index 72e37363e..000000000 --- a/src/main/java/forestry/arboriculture/gadgets/BlockFireproofPlanks.java +++ /dev/null @@ -1,59 +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.gadgets; - -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.world.IBlockAccess; - -import net.minecraftforge.common.util.ForgeDirection; - -import forestry.arboriculture.IWoodFireproof; -import forestry.core.config.ForestryBlock; - -public class BlockFireproofPlanks extends BlockPlanks implements IWoodFireproof { - - private static final Material fireproofWood = new Material(MapColor.woodColor); - - public BlockFireproofPlanks(PlankCat cat) { - super(cat, fireproofWood); - } - - public static ForestryBlock getFireproofPlanks(BlockPlanks planks) { - return getFireproofPlanks(planks.cat); - } - - private static ForestryBlock getFireproofPlanks(PlankCat plankCat) { - switch (plankCat) { - case CAT0: - return ForestryBlock.fireproofPlanks1; - case CAT1: - return ForestryBlock.fireproofPlanks2; - } - throw new IllegalArgumentException("No fireproof log for this category: " + plankCat); - } - - @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 0; - } - - @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return false; - } - - @Override - public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 0; - } - -} diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java index d4bf2b9e4..86d631efc 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java @@ -13,12 +13,9 @@ package forestry.arboriculture.gadgets; import java.util.List; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -28,36 +25,14 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; -public class BlockLog extends Block implements IWoodTyped { +public class BlockLog extends BlockWood { - public enum LogCat { - CAT0, CAT1, CAT2, CAT3, CAT4, CAT5, CAT6, CAT7 - } - - public static final short logsPerCat = 4; - - protected final LogCat cat; - - public BlockLog(LogCat cat) { - this(cat, Material.wood); - } - - protected BlockLog(LogCat cat, Material material) { - super(material); - this.cat = cat; - - setHardness(2.0F); + public BlockLog(boolean fireproof) { + super("log", fireproof); setResistance(5.0F); - setStepSound(soundTypeWood); - setCreativeTab(Tabs.tabArboriculture); - } - - public static int getTypeFromMeta(int damage) { - return damage & 3; + setHarvestLevel("axe", 0); } @Override @@ -86,7 +61,6 @@ public class BlockLog extends Block implements IWoodTyped { @Override public int onBlockPlaced(World world, int x, int y, int z, int side, float par6, float par7, float par8, int meta) { - int type = getTypeFromMeta(meta); byte b0 = 0; switch (side) { @@ -103,89 +77,41 @@ public class BlockLog extends Block implements IWoodTyped { b0 = 4; } - return type | b0; + return meta | b0; } @SuppressWarnings({"rawtypes", "unchecked"}) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - int totalWoods = WoodType.values().length; - int count = Math.min(totalWoods - (cat.ordinal() * logsPerCat), logsPerCat); - for (int i = 0; i < count; i++) { - itemList.add(new ItemStack(this, 1, i)); + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (WoodType woodType : WoodType.VALUES) { + list.add(woodType.getLog(isFireproof())); } } /* ICONS */ - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister register) { - WoodType.registerIcons(register); - } - @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { + return WoodType.ACACIA.getIcon(meta, side); + } - int oriented = meta & 12; - - WoodType type = getWoodType(meta); + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + TileWood wood = getWoodTile(world, x, y, z); + WoodType type = wood.getWoodType(); if (type == null) { - return null; + return getIcon(side, meta); } - - switch (oriented) { - case 4: - if (side > 3) { - return type.getHeartIcon(); - } else { - return type.getBarkIcon(); - } - case 8: - if (side == 2 || side == 3) { - return type.getHeartIcon(); - } else { - return type.getBarkIcon(); - } - case 0: - default: - if (side < 2) { - return type.getHeartIcon(); - } else { - return type.getBarkIcon(); - } - } - } - - @Override - public int damageDropped(int meta) { - return getTypeFromMeta(meta); - } - - @Override - protected ItemStack createStackedBlock(int meta) { - return new ItemStack(this, 1, getTypeFromMeta(meta)); + return type.getIcon(meta, side); } /* PROPERTIES */ - @Override - public float getBlockHardness(World world, int x, int y, int z) { - return getWoodType(world.getBlockMetadata(x, y, z)).getHardness(); - } - - @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 20; - } - - @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return true; - } - @Override public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - if (face == ForgeDirection.DOWN) { + if (isFireproof()) { + return 0; + } else if (face == ForgeDirection.DOWN) { return 20; } else if (face != ForgeDirection.UP) { return 10; @@ -204,20 +130,4 @@ public class BlockLog extends Block implements IWoodTyped { return true; } - @Override - public WoodType getWoodType(int meta) { - meta = getTypeFromMeta(meta); - int woodOrdinal = meta + cat.ordinal() * logsPerCat; - if (woodOrdinal < WoodType.VALUES.length) { - return WoodType.VALUES[woodOrdinal]; - } else { - return null; - } - } - - @Override - public String getBlockKind() { - return "log"; - } - } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java index df5b3c584..a1fad52c5 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java @@ -12,116 +12,44 @@ package forestry.arboriculture.gadgets; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; -public class BlockPlanks extends Block implements IWoodTyped { +public class BlockPlanks extends BlockWood { - public enum PlankCat { - CAT0, CAT1 - } - - public static final int planksPerCat = 16; - protected final PlankCat cat; - - public BlockPlanks(PlankCat cat) { - this(cat, Material.wood); - } - - protected BlockPlanks(PlankCat cat, Material material) { - super(material); - this.cat = cat; + public BlockPlanks(boolean fireproof) { + super("planks", fireproof); setResistance(5.0F); - setStepSound(soundTypeWood); - setCreativeTab(Tabs.tabArboriculture); + setHarvestLevel("axe", 0); } @SuppressWarnings({"rawtypes", "unchecked"}) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - int totalWoods = WoodType.values().length; - int count = Math.min(totalWoods - (cat.ordinal() * planksPerCat), planksPerCat); - for (int i = 0; i < count; i++) { - itemList.add(new ItemStack(this, 1, i)); + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) { + for (WoodType woodType : WoodType.VALUES) { + list.add(woodType.getPlanks(isFireproof())); } } /* ICONS */ - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister register) { - WoodType.registerIcons(register); - } - @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int meta) { - WoodType woodType = getWoodType(meta); - if (woodType == null) { - return null; - } - return woodType.getPlankIcon(); + return WoodType.ACACIA.getPlankIcon(); } @Override - public int damageDropped(int meta) { - return meta; + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileWood wood = getWoodTile(world, x, y, z); + WoodType type = wood.getWoodType(); + return type.getPlankIcon(); } - /* PROPERTIES */ - @Override - public float getBlockHardness(World world, int x, int y, int z) { - return getWoodType(world.getBlockMetadata(x, y, z)).getHardness(); - } - - @Override - public boolean isWood(IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 20; - } - - @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return true; - } - - @Override - public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 5; - } - - @Override - public WoodType getWoodType(int meta) { - int woodOrdinal = cat.ordinal() * planksPerCat + meta; - if (woodOrdinal < WoodType.VALUES.length) { - return WoodType.VALUES[woodOrdinal]; - } else { - return null; - } - } - - @Override - public String getBlockKind() { - return "planks"; - } } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java index 6a88304a9..656aafd26 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java @@ -32,22 +32,19 @@ import cpw.mods.fml.relauncher.SideOnly; import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; 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); - if (!(tile instanceof TileSapling)) { - return null; - } - - return (TileSapling) tile; + return Utils.getTile(world, x, y, z, TileSapling.class); } public BlockSapling() { @@ -162,7 +159,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable { if (sapling == null || sapling.getTree() == null) { return null; } - return PluginArboriculture.treeInterface.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal()); + return TreeManager.treeRoot.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal()); } @Override @@ -176,14 +173,14 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable { return world.setBlockToAir(x, y, z); } - private void dropAsSapling(World world, int x, int y, int z) { + private static void dropAsSapling(World world, int x, int y, int z) { if (!Proxies.common.isSimulating(world)) { return; } TileSapling sapling = getSaplingTile(world, x, y, z); if (sapling != null && sapling.getTree() != null) { - ItemStack saplingStack = PluginArboriculture.treeInterface.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal()); + ItemStack saplingStack = TreeManager.treeRoot.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal()); StackUtils.dropItemStackAsEntity(saplingStack, world, x, y, z); } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index 00ae9eecf..24d265d96 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -10,16 +10,23 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import java.util.ArrayList; import java.util.List; import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; 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.IBlockAccess; import net.minecraft.world.World; @@ -32,23 +39,21 @@ import forestry.api.core.Tabs; import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; -public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped { +public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped, ITileEntityProvider { - public enum SlabCat { - CAT0, CAT1, CAT2, CAT3 - } + private final boolean fireproof; - public static final int slabsPerCat = 8; - private final SlabCat cat; - - public BlockSlab(SlabCat cat) { + public BlockSlab(boolean fireproof) { super(false, Material.wood); - this.cat = cat; + + this.fireproof = fireproof; + setCreativeTab(Tabs.tabArboriculture); setLightOpacity(0); setHardness(2.0F); setResistance(5.0F); setStepSound(soundTypeWood); + setHarvestLevel("axe", 0); } @Override @@ -63,12 +68,17 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp WoodType.registerIcons(register); } + /* ICONS */ + @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int meta) { - WoodType type = getWoodType(meta); - if (type == null) { - return null; - } + return WoodType.ACACIA.getPlankIcon(); + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileWood wood = BlockWood.getWoodTile(world, x, y, z); + WoodType type = wood.getWoodType(); return type.getPlankIcon(); } @@ -89,38 +99,64 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @SuppressWarnings({"rawtypes", "unchecked"}) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - int totalWoods = WoodType.values().length; - int count = Math.min(totalWoods - (cat.ordinal() * slabsPerCat), slabsPerCat); - for (int i = 0; i < count; i++) { - itemList.add(new ItemStack(this, 1, i)); + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) { + for (WoodType woodType : WoodType.VALUES) { + list.add(woodType.getSlab(fireproof)); } } + @Override + public final TileEntity createNewTileEntity(World world, int meta) { + return new TileWood(); + } + /* PROPERTIES */ @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 20; + public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + ItemStack itemStack = new ItemStack(this); + NBTTagCompound nbt = BlockWood.getTagCompound(world, x, y, z); + itemStack.setTagCompound(nbt); + return itemStack; } @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return true; + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { + return TileWood.blockRemovedByPlayer(this, world, player, x, y, z); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + world.removeTileEntity(x, y, z); + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public final float getBlockHardness(World world, int x, int y, int z) { + TileWood wood = BlockWood.getWoodTile(world, x, y, z); + if (wood == null) { + return WoodType.DEFAULT_HARDNESS; + } + return wood.getWoodType().getHardness(); + } + + @Override + public final boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return !isFireproof(); + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return isFireproof() ? 0 : 20; } @Override public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { - return 5; - } - - @Override - public WoodType getWoodType(int meta) { - int woodOrdinal = (meta % slabsPerCat) + cat.ordinal() * slabsPerCat; - if (woodOrdinal < WoodType.VALUES.length) { - return WoodType.VALUES[woodOrdinal]; - } else { - return null; - } + return isFireproof() ? 0 : 5; } @Override @@ -128,6 +164,11 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp return "slab"; } + @Override + public boolean isFireproof() { + return fireproof; + } + @Override public boolean getUseNeighborBrightness() { return true; diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockWood.java b/src/main/java/forestry/arboriculture/gadgets/BlockWood.java new file mode 100644 index 000000000..3b2e5db51 --- /dev/null +++ b/src/main/java/forestry/arboriculture/gadgets/BlockWood.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * 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.gadgets; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +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.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; +import forestry.core.utils.Utils; + +public abstract class BlockWood extends Block implements ITileEntityProvider, IWoodTyped { + + private final String blockKind; + private final boolean fireproof; + + protected BlockWood(String blockKind, boolean fireproof) { + super(Material.wood); + this.blockKind = blockKind; + this.fireproof = fireproof; + + setStepSound(soundTypeWood); + setCreativeTab(Tabs.tabArboriculture); + } + + @Override + public final String getBlockKind() { + return blockKind; + } + + @Override + public boolean isFireproof() { + return fireproof; + } + + public static TileWood getWoodTile(IBlockAccess world, int x, int y, int z) { + return Utils.getTile(world, x, y, z, TileWood.class); + } + + protected static NBTTagCompound getTagCompound(IBlockAccess world, int x, int y, int z) { + TileWood wood = getWoodTile(world, x, y, z); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + if (wood == null) { + return nbttagcompound; + } + WoodType woodType = wood.getWoodType(); + woodType.saveToCompound(nbttagcompound); + return nbttagcompound; + } + + @SideOnly(Side.CLIENT) + @Override + public final void registerBlockIcons(IIconRegister register) { + WoodType.registerIcons(register); + } + + @Override + public final TileEntity createNewTileEntity(World world, int meta) { + return new TileWood(); + } + + @Override + public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + ItemStack itemStack = new ItemStack(this); + NBTTagCompound nbt = getTagCompound(world, x, y, z); + itemStack.setTagCompound(nbt); + return itemStack; + } + + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { + return TileWood.blockRemovedByPlayer(this, world, player, x, y, z); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + world.removeTileEntity(x, y, z); + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList(); + } + + @Override + public final float getBlockHardness(World world, int x, int y, int z) { + TileWood wood = getWoodTile(world, x, y, z); + if (wood == null) { + return WoodType.DEFAULT_HARDNESS; + } + return wood.getWoodType().getHardness(); + } + + @Override + public final boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return !isFireproof(); + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return isFireproof() ? 0 : 20; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return isFireproof() ? 0 : 5; + } + + @SideOnly(Side.CLIENT) + public abstract IIcon getIcon(IBlockAccess world, int x, int y, int z, int side); + +} diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index e67258ccb..ee47ff5f7 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -39,15 +40,17 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.EnumLeafType; import forestry.api.arboriculture.IToolGrafter; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.core.IToolScoop; import forestry.api.core.Tabs; import forestry.api.lepidopterology.EnumFlutterType; import forestry.api.lepidopterology.IButterfly; import forestry.arboriculture.items.ItemLeavesBlock; +import forestry.arboriculture.render.LeafTexture; import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; import forestry.plugins.PluginArboriculture; import forestry.plugins.PluginLepidopterology; @@ -87,7 +90,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @SuppressWarnings({"unchecked", "rawtypes"}) public void getSubBlocks(Item item, CreativeTabs tab, List list) { - for (ITree tree : PluginArboriculture.treeInterface.getIndividualTemplates()) { + for (ITree tree : TreeManager.treeRoot.getIndividualTemplates()) { TileLeaves leaves = new TileLeaves(); leaves.setDecorative(); leaves.setTree(tree); @@ -145,7 +148,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv return ret; } - private static ArrayList getLeafDrop(World world, GameProfile playerProfile, int x, int y, int z, float saplingModifier, int fortune) { + private static ArrayList getLeafDrop(World world, @Nullable GameProfile playerProfile, int x, int y, int z, float saplingModifier, int fortune) { ArrayList prod = new ArrayList(); TileLeaves tile = getLeafTile(world, x, y, z); @@ -158,7 +161,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv for (ITree sapling : saplings) { if (sapling != null) { - prod.add(PluginArboriculture.treeInterface.getMemberStack(sapling, EnumGermlingType.SAPLING.ordinal())); + prod.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING.ordinal())); } } @@ -268,7 +271,8 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister register) { - defaultIcon = TextureManager.getInstance().registerTex(register, "leaves/deciduous.fancy"); + LeafTexture.registerAllIcons(register); + defaultIcon = LeafTexture.get(EnumLeafType.DECIDUOUS).getFancy(); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 46cf7b86b..f24974b05 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -16,11 +16,9 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IIcon; import net.minecraft.world.World; @@ -37,6 +35,7 @@ import forestry.api.arboriculture.ILeafTickHandler; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeGenome; import forestry.api.arboriculture.ITreekeepingMode; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IEffectData; @@ -48,6 +47,7 @@ import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.IButterflyGenome; import forestry.api.lepidopterology.IButterflyNursery; import forestry.api.lepidopterology.IButterflyRoot; +import forestry.arboriculture.genetics.TreeDefinition; import forestry.arboriculture.network.PacketRipeningUpdate; import forestry.core.genetics.alleles.Allele; import forestry.core.network.DataInputStreamForestry; @@ -57,16 +57,15 @@ import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.GeneticsUtil; import forestry.core.utils.Utils; -import forestry.plugins.PluginArboriculture; public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery { private int colourLeaves; + private int colourLeavesPollinated; private int colourFruits; - private short textureIndexFancy = 48; - private short textureIndexPlain = 64; private short textureIndexFruits = -1; + private IAlleleTreeSpecies species; private boolean isFruitLeaf; private boolean isPollinatedState; @@ -148,7 +147,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } if (hasFruit() && getRipeningTime() < ripeningPeriod) { - ITreekeepingMode treekeepingMode = PluginArboriculture.treeInterface.getTreekeepingMode(worldObj); + ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(worldObj); float sappinessModifier = treekeepingMode.getSappinessModifier(genome, 1f); float sappiness = genome.getSappiness() * sappinessModifier; @@ -170,7 +169,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru super.setTree(tree); ITreeGenome genome = tree.getGenome(); - IAlleleTreeSpecies species = genome.getPrimary(); + species = genome.getPrimary(); if (tree.canBearFruit()) { IFruitProvider fruitProvider = genome.getFruitProvider(); @@ -178,7 +177,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru isFruitLeaf = fruitProvider.markAsFruitLeaf(genome, worldObj, xCoord, yCoord, zCoord); if (isFruitLeaf) { // Hardcoded because vanilla oak trees don't show fruits. - if ((species == Allele.treeOak) && (fruitProvider == Allele.fruitApple.getProvider())) { + if ((species == TreeDefinition.Oak.getGenome().getPrimary()) && (fruitProvider == Allele.fruitApple.getProvider())) { textureIndexFruits = -1; } else { textureIndexFruits = fruitProvider.getIconIndex(genome, worldObj, xCoord, yCoord, zCoord, getRipeningTime(), true); @@ -191,10 +190,8 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru textureIndexFruits = -1; } - textureIndexFancy = species.getLeafIconIndex(tree, true); - textureIndexPlain = species.getLeafIconIndex(tree, false); - - colourLeaves = species.getLeafColour(tree); + colourLeaves = species.getLeafColour(false); + colourLeavesPollinated = species.getLeafColour(true); if (isDestroyed(tree, damage)) { colourLeaves = Utils.addRGBComponents(colourLeaves, 92, 61, 0); } else if (caterpillar != null) { @@ -216,7 +213,11 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } public int getFoliageColour(EntityPlayer player) { - return (isPollinatedState && GeneticsUtil.hasNaturalistEye(player)) ? 0xffffff : colourLeaves; + if (isPollinatedState && GeneticsUtil.hasNaturalistEye(player)) { + return colourLeavesPollinated; + } else { + return colourLeaves; + } } public int getFruitColour() { @@ -235,11 +236,10 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @SideOnly(Side.CLIENT) public IIcon getIcon(boolean fancy) { - if (fancy) { - return TextureManager.getInstance().getIcon(textureIndexFancy); - } else { - return TextureManager.getInstance().getIcon(textureIndexPlain); + if (species == null) { + return TreeDefinition.Oak.getIndividual().getGenome().getPrimary().getLeafIcon(false, fancy); } + return species.getLeafIcon(isPollinatedState, fancy); } @SideOnly(Side.CLIENT) @@ -315,11 +315,6 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } /* NETWORK */ - @Override - public Packet getDescriptionPacket() { - return new PacketTileStream(this).getPacket(); - } - public void sendNetworkUpdate() { Proxies.net.sendNetworkPacket(new PacketTileStream(this), worldObj); } @@ -379,7 +374,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru colourFruits = data.readInt(); } - IAllele[] treeTemplate = PluginArboriculture.treeInterface.getTemplate(speciesUID); + IAllele[] treeTemplate = TreeManager.treeRoot.getTemplate(speciesUID); if (fruitAlleleUID != null) { IAllele fruitAllele = AlleleManager.alleleRegistry.getAllele(fruitAlleleUID); @@ -389,7 +384,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } if (treeTemplate != null) { - ITree tree = PluginArboriculture.treeInterface.templateAsIndividual(treeTemplate); + ITree tree = TreeManager.treeRoot.templateAsIndividual(treeTemplate); if (isPollinatedState) { tree.mate(tree); } @@ -408,15 +403,6 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru worldObj.func_147479_m(xCoord, yCoord, zCoord); } - /** - * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes. - * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly. - */ - @Override - public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { - return !Block.isEqualTo(oldBlock, newBlock); - } - /* IFRUITBEARER */ @Override public Collection pickFruit(ItemStack tool) { diff --git a/src/main/java/forestry/arboriculture/gadgets/TileSapling.java b/src/main/java/forestry/arboriculture/gadgets/TileSapling.java index 10dbdec2c..90e8bed37 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileSapling.java @@ -11,11 +11,9 @@ package forestry.arboriculture.gadgets; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; import net.minecraft.world.gen.feature.WorldGenerator; -import forestry.core.network.PacketTileStream; -import forestry.plugins.PluginArboriculture; +import forestry.api.arboriculture.TreeManager; public class TileSapling extends TileTreeContainer { @@ -50,7 +48,7 @@ public class TileSapling extends TileTreeContainer { return result; } - int maturity = (int) (getTree().getRequiredMaturity() * PluginArboriculture.treeInterface.getTreekeepingMode(worldObj).getMaturationModifier( + int maturity = (int) (getTree().getRequiredMaturity() * TreeManager.treeRoot.getTreekeepingMode(worldObj).getMaturationModifier( getTree().getGenome(), 1f)); if (bonemealed && timesTicked < maturity) { @@ -64,15 +62,11 @@ public class TileSapling extends TileTreeContainer { WorldGenerator generator = this.getTree().getTreeGenerator(worldObj, xCoord, yCoord, zCoord, bonemealed); if (generator.generate(worldObj, worldObj.rand, xCoord, yCoord, zCoord)) { - PluginArboriculture.treeInterface.getBreedingTracker(worldObj, getOwner()).registerBirth(getTree()); + TreeManager.treeRoot.getBreedingTracker(worldObj, getOwner()).registerBirth(getTree()); return 2; } return 3; } - @Override - public Packet getDescriptionPacket() { - return new PacketTileStream(this).getPacket(); - } } diff --git a/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java b/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java index 168cb3c07..0a438ef97 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java @@ -12,20 +12,23 @@ package forestry.arboriculture.gadgets; import java.io.IOException; +import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import com.mojang.authlib.GameProfile; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IAllele; import forestry.arboriculture.genetics.Tree; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamable; -import forestry.plugins.PluginArboriculture; +import forestry.core.network.PacketTileStream; /** * This is the base TE class for any block that needs to contain tree genome information. @@ -84,11 +87,11 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl } public static ITree getTree(String speciesUID) { - IAllele[] treeTemplate = PluginArboriculture.treeInterface.getTemplate(speciesUID); + IAllele[] treeTemplate = TreeManager.treeRoot.getTemplate(speciesUID); if (treeTemplate == null) { return null; } - return PluginArboriculture.treeInterface.templateAsIndividual(treeTemplate); + return TreeManager.treeRoot.templateAsIndividual(treeTemplate); } /* CLIENT INFORMATION */ @@ -96,6 +99,9 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl /* CONTAINED TREE */ public void setTree(ITree tree) { this.containedTree = tree; + if (worldObj != null && worldObj.isRemote) { + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } public ITree getTree() { @@ -126,8 +132,19 @@ public abstract class TileTreeContainer extends TileEntity implements IStreamabl */ public abstract void onBlockTick(); + /** + * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes. + * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly. + */ + @Override + public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { + return !Block.isEqualTo(oldBlock, newBlock); + } + /* INETWORKEDENTITY */ @Override - public abstract Packet getDescriptionPacket(); + public Packet getDescriptionPacket() { + return new PacketTileStream(this).getPacket(); + } } diff --git a/src/main/java/forestry/arboriculture/gadgets/TileStairs.java b/src/main/java/forestry/arboriculture/gadgets/TileWood.java old mode 100755 new mode 100644 similarity index 51% rename from src/main/java/forestry/arboriculture/gadgets/TileStairs.java rename to src/main/java/forestry/arboriculture/gadgets/TileWood.java index 64c0c8d7f..9fcae1328 --- a/src/main/java/forestry/arboriculture/gadgets/TileStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileWood.java @@ -1,89 +1,107 @@ -/******************************************************************************* - * 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.gadgets; - -import java.io.IOException; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; - -import forestry.arboriculture.WoodType; -import forestry.core.network.DataInputStreamForestry; -import forestry.core.network.DataOutputStreamForestry; -import forestry.core.network.IStreamable; -import forestry.core.network.PacketTileStream; -import forestry.core.proxy.Proxies; - -public class TileStairs extends TileEntity implements IStreamable { - - private WoodType woodType; - - public WoodType getWoodType() { - return this.woodType; - } - - public void setWoodType(WoodType woodType) { - this.woodType = woodType; - sendNetworkUpdate(); - } - - /* SAVING & LOADING */ - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - - if (nbttagcompound.hasKey("WT")) { - woodType = WoodType.VALUES[nbttagcompound.getShort("WT")]; - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - - if (woodType != null) { - nbttagcompound.setShort("WT", (short) woodType.ordinal()); - } - } - - /* UPDATING */ - - /** - * This doesn't use normal TE updates - */ - @Override - public boolean canUpdate() { - return false; - } - - /* INETWORKEDENTITY */ - @Override - public Packet getDescriptionPacket() { - return new PacketTileStream(this).getPacket(); - } - - public void sendNetworkUpdate() { - Proxies.net.sendNetworkPacket(new PacketTileStream(this), worldObj); - } - - @Override - public void writeData(DataOutputStreamForestry data) throws IOException { - data.writeVarInt(woodType.ordinal()); - } - - @Override - public void readData(DataInputStreamForestry data) throws IOException { - int woodTypeOrdinal = data.readVarInt(); - woodType = WoodType.values()[woodTypeOrdinal]; - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } -} +/******************************************************************************* + * 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.gadgets; + +import java.io.IOException; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; +import forestry.core.network.DataInputStreamForestry; +import forestry.core.network.DataOutputStreamForestry; +import forestry.core.network.IStreamable; +import forestry.core.network.PacketTileStream; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; + +public class TileWood extends TileEntity implements IStreamable { + private WoodType woodType; + + public TileWood() { + this.woodType = WoodType.ACACIA; + } + + public void setWoodType(WoodType woodType) { + this.woodType = woodType; + markDirty(); + } + + public WoodType getWoodType() { + return woodType; + } + + @Override + public boolean canUpdate() { + return false; + } + + /* NETWORK */ + @Override + public Packet getDescriptionPacket() { + return new PacketTileStream(this).getPacket(); + } + + @Override + public void writeData(DataOutputStreamForestry data) throws IOException { + data.writeVarInt(woodType.ordinal()); + } + + @Override + public void readData(DataInputStreamForestry data) throws IOException { + int ordinal = data.readVarInt(); + woodType = WoodType.VALUES[ordinal]; + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + if (woodType != null) { + nbt.setInteger("WT", woodType.ordinal()); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + if (nbt.hasKey("WT")) { + int ordinal = nbt.getInteger("WT"); + woodType = WoodType.VALUES[ordinal]; + } + } + + public static boolean blockRemovedByPlayer(T block, World world, EntityPlayer player, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + if (Proxies.common.isSimulating(world) && block.canHarvestBlock(player, meta) && !player.capabilities.isCreativeMode) { + + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileWood) { + TileWood wood = (TileWood) tile; + + ItemStack stack = new ItemStack(block); + NBTTagCompound compound = new NBTTagCompound(); + wood.getWoodType().saveToCompound(compound); + stack.setTagCompound(compound); + StackUtils.dropItemStackAsEntity(stack, world, x, y, z); + } + } + + return world.setBlockToAir(x, y, z); + } + +} diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java index c97de7033..7e547417e 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java @@ -11,156 +11,69 @@ package forestry.arboriculture.genetics; import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.EnumPlantType; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.EnumTreeChromosome; +import forestry.api.arboriculture.IAlleleTreeSpeciesCustom; +import forestry.api.arboriculture.IGermlingIconProvider; +import forestry.api.arboriculture.ILeafIconProvider; +import forestry.api.arboriculture.ITreeGenerator; import forestry.api.arboriculture.ITreeRoot; +import forestry.api.arboriculture.TreeManager; import forestry.api.core.IIconProvider; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; import forestry.api.genetics.IClassification; import forestry.api.genetics.IFruitFamily; -import forestry.api.genetics.IMutation; -import forestry.api.world.ITreeGenData; -import forestry.arboriculture.worldgen.WorldGenArboriculture; -import forestry.arboriculture.worldgen.WorldGenBalsa; -import forestry.core.config.ForestryItem; import forestry.core.genetics.alleles.AlleleSpecies; import forestry.core.render.TextureManager; -import forestry.core.utils.Utils; +import forestry.core.utils.GeneticsUtil; -public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpecies, IIconProvider { +public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeciesCustom, IIconProvider { - private static class LeafType { - public final String ident; - public final short fancyUID; - public final short plainUID; - public final short changedUID; + private final ITreeGenerator generator; + private final IGermlingIconProvider germlingIconProvider; + private final ILeafIconProvider leafIconProvider; + private final List fruits = new ArrayList(); - public LeafType(String ident, short fancyUID, short plainUID, short changedUID) { - this.ident = ident; - this.fancyUID = fancyUID; - this.plainUID = plainUID; - this.changedUID = changedUID; - } - } - - private static final HashMap leafTypes = new HashMap(); - - static { - leafTypes.put("deciduous", new LeafType("deciduous", (short) 10, (short) 11, (short) 12)); - leafTypes.put("conifers", new LeafType("conifers", (short) 15, (short) 16, (short) 17)); - leafTypes.put("jungle", new LeafType("jungle", (short) 20, (short) 21, (short) 22)); - leafTypes.put("willow", new LeafType("willow", (short) 25, (short) 26, (short) 27)); - leafTypes.put("maple", new LeafType("maple", (short) 30, (short) 31, (short) 32)); - leafTypes.put("palm", new LeafType("palm", (short) 35, (short) 36, (short) 37)); - } - - private final ITreeRoot root; - - private Class generatorClass = WorldGenBalsa.class; - - private final int primaryColour; - //private final int secondaryColour; - - private LeafType leafType; - - private int girth = 1; private EnumPlantType nativeType = EnumPlantType.Plains; - private final ArrayList fruits = new ArrayList(); - private final ItemStack wood; + public AlleleTreeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean isDominant, IClassification branch, String binomial, ILeafIconProvider leafIconProvider, IGermlingIconProvider germlingIconProvider, ITreeGenerator generator) { + super(uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial, false); - public AlleleTreeSpecies(String uid, boolean isDominant, String speciesName, IClassification branch, String binomial, int primaryColor, - Class generator, ItemStack wood) { - this(uid, isDominant, speciesName, branch, binomial, primaryColor, Utils.multiplyRGBComponents(primaryColor, 1.35f), generator, wood); - } - - public AlleleTreeSpecies(String uid, boolean isDominant, String speciesName, IClassification branch, String binomial, int primaryColor, int secondaryColor, - Class generator, ItemStack wood) { - super("forestry." + uid, "for.trees.species." + speciesName, "Sengir", "for.description." + uid, isDominant, branch, binomial, true); - - this.root = (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); - this.generatorClass = generator; - this.primaryColour = primaryColor; - //this.secondaryColour = secondaryColor; - leafType = leafTypes.get("deciduous"); - this.wood = wood; + this.generator = generator; + this.germlingIconProvider = germlingIconProvider; + this.leafIconProvider = leafIconProvider; } @Override public ITreeRoot getRoot() { - return root; + return TreeManager.treeRoot; } + @Override public AlleleTreeSpecies setPlantType(EnumPlantType type) { - this.nativeType = type; - return this; - } - - public AlleleTreeSpecies setGirth(int girth) { - this.girth = girth; + nativeType = type; return this; } + @Override public AlleleTreeSpecies addFruitFamily(IFruitFamily family) { fruits.add(family); return this; } - public AlleleTreeSpecies setLeafIndices(String ident) { - leafType = leafTypes.get(ident); - return this; - } - - public AlleleTreeSpecies setVanillaMap(int vanillaMeta) { - vanillaMap = vanillaMeta; - return this; - } - /* RESEARCH */ @Override public int getComplexity() { - return 1 + getGeneticAdvancement(this, new ArrayList()); - } - - private int getGeneticAdvancement(IAllele species, ArrayList exclude) { - - int own = 1; - int highest = 0; - exclude.add(species); - - for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { - if (!exclude.contains(mutation.getAllele0())) { - int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude); - if (otherAdvance > highest) { - highest = otherAdvance; - } - } - if (!exclude.contains(mutation.getAllele1())) { - int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude); - if (otherAdvance > highest) { - highest = otherAdvance; - } - } - } - - return own + (highest < 0 ? 0 : highest); + return GeneticsUtil.getResearchComplexity(this, EnumTreeChromosome.SPECIES); } /* OTHER */ @@ -170,105 +83,51 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci } @Override - public ArrayList getSuitableFruit() { + public List getSuitableFruit() { return fruits; } @Override - @SuppressWarnings("rawtypes") - public WorldGenerator getGenerator(ITree tree, World world, int x, int y, int z) { - try { - return generatorClass.getConstructor(new Class[]{ITreeGenData.class}).newInstance(tree); - } catch (Exception ex) { - throw new RuntimeException("Failed to instantiate generator of class " + generatorClass.getName()); - } - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public Class[] getGeneratorClasses() { - return new Class[]{generatorClass}; + public ITreeGenerator getGenerator() { + return generator; } @Override - public short getLeafIconIndex(ITree tree, boolean fancy) { - - if (!fancy) { - return leafType.plainUID; - } - - if (tree.getMate() != null) { - return leafType.changedUID; - } - - return leafType.fancyUID; - } - - public AlleleTreeSpecies setGenerator(Class generatorClass) { - this.generatorClass = generatorClass; - return this; + public IIcon getLeafIcon(boolean pollinated, boolean fancy) { + return leafIconProvider.getIcon(pollinated, fancy); } @Override - public int getLeafColour(ITree tree) { - //if(tree == null) - // return primaryColour; - - //if (tree.getMate() != null) - // return secondaryColour; - //else - return primaryColour; + public int getLeafColour(boolean pollinated) { + return leafIconProvider.getColor(pollinated); } - /* ICONS */ - private int vanillaMap = -1; - @Override public int getIconColour(int renderPass) { - if (renderPass == 0) { - return primaryColour; - } return 0xffffff; } - @SideOnly(Side.CLIENT) - private IIcon icon; - @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { - if (vanillaMap < 0) { - String name = uid.substring("forestry.".length()); - icon = TextureManager.getInstance().registerTex(register, "germlings/sapling." + name); - } else { - icon = Blocks.sapling.getIcon(0, vanillaMap); - } - TextureManager.getInstance().registerTexUID(register, leafType.plainUID, "leaves/" + leafType.ident + ".plain"); - TextureManager.getInstance().registerTexUID(register, leafType.changedUID, "leaves/" + leafType.ident + ".changed"); - TextureManager.getInstance().registerTexUID(register, leafType.fancyUID, "leaves/" + leafType.ident + ".fancy"); + germlingIconProvider.registerIcons(register); } @Override @SideOnly(Side.CLIENT) public IIcon getGermlingIcon(EnumGermlingType type, int renderPass) { - if (type == EnumGermlingType.POLLEN) { - return ForestryItem.pollenCluster.item().getIconFromDamageForRenderPass(0, renderPass); - } - - return icon; + return germlingIconProvider.getIcon(type, renderPass); } - @Override @SideOnly(Side.CLIENT) public int getGermlingColour(EnumGermlingType type, int renderPass) { if (type == EnumGermlingType.SAPLING) { return 0xFFFFFF; } - return getLeafColour(null); + return getLeafColour(false); } - @Override @SideOnly(Side.CLIENT) public IIconProvider getIconProvider() { @@ -281,9 +140,4 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci return TextureManager.getInstance().getIcon(texUID); } - @Override - public ItemStack[] getLogStacks() { - return new ItemStack[]{wood}; - } - } diff --git a/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java b/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java index ee8666312..cf1bcc5e0 100755 --- a/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java +++ b/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java @@ -15,10 +15,10 @@ import net.minecraft.entity.player.EntityPlayer; import com.mojang.authlib.GameProfile; import forestry.api.arboriculture.IArboristTracker; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.core.genetics.BreedingTracker; -import forestry.plugins.PluginArboriculture; public class ArboristTracker extends BreedingTracker implements IArboristTracker { @@ -33,7 +33,7 @@ public class ArboristTracker extends BreedingTracker implements IArboristTracker @Override protected IBreedingTracker getBreedingTracker(EntityPlayer player) { - return PluginArboriculture.treeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()); + return TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()); } @Override diff --git a/src/main/java/forestry/arboriculture/genetics/ITreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/ITreeDefinition.java new file mode 100644 index 000000000..85e54654e --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/ITreeDefinition.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.genetics; + +import net.minecraft.item.ItemStack; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeGenome; +import forestry.core.genetics.IGeneticDefinition; + +public interface ITreeDefinition extends IGeneticDefinition { + @Override + ITreeGenome getGenome(); + + @Override + ITree getIndividual(); + + ItemStack getMemberStack(EnumGermlingType treeType); +} diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 9df7dbd6e..27c3f1c74 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -40,22 +40,18 @@ import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeGenome; import forestry.api.arboriculture.ITreeMutation; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleBoolean; import forestry.api.genetics.IChromosome; import forestry.api.genetics.IEffectData; import forestry.api.genetics.IFruitFamily; import forestry.api.genetics.IMutation; -import forestry.arboriculture.gadgets.ForestryBlockLeaves; -import forestry.arboriculture.gadgets.TileLeaves; import forestry.core.config.Config; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; import forestry.core.genetics.Chromosome; import forestry.core.genetics.Individual; import forestry.core.genetics.alleles.Allele; import forestry.core.utils.StringUtil; -import forestry.plugins.PluginArboriculture; public class Tree extends Individual implements ITree, IPlantable { @@ -83,7 +79,7 @@ public class Tree extends Individual implements ITree, IPlantable { if (nbttagcompound.hasKey("Genome")) { setGenome(new TreeGenome(nbttagcompound.getCompoundTag("Genome"))); } else { - setGenome(PluginArboriculture.treeInterface.templateAsGenome(TreeTemplates.getOakTemplate())); + setGenome(TreeDefinition.Oak.getGenome()); } if (nbttagcompound.hasKey("Mate")) { @@ -155,7 +151,7 @@ public class Tree extends Individual implements ITree, IPlantable { /* GROWTH */ @Override public WorldGenerator getTreeGenerator(World world, int x, int y, int z, boolean wasBonemealed) { - return genome.getPrimary().getGenerator(this, world, x, y, z); + return genome.getPrimary().getGenerator().getWorldGenerator(this); } @Override @@ -223,38 +219,17 @@ public class Tree extends Individual implements ITree, IPlantable { @Override public void setLeaves(World world, GameProfile owner, int x, int y, int z) { - setLeaves(world, owner, x, y, z, false); + genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, false); } @Override public void setLeavesDecorative(World world, GameProfile owner, int x, int y, int z) { - setLeaves(world, owner, x, y, z, true); + genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, true); } - private void setLeaves(World world, GameProfile owner, int x, int y, int z, boolean decorative) { - boolean placed = ForestryBlock.leaves.setBlock(world, x, y, z, 0, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) { - return; - } - - if (!ForestryBlock.leaves.isBlockEqual(world, x, y, z)) { - world.setBlockToAir(x, y, z); - return; - } - - TileLeaves tileLeaves = ForestryBlockLeaves.getLeafTile(world, x, y, z); - if (tileLeaves == null) { - world.setBlockToAir(x, y, z); - return; - } - - tileLeaves.setOwner(owner); - if (decorative) { - tileLeaves.setDecorative(); - } - tileLeaves.setTree(this.copy()); - - world.markBlockForUpdate(x, y, z); + @Override + public void setLogBlock(World world, int x, int y, int z, ForgeDirection facing) { + genome.getPrimary().getGenerator().setLogBlock(world, x, y, z, facing); } @Override @@ -364,7 +339,7 @@ public class Tree extends Individual implements ITree, IPlantable { if (world.rand.nextFloat() <= chance) { if (this.getMate() == null) { - prod.add(PluginArboriculture.treeInterface.getTree(world, new TreeGenome(genome.getChromosomes()))); + prod.add(TreeManager.treeRoot.getTree(world, new TreeGenome(genome.getChromosomes()))); } else { prod.add(createOffspring(world, playerProfile, x, y, z)); } @@ -425,10 +400,10 @@ public class Tree extends Individual implements ITree, IPlantable { IArboristTracker breedingTracker = null; if (playerProfile != null) { - breedingTracker = PluginArboriculture.treeInterface.getBreedingTracker(world, playerProfile); + breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, playerProfile); } - List combinations = PluginArboriculture.treeInterface.getCombinations(allele0, allele1, true); + List combinations = TreeManager.treeRoot.getCombinations(allele0, allele1, true); for (IMutation mutation : combinations) { ITreeMutation treeMutation = (ITreeMutation) mutation; // Stop blacklisted species. @@ -449,7 +424,7 @@ public class Tree extends Individual implements ITree, IPlantable { } if (chance > world.rand.nextFloat() * 100) { - return PluginArboriculture.treeInterface.templateAsChromosomes(treeMutation.getTemplate()); + return TreeManager.treeRoot.templateAsChromosomes(treeMutation.getTemplate()); } } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeBranchDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeBranchDefinition.java new file mode 100644 index 000000000..ea05f932d --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/TreeBranchDefinition.java @@ -0,0 +1,221 @@ +/******************************************************************************* + * 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.genetics; + +import java.util.Arrays; + +import org.apache.commons.lang3.text.WordUtils; + +import forestry.api.arboriculture.EnumTreeChromosome; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleRegistry; +import forestry.api.genetics.IClassification; +import forestry.api.genetics.IClassification.EnumClassLevel; +import forestry.core.genetics.IBranchDefinition; +import forestry.core.genetics.alleles.Allele; +import forestry.core.genetics.alleles.EnumAllele; + +public enum TreeBranchDefinition implements IBranchDefinition { + ACACIA, + ACER, + ADANSONIA, + ASTRONIUM, + BETULA, + CASTANEA, + CEIBA, + CHLOROCARDIUM, + CITRUS, + DALBERGIA, + EBONY("Diospyros"), + JUGLANS, + LARIX, + MAHOGANY("Shorea"), + MILLETTIA, + OCHROMA, + PHOENIX, + PICEA, + PINUS, + POPULUS, + PRUNUS, + PTEROCARPUS, + QUERCUS, + SALIX, + SEQUOIA, + SEQUOIADENDRON, + TABEBUIA, + TALIPARITI, + TECTONA, + TILIA, + + // unclassified + CARICA, + TROPICAL(""),; + + private final IClassification branch; + + TreeBranchDefinition() { + String name = this.name().toLowerCase(); + String scientific = WordUtils.capitalize(name); + branch = new BranchTrees(name, scientific); + } + + TreeBranchDefinition(String scientific) { + String name = this.name().toLowerCase(); + branch = new BranchTrees(name, scientific); + } + + private static IAllele[] defaultTemplate; + + @Override + public IAllele[] getTemplate() { + if (defaultTemplate == null) { + defaultTemplate = new IAllele[EnumTreeChromosome.values().length]; + + Allele.helper.set(defaultTemplate, EnumTreeChromosome.FRUITS, Allele.fruitNone); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.GROWTH, Allele.growthLightlevel); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALL); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOWER); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWEST); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.PLANT, Allele.plantTypeNone); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWEST); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.TERRITORY, EnumAllele.Territory.AVERAGE); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.EFFECT, Allele.leavesNone); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.AVERAGE); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.GIRTH, 1); + Allele.helper.set(defaultTemplate, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.FALSE); + } + return Arrays.copyOf(defaultTemplate, defaultTemplate.length); + } + + @Override + public IClassification getBranch() { + return branch; + } + + public static void createAlleles() { + + IAlleleRegistry alleleRegistry = AlleleManager.alleleRegistry; + + IClassification plantae = alleleRegistry.getClassification("kingdom.plantae"); + + plantae.addMemberGroup( + alleleRegistry.createAndRegisterClassification(EnumClassLevel.DIVISION, "angiosperms", "Angiosperms", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.CLASS, "asterids", "Asterids", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "ericales", "Ericales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "ebenaceae", "Ebenaceae", + EBONY.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "fabaceae", "Fabaceae", + ACACIA.getBranch(), + DALBERGIA.getBranch(), + MILLETTIA.getBranch(), + PTEROCARPUS.getBranch() + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "lamiales", "Lamiales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "bignoniaceae", "Bignoniaceae", + TABEBUIA.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "lamiaceae", "Lamiaceae", + TECTONA.getBranch() + ) + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.CLASS, "commelinids", "Commelinids", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "arecales", "Arecales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "arecaceae", "Arecaceae", + PHOENIX.getBranch() + ) + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.CLASS, "rosids", "Rosids", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "brassicales", "Brassicales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "caricaceae", "Caricaceae") + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "fabales", "Fabales"), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "fagales", "Fagales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "betulaceae", "Betulaceae", + BETULA.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "fagaceae", "Fagaceae", + CASTANEA.getBranch(), + QUERCUS.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "juglandaceae", "Juglandaceae", + JUGLANS.getBranch() + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "rosales", "Rosales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "rosaceae", "Rosaceae", + PRUNUS.getBranch() + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "malvales", "Malvales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "dipterocarpaceae", "Dipterocarpaceae", + MAHOGANY.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "malvaceae", "Malvaceae", + ADANSONIA.getBranch(), + CEIBA.getBranch(), + OCHROMA.getBranch(), + TALIPARITI.getBranch(), + TILIA.getBranch() + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "laurales", "Laurales"), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "malpighiales", "Malpighiales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "salicaceae", "Salicaceae", + CHLOROCARDIUM.getBranch(), + POPULUS.getBranch(), + SALIX.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "lauraceae", "Lauraceae") + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "sapindales", "Sapindales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "rutaceae", "Rutaceae", + CITRUS.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "sapindaceae", "Sapindaceae", + ACER.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "anacardiaceae", "Anacardiaceae", + ASTRONIUM.getBranch() + ) + ) + ) + ) + ); + + plantae.addMemberGroup( + alleleRegistry.createAndRegisterClassification(EnumClassLevel.DIVISION, "pinophyta", "Pinophyta", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.CLASS, "pinopsida", "Pinopsida", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.ORDER, "pinales", "Pinales", + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "pinaceae", "Pinaceae", + PICEA.getBranch(), + PINUS.getBranch(), + LARIX.getBranch() + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.FAMILY, "cupressaceae", "Cupressaceae", + SEQUOIA.getBranch(), + SEQUOIADENDRON.getBranch() + ) + ) + ), + alleleRegistry.createAndRegisterClassification(EnumClassLevel.CLASS, "magnoliopsida", "Magnoliopsida") + ) + ); + + plantae.addMemberGroup( + alleleRegistry.createAndRegisterClassification(EnumClassLevel.DIVISION, "magnoliophyta", "Magnoliophyta") + ); + } +} diff --git a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java new file mode 100644 index 000000000..7de679743 --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java @@ -0,0 +1,1081 @@ +/******************************************************************************* + * 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.genetics; + +import java.awt.Color; +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.arboriculture.EnumFruitFamily; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.EnumLeafType; +import forestry.api.arboriculture.EnumTreeChromosome; +import forestry.api.arboriculture.IAlleleTreeSpeciesCustom; +import forestry.api.arboriculture.IGermlingIconProvider; +import forestry.api.arboriculture.ILeafIconProvider; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeGenerator; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.ITreeMutationCustom; +import forestry.api.arboriculture.TreeManager; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.genetics.IAllele; +import forestry.api.world.ITreeGenData; +import forestry.arboriculture.WoodType; +import forestry.arboriculture.gadgets.ForestryBlockLeaves; +import forestry.arboriculture.gadgets.TileLeaves; +import forestry.arboriculture.render.GermlingIconProvider; +import forestry.arboriculture.render.GermlingVanillaIconProvider; +import forestry.arboriculture.render.LeafIconProvider; +import forestry.arboriculture.worldgen.BlockTypeLog; +import forestry.arboriculture.worldgen.WorldGenAcacia; +import forestry.arboriculture.worldgen.WorldGenAcaciaVanilla; +import forestry.arboriculture.worldgen.WorldGenBalsa; +import forestry.arboriculture.worldgen.WorldGenBaobab; +import forestry.arboriculture.worldgen.WorldGenBirch; +import forestry.arboriculture.worldgen.WorldGenCherry; +import forestry.arboriculture.worldgen.WorldGenChestnut; +import forestry.arboriculture.worldgen.WorldGenCocobolo; +import forestry.arboriculture.worldgen.WorldGenDarkOak; +import forestry.arboriculture.worldgen.WorldGenDate; +import forestry.arboriculture.worldgen.WorldGenEbony; +import forestry.arboriculture.worldgen.WorldGenGiganteum; +import forestry.arboriculture.worldgen.WorldGenGreenheart; +import forestry.arboriculture.worldgen.WorldGenIpe; +import forestry.arboriculture.worldgen.WorldGenJungle; +import forestry.arboriculture.worldgen.WorldGenKapok; +import forestry.arboriculture.worldgen.WorldGenLarch; +import forestry.arboriculture.worldgen.WorldGenLemon; +import forestry.arboriculture.worldgen.WorldGenMahoe; +import forestry.arboriculture.worldgen.WorldGenMahogany; +import forestry.arboriculture.worldgen.WorldGenMaple; +import forestry.arboriculture.worldgen.WorldGenOak; +import forestry.arboriculture.worldgen.WorldGenPadauk; +import forestry.arboriculture.worldgen.WorldGenPapaya; +import forestry.arboriculture.worldgen.WorldGenPine; +import forestry.arboriculture.worldgen.WorldGenPlum; +import forestry.arboriculture.worldgen.WorldGenPoplar; +import forestry.arboriculture.worldgen.WorldGenSequoia; +import forestry.arboriculture.worldgen.WorldGenSpruce; +import forestry.arboriculture.worldgen.WorldGenTeak; +import forestry.arboriculture.worldgen.WorldGenWalnut; +import forestry.arboriculture.worldgen.WorldGenWenge; +import forestry.arboriculture.worldgen.WorldGenWillow; +import forestry.arboriculture.worldgen.WorldGenZebrawood; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.genetics.alleles.Allele; +import forestry.core.genetics.alleles.AlleleBoolean; +import forestry.core.genetics.alleles.EnumAllele; + +public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { + Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 0, new ItemStack(Blocks.log, 1, 0)) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenOak(tree); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitApple); + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void registerMutations() { + // vanilla + } + }, + DarkOak(TreeBranchDefinition.QUERCUS, "darkOak", "velutina", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 5, new ItemStack(Blocks.log2, 1, 1)) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenDarkOak(tree); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void registerMutations() { + // vanilla + } + }, + Birch(TreeBranchDefinition.BETULA, "silverBirch", "pendula", false, EnumLeafType.DECIDUOUS, new Color(8431445), new Color(0xb0c648), 2, new ItemStack(Blocks.log, 1, 2)) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenBirch(tree); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + + } + + @Override + protected void registerMutations() { + // vanilla + } + }, + Lime(TreeBranchDefinition.TILIA, "silverLime", "pendula", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0x5ea107).brighter(), WoodType.LIME) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenDarkOak(tree); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWER); + //Allele.helper.set(alleles, EnumTreeChromosome.EFFECT, Allele.leavesBrimstone); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.NUX) + .addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void registerMutations() { + registerMutation(Birch, Oak, 15); + } + }, + Walnut(TreeBranchDefinition.JUGLANS, "commonWalnut", "regia", true, EnumLeafType.DECIDUOUS, new Color(0x798c55), new Color(0xb0c648), WoodType.WALNUT) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenWalnut(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.NUX) + .addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitWalnut); + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void registerMutations() { + registerMutation(Lime, Cherry, 10); + } + }, + Chestnut(TreeBranchDefinition.CASTANEA, "sweetChestnut", "sativa", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0xb0c648), WoodType.CHESTNUT) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenChestnut(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.NUX) + .addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitChestnut); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void registerMutations() { + registerMutation(Walnut, Lime, 10); + registerMutation(Walnut, Cherry, 10); + } + }, + Cherry(TreeBranchDefinition.PRUNUS, "hillCherry", "serrulata", true, EnumLeafType.DECIDUOUS, new Color(0xe691da), new Color(0xe63e59), WoodType.CHERRY) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenCherry(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitCherry); + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALLER); + } + + @Override + protected void registerMutations() { + registerMutation(Lime, Oak, 10); + registerMutation(Lime, Birch, 10); + } + }, + Lemon(TreeBranchDefinition.CITRUS, "lemon", "limon", true, EnumLeafType.DECIDUOUS, new Color(0x88af54), new Color(0xa3b850), WoodType.CITRUS) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenLemon(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitLemon); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALLEST); + } + + @Override + protected void registerMutations() { + registerMutation(Lime, Cherry, 5); + } + }, + Plum(TreeBranchDefinition.PRUNUS, "plum", "domestica", true, EnumLeafType.DECIDUOUS, new Color(0x589246), new Color(0xa3b850), WoodType.PLUM) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenPlum(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitPlum); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.HIGH); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALLEST); + } + + @Override + protected void registerMutations() { + registerMutation(Lemon, Cherry, 5); + } + }, + Maple(TreeBranchDefinition.ACER, "sugarMaple", "saccharum", true, EnumLeafType.MAPLE, new Color(0xd4f425), new Color(0x619a3c), WoodType.MAPLE) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenMaple(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + } + + @Override + protected void registerMutations() { + registerMutation(Spruce, Larch, 5); + } + }, + Spruce(TreeBranchDefinition.PICEA, "redSpruce", "abies", false, EnumLeafType.CONIFERS, new Color(6396257), new Color(0x539d12), 1, new ItemStack(Blocks.log, 1, 1)) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenSpruce(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); + } + + @Override + protected void registerMutations() { + // vanilla + } + }, + Larch(TreeBranchDefinition.LARIX, "mundaneLarch", "decidua", true, EnumLeafType.CONIFERS, new Color(0x698f90), new Color(0x569896), WoodType.LARCH) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenLarch(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + } + + @Override + protected void registerMutations() { + registerMutation(Spruce, Birch, 10); + registerMutation(Spruce, Oak, 10); + } + }, + Pine(TreeBranchDefinition.PINUS, "bullPine", "sabiniana", true, EnumLeafType.CONIFERS, new Color(0xfeff8f), new Color(0xffd98f), WoodType.PINE) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenPine(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + } + + @Override + protected void registerMutations() { + registerMutation(Spruce, Larch, 10); + } + }, + Sequioa(TreeBranchDefinition.SEQUOIA, "coastSequoia", "sempervirens", false, EnumLeafType.CONIFERS, new Color(0x418e71), new Color(0x569896), WoodType.SEQUOIA) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenSequoia(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGEST); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 3); + Allele.helper.set(alleles, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.TRUE); + } + + @Override + protected void registerMutations() { + registerMutation(Larch, Pine, 5); + } + }, + Gigant(TreeBranchDefinition.SEQUOIADENDRON, "giantSequoia", "giganteum", false, EnumLeafType.CONIFERS, new Color(0x738434), new Color(0x738434).brighter(), WoodType.GIGANTEUM) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenGiganteum(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.GIGANTIC); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWEST); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWEST); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 4); + Allele.helper.set(alleles, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.TRUE); + } + + @Override + protected void registerMutations() { + // 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)) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenJungle(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitCocoa); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGER); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FAST); + } + + @Override + protected void registerMutations() { + // vanilla + } + }, + Teak(TreeBranchDefinition.TECTONA, "teak", "grandis", true, EnumLeafType.JUNGLE, new Color(0xfeff8f), new Color(0xffd98f), WoodType.TEAK) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenTeak(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + } + + @Override + protected void registerMutations() { + registerMutation(DarkOak, Jungle, 10); + } + }, + Ipe(TreeBranchDefinition.TABEBUIA, "ipe", "serratifolia", true, EnumLeafType.JUNGLE, new Color(0xfdd207), new Color(0xad8f04), WoodType.IPE) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenIpe(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void registerMutations() { + registerMutation(Teak, DarkOak, 10); + } + }, + Kapok(TreeBranchDefinition.CEIBA, "kapok", "pentandra", true, EnumLeafType.JUNGLE, new Color(0x89987b), new Color(0x89aa9e), WoodType.KAPOK) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenKapok(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.PRUNES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); + } + + @Override + protected void registerMutations() { + registerMutation(Jungle, Teak, 10); + } + }, + Ebony(TreeBranchDefinition.EBONY, "myrtleEbony", "pentamera", true, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), WoodType.EBONY) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenEbony(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.PRUNES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 3); + } + + @Override + protected void registerMutations() { + registerMutation(DarkOak, Kapok, 10); + } + }, + Zebrawood(TreeBranchDefinition.ASTRONIUM, "zebrawood", "graveolens", false, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), WoodType.ZEBRAWOOD) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenZebrawood(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void registerMutations() { + registerMutation(Ebony, Poplar, 5); + } + }, + Mahogony(TreeBranchDefinition.MAHOGANY, "yellowMeranti", "gibbosa", true, EnumLeafType.JUNGLE, new Color(0x8ab154), new Color(0xa9b154), WoodType.MAHOGANY) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenMahogany(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void registerMutations() { + registerMutation(Kapok, Ebony, 10); + } + }, + AcaciaVanilla(TreeBranchDefinition.ACACIA, "acacia", "aneura", true, EnumLeafType.DECIDUOUS, new Color(0x616101), new Color(0xb3b302), 4, new ItemStack(Blocks.log2, 1, 0)) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenAcaciaVanilla(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + + } + + @Override + protected void registerMutations() { + // vanilla + } + }, + Acacia(TreeBranchDefinition.ACACIA, "desertAcacia", "erioloba", true, EnumLeafType.DECIDUOUS, new Color(0x748C1C), new Color(0xb3b302), WoodType.ACACIA) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenAcacia(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.PLANT, Allele.plantTypeDesert); + } + + @Override + protected void registerMutations() { + registerMutation(Teak, Balsa, 10); + } + }, + Padauk(TreeBranchDefinition.PTEROCARPUS, "padauk", "soyauxii", true, EnumLeafType.DECIDUOUS, new Color(0xd0df8c), new Color(0x435c32), WoodType.PADAUK) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenPadauk(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + } + + @Override + protected void registerMutations() { + registerMutation(AcaciaVanilla, Jungle, 10); + } + }, + Balsa(TreeBranchDefinition.OCHROMA, "balsa", "pyramidale", true, EnumLeafType.DECIDUOUS, new Color(0x59ac00), new Color(0xfeff8f), WoodType.BALSA) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenBalsa(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.HIGH); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + } + + @Override + protected void registerMutations() { + registerMutation(Teak, AcaciaVanilla, 10); + } + }, + Cocobolo(TreeBranchDefinition.DALBERGIA, "cocobolo", "retusa", false, EnumLeafType.DECIDUOUS, new Color(0x6aa17a), new Color(0x487d4c), WoodType.COCOBOLO) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenCocobolo(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGEST); + } + + @Override + protected void registerMutations() { + registerMutation(Acacia, DarkOak, 10); + } + }, + Wenge(TreeBranchDefinition.MILLETTIA, "wenge", "laurentii", true, EnumLeafType.DECIDUOUS, new Color(0xada157), new Color(0xad8a57), WoodType.WENGE) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenWenge(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOWEST); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); + } + + @Override + protected void registerMutations() { + registerMutation(Cocobolo, Balsa, 10); + } + }, + Baobab(TreeBranchDefinition.ADANSONIA, "grandidierBaobab", "digitata", true, EnumLeafType.DECIDUOUS, new Color(0xfeff8f), new Color(0xffd98f), WoodType.BAOBAB) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenBaobab(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.PLANT, Allele.plantTypeDesert); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); + Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 3); + } + + @Override + protected void registerMutations() { + registerMutation(Balsa, Wenge, 10); + } + }, + Mahoe(TreeBranchDefinition.TALIPARITI, "blueMahoe", "elatum", true, EnumLeafType.DECIDUOUS, new Color(0xa0ba1b), new Color(0x79a175), WoodType.MAHOE) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenMahoe(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.POMES) + .addFruitFamily(EnumFruitFamily.PRUNES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALL); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.HIGH); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWEST); + } + + @Override + protected void registerMutations() { + registerMutation(Balsa, Acacia, 5); + } + }, + Willow(TreeBranchDefinition.SALIX, "whiteWillow", "alba", true, EnumLeafType.WILLOW, new Color(0xa3b8a5), new Color(0xa3b850), WoodType.WILLOW) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenWillow(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.NUX) + .addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); + } + + @Override + protected void registerMutations() { + registerMutation(Oak, Birch, 10) + .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) + .restrictHumidity(EnumHumidity.DAMP); + registerMutation(Oak, Lime, 10) + .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) + .restrictHumidity(EnumHumidity.DAMP); + registerMutation(Lime, Birch, 10) + .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) + .restrictHumidity(EnumHumidity.DAMP); + } + }, + Sipiri(TreeBranchDefinition.CHLOROCARDIUM, "sipiri", "rodiei", true, EnumLeafType.DECIDUOUS, new Color(0x678911), new Color(0x79a175), WoodType.GREENHEART) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenGreenheart(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.GROWTH, Allele.growthTropical); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); + } + + @Override + protected void registerMutations() { + registerMutation(Kapok, Mahogony, 10) + .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) + .restrictHumidity(EnumHumidity.DAMP); + } + }, + Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x9ee67f), WoodType.PAPAYA) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenPapaya(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitPapaya); + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + } + + @Override + protected void registerMutations() { + registerMutation(Jungle, Cherry, 5); + } + }, + Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xf0f38f), WoodType.PALM) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenDate(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.JUNGLE) + .addFruitFamily(EnumFruitFamily.NUX); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitDates); + Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); + } + + @Override + protected void registerMutations() { + registerMutation(Jungle, Papaya, 5); + } + }, + Poplar(TreeBranchDefinition.POPULUS, "whitePoplar", "alba", true, EnumLeafType.DECIDUOUS, new Color(0xa3b8a5), new Color(0x539d12), WoodType.POPLAR) { + @Override + public WorldGenerator getWorldGenerator(ITreeGenData tree) { + return new WorldGenPoplar(tree); + } + + @Override + protected void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies) { + treeSpecies.addFruitFamily(EnumFruitFamily.PRUNES) + .addFruitFamily(EnumFruitFamily.POMES); + } + + @Override + protected void setAlleles(IAllele[] alleles) { + Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALL); + Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); + Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER); + } + + @Override + protected void registerMutations() { + registerMutation(Birch, Willow, 5); + registerMutation(Oak, Willow, 5); + registerMutation(Lime, Willow, 5); + } + }; + + private final TreeBranchDefinition branch; + private final IAlleleTreeSpeciesCustom species; + + private final WoodType woodType; // for forestry trees + private final ItemStack vanillaWood; // for vanilla trees + + private IAllele[] template; + private ITreeGenome genome; + + // vanilla tree constructor + TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, int vanillaMeta, ItemStack vanillaWood) { + String uid = "forestry.tree" + this.toString(); + String unlocalizedDescription = "for.description.tree" + this.toString(); + String unlocalizedName = "for.trees.species." + speciesName; + + this.branch = branch; + + ILeafIconProvider leafIconProvider = new LeafIconProvider(leafType, primary, secondary); + IGermlingIconProvider germlingIconProvider = new GermlingVanillaIconProvider(vanillaMeta); + + this.species = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, leafIconProvider, germlingIconProvider, this); + this.woodType = null; + this.vanillaWood = vanillaWood; + } + + // forestry tree constructor + TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, WoodType woodType) { + String uid = "forestry.tree" + this.toString(); + String unlocalizedDescription = "for.description.tree" + this.toString(); + String unlocalizedName = "for.trees.species." + speciesName; + + this.branch = branch; + + ILeafIconProvider leafIconProvider = new LeafIconProvider(leafType, primary, secondary); + IGermlingIconProvider germlingIconProvider = new GermlingIconProvider(uid); + + this.species = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, leafIconProvider, germlingIconProvider, this); + this.woodType = woodType; + this.vanillaWood = null; + } + + protected abstract void setSpeciesProperties(IAlleleTreeSpeciesCustom treeSpecies); + + protected abstract void setAlleles(IAllele[] alleles); + + protected abstract void registerMutations(); + + @Override + public void setLogBlock(World world, int x, int y, int z, ForgeDirection facing) { + if (woodType == null) { + Block vanillaWoodBlock = Block.getBlockFromItem(vanillaWood.getItem()); + int vanillaWoodMeta = vanillaWood.getItemDamage(); + world.setBlock(x, y, z, vanillaWoodBlock, vanillaWoodMeta, Defaults.FLAG_BLOCK_SYNCH); + } else { + AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); + boolean fireproof = fireproofAllele.getValue(); + ItemStack log = woodType.getLog(fireproof); + + BlockTypeLog logBlock = new BlockTypeLog(log); + logBlock.setDirection(facing); + logBlock.setBlock(world, x, y, z); + } + } + + @Override + public void setLeaves(World world, GameProfile owner, int x, int y, int z, boolean decorative) { + boolean placed = ForestryBlock.leaves.setBlock(world, x, y, z, 0, Defaults.FLAG_BLOCK_SYNCH); + if (!placed) { + return; + } + + if (!ForestryBlock.leaves.isBlockEqual(world, x, y, z)) { + world.setBlockToAir(x, y, z); + return; + } + + TileLeaves tileLeaves = ForestryBlockLeaves.getLeafTile(world, x, y, z); + if (tileLeaves == null) { + world.setBlockToAir(x, y, z); + return; + } + + tileLeaves.setOwner(owner); + if (decorative) { + tileLeaves.setDecorative(); + } + tileLeaves.setTree(getIndividual()); + + world.markBlockForUpdate(x, y, z); + } + + public static void initTrees() { + for (TreeDefinition tree : values()) { + tree.init(); + } + for (TreeDefinition tree : values()) { + tree.registerMutations(); + } + } + + private void init() { + setSpeciesProperties(species); + + template = branch.getTemplate(); + Allele.helper.set(template, EnumTreeChromosome.SPECIES, species); + setAlleles(template); + + genome = TreeManager.treeRoot.templateAsGenome(template); + + TreeManager.treeRoot.registerTemplate(template); + } + + protected final ITreeMutationCustom registerMutation(TreeDefinition parent1, TreeDefinition parent2, int chance) { + return TreeManager.treeMutationFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance); + } + + @Override + public final IAllele[] getTemplate() { + return Arrays.copyOf(template, template.length); + } + + @Override + public final ITreeGenome getGenome() { + return genome; + } + + @Override + public final ITree getIndividual() { + return new Tree(genome); + } + + @Override + public final ItemStack getMemberStack(EnumGermlingType treeType) { + ITree tree = getIndividual(); + return TreeManager.treeRoot.getMemberStack(tree, treeType.ordinal()); + } +} diff --git a/src/main/java/forestry/arboriculture/genetics/TreeFactory.java b/src/main/java/forestry/arboriculture/genetics/TreeFactory.java new file mode 100644 index 000000000..b0ce62af2 --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/TreeFactory.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.genetics; + +import java.awt.Color; + +import forestry.api.arboriculture.EnumLeafType; +import forestry.api.arboriculture.IAlleleTreeSpeciesCustom; +import forestry.api.arboriculture.IGermlingIconProvider; +import forestry.api.arboriculture.ILeafIconProvider; +import forestry.api.arboriculture.ITreeFactory; +import forestry.api.arboriculture.ITreeGenerator; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IClassification; +import forestry.arboriculture.render.LeafIconProvider; + +public class TreeFactory implements ITreeFactory { + @Override + public IAlleleTreeSpeciesCustom createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, ILeafIconProvider leafIconProvider, IGermlingIconProvider germlingIconProvider, ITreeGenerator generator) { + IAlleleTreeSpeciesCustom treeSpecies = new AlleleTreeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, leafIconProvider, germlingIconProvider, generator); + AlleleManager.alleleRegistry.registerAllele(treeSpecies); + return treeSpecies; + } + + @Override + public ILeafIconProvider getLeafIconProvider(EnumLeafType enumLeafType, Color color, Color colorPollinated) { + return new LeafIconProvider(enumLeafType, color, colorPollinated); + } +} diff --git a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java index 0ad9f99d2..df0c915ec 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java @@ -25,6 +25,7 @@ import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.IGrowthProvider; import forestry.api.arboriculture.ITreeGenome; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IAlleleFloat; import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IAlleleSpecies; @@ -32,7 +33,6 @@ import forestry.api.genetics.IChromosome; import forestry.api.genetics.ISpeciesRoot; import forestry.core.genetics.Genome; import forestry.core.genetics.alleles.AllelePlantType; -import forestry.plugins.PluginArboriculture; public class TreeGenome extends Genome implements ITreeGenome { @@ -51,7 +51,7 @@ public class TreeGenome extends Genome implements ITreeGenome { return (IAlleleTreeSpecies) species; } - return (IAlleleTreeSpecies) getActiveAllele(itemStack, EnumTreeChromosome.SPECIES, PluginArboriculture.treeInterface); + return (IAlleleTreeSpecies) getActiveAllele(itemStack, EnumTreeChromosome.SPECIES, TreeManager.treeRoot); } @Override @@ -116,7 +116,7 @@ public class TreeGenome extends Genome implements ITreeGenome { @Override public ISpeciesRoot getSpeciesRoot() { - return PluginArboriculture.treeInterface; + return TreeManager.treeRoot; } } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index 1e73ece6e..36355116f 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; +import java.util.List; import java.util.Locale; import java.util.Map.Entry; @@ -39,6 +40,7 @@ import forestry.api.arboriculture.ITreeGenome; import forestry.api.arboriculture.ITreeMutation; import forestry.api.arboriculture.ITreeRoot; import forestry.api.arboriculture.ITreekeepingMode; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IChromosomeType; @@ -205,7 +207,6 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { TileSapling sapling = (TileSapling) tile; sapling.setTree(tree.copy()); sapling.setOwner(owner); - world.markBlockForUpdate(x, y, z); return true; } @@ -330,20 +331,20 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { @Override public void registerTemplate(String identifier, IAllele[] template) { - treeTemplates.add(new Tree(PluginArboriculture.treeInterface.templateAsGenome(template))); + treeTemplates.add(new Tree(TreeManager.treeRoot.templateAsGenome(template))); speciesTemplates.put(identifier, template); } @Override public IAllele[] getDefaultTemplate() { - return TreeTemplates.getDefaultTemplate(); + return TreeDefinition.Oak.getTemplate(); } /* MUTATIONS */ - private static final ArrayList treeMutations = new ArrayList(); + private static final List treeMutations = new ArrayList(); @Override - public ArrayList getMutations(boolean shuffle) { + public List getMutations(boolean shuffle) { if (shuffle) { Collections.shuffle(treeMutations); } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeMutation.java b/src/main/java/forestry/arboriculture/genetics/TreeMutation.java index 8d2c56a90..23b0c643b 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeMutation.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeMutation.java @@ -14,28 +14,21 @@ import net.minecraft.world.World; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITreeGenome; -import forestry.api.arboriculture.ITreeMutation; +import forestry.api.arboriculture.ITreeMutationCustom; import forestry.api.arboriculture.ITreeRoot; -import forestry.api.genetics.AlleleManager; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IAllele; -import forestry.api.genetics.IAlleleSpecies; import forestry.core.genetics.Mutation; -import forestry.plugins.PluginArboriculture; -public class TreeMutation extends Mutation implements ITreeMutation { +public class TreeMutation extends Mutation implements ITreeMutationCustom { - private final ITreeRoot root; - - public TreeMutation(IAlleleSpecies allele0, IAlleleSpecies allele1, IAllele[] template, int chance) { + public TreeMutation(IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, IAllele[] template, int chance) { super(allele0, allele1, template, chance); - - root = (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); - PluginArboriculture.treeInterface.registerMutation(this); } @Override public ITreeRoot getRoot() { - return root; + return TreeManager.treeRoot; } @Override @@ -45,7 +38,7 @@ public class TreeMutation extends Mutation implements ITreeMutation { return 0; } - processedChance *= PluginArboriculture.treeInterface.getTreekeepingMode(world).getMutationModifier(genome0, genome1, 1f); + processedChance *= getRoot().getTreekeepingMode(world).getMutationModifier(genome0, genome1, 1f); return processedChance; } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeMutationFactory.java b/src/main/java/forestry/arboriculture/genetics/TreeMutationFactory.java new file mode 100644 index 000000000..23af72f92 --- /dev/null +++ b/src/main/java/forestry/arboriculture/genetics/TreeMutationFactory.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.genetics; + +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.arboriculture.ITreeMutationCustom; +import forestry.api.arboriculture.ITreeMutationFactory; +import forestry.api.arboriculture.TreeManager; +import forestry.api.genetics.IAllele; + +public class TreeMutationFactory implements ITreeMutationFactory { + + @Override + public ITreeMutationCustom createMutation(IAlleleTreeSpecies parent0, IAlleleTreeSpecies parent1, IAllele[] result, int chance) { + ITreeMutationCustom mutation = new TreeMutation(parent0, parent1, result, chance); + TreeManager.treeRoot.registerMutation(mutation); + return mutation; + } +} diff --git a/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java b/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java deleted file mode 100755 index 1a5e3eb2c..000000000 --- a/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java +++ /dev/null @@ -1,448 +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.genetics; - -import forestry.api.arboriculture.EnumTreeChromosome; -import forestry.api.arboriculture.ITreeGenome; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IMutation; -import forestry.core.genetics.Chromosome; -import forestry.core.genetics.alleles.Allele; -import forestry.core.genetics.alleles.EnumAllele; - -public class TreeTemplates { - - /* MUTATIONS */ - public static IMutation larchA; - public static IMutation larchB; - public static IMutation pineA; - public static IMutation sequoiaA; - - public static IMutation limeA; - - public static IMutation cherryA; - public static IMutation cherryB; - - public static IMutation walnutA; - public static IMutation chestnutA; - public static IMutation chestnutB; - - public static IMutation teakA; - public static IMutation kapokA; - public static IMutation ebonyA; - public static IMutation mahoganyA; - - public static IMutation balsaA; - public static IMutation acaciaA; - public static IMutation wengeA; - public static IMutation baobabA; - - public static IMutation willowA; - public static IMutation willowB; - public static IMutation willowC; - - public static IMutation sipiriA; - - public static IMutation mahoeA; - - public static IMutation poplarA; - public static IMutation poplarB; - public static IMutation poplarC; - - public static IMutation lemonA; - public static IMutation plumA; - - public static IMutation mapleA; - - public static IMutation papayaA; - public static IMutation dateA; - - public static IMutation ipeA; - public static TreeMutation padaukA; - public static TreeMutation cocoboloA; - public static TreeMutation zebrawoodA; - - /* TEMPLATES */ - public static IAllele[] getDefaultTemplate() { - IAllele[] alleles = new IAllele[EnumTreeChromosome.values().length]; - - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeOak); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitNone); - Allele.helper.set(alleles, EnumTreeChromosome.GROWTH, Allele.growthLightlevel); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALL); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWEST); - Allele.helper.set(alleles, EnumTreeChromosome.PLANT, Allele.plantTypeNone); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWEST); - Allele.helper.set(alleles, EnumTreeChromosome.TERRITORY, EnumAllele.Territory.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.EFFECT, Allele.leavesNone); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 1); - Allele.helper.set(alleles, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.FALSE); - - return alleles; - } - - public static IAllele[] getOakTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitApple); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); - return alleles; - } - - public static IAllele[] getBirchTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeBirch); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); - return alleles; - } - - public static IAllele[] getSpruceTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeSpruce); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); - return alleles; - } - - public static IAllele[] getJungleTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeJungle); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitCocoa); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGER); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FAST); - return alleles; - } - - public static IAllele[] getAcaciaTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeAcacia); - return alleles; - } - - public static IAllele[] getDarkOakTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeDarkOak); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - public static IAllele[] getBalsaTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeBalsa); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.HIGH); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - return alleles; - } - - public static IAllele[] getSequoiaTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeSequioa); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGEST); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 3); - Allele.helper.set(alleles, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.TRUE); - return alleles; - } - - public static IAllele[] getGiganteumTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeGiganteum); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.GIGANTIC); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWEST); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWEST); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 4); - Allele.helper.set(alleles, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.TRUE); - return alleles; - } - - public static IAllele[] getLarchTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeLarch); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - return alleles; - } - - public static IAllele[] getPineTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treePine); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - return alleles; - } - - public static IAllele[] getCherryTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeCherry); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitCherry); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALLER); - return alleles; - } - - public static IAllele[] getLimeTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeLime); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWER); - //Allele.helper.set(alleles, EnumTreeChromosome.EFFECT, Allele.leavesBrimstone); - return alleles; - } - - public static IAllele[] getTeakTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeTeak); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - return alleles; - } - - public static IAllele[] getKapokTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeKapok); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); - return alleles; - } - - public static IAllele[] getEbonyTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeEbony); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 3); - return alleles; - } - - public static IAllele[] getMahoganyTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeMahogany); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - public static IAllele[] getChestnutTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeChestnut); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitChestnut); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - public static IAllele[] getDesertAcaciaTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeDesertAcacia); - Allele.helper.set(alleles, EnumTreeChromosome.PLANT, Allele.plantTypeDesert); - return alleles; - } - - public static IAllele[] getWengeTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeWenge); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOWEST); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - public static IAllele[] getBaobabTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeBaobab); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.PLANT, Allele.plantTypeDesert); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 3); - return alleles; - } - - public static IAllele[] getWalnutTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeWalnut); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitWalnut); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - public static IAllele[] getWillowTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeWillow); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER); - return alleles; - } - - public static IAllele[] getSipiriTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeSipiri); - Allele.helper.set(alleles, EnumTreeChromosome.GROWTH, Allele.growthTropical); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW); - return alleles; - } - - public static IAllele[] getMahoeTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeMahoe); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALL); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.HIGH); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWEST); - return alleles; - } - - public static IAllele[] getPoplarTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treePoplar); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALL); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER); - return alleles; - } - - public static IAllele[] getLemonTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeLemon); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitLemon); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALLEST); - return alleles; - } - - public static IAllele[] getPlumTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treePlum); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitPlum); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.HIGH); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.AVERAGE); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.SMALLEST); - return alleles; - } - - public static IAllele[] getMapleTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeMaple); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - return alleles; - } - - public static IAllele[] getPapayaTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treePapaya); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitPapaya); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - return alleles; - } - - public static IAllele[] getDateTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeDate); - Allele.helper.set(alleles, EnumTreeChromosome.FRUITS, Allele.fruitDates); - Allele.helper.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE); - return alleles; - } - - public static IAllele[] getIpeTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeIpe); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - public static IAllele[] getPadaukTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treePadauk); - Allele.helper.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - return alleles; - } - - public static IAllele[] getCocoboloTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeCocobolo); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGEST); - return alleles; - } - - public static IAllele[] getZebrawoodTemplate() { - IAllele[] alleles = getDefaultTemplate(); - Allele.helper.set(alleles, EnumTreeChromosome.SPECIES, Allele.treeZebrawood); - Allele.helper.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE); - Allele.helper.set(alleles, EnumTreeChromosome.GIRTH, 2); - return alleles; - } - - // / HELPER FUNCTIONS - - public static Chromosome[] templateAsChromosomes(IAllele[] template) { - Chromosome[] chromosomes = new Chromosome[template.length]; - for (int i = 0; i < template.length; i++) { - if (template[i] != null) { - chromosomes[i] = new Chromosome(template[i]); - } - } - - return chromosomes; - } - - public static Chromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive) { - Chromosome[] chromosomes = new Chromosome[templateActive.length]; - for (int i = 0; i < templateActive.length; i++) { - if (templateActive[i] != null) { - chromosomes[i] = new Chromosome(templateActive[i], templateInactive[i]); - } - } - - return chromosomes; - } - - public static ITreeGenome templateAsGenome(IAllele[] template) { - return new TreeGenome(templateAsChromosomes(template)); - } - - public static ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) { - return new TreeGenome(templateAsChromosomes(templateActive, templateInactive)); - } -} diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index 1edd1dee6..66b6ea163 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -27,6 +27,7 @@ import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleGrowth; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IFruitFamily; @@ -40,7 +41,6 @@ import forestry.core.genetics.alleles.AllelePlantType; import forestry.core.gui.ContainerAlyzer; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; -import forestry.plugins.PluginArboriculture; public class GuiTreealyzer extends GuiAlyzer { @@ -72,8 +72,8 @@ public class GuiTreealyzer extends GuiAlyzer { if (inventory.getStackInSlot(k) == null) { continue; } - tree = PluginArboriculture.treeInterface.getMember(inventory.getStackInSlot(k)); - treeType = PluginArboriculture.treeInterface.getType(inventory.getStackInSlot(k)); + tree = TreeManager.treeRoot.getMember(inventory.getStackInSlot(k)); + treeType = TreeManager.treeRoot.getType(inventory.getStackInSlot(k)); if (tree == null || !tree.isAnalyzed()) { continue; } diff --git a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java index f0de55852..5ee9bdbbf 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java +++ b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java @@ -23,9 +23,9 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.core.Tabs; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IIndividual; @@ -33,6 +33,7 @@ import forestry.api.genetics.IPollinatable; import forestry.api.recipes.IVariableFermentable; import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.arboriculture.genetics.Tree; +import forestry.arboriculture.genetics.TreeDefinition; import forestry.arboriculture.genetics.TreeGenome; import forestry.core.config.Config; import forestry.core.genetics.ItemGE; @@ -42,7 +43,6 @@ import forestry.core.render.SpriteSheet; import forestry.core.utils.GeneticsUtil; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; -import forestry.plugins.PluginArboriculture; public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @@ -64,10 +64,10 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { return TreeGenome.getSpecies(itemStack); } - private IAlleleTreeSpecies getSpeciesOrDefault(ItemStack itemstack) { + private static IAlleleTreeSpecies getSpeciesOrDefault(ItemStack itemstack) { IAlleleTreeSpecies treeSpecies = TreeGenome.getSpecies(itemstack); if (treeSpecies == null) { - treeSpecies = (IAlleleTreeSpecies) PluginArboriculture.treeInterface.getDefaultTemplate()[EnumTreeChromosome.SPECIES.ordinal()]; + treeSpecies = TreeDefinition.Oak.getGenome().getPrimary(); } return treeSpecies; @@ -105,13 +105,13 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @SuppressWarnings({"rawtypes", "unchecked"}) public void addCreativeItems(List itemList, boolean hideSecrets) { - for (IIndividual individual : PluginArboriculture.treeInterface.getIndividualTemplates()) { + for (IIndividual individual : TreeManager.treeRoot.getIndividualTemplates()) { // Don't show secrets unless ordered to. if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; } - itemList.add(PluginArboriculture.treeInterface.getMemberStack(individual, type.ordinal())); + itemList.add(TreeManager.treeRoot.getMemberStack(individual, type.ordinal())); } } @@ -145,12 +145,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float facingX, float facingY, float facingZ) { - - if (!Proxies.common.isSimulating(world)) { - return false; - } - - ITree tree = PluginArboriculture.treeInterface.getMember(itemstack); + ITree tree = TreeManager.treeRoot.getMember(itemstack); if (tree == null) { return false; } @@ -171,7 +166,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { return false; } - if (PluginArboriculture.treeInterface.plantSapling(world, tree, player.getGameProfile(), x, y + yShift, z)) { + if (TreeManager.treeRoot.plantSapling(world, tree, player.getGameProfile(), x, y + yShift, z)) { Proxies.common.addBlockPlaceEffects(world, x, y, z, world.getBlock(x, y + yShift, z), 0); if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; @@ -213,7 +208,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { @Override public float getFermentationModifier(ItemStack itemstack) { - ITree tree = PluginArboriculture.treeInterface.getMember(itemstack); + ITree tree = TreeManager.treeRoot.getMember(itemstack); if (tree == null) { return 1.0f; } diff --git a/src/main/java/forestry/arboriculture/items/ItemStairs.java b/src/main/java/forestry/arboriculture/items/ItemStairs.java deleted file mode 100755 index eec9357dc..000000000 --- a/src/main/java/forestry/arboriculture/items/ItemStairs.java +++ /dev/null @@ -1,88 +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.items; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import forestry.arboriculture.WoodType; -import forestry.arboriculture.gadgets.TileStairs; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.items.ItemForestryBlock; -import forestry.core.utils.StringUtil; - -public class ItemStairs extends ItemForestryBlock { - - public ItemStairs(Block block) { - super(block); - } - - @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) { - - WoodType type = WoodType.getFromCompound(stack.getTagCompound()); - return placeStairs(world, player, stack, type, x, y, z, metadata); - - } - - private boolean placeStairs(World world, EntityPlayer player, ItemStack stack, WoodType type, int x, int y, int z, int metadata) { - - boolean placed = ForestryBlock.stairs.setBlock(world, x, y, z, metadata, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) { - return false; - } - - Block block = world.getBlock(x, y, z); - - if (!ForestryBlock.stairs.isBlockEqual(block)) { - return false; - } - - block.onBlockPlacedBy(world, x, y, z, player, stack); - block.onPostBlockPlaced(world, x, y, z, metadata); - - TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileStairs)) { - world.setBlockToAir(x, y, z); - return false; - } - - ((TileStairs) tile).setWoodType(type); - return true; - } - - @Override - public String getItemStackDisplayName(ItemStack itemStack) { - WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); - if (woodType == null) { - return null; - } - - String displayName; - String customUnlocalizedName = "stairs." + woodType.ordinal() + ".name"; - if (StringUtil.canTranslateTile(customUnlocalizedName)) { - displayName = StringUtil.localizeTile(customUnlocalizedName); - } else { - String woodGrammar = StringUtil.localize("stairs.grammar"); - String woodTypeName = StringUtil.localize("trees.woodType." + woodType); - - displayName = woodGrammar.replaceAll("%TYPE", woodTypeName); - } - - return displayName; - } - -} diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index 726ee4ab0..88c9fa630 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.core.config.Config; @@ -25,7 +26,6 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.GeneticsUtil; -import forestry.plugins.PluginArboriculture; public class ItemTreealyzer extends ItemInventoried { @@ -47,13 +47,13 @@ public class ItemTreealyzer extends ItemInventoried { return; } - if (!PluginArboriculture.treeInterface.isMember(getStackInSlot(SLOT_SPECIMEN))) { + if (!TreeManager.treeRoot.isMember(getStackInSlot(SLOT_SPECIMEN))) { ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_SPECIMEN)); if (ersatz != null) { setInventorySlotContents(SLOT_SPECIMEN, ersatz); } } - ITree tree = PluginArboriculture.treeInterface.getMember(getStackInSlot(SLOT_SPECIMEN)); + ITree tree = TreeManager.treeRoot.getMember(getStackInSlot(SLOT_SPECIMEN)); // No tree, abort if (tree == null) { return; @@ -69,8 +69,8 @@ public class ItemTreealyzer extends ItemInventoried { tree.analyze(); if (player != null) { - PluginArboriculture.treeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getPrimary()); - PluginArboriculture.treeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getSecondary()); + TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getPrimary()); + TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getSecondary()); } NBTTagCompound nbttagcompound = new NBTTagCompound(); tree.writeToNBT(nbttagcompound); diff --git a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java index 6c04f528b..f33254ab7 100755 --- a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java @@ -10,12 +10,18 @@ ******************************************************************************/ package forestry.arboriculture.items; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; -import forestry.arboriculture.IWoodFireproof; import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; +import forestry.arboriculture.gadgets.TileWood; +import forestry.core.config.Defaults; import forestry.core.items.ItemForestryBlock; import forestry.core.utils.StringUtil; @@ -25,33 +31,74 @@ public class ItemWoodBlock extends ItemForestryBlock { super(block); } + public static boolean placeWood(ItemStack stack, @Nullable EntityPlayer player, World world, int x, int y, int z, int metadata) { + WoodType woodType = WoodType.getFromCompound(stack.getTagCompound()); + Block block = Block.getBlockFromItem(stack.getItem()); + + boolean placed = world.setBlock(x, y, z, block, metadata, Defaults.FLAG_BLOCK_SYNCH); + if (!placed) { + return false; + } + + Block worldBlock = world.getBlock(x, y, z); + if (!Block.isEqualTo(block, worldBlock)) { + return false; + } + + TileEntity tile = world.getTileEntity(x, y, z); + if (!(tile instanceof TileWood)) { + world.setBlockToAir(x, y, z); + return false; + } + + if (player != null) { + worldBlock.onBlockPlacedBy(world, x, y, z, player, stack); + worldBlock.onPostBlockPlaced(world, x, y, z, metadata); + } + + ((TileWood) tile).setWoodType(woodType); + return true; + } + + @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); + } + @Override public String getItemStackDisplayName(ItemStack itemstack) { - if (this.getBlock() instanceof IWoodTyped) { - IWoodTyped block = (IWoodTyped) getBlock(); - int meta = itemstack.getItemDamage(); - WoodType woodType = block.getWoodType(meta); - if (woodType == null) { - return null; - } - - String displayName; - String customUnlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name"; - if (StringUtil.canTranslateTile(customUnlocalizedName)) { - displayName = StringUtil.localizeTile(customUnlocalizedName); - } else { - String woodGrammar = StringUtil.localize(block.getBlockKind() + ".grammar"); - String woodTypeName = StringUtil.localize("trees.woodType." + woodType); - - displayName = woodGrammar.replaceAll("%TYPE", woodTypeName); - } - - if (this.getBlock() instanceof IWoodFireproof) { - displayName = StringUtil.localizeAndFormatRaw("tile.for.fireproof", displayName); - } - - return displayName; + Block block = getBlock(); + if (!(block instanceof IWoodTyped)) { + return super.getItemStackDisplayName(itemstack); } - return super.getItemStackDisplayName(itemstack); + + WoodType woodType = getWood(itemstack); + if (woodType == null) { + return super.getItemStackDisplayName(itemstack); + } + + IWoodTyped wood = (IWoodTyped) block; + String blockKind = wood.getBlockKind(); + + String displayName; + String customUnlocalizedName = blockKind + "." + woodType.ordinal() + ".name"; + if (StringUtil.canTranslateTile(customUnlocalizedName)) { + displayName = StringUtil.localizeTile(customUnlocalizedName); + } else { + String woodGrammar = StringUtil.localize(blockKind + ".grammar"); + String woodTypeName = StringUtil.localize("trees.woodType." + woodType); + + displayName = woodGrammar.replaceAll("%TYPE", woodTypeName); + } + + if (wood.isFireproof()) { + displayName = StringUtil.localizeAndFormatRaw("tile.for.fireproof", displayName); + } + + return displayName; + } + + private static WoodType getWood(ItemStack itemStack) { + return WoodType.getFromCompound(itemStack.getTagCompound()); } } diff --git a/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java b/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java index 47c167964..542d6deba 100755 --- a/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java +++ b/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java @@ -19,7 +19,10 @@ import cpw.mods.fml.client.registry.RenderingRegistry; import forestry.arboriculture.render.FenceRenderingHandler; import forestry.arboriculture.render.FruitPodRenderingHandler; import forestry.arboriculture.render.LeavesRenderingHandler; +import forestry.arboriculture.render.LogItemRenderer; +import forestry.arboriculture.render.PlankItemRenderer; import forestry.arboriculture.render.SaplingRenderHandler; +import forestry.arboriculture.render.SlabItemRenderer; import forestry.arboriculture.render.StairItemRenderer; import forestry.core.config.ForestryBlock; import forestry.plugins.PluginArboriculture; @@ -37,7 +40,21 @@ public class ClientProxyArboriculture extends ProxyArboriculture { RenderingRegistry.registerBlockHandler(new FenceRenderingHandler()); RenderingRegistry.registerBlockHandler(new FruitPodRenderingHandler()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.logs.item(), new LogItemRenderer()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.logsFireproof.item(), new LogItemRenderer()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.stairs.item(), new StairItemRenderer()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.stairsFireproof.item(), new StairItemRenderer()); + + MinecraftForgeClient.registerItemRenderer(ForestryBlock.planks.item(), new PlankItemRenderer()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.planksFireproof.item(), new PlankItemRenderer()); + + MinecraftForgeClient.registerItemRenderer(ForestryBlock.slabs.item(), new SlabItemRenderer()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.slabsFireproof.item(), new SlabItemRenderer()); + + MinecraftForgeClient.registerItemRenderer(ForestryBlock.fences.item(), new FenceRenderingHandler()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.fencesFireproof.item(), new FenceRenderingHandler()); + MinecraftForgeClient.registerItemRenderer(ForestryBlock.leaves.item(), new LeavesRenderingHandler()); } diff --git a/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java b/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java index 220c364b7..238e5d130 100755 --- a/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java @@ -14,21 +14,83 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import net.minecraftforge.client.IItemRenderer; + import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import org.lwjgl.opengl.GL11; +import forestry.arboriculture.WoodType; import forestry.plugins.PluginArboriculture; -public class FenceRenderingHandler implements ISimpleBlockRenderingHandler { +public class FenceRenderingHandler implements ISimpleBlockRenderingHandler, IItemRenderer { @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + // uses IItemRenderer + } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return renderer.renderBlockFence((BlockFence) block, x, y, z); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return PluginArboriculture.modelIdFences; + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, true); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderItem((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f, true); + break; + case INVENTORY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, false); + break; + default: + } + } + + private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z, boolean fullBlock) { Tessellator tess = Tessellator.instance; + WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); + IIcon plankIcon = woodType.getPlankIcon(); + Block block = Block.getBlockFromItem(itemStack.getItem()); + for (int i = 0; i < 4; ++i) { float thickness = 0.125F; @@ -56,49 +118,38 @@ public class FenceRenderingHandler implements ISimpleBlockRenderingHandler { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tess.startDrawingQuads(); tess.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); tess.draw(); + tess.startDrawingQuads(); tess.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, plankIcon); tess.draw(); + tess.startDrawingQuads(); tess.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); tess.draw(); + tess.startDrawingQuads(); tess.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, plankIcon); tess.draw(); + tess.startDrawingQuads(); tess.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); tess.draw(); + tess.startDrawingQuads(); tess.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, plankIcon); tess.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); } block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); renderer.setRenderBoundsFromBlock(block); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return renderer.renderBlockFence((BlockFence) block, x, y, z); - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return PluginArboriculture.modelIdFences; - } - } diff --git a/src/main/java/forestry/arboriculture/render/GermlingIconProvider.java b/src/main/java/forestry/arboriculture/render/GermlingIconProvider.java new file mode 100644 index 000000000..e76f24050 --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/GermlingIconProvider.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.render; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IGermlingIconProvider; +import forestry.core.config.ForestryItem; +import forestry.core.render.TextureManager; + +public class GermlingIconProvider implements IGermlingIconProvider { + + private final String name; + + private IIcon icon; + + public GermlingIconProvider(String uid) { + this.name = uid.substring("forestry.".length()); + } + + @Override + public void registerIcons(IIconRegister register) { + TextureManager textureManager = TextureManager.getInstance(); + + icon = textureManager.registerTex(register, "germlings/sapling." + name); + } + + @Override + public IIcon getIcon(EnumGermlingType type, int renderPass) { + if (type == EnumGermlingType.POLLEN) { + return ForestryItem.pollenCluster.item().getIconFromDamageForRenderPass(0, renderPass); + } + + return icon; + } +} diff --git a/src/main/java/forestry/arboriculture/render/GermlingVanillaIconProvider.java b/src/main/java/forestry/arboriculture/render/GermlingVanillaIconProvider.java new file mode 100644 index 000000000..ea16c8af5 --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/GermlingVanillaIconProvider.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.render; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IGermlingIconProvider; +import forestry.core.config.ForestryItem; + +public class GermlingVanillaIconProvider implements IGermlingIconProvider { + private final int vanillaMap; + + private IIcon icon; + + public GermlingVanillaIconProvider(int vanillaMap) { + this.vanillaMap = vanillaMap; + } + + @Override + public void registerIcons(IIconRegister register) { + icon = Blocks.sapling.getIcon(0, vanillaMap); + } + + @Override + public IIcon getIcon(EnumGermlingType type, int renderPass) { + if (type == EnumGermlingType.POLLEN) { + return ForestryItem.pollenCluster.item().getIconFromDamageForRenderPass(0, renderPass); + } + + return icon; + } +} diff --git a/src/main/java/forestry/arboriculture/render/LeafIconProvider.java b/src/main/java/forestry/arboriculture/render/LeafIconProvider.java new file mode 100644 index 000000000..daa18ba14 --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/LeafIconProvider.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.render; + +import java.awt.Color; + +import net.minecraft.util.IIcon; + +import forestry.api.arboriculture.EnumLeafType; +import forestry.api.arboriculture.ILeafIconProvider; + +public class LeafIconProvider implements ILeafIconProvider { + + private final LeafTexture leafTexture; + private final int color; + private final int colorPollinated; + + public LeafIconProvider(EnumLeafType leafType, Color color, Color colorPollinated) { + this.leafTexture = LeafTexture.get(leafType); + this.color = color.getRGB(); + this.colorPollinated = colorPollinated.getRGB(); + } + + @Override + public int getColor(boolean pollinated) { + if (pollinated) { + return colorPollinated; + } else { + return color; + } + } + + @Override + public IIcon getIcon(boolean pollinated, boolean fancy) { + if (pollinated) { + return leafTexture.getPollinated(); + } else if (fancy) { + return leafTexture.getFancy(); + } else { + return leafTexture.getPlain(); + } + } + +} + diff --git a/src/main/java/forestry/arboriculture/render/LeafTexture.java b/src/main/java/forestry/arboriculture/render/LeafTexture.java new file mode 100644 index 000000000..32304c628 --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/LeafTexture.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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.render; + +import java.util.EnumMap; +import java.util.Locale; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import forestry.api.arboriculture.EnumLeafType; +import forestry.core.render.TextureManager; + +public class LeafTexture { + private static final Map leafTextures = new EnumMap(EnumLeafType.class); + + static { + for (EnumLeafType leafType : EnumLeafType.values()) { + leafTextures.put(leafType, new LeafTexture(leafType)); + } + } + + public static LeafTexture get(EnumLeafType leafType) { + return leafTextures.get(leafType); + } + + public static void registerAllIcons(IIconRegister register) { + for (LeafTexture leafTexture : leafTextures.values()) { + leafTexture.registerIcons(register); + } + } + + private final EnumLeafType leafType; + + private IIcon plain; + private IIcon pollinated; + private IIcon fancy; + + private LeafTexture(EnumLeafType enumLeafType) { + this.leafType = enumLeafType; + } + + private void registerIcons(IIconRegister register) { + TextureManager textureManager = TextureManager.getInstance(); + + String ident = leafType.toString().toLowerCase(Locale.ENGLISH); + + plain = textureManager.registerTex(register, "leaves/" + ident + ".plain"); + pollinated = textureManager.registerTex(register, "leaves/" + ident + ".changed"); + fancy = textureManager.registerTex(register, "leaves/" + ident + ".fancy"); + } + + public IIcon getPlain() { + return plain; + } + + public IIcon getPollinated() { + return pollinated; + } + + public IIcon getFancy() { + return fancy; + } +} \ No newline at end of file diff --git a/src/main/java/forestry/arboriculture/render/LogItemRenderer.java b/src/main/java/forestry/arboriculture/render/LogItemRenderer.java new file mode 100644 index 000000000..618db75bc --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/LogItemRenderer.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * 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.render; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import forestry.arboriculture.WoodType; +import forestry.arboriculture.items.ItemWoodBlock; +import forestry.core.utils.StackUtils; + +public class LogItemRenderer implements IItemRenderer { + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, true); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderItem((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f, true); + break; + case INVENTORY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, false); + break; + default: + } + } + + private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z, boolean fullBlock) { + Tessellator tessellator = Tessellator.instance; + Block block = StackUtils.getBlock(itemStack); + + if (!(itemStack.getItem() instanceof ItemWoodBlock) || block == null) { + return; + } + + WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); + + GL11.glEnable(GL11.GL_BLEND); + + IIcon barkIcon = woodType.getBarkIcon(); + IIcon heartIcon = woodType.getHeartIcon(); + if (barkIcon == null || heartIcon == null) { + return; + } + + GL11.glTranslatef(x, y, z); + + block.setBlockBoundsForItemRender(); + renderer.setRenderBoundsFromBlock(block); + + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + // top + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, heartIcon); + tessellator.draw(); + + // front right + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, barkIcon); + tessellator.draw(); + + // front left + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, barkIcon); + tessellator.draw(); + + if (fullBlock) { + // bottom + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, heartIcon); + tessellator.draw(); + + // back right + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, barkIcon); + tessellator.draw(); + + // back left + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, barkIcon); + tessellator.draw(); + } + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/src/main/java/forestry/arboriculture/render/PlankItemRenderer.java b/src/main/java/forestry/arboriculture/render/PlankItemRenderer.java new file mode 100644 index 000000000..e9c6ff219 --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/PlankItemRenderer.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * 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.render; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import forestry.arboriculture.WoodType; +import forestry.arboriculture.items.ItemWoodBlock; +import forestry.core.utils.StackUtils; + +public class PlankItemRenderer implements IItemRenderer { + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, true); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderItem((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f, true); + break; + case INVENTORY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, false); + break; + default: + } + } + + private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z, boolean fullBlock) { + Tessellator tessellator = Tessellator.instance; + Block block = StackUtils.getBlock(itemStack); + + if (!(itemStack.getItem() instanceof ItemWoodBlock) || block == null) { + return; + } + + WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); + + GL11.glEnable(GL11.GL_BLEND); + + IIcon plankIcon = woodType.getPlankIcon(); + if (plankIcon == null) { + return; + } + + GL11.glTranslatef(x, y, z); + + block.setBlockBoundsForItemRender(); + renderer.setRenderBoundsFromBlock(block); + + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + // top + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // front right + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // front left + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + if (fullBlock) { + // bottom + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // back right + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // back left + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + } + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/src/main/java/forestry/arboriculture/render/SlabItemRenderer.java b/src/main/java/forestry/arboriculture/render/SlabItemRenderer.java new file mode 100644 index 000000000..ab40f0d33 --- /dev/null +++ b/src/main/java/forestry/arboriculture/render/SlabItemRenderer.java @@ -0,0 +1,118 @@ +package forestry.arboriculture.render; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import forestry.arboriculture.WoodType; +import forestry.arboriculture.items.ItemWoodBlock; +import forestry.core.utils.StackUtils; + +public class SlabItemRenderer implements IItemRenderer { + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, true); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderItem((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f, true); + break; + case INVENTORY: + renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f, false); + break; + default: + } + } + + private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z, boolean fullBlock) { + Tessellator tessellator = Tessellator.instance; + Block block = StackUtils.getBlock(itemStack); + + if (!(itemStack.getItem() instanceof ItemWoodBlock) || block == null) { + return; + } + + WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); + + GL11.glEnable(GL11.GL_BLEND); + + IIcon plankIcon = woodType.getPlankIcon(); + if (plankIcon == null) { + return; + } + + GL11.glTranslatef(x, y, z); + + block.setBlockBoundsForItemRender(); + renderer.setRenderBoundsFromBlock(block); + + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + // top + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // front right + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // front left + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + if (fullBlock) { + // bottom + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // back right + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + + // back left + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, plankIcon); + tessellator.draw(); + } + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } +} diff --git a/src/main/java/forestry/arboriculture/render/StairItemRenderer.java b/src/main/java/forestry/arboriculture/render/StairItemRenderer.java index f0ef41a61..5601ffdac 100755 --- a/src/main/java/forestry/arboriculture/render/StairItemRenderer.java +++ b/src/main/java/forestry/arboriculture/render/StairItemRenderer.java @@ -25,7 +25,42 @@ import forestry.core.utils.StackUtils; public class StairItemRenderer implements IItemRenderer { - private void renderStairBlock(RenderBlocks renderBlocks, ItemStack item, float f, float g, float h) { + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + case EQUIPPED_FIRST_PERSON: + case EQUIPPED: + case INVENTORY: + return true; + default: + return false; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + switch (type) { + case ENTITY: + renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); + break; + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + renderStairBlock((RenderBlocks) data[0], item, 0f, 0.0f, 0.0f); + break; + case INVENTORY: + renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); + break; + default: + } + } + + private static void renderStairBlock(RenderBlocks renderBlocks, ItemStack item, float f, float g, float h) { Tessellator tessellator = Tessellator.instance; Block block = StackUtils.getBlock(item); @@ -71,39 +106,4 @@ public class StairItemRenderer implements IItemRenderer { } - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - case EQUIPPED_FIRST_PERSON: - case EQUIPPED: - case INVENTORY: - return true; - default: - return false; - } - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return true; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - switch (type) { - case ENTITY: - renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - case EQUIPPED: - case EQUIPPED_FIRST_PERSON: - renderStairBlock((RenderBlocks) data[0], item, 0f, 0.0f, 0.0f); - break; - case INVENTORY: - renderStairBlock((RenderBlocks) data[0], item, -0.5f, -0.5f, -0.5f); - break; - default: - } - } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java new file mode 100644 index 000000000..c463b9086 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLog.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockTypeLog extends BlockTypeWood { + + public BlockTypeLog(ItemStack itemStack) { + super(itemStack); + } + + @Override + public void setDirection(ForgeDirection facing) { + if (facing.offsetX != 0) { + itemStack.setItemDamage(4); + } else if (facing.offsetZ != 0) { + itemStack.setItemDamage(8); + } else { + itemStack.setItemDamage(0); + } + } + +} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java new file mode 100644 index 000000000..397008f69 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVanillaStairs.java @@ -0,0 +1,31 @@ +package forestry.arboriculture.worldgen; + +import net.minecraft.block.Block; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.core.worldgen.BlockType; + +public class BlockTypeVanillaStairs extends BlockType { + public BlockTypeVanillaStairs(Block block, int meta) { + super(block, meta); + } + + @Override + public void setDirection(ForgeDirection facing) { + switch (facing) { + case NORTH: + meta = 3; + break; + case SOUTH: + meta = 2; + break; + case WEST: + meta = 1; + break; + default: + meta = 0; + break; + } + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java new file mode 100644 index 000000000..782e4681b --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeWood.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.world.ITreeGenData; +import forestry.arboriculture.items.ItemWoodBlock; +import forestry.core.worldgen.IBlockType; + +public class BlockTypeWood implements IBlockType, ITreeBlockType { + + protected final ItemStack itemStack; + + public BlockTypeWood(ItemStack itemStack) { + this.itemStack = itemStack; + } + + @Override + public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { + setBlock(world, x, y, z); + } + + @Override + public void setBlock(World world, int x, int y, int z) { + ItemWoodBlock.placeWood(itemStack, null, world, x, y, z, itemStack.getItemDamage()); + } + + @Override + public void setDirection(ForgeDirection facing) { + + } + + @Override + public Block getBlock() { + return Block.getBlockFromItem(itemStack.getItem()); + } + + @Override + public int getMeta() { + return itemStack.getItemDamage(); + } + + @Override + public ItemStack getItemStack() { + return itemStack; + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java new file mode 100644 index 000000000..88c6e3c2a --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeWoodStairs.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockTypeWoodStairs extends BlockTypeWood { + public BlockTypeWoodStairs(ItemStack itemStack) { + super(itemStack); + } + + @Override + public void setDirection(ForgeDirection facing) { + switch (facing) { + case NORTH: + itemStack.setItemDamage(3); + break; + case SOUTH: + itemStack.setItemDamage(2); + break; + case WEST: + itemStack.setItemDamage(1); + break; + default: + itemStack.setItemDamage(0); + break; + } + } +} diff --git a/src/main/java/forestry/arboriculture/IWoodFireproof.java b/src/main/java/forestry/arboriculture/worldgen/ITreeBlockType.java similarity index 62% rename from src/main/java/forestry/arboriculture/IWoodFireproof.java rename to src/main/java/forestry/arboriculture/worldgen/ITreeBlockType.java index 9ee99ce72..94f1cb836 100644 --- a/src/main/java/forestry/arboriculture/IWoodFireproof.java +++ b/src/main/java/forestry/arboriculture/worldgen/ITreeBlockType.java @@ -1,14 +1,23 @@ -/******************************************************************************* - * 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; - -public interface IWoodFireproof { -} +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.world.ITreeGenData; + +public interface ITreeBlockType { + void setDirection(ForgeDirection facing); + + void setBlock(World world, ITreeGenData tree, int x, int y, int z); +} diff --git a/src/main/java/forestry/arboriculture/worldgen/TreeBlockType.java b/src/main/java/forestry/arboriculture/worldgen/TreeBlockType.java new file mode 100644 index 000000000..a69517a68 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/TreeBlockType.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.world.ITreeGenData; +import forestry.core.config.Defaults; + +public class TreeBlockType implements ITreeBlockType { + + private final Block block; + private final int meta; + + public TreeBlockType(Block block, int meta) { + this.block = block; + this.meta = meta; + } + + @Override + public void setDirection(ForgeDirection facing) { + + } + + @Override + public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { + world.setBlock(x, y, z, block, meta, Defaults.FLAG_BLOCK_SYNCH); + } + + public int getMeta() { + return this.meta; + } + + public Block getBlock() { + return this.block; + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java b/src/main/java/forestry/arboriculture/worldgen/TreeBlockTypeLeaf.java old mode 100755 new mode 100644 similarity index 77% rename from src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java rename to src/main/java/forestry/arboriculture/worldgen/TreeBlockTypeLeaf.java index e8b277a51..c101a02a2 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java +++ b/src/main/java/forestry/arboriculture/worldgen/TreeBlockTypeLeaf.java @@ -1,34 +1,38 @@ -/******************************************************************************* - * 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.worldgen; - -import net.minecraft.world.World; - -import com.mojang.authlib.GameProfile; - -import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; - -public class BlockTypeLeaf extends BlockType { - - private final GameProfile owner; - - public BlockTypeLeaf(GameProfile owner) { - super(ForestryBlock.leaves, 0); - this.owner = owner; - } - - @Override - public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { - tree.setLeaves(world, owner, x, y, z); - } -} +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.world.ITreeGenData; + +public class TreeBlockTypeLeaf implements ITreeBlockType { + + private final GameProfile owner; + + public TreeBlockTypeLeaf(GameProfile owner) { + this.owner = owner; + } + + @Override + public void setDirection(ForgeDirection facing) { + + } + + @Override + public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { + tree.setLeaves(world, owner, x, y, z); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/TreeBlockTypeLog.java b/src/main/java/forestry/arboriculture/worldgen/TreeBlockTypeLog.java new file mode 100644 index 000000000..0dd097979 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/TreeBlockTypeLog.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.api.world.ITreeGenData; + +public class TreeBlockTypeLog implements ITreeBlockType { + private ForgeDirection facing = ForgeDirection.UP; + + public TreeBlockTypeLog() { + + } + + @Override + public void setDirection(ForgeDirection facing) { + this.facing = facing; + } + + @Override + public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { + tree.setLogBlock(world, x, y, z, facing); + } +} \ No newline at end of file diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java index 11ce7c108..3f64bba97 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java @@ -10,10 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; public class WorldGenAcaciaVanilla extends WorldGenTree { @@ -21,9 +18,4 @@ public class WorldGenAcaciaVanilla extends WorldGenTree { super(tree); } - @Override - public BlockType getWood() { - return new BlockType(Blocks.log2, 0); - } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index 6cf42ac3c..b15d61dff 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -19,14 +19,15 @@ import forestry.api.world.ITreeGenData; import forestry.arboriculture.gadgets.TileSapling; import forestry.core.utils.Utils; import forestry.core.worldgen.BlockType; +import forestry.core.worldgen.BlockTypeVoid; import forestry.core.worldgen.WorldGenBase; public abstract class WorldGenArboriculture extends WorldGenBase { - private static final BlockType vineNorth = new BlockType(Blocks.vine, 1); - private static final BlockType vineSouth = new BlockType(Blocks.vine, 4); - private static final BlockType vineWest = new BlockType(Blocks.vine, 8); - private static final BlockType vineEast = new BlockType(Blocks.vine, 2); + private static final ITreeBlockType vineNorth = new TreeBlockType(Blocks.vine, 1); + private static final ITreeBlockType vineSouth = new TreeBlockType(Blocks.vine, 4); + private static final ITreeBlockType vineWest = new TreeBlockType(Blocks.vine, 8); + private static final ITreeBlockType vineEast = new TreeBlockType(Blocks.vine, 2); private static final BlockType air = new BlockTypeVoid(); @@ -35,8 +36,8 @@ public abstract class WorldGenArboriculture extends WorldGenBase { protected int startY; protected int startZ; - protected BlockType leaf; - protected BlockType wood; + protected TreeBlockTypeLeaf leaf; + protected ITreeBlockType wood; protected boolean spawnPods = false; protected int minPodHeight = 3; @@ -80,9 +81,9 @@ public abstract class WorldGenArboriculture extends WorldGenBase { public abstract boolean canGrow(); - public abstract BlockType getLeaf(GameProfile owner); + public abstract TreeBlockTypeLeaf getLeaf(GameProfile owner); - public abstract BlockType getWood(); + public abstract ITreeBlockType getWood(); protected void generateTreeTrunk(int height, int girth) { generateTreeTrunk(height, girth, 0); @@ -153,7 +154,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } @Override - protected void addBlock(int x, int y, int z, BlockType type, EnumReplaceMode replace) { + protected void addBlock(int x, int y, int z, ITreeBlockType type, EnumReplaceMode replace) { if (replace == EnumReplaceMode.ALL || (replace == EnumReplaceMode.SOFT && Utils.isReplaceableBlock(world, startX + x, startY + y, startZ + z)) || world.isAirBlock(startX + x, startY + y, startZ + z)) { @@ -162,28 +163,18 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } protected final void clearBlock(int x, int y, int z) { - air.setBlock(world, tree, startX + x, startY + y, startZ + z); + air.setBlock(world, startX + x, startY + y, startZ + z); } protected final void addWood(int x, int y, int z, EnumReplaceMode replace) { addBlock(x, y, z, wood, replace); } - protected final void addXWood(int x, int y, int z, EnumReplaceMode replace) { - BlockType woodX = new BlockType(wood.getBlock(), wood.getMeta() + 4); - addBlock(x, y, z, woodX, replace); - } - - protected final void addZWood(int x, int y, int z, EnumReplaceMode replace) { - BlockType woodZ = new BlockType(wood.getBlock(), wood.getMeta() + 8); - addBlock(x, y, z, woodZ, replace); - } - protected final void addLeaf(int x, int y, int z, EnumReplaceMode replace) { addBlock(x, y, z, leaf, replace); } - protected final void addVine(int x, int y, int z, BlockType vine) { + protected final void addVine(int x, int y, int z, ITreeBlockType vine) { addBlock(x, y, z, vine, EnumReplaceMode.NONE); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java index 62ec41140..5b22ee685 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java @@ -10,10 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; public class WorldGenBirch extends WorldGenTree { @@ -21,9 +18,4 @@ public class WorldGenBirch extends WorldGenTree { super(tree); } - @Override - public BlockType getWood() { - return new BlockType(Blocks.log, 2); - } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java index 5dfd26146..8f369cde6 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java @@ -10,10 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; public class WorldGenDarkOak extends WorldGenTree { @@ -21,9 +18,4 @@ public class WorldGenDarkOak extends WorldGenTree { super(tree); } - @Override - public BlockType getWood() { - return new BlockType(Blocks.log2, 1); - } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java index 7bb13a530..b12db5404 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java @@ -10,10 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; /** * This is a dummy and needs to be replaced with something proper. @@ -39,9 +36,4 @@ public class WorldGenJungle extends WorldGenTree { } - @Override - public BlockType getWood() { - return new BlockType(Blocks.log, 3); - } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java index 1e763e068..eb079d5f8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java @@ -10,10 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; public class WorldGenOak extends WorldGenTree { @@ -21,9 +18,4 @@ public class WorldGenOak extends WorldGenTree { super(tree); } - @Override - public BlockType getWood() { - return new BlockType(Blocks.log, 0); - } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java index ee1649078..948b96625 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java @@ -12,6 +12,8 @@ package forestry.arboriculture.worldgen; import java.util.Random; +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.world.ITreeGenData; public class WorldGenPadauk extends WorldGenTree { @@ -49,21 +51,22 @@ public class WorldGenPadauk extends WorldGenTree { int offsetValue = (offset[new Random().nextInt(offset.length)]); int maxBranchLength = 3; int branchLength = new Random().nextInt(maxBranchLength + 1); - char[] direction = {'z', 'x'}; - char directionValue = (direction[new Random().nextInt(direction.length)]); + ForgeDirection[] direction = {ForgeDirection.NORTH, ForgeDirection.EAST}; + ForgeDirection directionValue = (direction[new Random().nextInt(direction.length)]); int branchSpawn = leafSpawn; for (int j = 1; j < branchLength + 1; j++) { if (j == branchLength && rand.nextBoolean()) { //Just adding a bit of variation to the ends for character branchSpawn += 1; } - if (directionValue == 'z') { - addZWood(0, branchSpawn, j * offsetValue, EnumReplaceMode.ALL); - } else if (directionValue == 'x') { - addXWood(j * offsetValue, branchSpawn, 0, EnumReplaceMode.ALL); + + wood.setDirection(directionValue); + if (directionValue == ForgeDirection.NORTH) { + addWood(0, branchSpawn, j * offsetValue, EnumReplaceMode.ALL); + } else if (directionValue == ForgeDirection.EAST) { + addWood(j * offsetValue, branchSpawn, 0, EnumReplaceMode.ALL); } } - } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java index 7b749751e..678d656e7 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java @@ -10,20 +10,11 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - import com.mojang.authlib.GameProfile; -import forestry.api.arboriculture.EnumTreeChromosome; -import forestry.api.genetics.IAlleleBoolean; +import forestry.api.arboriculture.ITreeModifier; +import forestry.api.arboriculture.TreeManager; import forestry.api.world.ITreeGenData; -import forestry.arboriculture.gadgets.BlockFireproofLog; -import forestry.arboriculture.gadgets.BlockLog; -import forestry.core.config.ForestryBlock; -import forestry.core.utils.StackUtils; -import forestry.core.worldgen.BlockType; -import forestry.plugins.PluginArboriculture; public abstract class WorldGenTree extends WorldGenArboriculture { @@ -56,22 +47,21 @@ public abstract class WorldGenTree extends WorldGenArboriculture { return new Vector(cent + offset, yCenter, cent + offset); } - protected void generateAdjustedCylinder(int yCenter, float radius, int height, BlockType block) { + protected void generateAdjustedCylinder(int yCenter, float radius, int height, ITreeBlockType block) { generateAdjustedCylinder(yCenter, 0, radius, height, block, EnumReplaceMode.NONE); } - protected void generateAdjustedCylinder(int yCenter, float radius, int height, BlockType block, EnumReplaceMode replace) { + protected void generateAdjustedCylinder(int yCenter, float radius, int height, ITreeBlockType block, EnumReplaceMode replace) { generateAdjustedCylinder(yCenter, 0, radius, height, block, replace); } - protected void generateAdjustedCylinder(int yCenter, int offset, float radius, int height, BlockType block, EnumReplaceMode replace) { + protected void generateAdjustedCylinder(int yCenter, int offset, float radius, int height, ITreeBlockType block, EnumReplaceMode replace) { generateCylinder(getCenteredAt(yCenter, offset), radius + girth, height, block, replace); } @Override public boolean canGrow() { return tree.canGrow(world, startX, startY, startZ, tree.getGirth(world, startX, startY, startZ), height); - } @Override @@ -85,39 +75,26 @@ public abstract class WorldGenTree extends WorldGenArboriculture { } protected int modifyByHeight(int val, int min, int max) { - int determined = Math.round(val * tree.getHeightModifier() * PluginArboriculture.treeInterface.getTreekeepingMode(world).getHeightModifier(null, 1f)); + ITreeModifier treeModifier = TreeManager.treeRoot.getTreekeepingMode(world); + int determined = Math.round(val * tree.getHeightModifier() * treeModifier.getHeightModifier(tree.getGenome(), 1f)); return determined < min ? min : determined > max ? max : determined; } - // TODO: Get access to the tree genome for the treekeeping mode protected int determineHeight(int required, int variation) { - int determined = Math.round((required + rand.nextInt(variation)) * tree.getHeightModifier() - * PluginArboriculture.treeInterface.getTreekeepingMode(world).getHeightModifier(null, 1f)); - return determined < minHeight ? minHeight : determined > maxHeight ? maxHeight : determined; + ITreeModifier treeModifier = TreeManager.treeRoot.getTreekeepingMode(world); + int baseHeight = required + rand.nextInt(variation); + int height = Math.round(baseHeight * tree.getHeightModifier() * treeModifier.getHeightModifier(tree.getGenome(), 1f)); + return height < minHeight ? minHeight : height > maxHeight ? maxHeight : height; } @Override - public BlockType getLeaf(GameProfile owner) { - return new BlockTypeLeaf(owner); + public TreeBlockTypeLeaf getLeaf(GameProfile owner) { + return new TreeBlockTypeLeaf(owner); } @Override - public BlockType getWood() { - ItemStack woodStack = tree.getGenome().getPrimary().getLogStacks()[0]; - - Block block = StackUtils.getBlock(woodStack); - int meta = woodStack.getItemDamage(); - - // if we have a fireproof tree, return the fireproof log - if (block instanceof BlockLog) { - IAlleleBoolean fireproof = (IAlleleBoolean) tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF); - if (fireproof.getValue()) { - BlockLog blockLog = (BlockLog) block; - ForestryBlock fireproofLogBlock = BlockFireproofLog.getFireproofLog(blockLog); - return new BlockType(fireproofLogBlock.block(), meta); - } - } - - return new BlockType(block, meta); + public ITreeBlockType getWood() { + return new TreeBlockTypeLog(); } + } diff --git a/src/main/java/forestry/core/config/ForestryBlock.java b/src/main/java/forestry/core/config/ForestryBlock.java index db41597fb..d5b7bcd8a 100755 --- a/src/main/java/forestry/core/config/ForestryBlock.java +++ b/src/main/java/forestry/core/config/ForestryBlock.java @@ -52,33 +52,18 @@ public enum ForestryBlock { candle, stump, glass, - planks1, - planks2, - fireproofPlanks1, - fireproofPlanks2, - slabs1, - slabs2, - slabs3, - slabs4, - log1, - log2, - log3, - log4, - log5, - log6, - log7, - log8, - fireproofLog1, - fireproofLog2, - fireproofLog3, - fireproofLog4, - fireproofLog5, - fireproofLog6, - fireproofLog7, - fireproofLog8, - fences1, - fences2, + // wood items + planks, + slabs, + logs, + fences, stairs, + planksFireproof, + slabsFireproof, + logsFireproof, + fencesFireproof, + stairsFireproof, + // trees saplingGE, leaves, pods, diff --git a/src/main/java/forestry/core/genetics/FruitFamily.java b/src/main/java/forestry/core/genetics/FruitFamily.java deleted file mode 100755 index 1a437dce2..000000000 --- a/src/main/java/forestry/core/genetics/FruitFamily.java +++ /dev/null @@ -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.core.genetics; - -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IFruitFamily; -import forestry.core.utils.StringUtil; - -public class FruitFamily implements IFruitFamily { - - private final String uid; - private final String scientific; - - public FruitFamily(String uid, String scientific) { - this.uid = uid; - this.scientific = scientific; - AlleleManager.alleleRegistry.registerFruitFamily(this); - } - - @Override - public String getUID() { - return "forestry." + uid; - } - - @Override - public String getScientific() { - return this.scientific; - } - - @Override - public String getName() { - return StringUtil.localize("family." + uid); - } - - @Override - public String getDescription() { - return null; - } - -} diff --git a/src/main/java/forestry/core/genetics/IBranchDefinition.java b/src/main/java/forestry/core/genetics/IBranchDefinition.java new file mode 100644 index 000000000..ed327ae83 --- /dev/null +++ b/src/main/java/forestry/core/genetics/IBranchDefinition.java @@ -0,0 +1,10 @@ +package forestry.core.genetics; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IClassification; + +public interface IBranchDefinition { + IAllele[] getTemplate(); + + IClassification getBranch(); +} diff --git a/src/main/java/forestry/core/genetics/Mutation.java b/src/main/java/forestry/core/genetics/Mutation.java index f481d3569..f94a8b179 100755 --- a/src/main/java/forestry/core/genetics/Mutation.java +++ b/src/main/java/forestry/core/genetics/Mutation.java @@ -32,8 +32,8 @@ public abstract class Mutation implements IMutationCustom { private final int chance; boolean isSecret = false; - protected final IAllele species0; - protected final IAllele species1; + protected final IAlleleSpecies species0; + protected final IAlleleSpecies species1; private final IAllele[] template; @@ -129,12 +129,12 @@ public abstract class Mutation implements IMutationCustom { } @Override - public IAllele getAllele0() { + public IAlleleSpecies getAllele0() { return species0; } @Override - public IAllele getAllele1() { + public IAlleleSpecies getAllele1() { return species1; } diff --git a/src/main/java/forestry/core/genetics/alleles/Allele.java b/src/main/java/forestry/core/genetics/alleles/Allele.java index 5ecd6c521..243b7efe4 100644 --- a/src/main/java/forestry/core/genetics/alleles/Allele.java +++ b/src/main/java/forestry/core/genetics/alleles/Allele.java @@ -18,7 +18,6 @@ import net.minecraftforge.common.EnumPlantType; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleGrowth; -import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.lepidopterology.IAlleleButterflySpecies; @@ -55,50 +54,6 @@ public abstract class Allele implements IAllele { public static AlleleHelper helper; - // / TREES // SPECIES 512 - 1023 - public static IAlleleTreeSpecies treeOak; - public static IAlleleTreeSpecies treeBirch; - public static IAlleleTreeSpecies treeSpruce; - public static IAlleleTreeSpecies treePine; - public static IAlleleTreeSpecies treeJungle; - public static IAlleleTreeSpecies treeAcacia; - public static IAlleleTreeSpecies treeDarkOak; - - public static IAlleleTreeSpecies treeLarch; - public static IAlleleTreeSpecies treeTeak; - public static IAlleleTreeSpecies treeDesertAcacia; - public static IAlleleTreeSpecies treeLime; - public static IAlleleTreeSpecies treeChestnut; - public static IAlleleTreeSpecies treeWenge; - public static IAlleleTreeSpecies treeBaobab; - public static IAlleleTreeSpecies treeSequioa; - public static IAlleleTreeSpecies treeGiganteum; - - public static IAlleleTreeSpecies treeKapok; - public static IAlleleTreeSpecies treeEbony; - public static IAlleleTreeSpecies treeMahogany; - public static IAlleleTreeSpecies treeBalsa; - public static IAlleleTreeSpecies treePapaya; - public static IAlleleTreeSpecies treeWalnut; - public static IAlleleTreeSpecies treeDate; - public static IAlleleTreeSpecies treeCherry; - - public static IAlleleTreeSpecies treeWillow; - public static IAlleleTreeSpecies treeSipiri; - - public static IAlleleTreeSpecies treeMahoe; - public static IAlleleTreeSpecies treePoplar; - - public static IAlleleTreeSpecies treeLemon; - public static IAlleleTreeSpecies treePlum; - - public static IAlleleTreeSpecies treeMaple; - - public static IAlleleTreeSpecies treeIpe; - public static IAlleleTreeSpecies treePadauk; - public static IAlleleTreeSpecies treeCocobolo; - public static IAlleleTreeSpecies treeZebrawood; - /// BUTTERFLIES // SPECIES // Moths public static IAlleleButterflySpecies mothBrimstone; diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java b/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java index 394673dd1..2fc235e2d 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java @@ -107,7 +107,10 @@ public class AlleleHelper implements IAlleleHelper { @Override public & IChromosomeType> void set(IAllele[] alleles, T chromosomeType, IAllele allele) { - if (allele == null || !chromosomeType.getAlleleClass().isInstance(allele)) { + if (allele == null) { + throw new NullPointerException("Allele must not be null"); + } + if (!chromosomeType.getAlleleClass().isInstance(allele)) { throw new IllegalArgumentException("Allele is the wrong type. Expected: " + chromosomeType + " Got: " + allele); } alleles[chromosomeType.ordinal()] = allele; diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java b/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java index f64954054..dd322e3df 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java @@ -194,6 +194,15 @@ public class AlleleRegistry implements IAlleleRegistry { return new Classification(level, uid, scientific); } + @Override + public IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific, IClassification... members) { + IClassification classification = new Classification(level, uid, scientific); + for (IClassification member : members) { + classification.addMemberGroup(member); + } + return classification; + } + @Override public IClassification getClassification(String uid) { return classificationMap.get(uid); diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index c0e39fc4e..b48d53582 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -23,6 +23,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; import net.minecraft.potion.Potion; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChunkCoordinates; @@ -87,6 +88,17 @@ public class ProxyCommon { GameRegistry.registerItem(item, StringUtil.cleanItemName(item)); } + + /** + * As addRecipe, except that the recipe is injected into the front of the + * crafting manager to avoid certain generic collisions. Notably, all + * Forestry wood crafting into oak stairs & slabs. + */ + @SuppressWarnings("unchecked") + public void addPriorityRecipe(IRecipe recipe) { + CraftingManager.getInstance().getRecipeList().add(0, recipe); + } + /** * As addRecipe, except that the recipe is injected into the front of the * crafting manager to avoid certain generic collisions. Notably, all @@ -95,7 +107,7 @@ public class ProxyCommon { @SuppressWarnings("unchecked") public void addPriorityRecipe(ItemStack itemstack, Object... obj) { cleanRecipe(obj); - CraftingManager.getInstance().getRecipeList().add(0, new ShapedOreRecipe(itemstack, obj)); + addPriorityRecipe(new ShapedOreRecipe(itemstack, obj)); } /** @@ -106,7 +118,7 @@ public class ProxyCommon { @SuppressWarnings("unchecked") public void addPriorityShapelessRecipe(ItemStack itemstack, Object... obj) { cleanRecipe(obj); - CraftingManager.getInstance().getRecipeList().add(0, new ShapelessOreRecipe(itemstack, obj)); + addPriorityRecipe(new ShapelessOreRecipe(itemstack, obj)); } @SuppressWarnings("unchecked") diff --git a/src/main/java/forestry/core/utils/GeneticsUtil.java b/src/main/java/forestry/core/utils/GeneticsUtil.java index 7a802184b..54fe53e9f 100644 --- a/src/main/java/forestry/core/utils/GeneticsUtil.java +++ b/src/main/java/forestry/core/utils/GeneticsUtil.java @@ -10,7 +10,9 @@ ******************************************************************************/ package forestry.core.utils; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -24,11 +26,17 @@ import net.minecraft.world.World; import com.mojang.authlib.GameProfile; +import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.core.IArmorNaturalist; import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IMutation; import forestry.api.genetics.IPollinatable; import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.IButterflyNursery; @@ -36,7 +44,6 @@ import forestry.arboriculture.genetics.CheckPollinatable; import forestry.arboriculture.genetics.CheckPollinatableTree; import forestry.arboriculture.genetics.ICheckPollinatable; import forestry.core.genetics.ItemGE; -import forestry.plugins.PluginArboriculture; public class GeneticsUtil { @@ -172,8 +179,34 @@ public class GeneticsUtil { return null; } - ItemStack ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); + ItemStack ersatz = TreeManager.treeRoot.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); ersatz.stackSize = foreign.stackSize; return ersatz; } + + public static int getResearchComplexity(IAlleleSpecies species, IChromosomeType speciesChromosome) { + return 1 + getGeneticAdvancement(species, new HashSet(), speciesChromosome); + } + + private static int getGeneticAdvancement(IAlleleSpecies species, Set exclude, IChromosomeType speciesChromosome) { + int highest = 0; + exclude.add(species); + + for (IMutation mutation : species.getRoot().getPaths(species, speciesChromosome)) { + if (!exclude.contains(mutation.getAllele0())) { + int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude, speciesChromosome); + if (otherAdvance > highest) { + highest = otherAdvance; + } + } + if (!exclude.contains(mutation.getAllele1())) { + int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude, speciesChromosome); + if (otherAdvance > highest) { + highest = otherAdvance; + } + } + } + + return 1 + highest; + } } diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index 96fb8e63d..c9720d73a 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -15,9 +15,11 @@ import java.util.Collections; import java.util.List; import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; @@ -67,6 +69,26 @@ public class RecipeUtil { return oreDictNames; } + public static NBTTagCompound getCraftingNbt(IInventory inventoryCrafting) { + NBTTagCompound craftingNbt = null; + for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) { + ItemStack stackInSlot = inventoryCrafting.getStackInSlot(i); + if (stackInSlot == null || !stackInSlot.hasTagCompound()) { + continue; + } + + NBTTagCompound tagCompound = stackInSlot.getTagCompound(); + // if there are multiple NBT they must all match + if (craftingNbt != null && !craftingNbt.equals(tagCompound)) { + return null; + } else { + craftingNbt = tagCompound; + } + } + + return craftingNbt; + } + public static Object[] getCraftingRecipeAsArray(Object rec) { try { diff --git a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java index a597df0de..5619f9e51 100755 --- a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java @@ -148,7 +148,7 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { return true; } - private boolean checkItemMatch(ItemStack compare, ItemStack resource) { + private static boolean checkItemMatch(ItemStack compare, ItemStack resource) { if (resource == null && compare == null) { return true; @@ -170,23 +170,23 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { } @Override - public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { - if (preserveNBT) { - for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) { - if (inventorycrafting.getStackInSlot(i) == null) { - continue; - } - if (!inventorycrafting.getStackInSlot(i).hasTagCompound()) { - continue; - } + public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { + return getCraftingResult((IInventory) inventoryCrafting); + } - ItemStack crafted = product.copy(); - crafted.setTagCompound((NBTTagCompound) inventorycrafting.getStackInSlot(i).getTagCompound().copy()); - return crafted; + public ItemStack getCraftingResult(IInventory inventoryCrafting) { + ItemStack result = product.copy(); + + if (preserveNBT) { + NBTTagCompound craftingNbt = RecipeUtil.getCraftingNbt(inventoryCrafting); + if (craftingNbt == null) { + return null; } + + result.setTagCompound(craftingNbt); } - return product.copy(); + return result; } @Override @@ -285,4 +285,11 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { CraftingManager.getInstance().getRecipeList().add(recipe); return recipe; } + + @SuppressWarnings("unchecked") + public static ShapedRecipeCustom buildPriorityRecipe(ItemStack product, Object... materials) { + ShapedRecipeCustom recipe = createShapedRecipe(product, materials); + CraftingManager.getInstance().getRecipeList().add(0, recipe); + return recipe; + } } diff --git a/src/main/java/forestry/core/utils/ShapelessRecipeCustom.java b/src/main/java/forestry/core/utils/ShapelessRecipeCustom.java new file mode 100644 index 000000000..225bac08b --- /dev/null +++ b/src/main/java/forestry/core/utils/ShapelessRecipeCustom.java @@ -0,0 +1,100 @@ +package forestry.core.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import net.minecraftforge.oredict.OreDictionary; + +public class ShapelessRecipeCustom implements IRecipe { + + private final List ingredients; + private final ItemStack product; + private boolean preserveNBT = false; + + public ShapelessRecipeCustom(ItemStack product, ItemStack... ingredients) { + this.ingredients = Arrays.asList(ingredients); + this.product = product; + } + + public ShapelessRecipeCustom setPreserveNBT() { + this.preserveNBT = true; + return this; + } + + @Override + public boolean matches(InventoryCrafting inventoryCrafting, World world) { + ArrayList arraylist = new ArrayList(this.ingredients); + + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + ItemStack itemstack = inventoryCrafting.getStackInRowAndColumn(j, i); + + if (itemstack != null) { + boolean flag = false; + + for (ItemStack itemstack1 : arraylist) { + if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack.getItemDamage() == itemstack1.getItemDamage())) { + flag = true; + arraylist.remove(itemstack1); + break; + } + } + + if (!flag) { + return false; + } + } + } + } + + return arraylist.isEmpty(); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { + ItemStack result = product.copy(); + + if (preserveNBT) { + NBTTagCompound craftingNbt = RecipeUtil.getCraftingNbt(inventoryCrafting); + if (craftingNbt == null) { + return null; + } + + result.setTagCompound(craftingNbt); + } + + return result; + } + + @Override + public int getRecipeSize() { + return ingredients.size(); + } + + @Override + public ItemStack getRecipeOutput() { + return product.copy(); + } + + @SuppressWarnings("unchecked") + public static ShapelessRecipeCustom buildRecipe(ItemStack product, ItemStack... ingredients) { + ShapelessRecipeCustom recipe = new ShapelessRecipeCustom(product, ingredients); + CraftingManager.getInstance().getRecipeList().add(recipe); + return recipe; + } + + @SuppressWarnings("unchecked") + public static ShapelessRecipeCustom buildPriorityRecipe(ItemStack product, ItemStack... ingredients) { + ShapelessRecipeCustom recipe = new ShapelessRecipeCustom(product, ingredients); + CraftingManager.getInstance().getRecipeList().add(0, recipe); + return recipe; + } +} diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index ba892380a..ae865734b 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -23,6 +23,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; @@ -204,7 +205,7 @@ public class Utils { Proxies.log.finer("Registered entity %s (%s) with id %s.", ident, entityClass.toString(), id); } - public static T getTile(World world, int x, int y, int z, Class tileClass) { + public static T getTile(IBlockAccess world, int x, int y, int z, Class tileClass) { T tileEntity = null; try { tileEntity = tileClass.cast(world.getTileEntity(x, y, z)); diff --git a/src/main/java/forestry/core/worldgen/BlockType.java b/src/main/java/forestry/core/worldgen/BlockType.java index caed84e97..1303e07cb 100755 --- a/src/main/java/forestry/core/worldgen/BlockType.java +++ b/src/main/java/forestry/core/worldgen/BlockType.java @@ -11,36 +11,45 @@ package forestry.core.worldgen; import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import forestry.api.world.ITreeGenData; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; +import net.minecraftforge.common.util.ForgeDirection; -public class BlockType { +import forestry.core.config.Defaults; + +public class BlockType implements IBlockType { private final Block block; - private final int meta; + protected int meta; public BlockType(Block block, int meta) { this.block = block; this.meta = meta; } - public BlockType(ForestryBlock block, int meta) { - this.block = block.block(); - this.meta = meta; + @Override + public void setDirection(ForgeDirection facing) { + } - public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { + @Override + public void setBlock(World world, int x, int y, int z) { world.setBlock(x, y, z, block, meta, Defaults.FLAG_BLOCK_SYNCH); } - + + @Override public int getMeta() { return this.meta; } - + + @Override public Block getBlock() { return this.block; } + + @Override + public ItemStack getItemStack() { + return new ItemStack(block, 1, meta); + } } diff --git a/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java b/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java new file mode 100644 index 000000000..59cf3c7ac --- /dev/null +++ b/src/main/java/forestry/core/worldgen/BlockTypeTileForestry.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.gadgets.TileForestry; + +public class BlockTypeTileForestry implements IBlockType { + + private final Block block; + private final int meta; + private ForgeDirection direction; + + public BlockTypeTileForestry(ForestryBlock forestryBlock, int meta) { + this.block = forestryBlock.block(); + this.meta = meta; + } + + @Override + public void setDirection(ForgeDirection facing) { + this.direction = facing; + } + + @Override + public void setBlock(World world, int x, int y, int z) { + boolean placed = world.setBlock(x, y, z, block, meta, Defaults.FLAG_BLOCK_SYNCH); + if (!placed) { + return; + } + + Block worldBlock = world.getBlock(x, y, z); + if (!Block.isEqualTo(block, worldBlock)) { + return; + } + + TileEntity tile = world.getTileEntity(x, y, z); + if (!(tile instanceof TileForestry)) { + world.setBlockToAir(x, y, z); + return; + } + + TileForestry tileForestry = (TileForestry) tile; + + tileForestry.setOrientation(direction); + } + + @Override + public int getMeta() { + return meta; + } + + @Override + public Block getBlock() { + return block; + } + + @Override + public ItemStack getItemStack() { + return new ItemStack(block, 1, meta); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java b/src/main/java/forestry/core/worldgen/BlockTypeVoid.java old mode 100755 new mode 100644 similarity index 80% rename from src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java rename to src/main/java/forestry/core/worldgen/BlockTypeVoid.java index ad19701b8..28a727c1b --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java +++ b/src/main/java/forestry/core/worldgen/BlockTypeVoid.java @@ -8,14 +8,11 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.arboriculture.worldgen; +package forestry.core.worldgen; import net.minecraft.init.Blocks; import net.minecraft.world.World; -import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; - public class BlockTypeVoid extends BlockType { public BlockTypeVoid() { @@ -23,7 +20,7 @@ public class BlockTypeVoid extends BlockType { } @Override - public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { + public void setBlock(World world, int x, int y, int z) { world.setBlockToAir(x, y, z); } diff --git a/src/main/java/forestry/core/worldgen/IBlockType.java b/src/main/java/forestry/core/worldgen/IBlockType.java new file mode 100644 index 000000000..bf2ce06c3 --- /dev/null +++ b/src/main/java/forestry/core/worldgen/IBlockType.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.worldgen; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IBlockType { + void setDirection(ForgeDirection facing); + + void setBlock(World world, int x, int y, int z); + + int getMeta(); + + Block getBlock(); + + ItemStack getItemStack(); +} diff --git a/src/main/java/forestry/core/worldgen/WorldGenBase.java b/src/main/java/forestry/core/worldgen/WorldGenBase.java index f2845d67a..757a7a5e2 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenBase.java +++ b/src/main/java/forestry/core/worldgen/WorldGenBase.java @@ -15,6 +15,8 @@ import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import forestry.arboriculture.worldgen.ITreeBlockType; + public abstract class WorldGenBase extends WorldGenerator { protected enum EnumReplaceMode { @@ -60,9 +62,9 @@ public abstract class WorldGenBase extends WorldGenerator { return false; } - protected abstract void addBlock(int x, int y, int z, BlockType type, EnumReplaceMode replace); + protected abstract void addBlock(int x, int y, int z, ITreeBlockType type, EnumReplaceMode replace); - protected final void generateCuboid(Vector start, Vector area, BlockType block, EnumReplaceMode replace) { + protected final void generateCuboid(Vector start, Vector area, ITreeBlockType block, EnumReplaceMode replace) { for (int x = (int) start.x; x < (int) start.x + area.x; x++) { for (int y = (int) start.y; y < (int) start.y + area.y; y++) { for (int z = (int) start.z; z < (int) start.z + area.z; z++) { @@ -75,7 +77,7 @@ public abstract class WorldGenBase extends WorldGenerator { /* * Center is the bottom middle of the cylinder */ - protected final void generateCylinder(Vector center, float radius, int height, BlockType block, EnumReplaceMode replace) { + protected final void generateCylinder(Vector center, float radius, int height, ITreeBlockType block, EnumReplaceMode replace) { Vector start = new Vector(center.x - radius, center.y, center.z - radius); Vector area = new Vector(radius * 2 + 1, height, radius * 2 + 1); for (int x = (int) start.x; x < (int) start.x + area.x; x++) { @@ -89,11 +91,11 @@ public abstract class WorldGenBase extends WorldGenerator { } } - protected final void generateCircle(Vector center, float radius, int width, int height, BlockType block, EnumReplaceMode replace) { + protected final void generateCircle(Vector center, float radius, int width, int height, ITreeBlockType block, EnumReplaceMode replace) { generateCircle(center, radius, width, height, block, 1.0f, replace); } - protected final void generateCircle(Vector center, float radius, int width, int height, BlockType block, float chance, EnumReplaceMode replace) { + protected final void generateCircle(Vector center, float radius, int width, int height, ITreeBlockType block, float chance, EnumReplaceMode replace) { Vector start = new Vector(center.x - radius, center.y, center.z - radius); Vector area = new Vector(radius * 2 + 1, height, radius * 2 + 1); @@ -114,7 +116,7 @@ public abstract class WorldGenBase extends WorldGenerator { } } - protected final void generateSphere(Vector center, int radius, BlockType block, EnumReplaceMode replace) { + protected final void generateSphere(Vector center, int radius, ITreeBlockType block, EnumReplaceMode replace) { Vector start = new Vector(center.x - radius, center.y - radius, center.z - radius); Vector area = new Vector(radius * 2 + 1, radius * 2 + 1, radius * 2 + 1); for (int x = (int) start.x; x < (int) start.x + area.x; x++) { diff --git a/src/main/java/forestry/factory/DummyManagers.java b/src/main/java/forestry/factory/DummyManagers.java index 7debe890d..a1e175987 100644 --- a/src/main/java/forestry/factory/DummyManagers.java +++ b/src/main/java/forestry/factory/DummyManagers.java @@ -10,6 +10,7 @@ import forestry.api.recipes.ICarpenterManager; import forestry.api.recipes.ICentrifugeManager; import forestry.api.recipes.ICentrifugeRecipe; import forestry.api.recipes.IFabricatorManager; +import forestry.api.recipes.IFabricatorRecipe; import forestry.api.recipes.IFermenterManager; import forestry.api.recipes.IMoistenerManager; import forestry.api.recipes.ISqueezerManager; @@ -60,6 +61,11 @@ public class DummyManagers { public static class FabricatorManager implements IFabricatorManager { + @Override + public void addRecipe(IFabricatorRecipe recipe) { + + } + @Override public void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern) { diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 02b8296de..0c4e8cb96 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -13,6 +13,7 @@ package forestry.factory.gadgets; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; @@ -22,7 +23,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -32,6 +32,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import forestry.api.core.ForestryAPI; import forestry.api.recipes.IFabricatorManager; +import forestry.api.recipes.IFabricatorRecipe; import forestry.core.config.Defaults; import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; @@ -52,175 +53,10 @@ import forestry.core.network.GuiId; import forestry.core.utils.GuiUtil; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; +import forestry.factory.recipes.FabricatorRecipe; public class MachineFabricator extends TilePowered implements ICrafter, ILiquidTankContainer, ISidedInventory { - /* RECIPE MANAGMENT */ - public static class Recipe { - - private final ItemStack plan; - private final FluidStack molten; - private final ShapedRecipeCustom internal; - - public Recipe(ItemStack plan, FluidStack molten, ShapedRecipeCustom internal) { - this.plan = plan; - this.molten = molten; - this.internal = internal; - } - - public boolean matches(ItemStack plan, ItemStack[][] resources) { - if (this.plan != null && !StackUtils.isCraftingEquivalent(this.plan, plan)) { - return false; - } - - return internal.matches(resources); - } - - public boolean hasLiquid(FluidStack resource) { - if (resource == null) { - return molten == null; - } - - return resource.containsFluid(molten); - } - - public ItemStack getPlan() { - return plan; - } - - public FluidStack getLiquid() { - return molten; - } - - public IRecipe asIRecipe() { - return internal; - } - - } - - public static class Smelting { - - private final ItemStack resource; - private final FluidStack product; - private final int meltingPoint; - - public Smelting(ItemStack resource, FluidStack molten, int meltingPoint) { - if (resource == null) { - throw new IllegalArgumentException("Resource cannot be null"); - } - if (molten == null) { - throw new IllegalArgumentException("Molten cannot be null"); - } - - this.resource = resource; - this.product = molten; - this.meltingPoint = meltingPoint; - } - - public boolean matches(FluidStack product) { - return this.product.isFluidEqual(product); - } - - public ItemStack getResource() { - return resource; - } - - public FluidStack getProduct() { - return product; - } - - public int getMeltingPoint() { - return meltingPoint; - } - } - - public static class RecipeManager implements IFabricatorManager { - - public static final ArrayList recipes = new ArrayList(); - public static final ArrayList smeltings = new ArrayList(); - - @Override - public void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern) { - recipes.add(new Recipe(plan, molten, ShapedRecipeCustom.createShapedRecipe(result, pattern))); - } - - @Override - public void addSmelting(ItemStack resource, FluidStack molten, int meltingPoint) { - if (resource == null || molten == null) { - return; - } - smeltings.add(new Smelting(resource, molten, meltingPoint)); - } - - public static Recipe findMatchingRecipe(ItemStack plan, FluidStack liquid, ItemStack[] resources) { - ItemStack[][] gridResources = new ItemStack[3][3]; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - gridResources[j][i] = resources[i * 3 + j]; - } - } - - for (Recipe recipe : recipes) { - if (recipe.matches(plan, gridResources)) { - if (recipe.hasLiquid(liquid)) { - return recipe; - } - } - } - - return null; - } - - public static boolean isPlan(ItemStack plan) { - for (Recipe recipe : recipes) { - if (StackUtils.isIdenticalItem(recipe.getPlan(), plan)) { - return true; - } - } - - return false; - } - - public static Smelting findMatchingSmelting(ItemStack resource) { - if (resource == null) { - return null; - } - - for (Smelting smelting : smeltings) { - if (StackUtils.isCraftingEquivalent(smelting.resource, resource)) { - return smelting; - } - } - - return null; - } - - public static Smelting findMatchingSmelting(FluidStack product) { - if (product == null) { - return null; - } - - for (Smelting smelting : smeltings) { - if (smelting.matches(product)) { - return smelting; - } - } - - return null; - } - - @Override - public Map getRecipes() { - HashMap recipeList = new HashMap(); - - for (Recipe recipe : recipes) { - recipeList.put(recipe.internal.getIngredients(), new Object[]{recipe.internal.getRecipeOutput()}); - } - - return recipeList; - } - } - /* CONSTANTS */ private static final int MAX_HEAT = 5000; @@ -376,7 +212,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } } - private Recipe getRecipe() { + private IFabricatorRecipe getRecipe() { IInventoryAdapter inventory = getInternalInventory(); ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); ItemStack[] crafting = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); @@ -391,13 +227,13 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT @Override public ItemStack getResult() { - Recipe myRecipe = getRecipe(); + IFabricatorRecipe myRecipe = getRecipe(); if (myRecipe == null) { return null; } - return myRecipe.internal.getRecipeOutput().copy(); + return myRecipe.getCraftingResult(craftingInventory); } @Override @@ -410,7 +246,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } private void craftResult(EntityPlayer player) { - Recipe myRecipe = getRecipe(); + IFabricatorRecipe myRecipe = getRecipe(); if (myRecipe == null) { return; } @@ -426,7 +262,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT return; } - FluidStack liquid = myRecipe.molten; + FluidStack liquid = myRecipe.getLiquid(); // Remove resources ItemStack[] crafting = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); @@ -606,4 +442,133 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT return slotIndex == SLOT_RESULT; } } + + public static class Smelting { + + private final ItemStack resource; + private final FluidStack product; + private final int meltingPoint; + + public Smelting(ItemStack resource, FluidStack molten, int meltingPoint) { + if (resource == null) { + throw new IllegalArgumentException("Resource cannot be null"); + } + if (molten == null) { + throw new IllegalArgumentException("Molten cannot be null"); + } + + this.resource = resource; + this.product = molten; + this.meltingPoint = meltingPoint; + } + + public boolean matches(FluidStack product) { + return this.product.isFluidEqual(product); + } + + public ItemStack getResource() { + return resource; + } + + public FluidStack getProduct() { + return product; + } + + public int getMeltingPoint() { + return meltingPoint; + } + } + + public static class RecipeManager implements IFabricatorManager { + + public static final List recipes = new ArrayList(); + public static final List smeltings = new ArrayList(); + + @Override + public void addRecipe(IFabricatorRecipe recipe) { + recipes.add(recipe); + } + + @Override + public void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern) { + IFabricatorRecipe recipe = new FabricatorRecipe(plan, molten, ShapedRecipeCustom.createShapedRecipe(result, pattern)); + addRecipe(recipe); + } + + @Override + public void addSmelting(ItemStack resource, FluidStack molten, int meltingPoint) { + if (resource == null || molten == null) { + return; + } + smeltings.add(new Smelting(resource, molten, meltingPoint)); + } + + public static IFabricatorRecipe findMatchingRecipe(ItemStack plan, FluidStack liquid, ItemStack[] resources) { + ItemStack[][] gridResources = new ItemStack[3][3]; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + gridResources[j][i] = resources[i * 3 + j]; + } + } + + for (IFabricatorRecipe recipe : recipes) { + if (recipe.matches(plan, gridResources)) { + if (liquid == null || liquid.containsFluid(recipe.getLiquid())) { + return recipe; + } + } + } + + return null; + } + + public static boolean isPlan(ItemStack plan) { + for (IFabricatorRecipe recipe : recipes) { + if (StackUtils.isIdenticalItem(recipe.getPlan(), plan)) { + return true; + } + } + + return false; + } + + public static Smelting findMatchingSmelting(ItemStack resource) { + if (resource == null) { + return null; + } + + for (Smelting smelting : smeltings) { + if (StackUtils.isCraftingEquivalent(smelting.resource, resource)) { + return smelting; + } + } + + return null; + } + + public static Smelting findMatchingSmelting(FluidStack product) { + if (product == null) { + return null; + } + + for (Smelting smelting : smeltings) { + if (smelting.matches(product)) { + return smelting; + } + } + + return null; + } + + @Override + public Map getRecipes() { + HashMap recipeList = new HashMap(); + + for (IFabricatorRecipe recipe : recipes) { + recipeList.put(recipe.getIngredients(), new Object[]{recipe.getRecipeOutput()}); + } + + return recipeList; + } + } } diff --git a/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java b/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java index a41135763..c20ab4ac7 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java @@ -12,9 +12,9 @@ package forestry.factory.recipes; import net.minecraft.item.ItemStack; +import forestry.api.recipes.IFabricatorRecipe; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; -import forestry.core.utils.RecipeUtil; import forestry.factory.gadgets.MachineFabricator; import uristqwerty.CraftGuide.api.ItemSlot; @@ -50,17 +50,17 @@ public class CraftGuideFabricator implements RecipeProvider { ItemStack machine = ForestryBlock.factoryPlain.getItemStack(1, Defaults.DEFINITION_FABRICATOR_META); RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - for (MachineFabricator.Recipe recipe : MachineFabricator.RecipeManager.recipes) { + for (IFabricatorRecipe recipe : MachineFabricator.RecipeManager.recipes) { Object[] array = new Object[12]; - Object[] flattened = RecipeUtil.getCraftingRecipeAsArray(recipe.asIRecipe()); - if (flattened == null) { - flattened = generator.getCraftingRecipe(recipe.asIRecipe()); - } - if (flattened == null) { + Object[] recipeIngredients = recipe.getIngredients(); + if (recipeIngredients == null) { continue; } - System.arraycopy(flattened, 0, array, 0, flattened.length); + + System.arraycopy(recipeIngredients, 0, array, 0, recipeIngredients.length); + array[9] = recipe.getRecipeOutput(); + if (recipe.getLiquid() != null) { array[10] = recipe.getLiquid(); } diff --git a/src/main/java/forestry/factory/recipes/FabricatorRecipe.java b/src/main/java/forestry/factory/recipes/FabricatorRecipe.java new file mode 100644 index 000000000..642b1bd9e --- /dev/null +++ b/src/main/java/forestry/factory/recipes/FabricatorRecipe.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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.factory.recipes; + +import javax.annotation.Nullable; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IFabricatorRecipe; +import forestry.core.utils.ShapedRecipeCustom; +import forestry.core.utils.StackUtils; + +public class FabricatorRecipe implements IFabricatorRecipe { + + private final ItemStack plan; + private final FluidStack molten; + private final ShapedRecipeCustom internal; + + public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] ingredients) { + this(plan, molten, ShapedRecipeCustom.createShapedRecipe(result, ingredients)); + } + + public FabricatorRecipe(ItemStack plan, FluidStack molten, ShapedRecipeCustom internal) { + this.plan = plan; + this.molten = molten; + this.internal = internal; + } + + @Override + public boolean matches(@Nullable ItemStack plan, ItemStack[][] resources) { + if (this.plan != null && !StackUtils.isCraftingEquivalent(this.plan, plan)) { + return false; + } + + return internal.matches(resources); + } + + @Override + public Object[] getIngredients() { + return internal.getIngredients(); + } + + @Override + @Nullable + public ItemStack getPlan() { + return plan; + } + + @Override + public FluidStack getLiquid() { + return molten; + } + + @Override + public ItemStack getCraftingResult(IInventory craftingInventory) { + return internal.getCraftingResult(craftingInventory); + } + + @Override + public ItemStack getRecipeOutput() { + return internal.getRecipeOutput(); + } + + public FabricatorRecipe setPreserveNBT() { + internal.setPreserveNBT(); + return this; + } + +} diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java index bc4ff925f..580515b82 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java @@ -17,9 +17,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.TreeManager; import forestry.api.genetics.IIndividual; import forestry.core.utils.GeneticsUtil; -import forestry.plugins.PluginArboriculture; public class FarmableVanillaSapling extends FarmableGenericSapling { @@ -34,7 +34,7 @@ public class FarmableVanillaSapling extends FarmableGenericSapling { return false; } - return PluginArboriculture.treeInterface.plantSapling(world, (ITree) tree, player.getGameProfile(), x, y, z); + return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), x, y, z); } } diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 77c6e6535..dd881974c 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -11,7 +11,6 @@ package forestry.plugins; import java.util.ArrayList; -import java.util.EnumSet; import java.util.List; import net.minecraft.block.Block; @@ -19,7 +18,6 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; @@ -33,17 +31,11 @@ import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; +import forestry.api.arboriculture.EnumFruitFamily; import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.ITree; -import forestry.api.arboriculture.ITreeRoot; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; +import forestry.api.arboriculture.TreeManager; import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IClassification; -import forestry.api.genetics.IClassification.EnumClassLevel; -import forestry.api.genetics.IFruitFamily; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.ICrateRegistry; import forestry.api.storage.StorageManager; @@ -57,79 +49,36 @@ import forestry.arboriculture.VillageHandlerArboriculture; import forestry.arboriculture.WoodType; import forestry.arboriculture.commands.CommandTree; import forestry.arboriculture.gadgets.BlockArbFence; -import forestry.arboriculture.gadgets.BlockArbFence.FenceCat; import forestry.arboriculture.gadgets.BlockArbStairs; -import forestry.arboriculture.gadgets.BlockFireproofLog; -import forestry.arboriculture.gadgets.BlockFireproofPlanks; import forestry.arboriculture.gadgets.BlockFruitPod; import forestry.arboriculture.gadgets.BlockLog; -import forestry.arboriculture.gadgets.BlockLog.LogCat; import forestry.arboriculture.gadgets.BlockPlanks; -import forestry.arboriculture.gadgets.BlockPlanks.PlankCat; import forestry.arboriculture.gadgets.BlockSapling; import forestry.arboriculture.gadgets.BlockSlab; -import forestry.arboriculture.gadgets.BlockSlab.SlabCat; import forestry.arboriculture.gadgets.ForestryBlockLeaves; import forestry.arboriculture.gadgets.TileArboristChest; import forestry.arboriculture.gadgets.TileFruitPod; import forestry.arboriculture.gadgets.TileLeaves; import forestry.arboriculture.gadgets.TileSapling; -import forestry.arboriculture.gadgets.TileStairs; +import forestry.arboriculture.gadgets.TileWood; import forestry.arboriculture.genetics.AlleleFruit; import forestry.arboriculture.genetics.AlleleGrowth; import forestry.arboriculture.genetics.AlleleLeafEffectNone; -import forestry.arboriculture.genetics.AlleleTreeSpecies; -import forestry.arboriculture.genetics.BranchTrees; import forestry.arboriculture.genetics.GrowthProvider; import forestry.arboriculture.genetics.GrowthProviderTropical; -import forestry.arboriculture.genetics.Tree; +import forestry.arboriculture.genetics.TreeBranchDefinition; +import forestry.arboriculture.genetics.TreeDefinition; +import forestry.arboriculture.genetics.TreeFactory; import forestry.arboriculture.genetics.TreeHelper; -import forestry.arboriculture.genetics.TreeMutation; -import forestry.arboriculture.genetics.TreeTemplates; +import forestry.arboriculture.genetics.TreeMutationFactory; 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; import forestry.arboriculture.network.PacketHandlerArboriculture; import forestry.arboriculture.proxy.ProxyArboriculture; -import forestry.arboriculture.worldgen.WorldGenAcacia; -import forestry.arboriculture.worldgen.WorldGenAcaciaVanilla; -import forestry.arboriculture.worldgen.WorldGenBalsa; -import forestry.arboriculture.worldgen.WorldGenBaobab; -import forestry.arboriculture.worldgen.WorldGenBirch; -import forestry.arboriculture.worldgen.WorldGenCherry; -import forestry.arboriculture.worldgen.WorldGenChestnut; -import forestry.arboriculture.worldgen.WorldGenCocobolo; -import forestry.arboriculture.worldgen.WorldGenDarkOak; -import forestry.arboriculture.worldgen.WorldGenDate; -import forestry.arboriculture.worldgen.WorldGenEbony; -import forestry.arboriculture.worldgen.WorldGenGiganteum; -import forestry.arboriculture.worldgen.WorldGenGreenheart; -import forestry.arboriculture.worldgen.WorldGenIpe; -import forestry.arboriculture.worldgen.WorldGenJungle; -import forestry.arboriculture.worldgen.WorldGenKapok; -import forestry.arboriculture.worldgen.WorldGenLarch; -import forestry.arboriculture.worldgen.WorldGenLemon; -import forestry.arboriculture.worldgen.WorldGenLime; -import forestry.arboriculture.worldgen.WorldGenMahoe; -import forestry.arboriculture.worldgen.WorldGenMahogany; -import forestry.arboriculture.worldgen.WorldGenMaple; -import forestry.arboriculture.worldgen.WorldGenOak; -import forestry.arboriculture.worldgen.WorldGenPadauk; -import forestry.arboriculture.worldgen.WorldGenPapaya; -import forestry.arboriculture.worldgen.WorldGenPine; -import forestry.arboriculture.worldgen.WorldGenPlum; -import forestry.arboriculture.worldgen.WorldGenPoplar; -import forestry.arboriculture.worldgen.WorldGenSequoia; -import forestry.arboriculture.worldgen.WorldGenSpruce; -import forestry.arboriculture.worldgen.WorldGenTeak; -import forestry.arboriculture.worldgen.WorldGenWalnut; -import forestry.arboriculture.worldgen.WorldGenWenge; -import forestry.arboriculture.worldgen.WorldGenWillow; -import forestry.arboriculture.worldgen.WorldGenZebrawood; import forestry.core.GameMode; import forestry.core.config.Config; import forestry.core.config.Defaults; @@ -138,7 +87,6 @@ import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; -import forestry.core.genetics.FruitFamily; import forestry.core.genetics.alleles.Allele; import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemFruit.EnumFruit; @@ -146,6 +94,8 @@ import forestry.core.network.IPacketHandler; import forestry.core.proxy.Proxies; import forestry.core.utils.RecipeUtil; import forestry.core.utils.ShapedRecipeCustom; +import forestry.core.utils.ShapelessRecipeCustom; +import forestry.factory.recipes.FabricatorRecipe; @Plugin(pluginID = "Arboriculture", name = "Arboriculture", author = "Binnie & SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.arboriculture.description") public class PluginArboriculture extends ForestryPlugin { @@ -153,133 +103,74 @@ public class PluginArboriculture extends ForestryPlugin { @SidedProxy(clientSide = "forestry.arboriculture.proxy.ClientProxyArboriculture", serverSide = "forestry.arboriculture.proxy.ProxyArboriculture") public static ProxyArboriculture proxy; public static String treekeepingMode = "NORMAL"; + public static int modelIdSaplings; public static int modelIdLeaves; public static int modelIdFences; public static int modelIdPods; - public static ITreeRoot treeInterface; + public static MachineDefinition definitionChest; public static final List validFences = new ArrayList(); - private static final EnumSet logs = EnumSet.of( - ForestryBlock.log1, - ForestryBlock.log2, - ForestryBlock.log3, - ForestryBlock.log4, - ForestryBlock.log5, - ForestryBlock.log6, - ForestryBlock.log7, - ForestryBlock.log8); - public static final EnumSet fireproofLogs = EnumSet.of( - ForestryBlock.fireproofLog1, - ForestryBlock.fireproofLog2, - ForestryBlock.fireproofLog3, - ForestryBlock.fireproofLog4, - ForestryBlock.fireproofLog5, - ForestryBlock.fireproofLog6, - ForestryBlock.fireproofLog7, - ForestryBlock.fireproofLog8); - private static final EnumSet planks = EnumSet.of( - ForestryBlock.planks1, - ForestryBlock.planks2); - private static final EnumSet fireproofPlanks = EnumSet.of( - ForestryBlock.fireproofPlanks1, - ForestryBlock.fireproofPlanks2); - private static final EnumSet slabs = EnumSet.of( - ForestryBlock.slabs1, - ForestryBlock.slabs2, - ForestryBlock.slabs3, - ForestryBlock.slabs4); - private static final EnumSet fences = EnumSet.of( - ForestryBlock.fences1, - ForestryBlock.fences2); @Override protected void setupAPI() { super.setupAPI(); + TreeManager.treeFactory = new TreeFactory(); + TreeManager.treeMutationFactory = new TreeMutationFactory(); + // Init tree interface - AlleleManager.alleleRegistry.registerSpeciesRoot(PluginArboriculture.treeInterface = new TreeHelper()); + TreeManager.treeRoot = new TreeHelper(); + AlleleManager.alleleRegistry.registerSpeciesRoot(TreeManager.treeRoot); // Modes - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.easy); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.normal); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hard); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hardcore); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.insane); + TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.easy); + TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.normal); + TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.hard); + TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.hardcore); + TreeManager.treeRoot.registerTreekeepingMode(TreekeepingMode.insane); } @Override public void preInit() { super.preInit(); - ForestryBlock.log1.registerBlock(new BlockLog(LogCat.CAT0), ItemWoodBlock.class, "log1"); - ForestryBlock.log2.registerBlock(new BlockLog(LogCat.CAT1), ItemWoodBlock.class, "log2"); - ForestryBlock.log3.registerBlock(new BlockLog(LogCat.CAT2), ItemWoodBlock.class, "log3"); - ForestryBlock.log4.registerBlock(new BlockLog(LogCat.CAT3), ItemWoodBlock.class, "log4"); - ForestryBlock.log5.registerBlock(new BlockLog(LogCat.CAT4), ItemWoodBlock.class, "log5"); - ForestryBlock.log6.registerBlock(new BlockLog(LogCat.CAT5), ItemWoodBlock.class, "log6"); - ForestryBlock.log7.registerBlock(new BlockLog(LogCat.CAT6), ItemWoodBlock.class, "log7"); - ForestryBlock.log8.registerBlock(new BlockLog(LogCat.CAT7), ItemWoodBlock.class, "log8"); + // Wood blocks + ForestryBlock.logs.registerBlock(new BlockLog(false), ItemWoodBlock.class, "logs"); + OreDictionary.registerOre("logWood", ForestryBlock.logs.getWildcard()); - for (ForestryBlock log : logs) { - log.block().setHarvestLevel("axe", 0); - OreDictionary.registerOre("logWood", log.getWildcard()); - } + ForestryBlock.planks.registerBlock(new BlockPlanks(false), ItemWoodBlock.class, "planks"); + OreDictionary.registerOre("plankWood", ForestryBlock.planks.getWildcard()); - ForestryBlock.fireproofLog1.registerBlock(new BlockFireproofLog(LogCat.CAT0), ItemWoodBlock.class, "fireproofLog1"); - ForestryBlock.fireproofLog2.registerBlock(new BlockFireproofLog(LogCat.CAT1), ItemWoodBlock.class, "fireproofLog2"); - ForestryBlock.fireproofLog3.registerBlock(new BlockFireproofLog(LogCat.CAT2), ItemWoodBlock.class, "fireproofLog3"); - ForestryBlock.fireproofLog4.registerBlock(new BlockFireproofLog(LogCat.CAT3), ItemWoodBlock.class, "fireproofLog4"); - ForestryBlock.fireproofLog5.registerBlock(new BlockFireproofLog(LogCat.CAT4), ItemWoodBlock.class, "fireproofLog5"); - ForestryBlock.fireproofLog6.registerBlock(new BlockFireproofLog(LogCat.CAT5), ItemWoodBlock.class, "fireproofLog6"); - ForestryBlock.fireproofLog7.registerBlock(new BlockFireproofLog(LogCat.CAT6), ItemWoodBlock.class, "fireproofLog7"); - ForestryBlock.fireproofLog8.registerBlock(new BlockFireproofLog(LogCat.CAT7), ItemWoodBlock.class, "fireproofLog8"); + ForestryBlock.slabs.registerBlock(new BlockSlab(false), ItemWoodBlock.class, "slabs"); + OreDictionary.registerOre("slabWood", ForestryBlock.slabs.getWildcard()); - for (ForestryBlock fireproofLog : fireproofLogs) { - fireproofLog.block().setHarvestLevel("axe", 0); - OreDictionary.registerOre("logWood", fireproofLog.getWildcard()); - } + ForestryBlock.fences.registerBlock(new BlockArbFence(false), ItemWoodBlock.class, "fences"); + OreDictionary.registerOre("fenceWood", ForestryBlock.fences.getWildcard()); - ForestryBlock.planks1.registerBlock(new BlockPlanks(PlankCat.CAT0), ItemWoodBlock.class, "planks"); - ForestryBlock.planks2.registerBlock(new BlockPlanks(PlankCat.CAT1), ItemWoodBlock.class, "planks2"); - - for (ForestryBlock plank : planks) { - plank.block().setHarvestLevel("axe", 0); - OreDictionary.registerOre("plankWood", plank.getWildcard()); - } - - ForestryBlock.fireproofPlanks1.registerBlock(new BlockFireproofPlanks(PlankCat.CAT0), ItemWoodBlock.class, "fireproofPlanks1"); - ForestryBlock.fireproofPlanks2.registerBlock(new BlockFireproofPlanks(PlankCat.CAT1), ItemWoodBlock.class, "fireproofPlanks2"); - - for (ForestryBlock plank : fireproofPlanks) { - plank.block().setHarvestLevel("axe", 0); - OreDictionary.registerOre("plankWood", plank.getWildcard()); - } - - ForestryBlock.slabs1.registerBlock(new BlockSlab(SlabCat.CAT0), ItemWoodBlock.class, "slabs1"); - ForestryBlock.slabs2.registerBlock(new BlockSlab(SlabCat.CAT1), ItemWoodBlock.class, "slabs2"); - ForestryBlock.slabs3.registerBlock(new BlockSlab(SlabCat.CAT2), ItemWoodBlock.class, "slabs3"); - ForestryBlock.slabs4.registerBlock(new BlockSlab(SlabCat.CAT3), ItemWoodBlock.class, "slabs4"); - - for (ForestryBlock plank : slabs) { - plank.block().setHarvestLevel("axe", 0); - OreDictionary.registerOre("slabWood", plank.getWildcard()); - } - - // Fences - ForestryBlock.fences1.registerBlock(new BlockArbFence(FenceCat.CAT0), ItemWoodBlock.class, "fences"); - ForestryBlock.fences2.registerBlock(new BlockArbFence(FenceCat.CAT1), ItemWoodBlock.class, "fences2"); - - for (ForestryBlock block : fences) { - block.block().setHarvestLevel("axe", 0); - OreDictionary.registerOre("fenceWood", block.getWildcard()); - } - - // Stairs - ForestryBlock.stairs.registerBlock(new BlockArbStairs(ForestryBlock.planks1.block(), 0), ItemStairs.class, "stairs"); - ForestryBlock.stairs.block().setHarvestLevel("axe", 0); + ForestryBlock.stairs.registerBlock(new BlockArbStairs(ForestryBlock.planks.block(), 0, false), ItemWoodBlock.class, "stairs"); OreDictionary.registerOre("stairWood", ForestryBlock.stairs.getWildcard()); + ForestryBlock.logsFireproof.registerBlock(new BlockLog(true), ItemWoodBlock.class, "logsFireproof"); + ForestryBlock.planksFireproof.registerBlock(new BlockPlanks(true), ItemWoodBlock.class, "planksFireproof"); + ForestryBlock.slabsFireproof.registerBlock(new BlockSlab(true), ItemWoodBlock.class, "slabsFireproof"); + ForestryBlock.fencesFireproof.registerBlock(new BlockArbFence(true), ItemWoodBlock.class, "fencesFireproof"); + ForestryBlock.stairsFireproof.registerBlock(new BlockArbStairs(ForestryBlock.planksFireproof.block(), 0, true), ItemWoodBlock.class, "stairsFireproof"); + + for (WoodType woodType : WoodType.VALUES) { + woodType.registerLog(ForestryBlock.logs.block(), false); + woodType.registerPlanks(ForestryBlock.planks.block(), false); + woodType.registerSlab(ForestryBlock.slabs.block(), false); + woodType.registerFence(ForestryBlock.fences.block(), false); + woodType.registerStairs(ForestryBlock.stairs.block(), false); + + woodType.registerLog(ForestryBlock.logsFireproof.block(), true); + woodType.registerPlanks(ForestryBlock.planksFireproof.block(), true); + woodType.registerSlab(ForestryBlock.slabsFireproof.block(), true); + woodType.registerFence(ForestryBlock.fencesFireproof.block(), true); + woodType.registerStairs(ForestryBlock.stairsFireproof.block(), true); + } + // Saplings ForestryBlock.saplingGE.registerBlock(new BlockSapling(), ItemForestryBlock.class, "saplingGE"); OreDictionary.registerOre("treeSapling", ForestryBlock.saplingGE.getWildcard()); @@ -310,8 +201,8 @@ public class PluginArboriculture extends ForestryPlugin { proxy.initializeRendering(); // Register vanilla and forestry fence ids - validFences.add(ForestryBlock.fences1.block()); - validFences.add(ForestryBlock.fences2.block()); + validFences.add(ForestryBlock.fences.block()); + validFences.add(ForestryBlock.fencesFireproof.block()); validFences.add(Blocks.fence); validFences.add(Blocks.fence_gate); validFences.add(Blocks.nether_brick_fence); @@ -326,13 +217,12 @@ public class PluginArboriculture extends ForestryPlugin { // Create alleles createAlleles(); - createMutations(); - registerTemplates(); + TreeDefinition.initTrees(); registerErsatzGenomes(); GameRegistry.registerTileEntity(TileSapling.class, "forestry.Sapling"); GameRegistry.registerTileEntity(TileLeaves.class, "forestry.Leaves"); - GameRegistry.registerTileEntity(TileStairs.class, "forestry.Stairs"); + GameRegistry.registerTileEntity(TileWood.class, "forestry.Wood"); GameRegistry.registerTileEntity(TileFruitPod.class, "forestry.Pods"); definitionChest.register(); @@ -381,144 +271,36 @@ public class PluginArboriculture extends ForestryPlugin { @Override protected void registerRecipes() { - for (ForestryBlock log : logs) { - Proxies.common.addSmelting(log.getWildcard(), new ItemStack(Items.coal, 1, 1), 0.15F); - } + Proxies.common.addSmelting(ForestryBlock.logs.getWildcard(), new ItemStack(Items.coal, 1, 1), 0.15F); - // / Plank recipes - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, i), ForestryBlock.log1.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, 4 + i), ForestryBlock.log2.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, 8 + i), ForestryBlock.log3.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks1.getItemStack(4, 12 + i), ForestryBlock.log4.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, i), ForestryBlock.log5.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 4 + i), ForestryBlock.log6.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 8 + i), ForestryBlock.log7.getItemStack(1, i)); - } - for (int i = 0; i < 1; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 12 + i), ForestryBlock.log8.getItemStack(1, i)); - } + ShapelessRecipeCustom.buildRecipe(ForestryBlock.planks.getItemStack(4), ForestryBlock.logs.getItemStack()).setPreserveNBT(); + ShapelessRecipeCustom.buildRecipe(ForestryBlock.planksFireproof.getItemStack(4), ForestryBlock.logsFireproof.getItemStack()).setPreserveNBT(); // Fabricator recipes if (PluginManager.Module.FACTORY.isEnabled() && PluginManager.Module.APICULTURE.isEnabled()) { - // Fireproof log recipes - for (ForestryBlock forestryBlock : logs) { - BlockLog blockLog = (BlockLog) forestryBlock.block(); - ForestryBlock fireproofLog = BlockFireproofLog.getFireproofLog(blockLog); + // Fireproof log recipe + RecipeManagers.fabricatorManager.addRecipe(new FabricatorRecipe(null, Fluids.GLASS.getFluid(500), ForestryBlock.logsFireproof.getItemStack(), new Object[]{ + " # ", + "#X#", + " # ", + '#', ForestryItem.refractoryWax, + 'X', ForestryBlock.logs.getItemStack()}).setPreserveNBT()); - for (int i = 0; i < 4; i++) { - if (forestryBlock == ForestryBlock.log8 && i > 0) { - break; - } - - ItemStack logStack = forestryBlock.getItemStack(1, i); - ItemStack fireproofLogStack = fireproofLog.getItemStack(1, i); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofLogStack, new Object[]{ - " # ", - "#X#", - " # ", - '#', ForestryItem.refractoryWax, - 'X', logStack}); - } - } - - // Fireproof plank recipes - ForestryBlock plank = ForestryBlock.planks1; - for (int i = 0; i < 16; i++) { - ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks) plank.block()); - ItemStack plankStack = plank.getItemStack(1, i); - ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlankStack, new Object[]{ - "X#X", - "#X#", - "X#X", - '#', ForestryItem.refractoryWax, - 'X', plankStack}); - } - plank = ForestryBlock.planks2; - for (int i = 0; i < 12; i++) { - ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks) plank.block()); - ItemStack plankStack = plank.getItemStack(1, i); - ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlankStack, new Object[]{ - "X#X", - "#X#", - "X#X", - '#', ForestryItem.refractoryWax, - 'X', plankStack}); - } + // Fireproof plank recipe + RecipeManagers.fabricatorManager.addRecipe(new FabricatorRecipe(null, Fluids.GLASS.getFluid(500), ForestryBlock.planksFireproof.getItemStack(5), new Object[]{ + "X#X", + "#X#", + "X#X", + '#', ForestryItem.refractoryWax, + 'X', ForestryBlock.planks.getItemStack()}).setPreserveNBT()); } - // / Fireproof Plank recipes - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, i), ForestryBlock.fireproofLog1.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, 4 + i), ForestryBlock.fireproofLog2.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, 8 + i), ForestryBlock.fireproofLog3.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks1.getItemStack(4, 12 + i), ForestryBlock.fireproofLog4.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, i), ForestryBlock.fireproofLog5.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 4 + i), ForestryBlock.fireproofLog6.getItemStack(1, i)); - } - for (int i = 0; i < 4; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 8 + i), ForestryBlock.fireproofLog7.getItemStack(1, i)); - } - for (int i = 0; i < 1; i++) { - Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 12 + i), ForestryBlock.fireproofLog8.getItemStack(1, i)); - } + ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.slabs.getItemStack(), "###", '#', ForestryBlock.planks).setPreserveNBT(); + ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.slabsFireproof.getItemStack(), "###", '#', ForestryBlock.planksFireproof).setPreserveNBT(); - // Slab recipes - for (WoodType woodType : WoodType.values()) { - int i = woodType.ordinal(); - if (i < 8) { - Proxies.common.addPriorityRecipe(ForestryBlock.slabs1.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); - } else if (i < 16) { - Proxies.common.addPriorityRecipe(ForestryBlock.slabs2.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); - } else if (i < 24) { - Proxies.common.addPriorityRecipe(ForestryBlock.slabs3.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); - } else if (i < 32) { - Proxies.common.addPriorityRecipe(ForestryBlock.slabs4.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); - } else { - throw new RuntimeException("Wood type has no slabs defined"); - } - } - - // Fence recipes - for (WoodType woodType : WoodType.values()) { - int i = woodType.ordinal(); - if (i < 16) { - // TODO remove first recipe on 1.8 - Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i % 16), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); - Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(3, i % 16), "#X#", "#X#", '#', ForestryBlock.planks1.getItemStack(1, i % 16), 'X', "stickWood"); - } else if (i < 32) { - // TODO remove first recipe on 1.8 - Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i % 16), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); - Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(3, i % 16), "#X#", "#X#", '#', ForestryBlock.planks2.getItemStack(1, i % 16), 'X', "stickWood"); - } else { - throw new RuntimeException("Wood type has no fences defined"); - } - } + ShapedRecipeCustom.buildRecipe(ForestryBlock.fences.getItemStack(3), "#X#", "#X#", '#', ForestryBlock.planks.getItemStack(1), 'X', "stickWood").setPreserveNBT(); + ShapedRecipeCustom.buildRecipe(ForestryBlock.fencesFireproof.getItemStack(3), "#X#", "#X#", '#', ForestryBlock.planksFireproof.getItemStack(1), 'X', "stickWood").setPreserveNBT(); if (PluginManager.Module.FACTORY.isEnabled()) { // Treealyzer @@ -544,468 +326,47 @@ public class PluginArboriculture extends ForestryPlugin { } // Stairs - for (WoodType woodType : WoodType.values()) { - ForestryBlock planks; - int i = woodType.ordinal(); - if (i < 16) { - planks = ForestryBlock.planks1; - } else if (i < 32) { - planks = ForestryBlock.planks2; - } else { - throw new RuntimeException("Wood type has no planks defined"); - } + ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.stairs.getItemStack(4), + "# ", + "## ", + "###", + '#', ForestryBlock.planks.getItemStack()).setPreserveNBT(); - NBTTagCompound compound = new NBTTagCompound(); - woodType.saveToCompound(compound); - - ItemStack stairs = ForestryBlock.stairs.getItemStack(4); - stairs.setTagCompound(compound); - Proxies.common.addPriorityRecipe(stairs, - "# ", - "## ", - "###", '#', planks.getItemStack(1, i % 16)); - } + ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.stairsFireproof.getItemStack(4), + "# ", + "## ", + "###", + '#', ForestryBlock.planksFireproof.getItemStack()).setPreserveNBT(); // Grafter - Proxies.common.addRecipe(ForestryItem.grafter.getItemStack(), " B", " # ", "# ", 'B', "ingotBronze", '#', Items.stick); + Proxies.common.addRecipe(ForestryItem.grafter.getItemStack(), + " B", + " # ", + "# ", + 'B', "ingotBronze", + '#', "stickWood"); } private static void createAlleles() { - // Divisions - IClassification angiosperms = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.DIVISION, "angiosperms", "Angiosperms"); - AlleleManager.alleleRegistry.getClassification("kingdom.plantae").addMemberGroup( - angiosperms); - IClassification pinophyta = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.DIVISION, "pinophyta", "Pinophyta"); - AlleleManager.alleleRegistry.getClassification("kingdom.plantae").addMemberGroup(pinophyta); - IClassification magnoliophyta = AlleleManager.alleleRegistry - .createAndRegisterClassification(EnumClassLevel.DIVISION, "magnoliophyta", - "Magnoliophyta"); - AlleleManager.alleleRegistry.getClassification("kingdom.plantae").addMemberGroup( - magnoliophyta); - - // Classes - IClassification rosids = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.CLASS, "rosids", "Rosids"); - angiosperms.addMemberGroup(rosids); - IClassification asterids = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.CLASS, "asterids", "Asterids"); - angiosperms.addMemberGroup(asterids); - IClassification pinopsida = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.CLASS, "pinopsida", "Pinopsida"); - pinophyta.addMemberGroup(pinopsida); - IClassification magnoliopsida = AlleleManager.alleleRegistry - .createAndRegisterClassification(EnumClassLevel.CLASS, "magnoliopsida", - "Magnoliopsida"); - pinophyta.addMemberGroup(magnoliopsida); - - // Orders - IClassification fabales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "fabales", "Fabales"); - rosids.addMemberGroup(fabales); - IClassification rosales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "rosales", "Rosales"); - rosids.addMemberGroup(rosales); - IClassification fagales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "fagales", "Fagales"); - rosids.addMemberGroup(fagales); - IClassification malvales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "malvales", "Malvales"); - rosids.addMemberGroup(malvales); - IClassification malpighiales = AlleleManager.alleleRegistry - .createAndRegisterClassification(EnumClassLevel.ORDER, "malpighiales", - "Malpighiales"); - rosids.addMemberGroup(malpighiales); - - IClassification ericales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "ericales", "Ericales"); - asterids.addMemberGroup(ericales); - IClassification lamiales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "lamiales", "Lamiales"); - asterids.addMemberGroup(lamiales); - - IClassification pinales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "pinales", "Pinales"); - pinopsida.addMemberGroup(pinales); - - IClassification laurales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "laurales", "Laurales"); - rosids.addMemberGroup(laurales); - IClassification sapindales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "sapindales", "Sapindales"); - rosids.addMemberGroup(sapindales); - IClassification brassicales = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.ORDER, "brassicales", "Brassicales"); - rosids.addMemberGroup(brassicales); - - // Families - IClassification betulaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "betulaceae", "Betulaceae"); - fagales.addMemberGroup(betulaceae); - IClassification fagaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "fagaceae", "Fagaceae"); - fagales.addMemberGroup(fagaceae); - IClassification juglandaceae = AlleleManager.alleleRegistry - .createAndRegisterClassification(EnumClassLevel.FAMILY, "juglandaceae", - "Juglandaceae"); - fagales.addMemberGroup(juglandaceae); - - IClassification malvaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "malvaceae", "Malvaceae"); - malvales.addMemberGroup(malvaceae); - IClassification dipterocarpaceae = AlleleManager.alleleRegistry - .createAndRegisterClassification(EnumClassLevel.FAMILY, "dipterocarpaceae", - "Dipterocarpaceae"); - malvales.addMemberGroup(dipterocarpaceae); - - IClassification pinaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "pinaceae", "Pinaceae"); - pinales.addMemberGroup(pinaceae); - IClassification cupressaceae = AlleleManager.alleleRegistry - .createAndRegisterClassification(EnumClassLevel.FAMILY, "cupressaceae", - "Cupressaceae"); - pinales.addMemberGroup(cupressaceae); - - IClassification lamiaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "lamiaceae", "Lamiaceae"); - lamiales.addMemberGroup(lamiaceae); - IClassification bignoniaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "bignoniaceae", "Bignoniaceae"); - lamiales.addMemberGroup(bignoniaceae); - - IClassification ebenaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "ebenaceae", "Ebenaceae"); - ericales.addMemberGroup(ebenaceae); - - IClassification fabaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "fabaceae", "Fabaceae"); - ericales.addMemberGroup(fabaceae); - - IClassification rosaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "rosaceae", "Rosaceae"); - rosales.addMemberGroup(rosaceae); - - IClassification salicaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "salicaceae", "Salicaceae"); - malpighiales.addMemberGroup(salicaceae); - - IClassification lauraceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "lauraceae", "Lauraceae"); - malpighiales.addMemberGroup(lauraceae); - - IClassification rutaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "rutaceae", "Rutaceae"); - sapindales.addMemberGroup(rutaceae); - IClassification sapindaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "sapindaceae", "Sapindaceae"); - sapindales.addMemberGroup(sapindaceae); - IClassification anacardiaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "anacardiaceae", "Anacardiaceae"); - sapindales.addMemberGroup(anacardiaceae); - - - IClassification caricaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( - EnumClassLevel.FAMILY, "caricaceae", "Caricaceae"); - brassicales.addMemberGroup(caricaceae); - - // Genii - IClassification quercus = new BranchTrees("quercus", "Quercus"); - fagaceae.addMemberGroup(quercus); - IClassification castanea = new BranchTrees("castanea", "Castanea"); - fagaceae.addMemberGroup(castanea); - - IClassification betula = new BranchTrees("betula", "Betula"); - betulaceae.addMemberGroup(betula); - - IClassification tilia = new BranchTrees("tilia", "Tilia"); - malvaceae.addMemberGroup(tilia); - IClassification ceiba = new BranchTrees("ceiba", "Ceiba"); - malvaceae.addMemberGroup(ceiba); - IClassification adansonia = new BranchTrees("adansonia", "Adansonia"); - malvaceae.addMemberGroup(adansonia); - - IClassification picea = new BranchTrees("picea", "Picea"); - pinaceae.addMemberGroup(picea); - IClassification pinus = new BranchTrees("pinus", "Pinus"); - pinaceae.addMemberGroup(pinus); - IClassification larix = new BranchTrees("larix", "Larix"); - pinaceae.addMemberGroup(larix); - - IClassification juglans = new BranchTrees("juglans", "Juglans"); - juglandaceae.addMemberGroup(juglans); - - IClassification sequoia = new BranchTrees("sequoia", "Sequoia"); - cupressaceae.addMemberGroup(sequoia); - IClassification sequoiadendron = new BranchTrees("sequoiadendron", "Sequoiadendron"); - cupressaceae.addMemberGroup(sequoiadendron); - - IClassification tectona = new BranchTrees("tectona", "Tectona"); - lamiaceae.addMemberGroup(tectona); - - IClassification diospyros = new BranchTrees("ebony", "Diospyros"); - ebenaceae.addMemberGroup(diospyros); - - IClassification shorea = new BranchTrees("mahogany", "Shorea"); - dipterocarpaceae.addMemberGroup(shorea); - - IClassification acacia = new BranchTrees("acacia", "Acacia"); - fabaceae.addMemberGroup(acacia); - IClassification millettia = new BranchTrees("millettia", "Millettia"); - fabaceae.addMemberGroup(millettia); - IClassification dalbergia = new BranchTrees("dalbergia", "Dalbergia"); - fabaceae.addMemberGroup(dalbergia); - IClassification pterocarpus = new BranchTrees("pterocarpus", "Pterocarpus"); - fabaceae.addMemberGroup(pterocarpus); - - IClassification tabebuia = new BranchTrees("tabebuia", "Tabebuia"); - bignoniaceae.addMemberGroup(tabebuia); - - IClassification astronium = new BranchTrees("astronium", "Astronium"); - anacardiaceae.addMemberGroup(astronium); - - IClassification ochroma = new BranchTrees("ochroma", "Ochroma"); - malvaceae.addMemberGroup(ochroma); - - IClassification prunus = new BranchTrees("prunus", "Prunus"); - rosaceae.addMemberGroup(prunus); - - IClassification salix = new BranchTrees("salix", "Salix"); - salicaceae.addMemberGroup(salix); - - IClassification chlorocardium = new BranchTrees("chlorocardium", "Chlorocardium"); - salicaceae.addMemberGroup(chlorocardium); - - IClassification talipariti = new BranchTrees("talipariti", "Talipariti"); - malvaceae.addMemberGroup(talipariti); - - IClassification populus = new BranchTrees("populus", "Populus"); - salicaceae.addMemberGroup(populus); - - IClassification citrus = new BranchTrees("citrus", "Citrus"); - rutaceae.addMemberGroup(citrus); - IClassification acer = new BranchTrees("acer", "Acer"); - sapindaceae.addMemberGroup(acer); - - IClassification tropical = new BranchTrees("Tropical", ""); - - IClassification carica = new BranchTrees("carica", "Carica"); - - IFruitFamily prunes = new FruitFamily("prunes", "Prunus domestica"); - IFruitFamily pomes = new FruitFamily("pomes", "Pomum"); - IFruitFamily jungle = new FruitFamily("jungle", "Tropicus"); - IFruitFamily nux = new FruitFamily("nuts", "Nux"); - - /* Logs */ - final ItemStack oakLog = new ItemStack(Blocks.log, 1, 0); - final ItemStack spruceLog = new ItemStack(Blocks.log, 1, 1); - final ItemStack birchLog = new ItemStack(Blocks.log, 1, 2); - final ItemStack jungleLog = new ItemStack(Blocks.log, 1, 3); - - final ItemStack acaciaLog = new ItemStack(Blocks.log2, 1, 0); - final ItemStack darkOakLog = new ItemStack(Blocks.log2, 1, 1); - - final ItemStack larchLog = ForestryBlock.log1.getItemStack(1, 0); - final ItemStack teakLog = ForestryBlock.log1.getItemStack(1, 1); - final ItemStack desertAcaciaLog = ForestryBlock.log1.getItemStack(1, 2); - final ItemStack limeLog = ForestryBlock.log1.getItemStack(1, 3); - - final ItemStack chestnutLog = ForestryBlock.log2.getItemStack(1, 0); - final ItemStack wengeLog = ForestryBlock.log2.getItemStack(1, 1); - final ItemStack baobabLog = ForestryBlock.log2.getItemStack(1, 2); - final ItemStack sequioaLog = ForestryBlock.log2.getItemStack(1, 3); - - final ItemStack kapokLog = ForestryBlock.log3.getItemStack(1, 0); - final ItemStack ebonyLog = ForestryBlock.log3.getItemStack(1, 1); - final ItemStack mahoganyLog = ForestryBlock.log3.getItemStack(1, 2); - final ItemStack balsaLog = ForestryBlock.log3.getItemStack(1, 3); - - final ItemStack willowLog = ForestryBlock.log4.getItemStack(1, 0); - final ItemStack walnutLog = ForestryBlock.log4.getItemStack(1, 1); - final ItemStack sipiriLog = ForestryBlock.log4.getItemStack(1, 2); - final ItemStack cherryLog = ForestryBlock.log4.getItemStack(1, 3); - - final ItemStack mahoeLog = ForestryBlock.log5.getItemStack(1, 0); - final ItemStack poplarLog = ForestryBlock.log5.getItemStack(1, 1); - final ItemStack dateLog = ForestryBlock.log5.getItemStack(1, 2); - final ItemStack papayaLog = ForestryBlock.log5.getItemStack(1, 3); - - final ItemStack pineLog = ForestryBlock.log6.getItemStack(1, 0); - final ItemStack plumLog = ForestryBlock.log6.getItemStack(1, 1); - final ItemStack mapleLog = ForestryBlock.log6.getItemStack(1, 2); - final ItemStack lemonLog = ForestryBlock.log6.getItemStack(1, 3); - - final ItemStack giganteumLog = ForestryBlock.log7.getItemStack(1, 0); - final ItemStack ipeLog = ForestryBlock.log7.getItemStack(1, 1); - final ItemStack padaukLog = ForestryBlock.log7.getItemStack(1, 2); - final ItemStack cocoboloLog = ForestryBlock.log7.getItemStack(1, 3); - - final ItemStack zebrawoodLog = ForestryBlock.log8.getItemStack(1, 0); - - // Deciduous - Allele.treeOak = new AlleleTreeSpecies("treeOak", false, "appleOak", quercus, "robur", - proxy.getFoliageColorBasic(), WorldGenOak.class, oakLog).addFruitFamily(pomes) - .setVanillaMap(0); - - Allele.treeDarkOak = new AlleleTreeSpecies("treeDarkOak", false, "darkOak", quercus, "velutina", - proxy.getFoliageColorBasic(), WorldGenDarkOak.class, darkOakLog).addFruitFamily(pomes) - .setVanillaMap(5); - - Allele.treeBirch = new AlleleTreeSpecies("treeBirch", false, "silverBirch", betula, - "pendula", proxy.getFoliageColorBirch(), 0xb0c648, WorldGenBirch.class, birchLog) - .setVanillaMap(2); - Allele.treeLime = new AlleleTreeSpecies("treeLime", true, "silverLime", tilia, - "tomentosa", 0x5ea107, WorldGenLime.class, limeLog).addFruitFamily(nux) - .addFruitFamily(prunes).addFruitFamily(pomes); - - // Nucifera - Allele.treeWalnut = new AlleleTreeSpecies("treeWalnut", true, "commonWalnut", juglans, - "regia", 0x798c55, 0xb0c648, WorldGenWalnut.class, walnutLog).addFruitFamily(nux) - .addFruitFamily(prunes).addFruitFamily(pomes).setGirth(2); - Allele.treeChestnut = new AlleleTreeSpecies("treeChestnut", true, "sweetChestnut", - castanea, "sativa", 0x5ea107, 0xb0c648, WorldGenChestnut.class, chestnutLog).addFruitFamily(nux) - .addFruitFamily(prunes).addFruitFamily(pomes).setGirth(2); - - // Prunus & Citrus - // fructifer, annifer, bifer, aurifer = bearing fruit, - // bearing fruit year round, bearing fruit twice a year, bearing golden - // fruit - Allele.treeCherry = new AlleleTreeSpecies("treeCherry", true, "hillCherry", prunus, - "serrulata", 0xe691da, 0xe63e59, WorldGenCherry.class, cherryLog).addFruitFamily(prunes) - .addFruitFamily(pomes); - Allele.treeLemon = new AlleleTreeSpecies("treeLemon", true, "lemon", citrus, "limon", - 0x88af54, 0xa3b850, WorldGenLemon.class, lemonLog).addFruitFamily(pomes).addFruitFamily( - prunes); - Allele.treePlum = new AlleleTreeSpecies("treePlum", true, "plum", prunus, "domestica", - 0x589246, 0xa3b850, WorldGenPlum.class, plumLog).addFruitFamily(pomes) - .addFruitFamily(prunes); - - // Maples - Allele.treeMaple = new AlleleTreeSpecies("treeMaple", true, "sugarMaple", acer, - "saccharum", 0xd4f425, 0x619a3c, WorldGenMaple.class, mapleLog).addFruitFamily(prunes) - .addFruitFamily(pomes).setLeafIndices("maple"); - - // Conifers - Allele.treeSpruce = new AlleleTreeSpecies("treeSpruce", false, "redSpruce", picea, - "abies", proxy.getFoliageColorPine(), 0x539d12, WorldGenSpruce.class, spruceLog) - .setLeafIndices("conifers").setVanillaMap(1); - Allele.treeLarch = new AlleleTreeSpecies("treeLarch", true, "mundaneLarch", larix, - "decidua", 0x698f90, 0x569896, WorldGenLarch.class, larchLog).setLeafIndices("conifers"); - Allele.treePine = new AlleleTreeSpecies("treePine", true, "bullPine", pinus, "sabiniana", - 0xfeff8f, 0xffd98f, WorldGenPine.class, pineLog).setLeafIndices("conifers"); - - Allele.treeSequioa = new AlleleTreeSpecies("treeSequioa", false, "coastSequoia", sequoia, - "sempervirens", 0x418e71, 0x569896, WorldGenSequoia.class, sequioaLog).setLeafIndices( - "conifers").setGirth(3); - Allele.treeGiganteum = new AlleleTreeSpecies("treeGigant", false, "giantSequoia", - sequoiadendron, "giganteum", 0x738434, WorldGenGiganteum.class, giganteumLog).setLeafIndices( - "conifers").setGirth(4); - - // Jungle - Allele.treeJungle = new AlleleTreeSpecies("treeJungle", false, "jungle", tropical, - "tectona", proxy.getFoliageColorBasic(), 0x539d12, WorldGenJungle.class, jungleLog) - .addFruitFamily(jungle).setLeafIndices("jungle").setVanillaMap(3); - Allele.treeTeak = new AlleleTreeSpecies("treeTeak", true, "teak", tectona, "grandis", - 0xfeff8f, 0xffd98f, WorldGenTeak.class, teakLog) - .addFruitFamily(jungle).setLeafIndices("jungle"); - Allele.treeIpe = new AlleleTreeSpecies("treeIpe", true, "ipe", tabebuia, "serratifolia", - 0xfdd207, 0xad8f04, WorldGenIpe.class, ipeLog) - .addFruitFamily(jungle).setLeafIndices("jungle").setGirth(2); - Allele.treeKapok = new AlleleTreeSpecies("treeKapok", true, "kapok", ceiba, "pentandra", - 0x89987b, 0x89aa9e, WorldGenKapok.class, kapokLog).addFruitFamily(jungle) - .addFruitFamily(prunes).setLeafIndices("jungle"); - - // Ebony - Allele.treeEbony = new AlleleTreeSpecies("treeEbony", true, "myrtleEbony", diospyros, - "pentamera", 0xa2d24a, 0xc4d24a, WorldGenEbony.class, ebonyLog).addFruitFamily(jungle) - .addFruitFamily(prunes).setGirth(3).setLeafIndices("jungle"); - Allele.treeZebrawood = new AlleleTreeSpecies("treeZebrawood", false, "zebrawood", astronium, - "graveolens", 0xa2d24a, 0xc4d24a, WorldGenZebrawood.class, zebrawoodLog) - .addFruitFamily(nux).setGirth(2).setLeafIndices("jungle"); - - // Diospyros mespiliformis, the Jackalberry (also known as African Ebony - // The Gaub Tree, Malabar ebony, Black-and-white Ebony or Pale Moon - // Ebony (Diospyros malabarica) - // Diospyros fasciculosa, is a rainforest tree in the Ebony family. - // Usually seen as a medium sized tree, but it may grow to 30 metres - // tall. - // http://en.wikipedia.org/wiki/Diospyros_ebenum - // http://en.wikipedia.org/wiki/Diospyros_crassiflora - - // "The wood this particular tree produces is believed to be the blackest of all timber-producing Diospyros species" - // Coromandel Ebony or East Indian Ebony (Diospyros melanoxylon) - - // " locally it is known as temburini or by its Hindi name tendu. In Orissa and Jharkhand it known as kendu." - // Mahogany - Allele.treeMahogany = new AlleleTreeSpecies("treeMahogony", true, "yellowMeranti", shorea, - "gibbosa", 0x8ab154, 0xa9b154, WorldGenMahogany.class, mahoganyLog).addFruitFamily(jungle) - .setGirth(2).setLeafIndices("jungle"); - - // 80+ meters tall: - // Shorea argentifolia (also called Dark Red Meranti) - // Shorea gibbosa (also called Yellow Meranti) - // Shorea smithiana (also called Light Red Meranti) - // Shorea superba - // Malva - Allele.treeAcacia = new AlleleTreeSpecies("treeAcaciaVanilla", true, "acacia", acacia, - "aneura", 0x616101, 0xb3b302, WorldGenAcaciaVanilla.class, acaciaLog).addFruitFamily(jungle) - .addFruitFamily(nux).setVanillaMap(4); - - Allele.treeDesertAcacia = new AlleleTreeSpecies("treeAcacia", true, "desertAcacia", acacia, - "erioloba", 0x748C1C, 0xb3b302, WorldGenAcacia.class, desertAcaciaLog).addFruitFamily(jungle) - .addFruitFamily(nux); - Allele.treePadauk = new AlleleTreeSpecies("treePadauk", true, "padauk", pterocarpus, - "soyauxii", 0xd0df8c, 0x435c32, WorldGenPadauk.class, padaukLog).addFruitFamily(jungle); - Allele.treeBalsa = new AlleleTreeSpecies("treeBalsa", true, "balsa", ochroma, "pyramidale", - 0x59ac00, 0xfeff8f, WorldGenBalsa.class, balsaLog).addFruitFamily(jungle).addFruitFamily(nux); - Allele.treeCocobolo = new AlleleTreeSpecies("treeCocobolo", false, "cocobolo", dalbergia, "retusa", - 0x6aa17a, 0x487d4c, WorldGenCocobolo.class, cocoboloLog).addFruitFamily(jungle); - Allele.treeWenge = new AlleleTreeSpecies("treeWenge", true, "wenge", millettia, - "laurentii", 0xada157, 0xad8a57, WorldGenWenge.class, wengeLog).addFruitFamily(jungle) - .addFruitFamily(nux).setGirth(2); - Allele.treeBaobab = new AlleleTreeSpecies("treeBaobab", true, "grandidierBaobab", - adansonia, "digitata", 0xfeff8f, 0xffd98f, WorldGenBaobab.class, baobabLog) - .addFruitFamily(jungle).addFruitFamily(nux).setGirth(3); - Allele.treeMahoe = new AlleleTreeSpecies("treeMahoe", true, "blueMahoe", talipariti, - "elatum", 0xa0ba1b, 0x79a175, WorldGenMahoe.class, mahoeLog).addFruitFamily(jungle) - .addFruitFamily(pomes).addFruitFamily(prunes); - - // Willows - Allele.treeWillow = new AlleleTreeSpecies("treeWillow", true, "whiteWillow", salix, - "alba", 0xa3b8a5, 0xa3b850, WorldGenWillow.class, willowLog).addFruitFamily(nux) - .addFruitFamily(prunes).addFruitFamily(pomes).setLeafIndices("willow"); - - // Lauraceae - Allele.treeSipiri = new AlleleTreeSpecies("treeSipiri", true, "sipiri", chlorocardium, - "rodiei", 0x678911, 0x79a175, WorldGenGreenheart.class, sipiriLog).addFruitFamily(jungle); - - // Unclassified - Allele.treePapaya = new AlleleTreeSpecies("treePapaya", true, "papaya", carica, "papaya", - 0x6d9f58, 0x9ee67f, WorldGenPapaya.class, papayaLog).addFruitFamily(jungle) - .addFruitFamily(nux).setLeafIndices("palm"); - Allele.treeDate = new AlleleTreeSpecies("treeDate", true, "datePalm", null, "dactylifera", - 0xcbcd79, 0xf0f38f, WorldGenDate.class, dateLog).addFruitFamily(jungle).addFruitFamily(nux) - .setLeafIndices("palm"); - - Allele.treePoplar = new AlleleTreeSpecies("treePoplar", true, "whitePoplar", populus, - "alba", 0xa3b8a5, 0x539d12, WorldGenPoplar.class, poplarLog).addFruitFamily(pomes) - .addFruitFamily(prunes); + TreeBranchDefinition.createAlleles(); // FRUITS Allele.fruitNone = new AlleleFruit("none", new FruitProviderNone("none", null)); - Allele.fruitApple = new AlleleFruit("apple", new FruitProviderRandom("apple", pomes, new ItemStack(Items.apple), 1.0f).setColour(0xff2e2e).setOverlay("pomes")); - Allele.fruitCocoa = new AlleleFruit("cocoa", new FruitProviderPod("cocoa", jungle, EnumPodType.COCOA)); + Allele.fruitApple = new AlleleFruit("apple", new FruitProviderRandom("apple", EnumFruitFamily.POMES, new ItemStack(Items.apple), 1.0f).setColour(0xff2e2e).setOverlay("pomes")); + Allele.fruitCocoa = new AlleleFruit("cocoa", new FruitProviderPod("cocoa", EnumFruitFamily.JUNGLE, EnumPodType.COCOA)); // .setColours(0xecdca5, 0xc4d24a), true); - Allele.fruitChestnut = new AlleleFruit("chestnut", new FruitProviderRipening("chestnut", nux, EnumFruit.CHESTNUT.getStack(), 1.0f).setRipeningPeriod(6).setColours(0x7f333d, 0xc4d24a).setOverlay("nuts"), true); - Allele.fruitWalnut = new AlleleFruit("walnut", new FruitProviderRipening("walnut", nux, EnumFruit.WALNUT.getStack(), 1.0f).setRipeningPeriod(8).setColours(0xfba248, 0xc4d24a).setOverlay("nuts"), true); - Allele.fruitCherry = new AlleleFruit("cherry", new FruitProviderRipening("cherry", prunes, EnumFruit.CHERRY.getStack(), 1.0f).setColours(0xff2e2e, 0xc4d24a).setOverlay("berries"), true); - Allele.fruitDates = new AlleleFruit("dates", new FruitProviderPod("dates", jungle, EnumPodType.DATES, EnumFruit.DATES.getStack(4))); - Allele.fruitPapaya = new AlleleFruit("papaya", new FruitProviderPod("papaya", jungle, EnumPodType.PAPAYA, EnumFruit.PAPAYA.getStack())); + Allele.fruitChestnut = new AlleleFruit("chestnut", new FruitProviderRipening("chestnut", EnumFruitFamily.NUX, EnumFruit.CHESTNUT.getStack(), 1.0f).setRipeningPeriod(6).setColours(0x7f333d, 0xc4d24a).setOverlay("nuts"), true); + Allele.fruitWalnut = new AlleleFruit("walnut", new FruitProviderRipening("walnut", EnumFruitFamily.NUX, EnumFruit.WALNUT.getStack(), 1.0f).setRipeningPeriod(8).setColours(0xfba248, 0xc4d24a).setOverlay("nuts"), true); + Allele.fruitCherry = new AlleleFruit("cherry", new FruitProviderRipening("cherry", EnumFruitFamily.PRUNES, EnumFruit.CHERRY.getStack(), 1.0f).setColours(0xff2e2e, 0xc4d24a).setOverlay("berries"), true); + Allele.fruitDates = new AlleleFruit("dates", new FruitProviderPod("dates", EnumFruitFamily.JUNGLE, EnumPodType.DATES, EnumFruit.DATES.getStack(4))); + Allele.fruitPapaya = new AlleleFruit("papaya", new FruitProviderPod("papaya", EnumFruitFamily.JUNGLE, EnumPodType.PAPAYA, EnumFruit.PAPAYA.getStack())); // Allele.fruitCoconut = new AlleleFruit("fruitCoconut", new // FruitProviderPod("coconut", jungle, EnumPodType.COCONUT, new // ItemStack[] { new ItemStack( // ForestryItem.fruits, 1, EnumFruit.COCONUT.ordinal()) })); - Allele.fruitLemon = new AlleleFruit("lemon", new FruitProviderRipening("lemon", prunes, EnumFruit.LEMON.getStack(), 1.0f).setColours(0xeeee00, 0x99ff00).setOverlay("citrus"), true); - Allele.fruitPlum = new AlleleFruit("plum", new FruitProviderRipening("plum", prunes, EnumFruit.PLUM.getStack(), 1.0f).setColours(0x663446, 0xeeff1a).setOverlay("plums"), true); + Allele.fruitLemon = new AlleleFruit("lemon", new FruitProviderRipening("lemon", EnumFruitFamily.PRUNES, EnumFruit.LEMON.getStack(), 1.0f).setColours(0xeeee00, 0x99ff00).setOverlay("citrus"), true); + Allele.fruitPlum = new AlleleFruit("plum", new FruitProviderRipening("plum", EnumFruitFamily.PRUNES, EnumFruit.PLUM.getStack(), 1.0f).setColours(0x663446, 0xeeff1a).setOverlay("plums"), true); // / TREES // GROWTH PROVIDER 1350 - 1399 Allele.growthLightlevel = new AlleleGrowth("lightlevel", new GrowthProvider()); @@ -1017,172 +378,20 @@ public class PluginArboriculture extends ForestryPlugin { } - private static void registerTemplates() { - treeInterface.registerTemplate(TreeTemplates.getOakTemplate()); - treeInterface.registerTemplate(TreeTemplates.getBirchTemplate()); - treeInterface.registerTemplate(TreeTemplates.getSpruceTemplate()); - treeInterface.registerTemplate(TreeTemplates.getJungleTemplate()); - treeInterface.registerTemplate(TreeTemplates.getAcaciaTemplate()); - treeInterface.registerTemplate(TreeTemplates.getDarkOakTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getLimeTemplate()); - treeInterface.registerTemplate(TreeTemplates.getCherryTemplate()); - treeInterface.registerTemplate(TreeTemplates.getChestnutTemplate()); - treeInterface.registerTemplate(TreeTemplates.getWalnutTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getLarchTemplate()); - treeInterface.registerTemplate(TreeTemplates.getPineTemplate()); - treeInterface.registerTemplate(TreeTemplates.getSequoiaTemplate()); - treeInterface.registerTemplate(TreeTemplates.getGiganteumTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getBalsaTemplate()); - treeInterface.registerTemplate(TreeTemplates.getDesertAcaciaTemplate()); - treeInterface.registerTemplate(TreeTemplates.getWengeTemplate()); - treeInterface.registerTemplate(TreeTemplates.getBaobabTemplate()); - treeInterface.registerTemplate(TreeTemplates.getPadaukTemplate()); - treeInterface.registerTemplate(TreeTemplates.getCocoboloTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getTeakTemplate()); - treeInterface.registerTemplate(TreeTemplates.getIpeTemplate()); - treeInterface.registerTemplate(TreeTemplates.getKapokTemplate()); - treeInterface.registerTemplate(TreeTemplates.getEbonyTemplate()); - treeInterface.registerTemplate(TreeTemplates.getZebrawoodTemplate()); - treeInterface.registerTemplate(TreeTemplates.getMahoganyTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getWillowTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getSipiriTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getMahoeTemplate()); - treeInterface.registerTemplate(TreeTemplates.getPoplarTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getLemonTemplate()); - treeInterface.registerTemplate(TreeTemplates.getPlumTemplate()); - treeInterface.registerTemplate(TreeTemplates.getMapleTemplate()); - - treeInterface.registerTemplate(TreeTemplates.getPapayaTemplate()); - treeInterface.registerTemplate(TreeTemplates.getDateTemplate()); - } - private static void registerErsatzGenomes() { - AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 0), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getOakTemplate()))); - AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 1), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getSpruceTemplate()))); - AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 2), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getBirchTemplate()))); - AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 3), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getJungleTemplate()))); - AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves2, 1, 0), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getAcaciaTemplate()))); - AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves2, 1, 1), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getDarkOakTemplate()))); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 0), TreeDefinition.Oak.getIndividual()); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 1), TreeDefinition.Spruce.getIndividual()); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 2), TreeDefinition.Birch.getIndividual()); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 3), TreeDefinition.Jungle.getIndividual()); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves2, 1, 0), TreeDefinition.Acacia.getIndividual()); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves2, 1, 1), TreeDefinition.DarkOak.getIndividual()); - AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 0), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getOakTemplate()))); - AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 1), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getSpruceTemplate()))); - AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 2), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getBirchTemplate()))); - AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 3), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getJungleTemplate()))); - AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 4), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getAcaciaTemplate()))); - AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 5), new Tree( - TreeTemplates.templateAsGenome(TreeTemplates.getDarkOakTemplate()))); - } - - private static void createMutations() { - - // Decidious - TreeTemplates.limeA = new TreeMutation(Allele.treeBirch, Allele.treeOak, - TreeTemplates.getLimeTemplate(), 15); - TreeTemplates.mapleA = new TreeMutation(Allele.treeSpruce, Allele.treeLarch, - TreeTemplates.getMapleTemplate(), 5); - - // Fructifera - TreeTemplates.cherryA = new TreeMutation(Allele.treeLime, Allele.treeOak, - TreeTemplates.getCherryTemplate(), 10); - TreeTemplates.cherryB = new TreeMutation(Allele.treeLime, Allele.treeBirch, - TreeTemplates.getCherryTemplate(), 10); - TreeTemplates.lemonA = new TreeMutation(Allele.treeLime, Allele.treeCherry, - TreeTemplates.getLemonTemplate(), 5); - TreeTemplates.plumA = new TreeMutation(Allele.treeLemon, Allele.treeCherry, - TreeTemplates.getPlumTemplate(), 5); - - // Nucifera - TreeTemplates.walnutA = new TreeMutation(Allele.treeLime, Allele.treeCherry, - TreeTemplates.getWalnutTemplate(), 10); - TreeTemplates.chestnutA = new TreeMutation(Allele.treeWalnut, Allele.treeLime, - TreeTemplates.getChestnutTemplate(), 10); - TreeTemplates.chestnutB = new TreeMutation(Allele.treeWalnut, Allele.treeCherry, - TreeTemplates.getChestnutTemplate(), 10); - - // Conifera - TreeTemplates.larchA = new TreeMutation(Allele.treeSpruce, Allele.treeBirch, - TreeTemplates.getLarchTemplate(), 10); - TreeTemplates.larchB = new TreeMutation(Allele.treeSpruce, Allele.treeOak, - TreeTemplates.getLarchTemplate(), 10); - TreeTemplates.pineA = new TreeMutation(Allele.treeSpruce, Allele.treeLarch, - TreeTemplates.getPineTemplate(), 10); - TreeTemplates.sequoiaA = new TreeMutation(Allele.treeLarch, Allele.treePine, - TreeTemplates.getSequoiaTemplate(), 5); - - // Tropical - TreeTemplates.teakA = new TreeMutation(Allele.treeDarkOak, Allele.treeJungle, - TreeTemplates.getTeakTemplate(), 10); - TreeTemplates.ipeA = new TreeMutation(Allele.treeTeak, Allele.treeDarkOak, - TreeTemplates.getIpeTemplate(), 10); - TreeTemplates.kapokA = new TreeMutation(Allele.treeJungle, Allele.treeTeak, - TreeTemplates.getKapokTemplate(), 10); - TreeTemplates.ebonyA = new TreeMutation(Allele.treeDarkOak, Allele.treeKapok, - TreeTemplates.getEbonyTemplate(), 10); - TreeTemplates.zebrawoodA = new TreeMutation(Allele.treeEbony, Allele.treePoplar, - TreeTemplates.getZebrawoodTemplate(), 5); - TreeTemplates.mahoganyA = new TreeMutation(Allele.treeKapok, Allele.treeEbony, - TreeTemplates.getMahoganyTemplate(), 10); - - TreeTemplates.papayaA = new TreeMutation(Allele.treeJungle, Allele.treeCherry, - TreeTemplates.getPapayaTemplate(), 5); - TreeTemplates.dateA = new TreeMutation(Allele.treeJungle, Allele.treePapaya, - TreeTemplates.getDateTemplate(), 5); - - // Malva - TreeTemplates.balsaA = new TreeMutation(Allele.treeTeak, Allele.treeAcacia, - TreeTemplates.getBalsaTemplate(), 10); - TreeTemplates.acaciaA = new TreeMutation(Allele.treeTeak, Allele.treeBalsa, - TreeTemplates.getDesertAcaciaTemplate(), 10); - TreeTemplates.padaukA = new TreeMutation(Allele.treeAcacia, Allele.treeJungle, - TreeTemplates.getPadaukTemplate(), 10); - TreeTemplates.cocoboloA = new TreeMutation(Allele.treeDesertAcacia, Allele.treeDarkOak, - TreeTemplates.getCocoboloTemplate(), 10); - TreeTemplates.wengeA = new TreeMutation(Allele.treeCocobolo, Allele.treeBalsa, - TreeTemplates.getWengeTemplate(), 10); - TreeTemplates.baobabA = new TreeMutation(Allele.treeBalsa, Allele.treeWenge, - TreeTemplates.getBaobabTemplate(), 10); - TreeTemplates.mahoeA = new TreeMutation(Allele.treeBalsa, Allele.treeDesertAcacia, - TreeTemplates.getMahoeTemplate(), 5); - - TreeTemplates.willowA = new TreeMutation(Allele.treeOak, Allele.treeBirch, TreeTemplates.getWillowTemplate(), 10) - .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) - .restrictHumidity(EnumHumidity.DAMP); - TreeTemplates.willowB = new TreeMutation(Allele.treeOak, Allele.treeLime, TreeTemplates.getWillowTemplate(), 10) - .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) - .restrictHumidity(EnumHumidity.DAMP); - TreeTemplates.willowC = new TreeMutation(Allele.treeLime, Allele.treeBirch, TreeTemplates.getWillowTemplate(), 10) - .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) - .restrictHumidity(EnumHumidity.DAMP); - - TreeTemplates.sipiriA = new TreeMutation(Allele.treeKapok, Allele.treeMahogany, TreeTemplates.getSipiriTemplate(), 10) - .restrictTemperature(EnumTemperature.WARM, EnumTemperature.HOT) - .restrictHumidity(EnumHumidity.DAMP); - - TreeTemplates.poplarA = new TreeMutation(Allele.treeBirch, Allele.treeWillow, - TreeTemplates.getPoplarTemplate(), 5); - TreeTemplates.poplarB = new TreeMutation(Allele.treeOak, Allele.treeWillow, - TreeTemplates.getPoplarTemplate(), 5); - TreeTemplates.poplarB = new TreeMutation(Allele.treeLime, Allele.treeWillow, - TreeTemplates.getPoplarTemplate(), 5); + AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 0), TreeDefinition.Oak.getIndividual()); + AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 1), TreeDefinition.Spruce.getIndividual()); + AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 2), TreeDefinition.Birch.getIndividual()); + AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 3), TreeDefinition.Jungle.getIndividual()); + AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 4), TreeDefinition.Acacia.getIndividual()); + AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 5), TreeDefinition.DarkOak.getIndividual()); } @Override @@ -1218,38 +427,21 @@ public class PluginArboriculture extends ForestryPlugin { private static void registerDungeonLoot() { ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(ForestryItem.grafter.getItemStack(), 1, 1, 8)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getOakTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getSpruceTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getBirchTemplate(), EnumGermlingType.SAPLING), 2, 3, 6)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLarchTemplate(), EnumGermlingType.SAPLING), 1, 2, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLimeTemplate(), EnumGermlingType.SAPLING), 1, 2, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Oak.getMemberStack(EnumGermlingType.SAPLING), 2, 3, 6)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Spruce.getMemberStack(EnumGermlingType.SAPLING), 2, 3, 6)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Birch.getMemberStack(EnumGermlingType.SAPLING), 2, 3, 6)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Larch.getMemberStack(EnumGermlingType.SAPLING), 1, 2, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Lime.getMemberStack(EnumGermlingType.SAPLING), 1, 2, 4)); if (PluginManager.Module.APICULTURE.isEnabled()) { - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getOakTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getSpruceTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getBirchTemplate(), EnumGermlingType.POLLEN), 2, 3, 4)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLarchTemplate(), EnumGermlingType.POLLEN), 1, 2, 3)); - ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(getTreeItemFromTemplate(TreeTemplates.getLimeTemplate(), EnumGermlingType.POLLEN), 1, 2, 3)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Oak.getMemberStack(EnumGermlingType.POLLEN), 2, 3, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Spruce.getMemberStack(EnumGermlingType.POLLEN), 2, 3, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Birch.getMemberStack(EnumGermlingType.POLLEN), 2, 3, 4)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Larch.getMemberStack(EnumGermlingType.POLLEN), 1, 2, 3)); + ChestGenHooks.addItem(Defaults.CHEST_GEN_HOOK_NATURALIST_CHEST, new WeightedRandomChestContent(TreeDefinition.Lime.getMemberStack(EnumGermlingType.POLLEN), 1, 2, 3)); } } - private static ItemStack getTreeItemFromTemplate(IAllele[] template, EnumGermlingType type) { - ITree tree = new Tree(PluginArboriculture.treeInterface.templateAsGenome(template)); - ItemStack treeItem; - switch (type) { - default: - case POLLEN: - treeItem = ForestryItem.pollenFertile.getItemStack(); - break; - case SAPLING: - treeItem = ForestryItem.sapling.getItemStack(); - } - NBTTagCompound nbtTagCompound = new NBTTagCompound(); - tree.writeToNBT(nbtTagCompound); - treeItem.setTagCompound(nbtTagCompound); - return treeItem; - } - private static class FuelHandler implements IFuelHandler { @Override public int getBurnTime(ItemStack fuel) { @@ -1257,10 +449,8 @@ public class PluginArboriculture extends ForestryPlugin { return 100; } - for (ForestryBlock slab : slabs) { - if (slab.isItemEqual(fuel)) { - return 150; - } + if (ForestryBlock.slabs.isItemEqual(fuel)) { + return 150; } return 0;