diff --git a/src/main/java/biomesoplenty/api/block/BOPBlock.java b/src/main/java/biomesoplenty/api/block/BOPBlock.java deleted file mode 100644 index 0a8ecdf51..000000000 --- a/src/main/java/biomesoplenty/api/block/BOPBlock.java +++ /dev/null @@ -1,86 +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.api.block; - -import java.util.List; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -import biomesoplenty.common.item.ItemBlockWithVariants; -import biomesoplenty.common.util.block.BlockStateUtils; -import biomesoplenty.common.util.inventory.CreativeTabBOP; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public abstract class BOPBlock extends Block -{ - public ImmutableSet presetStates; - - protected BOPBlock(Material material) - { - super(material); - - this.setCreativeTab(CreativeTabBOP.instance); - } - - // get the item class to use when registering this block - public Class getItemClass() { - return ItemBlockWithVariants.class; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs tab, List list) - { - if (this.hasPresetProperties()) - { - for (IBlockState state : presetStates) - { - list.add(new ItemStack(item, 1, this.getMetaFromState(state))); - } - } - else - { - list.add(new ItemStack(item, 1, 0)); - } - } - - @Override - public int damageDropped(IBlockState state) - { - return this.getMetaFromState(state); - } - - public IProperty[] getPresetProperties() - { - return null; - } - - public boolean hasPresetProperties() - { - return getPresetProperties() != null; - } - - public String getStateName(IBlockState state, boolean fullName) - { - String unlocalizedName = state.getBlock().getUnlocalizedName(); - - return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); - } -} diff --git a/src/main/java/biomesoplenty/api/block/BOPCrops.java b/src/main/java/biomesoplenty/api/block/BOPCrops.java deleted file mode 100644 index 11bafbd05..000000000 --- a/src/main/java/biomesoplenty/api/block/BOPCrops.java +++ /dev/null @@ -1,269 +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.api.block; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.block.IGrowable; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockState; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -// TODO: BOPPlant should probably implement IPlantable instead? -public abstract class BOPCrops extends BOPPlant implements IGrowable, IPlantable -{ - public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 7); - - protected BOPCrops() - { - // start with age=0 - this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0))); - - // one-quarter height - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); - - // general crop stuff - this.setTickRandomly(true); - this.setHardness(0.0F); - this.setStepSound(Block.soundTypeGrass); - - // copied from Vanilla BlockCrops class - this.disableStats(); - } - - // crops should always be in the centre of the block - @Override - public Block.EnumOffsetType getOffsetType() - { - return Block.EnumOffsetType.NONE; - } - - // grow crops +1 age on random ticks if the light is good enough - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - super.updateTick(worldIn, pos, state, rand); - - if (worldIn.getLightFromNeighbors(pos.up()) >= 9) - { - int i = ((Integer)state.getValue(AGE)).intValue(); - - if (i < 7) - { - float f = getGrowthChance(this, worldIn, pos); - - if (rand.nextInt((int)(25.0F / f) + 1) == 0) - { - worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i + 1)), 2); - } - } - } - } - - // grow crops a random amount from 2 to 5 - I think this is only called when bonemeal is applied to the crop - public void grow(World worldIn, BlockPos pos, IBlockState state) - { - int i = ((Integer)state.getValue(AGE)).intValue() + MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5); - if (i > 7) - { - i = 7; - } - worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i)), 2); - } - - @Override - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - this.grow(worldIn, pos, state); - } - - // return a multiplier reflecting the chance of crop growth - // TODO: some pretty arcane looking rules in here - need to decipher them - and simplify perhaps - protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) - { - float f = 1.0F; - BlockPos blockpos1 = pos.down(); - - for (int i = -1; i <= 1; ++i) - { - for (int j = -1; j <= 1; ++j) - { - float f1 = 0.0F; - IBlockState iblockstate = worldIn.getBlockState(blockpos1.add(i, 0, j)); - - if (iblockstate.getBlock().canSustainPlant(worldIn, blockpos1.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)blockIn)) - { - f1 = 1.0F; - - if (iblockstate.getBlock().isFertile(worldIn, blockpos1.add(i, 0, j))) - { - f1 = 3.0F; - } - } - - if (i != 0 || j != 0) - { - f1 /= 4.0F; - } - - f += f1; - } - } - - BlockPos blockpos2 = pos.north(); - BlockPos blockpos3 = pos.south(); - BlockPos blockpos4 = pos.west(); - BlockPos blockpos5 = pos.east(); - boolean flag = blockIn == worldIn.getBlockState(blockpos4).getBlock() || blockIn == worldIn.getBlockState(blockpos5).getBlock(); - boolean flag1 = blockIn == worldIn.getBlockState(blockpos2).getBlock() || blockIn == worldIn.getBlockState(blockpos3).getBlock(); - - if (flag && flag1) - { - f /= 2.0F; - } - else - { - boolean flag2 = blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos5.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos5.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock(); - - if (flag2) - { - f /= 2.0F; - } - } - - return f; - } - - // whether or not the crop can remain planted at its current position - @Override - public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) - { - return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && worldIn.getBlockState(pos.down()).getBlock().canSustainPlant(worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this); - } - - // the item to return as the seed for this crop - child classes must override - protected abstract Item getSeed(); - - // the item to return as the harvest for this crop - child classes must implement - protected abstract Item getCrop(); - - // fortune tools have no effect on crop yield - @Override - public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) - { - super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0); - } - - // if the plant is mature, drop the crop, otherwise drop seeds - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return ((Integer)state.getValue(AGE)).intValue() == 7 ? this.getCrop() : this.getSeed(); - } - - // whether or not the crop can still grow further (and so bonemeal can be used) - @Override - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) - { - return ((Integer)state.getValue(AGE)).intValue() < 7; - } - - // always returns true - so presumably this just says the block in general is capable of receiving bonemeal, although a specific instance might not if it's fully grown - @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public Item getItem(World worldIn, BlockPos pos) - { - return this.getSeed(); - } - - // map state to meta - simple choice here meta=age - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta)); - } - - // map state to meta - simple choice here meta=age - @Override - public int getMetaFromState(IBlockState state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] {AGE}); - } - - // default behavior when the block is broken is to call getItemDropped() which yields 1 seed item or 1 crop item depending on the crop's maturity - // modify this so that mature crops in addition might also yield some seeds - @Override - public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) - { - java.util.List ret = super.getDrops(world, pos, state, fortune); - int age = ((Integer)state.getValue(AGE)).intValue(); - Random rand = world instanceof World ? ((World)world).rand : new Random(); - - if (age >= 7) - { - int k = 3 + fortune; - for (int i = 0; i < k; ++i) - { - if (rand.nextInt(15) <= age) - { - ret.add(new ItemStack(this.getSeed(), 1, 0)); - } - } - } - return ret; - } - - @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) - { - return net.minecraftforge.common.EnumPlantType.Crop; - // note the value 'Crop' prevents these blocks from being placed anywhere other than farmland - see Block.canSustainPlant - } - - @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) - { - IBlockState state = world.getBlockState(pos); - if (state.getBlock() != this) return getDefaultState(); - return state; - } - - // BOPBlock uses getMetaFromState as default value for damageDropped - this is unhelpful for crops where the meta value is the crop age - use 0 as default instead - @Override - public int damageDropped(IBlockState state) - { - return 0; - } - - -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/api/block/BOPPlant.java b/src/main/java/biomesoplenty/api/block/BOPPlant.java deleted file mode 100644 index f9c99f108..000000000 --- a/src/main/java/biomesoplenty/api/block/BOPPlant.java +++ /dev/null @@ -1,110 +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.api.block; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BOPPlant extends BOPBlock -{ - protected BOPPlant(Material material) - { - super(material); - - this.setTickRandomly(true); - - this.setHardness(0.0F); - this.setStepSound(Block.soundTypeGrass); - } - - protected BOPPlant() - { - this(Material.plants); - } - - @Override - public boolean canReplace(World world, BlockPos pos, EnumFacing side, ItemStack stack) - { - return super.canPlaceBlockOnSide(world, pos, side) && this.canBlockStay(world, pos, this.getStateFromMeta(stack.getMetadata())); - } - - public boolean canBlockStay(World world, BlockPos pos, IBlockState state) - { - Block ground = world.getBlockState(pos.down()).getBlock(); - - return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland; - } - - @Override - public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) - { - super.onNeighborBlockChange(world, pos, state, neighborBlock); - this.checkAndDropBlock(world, pos, state); - } - - @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) - { - this.checkAndDropBlock(world, pos, state); - } - - protected void checkAndDropBlock(World world, BlockPos pos, IBlockState state) - { - if (!this.canBlockStay(world, pos, state)) - { - this.dropBlockAsItem(world, pos, state, 0); - world.setBlockState(pos, Blocks.air.getDefaultState(), 3); - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) - { - return null; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean isFullCube() - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public EnumWorldBlockLayer getBlockLayer() - { - return EnumWorldBlockLayer.CUTOUT; - } - - @Override - @SideOnly(Side.CLIENT) - public Block.EnumOffsetType getOffsetType() - { - return Block.EnumOffsetType.XZ; - } -} diff --git a/src/main/java/biomesoplenty/api/block/IBOPBlock.java b/src/main/java/biomesoplenty/api/block/IBOPBlock.java index 1486ce3d5..89b9bf6f2 100644 --- a/src/main/java/biomesoplenty/api/block/IBOPBlock.java +++ b/src/main/java/biomesoplenty/api/block/IBOPBlock.java @@ -10,16 +10,13 @@ package biomesoplenty.api.block; import java.util.Map; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemBlock; public interface IBOPBlock { public Map getNamedStates(); public IBlockState getNamedState(String name); - public Class getItemClass(); } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFlower2Old.java b/src/main/java/biomesoplenty/common/block/BlockBOPFlower2Old.java deleted file mode 100644 index d43f7a2e3..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFlower2Old.java +++ /dev/null @@ -1,101 +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.BOPPlant; -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.util.BlockPos; -import net.minecraft.util.IStringSerializable; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockBOPFlower2Old extends BOPPlant -{ - public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class); - - public BlockBOPFlower2Old() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.LAVENDER)); - } - - @Override - public boolean canBlockStay(World world, BlockPos pos, IBlockState state) - { - Block ground = world.getBlockState(pos.down()).getBlock(); - FlowerType type = (FlowerType) state.getValue(VARIANT_PROP); - - switch (type) - { - case MINERS_DELIGHT: - return ground == Blocks.stone; - - default: - return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland; - } - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(VARIANT_PROP, FlowerType.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int meta = ((FlowerType) state.getValue(VARIANT_PROP)).ordinal(); - - return meta; - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - return ((FlowerType) state.getValue(VARIANT_PROP)).getName(); - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) - { - this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F); - } - - public static enum FlowerType implements IStringSerializable - { - LAVENDER, GOLDENROD, BLUEBELLS, MINERS_DELIGHT, ICY_IRIS, ROSE; - - public String getName() - { - return this.name().toLowerCase(); - } - - @Override - public String toString() - { - return getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPFlowerOld.java b/src/main/java/biomesoplenty/common/block/BlockBOPFlowerOld.java deleted file mode 100644 index ac7e41e45..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPFlowerOld.java +++ /dev/null @@ -1,214 +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 java.util.Random; - -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; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemShears; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -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; -import net.minecraftforge.fml.relauncher.SideOnly; -import biomesoplenty.api.block.BOPPlant; -import biomesoplenty.common.block.BlockBOPLogOld.LogType; - -public class BlockBOPFlowerOld extends BOPPlant -{ - public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class); - - public BlockBOPFlowerOld() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, FlowerType.CLOVER)); - } - - @Override - public int getLightValue(IBlockAccess world, BlockPos pos) - { - IBlockState state = world.getBlockState(pos); - FlowerType type = (FlowerType) state.getValue(VARIANT_PROP); - - switch (type) - { - case GLOWFLOWER: - return 9; - - case ENDERLOTUS: - return 5; - - case BURNING_BLOSSOM: - return 9; - - default: - return super.getLightValue(); - } - } - - // TODO: Make enderlotus require spectral moss - // TODO: Make bromeliads require hard dirt, hardened clay or sand - // TODO: Make the burning blossom require netherrack or overgrown netherrack - - @Override - public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileentity) - { - super.harvestBlock(world, player, pos, state, tileentity); - - FlowerType type = (FlowerType) state.getValue(VARIANT_PROP); - - if (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemShears)) - { - switch (type) - { - case DEATHBLOOM: - player.addPotionEffect(new PotionEffect(Potion.wither.id, 300)); - break; - - case BURNING_BLOSSOM: - player.setFire(5); - break; - } - } - } - - @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) - { - FlowerType type = (FlowerType) state.getValue(VARIANT_PROP); - - if (type == FlowerType.BURNING_BLOSSOM) - { - entity.setFire(1); - } - else - if (entity instanceof EntityLivingBase && type == FlowerType.DEATHBLOOM) - { - ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.wither.id, 200)); - } - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(VARIANT_PROP, FlowerType.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int meta = ((FlowerType) state.getValue(VARIANT_PROP)).ordinal(); - - return meta; - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - return ((FlowerType) state.getValue(VARIANT_PROP)).getName(); - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) - { - IBlockState state = world.getBlockState(pos); - - switch ((FlowerType) state.getValue(VARIANT_PROP)) - { - case CLOVER: - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F); - break; - - case ORANGE_COSMOS: - this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.8F, 0.7F); - break; - - case PINK_DAFFODIL: - this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); - break; - - case WHITE_ANEMONE: - this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F); - break; - - case DANDELION: - this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); - break; - - default: - this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F); - break; - } - } - - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand) - { - FlowerType type = (FlowerType) state.getValue(VARIANT_PROP); - - if (type == FlowerType.DEATHBLOOM) - { - if (rand.nextInt(4) != 0) - world.spawnParticle(EnumParticleTypes.TOWN_AURA, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); - if (rand.nextInt(4) == 0) - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); - } - else - if (type == FlowerType.BURNING_BLOSSOM) - { - if (rand.nextInt(2) == 0) - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); - if (rand.nextInt(4) == 0) - world.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), pos.getZ() + rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]); - } - } - - // TODO: Readd eyebulb in as a seperate block - // TODO: Readd dandelion blowing - 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 getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLilypad.java b/src/main/java/biomesoplenty/common/block/BlockBOPLilypad.java index 093f15029..40679ac0e 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLilypad.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPLilypad.java @@ -18,7 +18,6 @@ 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; diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLog2.java b/src/main/java/biomesoplenty/common/block/BlockBOPLog2.java deleted file mode 100644 index 0fd4c5e5e..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLog2.java +++ /dev/null @@ -1,84 +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 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.util.EnumFacing; -import net.minecraft.util.IStringSerializable; - -public class BlockBOPLog2 extends BlockBOPLogBaseOld -{ - public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); - - public BlockBOPLog2() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAGIC).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); - } - - @Override - public int damageDropped(IBlockState state) - { - return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP))); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - int axis = meta % 3; - int type = (meta - axis) / 3; - - return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal(); - - return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal(); - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : ""); - } - - public static enum LogType implements IStringSerializable - { - MAGIC, MANGROVE, PALM, REDWOOD, WILLOW; - - @Override - public String getName() - { - return this.name().toLowerCase(); - } - - @Override - public String toString() - { - return getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLog3.java b/src/main/java/biomesoplenty/common/block/BlockBOPLog3.java deleted file mode 100644 index 103d5a91f..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLog3.java +++ /dev/null @@ -1,86 +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 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.util.EnumFacing; -import net.minecraft.util.IStringSerializable; - -public class BlockBOPLog3 extends BlockBOPLogBaseOld -{ - public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); - - public BlockBOPLog3() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.DEAD).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); - } - - @Override - public int damageDropped(IBlockState state) - { - return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP))); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - int axis = meta % 3; - int type = (meta - axis) / 3; - - return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal(); - - return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal(); - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - LogType type = (LogType) state.getValue(VARIANT_PROP); - - return type.getName() + (fullName && type != LogType.GIANT_FLOWER_STEM ? "_log" : ""); - } - - public static enum LogType implements IStringSerializable - { - DEAD, GIANT_FLOWER_STEM, PINE, HELL_BARK, JACARANDA; - - @Override - public String getName() - { - return this.name().toLowerCase(); - } - - @Override - public String toString() - { - return getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLog4.java b/src/main/java/biomesoplenty/common/block/BlockBOPLog4.java deleted file mode 100644 index 0e4117ab2..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLog4.java +++ /dev/null @@ -1,85 +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.common.block.BlockBOPLog3.LogType; -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.util.EnumFacing; -import net.minecraft.util.IStringSerializable; - -public class BlockBOPLog4 extends BlockBOPLogBaseOld -{ - public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); - - public BlockBOPLog4() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.MAHOGANY).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); - } - - @Override - public int damageDropped(IBlockState state) - { - return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP))); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - int axis = meta % 3; - int type = (meta - axis) / 3; - - return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal(); - - return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal(); - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : ""); - } - - public static enum LogType implements IStringSerializable - { - MAHOGANY; - - @Override - public String getName() - { - return this.name().toLowerCase(); - } - - @Override - public String toString() - { - return getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLogBaseOld.java b/src/main/java/biomesoplenty/common/block/BlockBOPLogBaseOld.java deleted file mode 100644 index a682ae326..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLogBaseOld.java +++ /dev/null @@ -1,42 +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 net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; -import biomesoplenty.api.block.BOPBlock; -import biomesoplenty.common.util.inventory.CreativeTabBOP; - -public abstract class BlockBOPLogBaseOld extends BOPBlock -{ - public static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class); - - protected BlockBOPLogBaseOld() - { - super(Material.wood); - - this.setHarvestLevel("axe", 0); - - this.setHardness(2.0F); - this.setResistance(5.0F); - this.setStepSound(Block.soundTypeWood); - } - - @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int metadata, EntityLivingBase entity) - { - return super.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, metadata, entity).withProperty(AXIS_PROP, side.getAxis()); - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPLogOld.java b/src/main/java/biomesoplenty/common/block/BlockBOPLogOld.java deleted file mode 100644 index d5743d826..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPLogOld.java +++ /dev/null @@ -1,84 +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 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.util.EnumFacing; -import net.minecraft.util.IStringSerializable; - -public class BlockBOPLogOld extends BlockBOPLogBaseOld -{ - public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", LogType.class); - - public BlockBOPLogOld() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, LogType.SACRED_OAK).withProperty(AXIS_PROP, EnumFacing.Axis.Y)); - } - - @Override - public int damageDropped(IBlockState state) - { - return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT_PROP, state.getValue(VARIANT_PROP))); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - int axis = meta % 3; - int type = (meta - axis) / 3; - - return this.getDefaultState().withProperty(VARIANT_PROP, LogType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int baseMeta = ((LogType) state.getValue(VARIANT_PROP)).ordinal(); - - return baseMeta * 3 + ((EnumFacing.Axis) state.getValue(AXIS_PROP)).ordinal(); - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { AXIS_PROP, VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - return ((LogType) state.getValue(VARIANT_PROP)).getName() + (fullName ? "_log" : ""); - } - - public static enum LogType implements IStringSerializable - { - SACRED_OAK, CHERRY, DARK, FIR, ETHEREAL; - - @Override - public String getName() - { - return this.name().toLowerCase(); - } - - @Override - public String toString() - { - return getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPPlanksOld.java b/src/main/java/biomesoplenty/common/block/BlockBOPPlanksOld.java deleted file mode 100644 index 734cc136c..000000000 --- a/src/main/java/biomesoplenty/common/block/BlockBOPPlanksOld.java +++ /dev/null @@ -1,86 +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 net.minecraft.block.Block; -import net.minecraft.block.material.Material; -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.util.IStringSerializable; -import biomesoplenty.api.block.BOPBlock; - -public class BlockBOPPlanksOld extends BOPBlock -{ - public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", PlankType.class); - - public BlockBOPPlanksOld() - { - super(Material.wood); - - this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, PlankType.SACRED_OAK)); - - this.setHarvestLevel("axe", 0); - - this.setHardness(2.0F); - this.setStepSound(Block.soundTypeWood); - } - - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(VARIANT_PROP, PlankType.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) - { - int meta = ((PlankType) state.getValue(VARIANT_PROP)).ordinal(); - - return meta; - } - - @Override - protected BlockState createBlockState() - { - return new BlockState(this, new IProperty[] { VARIANT_PROP }); - } - - @Override - public IProperty[] getPresetProperties() - { - return new IProperty[] { VARIANT_PROP }; - } - - @Override - public String getStateName(IBlockState state, boolean fullName) - { - PlankType type = (PlankType) state.getValue(VARIANT_PROP); - - return type.getName() + (fullName && type != PlankType.BAMBOO_THATCHING ? "_planks" : ""); - } - - public static enum PlankType implements IStringSerializable - { - SACRED_OAK, CHERRY, DARK, FIR, ETHEREAL, MAGIC, MANGROVE, PALM, REDWOOD, WILLOW, BAMBOO_THATCHING, PINE, HELL_BARK, JACARANDA, MAHOGANY; - - @Override - public String getName() - { - return this.name().toLowerCase(); - } - - @Override - public String toString() - { - return getName(); - } - } -} diff --git a/src/main/java/biomesoplenty/common/block/BlockBamboo.java b/src/main/java/biomesoplenty/common/block/BlockBamboo.java index b85ddbce1..7a3e08aca 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBamboo.java +++ b/src/main/java/biomesoplenty/common/block/BlockBamboo.java @@ -93,13 +93,14 @@ public class BlockBamboo extends BlockDecoration { if (this.checkAndDropBlock(worldIn, pos, state) && worldIn.isAirBlock(pos.up())) { + int age = ((Integer)state.getValue(AGE)).intValue(); int treeHeight = 1; while (worldIn.getBlockState(pos.down(treeHeight)).getBlock() == this) {++treeHeight;} - if (treeHeight < 3) - { - int age = ((Integer)state.getValue(AGE)).intValue(); - if (true) - //if (age == 15) + //System.out.println("Banboo age: "+age+" tree height: "+treeHeight); + + if (treeHeight < 4) + { + if (age == 15) { // it's old enough to grow worldIn.setBlockState(pos.up(), this.getDefaultState()); diff --git a/src/main/java/biomesoplenty/common/block/BlockDecoration.java b/src/main/java/biomesoplenty/common/block/BlockDecoration.java index 7111851fb..0419f2046 100644 --- a/src/main/java/biomesoplenty/common/block/BlockDecoration.java +++ b/src/main/java/biomesoplenty/common/block/BlockDecoration.java @@ -46,6 +46,7 @@ public class BlockDecoration extends Block implements IBOPBlock super(material); // set some defaults + this.setTickRandomly(true); this.setHardness(0.0F); this.setStepSound(Block.soundTypePiston); this.setBlockBoundsByRadiusAndHeight(0.3F, 0.6F); diff --git a/src/main/java/biomesoplenty/common/block/DHBlock.java b/src/main/java/biomesoplenty/common/block/DHBlock.java deleted file mode 100644 index 1ecd909fc..000000000 --- a/src/main/java/biomesoplenty/common/block/DHBlock.java +++ /dev/null @@ -1,65 +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 java.util.HashMap; -import java.util.Map; - -import biomesoplenty.api.block.IBOPBlock; -import biomesoplenty.common.item.ItemBOPBlock; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -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.item.ItemBlock; -import net.minecraft.util.IStringSerializable; - -public class DHBlock extends Block implements IBOPBlock -{ - - // add properties - public static enum Variant implements IStringSerializable {ROUGH, SHINY; public String getName() {return this.name().toLowerCase();}}; - public static final PropertyEnum VARIANT = PropertyEnum.create("variant", Variant.class); - @Override - protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });} - - // implement IDHBlock - private Map namedStates = new HashMap(); - public Map getNamedStates() {return this.namedStates;} - public IBlockState getNamedState(String name) {return this.namedStates.get(name);} - public Class getItemClass() {return ItemBOPBlock.class;} - - // constructor - public DHBlock(Material material) { - - super(material); - - // define named states - this.namedStates.put("rough", this.blockState.getBaseState().withProperty(VARIANT, Variant.ROUGH) ); - this.namedStates.put("shiny", this.blockState.getBaseState().withProperty(VARIANT, Variant.SHINY) ); - - this.setDefaultState(this.namedStates.get("rough")); - - } - - // map from state to meta and vice verca - @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(VARIANT, Variant.values()[meta]); - } - @Override - public int getMetaFromState(IBlockState state) - { - return ((Variant) state.getValue(VARIANT)).ordinal(); - } - -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/init/ModBlocks.java b/src/main/java/biomesoplenty/common/init/ModBlocks.java index 81f731b97..060b313d5 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlocks.java +++ b/src/main/java/biomesoplenty/common/init/ModBlocks.java @@ -19,7 +19,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; -import biomesoplenty.api.block.BOPBlock; import biomesoplenty.api.block.BOPWoodType; import biomesoplenty.api.block.IBOPBlock; import biomesoplenty.common.block.BlockAsh; @@ -48,20 +47,17 @@ import biomesoplenty.common.block.BlockStoneFormations; import biomesoplenty.common.block.BlockTurnip; import biomesoplenty.common.block.BlockFlesh; import biomesoplenty.common.handler.GuiEventHandler; -import biomesoplenty.common.util.block.BlockStateUtils; import biomesoplenty.common.util.inventory.CreativeTabBOP; import biomesoplenty.core.BiomesOPlenty; public class ModBlocks { - // syntactic sugar - + // BlockModifier class encapsulates modifications which can be made to generic blocks in a unified way public static enum BlockModifiers {HARDNESS, RESISTANCE, STEP_SOUND, CREATIVE_TAB, HARVEST_LEVEL}; public static class BlockModifier { - private BlockModifiers mod; public float f; public int i; @@ -91,18 +87,18 @@ public class ModBlocks case HARVEST_LEVEL: block.setHarvestLevel(s, i); break; - } - - - } - + } + } } + // convenience methods for creating BlockModifier instances - eg hardness(2.5F) creates a BlockModifier which can set a block's hardness to 2.5 public static BlockModifier hardness(float f) {BlockModifier m = new BlockModifier(BlockModifiers.HARDNESS); m.f = f; return m;} public static BlockModifier resistance(float f) {BlockModifier m = new BlockModifier(BlockModifiers.RESISTANCE); m.f = f; return m;} public static BlockModifier stepSound(Block.SoundType sound) {BlockModifier m = new BlockModifier(BlockModifiers.STEP_SOUND); m.sound = sound; return m;} public static BlockModifier creativeTab(CreativeTabs tab) {BlockModifier m = new BlockModifier(BlockModifiers.CREATIVE_TAB); m.tab = tab; return m;} public static BlockModifier harvestLevel(String toolClass, int level) {BlockModifier m = new BlockModifier(BlockModifiers.HARVEST_LEVEL); m.s = toolClass; m.i = level; return m;} - + // result - can now specify lists of modifiers which all have a common type. eg: + // BlockModifier[] = {hardness(2.5F), harvestLevel("axe",2), creativeTab(null)}; + // these can be used to quickly add new blocks from generic block classes @@ -202,7 +198,7 @@ public class ModBlocks GameRegistry.registerBlock(block, bopBlock.getItemClass(), blockName); if (bopBlock.getNamedStates().isEmpty()) { - // block has no variants to register + // block has no named variants to register registerBlockVariant(block, blockName, block.getMetaFromState(block.getDefaultState())); } else @@ -220,7 +216,6 @@ public class ModBlocks else { // for vanilla blocks, just register a single variant with meta=0 and assume ItemBlock for the item class - // TODO: remove this bit once all the BOP blocks have been updated to support IBOPBlock GameRegistry.registerBlock(block, ItemBlock.class , blockName); registerBlockVariant(block, blockName, 0); } @@ -228,39 +223,4 @@ public class ModBlocks return block; } - private static Block registerBOPBlock(BOPBlock block, String name) - { - if (block.presetStates == null) - block.presetStates = BlockStateUtils.getValidStatesForProperties(block.getDefaultState(), block.getPresetProperties()); - - block.setUnlocalizedName(name); - - if (block.hasPresetProperties()) - { - GameRegistry.registerBlock(block, block.getItemClass(), name); - - for (IBlockState state : block.presetStates) - { - String stateName = block.getStateName(state, true); - int stateMeta = block.getMetaFromState(state); - - BiomesOPlenty.proxy.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + stateName); - BiomesOPlenty.proxy.registerBlockForMeshing(block, stateMeta, stateName); - - GuiEventHandler.blockCount++; - } - } - else - { - GameRegistry.registerBlock(block, name); - - BiomesOPlenty.proxy.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + name); - BiomesOPlenty.proxy.registerBlockForMeshing(block, 0, name); - - GuiEventHandler.blockCount++; - } - - return block; - } - } diff --git a/src/main/java/biomesoplenty/common/init/ModItems.java b/src/main/java/biomesoplenty/common/init/ModItems.java index c5141ec64..e11a7fb8e 100644 --- a/src/main/java/biomesoplenty/common/init/ModItems.java +++ b/src/main/java/biomesoplenty/common/init/ModItems.java @@ -21,7 +21,6 @@ import biomesoplenty.core.BiomesOPlenty; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemSeedFood; import net.minecraft.item.ItemSeeds; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.GameRegistry; diff --git a/src/main/java/biomesoplenty/common/item/ItemBlockWithVariants.java b/src/main/java/biomesoplenty/common/item/ItemBlockWithVariants.java deleted file mode 100644 index 2e13a3805..000000000 --- a/src/main/java/biomesoplenty/common/item/ItemBlockWithVariants.java +++ /dev/null @@ -1,61 +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.item; - -import biomesoplenty.api.block.BOPBlock; -import biomesoplenty.common.block.BlockBOPGrass; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemBlockWithVariants extends ItemBlock -{ - public ItemBlockWithVariants(Block block) - { - super(block); - - this.setMaxDamage(0); - this.setHasSubtypes(true); - } - - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int renderPass) - { - // TODO: might be neater to use an interface rather than checking for specific blocks? - if (this.block instanceof BlockBOPGrass) - { - // grass item will render with grey grass unless we set the color here - return ((BlockBOPGrass)this.block).getRenderColor(this.block.getStateFromMeta(stack.getMetadata())); - } - return super.getColorFromItemStack(stack,renderPass); - } - - @Override - public int getMetadata(int metadata) - { - return metadata; - } - - @Override - public String getUnlocalizedName(ItemStack stack) - { - BOPBlock block = (BOPBlock) this.block; - - if (block.hasPresetProperties()) - { - return super.getUnlocalizedName() + "." + block.getStateName(block.getStateFromMeta(stack.getMetadata()), false); - } - - else - return super.getUnlocalizedName(); - } -} diff --git a/src/main/java/biomesoplenty/common/util/block/BlockStateUtils.java b/src/main/java/biomesoplenty/common/util/block/BlockStateUtils.java index b0bd6fdec..080b93a50 100644 --- a/src/main/java/biomesoplenty/common/util/block/BlockStateUtils.java +++ b/src/main/java/biomesoplenty/common/util/block/BlockStateUtils.java @@ -9,7 +9,6 @@ package biomesoplenty.common.util.block; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Set; @@ -18,9 +17,7 @@ import java.util.Map.Entry; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; -import com.google.common.collect.HashBasedTable; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; public class BlockStateUtils diff --git a/src/main/java/biomesoplenty/core/ClientProxy.java b/src/main/java/biomesoplenty/core/ClientProxy.java index 639f55007..c3d093db1 100644 --- a/src/main/java/biomesoplenty/core/ClientProxy.java +++ b/src/main/java/biomesoplenty/core/ClientProxy.java @@ -9,18 +9,16 @@ package biomesoplenty.core; import java.util.ArrayList; -import java.util.Map.Entry; import net.minecraft.block.Block; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.item.Item; -import biomesoplenty.api.block.BOPBlock; import biomesoplenty.client.util.ModelHelper; public class ClientProxy extends CommonProxy { - private static ArrayList blocksToRegister = new ArrayList(); - private static ArrayList itemsToRegister = new ArrayList(); + private static ArrayList blocksToRegister = new ArrayList(); + private static ArrayList itemsToRegister = new ArrayList(); @Override public void registerRenderers()