Add stalagmites and stalactites
This commit is contained in:
parent
f759408d38
commit
8eefe072c6
11 changed files with 179 additions and 0 deletions
|
@ -34,4 +34,5 @@ public class BOPBlocks
|
||||||
public static Block grass;
|
public static Block grass;
|
||||||
public static Block waterlily;
|
public static Block waterlily;
|
||||||
public static Block dirt;
|
public static Block dirt;
|
||||||
|
public static Block stone_formations;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.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.init.Blocks;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import biomesoplenty.api.block.BOPPlant;
|
||||||
|
|
||||||
|
public class BlockStoneFormations extends BOPPlant
|
||||||
|
{
|
||||||
|
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", StoneFormationType.class);
|
||||||
|
|
||||||
|
public BlockStoneFormations()
|
||||||
|
{
|
||||||
|
super(Material.vine);
|
||||||
|
this.setHardness(0.5F);
|
||||||
|
this.setStepSound(soundTypePiston);
|
||||||
|
}
|
||||||
|
|
||||||
|
// bounding box is not full size
|
||||||
|
@Override
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
|
||||||
|
float radius = 0.3F;
|
||||||
|
float height = 0.6F;
|
||||||
|
switch ((StoneFormationType) worldIn.getBlockState(pos).getValue(VARIANT_PROP))
|
||||||
|
{
|
||||||
|
case STALACTITE:
|
||||||
|
// against top of block for stalactites
|
||||||
|
this.setBlockBounds(0.5F - radius, 1.0F - height, 0.5F - radius, 0.5F + radius, 1.0F, 0.5F + radius);
|
||||||
|
break;
|
||||||
|
case STALAGMITE:
|
||||||
|
// against bottom of block for stalagmites
|
||||||
|
this.setBlockBounds(0.5F - radius, 0.0F, 0.5F - radius, 0.5F + radius, height, 0.5F + radius);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta)
|
||||||
|
{
|
||||||
|
// only one property to worry about, the variant, so just map [0 => STALAGMITE, 1 => STALACTITE]
|
||||||
|
return this.getDefaultState().withProperty(VARIANT_PROP, StoneFormationType.values()[meta]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state)
|
||||||
|
{
|
||||||
|
// only one property to worry about, the variant, so just map [0 => STALAGMITE, 1 => STALACTITE]
|
||||||
|
return ((StoneFormationType) state.getValue(VARIANT_PROP)).ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 ((StoneFormationType) state.getValue(VARIANT_PROP)).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
// only allow stalactites hanging from stone, and only allow stalagmites on top of stone
|
||||||
|
@Override
|
||||||
|
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
|
||||||
|
{
|
||||||
|
IBlockState touching;
|
||||||
|
switch ((StoneFormationType)state.getValue(VARIANT_PROP))
|
||||||
|
{
|
||||||
|
case STALACTITE:
|
||||||
|
touching = world.getBlockState(pos.up());
|
||||||
|
break;
|
||||||
|
case STALAGMITE: default:
|
||||||
|
touching = world.getBlockState(pos.down());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return touching.getBlock() == Blocks.stone;
|
||||||
|
}
|
||||||
|
|
||||||
|
// enum representing the 2 variants of stone formations
|
||||||
|
public static enum StoneFormationType implements IStringSerializable
|
||||||
|
{
|
||||||
|
STALAGMITE, STALACTITE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ import biomesoplenty.common.block.BlockGem;
|
||||||
import biomesoplenty.common.block.BlockGemOre;
|
import biomesoplenty.common.block.BlockGemOre;
|
||||||
import biomesoplenty.common.block.BlockHive;
|
import biomesoplenty.common.block.BlockHive;
|
||||||
import biomesoplenty.common.block.BlockMud;
|
import biomesoplenty.common.block.BlockMud;
|
||||||
|
import biomesoplenty.common.block.BlockStoneFormations;
|
||||||
import biomesoplenty.common.block.BlockTurnip;
|
import biomesoplenty.common.block.BlockTurnip;
|
||||||
import biomesoplenty.common.block.BlockFlesh;
|
import biomesoplenty.common.block.BlockFlesh;
|
||||||
import biomesoplenty.common.handler.GuiEventHandler;
|
import biomesoplenty.common.handler.GuiEventHandler;
|
||||||
|
@ -66,6 +67,7 @@ public class ModBlocks
|
||||||
grass = registerBlock(new BlockBOPGrass(), "grass");
|
grass = registerBlock(new BlockBOPGrass(), "grass");
|
||||||
waterlily = registerBlock(new BlockBOPLilypad(), "waterlily");
|
waterlily = registerBlock(new BlockBOPLilypad(), "waterlily");
|
||||||
dirt = registerBlock(new BlockBOPDirt(), "dirt");
|
dirt = registerBlock(new BlockBOPDirt(), "dirt");
|
||||||
|
stone_formations = registerBlock(new BlockStoneFormations(),"stone_formations");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"variant=stalagmite": { "model": "biomesoplenty:stalagmite" },
|
||||||
|
"variant=stalactite": { "model": "biomesoplenty:stalactite" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -140,6 +140,9 @@ tile.dirt.coarse_loamy_dirt.name=Coarse Loamy Dirt
|
||||||
tile.dirt.coarse_sandy_dirt.name=Coarse Sandy Dirt
|
tile.dirt.coarse_sandy_dirt.name=Coarse Sandy Dirt
|
||||||
tile.dirt.coarse_silty_dirt.name=Coarse Silty Dirt
|
tile.dirt.coarse_silty_dirt.name=Coarse Silty Dirt
|
||||||
|
|
||||||
|
tile.stone_formations.stalagmite.name=Stalagmite
|
||||||
|
tile.stone_formations.stalactite.name=Stalactite
|
||||||
|
|
||||||
item.fleshchunk.name=Chunk of Flesh
|
item.fleshchunk.name=Chunk of Flesh
|
||||||
item.mudball.name=Mud Ball
|
item.mudball.name=Mud Ball
|
||||||
item.turnip.name=Turnip
|
item.turnip.name=Turnip
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cross",
|
||||||
|
"textures": {
|
||||||
|
"cross": "biomesoplenty:blocks/stalactite"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cross",
|
||||||
|
"textures": {
|
||||||
|
"cross": "biomesoplenty:blocks/stalagmite"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "biomesoplenty:blocks/stalactite"
|
||||||
|
},
|
||||||
|
"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 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "biomesoplenty:blocks/stalagmite"
|
||||||
|
},
|
||||||
|
"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: 273 B |
Binary file not shown.
After Width: | Height: | Size: 281 B |
Loading…
Reference in a new issue