Readded bone segments

This commit is contained in:
Adubbz 2015-01-06 17:49:04 +00:00
parent c8ea198f67
commit 9012152e5c
15 changed files with 287 additions and 2 deletions

View file

@ -33,8 +33,6 @@ public abstract class BOPBlock extends Block
{ {
super(material); super(material);
this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
this.setCreativeTab(CreativeTabBOP.instance); this.setCreativeTab(CreativeTabBOP.instance);
} }

View file

@ -14,6 +14,7 @@ public class BOPBlocks
{ {
public static Block ash_block; public static Block ash_block;
public static Block bamboo; public static Block bamboo;
public static Block bone_segment;
public static Block flower; public static Block flower;
public static Block flower2; public static Block flower2;
public static Block gem; public static Block gem;

View file

@ -0,0 +1,183 @@
/*******************************************************************************
* 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.entity.EntityLivingBase;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
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.BOPBlock;
public class BlockBones extends BOPBlock
{
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", BoneType.class);
public static final PropertyEnum AXIS_PROP = PropertyEnum.create("axis", EnumFacing.Axis.class);
public BlockBones()
{
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, BoneType.SMALL).withProperty(AXIS_PROP, EnumFacing.Axis.Y));
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setStepSound(Block.soundTypeStone);
}
@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());
}
@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, BoneType.values()[type]).withProperty(AXIS_PROP, EnumFacing.Axis.values()[axis]);
}
@Override
public int getMetaFromState(IBlockState state)
{
int baseMeta = ((BoneType)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 ((BoneType)state.getValue(VARIANT_PROP)).getName() + (fullName ? "_bone_segment" : "");
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
@Override
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
if (state.getBlock() != this) return;
float width;
switch ((BoneType)state.getValue(VARIANT_PROP))
{
case SMALL:
width = 0.25F;
break;
case MEDIUM:
width = 0.625F;
break;
case LARGE:
width = 1F;
break;
default:
width = 1F;
break;
}
float min = (1.0F - width) / 2F;
float max = 1.0F - min;
switch ((EnumFacing.Axis)state.getValue(AXIS_PROP))
{
case X:
this.setBlockBounds(0F, min, min, 1.0F, max, max);
break;
case Y:
this.setBlockBounds(min, 0F, min, max, 1.0F, max);
break;
case Z:
this.setBlockBounds(min, min, 0F, max, max, 1.0F);
break;
}
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube()
{
return false;
}
public static enum BoneType implements IStringSerializable
{
SMALL,
MEDIUM,
LARGE;
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override
public String toString()
{
return getName();
}
}
}

View file

@ -9,6 +9,7 @@
package biomesoplenty.common.block; package biomesoplenty.common.block;
import biomesoplenty.api.block.BOPBlock; import biomesoplenty.api.block.BOPBlock;
import biomesoplenty.common.util.block.BlockStateUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@ -28,6 +29,8 @@ public class BlockGem extends BOPBlock
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST));
this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
for (IBlockState state : presetStates) for (IBlockState state : presetStates)
{ {
this.setHarvestLevel("pickaxe", 2, state); this.setHarvestLevel("pickaxe", 2, state);

View file

@ -11,6 +11,7 @@ package biomesoplenty.common.block;
import static biomesoplenty.common.block.BlockGem.VARIANT_PROP; import static biomesoplenty.common.block.BlockGem.VARIANT_PROP;
import biomesoplenty.api.block.BOPBlock; import biomesoplenty.api.block.BOPBlock;
import biomesoplenty.common.block.BlockGem.GemType; import biomesoplenty.common.block.BlockGem.GemType;
import biomesoplenty.common.util.block.BlockStateUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@ -25,6 +26,8 @@ public class BlockGemOre extends BOPBlock
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST)); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, GemType.AMETHYST));
this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties());
for (IBlockState state : presetStates) for (IBlockState state : presetStates)
{ {
this.setHarvestLevel("pickaxe", 2, state); this.setHarvestLevel("pickaxe", 2, state);

View file

@ -29,6 +29,7 @@ import biomesoplenty.common.block.BlockBOPMushroom;
import biomesoplenty.common.block.BlockBOPPlanks; import biomesoplenty.common.block.BlockBOPPlanks;
import biomesoplenty.common.block.BlockBOPStone; import biomesoplenty.common.block.BlockBOPStone;
import biomesoplenty.common.block.BlockBamboo; import biomesoplenty.common.block.BlockBamboo;
import biomesoplenty.common.block.BlockBones;
import biomesoplenty.common.block.BlockGem; 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;
@ -42,6 +43,7 @@ public class ModBlocks
{ {
ash_block = registerBlock(new BlockAsh(), "ash_block"); ash_block = registerBlock(new BlockAsh(), "ash_block");
bamboo = registerBlock(new BlockBamboo(), "bamboo"); bamboo = registerBlock(new BlockBamboo(), "bamboo");
bone_segment = registerBlock(new BlockBones(), "bone_segment");
flower = registerBlock(new BlockBOPFlower(), "flower"); flower = registerBlock(new BlockBOPFlower(), "flower");
flower2 = registerBlock(new BlockBOPFlower2(), "flower2"); flower2 = registerBlock(new BlockBOPFlower2(), "flower2");
gem = registerBlock(new BlockGem(), "gem"); gem = registerBlock(new BlockGem(), "gem");
@ -58,6 +60,8 @@ public class ModBlocks
private static Block registerBlock(BOPBlock block, String name) private static Block registerBlock(BOPBlock block, String name)
{ {
if (block.presetStates == null) block.presetStates = BlockStateUtils.getValidStatesForProperties(block.getDefaultState(), block.getPresetProperties());
block.setUnlocalizedName(name); block.setUnlocalizedName(name);
if (block.hasPresetProperties()) if (block.hasPresetProperties())

View file

@ -0,0 +1,13 @@
{
"variants": {
"axis=x,variant=small": { "model": "biomesoplenty:small_bone_segment", "x": 90, "y": 90 },
"axis=y,variant=small": { "model": "biomesoplenty:small_bone_segment" },
"axis=z,variant=small": { "model": "biomesoplenty:small_bone_segment", "x": 90 },
"axis=x,variant=medium": { "model": "biomesoplenty:medium_bone_segment", "x": 90, "y": 90 },
"axis=y,variant=medium": { "model": "biomesoplenty:medium_bone_segment" },
"axis=z,variant=medium": { "model": "biomesoplenty:medium_bone_segment", "x": 90 },
"axis=x,variant=large": { "model": "biomesoplenty:large_bone_segment", "x": 90, "y": 90 },
"axis=y,variant=large": { "model": "biomesoplenty:large_bone_segment" },
"axis=z,variant=large": { "model": "biomesoplenty:large_bone_segment", "x": 90 }
}
}

View file

@ -4,6 +4,10 @@ tile.ash_block.name=Ash Block
tile.bamboo.name=Bamboo tile.bamboo.name=Bamboo
tile.bone_segment.small.name=Small Bone Segment
tile.bone_segment.medium.name=Medium Bone Segment
tile.bone_segment.large.name=Large Bone Segment
tile.bopGrass.spectral_moss.name=Spectral Moss tile.bopGrass.spectral_moss.name=Spectral Moss
tile.bopGrass.smoldering_grass_block.name=Smoldering Grass Block tile.bopGrass.smoldering_grass_block.name=Smoldering Grass Block

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "biomesoplenty:blocks/bone_segment"
}
}

View file

@ -0,0 +1,20 @@
{
"textures": {
"bone_segment": "biomesoplenty:blocks/bone_segment",
"particle": "biomesoplenty:blocks/bone_segment"
},
"elements": [
{
"from": [ 3, 0, 3 ],
"to": [ 13, 16, 13 ],
"faces": {
"down": { "uv": [ 3, 3, 13, 10 ], "texture": "#bone_segment" },
"up": { "uv": [ 3, 3, 13, 10 ], "texture": "#bone_segment" },
"north": { "uv": [ 3, 0, 13, 16 ], "texture": "#bone_segment" },
"south": { "uv": [ 3, 0, 13, 16 ], "texture": "#bone_segment" },
"west": { "uv": [ 3, 0, 13, 16 ], "texture": "#bone_segment" },
"east": { "uv": [ 3, 0, 13, 16 ], "texture": "#bone_segment" }
}
}
]
}

View file

@ -0,0 +1,20 @@
{
"textures": {
"bone_segment": "biomesoplenty:blocks/bone_segment",
"particle": "biomesoplenty:blocks/bone_segment"
},
"elements": [
{
"from": [ 6, 0, 6 ],
"to": [ 10, 16, 10 ],
"faces": {
"down": { "uv": [ 6, 6, 10, 10 ], "texture": "#bone_segment" },
"up": { "uv": [ 6, 6, 10, 10 ], "texture": "#bone_segment" },
"north": { "uv": [ 6, 0, 10, 16 ], "texture": "#bone_segment" },
"south": { "uv": [ 6, 0, 10, 16 ], "texture": "#bone_segment" },
"west": { "uv": [ 6, 0, 10, 16 ], "texture": "#bone_segment" },
"east": { "uv": [ 6, 0, 10, 16 ], "texture": "#bone_segment" }
}
}
]
}

View file

@ -0,0 +1,10 @@
{
"parent": "biomesoplenty:block/large_bone_segment",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View file

@ -0,0 +1,10 @@
{
"parent": "biomesoplenty:block/medium_bone_segment",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View file

@ -0,0 +1,10 @@
{
"parent": "biomesoplenty:block/small_bone_segment",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B