Unite flower 1 and flower 2 into a single paged block class

This commit is contained in:
Cheeserolls 2015-05-22 11:15:13 +01:00
parent 04c91ca0d8
commit 7d7917d757
12 changed files with 132 additions and 222 deletions

View File

@ -17,8 +17,6 @@ public class BOPBlocks
public static Block bamboo;
public static Block bone_segment;
public static Block coral;
public static Block flower1;
public static Block flower2;
public static Block gem_block;
public static Block gem_ore;
public static Block hive;
@ -26,6 +24,8 @@ public class BOPBlocks
public static Block stone;
public static Block biome_block;
public static Block flower_0;
public static Block flower_1;
public static Block log_0;
public static Block log_1;
public static Block log_2;

View File

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.api.block;
import biomesoplenty.common.util.block.VariantPagingHelper.IPagedVariants;
import net.minecraft.util.IStringSerializable;
public class BOPFlowerEnums
{
public static enum AllFlowers implements IStringSerializable, IPagedVariants
{
CLOVER, SWAMPFLOWER, DEATHBLOOM, GLOWFLOWER, BLUE_HYDRANGEA, ORANGE_COSMOS, PINK_DAFFODIL, WILDFLOWER, VIOLET, WHITE_ANEMONE, ENDERLOTUS, BROMELIAD, DANDELION, PINK_HIBISCUS, LILY_OF_THE_VALLEY, BURNING_BLOSSOM, LAVENDER, GOLDENROD, BLUEBELLS, MINERS_DELIGHT, ICY_IRIS, ROSE;
@Override
public String getName() {
return this.name().toLowerCase();
}
@Override
public String toString()
{
return this.getName();
}
}
}

View File

@ -16,11 +16,11 @@ import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.api.block.BOPFlowerEnums.AllFlowers;
import biomesoplenty.api.block.BOPPlantEnums.AllPlants;
import biomesoplenty.api.block.BOPTreeEnums.AllTrees;
import biomesoplenty.api.block.BOPWoodEnums.AllWoods;
import biomesoplenty.common.block.BlockBOPFlower2;
import biomesoplenty.common.block.BlockBOPFlower2.FlowerType;
import biomesoplenty.common.block.BlockBOPFlower;
import biomesoplenty.common.block.BlockBOPLeaves;
import biomesoplenty.common.block.BlockBOPLog;
import biomesoplenty.common.block.BlockBOPPlant;
@ -44,7 +44,7 @@ public class BiomeGenLavenderFields extends BOPBiome
this.addWeight(BiomeType.WARM, 3);
this.addGenerator("lavender", GeneratorStage.FLOWERS, new GeneratorFlora(999, BOPBlocks.flower2.getDefaultState().withProperty(BlockBOPFlower2.VARIANT, FlowerType.LAVENDER)));
this.addGenerator("lavender", GeneratorStage.FLOWERS, new GeneratorFlora(999, BlockBOPFlower.paging.getVariantState(AllFlowers.LAVENDER)));
GeneratorWeighted treeGenerator = new GeneratorWeighted(1);
treeGenerator.add(3, new GeneratorBasicTree(1, false, 4, 7, BlockBOPLog.paging.getVariantState(AllWoods.JACARANDA), BlockBOPLeaves.paging.getVariantState(AllTrees.JACARANDA)));

View File

@ -15,9 +15,9 @@ import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.api.block.BOPFlowerEnums.AllFlowers;
import biomesoplenty.api.block.BOPTreeEnums.AllTrees;
import biomesoplenty.common.block.BlockBOPFlower2;
import biomesoplenty.common.block.BlockBOPFlower2.FlowerType;
import biomesoplenty.common.block.BlockBOPFlower;
import biomesoplenty.common.block.BlockBOPGrass;
import biomesoplenty.common.block.BlockBOPLeaves;
import biomesoplenty.common.block.BlockBOPGrass.BOPGrassType;
@ -43,7 +43,7 @@ public class BiomeGenOriginValley extends BOPBiome
this.addGenerator("trees", GeneratorStage.TREE, treeGenerator);
GeneratorWeighted flowerGenerator = new GeneratorWeighted(4);
flowerGenerator.add(8, new GeneratorFlora(1, BOPBlocks.flower2.getDefaultState().withProperty(BlockBOPFlower2.VARIANT, FlowerType.ROSE)));
flowerGenerator.add(8, new GeneratorFlora(1, BlockBOPFlower.paging.getVariantState(AllFlowers.ROSE)));
flowerGenerator.add(10, new GeneratorFlora(1, Blocks.yellow_flower.getDefaultState()));
this.addGenerator("flowers", GeneratorStage.FLOWERS, flowerGenerator);
}

View File

@ -11,10 +11,11 @@ package biomesoplenty.common.block;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.api.block.BOPFlowerEnums.AllFlowers;
import biomesoplenty.common.item.ItemBOPFlower;
import biomesoplenty.common.util.block.VariantPagingHelper;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
@ -28,7 +29,6 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -36,46 +36,60 @@ import net.minecraftforge.fml.relauncher.SideOnly;
// TODO: Readd eyebulb in as a seperate block
// TODO: placing lily of the valley. where is lily flower?
public class BlockBOPFlower1 extends BlockDecoration {
// add properties
public static enum FlowerType implements IStringSerializable
{
CLOVER, SWAMPFLOWER, DEATHBLOOM, GLOWFLOWER, BLUE_HYDRANGEA, ORANGE_COSMOS, PINK_DAFFODIL, WILDFLOWER, VIOLET, WHITE_ANEMONE, ENDERLOTUS, BROMELIAD, DANDELION, PINK_HIBISCUS, LILY_OF_THE_VALLEY, BURNING_BLOSSOM;
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override
public String toString()
{
return this.getName();
}
};
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", FlowerType.class);
@Override
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
public class BlockBOPFlower extends BlockDecoration
{
// setup paged variant property
// All 4 bits are available for the VARIANT which means we can have sixteen per instance
public static VariantPagingHelper<BlockBOPFlower, AllFlowers> paging = new VariantPagingHelper<BlockBOPFlower, AllFlowers>(16, AllFlowers.class);
// Slightly naughty hackery here
// The constructor of Block() calls createBlockState() which needs to know the particular instance's variant property
// There is no way to set the individual block instance's variant property before this, because the super() has to be first
// So, we use the static variable currentVariantProperty to provide each instance access to its variant property during creation
private static IProperty currentVariantProperty;
// Create an instance for each page
public static void createAllPages()
{
int numPages = paging.getNumPages();
for (int i = 0; i < numPages; ++i)
{
currentVariantProperty = paging.getVariantProperty(i);
paging.addBlock(i, new BlockBOPFlower());
}
}
// Each instance has a reference to its own variant property
public IProperty variantProperty;
@Override
protected BlockState createBlockState()
{
this.variantProperty = currentVariantProperty; // get from static variable
return new BlockState(this, new IProperty[] { this.variantProperty });
}
// implement IBOPBlock
@Override
public Class<? extends ItemBlock> getItemClass() { return ItemBOPFlower.class; }
@Override
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
public IProperty[] getPresetProperties() { return new IProperty[] { this.variantProperty }; }
@Override
public IProperty[] getNonRenderingProperties() { return null; }
@Override
public String getStateName(IBlockState state)
{
return ((FlowerType) state.getValue(VARIANT)).getName();
return ((AllFlowers) state.getValue(this.variantProperty)).getName();
}
public BlockBOPFlower1()
public BlockBOPFlower()
{
super();
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, FlowerType.CLOVER) );
this.setDefaultState( this.blockState.getBaseState() );
}
@ -83,12 +97,13 @@ public class BlockBOPFlower1 extends BlockDecoration {
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, FlowerType.values()[meta]);
return this.getDefaultState().withProperty(this.variantProperty, paging.getVariant(this, meta));
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((FlowerType) state.getValue(VARIANT)).ordinal();
AllFlowers flower = (AllFlowers) state.getValue(this.variantProperty);
return paging.getIndex(flower);
}
// make sure the block drops the right type of flower
@ -98,11 +113,12 @@ public class BlockBOPFlower1 extends BlockDecoration {
return this.getMetaFromState(state);
}
// set the size of the different flowers' bounding boxes
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
switch ((FlowerType) world.getBlockState(pos).getValue(VARIANT))
switch ((AllFlowers) world.getBlockState(pos).getValue(this.variantProperty))
{
case CLOVER:
this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.5F, 0.015625F, pos);
@ -131,7 +147,7 @@ public class BlockBOPFlower1 extends BlockDecoration {
@Override
public int getLightValue(IBlockAccess world, BlockPos pos)
{
switch ((FlowerType) world.getBlockState(pos).getValue(VARIANT))
switch ((AllFlowers) world.getBlockState(pos).getValue(this.variantProperty))
{
case GLOWFLOWER:
return 9;
@ -153,7 +169,7 @@ public class BlockBOPFlower1 extends BlockDecoration {
super.harvestBlock(world, player, pos, state, tileentity);
if (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemShears))
{
switch ((FlowerType) state.getValue(VARIANT))
switch ((AllFlowers) state.getValue(this.variantProperty))
{
// suffer wither effect if you harvest deathbloom without shears
case DEATHBLOOM:
@ -174,7 +190,7 @@ public class BlockBOPFlower1 extends BlockDecoration {
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
switch((FlowerType) state.getValue(VARIANT))
switch((AllFlowers) state.getValue(this.variantProperty))
{
// suffer wither effect if you walk on deathbloom
case DEATHBLOOM:
@ -201,7 +217,7 @@ public class BlockBOPFlower1 extends BlockDecoration {
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
{
switch((FlowerType) state.getValue(VARIANT))
switch((AllFlowers) state.getValue(this.variantProperty))
{
case DEATHBLOOM:
if (rand.nextInt(4) != 0)
@ -223,7 +239,6 @@ public class BlockBOPFlower1 extends BlockDecoration {
}
// which types of flower can live on which types of block
@Override
@ -235,6 +250,7 @@ public class BlockBOPFlower1 extends BlockDecoration {
boolean onFertile = (groundBlock == Blocks.dirt || groundBlock == Blocks.farmland || groundBlock == BOPBlocks.dirt || groundBlock == Blocks.grass);
boolean onDry = (groundBlock == BOPBlocks.hard_dirt || groundBlock == Blocks.hardened_clay || groundBlock == Blocks.sand || groundBlock == BOPBlocks.hard_sand);
boolean onNetherrack = (groundBlock == Blocks.netherrack);
boolean onStone = (groundBlock == Blocks.stone);
boolean onSpectralMoss = false;
if (groundBlock instanceof BlockBOPGrass)
@ -254,7 +270,7 @@ public class BlockBOPFlower1 extends BlockDecoration {
}
}
switch ((FlowerType) state.getValue(VARIANT))
switch ((AllFlowers) state.getValue(this.variantProperty))
{
case ENDERLOTUS:
return onSpectralMoss;
@ -262,6 +278,8 @@ public class BlockBOPFlower1 extends BlockDecoration {
return onDry;
case BURNING_BLOSSOM:
return onNetherrack;
case MINERS_DELIGHT:
return onStone;
default:
return onFertile;
}
@ -269,7 +287,6 @@ public class BlockBOPFlower1 extends BlockDecoration {
}
}

View File

@ -1,141 +0,0 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.block;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.item.ItemBOPFlower;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
// TODO: where have lily flowers and lilyofthevalley gone?
// TODO implement as paged block
public class BlockBOPFlower2 extends BlockDecoration {
// add properties
public static enum FlowerType implements IStringSerializable
{
LAVENDER, GOLDENROD, BLUEBELLS, MINERS_DELIGHT, ICY_IRIS, ROSE;
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override
public String toString()
{
return this.getName();
}
};
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", FlowerType.class);
@Override
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
// implement IBOPBlock
@Override
public Class<? extends ItemBlock> getItemClass() { return ItemBOPFlower.class; }
@Override
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
@Override
public IProperty[] getNonRenderingProperties() { return null; }
@Override
public String getStateName(IBlockState state)
{
return ((FlowerType) state.getValue(VARIANT)).getName();
}
public BlockBOPFlower2()
{
super();
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, FlowerType.LAVENDER) );
}
// map from state to meta and vice verca
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, FlowerType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((FlowerType) state.getValue(VARIANT)).ordinal();
}
// make sure the block drops the right type of flower
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(state);
}
// set the size of the different flowers' bounding boxes
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
switch ((FlowerType) world.getBlockState(pos).getValue(VARIANT))
{
default:
this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.4F, 0.8F, pos);
break;
}
}
// which types of flower can live on which types of block
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{
IBlockState groundState = world.getBlockState(pos.down());
Block groundBlock = groundState.getBlock();
boolean onFertile = (groundBlock == Blocks.dirt || groundBlock == Blocks.farmland || groundBlock == BOPBlocks.dirt || groundBlock == Blocks.grass);
boolean onStone = (groundBlock == Blocks.stone);
boolean onOrigin = false;
if (groundBlock instanceof BlockBOPGrass)
{
switch ((BlockBOPGrass.BOPGrassType) groundState.getValue(BlockBOPGrass.VARIANT))
{
case SPECTRAL_MOSS: case SMOLDERING:
break;
case LOAMY: case SANDY: case SILTY: case OVERGROWN_NETHERRACK: case ORIGIN: default:
onFertile = true;
break;
}
}
switch ((FlowerType) state.getValue(VARIANT))
{
case MINERS_DELIGHT:
return onStone;
case ROSE:
return onFertile || onOrigin;
default:
return onFertile;
}
}
}

View File

@ -50,8 +50,6 @@ public class ModBlocks
bamboo = registerBlock( new BlockBamboo(), "bamboo" );
bone_segment = registerBlock( new BlockBones(), "bone_segment" );
coral = registerBlock( new BlockCoral(), "coral" );
flower1 = registerBlock( new BlockBOPFlower1(), "flower1" );
flower2 = registerBlock( new BlockBOPFlower2(), "flower2" );
gem_block = registerBlock( new BlockGem(), "gem_block" );
gem_ore = registerBlock( new BlockGemOre(), "gem_ore" );
hive = registerBlock( new BlockHive(), "hive" );
@ -77,6 +75,11 @@ public class ModBlocks
hard_sand = registerBlock( (new BlockBOPGeneric(Material.sand)).setHardness(0.9F).setStepSound(Block.soundTypeSand), "hard_sand" );
mud_brick_block = registerBlock( (new BlockBOPGeneric()).setResistance(2.0F), "mud_brick_block" );
// 22 flower types 16 per BlockBOPFlower instance, needs 2 'pages'
BlockBOPFlower.createAllPages();
flower_0 = registerBlock( BlockBOPFlower.paging.getBlock(0), "flower_0" );
flower_1 = registerBlock( BlockBOPFlower.paging.getBlock(1), "flower_1" );
// 16 wood types, 4 per BlockBOPLog instance, needs 4 'pages'
BlockBOPLog.createAllPages();
log_0 = registerBlock( BlockBOPLog.paging.getBlock(0), "log_0" );

View File

@ -9,13 +9,13 @@
package biomesoplenty.common.init;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.api.block.BOPFlowerEnums.AllFlowers;
import biomesoplenty.api.block.BOPPlantEnums.AllPlants;
import biomesoplenty.api.block.BOPWoodEnums.AllWoods;
import biomesoplenty.api.item.BOPItems;
import biomesoplenty.common.block.BlockBOPDoor;
import biomesoplenty.common.block.BlockBOPDoublePlant;
import biomesoplenty.common.block.BlockBOPFlower1;
import biomesoplenty.common.block.BlockBOPFlower2;
import biomesoplenty.common.block.BlockBOPFlower;
import biomesoplenty.common.block.BlockBOPGrass;
import biomesoplenty.common.block.BlockBOPHalfWoodSlab;
import biomesoplenty.common.block.BlockBOPLog;
@ -55,29 +55,29 @@ public class ModCrafting
// Flower1
// CLOVER missing
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.CYAN.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.SWAMPFLOWER.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.black_dye), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.DEATHBLOOM.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.CYAN.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.SWAMPFLOWER)});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.black_dye), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.DEATHBLOOM)});
// GLOWFLOWER missing
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.LIGHT_BLUE.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.BLUE_HYDRANGEA.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.ORANGE.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.ORANGE_COSMOS.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PINK.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.PINK_DAFFODIL.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.MAGENTA.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.WILDFLOWER.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PURPLE.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.VIOLET.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.white_dye), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.WHITE_ANEMONE.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.LIGHT_BLUE.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.BLUE_HYDRANGEA)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.ORANGE.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.ORANGE_COSMOS)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PINK.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.PINK_DAFFODIL)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.MAGENTA.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.WILDFLOWER)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PURPLE.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.VIOLET)});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.white_dye), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.WHITE_ANEMONE)});
// ENDERLOTUS missing
// BROMELIAD missing
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.SILVER.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.DANDELION.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PINK.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.PINK_HIBISCUS.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.white_dye), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.LILY_OF_THE_VALLEY.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.ORANGE.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.BURNING_BLOSSOM.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.SILVER.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.DANDELION)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PINK.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.PINK_HIBISCUS)});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.white_dye), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.LILY_OF_THE_VALLEY)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.ORANGE.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.BURNING_BLOSSOM)});
// Flower 2
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PURPLE.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower2, 1, BlockBOPFlower2.FlowerType.LAVENDER.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.YELLOW.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower2, 1, BlockBOPFlower2.FlowerType.GOLDENROD.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.blue_dye), new Object[] {new ItemStack(BOPBlocks.flower2, 1, BlockBOPFlower2.FlowerType.BLUEBELLS.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.PURPLE.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.LAVENDER)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.YELLOW.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.GOLDENROD)});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.blue_dye), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.BLUEBELLS)});
// MINERS_DELIGHT missing
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.LIGHT_BLUE.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower2, 1, BlockBOPFlower2.FlowerType.ICY_IRIS.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.RED.getDyeDamage()), new Object[] {new ItemStack(BOPBlocks.flower2, 1, BlockBOPFlower2.FlowerType.ROSE.ordinal())});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.LIGHT_BLUE.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.ICY_IRIS)});
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.RED.getDyeDamage()), new Object[] {BlockBOPFlower.paging.getVariantItem(AllFlowers.ROSE)});
// Others
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 1, EnumDyeColor.GRAY.getDyeDamage()), new Object[] {new ItemStack(BOPItems.ash)});
@ -258,9 +258,9 @@ public class ModCrafting
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BOPItems.amethyst_scythe), new Object [] {"MM ", "S M", "S ", 'M', new ItemStack(BOPItems.gem, 1, BlockGem.GemType.AMETHYST.ordinal()), 'S', Items.iron_ingot}));
// Flower Bands
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.dull_flower_band), new Object [] {"CCC", "C C", "CCC", 'C', new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.CLOVER.ordinal())});
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.plain_flower_band), new Object [] {"CDC", "D D", "CDC", 'C', new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.CLOVER.ordinal()), 'D', new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.ORANGE_COSMOS.ordinal())});
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.exotic_flower_band), new Object [] {"CDC", "V V", "CDC", 'C', new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.CLOVER.ordinal()),'D', new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.ORANGE_COSMOS.ordinal()), 'V', new ItemStack(BOPBlocks.flower1, 1, BlockBOPFlower1.FlowerType.VIOLET.ordinal())});
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.dull_flower_band), new Object [] {"CCC", "C C", "CCC", 'C', BlockBOPFlower.paging.getVariantItem(AllFlowers.CLOVER)});
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.plain_flower_band), new Object [] {"CDC", "D D", "CDC", 'C', BlockBOPFlower.paging.getVariantItem(AllFlowers.CLOVER), 'D', BlockBOPFlower.paging.getVariantItem(AllFlowers.ORANGE_COSMOS)});
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.exotic_flower_band), new Object [] {"CDC", "V V", "CDC", 'C', BlockBOPFlower.paging.getVariantItem(AllFlowers.CLOVER),'D', BlockBOPFlower.paging.getVariantItem(AllFlowers.ORANGE_COSMOS), 'V', BlockBOPFlower.paging.getVariantItem(AllFlowers.VIOLET)});
// Dart Blower
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.dart_blower), new Object[] {"R R", "R R", "R R", 'R', BlockBOPPlant.paging.getVariantItem(AllPlants.RIVERCANE)});
@ -293,7 +293,7 @@ public class ModCrafting
// TODO: GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.bamboo, 8), new Object [] {" #", "# ", '#', new ItemStack(BOPBlocks.bamboo_thatching)});
// TODO: GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.bamboo, 8), new Object [] {"# ", " #", '#', new ItemStack(BOPBlocks.bamboo_thatching)});
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.jar_empty, 3, 0), new Object[] {"# #", "# #", "###", '#', Blocks.glass});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.ambrosia), new Object[] {new ItemStack(BOPItems.pixie_dust), new ItemStack(Items.potionitem, 1, 0), new ItemStack(BOPBlocks.flower2, 1, BlockBOPFlower2.FlowerType.MINERS_DELIGHT.ordinal()), /* TODO: add kelp new ItemStack(BOPCBlocks.coral1, 1, 11), */ BlockBOPPlant.paging.getVariantItem(AllPlants.ROOT), new ItemStack(BOPItems.crystal_shard), new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.HONEY.ordinal()), new ItemStack(BOPItems.berries), Items.sugar});
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.ambrosia), new Object[] {new ItemStack(BOPItems.pixie_dust), new ItemStack(Items.potionitem, 1, 0), BlockBOPFlower.paging.getVariantItem(AllFlowers.MINERS_DELIGHT), /* TODO: add kelp new ItemStack(BOPCBlocks.coral1, 1, 11), */ BlockBOPPlant.paging.getVariantItem(AllPlants.ROOT), new ItemStack(BOPItems.crystal_shard), new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.HONEY.ordinal()), new ItemStack(BOPItems.berries), Items.sugar});
GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.flesh), new Object[] {"##", "##", '#', new ItemStack(BOPItems.fleshchunk)});
GameRegistry.addShapedRecipe(new ItemStack(Items.rotten_flesh), new Object[] {"FFF", "FPF", "FFF", 'F', new ItemStack(BOPItems.fleshchunk), 'P', new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.POISON.ordinal())});

View File

@ -10,11 +10,11 @@ package biomesoplenty.common.item;
import java.util.Random;
import biomesoplenty.api.block.BOPFlowerEnums.AllFlowers;
import biomesoplenty.api.particle.BOPParticleTypes;
import biomesoplenty.common.block.BlockBOPFlower1;
import biomesoplenty.common.block.BlockBOPFlower;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
@ -27,11 +27,10 @@ public class ItemBOPFlower extends ItemBOPBlock {
super(block);
}
public boolean isDandelion(ItemStack stack)
public AllFlowers getFlower(ItemStack stack)
{
if (!(this.block instanceof BlockBOPFlower1)) {return false;}
IBlockState state = ((BlockBOPFlower1)this.block).getStateFromMeta(stack.getMetadata());
return state.getValue(BlockBOPFlower1.VARIANT) == BlockBOPFlower1.FlowerType.DANDELION;
if (! (this.block instanceof BlockBOPFlower)) {return null;}
return BlockBOPFlower.paging.getVariant((BlockBOPFlower)this.block, stack.getMetadata());
}
@Override
@ -43,13 +42,13 @@ public class ItemBOPFlower extends ItemBOPBlock {
@Override
public EnumAction getItemUseAction(ItemStack stack)
{
return this.isDandelion(stack) ? EnumAction.BLOCK : super.getItemUseAction(stack);
return (this.getFlower(stack) == AllFlowers.DANDELION) ? EnumAction.BLOCK : super.getItemUseAction(stack);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (this.isDandelion(stack))
if (this.getFlower(stack) == AllFlowers.DANDELION)
{
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
}
@ -59,7 +58,7 @@ public class ItemBOPFlower extends ItemBOPBlock {
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
{
if (this.isDandelion(stack))
if (this.getFlower(stack) == AllFlowers.DANDELION)
{
Vec3 vec = player.getLook(0.5F);
Random rnd = player.getRNG();

View File

@ -10,8 +10,7 @@ package biomesoplenty.common.item;
import biomesoplenty.api.block.BOPPlantEnums.AllPlants;
import biomesoplenty.api.item.BOPItemHelper;
import biomesoplenty.common.block.BlockBOPFlower1;
import biomesoplenty.common.block.BlockBOPFlower2;
import biomesoplenty.common.block.BlockBOPFlower;
import biomesoplenty.common.block.BlockBOPPlant;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
@ -190,7 +189,7 @@ public class ItemBOPScythe extends Item
world.setBlockState(pos, BlockBOPPlant.paging.getVariantState(AllPlants.MEDIUMGRASS));
return true;
}
else if ((block instanceof BlockFlower) || (block instanceof BlockBOPFlower1) || (block instanceof BlockBOPFlower2))
else if ((block instanceof BlockFlower) || (block instanceof BlockBOPFlower))
{
block.dropBlockAsItem(world, pos, state, fortune);
world.setBlockToAir(pos);