Began work on flowers

This commit is contained in:
Adubbz 2014-10-04 22:35:51 +10:00
parent f236e93bfa
commit aa0b3fd423
46 changed files with 539 additions and 25 deletions

View file

@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.List;
import biomesoplenty.api.IConfigurable;
import biomesoplenty.common.util.inventory.CreativeTabBOP;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
@ -31,6 +32,10 @@ public abstract class BOPBlock extends Block implements IConfigurable
super(material);
this.variantProperty = variantProperty;
if (variantProperty != null) this.setDefaultState(this.blockState.getBaseState().withProperty(variantProperty, (Comparable)variantProperty.getAllowedValues().toArray()[0]));
this.setCreativeTab(CreativeTabBOP.instance);
}
protected BOPBlock(Material material)
@ -38,6 +43,18 @@ public abstract class BOPBlock extends Block implements IConfigurable
this(material, null);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return hasVariants() ? this.getDefaultState().withProperty(variantProperty, (Comparable)variantProperty.getAllowedValues().toArray()[meta]) : super.getStateFromMeta(meta);
}
@Override
public int getMetaFromState(IBlockState state)
{
return hasVariants() ? ((Enum)state.getValue(variantProperty)).ordinal() : super.getMetaFromState(state);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list)

View file

@ -13,6 +13,7 @@ import net.minecraft.block.Block;
public class BOPBlocks
{
public static Block ash_block;
public static Block flower;
public static Block log;
public static Block log2;
public static Block log3;

View file

@ -0,0 +1,96 @@
/*******************************************************************************
* 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.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
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(PropertyEnum variantProperty)
{
super(Material.plants, variantProperty);
this.setTickRandomly(true);
this.setHardness(0.0F);
this.setStepSound(Block.soundTypeGrass);
}
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
return super.canPlaceBlockAt(world, pos) && this.canBlockStay(world, pos, world.getBlockState(pos));
}
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
{
Block ground = world.getBlockState(pos.offsetDown()).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 worldIn, 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;
}
}

View file

@ -12,13 +12,13 @@ import java.util.Map;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
//TODO: Remove this or the ModelBakeryTransformer. It shouldn't be needed.
//TODO: Remove this or the BOPTransformer. It shouldn't be needed.
public class BOPLoadingPlugin implements IFMLLoadingPlugin
{
@Override
public String[] getASMTransformerClass()
{
return new String[] { ModelBakeryTransformer.class.getName() };
return new String[] { BOPTransformer.class.getName() };
}
@Override

View file

@ -21,7 +21,7 @@ import org.objectweb.asm.tree.VarInsnNode;
import net.minecraft.launchwrapper.IClassTransformer;
public class ModelBakeryTransformer implements IClassTransformer
public class BOPTransformer implements IClassTransformer
{
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass)

View file

@ -28,25 +28,10 @@ public class BOPBlockPlanks extends BOPBlock
{
super(Material.wood, VARIANT_PROP);
this.setDefaultBlockState(this.blockState.getBaseState().withProperty(VARIANT_PROP, PlankType.SACRED_OAK));
//this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setStepSound(Block.soundTypeWood);
this.setCreativeTab(CreativeTabBOP.instance);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT_PROP, PlankType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((PlankType)state.getValue(VARIANT_PROP)).ordinal();
}
@Override

View file

@ -33,7 +33,6 @@ public class BlockAsh extends BOPBlock
this.setHardness(0.4F);
//this.setHarvestLevel("shovel", 0);
this.setStepSound(Block.soundTypeSand);
this.setCreativeTab(CreativeTabBOP.instance);
}
@Override

View file

@ -0,0 +1,134 @@
/*******************************************************************************
* 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.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.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
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.BOPBlock;
import biomesoplenty.api.block.BOPPlant;
import biomesoplenty.api.block.IBOPVariant;
import biomesoplenty.common.util.inventory.CreativeTabBOP;
public class BlockBOPFlower extends BOPPlant
{
public static PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FlowerType.class);
public BlockBOPFlower()
{
super(VARIANT_PROP);
}
//TODO: Add light for glowflowers (Requires Forge)
@Override
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { VARIANT_PROP });
}
@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;
default:
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
break;
}
}
@Override
@SideOnly(Side.CLIENT)
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
{
if ((FlowerType)state.getValue(VARIANT_PROP) == 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]);
}
}
public static enum FlowerType implements IBOPVariant
{
CLOVER,
SWAMPFLOWER,
DEATHBLOOM,
GLOWFLOWER,
BLUE_HYDRANGEA,
ORANGE_COSMOS,
PINK_DAFFODIL,
WILDFLOWER,
VIOLET,
WHITE_ANEMONE;
@Override
public String getBaseName()
{
return null;
}
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
@Override
public int getDefaultMetadata()
{
return this.ordinal();
}
}
}

View file

@ -14,6 +14,7 @@ import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import biomesoplenty.api.block.IBOPVariant;
import biomesoplenty.common.block.BOPBlockPlanks.PlankType;
public class BlockBOPLog extends BlockBOPLogBase
{

View file

@ -28,12 +28,13 @@ public abstract class BlockBOPLogBase extends BOPBlock
{
super(Material.wood, variantProperty);
this.setDefaultState(this.getDefaultState().withProperty(AXIS_PROP, EnumFacing.Axis.Y));
//this.setHarvestLevel("axe", 0);
this.setHardness(2.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypeWood);
this.setCreativeTab(CreativeTabBOP.instance);
}
@Override

View file

@ -16,6 +16,7 @@ import biomesoplenty.api.block.IBOPVariant;
import biomesoplenty.client.util.ModelHelper;
import biomesoplenty.common.block.BOPBlockPlanks;
import biomesoplenty.common.block.BlockAsh;
import biomesoplenty.common.block.BlockBOPFlower;
import biomesoplenty.common.block.BlockBOPLog;
import biomesoplenty.common.block.BlockBOPLog2;
import biomesoplenty.common.block.BlockBOPLog3;
@ -29,6 +30,7 @@ public class ModBlocks
public static void init()
{
ash_block = registerBlock(new BlockAsh(), "ash_block");
flower = registerBlock(new BlockBOPFlower(), "flower");
log = registerBlock(new BlockBOPLog(), "log");
log2 = registerBlock(new BlockBOPLog2(), "log2");
log3 = registerBlock(new BlockBOPLog3(), "log3");

View file

@ -11,7 +11,6 @@ package biomesoplenty.common.item;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import biomesoplenty.api.block.BOPBlock;
public class ItemBlockWithVariants extends ItemBlock
@ -20,7 +19,7 @@ public class ItemBlockWithVariants extends ItemBlock
{
super(block);
this.setMaxDurability(0);
this.setMaxDamage(0);
this.setHasSubtypes(true);
}
@ -33,7 +32,7 @@ public class ItemBlockWithVariants extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack stack)
{
BOPBlock bopBlock = (BOPBlock)this.blockInstance;
BOPBlock bopBlock = (BOPBlock)this.block;
if (bopBlock.hasVariants())
{

View file

@ -11,4 +11,7 @@ package biomesoplenty.common.util;
public class ReflectionHelper
{
//Various fields used in Reflection. These should be checked with every update.
//Item
public static String[] BLOCK_TO_ITEM = new String[] { "BLOCK_TO_ITEM", "field_179220_a" };
}

View file

@ -36,7 +36,8 @@ public class RegistryUtil
block = GameRegistry.registerBlock(block, itemclass, name, itemCtorArgs);
Item associatedItem = GameRegistry.findItem(BiomesOPlenty.MOD_ID, name);
Item.field_179220_a.put(block, associatedItem);
Map blockToItem = ObfuscationReflectionHelper.getPrivateValue(Item.class, null, ReflectionHelper.BLOCK_TO_ITEM);
blockToItem.put(block, associatedItem);
Iterator iterator = block.getBlockState().getValidStates().iterator();
@ -44,7 +45,7 @@ public class RegistryUtil
{
IBlockState iblockstate = (IBlockState)iterator.next();
int id = Block.blockRegistry.getIDForObject(block) << 4 | block.getMetaFromState(iblockstate);
Block.field_176229_d.func_148746_a(iblockstate, id);
Block.BLOCK_STATE_IDS.put(iblockstate, id);
}
return block;

View file

@ -0,0 +1,14 @@
{
"variants": {
"variant=clover": { "model": "biomesoplenty:clover" },
"variant=swampflower": { "model": "biomesoplenty:swampflower" },
"variant=deathbloom": { "model": "biomesoplenty:deathbloom" },
"variant=glowflower": { "model": "biomesoplenty:glowflower" },
"variant=blue_hydrangea": { "model": "biomesoplenty:blue_hydrangea" },
"variant=orange_cosmos": { "model": "biomesoplenty:orange_cosmos" },
"variant=pink_daffodil": { "model": "biomesoplenty:pink_daffodil" },
"variant=wildflower": { "model": "biomesoplenty:wildflower" },
"variant=violet": { "model": "biomesoplenty:violet" },
"variant=white_anemone": { "model": "biomesoplenty:white_anemone" }
}
}

View file

@ -1,5 +1,16 @@
tile.ash_block.name=Ash Block
tile.flower.clover.name=Clover
tile.flower.swampflower.name=Swampflower
tile.flower.deathbloom.name=Deathbloom
tile.flower.glowflower.name=Glowflower
tile.flower.blue_hydrangea.name=Blue Hydrangea
tile.flower.orange_cosmos.name=Orange Cosmos
tile.flower.pink_daffodil.name=Pink Dafodil
tile.flower.wildflower.name=Wildflower
tile.flower.violet.name=Violet
tile.flower.white_anemone.name=White Anemone
tile.log.sacred_oak.name=Sacred Oak Wood
tile.log.cherry.name=Cherry Wood
tile.log.dark.name=Dark Wood

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/blue_hydrangea"
}
}

View file

@ -0,0 +1,16 @@
{
"ambientocclusion": false,
"textures": {
"particle": "biomesoplenty:blocks/clover",
"texture": "biomesoplenty:blocks/clover"
},
"elements": [
{ "from": [ 0, 0.015625, 0 ],
"to": [ 16, 0.015625, 16 ],
"faces": {
"down": { "uv": [ 16, 16, 0, 0 ], "texture": "#texture", "tintindex": 0 },
"up": { "uv": [ 16, 0, 0, 16 ], "texture": "#texture", "tintindex": 0 }
}
}
]
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/deathbloom"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/glowflower"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/orange_cosmos"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/pink_daffodil"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/swampflower"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/violet"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/white_anemone"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "biomesoplenty:blocks/wildflower"
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/blue_hydrangea"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/clover"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/deathbloom"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/glowflower"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/orange_cosmos"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/pink_daffodil"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/swampflower"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/violet"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/white_anemone"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View file

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:blocks/wildflower"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B