mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 19:29:17 +00:00
Close #1028 add Fireproof versions of Vanilla wood items
This commit is contained in:
1 parent
cdb85cb042
commit
23ffa00ca5
810 files changed
+4041
-3577
No files matched your search
+9
-9
@@ -9,9 +9,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumWoodType implements IStringSerializable {
|
||||
public enum EnumForestryWoodType implements IWoodType {
|
||||
LARCH, TEAK, ACACIA, LIME,
|
||||
CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f),
|
||||
|
||||
@@ -25,23 +23,24 @@ public enum EnumWoodType implements IStringSerializable {
|
||||
ZEBRAWOOD;
|
||||
|
||||
public static final float DEFAULT_HARDNESS = 2.0f;
|
||||
public static final EnumWoodType[] VALUES = values();
|
||||
public static final EnumForestryWoodType[] VALUES = values();
|
||||
|
||||
private final float hardness;
|
||||
|
||||
EnumWoodType() {
|
||||
this.hardness = DEFAULT_HARDNESS;
|
||||
EnumForestryWoodType() {
|
||||
this(DEFAULT_HARDNESS);
|
||||
}
|
||||
|
||||
EnumWoodType(float hardness) {
|
||||
EnumForestryWoodType(float hardness) {
|
||||
this.hardness = hardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness() {
|
||||
return hardness;
|
||||
}
|
||||
|
||||
public static EnumWoodType getRandom(Random random) {
|
||||
public static EnumForestryWoodType getRandom(Random random) {
|
||||
return VALUES[random.nextInt(VALUES.length)];
|
||||
}
|
||||
|
||||
@@ -55,12 +54,13 @@ public enum EnumWoodType implements IStringSerializable {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static EnumWoodType byMetadata(int meta) {
|
||||
public static EnumForestryWoodType byMetadata(int meta) {
|
||||
if (meta < 0 || meta >= VALUES.length) {
|
||||
meta = 0;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
|
||||
public enum EnumVanillaWoodType implements IWoodType {
|
||||
OAK(BlockPlanks.EnumType.OAK),
|
||||
BIRCH(BlockPlanks.EnumType.BIRCH),
|
||||
SPRUCE(BlockPlanks.EnumType.SPRUCE),
|
||||
JUNGLE(BlockPlanks.EnumType.JUNGLE),
|
||||
ACACIA(BlockPlanks.EnumType.ACACIA),
|
||||
DARK_OAK(BlockPlanks.EnumType.DARK_OAK);
|
||||
|
||||
public static final EnumVanillaWoodType[] VALUES = values();
|
||||
|
||||
public static EnumVanillaWoodType getRandom(Random random) {
|
||||
return VALUES[random.nextInt(VALUES.length)];
|
||||
}
|
||||
|
||||
private final BlockPlanks.EnumType vanillaType;
|
||||
|
||||
EnumVanillaWoodType(BlockPlanks.EnumType vanillaType) {
|
||||
this.vanillaType = vanillaType;
|
||||
}
|
||||
|
||||
public BlockPlanks.EnumType getVanillaType() {
|
||||
return vanillaType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static EnumVanillaWoodType byMetadata(int meta) {
|
||||
if (meta < 0 || meta >= VALUES.length) {
|
||||
meta = 0;
|
||||
}
|
||||
return VALUES[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness() {
|
||||
return 2.0F;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -43,12 +44,6 @@ public interface IAlleleTreeSpecies extends IAlleleSpecies, IAlleleProperty<IAll
|
||||
@Nonnull
|
||||
ITreeGenerator getGenerator();
|
||||
|
||||
/**
|
||||
* @return The name of the model from the tree.
|
||||
*/
|
||||
@Nonnull
|
||||
String getModelName();
|
||||
|
||||
/**
|
||||
* @return The modid from the mod of the species.
|
||||
*/
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
@@ -25,14 +24,13 @@ public interface ITreeFactory {
|
||||
* @param branch Classification of this species
|
||||
* @param binomial Binomial name of the species sans genus. "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun names or null.
|
||||
* @param modID The modID from the mod of the species
|
||||
* @param modelName The model name for this species
|
||||
* @param leafSpriteProvider The leaf sprite provider for this species
|
||||
* @param germlingModelProvider The germling model provider for this species
|
||||
* @param woodProvider The wood texture provider. It is used to get wood textures for the charcoal pile.
|
||||
* @param generator The tree generator
|
||||
* @return a new tree species allele.
|
||||
*/
|
||||
IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, String modelName, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, @Nonnull IWoodProvider woodProvider, ITreeGenerator generator);
|
||||
IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, @Nonnull IWoodProvider woodProvider, ITreeGenerator generator);
|
||||
|
||||
/** Get one of the built-in Forestry leaf types. Default type is deciduous. */
|
||||
ILeafSpriteProvider getLeafIconProvider(EnumLeafType enumLeafType, Color color, Color colorPollinated);
|
||||
|
||||
@@ -5,69 +5,22 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Provides easy access to Forestry and Vanilla wood items.
|
||||
* Forestry wood blocks have the same block state properties as vanilla ones.
|
||||
* Note that all doors are fireproof (even vanilla).
|
||||
*
|
||||
* @see WoodBlockKind
|
||||
* @see EnumForestryWoodType
|
||||
* @see EnumVanillaWoodType
|
||||
*/
|
||||
public interface IWoodAccess {
|
||||
// ITEMS
|
||||
|
||||
ItemStack getLog(EnumWoodType woodType, boolean fireproof);
|
||||
ItemStack getStack(IWoodType woodType, WoodBlockKind kind, boolean fireproof);
|
||||
|
||||
ItemStack getPlanks(EnumWoodType woodType, boolean fireproof);
|
||||
IBlockState getBlock(IWoodType woodType, WoodBlockKind kind, boolean fireproof);
|
||||
|
||||
ItemStack getSlab(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getFence(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
ItemStack getStairs(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* All doors in Minecraft are fireproof.
|
||||
*/
|
||||
ItemStack getDoor(EnumWoodType woodType);
|
||||
|
||||
// BLOCKS
|
||||
|
||||
/**
|
||||
* Forestry logs have their own properties for woodType and use {@link BlockLog.EnumAxis} for orientation.
|
||||
*/
|
||||
IBlockState getLogBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry slabs have no properties except their wood type.
|
||||
*/
|
||||
IBlockState getPlanksBlock(EnumWoodType woodType, boolean fireProof);
|
||||
|
||||
/**
|
||||
* Forestry slabs have the same properties as {@link BlockSlab}
|
||||
*/
|
||||
IBlockState getSlabBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry fences have the same properties as {@link BlockFence}
|
||||
*/
|
||||
IBlockState getFenceBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry fence gates have the same properties as {@link BlockFenceGate}
|
||||
*/
|
||||
IBlockState getFenceGateBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry stairs have the same properties as {@link BlockStairs}
|
||||
*/
|
||||
IBlockState getStairsBlock(EnumWoodType woodType, boolean fireproof);
|
||||
|
||||
/**
|
||||
* Forestry doors have the same properties as {@link BlockDoor}
|
||||
*/
|
||||
IBlockState getDoorBlock(EnumWoodType woodType);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
/**
|
||||
* @see EnumForestryWoodType
|
||||
* @see EnumVanillaWoodType
|
||||
*/
|
||||
public interface IWoodType extends IStringSerializable {
|
||||
int getMetadata();
|
||||
|
||||
float getHardness();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum WoodBlockKind {
|
||||
LOG, PLANKS, SLAB, FENCE, FENCE_GATE, STAIRS, DOOR;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockNewLog;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
@@ -47,9 +46,12 @@ import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -92,40 +94,22 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
}
|
||||
|
||||
private void createBuildingBlocks(Random random) {
|
||||
boolean fireproof = random.nextInt(4) == 0;
|
||||
IWoodType woodType;
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
|
||||
|
||||
boolean fireproof = random.nextInt(4) == 0;
|
||||
|
||||
EnumWoodType woodType = EnumWoodType.getRandom(random);
|
||||
|
||||
IWoodAccess woodAccess = TreeManager.woodAccess;
|
||||
this.logs = woodAccess.getLogBlock(woodType, fireproof).withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
this.planks = woodAccess.getPlanksBlock(woodType, fireproof);
|
||||
this.stairs = woodAccess.getStairsBlock(woodType, fireproof);
|
||||
this.fence = woodAccess.getFenceBlock(woodType, fireproof);
|
||||
this.door = woodAccess.getDoorBlock(woodType);
|
||||
this.fenceGate = woodAccess.getFenceGateBlock(woodType, fireproof);
|
||||
woodType = EnumForestryWoodType.getRandom(random);
|
||||
} else {
|
||||
if (random.nextInt(6) < 4) {
|
||||
this.logs = getRandomVariant(random, Blocks.LOG.getDefaultState(), BlockOldLog.VARIANT);
|
||||
} else {
|
||||
this.logs = getRandomVariant(random, Blocks.LOG2.getDefaultState(), BlockNewLog.VARIANT);
|
||||
}
|
||||
this.planks = getRandomVariant(random, Blocks.PLANKS.getDefaultState(), BlockPlanks.VARIANT);
|
||||
|
||||
List<Block> stairs = Arrays.asList(
|
||||
Blocks.ACACIA_STAIRS, Blocks.BIRCH_STAIRS, Blocks.DARK_OAK_STAIRS, Blocks.JUNGLE_STAIRS, Blocks.SPRUCE_STAIRS
|
||||
);
|
||||
this.stairs = stairs.get(random.nextInt(stairs.size())).getDefaultState();
|
||||
|
||||
List<Block> fences = Arrays.asList(
|
||||
Blocks.ACACIA_FENCE, Blocks.BIRCH_FENCE, Blocks.DARK_OAK_FENCE, Blocks.JUNGLE_FENCE, Blocks.SPRUCE_FENCE
|
||||
);
|
||||
this.fence = fences.get(random.nextInt(fences.size())).getDefaultState();
|
||||
|
||||
this.door = Blocks.OAK_DOOR.getDefaultState();
|
||||
this.fenceGate = Blocks.OAK_FENCE_GATE.getDefaultState();
|
||||
woodType = EnumVanillaWoodType.getRandom(random);
|
||||
}
|
||||
|
||||
IWoodAccess woodAccess = TreeManager.woodAccess;
|
||||
this.logs = woodAccess.getBlock(woodType, WoodBlockKind.LOG, fireproof).withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
this.planks = woodAccess.getBlock(woodType, WoodBlockKind.PLANKS, fireproof);
|
||||
this.stairs = woodAccess.getBlock(woodType, WoodBlockKind.STAIRS, fireproof);
|
||||
this.fence = woodAccess.getBlock(woodType, WoodBlockKind.FENCE, fireproof);
|
||||
this.door = woodAccess.getBlock(woodType, WoodBlockKind.DOOR, false);
|
||||
this.fenceGate = woodAccess.getBlock(woodType, WoodBlockKind.FENCE_GATE, fireproof);
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> IBlockState getRandomVariant(Random random, IBlockState defaultState, IProperty<T> variantProperty) {
|
||||
|
||||
@@ -13,17 +13,18 @@ package forestry.arboriculture;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
|
||||
public interface IWoodTyped {
|
||||
@Nonnull
|
||||
String getBlockKind();
|
||||
WoodBlockKind getBlockKind();
|
||||
|
||||
boolean isFireproof();
|
||||
|
||||
@Nonnull
|
||||
EnumWoodType getWoodType(int meta);
|
||||
IWoodType getWoodType(int meta);
|
||||
|
||||
@Nonnull
|
||||
Collection<EnumWoodType> getWoodTypes();
|
||||
Collection<? extends IWoodType> getWoodTypes();
|
||||
}
|
||||
@@ -13,6 +13,7 @@ package forestry.arboriculture;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -39,12 +40,15 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumPileType;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ILeafTranslator;
|
||||
@@ -52,10 +56,10 @@ import forestry.api.genetics.ISaplingTranslator;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.arboriculture.blocks.BlockArbLog;
|
||||
import forestry.arboriculture.blocks.BlockArbSlab;
|
||||
import forestry.arboriculture.blocks.BlockPile;
|
||||
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
import forestry.arboriculture.blocks.slab.BlockArbSlab;
|
||||
import forestry.arboriculture.commands.CommandTree;
|
||||
import forestry.arboriculture.genetics.TreeBranchDefinition;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
@@ -152,6 +156,13 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
WoodAccess.registerFenceGates(blocks.fenceGatesFireproof);
|
||||
WoodAccess.registerStairs(blocks.stairsFireproof);
|
||||
|
||||
WoodAccess.registerLogs(blocks.logsVanillaFireproof);
|
||||
WoodAccess.registerPlanks(blocks.planksVanillaFireproof);
|
||||
WoodAccess.registerSlabs(blocks.slabsVanillaFireproof);
|
||||
WoodAccess.registerFences(blocks.fencesVanillaFireproof);
|
||||
WoodAccess.registerFenceGates(blocks.fenceGatesVanillaFireproof);
|
||||
WoodAccess.registerStairs(blocks.stairsVanillaFireproof);
|
||||
|
||||
// Init rendering
|
||||
proxy.initializeModels();
|
||||
|
||||
@@ -227,35 +238,69 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
RecipeUtil.addSmelting(logInput, coalOutput, 0.15F);
|
||||
}
|
||||
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
ItemStack planks = TreeManager.woodAccess.getPlanks(woodType, false);
|
||||
ItemStack logs = TreeManager.woodAccess.getLog(woodType, false);
|
||||
ItemStack slabs = TreeManager.woodAccess.getSlab(woodType, false);
|
||||
ItemStack fences = TreeManager.woodAccess.getFence(woodType, false);
|
||||
ItemStack fenceGates = TreeManager.woodAccess.getFenceGate(woodType, false);
|
||||
ItemStack stairs = TreeManager.woodAccess.getStairs(woodType, false);
|
||||
ItemStack doors = TreeManager.woodAccess.getDoor(woodType);
|
||||
List<IWoodType> allWoodTypes = new ArrayList<>();
|
||||
Collections.addAll(allWoodTypes, EnumForestryWoodType.VALUES);
|
||||
Collections.addAll(allWoodTypes, EnumVanillaWoodType.VALUES);
|
||||
|
||||
ItemStack fireproofPlanks = TreeManager.woodAccess.getPlanks(woodType, true);
|
||||
ItemStack fireproofLogs = TreeManager.woodAccess.getLog(woodType, true);
|
||||
ItemStack fireproofSlabs = TreeManager.woodAccess.getSlab(woodType, true);
|
||||
ItemStack fireproofFences = TreeManager.woodAccess.getFence(woodType, true);
|
||||
ItemStack fireproofFenceGates = TreeManager.woodAccess.getFenceGate(woodType, true);
|
||||
ItemStack fireproofStairs = TreeManager.woodAccess.getStairs(woodType, true);
|
||||
for (IWoodType woodType : allWoodTypes) {
|
||||
ItemStack planks = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.PLANKS, false);
|
||||
ItemStack logs = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
ItemStack slabs = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.SLAB, false);
|
||||
ItemStack fences = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.FENCE, false);
|
||||
ItemStack fenceGates = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.FENCE_GATE, false);
|
||||
ItemStack stairs = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.STAIRS, false);
|
||||
ItemStack doors = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.DOOR, false);
|
||||
|
||||
planks.stackSize = 4;
|
||||
logs.stackSize = 1;
|
||||
RecipeUtil.addShapelessRecipe(planks.copy(), logs.copy());
|
||||
ItemStack fireproofPlanks = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.PLANKS, true);
|
||||
ItemStack fireproofLogs = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, true);
|
||||
ItemStack fireproofSlabs = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.SLAB, true);
|
||||
ItemStack fireproofFences = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.FENCE, true);
|
||||
ItemStack fireproofFenceGates = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.FENCE_GATE, true);
|
||||
ItemStack fireproofStairs = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.STAIRS, true);
|
||||
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
planks.stackSize = 4;
|
||||
logs.stackSize = 1;
|
||||
RecipeUtil.addShapelessRecipe(planks.copy(), logs.copy());
|
||||
|
||||
slabs.stackSize = 6;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(slabs.copy(), "###", '#', planks.copy());
|
||||
|
||||
fences.stackSize = 3;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addRecipe(fences.copy(),
|
||||
"#X#",
|
||||
"#X#",
|
||||
'#', planks.copy(), 'X', "stickWood");
|
||||
|
||||
fenceGates.stackSize = 1;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addRecipe(fenceGates.copy(),
|
||||
"X#X",
|
||||
"X#X",
|
||||
'#', planks.copy(), 'X', "stickWood");
|
||||
|
||||
stairs.stackSize = 4;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(stairs.copy(),
|
||||
"# ",
|
||||
"## ",
|
||||
"###",
|
||||
'#', planks.copy());
|
||||
|
||||
doors.stackSize = 3;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(doors.copy(),
|
||||
"## ",
|
||||
"## ",
|
||||
"## ",
|
||||
'#', planks.copy());
|
||||
}
|
||||
|
||||
fireproofPlanks.stackSize = 4;
|
||||
fireproofLogs.stackSize = 1;
|
||||
RecipeUtil.addShapelessRecipe(fireproofPlanks.copy(), fireproofLogs.copy());
|
||||
|
||||
slabs.stackSize = 6;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(slabs.copy(),
|
||||
"###",
|
||||
'#', planks.copy());
|
||||
|
||||
fireproofSlabs.stackSize = 6;
|
||||
fireproofPlanks.stackSize = 1;
|
||||
@@ -263,26 +308,12 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
"###",
|
||||
'#', fireproofPlanks.copy());
|
||||
|
||||
fences.stackSize = 3;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addRecipe(fences.copy(),
|
||||
"#X#",
|
||||
"#X#",
|
||||
'#', planks.copy(), 'X', "stickWood");
|
||||
|
||||
fireproofFences.stackSize = 3;
|
||||
fireproofPlanks.stackSize = 1;
|
||||
RecipeUtil.addRecipe(fireproofFences.copy(),
|
||||
"#X#",
|
||||
"#X#",
|
||||
'#', fireproofPlanks.copy(), 'X', "stickWood");
|
||||
|
||||
fenceGates.stackSize = 1;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addRecipe(fenceGates.copy(),
|
||||
"X#X",
|
||||
"X#X",
|
||||
'#', planks.copy(), 'X', "stickWood");
|
||||
|
||||
fireproofFenceGates.stackSize = 1;
|
||||
fireproofPlanks.stackSize = 1;
|
||||
@@ -291,14 +322,6 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
"X#X",
|
||||
'#', fireproofPlanks.copy(), 'X', "stickWood");
|
||||
|
||||
stairs.stackSize = 4;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(stairs.copy(),
|
||||
"# ",
|
||||
"## ",
|
||||
"###",
|
||||
'#', planks.copy());
|
||||
|
||||
fireproofStairs.stackSize = 4;
|
||||
fireproofPlanks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(fireproofStairs.copy(),
|
||||
@@ -307,14 +330,6 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
"###",
|
||||
'#', fireproofPlanks.copy());
|
||||
|
||||
doors.stackSize = 3;
|
||||
planks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(doors.copy(),
|
||||
"## ",
|
||||
"## ",
|
||||
"## ",
|
||||
'#', planks.copy());
|
||||
|
||||
doors.stackSize = 3;
|
||||
fireproofPlanks.stackSize = 1;
|
||||
RecipeUtil.addPriorityRecipe(doors.copy(),
|
||||
|
||||
@@ -13,9 +13,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
@@ -47,8 +48,8 @@ public class VillagerArboristTrades {
|
||||
j = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
EnumWoodType woodType = EnumWoodType.getRandom(random);
|
||||
ItemStack sellStack = TreeManager.woodAccess.getLog(woodType, false);
|
||||
EnumForestryWoodType woodType = EnumForestryWoodType.getRandom(random);
|
||||
ItemStack sellStack = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
sellStack.stackSize = i;
|
||||
|
||||
ItemStack emeralds = new ItemStack(Items.EMERALD, j);
|
||||
@@ -80,8 +81,8 @@ public class VillagerArboristTrades {
|
||||
j = this.emeraldPriceInfo.getPrice(random);
|
||||
}
|
||||
|
||||
EnumWoodType woodType = EnumWoodType.getRandom(random);
|
||||
ItemStack sellStack = TreeManager.woodAccess.getPlanks(woodType, false);
|
||||
EnumForestryWoodType woodType = EnumForestryWoodType.getRandom(random);
|
||||
ItemStack sellStack = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.PLANKS, false);
|
||||
sellStack.stackSize = i;
|
||||
|
||||
ItemStack emeralds = new ItemStack(Items.EMERALD, j);
|
||||
|
||||
@@ -12,230 +12,226 @@ package forestry.arboriculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockNewLog;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockWoodSlab;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.arboriculture.blocks.BlockArbDoor;
|
||||
import forestry.arboriculture.blocks.BlockArbFence;
|
||||
import forestry.arboriculture.blocks.BlockArbFenceGate;
|
||||
import forestry.arboriculture.blocks.BlockArbLog;
|
||||
import forestry.arboriculture.blocks.BlockArbPlanks;
|
||||
import forestry.arboriculture.blocks.BlockArbSlab;
|
||||
import forestry.arboriculture.blocks.BlockArbStairs;
|
||||
import forestry.arboriculture.blocks.BlockForestryFenceGate;
|
||||
import forestry.arboriculture.blocks.BlockForestryStairs;
|
||||
import forestry.arboriculture.blocks.fence.BlockForestryFence;
|
||||
import forestry.arboriculture.blocks.log.BlockForestryLog;
|
||||
import forestry.arboriculture.blocks.planks.BlockForestryPlanks;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.arboriculture.blocks.slab.BlockForestrySlab;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class WoodAccess implements IWoodAccess {
|
||||
private static final WoodMap logs = new WoodMap("logs");
|
||||
private static final WoodMap planks = new WoodMap("planks");
|
||||
private static final WoodMap slabs = new WoodMap("slabs");
|
||||
private static final WoodMap fences = new WoodMap("fences");
|
||||
private static final WoodMap fenceGates = new WoodMap("fenceGates");
|
||||
private static final WoodMap stairs = new WoodMap("stairs");
|
||||
private static final WoodMap doors = new WoodMap("doors") {
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumMap<EnumWoodType, ItemStack> getItem(boolean fireproof) {
|
||||
return super.getItem(false);
|
||||
}
|
||||
private static final Map<WoodBlockKind, WoodMap> woodMaps = new EnumMap<>(WoodBlockKind.class);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumMap<EnumWoodType, IBlockState> getBlock(boolean fireproof) {
|
||||
return super.getBlock(false);
|
||||
static {
|
||||
for (WoodBlockKind woodBlockKind : WoodBlockKind.values()) {
|
||||
woodMaps.put(woodBlockKind, new WoodMap(woodBlockKind));
|
||||
}
|
||||
};
|
||||
registerVanilla();
|
||||
}
|
||||
|
||||
private static class WoodMap {
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, ItemStack> normalItems = new EnumMap<>(EnumWoodType.class);
|
||||
private final Map<IWoodType, ItemStack> normalItems = new HashMap<>();
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, ItemStack> fireproofItems = new EnumMap<>(EnumWoodType.class);
|
||||
private final Map<IWoodType, ItemStack> fireproofItems = new HashMap<>();
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, IBlockState> normalBlocks = new EnumMap<>(EnumWoodType.class);
|
||||
private final Map<IWoodType, IBlockState> normalBlocks = new HashMap<>();
|
||||
@Nonnull
|
||||
private final EnumMap<EnumWoodType, IBlockState> fireproofBlocks = new EnumMap<>(EnumWoodType.class);
|
||||
private final Map<IWoodType, IBlockState> fireproofBlocks = new HashMap<>();
|
||||
@Nonnull
|
||||
private final String name;
|
||||
private final WoodBlockKind woodBlockKind;
|
||||
|
||||
public WoodMap(@Nonnull String name) {
|
||||
this.name = name;
|
||||
public WoodMap(@Nonnull WoodBlockKind woodBlockKind) {
|
||||
this.woodBlockKind = woodBlockKind;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getName() {
|
||||
return name;
|
||||
return woodBlockKind.name();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public EnumMap<EnumWoodType, ItemStack> getItem(boolean fireproof) {
|
||||
public Map<IWoodType, ItemStack> getItem(boolean fireproof) {
|
||||
return fireproof ? this.fireproofItems : this.normalItems;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public EnumMap<EnumWoodType, IBlockState> getBlock(boolean fireproof) {
|
||||
public Map<IWoodType, IBlockState> getBlock(boolean fireproof) {
|
||||
return fireproof ? this.fireproofBlocks : this.normalBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerLogs(List<BlockArbLog> blocks) {
|
||||
for (BlockArbLog block : blocks) {
|
||||
registerWithVariants(block, logs, block.getVariant());
|
||||
public static void registerLogs(List<? extends BlockForestryLog> blocks) {
|
||||
for (BlockForestryLog block : blocks) {
|
||||
registerWithVariants(block, WoodBlockKind.LOG, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerPlanks(List<BlockArbPlanks> blocks) {
|
||||
for (BlockArbPlanks block : blocks) {
|
||||
registerWithVariants(block, planks, block.getVariant());
|
||||
public static void registerPlanks(List<? extends BlockForestryPlanks> blocks) {
|
||||
for (BlockForestryPlanks block : blocks) {
|
||||
registerWithVariants(block, WoodBlockKind.PLANKS, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerSlabs(List<BlockArbSlab> blocks) {
|
||||
for (BlockArbSlab block : blocks) {
|
||||
registerWithVariants(block, slabs, block.getVariant());
|
||||
public static void registerSlabs(List<? extends BlockForestrySlab> blocks) {
|
||||
for (BlockForestrySlab block : blocks) {
|
||||
registerWithVariants(block, WoodBlockKind.SLAB, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerFences(List<BlockArbFence> blocks) {
|
||||
for (BlockArbFence block : blocks) {
|
||||
registerWithVariants(block, fences, block.getVariant());
|
||||
public static void registerFences(List<? extends BlockForestryFence> blocks) {
|
||||
for (BlockForestryFence block : blocks) {
|
||||
registerWithVariants(block, WoodBlockKind.FENCE, block.getVariant());
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerFenceGates(List<BlockArbFenceGate> blocks) {
|
||||
for (BlockArbFenceGate block : blocks) {
|
||||
registerWithoutVariants(block, fenceGates);
|
||||
public static void registerFenceGates(List<BlockForestryFenceGate> blocks) {
|
||||
for (BlockForestryFenceGate block : blocks) {
|
||||
registerWithoutVariants(block, WoodBlockKind.FENCE_GATE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerStairs(List<BlockArbStairs> blocks) {
|
||||
for (BlockArbStairs block : blocks) {
|
||||
registerWithoutVariants(block, stairs);
|
||||
public static void registerStairs(List<? extends BlockForestryStairs> blocks) {
|
||||
for (BlockForestryStairs block : blocks) {
|
||||
registerWithoutVariants(block, WoodBlockKind.STAIRS);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerDoors(List<BlockArbDoor> blocks) {
|
||||
for (BlockArbDoor block : blocks) {
|
||||
registerWithoutVariants(block, doors);
|
||||
registerWithoutVariants(block, WoodBlockKind.DOOR);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends Block & IWoodTyped> void registerWithVariants(T woodTyped, WoodMap woodMap, PropertyWoodType property) {
|
||||
private static void registerVanilla() {
|
||||
IBlockState defaultLogState = Blocks.LOG.getDefaultState();
|
||||
register(EnumVanillaWoodType.OAK, WoodBlockKind.LOG, false, defaultLogState.withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK), new ItemStack(Blocks.LOG, 1, 0));
|
||||
register(EnumVanillaWoodType.BIRCH, WoodBlockKind.LOG, false, defaultLogState.withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.BIRCH), new ItemStack(Blocks.LOG, 1, 1));
|
||||
register(EnumVanillaWoodType.SPRUCE, WoodBlockKind.LOG, false, defaultLogState.withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE), new ItemStack(Blocks.LOG, 1, 2));
|
||||
register(EnumVanillaWoodType.JUNGLE, WoodBlockKind.LOG, false, defaultLogState.withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE), new ItemStack(Blocks.LOG, 1, 3));
|
||||
IBlockState defaultLog2State = Blocks.LOG2.getDefaultState();
|
||||
register(EnumVanillaWoodType.ACACIA, WoodBlockKind.LOG, false, defaultLog2State.withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA), new ItemStack(Blocks.LOG2, 1, 0));
|
||||
register(EnumVanillaWoodType.DARK_OAK, WoodBlockKind.LOG, false, defaultLog2State.withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.DARK_OAK), new ItemStack(Blocks.LOG2, 1, 1));
|
||||
|
||||
IBlockState defaultPlanksState = Blocks.PLANKS.getDefaultState();
|
||||
IBlockState defaultSlabState = Blocks.WOODEN_SLAB.getDefaultState();
|
||||
for (EnumVanillaWoodType woodType : EnumVanillaWoodType.VALUES) {
|
||||
BlockPlanks.EnumType vanillaType = woodType.getVanillaType();
|
||||
|
||||
ItemStack plankStack = new ItemStack(Blocks.PLANKS, 1, vanillaType.getMetadata());
|
||||
IBlockState plankState = defaultPlanksState.withProperty(BlockPlanks.VARIANT, vanillaType);
|
||||
register(woodType, WoodBlockKind.PLANKS, false, plankState, plankStack);
|
||||
|
||||
ItemStack slabStack = new ItemStack(Blocks.WOODEN_SLAB, 1, vanillaType.getMetadata());
|
||||
IBlockState slabState = defaultSlabState.withProperty(BlockWoodSlab.VARIANT, vanillaType);
|
||||
register(woodType, WoodBlockKind.SLAB, false, slabState, slabStack);
|
||||
}
|
||||
|
||||
register(EnumVanillaWoodType.OAK, WoodBlockKind.FENCE, false, Blocks.OAK_FENCE.getDefaultState(), new ItemStack(Blocks.OAK_FENCE));
|
||||
register(EnumVanillaWoodType.BIRCH, WoodBlockKind.FENCE, false, Blocks.BIRCH_FENCE.getDefaultState(), new ItemStack(Blocks.BIRCH_FENCE));
|
||||
register(EnumVanillaWoodType.SPRUCE, WoodBlockKind.FENCE, false, Blocks.SPRUCE_FENCE.getDefaultState(), new ItemStack(Blocks.SPRUCE_FENCE));
|
||||
register(EnumVanillaWoodType.JUNGLE, WoodBlockKind.FENCE, false, Blocks.JUNGLE_FENCE.getDefaultState(), new ItemStack(Blocks.JUNGLE_FENCE));
|
||||
register(EnumVanillaWoodType.ACACIA, WoodBlockKind.FENCE, false, Blocks.ACACIA_FENCE.getDefaultState(), new ItemStack(Blocks.ACACIA_FENCE));
|
||||
register(EnumVanillaWoodType.DARK_OAK, WoodBlockKind.FENCE, false, Blocks.DARK_OAK_FENCE.getDefaultState(), new ItemStack(Blocks.DARK_OAK_FENCE));
|
||||
|
||||
register(EnumVanillaWoodType.OAK, WoodBlockKind.FENCE_GATE, false, Blocks.OAK_FENCE_GATE.getDefaultState(), new ItemStack(Blocks.OAK_FENCE_GATE));
|
||||
register(EnumVanillaWoodType.BIRCH, WoodBlockKind.FENCE_GATE, false, Blocks.BIRCH_FENCE_GATE.getDefaultState(), new ItemStack(Blocks.BIRCH_FENCE_GATE));
|
||||
register(EnumVanillaWoodType.SPRUCE, WoodBlockKind.FENCE_GATE, false, Blocks.SPRUCE_FENCE_GATE.getDefaultState(), new ItemStack(Blocks.SPRUCE_FENCE_GATE));
|
||||
register(EnumVanillaWoodType.JUNGLE, WoodBlockKind.FENCE_GATE, false, Blocks.JUNGLE_FENCE_GATE.getDefaultState(), new ItemStack(Blocks.JUNGLE_FENCE_GATE));
|
||||
register(EnumVanillaWoodType.ACACIA, WoodBlockKind.FENCE_GATE, false, Blocks.ACACIA_FENCE_GATE.getDefaultState(), new ItemStack(Blocks.ACACIA_FENCE_GATE));
|
||||
register(EnumVanillaWoodType.DARK_OAK, WoodBlockKind.FENCE_GATE, false, Blocks.DARK_OAK_FENCE_GATE.getDefaultState(), new ItemStack(Blocks.DARK_OAK_FENCE_GATE));
|
||||
|
||||
register(EnumVanillaWoodType.OAK, WoodBlockKind.STAIRS, false, Blocks.OAK_STAIRS.getDefaultState(), new ItemStack(Blocks.OAK_STAIRS));
|
||||
register(EnumVanillaWoodType.BIRCH, WoodBlockKind.STAIRS, false, Blocks.BIRCH_STAIRS.getDefaultState(), new ItemStack(Blocks.BIRCH_STAIRS));
|
||||
register(EnumVanillaWoodType.SPRUCE, WoodBlockKind.STAIRS, false, Blocks.SPRUCE_STAIRS.getDefaultState(), new ItemStack(Blocks.SPRUCE_STAIRS));
|
||||
register(EnumVanillaWoodType.JUNGLE, WoodBlockKind.STAIRS, false, Blocks.JUNGLE_STAIRS.getDefaultState(), new ItemStack(Blocks.JUNGLE_STAIRS));
|
||||
register(EnumVanillaWoodType.ACACIA, WoodBlockKind.STAIRS, false, Blocks.ACACIA_STAIRS.getDefaultState(), new ItemStack(Blocks.ACACIA_STAIRS));
|
||||
register(EnumVanillaWoodType.DARK_OAK, WoodBlockKind.STAIRS, false, Blocks.DARK_OAK_STAIRS.getDefaultState(), new ItemStack(Blocks.DARK_OAK_STAIRS));
|
||||
|
||||
register(EnumVanillaWoodType.OAK, WoodBlockKind.DOOR, false, Blocks.OAK_DOOR.getDefaultState(), new ItemStack(Items.OAK_DOOR));
|
||||
register(EnumVanillaWoodType.BIRCH, WoodBlockKind.DOOR, false, Blocks.BIRCH_DOOR.getDefaultState(), new ItemStack(Items.BIRCH_DOOR));
|
||||
register(EnumVanillaWoodType.SPRUCE, WoodBlockKind.DOOR, false, Blocks.SPRUCE_DOOR.getDefaultState(), new ItemStack(Items.SPRUCE_DOOR));
|
||||
register(EnumVanillaWoodType.JUNGLE, WoodBlockKind.DOOR, false, Blocks.JUNGLE_DOOR.getDefaultState(), new ItemStack(Items.JUNGLE_DOOR));
|
||||
register(EnumVanillaWoodType.ACACIA, WoodBlockKind.DOOR, false, Blocks.ACACIA_DOOR.getDefaultState(), new ItemStack(Items.ACACIA_DOOR));
|
||||
register(EnumVanillaWoodType.DARK_OAK, WoodBlockKind.DOOR, false, Blocks.DARK_OAK_DOOR.getDefaultState(), new ItemStack(Items.DARK_OAK_DOOR));
|
||||
}
|
||||
|
||||
private static <T extends Block & IWoodTyped, V extends Enum<V> & IWoodType> void registerWithVariants(T woodTyped, WoodBlockKind woodBlockKind, PropertyWoodType<V> property) {
|
||||
boolean fireproof = woodTyped.isFireproof();
|
||||
EnumMap<EnumWoodType, ItemStack> itemRegistryMap = woodMap.getItem(fireproof);
|
||||
EnumMap<EnumWoodType, IBlockState> blockRegistryMap = woodMap.getBlock(fireproof);
|
||||
for (EnumWoodType value : property.getAllowedValues()) {
|
||||
|
||||
for (V value : property.getAllowedValues()) {
|
||||
IBlockState blockState = woodTyped.getDefaultState().withProperty(property, value);
|
||||
int meta = woodTyped.getMetaFromState(blockState);
|
||||
EnumWoodType woodType = woodTyped.getWoodType(meta);
|
||||
IWoodType woodType = woodTyped.getWoodType(meta);
|
||||
ItemStack itemStack = new ItemStack(woodTyped, 1, meta);
|
||||
|
||||
itemRegistryMap.put(woodType, itemStack);
|
||||
blockRegistryMap.put(woodType, blockState);
|
||||
register(woodType, woodBlockKind, fireproof, blockState, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register wood blocks that have no variant property
|
||||
*/
|
||||
private static <T extends Block & IWoodTyped, P extends Comparable<P>, V extends P> void registerWithoutVariants(T woodTyped, WoodMap woodMap) {
|
||||
private static <T extends Block & IWoodTyped> void registerWithoutVariants(T woodTyped, WoodBlockKind woodBlockKind) {
|
||||
boolean fireproof = woodTyped.isFireproof();
|
||||
EnumMap<EnumWoodType, ItemStack> itemRegistryMap = woodMap.getItem(fireproof);
|
||||
EnumMap<EnumWoodType, IBlockState> blockRegistryMap = woodMap.getBlock(fireproof);
|
||||
|
||||
IBlockState blockState = woodTyped.getDefaultState();
|
||||
EnumWoodType woodType = woodTyped.getWoodType(0);
|
||||
IWoodType woodType = woodTyped.getWoodType(0);
|
||||
ItemStack itemStack = new ItemStack(woodTyped);
|
||||
register(woodType, woodBlockKind, fireproof, blockState, itemStack);
|
||||
}
|
||||
|
||||
itemRegistryMap.put(woodType, itemStack);
|
||||
blockRegistryMap.put(woodType, blockState);
|
||||
private static void register(IWoodType woodType, WoodBlockKind woodBlockKind, boolean fireproof, IBlockState blockState, ItemStack itemStack) {
|
||||
if (woodBlockKind == WoodBlockKind.DOOR) {
|
||||
fireproof = true;
|
||||
}
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
throw new NullPointerException("Invalid itemStack: " + itemStack);
|
||||
}
|
||||
WoodMap woodMap = woodMaps.get(woodBlockKind);
|
||||
woodMap.getItem(fireproof).put(woodType, itemStack);
|
||||
woodMap.getBlock(fireproof).put(woodType, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPlanks(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, planks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLog(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, logs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSlab(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, slabs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFence(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, fences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFenceGate(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, fenceGates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStairs(EnumWoodType woodType, boolean fireproof) {
|
||||
return getItem(woodType, fireproof, stairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDoor(EnumWoodType woodType) {
|
||||
return getItem(woodType, false, doors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getLogBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, logs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getPlanksBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, planks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getSlabBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, slabs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getFenceBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, fences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getFenceGateBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, fenceGates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStairsBlock(EnumWoodType woodType, boolean fireproof) {
|
||||
return getBlock(woodType, fireproof, stairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getDoorBlock(EnumWoodType woodType) {
|
||||
return getBlock(woodType, false, doors);
|
||||
}
|
||||
|
||||
private static ItemStack getItem(EnumWoodType woodType, boolean fireproof, WoodMap woodMap) {
|
||||
public ItemStack getStack(IWoodType woodType, WoodBlockKind woodBlockKind, boolean fireproof) {
|
||||
if (woodBlockKind == WoodBlockKind.DOOR) {
|
||||
fireproof = true;
|
||||
}
|
||||
WoodMap woodMap = woodMaps.get(woodBlockKind);
|
||||
ItemStack itemStack = woodMap.getItem(fireproof).get(woodType);
|
||||
if (itemStack == null) {
|
||||
Log.error("No stack found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
Log.error("No stack found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "");
|
||||
return null;
|
||||
}
|
||||
return itemStack.copy();
|
||||
}
|
||||
|
||||
private static IBlockState getBlock(EnumWoodType woodType, boolean fireproof, WoodMap woodMap) {
|
||||
@Override
|
||||
public IBlockState getBlock(IWoodType woodType, WoodBlockKind woodBlockKind, boolean fireproof) {
|
||||
if (woodBlockKind == WoodBlockKind.DOOR) {
|
||||
fireproof = true;
|
||||
}
|
||||
WoodMap woodMap = woodMaps.get(woodBlockKind);
|
||||
IBlockState blockState = woodMap.getBlock(fireproof).get(woodType);
|
||||
if (blockState == null) {
|
||||
Log.error("No block found for {} {} {}", woodType, woodMap.getName(), fireproof ? "fireproof" : "non-fireproof");
|
||||
|
||||
@@ -4,6 +4,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,25 +13,36 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.render.ForestryResource;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class WoodHelper {
|
||||
@Nonnull
|
||||
public static String getDisplayName(IWoodTyped wood, EnumWoodType woodType) {
|
||||
String blockKind = wood.getBlockKind();
|
||||
public static String getDisplayName(IWoodTyped wood, IWoodType woodType) {
|
||||
WoodBlockKind blockKind = wood.getBlockKind();
|
||||
|
||||
String displayName;
|
||||
String customUnlocalizedName = "tile.for." + blockKind + "." + woodType.ordinal() + ".name";
|
||||
if (Translator.canTranslateToLocal(customUnlocalizedName)) {
|
||||
displayName = Translator.translateToLocal(customUnlocalizedName);
|
||||
} else {
|
||||
String woodGrammar = Translator.translateToLocal("for." + blockKind + ".grammar");
|
||||
String woodTypeName = Translator.translateToLocal("for.trees.woodType." + woodType);
|
||||
|
||||
displayName = woodGrammar.replaceAll("%TYPE", woodTypeName);
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
String customUnlocalizedName = "tile.for." + blockKind + "." + woodType + ".name";
|
||||
if (Translator.canTranslateToLocal(customUnlocalizedName)) {
|
||||
displayName = Translator.translateToLocal(customUnlocalizedName);
|
||||
} else {
|
||||
String woodGrammar = Translator.translateToLocal("for." + blockKind + ".grammar");
|
||||
String woodTypeName = Translator.translateToLocal("for.trees.woodType." + woodType);
|
||||
|
||||
displayName = woodGrammar.replaceAll("%TYPE", woodTypeName);
|
||||
}
|
||||
} else if (woodType instanceof EnumVanillaWoodType) {
|
||||
displayName = TreeManager.woodAccess.getStack(woodType, blockKind, false).getDisplayName();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown wood type: " + woodType);
|
||||
}
|
||||
|
||||
if (wood.isFireproof()) {
|
||||
@@ -42,9 +54,13 @@ public class WoodHelper {
|
||||
|
||||
public static ResourceLocation[] getResourceLocations(IWoodTyped typed) {
|
||||
List<ResourceLocation> resourceLocations = new ArrayList<>();
|
||||
String blockKind = typed.getBlockKind();
|
||||
for (EnumWoodType woodType : typed.getWoodTypes()) {
|
||||
resourceLocations.add(new ForestryResource(blockKind + "/" + woodType));
|
||||
WoodBlockKind blockKind = typed.getBlockKind();
|
||||
for (IWoodType woodType : typed.getWoodTypes()) {
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
resourceLocations.add(new ResourceLocation(Constants.RESOURCE_ID, blockKind + "/" + woodType));
|
||||
} else if (woodType instanceof EnumVanillaWoodType) {
|
||||
resourceLocations.add(new ResourceLocation("minecraft", woodType + "_" + blockKind));
|
||||
}
|
||||
}
|
||||
return resourceLocations.toArray(new ResourceLocation[resourceLocations.size()]);
|
||||
}
|
||||
@@ -61,9 +77,15 @@ public class WoodHelper {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
int meta = stack.getMetadata();
|
||||
EnumWoodType woodType = wood.getWoodType(meta);
|
||||
String blockKind = wood.getBlockKind();
|
||||
return ForestryAPI.modelManager.getModelLocation(blockKind + "/" + woodType);
|
||||
IWoodType woodType = wood.getWoodType(meta);
|
||||
WoodBlockKind blockKind = wood.getBlockKind();
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
return ForestryAPI.modelManager.getModelLocation(blockKind + "/" + woodType);
|
||||
} else if (woodType instanceof EnumVanillaWoodType) {
|
||||
return new ModelResourceLocation("minecraft:" + woodType + "_" + blockKind, "inventory");
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown wood type: " + woodType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -26,8 +25,9 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
@@ -37,9 +37,9 @@ import forestry.arboriculture.WoodHelper;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
private final EnumWoodType woodType;
|
||||
private final EnumForestryWoodType woodType;
|
||||
|
||||
public BlockArbDoor(EnumWoodType woodType) {
|
||||
public BlockArbDoor(EnumForestryWoodType woodType) {
|
||||
super(MaterialArbWood.ARB_WOOD);
|
||||
this.woodType = woodType;
|
||||
|
||||
@@ -62,8 +62,8 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "doors";
|
||||
public WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.DOOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,20 +73,20 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
return woodType;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
public Collection<EnumForestryWoodType> getWoodTypes() {
|
||||
return Collections.singleton(woodType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
EnumForestryWoodType woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@@ -105,6 +105,6 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
|
||||
}
|
||||
|
||||
private Item getItem() {
|
||||
return TreeManager.woodAccess.getDoor(woodType).getItem();
|
||||
return TreeManager.woodAccess.getStack(woodType, getBlockKind(), false).getItem();
|
||||
}
|
||||
}
|
||||
+29
-27
@@ -10,14 +10,30 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.blocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockPlanks.EnumType;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
@@ -26,28 +42,14 @@ import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.WoodHelper.WoodMeshDefinition;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockPlanks.EnumType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockArbFenceGate extends BlockFenceGate implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
|
||||
public class BlockForestryFenceGate<T extends Enum<T> & IWoodType> extends BlockFenceGate implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
|
||||
private final boolean fireproof;
|
||||
private final EnumWoodType woodType;
|
||||
private final T woodType;
|
||||
|
||||
public BlockArbFenceGate(boolean fireproof, EnumWoodType woodType){
|
||||
super(EnumType.OAK);
|
||||
public BlockForestryFenceGate(boolean fireproof, T woodType) {
|
||||
super(EnumType.OAK);
|
||||
this.fireproof = fireproof;
|
||||
this.woodType = woodType;
|
||||
|
||||
@@ -85,19 +87,19 @@ public class BlockArbFenceGate extends BlockFenceGate implements IWoodTyped, IIt
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "fence_gates";
|
||||
public WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.FENCE_GATE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
public T getWoodType(int meta) {
|
||||
return woodType;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
public Collection<T> getWoodTypes() {
|
||||
return Collections.singleton(woodType);
|
||||
}
|
||||
|
||||
@@ -109,13 +111,13 @@ public class BlockArbFenceGate extends BlockFenceGate implements IWoodTyped, IIt
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
list.add(TreeManager.woodAccess.getFenceGate(woodType, fireproof));
|
||||
list.add(TreeManager.woodAccess.getStack(woodType, getBlockKind(), fireproof));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
+20
-29
@@ -1,13 +1,3 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -18,35 +8,36 @@ import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.WoodHelper.WoodMeshDefinition;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class BlockArbStairs extends BlockStairs implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
public class BlockForestryStairs<T extends Enum<T> & IWoodType> extends BlockStairs implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
private final boolean fireproof;
|
||||
private final EnumWoodType woodType;
|
||||
private final T woodType;
|
||||
|
||||
public BlockArbStairs(boolean fireproof, IBlockState modelState, EnumWoodType woodType) {
|
||||
public BlockForestryStairs(boolean fireproof, IBlockState modelState, T woodType) {
|
||||
super(modelState);
|
||||
this.fireproof = fireproof;
|
||||
this.woodType = woodType;
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Material getMaterial(IBlockState state) {
|
||||
return MaterialArbWood.ARB_WOOD;
|
||||
@@ -57,7 +48,13 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, IItemMode
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,32 +64,26 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, IItemMode
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "stairs";
|
||||
public WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.STAIRS;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
public T getWoodType(int meta) {
|
||||
return woodType;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
public Collection<T> getWoodTypes() {
|
||||
return Collections.singleton(woodType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@@ -19,9 +19,20 @@ import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumPileType;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.arboriculture.blocks.fence.BlockArbFence;
|
||||
import forestry.arboriculture.blocks.fence.BlockFireproofVanillaFence;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
import forestry.arboriculture.blocks.log.BlockFireproofVanillaLog;
|
||||
import forestry.arboriculture.blocks.planks.BlockArbPlanks;
|
||||
import forestry.arboriculture.blocks.planks.BlockFireproofVanillaPlanks;
|
||||
import forestry.arboriculture.blocks.slab.BlockArbSlab;
|
||||
import forestry.arboriculture.blocks.slab.BlockFireproofVanillaSlab;
|
||||
import forestry.arboriculture.blocks.slab.BlockForestrySlab;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleFruit;
|
||||
import forestry.arboriculture.items.ItemBlockDecorativeLeaves;
|
||||
@@ -37,18 +48,25 @@ import forestry.core.utils.OreDictUtil;
|
||||
public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
public final List<BlockArbLog> logs;
|
||||
public final List<BlockArbLog> logsFireproof;
|
||||
public final List<BlockFireproofVanillaLog> logsVanillaFireproof;
|
||||
public final List<BlockArbPlanks> planks;
|
||||
public final List<BlockArbPlanks> planksFireproof;
|
||||
public final List<BlockFireproofVanillaPlanks> planksVanillaFireproof;
|
||||
public final List<BlockArbSlab> slabs;
|
||||
public final List<BlockArbSlab> slabsDouble;
|
||||
public final List<BlockArbSlab> slabsFireproof;
|
||||
public final List<BlockArbSlab> slabsDoubleFireproof;
|
||||
public final List<BlockFireproofVanillaSlab> slabsVanillaFireproof;
|
||||
public final List<BlockFireproofVanillaSlab> slabsVanillaDoubleFireproof;
|
||||
public final List<BlockArbFence> fences;
|
||||
public final List<BlockArbFence> fencesFireproof;
|
||||
public final List<BlockArbFenceGate> fenceGates;
|
||||
public final List<BlockArbFenceGate> fenceGatesFireproof;
|
||||
public final List<BlockArbStairs> stairs;
|
||||
public final List<BlockArbStairs> stairsFireproof;
|
||||
public final List<BlockFireproofVanillaFence> fencesVanillaFireproof;
|
||||
public final List<BlockForestryFenceGate> fenceGates;
|
||||
public final List<BlockForestryFenceGate> fenceGatesFireproof;
|
||||
public final List<BlockForestryFenceGate> fenceGatesVanillaFireproof;
|
||||
public final List<BlockForestryStairs> stairs;
|
||||
public final List<BlockForestryStairs> stairsFireproof;
|
||||
public final List<BlockForestryStairs> stairsVanillaFireproof;
|
||||
public final List<BlockArbDoor> doors;
|
||||
|
||||
public final BlockSapling saplingGE;
|
||||
@@ -74,6 +92,12 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
|
||||
}
|
||||
|
||||
logsVanillaFireproof = BlockFireproofVanillaLog.create();
|
||||
for (BlockFireproofVanillaLog block : logsVanillaFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "logs.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
|
||||
}
|
||||
|
||||
planks = BlockArbPlanks.create(false);
|
||||
for (BlockArbPlanks block : planks) {
|
||||
registerBlock(block, new ItemBlockWood(block), "planks." + block.getBlockNumber());
|
||||
@@ -86,6 +110,12 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
|
||||
}
|
||||
|
||||
planksVanillaFireproof = BlockFireproofVanillaPlanks.create();
|
||||
for (BlockFireproofVanillaPlanks block : planksVanillaFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "planks.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
|
||||
}
|
||||
|
||||
slabs = BlockArbSlab.create(false, false);
|
||||
slabsDouble = BlockArbSlab.create(false, true);
|
||||
for (int i = 0; i < slabs.size(); i++) {
|
||||
@@ -106,6 +136,16 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
registerOreDictWildcard(OreDictUtil.SLAB_WOOD, slab);
|
||||
}
|
||||
|
||||
slabsVanillaFireproof = BlockFireproofVanillaSlab.create(false);
|
||||
slabsVanillaDoubleFireproof = BlockFireproofVanillaSlab.create(true);
|
||||
for (int i = 0; i < slabsVanillaFireproof.size(); i++) {
|
||||
BlockForestrySlab slab = slabsVanillaFireproof.get(i);
|
||||
BlockForestrySlab slabDouble = slabsVanillaDoubleFireproof.get(i);
|
||||
registerBlock(slab, new ItemBlockWoodSlab(slab, slab, slabDouble), "slabs.vanilla.fireproof." + slab.getBlockNumber());
|
||||
registerBlock(slabDouble, new ItemBlockWoodSlab(slabDouble, slab, slabDouble), "slabs.vanilla.double.fireproof." + slabDouble.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.SLAB_WOOD, slab);
|
||||
}
|
||||
|
||||
fences = BlockArbFence.create(false);
|
||||
for (BlockArbFence block : fences) {
|
||||
registerBlock(block, new ItemBlockWood(block), "fences." + block.getBlockNumber());
|
||||
@@ -117,28 +157,42 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
registerBlock(block, new ItemBlockWood(block), "fences.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
|
||||
}
|
||||
|
||||
fencesVanillaFireproof = BlockFireproofVanillaFence.create();
|
||||
for (BlockFireproofVanillaFence block : fencesVanillaFireproof) {
|
||||
registerBlock(block, new ItemBlockWood(block), "fences.vanilla.fireproof." + block.getBlockNumber());
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
|
||||
}
|
||||
|
||||
fenceGates = new ArrayList<>();
|
||||
fenceGatesFireproof = new ArrayList<>();
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
BlockArbFenceGate fenceGate = new BlockArbFenceGate(false, woodType);
|
||||
for (EnumForestryWoodType woodType : EnumForestryWoodType.VALUES) {
|
||||
BlockForestryFenceGate fenceGate = new BlockForestryFenceGate<>(false, woodType);
|
||||
registerBlock(fenceGate, new ItemBlockWood(fenceGate), "fence.gates." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGate);
|
||||
fenceGates.add(fenceGate);
|
||||
|
||||
BlockArbFenceGate fenceGateFireproof = new BlockArbFenceGate(true, woodType);
|
||||
BlockForestryFenceGate fenceGateFireproof = new BlockForestryFenceGate<>(true, woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood(fenceGateFireproof), "fence.gates.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGateFireproof);
|
||||
fenceGatesFireproof.add(fenceGateFireproof);
|
||||
}
|
||||
|
||||
fenceGatesVanillaFireproof = new ArrayList<>();
|
||||
for (EnumVanillaWoodType woodType : EnumVanillaWoodType.VALUES) {
|
||||
BlockForestryFenceGate fenceGateFireproof = new BlockForestryFenceGate<>(true, woodType);
|
||||
registerBlock(fenceGateFireproof, new ItemBlockWood(fenceGateFireproof), "fence.gates.vanilla.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGateFireproof);
|
||||
fenceGatesFireproof.add(fenceGateFireproof);
|
||||
}
|
||||
|
||||
stairs = new ArrayList<>();
|
||||
for (BlockArbPlanks plank : planks) {
|
||||
for (IBlockState blockState : plank.getBlockState().getValidStates()) {
|
||||
int meta = plank.getMetaFromState(blockState);
|
||||
EnumWoodType woodType = plank.getWoodType(meta);
|
||||
EnumForestryWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockArbStairs stair = new BlockArbStairs(false, blockState, woodType);
|
||||
BlockForestryStairs stair = new BlockForestryStairs<>(false, blockState, woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
stairs.add(stair);
|
||||
@@ -149,17 +203,30 @@ public class BlockRegistryArboriculture extends BlockRegistry {
|
||||
for (BlockArbPlanks plank : planksFireproof) {
|
||||
for (IBlockState blockState : plank.getBlockState().getValidStates()) {
|
||||
int meta = plank.getMetaFromState(blockState);
|
||||
EnumWoodType woodType = plank.getWoodType(meta);
|
||||
EnumForestryWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockArbStairs stair = new BlockArbStairs(true, blockState, woodType);
|
||||
BlockForestryStairs stair = new BlockForestryStairs<>(true, blockState, woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
stairsFireproof.add(stair);
|
||||
}
|
||||
}
|
||||
|
||||
stairsVanillaFireproof = new ArrayList<>();
|
||||
for (BlockFireproofVanillaPlanks plank : planksVanillaFireproof) {
|
||||
for (IBlockState blockState : plank.getBlockState().getValidStates()) {
|
||||
int meta = plank.getMetaFromState(blockState);
|
||||
EnumVanillaWoodType woodType = plank.getWoodType(meta);
|
||||
|
||||
BlockForestryStairs stair = new BlockForestryStairs<>(true, blockState, woodType);
|
||||
registerBlock(stair, new ItemBlockWood(stair), "stairs.vanilla.fireproof." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
stairsVanillaFireproof.add(stair);
|
||||
}
|
||||
}
|
||||
|
||||
doors = new ArrayList<>();
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
for (EnumForestryWoodType woodType : EnumForestryWoodType.VALUES) {
|
||||
BlockArbDoor door = new BlockArbDoor(woodType);
|
||||
registerBlock(door, new ItemBlockWoodDoor(door), "doors." + woodType);
|
||||
registerOreDictWildcard(OreDictUtil.DOOR_WOOD, door);
|
||||
|
||||
@@ -2,9 +2,9 @@ package forestry.arboriculture.blocks;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
|
||||
public class WoodTypePredicate implements Predicate<EnumWoodType> {
|
||||
public class WoodTypePredicate implements Predicate<IWoodType> {
|
||||
private final int minWoodTypeMeta;
|
||||
private final int maxWoodTypeMeta;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class WoodTypePredicate implements Predicate<EnumWoodType> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(EnumWoodType woodType) {
|
||||
public boolean apply(IWoodType woodType) {
|
||||
return woodType.getMetadata() >= minWoodTypeMeta && woodType.getMetadata() <= maxWoodTypeMeta;
|
||||
}
|
||||
}
|
||||
@@ -9,37 +9,42 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
class WoodTypeStateMapper extends StateMapperBase {
|
||||
public class WoodTypeStateMapper extends StateMapperBase {
|
||||
|
||||
@Nonnull
|
||||
private final IWoodTyped woodTyped;
|
||||
@Nonnull
|
||||
private final String blockPath;
|
||||
@Nullable
|
||||
private final PropertyWoodType propertyWoodType;
|
||||
private final PropertyWoodType<?> propertyWoodType;
|
||||
@Nonnull
|
||||
private final List<IProperty> propertiesToRemove = new ArrayList<>();
|
||||
|
||||
public WoodTypeStateMapper(@Nonnull IWoodTyped woodTyped, @Nullable PropertyWoodType propertyWoodType) {
|
||||
public WoodTypeStateMapper(@Nonnull IWoodTyped woodTyped, @Nullable PropertyWoodType<?> propertyWoodType) {
|
||||
this.woodTyped = woodTyped;
|
||||
this.blockPath = woodTyped.getBlockKind();
|
||||
this.blockPath = woodTyped.getBlockKind().toString();
|
||||
this.propertyWoodType = propertyWoodType;
|
||||
}
|
||||
|
||||
public WoodTypeStateMapper(@Nonnull IWoodTyped woodTyped, @Nonnull String blockPath, @Nullable PropertyWoodType propertyWoodType) {
|
||||
public WoodTypeStateMapper(@Nonnull IWoodTyped woodTyped, @Nonnull String blockPath, @Nullable PropertyWoodType<?> propertyWoodType) {
|
||||
this.woodTyped = woodTyped;
|
||||
this.blockPath = blockPath;
|
||||
this.propertyWoodType = propertyWoodType;
|
||||
@@ -59,18 +64,36 @@ class WoodTypeStateMapper extends StateMapperBase {
|
||||
} else {
|
||||
properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
}
|
||||
|
||||
|
||||
for (IProperty property : propertiesToRemove) {
|
||||
properties.remove(property);
|
||||
}
|
||||
|
||||
Block block = state.getBlock();
|
||||
int meta = block.getMetaFromState(state);
|
||||
EnumWoodType woodType = woodTyped.getWoodType(meta);
|
||||
String resourceDomain = Block.REGISTRY.getNameForObject(block).getResourceDomain();
|
||||
IWoodType woodType = woodTyped.getWoodType(meta);
|
||||
if (woodType instanceof EnumForestryWoodType) {
|
||||
return getForestryModelResourceLocation(woodType, properties);
|
||||
} else {
|
||||
return getVanillaModelResourceLocation(block, woodType, properties);
|
||||
}
|
||||
}
|
||||
|
||||
private ModelResourceLocation getForestryModelResourceLocation(IWoodType woodType, Map<IProperty<?>, Comparable<?>> properties) {
|
||||
String resourceLocation = "arboriculture/" + blockPath + '/' + woodType;
|
||||
String propertyString = this.getPropertyString(properties);
|
||||
return new ModelResourceLocation(resourceDomain + ':' + resourceLocation, propertyString);
|
||||
return new ModelResourceLocation(Constants.RESOURCE_ID + ':' + resourceLocation, propertyString);
|
||||
}
|
||||
|
||||
private ModelResourceLocation getVanillaModelResourceLocation(Block block, IWoodType woodType, Map<IProperty<?>, Comparable<?>> properties) {
|
||||
String resourceLocation;
|
||||
if (woodType == EnumVanillaWoodType.OAK && (block instanceof BlockFenceGate || block instanceof BlockFence)) {
|
||||
resourceLocation = blockPath;
|
||||
} else {
|
||||
resourceLocation = woodType + "_" + blockPath;
|
||||
}
|
||||
String propertyString = this.getPropertyString(properties);
|
||||
return new ModelResourceLocation("minecraft:" + resourceLocation, propertyString);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks.fence;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.blocks.property.PropertyForestryWoodType;
|
||||
|
||||
public abstract class BlockArbFence extends BlockForestryFence<EnumForestryWoodType> implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
public static List<BlockArbFence> create(boolean fireproof) {
|
||||
List<BlockArbFence> blocks = new ArrayList<>();
|
||||
|
||||
PropertyForestryWoodType[] variants = PropertyForestryWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyForestryWoodType variant = variants[i];
|
||||
BlockArbFence block = new BlockArbFence(fireproof, i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyForestryWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockArbFence(boolean fireproof, int blockNumber) {
|
||||
super(fireproof, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package forestry.arboriculture.blocks.fence;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.arboriculture.blocks.property.PropertyVanillaWoodType;
|
||||
|
||||
public abstract class BlockFireproofVanillaFence extends BlockForestryFence<EnumVanillaWoodType> {
|
||||
public static List<BlockFireproofVanillaFence> create() {
|
||||
List<BlockFireproofVanillaFence> blocks = new ArrayList<>();
|
||||
|
||||
PropertyVanillaWoodType[] variants = PropertyVanillaWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyVanillaWoodType variant = variants[i];
|
||||
BlockFireproofVanillaFence block = new BlockFireproofVanillaFence(i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyVanillaWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockFireproofVanillaFence(int blockNumber) {
|
||||
super(true, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
+21
-50
@@ -1,17 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
package forestry.arboriculture.blocks.fence;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,8 +25,9 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
@@ -45,40 +35,24 @@ import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.WoodHelper.WoodMeshDefinition;
|
||||
import forestry.arboriculture.blocks.MaterialArbWood;
|
||||
import forestry.arboriculture.blocks.WoodTypeStateMapper;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockArbFence extends BlockFence implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
private static final int VARIANTS_PER_BLOCK = 16;
|
||||
private static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
public static List<BlockArbFence> create(boolean fireproof) {
|
||||
List<BlockArbFence> blocks = new ArrayList<>();
|
||||
final int blockCount = PropertyWoodType.getBlockCount(VARIANTS_PER_BLOCK);
|
||||
for (int blockNumber = 0; blockNumber < blockCount; blockNumber++) {
|
||||
final PropertyWoodType variant = PropertyWoodType.create("variant", blockNumber, VARIANTS_PER_BLOCK);
|
||||
BlockArbFence block = new BlockArbFence(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
public abstract class BlockForestryFence<T extends Enum<T> & IWoodType> extends BlockFence implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 16;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
public BlockArbFence(boolean fireproof, int blockNumber) {
|
||||
protected BlockForestryFence(boolean fireproof, int blockNumber) {
|
||||
super(MaterialArbWood.ARB_WOOD, BlockPlanks.EnumType.OAK.getMapColor());
|
||||
this.fireproof = fireproof;
|
||||
this.blockNumber = blockNumber;
|
||||
|
||||
PropertyWoodType variant = getVariant();
|
||||
PropertyWoodType<T> variant = getVariant();
|
||||
this.setDefaultState(this.blockState.getBaseState()
|
||||
.withProperty(NORTH, false)
|
||||
.withProperty(EAST, false)
|
||||
@@ -95,7 +69,7 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType<T> getVariant();
|
||||
|
||||
@Override
|
||||
public boolean isFireproof() {
|
||||
@@ -131,13 +105,13 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@@ -159,8 +133,8 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "fences";
|
||||
public WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.FENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,20 +144,17 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + blockNumber * VARIANTS_PER_BLOCK;
|
||||
return EnumWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
public abstract T getWoodType(int meta);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
public Collection<T> getWoodTypes() {
|
||||
return getVariant().getAllowedValues();
|
||||
}
|
||||
|
||||
@@ -199,14 +170,14 @@ public abstract class BlockArbFence extends BlockFence implements IWoodTyped, II
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getFence(woodType, fireproof));
|
||||
for (T woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getStack(woodType, getBlockKind(), fireproof));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.blocks.log;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.arboriculture.blocks.property.PropertyForestryWoodType;
|
||||
|
||||
public abstract class BlockArbLog extends BlockForestryLog<EnumForestryWoodType> {
|
||||
public static List<BlockArbLog> create(boolean fireproof) {
|
||||
List<BlockArbLog> blocks = new ArrayList<>();
|
||||
PropertyForestryWoodType[] variants = PropertyForestryWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyForestryWoodType variant = variants[i];
|
||||
BlockArbLog block = new BlockArbLog(fireproof, i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyForestryWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockArbLog(boolean fireproof, int blockNumber) {
|
||||
super(fireproof, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -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.blocks.log;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.arboriculture.blocks.property.PropertyVanillaWoodType;
|
||||
|
||||
public abstract class BlockFireproofVanillaLog extends BlockForestryLog<EnumVanillaWoodType> {
|
||||
public static List<BlockFireproofVanillaLog> create() {
|
||||
List<BlockFireproofVanillaLog> blocks = new ArrayList<>();
|
||||
PropertyVanillaWoodType[] variants = PropertyVanillaWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyVanillaWoodType variant = variants[i];
|
||||
BlockFireproofVanillaLog block = new BlockFireproofVanillaLog(i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyVanillaWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockFireproofVanillaLog(int blockNumber) {
|
||||
super(true, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
+59
-88
@@ -1,17 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
package forestry.arboriculture.blocks.log;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,46 +20,32 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.blocks.MaterialArbWood;
|
||||
import forestry.arboriculture.blocks.WoodTypeStateMapper;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IStateMapperRegister, IItemModelRegister {
|
||||
private static final int VARIANTS_PER_BLOCK = 4;
|
||||
private static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
public static List<BlockArbLog> create(boolean fireproof) {
|
||||
List<BlockArbLog> logs = new ArrayList<>();
|
||||
final int blockCount = PropertyWoodType.getBlockCount(VARIANTS_PER_BLOCK);
|
||||
for (int blockNumber = 0; blockNumber < blockCount; blockNumber++) {
|
||||
final PropertyWoodType variant = PropertyWoodType.create("variant", blockNumber, VARIANTS_PER_BLOCK);
|
||||
BlockArbLog log = new BlockArbLog(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
logs.add(log);
|
||||
}
|
||||
return logs;
|
||||
}
|
||||
public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends BlockLog implements IWoodTyped, IStateMapperRegister, IItemModelRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 4;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
private BlockArbLog(boolean fireproof, int blockNumber) {
|
||||
protected BlockForestryLog(boolean fireproof, int blockNumber) {
|
||||
this.fireproof = fireproof;
|
||||
this.blockNumber = blockNumber;
|
||||
|
||||
PropertyWoodType variant = getVariant();
|
||||
PropertyWoodType<T> variant = getVariant();
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(variant, variant.getFirstType()).withProperty(LOG_AXIS, EnumAxis.Y));
|
||||
|
||||
setHarvestLevel("axe", 0);
|
||||
@@ -79,47 +54,24 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "log";
|
||||
public final WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.LOG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFireproof() {
|
||||
public final boolean isFireproof() {
|
||||
return fireproof;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract PropertyWoodType getVariant();
|
||||
|
||||
public int getBlockNumber() {
|
||||
public final int getBlockNumber() {
|
||||
return blockNumber;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Material getMaterial(IBlockState state) {
|
||||
public final Material getMaterial(IBlockState state) {
|
||||
return MaterialArbWood.ARB_WOOD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
EnumAxis axis = getAxis(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType).withProperty(LOG_AXIS, axis);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + blockNumber * VARIANTS_PER_BLOCK;
|
||||
return EnumWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
return getVariant().getAllowedValues();
|
||||
}
|
||||
|
||||
private static EnumAxis getAxis(int meta) {
|
||||
switch (meta & 12) {
|
||||
case 0:
|
||||
@@ -133,9 +85,16 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IBlockState getStateFromMeta(int meta) {
|
||||
T woodType = getWoodType(meta);
|
||||
EnumAxis axis = getAxis(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType).withProperty(LOG_AXIS, axis);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
public final int getMetaFromState(IBlockState state) {
|
||||
int i = damageDropped(state);
|
||||
|
||||
switch (state.getValue(LOG_AXIS)) {
|
||||
@@ -152,54 +111,60 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
return i;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract PropertyWoodType<T> getVariant();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
public abstract T getWoodType(int meta);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final Collection<T> getWoodTypes() {
|
||||
return getVariant().getAllowedValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, getVariant(), LOG_AXIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createStackedBlock(IBlockState state) {
|
||||
protected final ItemStack createStackedBlock(IBlockState state) {
|
||||
int meta = damageDropped(state);
|
||||
Item item = Item.getItemFromBlock(this);
|
||||
return new ItemStack(item, 1, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
public final int damageDropped(IBlockState state) {
|
||||
return state.getValue(getVariant()).getMetadata() - blockNumber * VARIANTS_PER_BLOCK;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
public final IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
EnumAxis axis = EnumAxis.fromFacingAxis(facing.getAxis());
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType).withProperty(LOG_AXIS, axis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getLog(woodType, fireproof));
|
||||
public final void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (T woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getStack(woodType, getBlockKind(), fireproof));
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
public final float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
/* PROPERTIES */
|
||||
@Override
|
||||
public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
public final int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
if (fireproof) {
|
||||
return 0;
|
||||
} else if (face == EnumFacing.DOWN) {
|
||||
@@ -212,17 +177,23 @@ public abstract class BlockArbLog extends BlockLog implements IWoodTyped, IState
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
public final int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
if (fireproof) {
|
||||
return 0;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, getVariant()));
|
||||
@Override
|
||||
public final void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, getVariant()));
|
||||
}
|
||||
}
|
||||
@@ -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.blocks.planks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.arboriculture.blocks.property.PropertyForestryWoodType;
|
||||
|
||||
public abstract class BlockArbPlanks extends BlockForestryPlanks<EnumForestryWoodType> {
|
||||
public static List<BlockArbPlanks> create(boolean fireproof) {
|
||||
List<BlockArbPlanks> blocks = new ArrayList<>();
|
||||
PropertyForestryWoodType[] variants = PropertyForestryWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyForestryWoodType variant = variants[i];
|
||||
BlockArbPlanks block = new BlockArbPlanks(fireproof, i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyForestryWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockArbPlanks(boolean fireproof, int blockNumber) {
|
||||
super(fireproof, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package forestry.arboriculture.blocks.planks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.arboriculture.blocks.property.PropertyVanillaWoodType;
|
||||
|
||||
public abstract class BlockFireproofVanillaPlanks extends BlockForestryPlanks<EnumVanillaWoodType> {
|
||||
public static List<BlockFireproofVanillaPlanks> create() {
|
||||
List<BlockFireproofVanillaPlanks> blocks = new ArrayList<>();
|
||||
PropertyVanillaWoodType[] variants = PropertyVanillaWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyVanillaWoodType variant = variants[i];
|
||||
BlockFireproofVanillaPlanks block = new BlockFireproofVanillaPlanks(i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyVanillaWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockFireproofVanillaPlanks(int blockNumber) {
|
||||
super(true, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
+29
-58
@@ -1,22 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
package forestry.arboriculture.blocks.planks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -31,47 +19,33 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.blocks.MaterialArbWood;
|
||||
import forestry.arboriculture.blocks.WoodTypeStateMapper;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockArbPlanks extends Block implements IWoodTyped, IStateMapperRegister, IItemModelRegister {
|
||||
private static final int VARIANTS_PER_BLOCK = 16;
|
||||
private static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
public static List<BlockArbPlanks> create(boolean fireproof) {
|
||||
List<BlockArbPlanks> planks = new ArrayList<>();
|
||||
final int blockCount = PropertyWoodType.getBlockCount(VARIANTS_PER_BLOCK);
|
||||
for (int blockNumber = 0; blockNumber < blockCount; blockNumber++) {
|
||||
final PropertyWoodType variant = PropertyWoodType.create("variant", blockNumber, VARIANTS_PER_BLOCK);
|
||||
BlockArbPlanks block = new BlockArbPlanks(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
};
|
||||
planks.add(block);
|
||||
}
|
||||
return planks;
|
||||
}
|
||||
public abstract class BlockForestryPlanks<T extends Enum<T> & IWoodType> extends Block implements IWoodTyped, IStateMapperRegister, IItemModelRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 16;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
private BlockArbPlanks(boolean fireproof, int blockNumber) {
|
||||
protected BlockForestryPlanks(boolean fireproof, int blockNumber) {
|
||||
super(MaterialArbWood.ARB_WOOD);
|
||||
this.fireproof = fireproof;
|
||||
this.blockNumber = blockNumber;
|
||||
|
||||
PropertyWoodType variant = getVariant();
|
||||
PropertyWoodType<T> variant = getVariant();
|
||||
setDefaultState(this.blockState.getBaseState().withProperty(variant, variant.getFirstType()));
|
||||
|
||||
setResistance(5.0F);
|
||||
@@ -85,7 +59,11 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType<T> getVariant();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract T getWoodType(int meta);
|
||||
|
||||
public int getBlockNumber() {
|
||||
return blockNumber;
|
||||
@@ -93,26 +71,19 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "planks";
|
||||
public WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.PLANKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + blockNumber * VARIANTS_PER_BLOCK;
|
||||
return EnumWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
public Collection<T> getWoodTypes() {
|
||||
return getVariant().getAllowedValues();
|
||||
}
|
||||
|
||||
@@ -133,23 +104,17 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return getDefaultState().withProperty(getVariant(), woodType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getPlanks(woodType, fireproof));
|
||||
for (T woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getStack(woodType, getBlockKind(), fireproof));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, getVariant()));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
@@ -157,10 +122,16 @@ public abstract class BlockArbPlanks extends Block implements IWoodTyped, IState
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final void registerStateMapper() {
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, getVariant()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package forestry.arboriculture.blocks.property;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.arboriculture.blocks.WoodTypePredicate;
|
||||
|
||||
public class PropertyForestryWoodType extends PropertyWoodType<EnumForestryWoodType> {
|
||||
public static PropertyForestryWoodType[] create(@Nonnull String name, int variantsPerBlock) {
|
||||
final int variantCount = (int) Math.ceil((float) EnumForestryWoodType.VALUES.length / variantsPerBlock);
|
||||
PropertyForestryWoodType[] variants = new PropertyForestryWoodType[variantCount];
|
||||
for (int variantNumber = 0; variantNumber < variantCount; variantNumber++) {
|
||||
WoodTypePredicate filter = new WoodTypePredicate(variantNumber, variantsPerBlock);
|
||||
Collection<EnumForestryWoodType> allowedValues = Collections2.filter(Lists.newArrayList(EnumForestryWoodType.class.getEnumConstants()), filter);
|
||||
variants[variantNumber] = new PropertyForestryWoodType(name, EnumForestryWoodType.class, allowedValues);
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
|
||||
protected PropertyForestryWoodType(String name, Class<EnumForestryWoodType> valueClass, Collection<EnumForestryWoodType> allowedValues) {
|
||||
super(name, valueClass, allowedValues);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.arboriculture.blocks.property;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -19,6 +20,7 @@ import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.core.blocks.propertys.PropertyAllele;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
public class PropertyTree extends PropertyAllele<IAlleleTreeSpecies> {
|
||||
|
||||
@@ -54,7 +56,7 @@ public class PropertyTree extends PropertyAllele<IAlleleTreeSpecies> {
|
||||
|
||||
@Override
|
||||
public String getName(IAlleleTreeSpecies value) {
|
||||
return value.getModelName().replace("tree", "").toLowerCase(Locale.ENGLISH);
|
||||
return value.getUID().replace(Constants.MOD_ID + ".tree", "").toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +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.blocks.property;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.arboriculture.blocks.WoodTypePredicate;
|
||||
|
||||
public class PropertyVanillaWoodType extends PropertyWoodType<EnumVanillaWoodType> {
|
||||
|
||||
public static PropertyVanillaWoodType[] create(@Nonnull String name, int variantsPerBlock) {
|
||||
final int variantCount = (int) Math.ceil((float) EnumVanillaWoodType.VALUES.length / variantsPerBlock);
|
||||
PropertyVanillaWoodType[] variants = new PropertyVanillaWoodType[variantCount];
|
||||
for (int variantNumber = 0; variantNumber < variantCount; variantNumber++) {
|
||||
WoodTypePredicate filter = new WoodTypePredicate(variantNumber, variantsPerBlock);
|
||||
Collection<EnumVanillaWoodType> allowedValues = Collections2.filter(Lists.newArrayList(EnumVanillaWoodType.class.getEnumConstants()), filter);
|
||||
variants[variantNumber] = new PropertyVanillaWoodType(name, EnumVanillaWoodType.class, allowedValues);
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
|
||||
protected PropertyVanillaWoodType(String name, Class<EnumVanillaWoodType> valueClass, Collection<EnumVanillaWoodType> allowedValues) {
|
||||
super(name, valueClass, allowedValues);
|
||||
}
|
||||
}
|
||||
@@ -10,39 +10,25 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.blocks.property;
|
||||
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.arboriculture.blocks.WoodTypePredicate;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
|
||||
public class PropertyWoodType extends PropertyEnum<EnumWoodType> {
|
||||
public static int getBlockCount(int variantsPerBlock) {
|
||||
return (int) Math.ceil((float) EnumWoodType.VALUES.length / variantsPerBlock);
|
||||
}
|
||||
|
||||
public static PropertyWoodType create(@Nonnull String name, int blockNumber, int variantsPerBlock) {
|
||||
WoodTypePredicate filter = new WoodTypePredicate(blockNumber, variantsPerBlock);
|
||||
Collection<EnumWoodType> allowedValues = Collections2.filter(Lists.newArrayList(EnumWoodType.class.getEnumConstants()), filter);
|
||||
return new PropertyWoodType(name, EnumWoodType.class, allowedValues);
|
||||
}
|
||||
|
||||
protected PropertyWoodType(String name, Class<EnumWoodType> valueClass, Collection<EnumWoodType> allowedValues) {
|
||||
public abstract class PropertyWoodType<T extends Enum<T> & IWoodType> extends PropertyEnum<T> {
|
||||
protected PropertyWoodType(String name, Class<T> valueClass, Collection<T> allowedValues) {
|
||||
super(name, valueClass, allowedValues);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public EnumWoodType getFirstType() {
|
||||
public T getFirstType() {
|
||||
return getAllowedValues().iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumWoodType> getAllowedValues() {
|
||||
public Collection<T> getAllowedValues() {
|
||||
return super.getAllowedValues();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks.slab;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.blocks.property.PropertyForestryWoodType;
|
||||
|
||||
public abstract class BlockArbSlab extends BlockForestrySlab<EnumForestryWoodType> implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
public static List<BlockArbSlab> create(boolean fireproof, final boolean doubleSlab) {
|
||||
List<BlockArbSlab> blocks = new ArrayList<>();
|
||||
PropertyForestryWoodType[] variants = PropertyForestryWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyForestryWoodType variant = variants[i];
|
||||
BlockArbSlab block = new BlockArbSlab(fireproof, i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyForestryWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return doubleSlab;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockArbSlab(boolean fireproof, int blockNumber) {
|
||||
super(fireproof, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumForestryWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumForestryWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks.slab;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.blocks.property.PropertyVanillaWoodType;
|
||||
|
||||
public abstract class BlockFireproofVanillaSlab extends BlockForestrySlab<EnumVanillaWoodType> implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
public static List<BlockFireproofVanillaSlab> create(final boolean doubleSlab) {
|
||||
List<BlockFireproofVanillaSlab> blocks = new ArrayList<>();
|
||||
PropertyVanillaWoodType[] variants = PropertyVanillaWoodType.create("variant", VARIANTS_PER_BLOCK);
|
||||
for (int i = 0; i < variants.length; i++) {
|
||||
PropertyVanillaWoodType variant = variants[i];
|
||||
BlockFireproofVanillaSlab block = new BlockFireproofVanillaSlab(i) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyVanillaWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return doubleSlab;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private BlockFireproofVanillaSlab(int blockNumber) {
|
||||
super(true, blockNumber);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumVanillaWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + getBlockNumber() * VARIANTS_PER_BLOCK;
|
||||
return EnumVanillaWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
}
|
||||
+29
-64
@@ -1,24 +1,12 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
package forestry.arboriculture.blocks.slab;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -33,48 +21,28 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.WoodHelper.WoodMeshDefinition;
|
||||
import forestry.arboriculture.blocks.MaterialArbWood;
|
||||
import forestry.arboriculture.blocks.WoodTypeStateMapper;
|
||||
import forestry.arboriculture.blocks.property.PropertyWoodType;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
private static final int VARIANTS_PER_BLOCK = 8;
|
||||
private static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
public static List<BlockArbSlab> create(boolean fireproof, final boolean doubleSlab) {
|
||||
List<BlockArbSlab> blocks = new ArrayList<>();
|
||||
final int blockCount = PropertyWoodType.getBlockCount(VARIANTS_PER_BLOCK);
|
||||
for (int blockNumber = 0; blockNumber < blockCount; blockNumber++) {
|
||||
final PropertyWoodType variant = PropertyWoodType.create("variant", blockNumber, VARIANTS_PER_BLOCK);
|
||||
BlockArbSlab block = new BlockArbSlab(fireproof, blockNumber) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public PropertyWoodType getVariant() {
|
||||
return variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return doubleSlab;
|
||||
}
|
||||
};
|
||||
blocks.add(block);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
public abstract class BlockForestrySlab<T extends Enum<T> & IWoodType> extends BlockSlab implements IWoodTyped, IItemModelRegister, IStateMapperRegister {
|
||||
protected static final int VARIANTS_PER_BLOCK = 8;
|
||||
protected static final int VARIANTS_META_MASK = VARIANTS_PER_BLOCK - 1;
|
||||
|
||||
private final boolean fireproof;
|
||||
private final int blockNumber;
|
||||
|
||||
private BlockArbSlab(boolean fireproof, int blockNumber) {
|
||||
protected BlockForestrySlab(boolean fireproof, int blockNumber) {
|
||||
super(MaterialArbWood.ARB_WOOD);
|
||||
this.fireproof = fireproof;
|
||||
this.blockNumber = blockNumber;
|
||||
@@ -85,7 +53,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
iblockstate = iblockstate.withProperty(HALF, EnumBlockHalf.BOTTOM);
|
||||
}
|
||||
|
||||
PropertyWoodType variant = getVariant();
|
||||
PropertyWoodType<T> variant = getVariant();
|
||||
setDefaultState(iblockstate.withProperty(variant, variant.getFirstType()));
|
||||
|
||||
setCreativeTab(Tabs.tabArboriculture);
|
||||
@@ -102,7 +70,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public abstract PropertyWoodType getVariant();
|
||||
public abstract PropertyWoodType<T> getVariant();
|
||||
|
||||
public int getBlockNumber() {
|
||||
return blockNumber;
|
||||
@@ -112,10 +80,10 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return this.isDouble() ? new BlockStateContainer(this, getVariant()) : new BlockStateContainer(this, HALF, getVariant());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
IBlockState iblockstate = this.getDefaultState().withProperty(getVariant(), woodType);
|
||||
|
||||
if (!this.isDouble()) {
|
||||
@@ -127,14 +95,11 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumWoodType getWoodType(int meta) {
|
||||
int variantMeta = (meta & VARIANTS_META_MASK) + blockNumber * VARIANTS_PER_BLOCK;
|
||||
return EnumWoodType.byMetadata(variantMeta);
|
||||
}
|
||||
public abstract T getWoodType(int meta);
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
EnumWoodType woodType = state.getValue(getVariant());
|
||||
T woodType = state.getValue(getVariant());
|
||||
int meta = woodType.getMetadata() - blockNumber * VARIANTS_PER_BLOCK;
|
||||
|
||||
if (!this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP) {
|
||||
@@ -151,37 +116,37 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||
EnumWoodType woodType = state.getValue(getVariant());
|
||||
ItemStack slab = TreeManager.woodAccess.getSlab(woodType, isFireproof());
|
||||
T woodType = state.getValue(getVariant());
|
||||
ItemStack slab = TreeManager.woodAccess.getStack(woodType, getBlockKind(), isFireproof());
|
||||
return slab.getItem();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // this is the way the vanilla slabs work
|
||||
@Override
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
|
||||
EnumWoodType woodType = state.getValue(getVariant());
|
||||
ItemStack slab = TreeManager.woodAccess.getSlab(woodType, isFireproof());
|
||||
T woodType = state.getValue(getVariant());
|
||||
ItemStack slab = TreeManager.woodAccess.getStack(woodType, getBlockKind(), isFireproof());
|
||||
return new ItemStack(slab.getItem(), 1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerVariant(item, WoodHelper.getResourceLocations(this));
|
||||
manager.registerItemModel(item, new WoodMeshDefinition(this));
|
||||
manager.registerItemModel(item, new WoodHelper.WoodMeshDefinition(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(int meta) {
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return WoodHelper.getDisplayName(this, woodType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List<ItemStack> list) {
|
||||
if (!isDouble()) {
|
||||
for (EnumWoodType woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getSlab(woodType, fireproof));
|
||||
for (T woodType : getVariant().getAllowedValues()) {
|
||||
list.add(TreeManager.woodAccess.getStack(woodType, getBlockKind(), fireproof));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +154,7 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
@Override
|
||||
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
int meta = getMetaFromState(blockState);
|
||||
EnumWoodType woodType = getWoodType(meta);
|
||||
T woodType = getWoodType(meta);
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@@ -205,8 +170,8 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getBlockKind() {
|
||||
return "slab";
|
||||
public WoodBlockKind getBlockKind() {
|
||||
return WoodBlockKind.SLAB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,14 +186,14 @@ public abstract class BlockArbSlab extends BlockSlab implements IWoodTyped, IIte
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<EnumWoodType> getWoodTypes() {
|
||||
public Collection<T> getWoodTypes() {
|
||||
return getVariant().getAllowedValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
String blockPath = isDouble() ? "slab/double" : "slab";
|
||||
String blockPath = isDouble() ? "double_slab" : getBlockKind().toString();
|
||||
Proxies.render.registerStateMapper(this, new WoodTypeStateMapper(this, blockPath, getVariant()));
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,7 @@ import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockNewLog;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
@@ -30,11 +26,12 @@ import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumFruitFamily;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumLeafType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpeciesBuilder;
|
||||
import forestry.api.arboriculture.IGermlingModelProvider;
|
||||
@@ -44,7 +41,9 @@ import forestry.api.arboriculture.ITreeGenerator;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.arboriculture.ITreeMutationCustom;
|
||||
import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IAllele;
|
||||
@@ -52,8 +51,7 @@ import forestry.api.world.ITreeGenData;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleFruit;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
|
||||
import forestry.arboriculture.models.ModelProviderGermling;
|
||||
import forestry.arboriculture.models.ModelProviderGermlingVanilla;
|
||||
import forestry.arboriculture.models.ModelProviderFactory;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.arboriculture.worldgen.WorldGenAcacia;
|
||||
import forestry.arboriculture.worldgen.WorldGenAcaciaVanilla;
|
||||
@@ -98,7 +96,7 @@ import forestry.core.genetics.alleles.EnumAllele;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
|
||||
public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSerializable {
|
||||
Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 0, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK)) {
|
||||
Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), EnumVanillaWoodType.OAK) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenOak(tree);
|
||||
@@ -123,7 +121,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// vanilla
|
||||
}
|
||||
},
|
||||
DarkOak(TreeBranchDefinition.QUERCUS, "darkOak", "velutina", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 5, Blocks.LOG2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.DARK_OAK)) {
|
||||
DarkOak(TreeBranchDefinition.QUERCUS, "darkOak", "velutina", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), EnumVanillaWoodType.DARK_OAK) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenDarkOak(tree);
|
||||
@@ -148,7 +146,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// vanilla
|
||||
}
|
||||
},
|
||||
Birch(TreeBranchDefinition.BETULA, "silverBirch", "pendula", false, EnumLeafType.DECIDUOUS, new Color(8431445), new Color(0xb0c648), 2, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.BIRCH)) {
|
||||
Birch(TreeBranchDefinition.BETULA, "silverBirch", "pendula", false, EnumLeafType.DECIDUOUS, new Color(8431445), new Color(0xb0c648), EnumVanillaWoodType.BIRCH) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenBirch(tree);
|
||||
@@ -171,7 +169,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// vanilla
|
||||
}
|
||||
},
|
||||
Lime(TreeBranchDefinition.TILIA, "silverLime", "pendula", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0x5ea107).brighter(), EnumWoodType.LIME) {
|
||||
Lime(TreeBranchDefinition.TILIA, "silverLime", "pendula", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0x5ea107).brighter(), EnumForestryWoodType.LIME) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenSilverLime(tree);
|
||||
@@ -198,7 +196,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Birch, Oak, 15);
|
||||
}
|
||||
},
|
||||
Walnut(TreeBranchDefinition.JUGLANS, "commonWalnut", "regia", true, EnumLeafType.DECIDUOUS, new Color(0x798c55), new Color(0xb0c648), EnumWoodType.WALNUT) {
|
||||
Walnut(TreeBranchDefinition.JUGLANS, "commonWalnut", "regia", true, EnumLeafType.DECIDUOUS, new Color(0x798c55), new Color(0xb0c648), EnumForestryWoodType.WALNUT) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenWalnut(tree);
|
||||
@@ -227,7 +225,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Lime, Cherry, 10);
|
||||
}
|
||||
},
|
||||
Chestnut(TreeBranchDefinition.CASTANEA, "sweetChestnut", "sativa", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0xb0c648), EnumWoodType.CHESTNUT) {
|
||||
Chestnut(TreeBranchDefinition.CASTANEA, "sweetChestnut", "sativa", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0xb0c648), EnumForestryWoodType.CHESTNUT) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenChestnut(tree);
|
||||
@@ -256,7 +254,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Walnut, Cherry, 10);
|
||||
}
|
||||
},
|
||||
Cherry(TreeBranchDefinition.PRUNUS, "hillCherry", "serrulata", true, EnumLeafType.DECIDUOUS, new Color(0xe691da), new Color(0xe63e59), EnumWoodType.CHERRY) {
|
||||
Cherry(TreeBranchDefinition.PRUNUS, "hillCherry", "serrulata", true, EnumLeafType.DECIDUOUS, new Color(0xe691da), new Color(0xe63e59), EnumForestryWoodType.CHERRY) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenCherry(tree);
|
||||
@@ -283,7 +281,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Lime, Birch, 10);
|
||||
}
|
||||
},
|
||||
Lemon(TreeBranchDefinition.CITRUS, "lemon", "limon", true, EnumLeafType.DECIDUOUS, new Color(0x88af54), new Color(0xa3b850), EnumWoodType.CITRUS) {
|
||||
Lemon(TreeBranchDefinition.CITRUS, "lemon", "limon", true, EnumLeafType.DECIDUOUS, new Color(0x88af54), new Color(0xa3b850), EnumForestryWoodType.CITRUS) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenLemon(tree);
|
||||
@@ -308,7 +306,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Lime, Cherry, 5);
|
||||
}
|
||||
},
|
||||
Plum(TreeBranchDefinition.PRUNUS, "plum", "domestica", true, EnumLeafType.DECIDUOUS, new Color(0x589246), new Color(0xa3b850), EnumWoodType.PLUM) {
|
||||
Plum(TreeBranchDefinition.PRUNUS, "plum", "domestica", true, EnumLeafType.DECIDUOUS, new Color(0x589246), new Color(0xa3b850), EnumForestryWoodType.PLUM) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenPlum(tree);
|
||||
@@ -333,7 +331,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Lemon, Cherry, 5);
|
||||
}
|
||||
},
|
||||
Maple(TreeBranchDefinition.ACER, "sugarMaple", "saccharum", true, EnumLeafType.MAPLE, new Color(0xd4f425), new Color(0x619a3c), EnumWoodType.MAPLE) {
|
||||
Maple(TreeBranchDefinition.ACER, "sugarMaple", "saccharum", true, EnumLeafType.MAPLE, new Color(0xd4f425), new Color(0x619a3c), EnumForestryWoodType.MAPLE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenMaple(tree);
|
||||
@@ -358,7 +356,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Spruce, Larch, 5);
|
||||
}
|
||||
},
|
||||
Spruce(TreeBranchDefinition.PICEA, "redSpruce", "abies", false, EnumLeafType.CONIFERS, new Color(6396257), new Color(0x539d12), 1, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE)) {
|
||||
Spruce(TreeBranchDefinition.PICEA, "redSpruce", "abies", false, EnumLeafType.CONIFERS, new Color(6396257), new Color(0x539d12), EnumVanillaWoodType.SPRUCE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenSpruce(tree);
|
||||
@@ -382,7 +380,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// vanilla
|
||||
}
|
||||
},
|
||||
Larch(TreeBranchDefinition.LARIX, "mundaneLarch", "decidua", true, EnumLeafType.CONIFERS, new Color(0x698f90), new Color(0x569896), EnumWoodType.LARCH) {
|
||||
Larch(TreeBranchDefinition.LARIX, "mundaneLarch", "decidua", true, EnumLeafType.CONIFERS, new Color(0x698f90), new Color(0x569896), EnumForestryWoodType.LARCH) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenLarch(tree);
|
||||
@@ -407,7 +405,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Spruce, Oak, 10);
|
||||
}
|
||||
},
|
||||
Pine(TreeBranchDefinition.PINUS, "bullPine", "sabiniana", true, EnumLeafType.CONIFERS, new Color(0xfeff8f), new Color(0xffd98f), EnumWoodType.PINE) {
|
||||
Pine(TreeBranchDefinition.PINUS, "bullPine", "sabiniana", true, EnumLeafType.CONIFERS, new Color(0xfeff8f), new Color(0xffd98f), EnumForestryWoodType.PINE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenPine(tree);
|
||||
@@ -430,7 +428,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Spruce, Larch, 10);
|
||||
}
|
||||
},
|
||||
Sequoia(TreeBranchDefinition.SEQUOIA, "coastSequoia", "sempervirens", false, EnumLeafType.CONIFERS, new Color(0x418e71), new Color(0x569896), EnumWoodType.SEQUOIA) {
|
||||
Sequoia(TreeBranchDefinition.SEQUOIA, "coastSequoia", "sempervirens", false, EnumLeafType.CONIFERS, new Color(0x418e71), new Color(0x569896), EnumForestryWoodType.SEQUOIA) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenSequoia(tree);
|
||||
@@ -455,7 +453,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Larch, Pine, 5);
|
||||
}
|
||||
},
|
||||
Gigant(TreeBranchDefinition.SEQUOIADENDRON, "giantSequoia", "giganteum", false, EnumLeafType.CONIFERS, new Color(0x738434), new Color(0x738434).brighter(), EnumWoodType.GIGANTEUM) {
|
||||
Gigant(TreeBranchDefinition.SEQUOIADENDRON, "giantSequoia", "giganteum", false, EnumLeafType.CONIFERS, new Color(0x738434), new Color(0x738434).brighter(), EnumForestryWoodType.GIGANTEUM) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenGiganteum(tree);
|
||||
@@ -482,7 +480,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// only available by rare villager trade
|
||||
}
|
||||
},
|
||||
Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x658917), 3, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE)) {
|
||||
Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x658917), EnumVanillaWoodType.JUNGLE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenJungle(tree);
|
||||
@@ -506,7 +504,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// vanilla
|
||||
}
|
||||
},
|
||||
Teak(TreeBranchDefinition.TECTONA, "teak", "grandis", true, EnumLeafType.JUNGLE, new Color(0xfeff8f), new Color(0xffd98f), EnumWoodType.TEAK) {
|
||||
Teak(TreeBranchDefinition.TECTONA, "teak", "grandis", true, EnumLeafType.JUNGLE, new Color(0xfeff8f), new Color(0xffd98f), EnumForestryWoodType.TEAK) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenTeak(tree);
|
||||
@@ -527,7 +525,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(DarkOak, Jungle, 10);
|
||||
}
|
||||
},
|
||||
Ipe(TreeBranchDefinition.TABEBUIA, "ipe", "serratifolia", true, EnumLeafType.JUNGLE, new Color(0xfdd207), new Color(0xad8f04), EnumWoodType.IPE) {
|
||||
Ipe(TreeBranchDefinition.TABEBUIA, "ipe", "serratifolia", true, EnumLeafType.JUNGLE, new Color(0xfdd207), new Color(0xad8f04), EnumForestryWoodType.IPE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenIpe(tree);
|
||||
@@ -550,7 +548,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Teak, DarkOak, 10);
|
||||
}
|
||||
},
|
||||
Kapok(TreeBranchDefinition.CEIBA, "kapok", "pentandra", true, EnumLeafType.JUNGLE, new Color(0x89987b), new Color(0x89aa9e), EnumWoodType.KAPOK) {
|
||||
Kapok(TreeBranchDefinition.CEIBA, "kapok", "pentandra", true, EnumLeafType.JUNGLE, new Color(0x89987b), new Color(0x89aa9e), EnumForestryWoodType.KAPOK) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenKapok(tree);
|
||||
@@ -574,7 +572,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Jungle, Teak, 10);
|
||||
}
|
||||
},
|
||||
Ebony(TreeBranchDefinition.EBONY, "myrtleEbony", "pentamera", true, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), EnumWoodType.EBONY) {
|
||||
Ebony(TreeBranchDefinition.EBONY, "myrtleEbony", "pentamera", true, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), EnumForestryWoodType.EBONY) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenEbony(tree);
|
||||
@@ -600,7 +598,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(DarkOak, Kapok, 10);
|
||||
}
|
||||
},
|
||||
Zebrawood(TreeBranchDefinition.ASTRONIUM, "zebrawood", "graveolens", false, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), EnumWoodType.ZEBRAWOOD) {
|
||||
Zebrawood(TreeBranchDefinition.ASTRONIUM, "zebrawood", "graveolens", false, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), EnumForestryWoodType.ZEBRAWOOD) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenZebrawood(tree);
|
||||
@@ -622,7 +620,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Ebony, Poplar, 5);
|
||||
}
|
||||
},
|
||||
Mahogony(TreeBranchDefinition.MAHOGANY, "yellowMeranti", "gibbosa", true, EnumLeafType.JUNGLE, new Color(0x8ab154), new Color(0xa9b154), EnumWoodType.MAHOGANY) {
|
||||
Mahogony(TreeBranchDefinition.MAHOGANY, "yellowMeranti", "gibbosa", true, EnumLeafType.JUNGLE, new Color(0x8ab154), new Color(0xa9b154), EnumForestryWoodType.MAHOGANY) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenMahogany(tree);
|
||||
@@ -646,7 +644,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Kapok, Ebony, 10);
|
||||
}
|
||||
},
|
||||
AcaciaVanilla(TreeBranchDefinition.ACACIA, "acacia", "aneura", true, EnumLeafType.DECIDUOUS, new Color(0x616101), new Color(0xb3b302), 4, Blocks.LOG2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA)) {
|
||||
AcaciaVanilla(TreeBranchDefinition.ACACIA, "acacia", "aneura", true, EnumLeafType.DECIDUOUS, new Color(0x616101), new Color(0xb3b302), EnumVanillaWoodType.ACACIA) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenAcaciaVanilla(tree);
|
||||
@@ -668,7 +666,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
// vanilla
|
||||
}
|
||||
},
|
||||
Acacia(TreeBranchDefinition.ACACIA, "desertAcacia", "erioloba", true, EnumLeafType.DECIDUOUS, new Color(0x748C1C), new Color(0xb3b302), EnumWoodType.ACACIA) {
|
||||
Acacia(TreeBranchDefinition.ACACIA, "desertAcacia", "erioloba", true, EnumLeafType.DECIDUOUS, new Color(0x748C1C), new Color(0xb3b302), EnumForestryWoodType.ACACIA) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenAcacia(tree);
|
||||
@@ -691,7 +689,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Teak, Balsa, 10);
|
||||
}
|
||||
},
|
||||
Padauk(TreeBranchDefinition.PTEROCARPUS, "padauk", "soyauxii", true, EnumLeafType.DECIDUOUS, new Color(0xd0df8c), new Color(0x435c32), EnumWoodType.PADAUK) {
|
||||
Padauk(TreeBranchDefinition.PTEROCARPUS, "padauk", "soyauxii", true, EnumLeafType.DECIDUOUS, new Color(0xd0df8c), new Color(0x435c32), EnumForestryWoodType.PADAUK) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenPadauk(tree);
|
||||
@@ -713,7 +711,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(AcaciaVanilla, Jungle, 10);
|
||||
}
|
||||
},
|
||||
Balsa(TreeBranchDefinition.OCHROMA, "balsa", "pyramidale", true, EnumLeafType.DECIDUOUS, new Color(0x59ac00), new Color(0xfeff8f), EnumWoodType.BALSA) {
|
||||
Balsa(TreeBranchDefinition.OCHROMA, "balsa", "pyramidale", true, EnumLeafType.DECIDUOUS, new Color(0x59ac00), new Color(0xfeff8f), EnumForestryWoodType.BALSA) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenBalsa(tree);
|
||||
@@ -737,7 +735,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Teak, AcaciaVanilla, 10);
|
||||
}
|
||||
},
|
||||
Cocobolo(TreeBranchDefinition.DALBERGIA, "cocobolo", "retusa", false, EnumLeafType.DECIDUOUS, new Color(0x6aa17a), new Color(0x487d4c), EnumWoodType.COCOBOLO) {
|
||||
Cocobolo(TreeBranchDefinition.DALBERGIA, "cocobolo", "retusa", false, EnumLeafType.DECIDUOUS, new Color(0x6aa17a), new Color(0x487d4c), EnumForestryWoodType.COCOBOLO) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenCocobolo(tree);
|
||||
@@ -758,7 +756,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Acacia, DarkOak, 10);
|
||||
}
|
||||
},
|
||||
Wenge(TreeBranchDefinition.MILLETTIA, "wenge", "laurentii", true, EnumLeafType.DECIDUOUS, new Color(0xada157), new Color(0xad8a57), EnumWoodType.WENGE) {
|
||||
Wenge(TreeBranchDefinition.MILLETTIA, "wenge", "laurentii", true, EnumLeafType.DECIDUOUS, new Color(0xada157), new Color(0xad8a57), EnumForestryWoodType.WENGE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenWenge(tree);
|
||||
@@ -781,7 +779,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Cocobolo, Balsa, 10);
|
||||
}
|
||||
},
|
||||
Baobab(TreeBranchDefinition.ADANSONIA, "grandidierBaobab", "digitata", true, EnumLeafType.DECIDUOUS, new Color(0xfeff8f), new Color(0xffd98f), EnumWoodType.BAOBAB) {
|
||||
Baobab(TreeBranchDefinition.ADANSONIA, "grandidierBaobab", "digitata", true, EnumLeafType.DECIDUOUS, new Color(0xfeff8f), new Color(0xffd98f), EnumForestryWoodType.BAOBAB) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenBaobab(tree);
|
||||
@@ -807,7 +805,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Balsa, Wenge, 10);
|
||||
}
|
||||
},
|
||||
Mahoe(TreeBranchDefinition.TALIPARITI, "blueMahoe", "elatum", true, EnumLeafType.DECIDUOUS, new Color(0xa0ba1b), new Color(0x79a175), EnumWoodType.MAHOE) {
|
||||
Mahoe(TreeBranchDefinition.TALIPARITI, "blueMahoe", "elatum", true, EnumLeafType.DECIDUOUS, new Color(0xa0ba1b), new Color(0x79a175), EnumForestryWoodType.MAHOE) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenMahoe(tree);
|
||||
@@ -832,7 +830,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Balsa, Acacia, 5);
|
||||
}
|
||||
},
|
||||
Willow(TreeBranchDefinition.SALIX, "whiteWillow", "alba", true, EnumLeafType.WILLOW, new Color(0xa3b8a5), new Color(0xa3b850), EnumWoodType.WILLOW) {
|
||||
Willow(TreeBranchDefinition.SALIX, "whiteWillow", "alba", true, EnumLeafType.WILLOW, new Color(0xa3b8a5), new Color(0xa3b850), EnumForestryWoodType.WILLOW) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenWillow(tree);
|
||||
@@ -865,7 +863,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
.restrictHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
},
|
||||
Sipiri(TreeBranchDefinition.CHLOROCARDIUM, "sipiri", "rodiei", true, EnumLeafType.DECIDUOUS, new Color(0x678911), new Color(0x79a175), EnumWoodType.GREENHEART) {
|
||||
Sipiri(TreeBranchDefinition.CHLOROCARDIUM, "sipiri", "rodiei", true, EnumLeafType.DECIDUOUS, new Color(0x678911), new Color(0x79a175), EnumForestryWoodType.GREENHEART) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenGreenheart(tree);
|
||||
@@ -891,7 +889,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
.restrictHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
},
|
||||
Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x75E675), EnumWoodType.PAPAYA) {
|
||||
Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x75E675), EnumForestryWoodType.PAPAYA) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenPapaya(tree);
|
||||
@@ -916,7 +914,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Jungle, Cherry, 5);
|
||||
}
|
||||
},
|
||||
Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xB3F370), EnumWoodType.PALM) {
|
||||
Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xB3F370), EnumForestryWoodType.PALM) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenDate(tree);
|
||||
@@ -942,7 +940,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
registerMutation(Jungle, Papaya, 5);
|
||||
}
|
||||
},
|
||||
Poplar(TreeBranchDefinition.POPULUS, "whitePoplar", "alba", true, EnumLeafType.DECIDUOUS, new Color(0xa3b8a5), new Color(0x539d12), EnumWoodType.POPLAR) {
|
||||
Poplar(TreeBranchDefinition.POPULUS, "whitePoplar", "alba", true, EnumLeafType.DECIDUOUS, new Color(0xa3b8a5), new Color(0x539d12), EnumForestryWoodType.POPLAR) {
|
||||
@Override
|
||||
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
|
||||
return new WorldGenPoplar(tree);
|
||||
@@ -974,52 +972,27 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
private final TreeBranchDefinition branch;
|
||||
private final IAlleleTreeSpecies species;
|
||||
|
||||
private final EnumWoodType woodType; // for forestry trees
|
||||
private final IBlockState vanillaWood; // for vanilla trees
|
||||
private final IWoodType woodType;
|
||||
|
||||
private IAllele[] template;
|
||||
private ITreeGenome genome;
|
||||
|
||||
// vanilla tree constructor
|
||||
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, int vanillaMeta, IBlockState vanillaWood) {
|
||||
String uid = "forestry.tree" + this;
|
||||
String unlocalizedDescription = "for.description.tree" + this;
|
||||
String unlocalizedName = "for.trees.species." + speciesName;
|
||||
String modelName = uid.substring("forestry.".length());
|
||||
|
||||
this.branch = branch;
|
||||
|
||||
ILeafSpriteProvider leafIconProvider = TreeManager.treeFactory.getLeafIconProvider(leafType, primary, secondary);
|
||||
IGermlingModelProvider germlingIconProvider = new ModelProviderGermlingVanilla(vanillaMeta);
|
||||
IWoodProvider woodProvider = new WoodProviderVanilla(vanillaMeta);
|
||||
|
||||
IAlleleTreeSpeciesBuilder speciesBuilder = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, Constants.MOD_ID, modelName, leafIconProvider, germlingIconProvider, woodProvider, this);
|
||||
setSpeciesProperties(speciesBuilder);
|
||||
this.species = speciesBuilder.build();
|
||||
|
||||
this.woodType = null;
|
||||
this.vanillaWood = vanillaWood;
|
||||
}
|
||||
|
||||
// forestry tree constructor
|
||||
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, EnumWoodType woodType) {
|
||||
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, IWoodType woodType) {
|
||||
String uid = Constants.MOD_ID + ".tree" + this;
|
||||
String unlocalizedDescription = "for.description.tree" + this;
|
||||
String unlocalizedName = "for.trees.species." + speciesName;
|
||||
String modelName = uid.substring("forestry.".length());
|
||||
|
||||
this.branch = branch;
|
||||
|
||||
ILeafSpriteProvider leafIconProvider = TreeManager.treeFactory.getLeafIconProvider(leafType, primary, secondary);
|
||||
IGermlingModelProvider germlingIconProvider = new ModelProviderGermling(uid);
|
||||
IWoodProvider woodProvider = new WoodProvider(woodType.toString().toLowerCase(Locale.ENGLISH), woodType);
|
||||
IGermlingModelProvider germlingIconProvider = ModelProviderFactory.create(woodType, uid);
|
||||
IWoodProvider woodProvider = WoodProviderFactory.create(woodType);
|
||||
|
||||
IAlleleTreeSpeciesBuilder speciesBuilder = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, Constants.MOD_ID, modelName, leafIconProvider, germlingIconProvider, woodProvider, this);
|
||||
IAlleleTreeSpeciesBuilder speciesBuilder = TreeManager.treeFactory.createSpecies(uid, unlocalizedName, "Sengir", unlocalizedDescription, dominant, branch.getBranch(), binomial, Constants.MOD_ID, leafIconProvider, germlingIconProvider, woodProvider, this);
|
||||
setSpeciesProperties(speciesBuilder);
|
||||
this.species = speciesBuilder.build();
|
||||
|
||||
this.woodType = woodType;
|
||||
this.vanillaWood = null;
|
||||
}
|
||||
|
||||
protected abstract void setSpeciesProperties(IAlleleTreeSpeciesBuilder treeSpecies);
|
||||
@@ -1030,14 +1003,10 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
|
||||
|
||||
@Override
|
||||
public boolean setLogBlock(ITreeGenome genome, World world, BlockPos pos, EnumFacing facing) {
|
||||
IBlockState logBlock;
|
||||
if (woodType == null) {
|
||||
logBlock = vanillaWood;
|
||||
} else {
|
||||
AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
|
||||
boolean fireproof = fireproofAllele.getValue();
|
||||
logBlock = TreeManager.woodAccess.getLogBlock(woodType, fireproof);
|
||||
}
|
||||
AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
|
||||
boolean fireproof = fireproofAllele.getValue();
|
||||
IBlockState logBlock = TreeManager.woodAccess.getBlock(woodType, WoodBlockKind.LOG, fireproof);
|
||||
|
||||
BlockLog.EnumAxis axis = BlockLog.EnumAxis.fromFacingAxis(facing.getAxis());
|
||||
return world.setBlockState(pos, logBlock.withProperty(BlockLog.LOG_AXIS, axis));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
|
||||
import forestry.api.arboriculture.EnumLeafType;
|
||||
@@ -25,8 +26,8 @@ import forestry.arboriculture.models.SpriteProviderLeaves;
|
||||
|
||||
public class TreeFactory implements ITreeFactory {
|
||||
@Override
|
||||
public IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, String modelName, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, IWoodProvider woodProvider, ITreeGenerator generator) {
|
||||
return new AlleleTreeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, modID, modelName, leafSpriteProvider, germlingModelProvider, woodProvider, generator);
|
||||
public IAlleleTreeSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String modID, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, @Nonnull IWoodProvider woodProvider, ITreeGenerator generator) {
|
||||
return new AlleleTreeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, modID, leafSpriteProvider, germlingModelProvider, woodProvider, generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,34 +10,43 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.render.ForestryResource;
|
||||
import forestry.core.render.TextureManager;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class WoodProvider implements IWoodProvider {
|
||||
|
||||
private final String name;
|
||||
private final EnumWoodType woodType;
|
||||
private TextureAtlasSprite woodTop;
|
||||
private TextureAtlasSprite woodBark;
|
||||
private final EnumForestryWoodType woodType;
|
||||
private TextureAtlasSprite woodTop;
|
||||
private TextureAtlasSprite woodBark;
|
||||
|
||||
public WoodProvider(String name, EnumWoodType woodType) {
|
||||
this.name = name;
|
||||
public WoodProvider(EnumForestryWoodType woodType) {
|
||||
this.name = woodType.toString().toLowerCase(Locale.ENGLISH);
|
||||
this.woodType = woodType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSprites(Item item, ITextureManager manager) {
|
||||
woodTop = TextureManager.registerSprite(new ForestryResource("blocks/wood/heart." + name));
|
||||
woodBark = TextureManager.registerSprite(new ForestryResource("blocks/wood/bark." + name));
|
||||
TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
woodTop = textureMap.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/wood/heart." + name));
|
||||
woodBark = textureMap.registerSprite(new ResourceLocation(Constants.RESOURCE_ID, "blocks/wood/bark." + name));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getSprite(boolean isTop) {
|
||||
if(isTop){
|
||||
@@ -49,7 +58,7 @@ public class WoodProvider implements IWoodProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWoodStack() {
|
||||
return TreeManager.woodAccess.getLog(woodType, false);
|
||||
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
|
||||
public class WoodProviderFactory {
|
||||
public static IWoodProvider create(IWoodType woodType) {
|
||||
if (woodType instanceof EnumVanillaWoodType) {
|
||||
return new WoodProviderVanilla((EnumVanillaWoodType) woodType);
|
||||
} else if (woodType instanceof EnumForestryWoodType) {
|
||||
return new WoodProvider((EnumForestryWoodType) woodType);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown wood type: " + woodType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,71 +10,77 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.genetics;
|
||||
|
||||
import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.render.TextureManager;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodProvider;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class WoodProviderVanilla implements IWoodProvider {
|
||||
|
||||
private final int vanillaMap;
|
||||
private TextureAtlasSprite woodTop;
|
||||
private TextureAtlasSprite woodBark;
|
||||
private final EnumVanillaWoodType woodType;
|
||||
private TextureAtlasSprite woodTop;
|
||||
private TextureAtlasSprite woodBark;
|
||||
|
||||
public WoodProviderVanilla(int vanillaMap) {
|
||||
this.vanillaMap = vanillaMap;
|
||||
public WoodProviderVanilla(EnumVanillaWoodType woodType) {
|
||||
this.woodType = woodType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSprites(Item item, ITextureManager manager) {
|
||||
String name = "";
|
||||
switch (vanillaMap) {
|
||||
case 0:
|
||||
name = "oak";
|
||||
break;
|
||||
case 1:
|
||||
name = "spruce";
|
||||
break;
|
||||
case 2:
|
||||
name = "birch";
|
||||
break;
|
||||
case 3:
|
||||
name = "jungle";
|
||||
break;
|
||||
case 4:
|
||||
name = "acacia";
|
||||
break;
|
||||
case 5:
|
||||
name = "big_oak";
|
||||
break;
|
||||
}
|
||||
woodTop = TextureManager.registerSprite(new ResourceLocation("minecraft:blocks/log_" + name + "_top"));
|
||||
woodBark = TextureManager.registerSprite(new ResourceLocation("minecraft:blocks/log_" + name));
|
||||
String name;
|
||||
switch (woodType) {
|
||||
case OAK:
|
||||
name = "oak";
|
||||
break;
|
||||
case SPRUCE:
|
||||
name = "spruce";
|
||||
break;
|
||||
case BIRCH:
|
||||
name = "birch";
|
||||
break;
|
||||
case JUNGLE:
|
||||
name = "jungle";
|
||||
break;
|
||||
case ACACIA:
|
||||
name = "acacia";
|
||||
break;
|
||||
case DARK_OAK:
|
||||
name = "big_oak";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
TextureMap textureMap = Proxies.common.getClientInstance().getTextureMapBlocks();
|
||||
woodTop = textureMap.registerSprite(new ResourceLocation("minecraft", "blocks/log_" + name + "_top"));
|
||||
woodBark = textureMap.registerSprite(new ResourceLocation("minecraft", "blocks/log_" + name));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getSprite(boolean isTop) {
|
||||
if(isTop){
|
||||
if (isTop) {
|
||||
return woodTop;
|
||||
}else{
|
||||
} else {
|
||||
return woodBark;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWoodStack() {
|
||||
Block block;
|
||||
if(vanillaMap < 4){
|
||||
block = Blocks.LOG;
|
||||
}else{
|
||||
block = Blocks.LOG2;
|
||||
}
|
||||
return new ItemStack(block, 1, vanillaMap >= 4? vanillaMap - 4 : vanillaMap);
|
||||
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,8 +49,6 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
@Nonnull
|
||||
private final List<IFruitFamily> fruits = new ArrayList<>();
|
||||
@Nonnull
|
||||
private final String modelName;
|
||||
@Nonnull
|
||||
private final String modID;
|
||||
@Nonnull
|
||||
private EnumPlantType nativeType = EnumPlantType.Plains;
|
||||
@@ -64,7 +62,6 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
@Nonnull IClassification branch,
|
||||
@Nonnull String binomial,
|
||||
@Nonnull String modID,
|
||||
@Nonnull String modelName,
|
||||
@Nonnull ILeafSpriteProvider leafIconProvider,
|
||||
@Nonnull IGermlingModelProvider germlingModelProvider,
|
||||
@Nonnull IWoodProvider woodProvider,
|
||||
@@ -77,7 +74,6 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
this.leafSpriteProvider = leafIconProvider;
|
||||
|
||||
this.modID = modID;
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,12 +164,6 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
return modID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull IAlleleTreeSpecies o) {
|
||||
return 0;
|
||||
|
||||
@@ -13,7 +13,7 @@ package forestry.arboriculture.items;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
@@ -27,7 +27,7 @@ public class ItemBlockWood<B extends Block & IWoodTyped> extends ItemBlockForest
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
IWoodTyped wood = getBlock();
|
||||
int meta = itemstack.getMetadata();
|
||||
EnumWoodType woodType = wood.getWoodType(meta);
|
||||
IWoodType woodType = wood.getWoodType(meta);
|
||||
return WoodHelper.getDisplayName(wood, woodType);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,20 @@ package forestry.arboriculture.items;
|
||||
import net.minecraft.item.ItemSlab;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.arboriculture.WoodHelper;
|
||||
import forestry.arboriculture.blocks.BlockArbSlab;
|
||||
import forestry.arboriculture.blocks.slab.BlockForestrySlab;
|
||||
|
||||
public class ItemBlockWoodSlab extends ItemSlab {
|
||||
public ItemBlockWoodSlab(BlockArbSlab block, BlockArbSlab slab, BlockArbSlab doubleSlab) {
|
||||
public ItemBlockWoodSlab(BlockForestrySlab block, BlockForestrySlab slab, BlockForestrySlab doubleSlab) {
|
||||
super(block, slab, doubleSlab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
BlockArbSlab wood = (BlockArbSlab) getBlock();
|
||||
BlockForestrySlab<?> wood = (BlockForestrySlab) getBlock();
|
||||
int meta = itemstack.getMetadata();
|
||||
EnumWoodType woodType = wood.getWoodType(meta);
|
||||
IWoodType woodType = wood.getWoodType(meta);
|
||||
return WoodHelper.getDisplayName(wood, woodType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package forestry.arboriculture.models;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IGermlingModelProvider;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
|
||||
public class ModelProviderFactory {
|
||||
public static IGermlingModelProvider create(@Nonnull IWoodType woodType, String modelUid) {
|
||||
if (woodType instanceof EnumVanillaWoodType) {
|
||||
return new ModelProviderGermlingVanilla((EnumVanillaWoodType) woodType);
|
||||
} else if (woodType instanceof EnumForestryWoodType) {
|
||||
return new ModelProviderGermling(modelUid);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown wood type: " + woodType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,8 @@ public class ModelProviderGermling implements IGermlingModelProvider {
|
||||
private ModelResourceLocation pollenModel;
|
||||
private ModelResourceLocation charcoalModel;
|
||||
|
||||
public ModelProviderGermling(String uid) {
|
||||
this.name = uid.substring("forestry.".length());
|
||||
public ModelProviderGermling(String modelUid) {
|
||||
this.name = modelUid.substring("forestry.".length());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,42 +14,44 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IGermlingModelProvider;
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
public class ModelProviderGermlingVanilla implements IGermlingModelProvider {
|
||||
|
||||
private final int vanillaMap;
|
||||
private final EnumVanillaWoodType woodType;
|
||||
|
||||
private ModelResourceLocation germlingModel;
|
||||
private ModelResourceLocation pollenModel;
|
||||
private ModelResourceLocation charcoalModel;
|
||||
|
||||
public ModelProviderGermlingVanilla(int vanillaMap) {
|
||||
this.vanillaMap = vanillaMap;
|
||||
public ModelProviderGermlingVanilla(EnumVanillaWoodType woodType) {
|
||||
this.woodType = woodType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModels(Item item, IModelManager manager, EnumGermlingType type) {
|
||||
if(type == EnumGermlingType.SAPLING){
|
||||
switch (vanillaMap) {
|
||||
case 0:
|
||||
switch (woodType) {
|
||||
case OAK:
|
||||
germlingModel = manager.getModelLocation("minecraft", "oak_sapling");
|
||||
break;
|
||||
case 1:
|
||||
case SPRUCE:
|
||||
germlingModel = manager.getModelLocation("minecraft", "spruce_sapling");
|
||||
break;
|
||||
case 2:
|
||||
case BIRCH:
|
||||
germlingModel = manager.getModelLocation("minecraft", "birch_sapling");
|
||||
break;
|
||||
case 3:
|
||||
case JUNGLE:
|
||||
germlingModel = manager.getModelLocation("minecraft", "jungle_sapling");
|
||||
break;
|
||||
case 4:
|
||||
case ACACIA:
|
||||
germlingModel = manager.getModelLocation("minecraft", "acacia_sapling");
|
||||
break;
|
||||
case 5:
|
||||
case DARK_OAK:
|
||||
germlingModel = manager.getModelLocation("minecraft", "dark_oak_sapling");
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user