mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Tree refactor. Breaks wooden logs and planks.
Fix #758 Add fireproof versions of all Forestry wooden items Fix #762 Forestry saplings are randomly invisible on place. Fix #689 Remove old fence recipes Fix #504 Make NaturalistEye pretty Fix #778 Villager house roofs should be made of colorful Forestry wood stairs
This commit is contained in:
1 parent
0a79ead98d
commit
3a5ccd87cd
98 files changed
+4205
-3178
No files matched your search
@@ -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<IAllele>());
|
||||
}
|
||||
|
||||
private int getGeneticAdvancement(IAllele species, ArrayList<IAllele> 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ItemStack> product = new ArrayList<ItemStack>();
|
||||
|
||||
float modeYieldMod = PluginArboriculture.treeInterface.getTreekeepingMode(world).getYieldModifier(genome, 1f);
|
||||
float modeYieldMod = TreeManager.treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1f);
|
||||
|
||||
for (Map.Entry<ItemStack, Float> entry : products.entrySet()) {
|
||||
if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry.getValue()) {
|
||||
|
||||
@@ -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<ItemStack, Float> entry : products.entrySet()) {
|
||||
if (world.rand.nextFloat() <= genome.getYield() * entry.getValue() * modeYieldMod * 5.0f * stage) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
package forestry.arboriculture;
|
||||
|
||||
public interface IWoodTyped {
|
||||
WoodType getWoodType(int meta);
|
||||
|
||||
String getBlockKind();
|
||||
|
||||
boolean isFireproof();
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)];
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<ITreekeepingMode> treekeepingModes = PluginArboriculture.treeInterface.getTreekeepingModes();
|
||||
ArrayList<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
|
||||
int modeStringCount = treekeepingModes.size();
|
||||
List<String> modeStrings = new ArrayList<String>(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<String> getDescription(String modeName) {
|
||||
ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(modeName);
|
||||
ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(modeName);
|
||||
return mode.getDescription();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -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<ItemStack>();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
@@ -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<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
}
|
||||
@@ -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<ItemStack> getLeafDrop(World world, GameProfile playerProfile, int x, int y, int z, float saplingModifier, int fortune) {
|
||||
private static ArrayList<ItemStack> getLeafDrop(World world, @Nullable GameProfile playerProfile, int x, int y, int z, float saplingModifier, int fortune) {
|
||||
ArrayList<ItemStack> prod = new ArrayList<ItemStack>();
|
||||
|
||||
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)
|
||||
|
||||
@@ -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<ItemStack> pickFruit(ItemStack tool) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
Executable → Regular
+107
-89
@@ -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 <T extends Block & IWoodTyped> 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<IFruitFamily> fruits = new ArrayList<IFruitFamily>();
|
||||
|
||||
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<String, LeafType> leafTypes = new HashMap<String, LeafType>();
|
||||
|
||||
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<? extends WorldGenArboriculture> 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<IFruitFamily> fruits = new ArrayList<IFruitFamily>();
|
||||
|
||||
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<? extends WorldGenArboriculture> 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<? extends WorldGenArboriculture> 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<IAllele>());
|
||||
}
|
||||
|
||||
private int getGeneticAdvancement(IAllele species, ArrayList<IAllele> 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<IFruitFamily> getSuitableFruit() {
|
||||
public List<IFruitFamily> 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<? extends WorldGenerator>[] 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<? extends WorldGenArboriculture> 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};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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<IMutation> combinations = PluginArboriculture.treeInterface.getCombinations(allele0, allele1, true);
|
||||
List<IMutation> 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<ITreeMutation> treeMutations = new ArrayList<ITreeMutation>();
|
||||
private static final List<ITreeMutation> treeMutations = new ArrayList<ITreeMutation>();
|
||||
|
||||
@Override
|
||||
public ArrayList<ITreeMutation> getMutations(boolean shuffle) {
|
||||
public List<ITreeMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(treeMutations);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<EnumLeafType, LeafTexture> leafTextures = new EnumMap<EnumLeafType, LeafTexture>(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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
-14
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Executable → Regular
+38
-34
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -107,7 +107,10 @@ public class AlleleHelper implements IAlleleHelper {
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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<IAlleleSpecies>(), speciesChromosome);
|
||||
}
|
||||
|
||||
private static int getGeneticAdvancement(IAlleleSpecies species, Set<IAlleleSpecies> 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;
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<ItemStack> 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<ItemStack> arraylist = new ArrayList<ItemStack>(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;
|
||||
}
|
||||
}
|
||||
@@ -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 extends TileEntity> T getTile(World world, int x, int y, int z, Class<T> tileClass) {
|
||||
public static <T extends TileEntity> T getTile(IBlockAccess world, int x, int y, int z, Class<T> tileClass) {
|
||||
T tileEntity = null;
|
||||
try {
|
||||
tileEntity = tileClass.cast(world.getTileEntity(x, y, z));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Executable → Regular
+2
-5
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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<Recipe> recipes = new ArrayList<Recipe>();
|
||||
public static final ArrayList<Smelting> smeltings = new ArrayList<Smelting>();
|
||||
|
||||
@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<Object[], Object[]> getRecipes() {
|
||||
HashMap<Object[], Object[]> recipeList = new HashMap<Object[], Object[]>();
|
||||
|
||||
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<IFabricatorRecipe> recipes = new ArrayList<IFabricatorRecipe>();
|
||||
public static final List<Smelting> smeltings = new ArrayList<Smelting>();
|
||||
|
||||
@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<Object[], Object[]> getRecipes() {
|
||||
HashMap<Object[], Object[]> recipeList = new HashMap<Object[], Object[]>();
|
||||
|
||||
for (IFabricatorRecipe recipe : recipes) {
|
||||
recipeList.put(recipe.getIngredients(), new Object[]{recipe.getRecipeOutput()});
|
||||
}
|
||||
|
||||
return recipeList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user