From 7019c0a68c4e99942dfb160d404927afaa56f41f Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Fri, 22 May 2015 13:24:21 +0100 Subject: [PATCH] Allow wool to be crafted from any combination of regular and tall cattail --- .../biome/overworld/BiomeGenShrubland.java | 4 +-- .../common/block/BlockBOPDoublePlant.java | 29 +++++++++---------- .../common/init/ModCrafting.java | 10 +++---- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenShrubland.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenShrubland.java index d0e00ce10..5ab9d3083 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenShrubland.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenShrubland.java @@ -19,7 +19,7 @@ import biomesoplenty.api.biome.BOPBiome; import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.GeneratorWeighted; import biomesoplenty.api.block.BOPBlocks; -import biomesoplenty.common.block.BlockBOPDoublePlant.FoliageType; +import biomesoplenty.common.block.BlockBOPDoublePlant; import biomesoplenty.common.block.BlockBOPPlant; import biomesoplenty.common.block.BlockDoubleDecoration.Half; import biomesoplenty.common.block.BlockGem; @@ -49,7 +49,7 @@ public class BiomeGenShrubland extends BOPBiome this.addGenerator("gravel", GeneratorStage.SAND_PASS2, new GeneratorWaterside(4, 7, Blocks.gravel.getDefaultState())); this.addGenerator("bushes", GeneratorStage.FLOWERS, new GeneratorFlora(7, BlockBOPPlant.paging.getVariantState(BOPPlants.BUSH))); this.addGenerator("shrubs", GeneratorStage.FLOWERS, new GeneratorFlora(5, BlockBOPPlant.paging.getVariantState(BOPPlants.SHRUB))); - this.addGenerator("flax", GeneratorStage.FLOWERS, new GeneratorDoubleFlora(1, BOPBlocks.double_plant.getDefaultState().withProperty(VARIANT, FoliageType.FLAX).withProperty(HALF, Half.LOWER), BOPBlocks.double_plant.getDefaultState().withProperty(VARIANT, FoliageType.FLAX).withProperty(HALF, Half.UPPER), 24)); + this.addGenerator("flax", GeneratorStage.FLOWERS, new GeneratorDoubleFlora(1, BOPBlocks.double_plant.getDefaultState().withProperty(VARIANT, BlockBOPDoublePlant.DoublePlantType.FLAX).withProperty(HALF, Half.LOWER), BOPBlocks.double_plant.getDefaultState().withProperty(VARIANT, BlockBOPDoublePlant.DoublePlantType.FLAX).withProperty(HALF, Half.UPPER), 24)); this.addGenerator("water_reeds", GeneratorStage.LILYPAD, new GeneratorFlora(3, BlockBOPPlant.paging.getVariantState(BOPPlants.REED), 128)); this.addGenerator("trees", GeneratorStage.TREE, new GeneratorBush(1, Blocks.log.getDefaultState(), Blocks.leaves.getDefaultState())); diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPDoublePlant.java b/src/main/java/biomesoplenty/common/block/BlockBOPDoublePlant.java index 0ea8a0226..1a0dae5e1 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPDoublePlant.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPDoublePlant.java @@ -35,8 +35,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear { // add properties (note we inherit HALF from BlockDoubleDecoration) - // TODO: rename this - public static enum FoliageType implements IStringSerializable + public static enum DoublePlantType implements IStringSerializable { FLAX, TALL_CATTAIL; @Override @@ -50,7 +49,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear return this.getName(); } }; - public static final PropertyEnum VARIANT = PropertyEnum.create("variant", FoliageType.class); + public static final PropertyEnum VARIANT = PropertyEnum.create("variant", DoublePlantType.class); @Override protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { HALF, VARIANT });} @@ -63,33 +62,33 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear @Override public String getStateName(IBlockState state) { - return ((FoliageType) state.getValue(VARIANT)).getName(); + return ((DoublePlantType) state.getValue(VARIANT)).getName(); } public BlockBOPDoublePlant() { super(); - this.setDefaultState( this.blockState.getBaseState().withProperty(HALF, Half.LOWER) .withProperty(VARIANT, FoliageType.FLAX) ); + this.setDefaultState( this.blockState.getBaseState().withProperty(HALF, Half.LOWER) .withProperty(VARIANT, DoublePlantType.FLAX) ); } // map from state to meta and vice verca - use highest bit for Half, and lower bits for variant @Override public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(HALF, Half.values()[meta >> 3]).withProperty(VARIANT, FoliageType.values()[meta & 7]); + return this.getDefaultState().withProperty(HALF, Half.values()[meta >> 3]).withProperty(VARIANT, DoublePlantType.values()[meta & 7]); } @Override public int getMetaFromState(IBlockState state) { - return ((Half) state.getValue(HALF)).ordinal() * 8 + ((FoliageType) state.getValue(VARIANT)).ordinal(); + return ((Half) state.getValue(HALF)).ordinal() * 8 + ((DoublePlantType) state.getValue(VARIANT)).ordinal(); } public enum ColoringType {PLAIN, LIKE_LEAVES, LIKE_GRASS}; - public static ColoringType getColoringType(FoliageType plant) + public static ColoringType getColoringType(DoublePlantType plant) { switch (plant) { @@ -111,7 +110,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state) { - switch (getColoringType((FoliageType) state.getValue(VARIANT))) + switch (getColoringType((DoublePlantType) state.getValue(VARIANT))) { case LIKE_LEAVES: return ColorizerFoliage.getFoliageColorBasic(); @@ -126,7 +125,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { - switch (getColoringType((FoliageType) worldIn.getBlockState(pos).getValue(VARIANT))) + switch (getColoringType((DoublePlantType) worldIn.getBlockState(pos).getValue(VARIANT))) { case LIKE_LEAVES: return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos); @@ -141,7 +140,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear @Override public int getItemRenderColor(IBlockState state, int tintIndex) { - switch ((FoliageType) state.getValue(VARIANT)) + switch ((DoublePlantType) state.getValue(VARIANT)) { case FLAX: return 0xFFFFFF; @@ -156,7 +155,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear @Override public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { - switch ((FoliageType) worldIn.getBlockState(pos).getValue(VARIANT)) + switch ((DoublePlantType) worldIn.getBlockState(pos).getValue(VARIANT)) { default: this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F); @@ -198,7 +197,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear List ret = new java.util.ArrayList(); // add items based on the VARIANT - default is to return nothing (require shears to collect the block) - switch ((FoliageType) lowerState.getValue(VARIANT)) + switch ((DoublePlantType) lowerState.getValue(VARIANT)) { case FLAX: if (rand.nextInt(8) == 0) @@ -225,7 +224,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear List ret = new java.util.ArrayList(); // add items based on the VARIANT - FoliageType type = (FoliageType) lowerState.getValue(VARIANT); + DoublePlantType type = (DoublePlantType) lowerState.getValue(VARIANT); switch (type) { default: @@ -235,7 +234,7 @@ public class BlockBOPDoublePlant extends BlockDoubleDecoration implements IShear return ret; } - public ItemStack getVariantItem(FoliageType type) { + public ItemStack getVariantItem(DoublePlantType type) { IBlockState state = this.getDefaultState().withProperty(HALF, Half.LOWER).withProperty(VARIANT, type); return new ItemStack(this, 1, this.getMetaFromState(state)); } diff --git a/src/main/java/biomesoplenty/common/init/ModCrafting.java b/src/main/java/biomesoplenty/common/init/ModCrafting.java index d6a2c852c..acc961770 100644 --- a/src/main/java/biomesoplenty/common/init/ModCrafting.java +++ b/src/main/java/biomesoplenty/common/init/ModCrafting.java @@ -75,7 +75,7 @@ public class ModCrafting GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.brown_dye), new Object[] {new ItemStack(BOPBlocks.mushroom, 1, BlockBOPMushroom.MushroomType.FLAT_MUSHROOM.ordinal())}); GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.blue_dye), new Object[] {new ItemStack(BOPBlocks.mushroom, 1, BlockBOPMushroom.MushroomType.BLUE_MILK_CAP.ordinal())}); GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.brown_dye), new Object[] {BlockBOPPlant.paging.getVariantItem(BOPPlants.CATTAIL)}); - GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.brown_dye), new Object[] {((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.FoliageType.TALL_CATTAIL)}); + GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.brown_dye), new Object[] {((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.DoublePlantType.TALL_CATTAIL)}); /*** Brick stairs and slabs ***/ @@ -172,11 +172,9 @@ public class ModCrafting /*** Misc Others ***/ - GameRegistry.addShapedRecipe(new ItemStack(Items.string), new Object[] {"FFF", "FFF", "FFF", 'F', ((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.FoliageType.FLAX)}); + GameRegistry.addShapedRecipe(new ItemStack(Items.string), new Object[] {"FFF", "FFF", "FFF", 'F', ((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.DoublePlantType.FLAX)}); GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.grass, 1, BlockBOPGrass.BOPGrassType.OVERGROWN_NETHERRACK.ordinal()), new Object[] {"SSS", "SNS", "SSS", 'S', Items.wheat_seeds, 'N', Blocks.netherrack}); - // TODO: use oredict so it works with any mixture of single or double cattail - GameRegistry.addShapedRecipe(new ItemStack(Blocks.wool), new Object[] {"CCC", "CCC", "CCC", 'C', BlockBOPPlant.paging.getVariantItem(BOPPlants.CATTAIL)}); - GameRegistry.addShapedRecipe(new ItemStack(Blocks.wool), new Object[] {"CCC", "CCC", "CCC", 'C', ((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.FoliageType.TALL_CATTAIL)}); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Blocks.wool), new Object [] {"CCC", "CCC", "CCC", 'C', "plantCattail"})); GameRegistry.addShapedRecipe(new ItemStack(Items.coal), new Object[] {"AAA", "AAA", "AAA", 'A', new ItemStack(BOPItems.ash)}); GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.ash_block), new Object[] {"AA", "AA", 'A', new ItemStack(BOPItems.ash)}); GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.mud, 1), new Object[] {"MM", "MM", 'M', BOPItems.mudball}); @@ -308,6 +306,8 @@ public class ModCrafting String plantName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, plant.name()); OreDictionary.registerOre("plant"+plantName, BlockBOPPlant.paging.getVariantItem(plant)); } + OreDictionary.registerOre("plantFlax", ((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.DoublePlantType.FLAX)); + OreDictionary.registerOre("plantCattail", ((BlockBOPDoublePlant)BOPBlocks.double_plant).getVariantItem(BlockBOPDoublePlant.DoublePlantType.TALL_CATTAIL)); for (BOPTrees tree : BOPTrees.values()) {