From 9012152e5c38114ab980888dcf235a9a6bdf0c60 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Tue, 6 Jan 2015 17:49:04 +0000 Subject: [PATCH] Readded bone segments --- .../biomesoplenty/api/block/BOPBlock.java | 2 - .../biomesoplenty/api/block/BOPBlocks.java | 1 + .../common/block/BlockBones.java | 183 ++++++++++++++++++ .../biomesoplenty/common/block/BlockGem.java | 3 + .../common/block/BlockGemOre.java | 3 + .../biomesoplenty/common/init/ModBlocks.java | 4 + .../blockstates/bone_segment.json | 13 ++ .../assets/biomesoplenty/lang/en_US.lang | 4 + .../models/block/large_bone_segment.json | 6 + .../models/block/medium_bone_segment.json | 20 ++ .../models/block/small_bone_segment.json | 20 ++ .../models/item/large_bone_segment.json | 10 + .../models/item/medium_bone_segment.json | 10 + .../models/item/small_bone_segment.json | 10 + .../textures/blocks/bone_segment.png | Bin 0 -> 523 bytes 15 files changed, 287 insertions(+), 2 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/block/BlockBones.java create mode 100755 src/main/resources/assets/biomesoplenty/blockstates/bone_segment.json create mode 100755 src/main/resources/assets/biomesoplenty/models/block/large_bone_segment.json create mode 100755 src/main/resources/assets/biomesoplenty/models/block/medium_bone_segment.json create mode 100755 src/main/resources/assets/biomesoplenty/models/block/small_bone_segment.json create mode 100755 src/main/resources/assets/biomesoplenty/models/item/large_bone_segment.json create mode 100755 src/main/resources/assets/biomesoplenty/models/item/medium_bone_segment.json create mode 100755 src/main/resources/assets/biomesoplenty/models/item/small_bone_segment.json create mode 100644 src/main/resources/assets/biomesoplenty/textures/blocks/bone_segment.png diff --git a/src/main/java/biomesoplenty/api/block/BOPBlock.java b/src/main/java/biomesoplenty/api/block/BOPBlock.java index 42f7c6d98..c0f412e39 100644 --- a/src/main/java/biomesoplenty/api/block/BOPBlock.java +++ b/src/main/java/biomesoplenty/api/block/BOPBlock.java @@ -33,8 +33,6 @@ public abstract class BOPBlock extends Block { super(material); - this.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties()); - this.setCreativeTab(CreativeTabBOP.instance); } diff --git a/src/main/java/biomesoplenty/api/block/BOPBlocks.java b/src/main/java/biomesoplenty/api/block/BOPBlocks.java index 720217ea4..85a9f04b2 100644 --- a/src/main/java/biomesoplenty/api/block/BOPBlocks.java +++ b/src/main/java/biomesoplenty/api/block/BOPBlocks.java @@ -14,6 +14,7 @@ public class BOPBlocks { public static Block ash_block; public static Block bamboo; + public static Block bone_segment; public static Block flower; public static Block flower2; public static Block gem; diff --git a/src/main/java/biomesoplenty/common/block/BlockBones.java b/src/main/java/biomesoplenty/common/block/BlockBones.java new file mode 100644 index 000000000..a11d5c724 --- /dev/null +++ b/src/main/java/biomesoplenty/common/block/BlockBones.java @@ -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(); + } + } +} diff --git a/src/main/java/biomesoplenty/common/block/BlockGem.java b/src/main/java/biomesoplenty/common/block/BlockGem.java index 334ee564c..95444ec1a 100644 --- a/src/main/java/biomesoplenty/common/block/BlockGem.java +++ b/src/main/java/biomesoplenty/common/block/BlockGem.java @@ -9,6 +9,7 @@ package biomesoplenty.common.block; import biomesoplenty.api.block.BOPBlock; +import biomesoplenty.common.util.block.BlockStateUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; 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.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties()); + for (IBlockState state : presetStates) { this.setHarvestLevel("pickaxe", 2, state); diff --git a/src/main/java/biomesoplenty/common/block/BlockGemOre.java b/src/main/java/biomesoplenty/common/block/BlockGemOre.java index e0c64a97c..2415f86ac 100644 --- a/src/main/java/biomesoplenty/common/block/BlockGemOre.java +++ b/src/main/java/biomesoplenty/common/block/BlockGemOre.java @@ -11,6 +11,7 @@ package biomesoplenty.common.block; import static biomesoplenty.common.block.BlockGem.VARIANT_PROP; import biomesoplenty.api.block.BOPBlock; import biomesoplenty.common.block.BlockGem.GemType; +import biomesoplenty.common.util.block.BlockStateUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; 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.presetStates = BlockStateUtils.getValidStatesForProperties(this.getDefaultState(), this.getPresetProperties()); + for (IBlockState state : presetStates) { this.setHarvestLevel("pickaxe", 2, state); diff --git a/src/main/java/biomesoplenty/common/init/ModBlocks.java b/src/main/java/biomesoplenty/common/init/ModBlocks.java index bc9f5a58e..d70afcc8b 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlocks.java +++ b/src/main/java/biomesoplenty/common/init/ModBlocks.java @@ -29,6 +29,7 @@ import biomesoplenty.common.block.BlockBOPMushroom; import biomesoplenty.common.block.BlockBOPPlanks; import biomesoplenty.common.block.BlockBOPStone; import biomesoplenty.common.block.BlockBamboo; +import biomesoplenty.common.block.BlockBones; import biomesoplenty.common.block.BlockGem; import biomesoplenty.common.block.BlockGemOre; import biomesoplenty.common.block.BlockHive; @@ -42,6 +43,7 @@ public class ModBlocks { ash_block = registerBlock(new BlockAsh(), "ash_block"); bamboo = registerBlock(new BlockBamboo(), "bamboo"); + bone_segment = registerBlock(new BlockBones(), "bone_segment"); flower = registerBlock(new BlockBOPFlower(), "flower"); flower2 = registerBlock(new BlockBOPFlower2(), "flower2"); gem = registerBlock(new BlockGem(), "gem"); @@ -58,6 +60,8 @@ public class ModBlocks private static Block registerBlock(BOPBlock block, String name) { + if (block.presetStates == null) block.presetStates = BlockStateUtils.getValidStatesForProperties(block.getDefaultState(), block.getPresetProperties()); + block.setUnlocalizedName(name); if (block.hasPresetProperties()) diff --git a/src/main/resources/assets/biomesoplenty/blockstates/bone_segment.json b/src/main/resources/assets/biomesoplenty/blockstates/bone_segment.json new file mode 100755 index 000000000..419c00299 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/blockstates/bone_segment.json @@ -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 } + } +} diff --git a/src/main/resources/assets/biomesoplenty/lang/en_US.lang b/src/main/resources/assets/biomesoplenty/lang/en_US.lang index 0be5ee81c..9742008dd 100644 --- a/src/main/resources/assets/biomesoplenty/lang/en_US.lang +++ b/src/main/resources/assets/biomesoplenty/lang/en_US.lang @@ -4,6 +4,10 @@ tile.ash_block.name=Ash Block 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.smoldering_grass_block.name=Smoldering Grass Block diff --git a/src/main/resources/assets/biomesoplenty/models/block/large_bone_segment.json b/src/main/resources/assets/biomesoplenty/models/block/large_bone_segment.json new file mode 100755 index 000000000..313cff9c6 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/block/large_bone_segment.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "biomesoplenty:blocks/bone_segment" + } +} diff --git a/src/main/resources/assets/biomesoplenty/models/block/medium_bone_segment.json b/src/main/resources/assets/biomesoplenty/models/block/medium_bone_segment.json new file mode 100755 index 000000000..919ea44d9 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/block/medium_bone_segment.json @@ -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" } + } + } + ] +} diff --git a/src/main/resources/assets/biomesoplenty/models/block/small_bone_segment.json b/src/main/resources/assets/biomesoplenty/models/block/small_bone_segment.json new file mode 100755 index 000000000..9ab1520b6 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/block/small_bone_segment.json @@ -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" } + } + } + ] +} diff --git a/src/main/resources/assets/biomesoplenty/models/item/large_bone_segment.json b/src/main/resources/assets/biomesoplenty/models/item/large_bone_segment.json new file mode 100755 index 000000000..c7787262a --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/large_bone_segment.json @@ -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 ] + } + } +} diff --git a/src/main/resources/assets/biomesoplenty/models/item/medium_bone_segment.json b/src/main/resources/assets/biomesoplenty/models/item/medium_bone_segment.json new file mode 100755 index 000000000..d64326a08 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/medium_bone_segment.json @@ -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 ] + } + } +} diff --git a/src/main/resources/assets/biomesoplenty/models/item/small_bone_segment.json b/src/main/resources/assets/biomesoplenty/models/item/small_bone_segment.json new file mode 100755 index 000000000..1016ce346 --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/small_bone_segment.json @@ -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 ] + } + } +} diff --git a/src/main/resources/assets/biomesoplenty/textures/blocks/bone_segment.png b/src/main/resources/assets/biomesoplenty/textures/blocks/bone_segment.png new file mode 100644 index 0000000000000000000000000000000000000000..9c2c95cbbf242369035d2140cc6d3c420d3e1a4d GIT binary patch literal 523 zcmV+m0`&cfP)N2bPDNB8 zb~7$DE-^4L^m3s900D-C-g<)htZ+BmyQ;j2G^y#?RcCH_ zyL*I8UOFG|11HNhJ-CKleNQnvI7lEq0#+Dqh@NoXZf=#B#){ArQkeCXtVYeM^ z%R8W{0IQb18%|Yk)aa^tYVm=HZ`kQJ< zI|c!!WBW``ZTi}UMr`7`8pr7RLz}Zw0{OIc*Hjv4bN^}w5NW&z)%Iv1Cl64IGFA8g zTHJ<_!aw)L&oK{~x5N$_n~qh6D$qR9RxVD^R1;JWlH6K6I((#-sEw7>z+(L=K1jB) zoOc|n