Add BOP wood slabs

This commit is contained in:
Cheeserolls 2015-04-05 12:48:25 +01:00
parent 2530ec7159
commit 582606826e
31 changed files with 340 additions and 1 deletions

View file

@ -39,6 +39,10 @@ public class BOPBlocks
public static Block sapling_2;
// TODO fruit tree leaves and saplings
public static Block planks_0;
public static Block half_wood_slab_0;
public static Block half_wood_slab_1;
public static Block double_wood_slab_0;
public static Block double_wood_slab_1;
public static Block sacred_oak_stairs;
public static Block cherry_stairs;
public static Block dark_stairs;

View file

@ -40,4 +40,6 @@ public class BOPItems
public static Item jacaranda_door;
public static Item mahogany_door;
public static Item wood_slab_0;
public static Item wood_slab_1;
}

View file

@ -0,0 +1,41 @@
package biomesoplenty.common.block;
import biomesoplenty.api.block.BOPWoodEnums.EightWoods;
import biomesoplenty.api.block.IBOPBlock;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
public class BlockBOPDoubleWoodSlab extends BlockBOPHalfWoodSlab implements IBOPBlock
{
// HALF isn't used in double slab because both halves are present
@Override
public IProperty[] getRenderProperties() { return new IProperty[] {VARIANT}; }
@Override
public String getStateName(IBlockState state)
{
return "double_" + ((EightWoods) state.getValue(VARIANT)).map(this.pageNum).toString() + "_wood_slab";
}
public BlockBOPDoubleWoodSlab(int pageNum)
{
super(pageNum);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, EightWoods.values()[meta & 7]);
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((EightWoods) state.getValue(VARIANT)).ordinal();
}
@Override
public boolean isDouble() {
return true;
}
}

View file

@ -0,0 +1,113 @@
package biomesoplenty.common.block;
import java.util.List;
import com.google.common.collect.ImmutableSet;
import biomesoplenty.api.block.BOPWoodEnums.EightWoods;
import biomesoplenty.api.block.IBOPBlock;
import biomesoplenty.common.util.block.BlockStateUtils;
import net.minecraft.block.BlockSlab;
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.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 class BlockBOPHalfWoodSlab extends BlockSlab implements IBOPBlock
{
// add properties (note we inherit HALF property from parent BlockSlab)
// HALF requires 1 meta bit, so we have 3 left for the VARIANT, which means we can have eight woods per instance
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", EightWoods.class );
protected int pageNum;
@Override
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] {HALF, VARIANT});}
// implement IBOPBlock
@Override
public Class<? extends ItemBlock> getItemClass() { return null; }
@Override
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
@Override
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
@Override
public IProperty[] getRenderProperties() { return new IProperty[] {HALF, VARIANT}; }
@Override
public String getStateName(IBlockState state)
{
return ((EightWoods) state.getValue(VARIANT)).map(this.pageNum).toString() + "_wood_slab";
}
public BlockBOPHalfWoodSlab(int pageNum)
{
super(Material.wood);
this.pageNum = pageNum;
this.useNeighborBrightness = true;
this.setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood);
this.setHarvestLevel("axe", 0);
this.setDefaultState(this.blockState.getBaseState().withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM).withProperty(VARIANT, EightWoods.A));
}
@Override
public String getUnlocalizedName(int meta)
{
return this.getStateName(this.getStateFromMeta(meta));
}
@Override
public IProperty getVariantProperty()
{
return VARIANT;
}
@Override
public Object getVariant(ItemStack stack)
{
return EightWoods.values()[stack.getMetadata() & 7];
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, EightWoods.values()[meta & 7]).withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
}
@Override
public int getMetaFromState(IBlockState state)
{
return (state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP ? 8 : 0) + ((EightWoods) state.getValue(VARIANT)).ordinal();
}
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(this.getDefaultState().withProperty(VARIANT, (EightWoods) state.getValue(VARIANT)));
}
@Override
public boolean isDouble() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list)
{
// get the preset blocks variants
ImmutableSet<IBlockState> presets = BlockStateUtils.getBlockPresets(this);
// register all the sub-blocks
for (IBlockState state : presets)
{
list.add(new ItemStack(itemIn, 1, this.getMetaFromState(state)));
}
}
}

View file

@ -10,6 +10,7 @@ package biomesoplenty.common.init;
import static biomesoplenty.api.block.BOPBlocks.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.model.ModelBakery;
@ -18,8 +19,10 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemSlab;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import biomesoplenty.api.block.BOPWoodEnums.AllWoods;
@ -28,12 +31,14 @@ import biomesoplenty.api.item.BOPItems;
import biomesoplenty.common.block.BlockAsh;
import biomesoplenty.common.block.BlockBOPDirt;
import biomesoplenty.common.block.BlockBOPDoor;
import biomesoplenty.common.block.BlockBOPDoubleWoodSlab;
import biomesoplenty.common.block.BlockBOPFence;
import biomesoplenty.common.block.BlockBOPFenceGate;
import biomesoplenty.common.block.BlockBOPFlower1;
import biomesoplenty.common.block.BlockBOPFlower2;
import biomesoplenty.common.block.BlockBOPGeneric;
import biomesoplenty.common.block.BlockBOPGrass;
import biomesoplenty.common.block.BlockBOPHalfWoodSlab;
import biomesoplenty.common.block.BlockBOPLeaves;
import biomesoplenty.common.block.BlockBOPLilypad;
import biomesoplenty.common.block.BlockBOPLog;
@ -110,6 +115,7 @@ public class ModBlocks
log_1 = registerBlock( new BlockBOPLog(1), "log_1" );
log_2 = registerBlock( new BlockBOPLog(2), "log_2" );
log_3 = registerBlock( new BlockBOPLog(3), "log_3" );
// 22 tree types, 4 per BlockBOPLeaves instance, needs 6 'pages'
leaves_0 = registerBlock( new BlockBOPLeaves(0), "leaves_0");
leaves_1 = registerBlock( new BlockBOPLeaves(1), "leaves_1" );
@ -117,14 +123,21 @@ public class ModBlocks
leaves_3 = registerBlock( new BlockBOPLeaves(3), "leaves_3" );
leaves_4 = registerBlock( new BlockBOPLeaves(4), "leaves_4" );
leaves_5 = registerBlock( new BlockBOPLeaves(5), "leaves_5" );
// 22 tree types, 8 per BlockBOPSapling instance, needs 3 'pages'
sapling_0 = registerBlock( new BlockBOPSapling(0), "sapling_0");
sapling_1 = registerBlock( new BlockBOPSapling(1), "sapling_1");
sapling_2 = registerBlock( new BlockBOPSapling(2), "sapling_2");
// TODO: check if hellbark planks, fence etc can burn
// TODO: wooden slabs
// 16 wood types, 8 per BlockBOPHalfWoodSlab and BlockBOPDoubleWoodSlab intance, needs 2 'pages'
registerWoodSlab( half_wood_slab_0, double_wood_slab_0, BOPItems.wood_slab_0, 0);
registerWoodSlab( half_wood_slab_1, double_wood_slab_1, BOPItems.wood_slab_1, 1);
// 16 wood types, 16 per BlockBOPPlanks instance, needs 1 'pages'
planks_0 = registerBlock( new BlockBOPPlanks(0), "planks_0");
// stairs have no variant metadata, use a new BlockBOPStairs instance for each (note there's no giant_flower_stairs or dead_stairs)
sacred_oak_stairs = registerBlock( new BlockBOPStairs(((BlockBOPPlanks)planks_0).getStateByWood(AllWoods.SACRED_OAK)), "sacred_oak_stairs" );
cherry_stairs = registerBlock( new BlockBOPStairs(((BlockBOPPlanks)planks_0).getStateByWood(AllWoods.CHERRY)), "cherry_stairs" );
@ -140,6 +153,7 @@ public class ModBlocks
hell_bark_stairs = registerBlock( new BlockBOPStairs(((BlockBOPPlanks)planks_0).getStateByWood(AllWoods.HELL_BARK)), "hell_bark_stairs" );
jacaranda_stairs = registerBlock( new BlockBOPStairs(((BlockBOPPlanks)planks_0).getStateByWood(AllWoods.JACARANDA)), "jacaranda_stairs" );
mahogany_stairs = registerBlock( new BlockBOPStairs(((BlockBOPPlanks)planks_0).getStateByWood(AllWoods.MAHOGANY)), "mahogany_stairs" );
// fences have no variant metadata, use a new BlockBOPFence instance for each (note there's no giant_flower_fence or dead_fence)
sacred_oak_fence = registerBlock( new BlockBOPFence(), "sacred_oak_fence" );
cherry_fence = registerBlock( new BlockBOPFence(), "cherry_fence" );
@ -155,6 +169,7 @@ public class ModBlocks
hell_bark_fence = registerBlock( new BlockBOPFence(), "hell_bark_fence" );
jacaranda_fence = registerBlock( new BlockBOPFence(), "jacaranda_fence" );
mahogany_fence = registerBlock( new BlockBOPFence(), "mahogany_fence" );
// fence gates have no variant metadata, use a new BlockBOPFenceGate instance for each (note there's no giant_flower_fence_gate or dead_fence_gate)
sacred_oak_fence_gate = registerBlock( new BlockBOPFenceGate(), "sacred_oak_fence_gate" );
cherry_fence_gate = registerBlock( new BlockBOPFenceGate(), "cherry_fence_gate" );
@ -170,6 +185,7 @@ public class ModBlocks
hell_bark_fence_gate = registerBlock( new BlockBOPFenceGate(), "hell_bark_fence_gate" );
jacaranda_fence_gate = registerBlock( new BlockBOPFenceGate(), "jacaranda_fence_gate" );
mahogany_fence_gate = registerBlock( new BlockBOPFenceGate(), "mahogany_fence_gate" );
// doors have no variant metadata, use a new BlockBOPDoor instance for each (note there's no giant_flower_door or dead_door)
sacred_oak_door = registerDoor( new BlockBOPDoor(), "sacred_oak_door", BOPItems.sacred_oak_door );
cherry_door = registerDoor( new BlockBOPDoor(), "cherry_door", BOPItems.cherry_door );
@ -198,10 +214,22 @@ public class ModBlocks
foliage = registerBlock( new BlockFoliage(), "foliage" );
double_foliage = registerBlock( new BlockDoubleFoliage(), "double_foliage" );
}
// use a separate function for registering slabs because the half slab, double slab, and item really need to be registered together
public static void registerWoodSlab(Block half_slab, Block double_slab, Item slab_item, int pageNum)
{
half_slab = registerBlock( new BlockBOPHalfWoodSlab(pageNum), "half_wood_slab_" + pageNum );
double_slab = registerBlock( new BlockBOPDoubleWoodSlab(pageNum), "double_wood_slab_" + pageNum, null ); // no creative tab for double slab
slab_item = ModItems.registerItem( new ItemSlab(half_slab, (BlockSlab)half_slab, (BlockSlab)double_slab), "wood_slab_" + pageNum );
GameData.getBlockItemMap().put(half_slab, slab_item);
GameData.getBlockItemMap().put(double_slab, slab_item);
}
// use a separate function for registering doors because the door block and item need to be registered together
public static Block registerDoor(Block door_block, String name, Item door_item)
{
door_block = registerBlock( new BlockBOPDoor(), name + "_block", null );
@ -210,6 +238,7 @@ public class ModBlocks
return door_block;
}
public static void registerBlockVariant(Block block, String stateName, int stateMeta)
{
Item item = Item.getItemFromBlock(block);

View file

@ -0,0 +1,20 @@
{
"variants": {
"half=bottom,variant=a": { "model": "biomesoplenty:sacred_oak_planks" },
"half=top,variant=a": { "model": "biomesoplenty:sacred_oak_planks" },
"half=bottom,variant=b": { "model": "biomesoplenty:cherry_planks" },
"half=top,variant=b": { "model": "biomesoplenty:cherry_planks" },
"half=bottom,variant=c": { "model": "biomesoplenty:dark_planks" },
"half=top,variant=c": { "model": "biomesoplenty:dark_planks" },
"half=bottom,variant=d": { "model": "biomesoplenty:fir_planks" },
"half=top,variant=d": { "model": "biomesoplenty:fir_planks" },
"half=bottom,variant=e": { "model": "biomesoplenty:ethereal_planks" },
"half=top,variant=e": { "model": "biomesoplenty:ethereal_planks" },
"half=bottom,variant=f": { "model": "biomesoplenty:magic_planks" },
"half=top,variant=f": { "model": "biomesoplenty:magic_planks" },
"half=bottom,variant=g": { "model": "biomesoplenty:mangrove_planks" },
"half=top,variant=g": { "model": "biomesoplenty:mangrove_planks" },
"half=bottom,variant=h": { "model": "biomesoplenty:palm_planks" },
"half=top,variant=h": { "model": "biomesoplenty:palm_planks" }
}
}

View file

@ -0,0 +1,20 @@
{
"variants": {
"half=bottom,variant=a": { "model": "biomesoplenty:redwood_planks" },
"half=top,variant=a": { "model": "biomesoplenty:redwood_planks" },
"half=bottom,variant=b": { "model": "biomesoplenty:willow_planks" },
"half=top,variant=b": { "model": "biomesoplenty:willow_planks" },
"half=bottom,variant=c": { "model": "biomesoplenty:pine_planks" },
"half=top,variant=c": { "model": "biomesoplenty:pine_planks" },
"half=bottom,variant=d": { "model": "biomesoplenty:hell_bark_planks" },
"half=top,variant=d": { "model": "biomesoplenty:hell_bark_planks" },
"half=bottom,variant=e": { "model": "biomesoplenty:jacaranda_planks" },
"half=top,variant=e": { "model": "biomesoplenty:jacaranda_planks" },
"half=bottom,variant=f": { "model": "biomesoplenty:mahogany_planks" },
"half=top,variant=f": { "model": "biomesoplenty:mahogany_planks" },
"half=bottom,variant=g": { "model": "biomesoplenty:giant_flower_planks" },
"half=top,variant=g": { "model": "biomesoplenty:giant_flower_planks" },
"half=bottom,variant=h": { "model": "biomesoplenty:dead_planks" },
"half=top,variant=h": { "model": "biomesoplenty:dead_planks" }
}
}

View file

@ -0,0 +1,20 @@
{
"variants": {
"half=bottom,variant=a": { "model": "biomesoplenty:half_slab_sacred_oak" },
"half=top,variant=a": { "model": "biomesoplenty:upper_slab_sacred_oak" },
"half=bottom,variant=b": { "model": "biomesoplenty:half_slab_cherry" },
"half=top,variant=b": { "model": "biomesoplenty:upper_slab_cherry" },
"half=bottom,variant=c": { "model": "biomesoplenty:half_slab_dark" },
"half=top,variant=c": { "model": "biomesoplenty:upper_slab_dark" },
"half=bottom,variant=d": { "model": "biomesoplenty:half_slab_fir" },
"half=top,variant=d": { "model": "biomesoplenty:upper_slab_fir" },
"half=bottom,variant=e": { "model": "biomesoplenty:half_slab_ethereal" },
"half=top,variant=e": { "model": "biomesoplenty:upper_slab_ethereal" },
"half=bottom,variant=f": { "model": "biomesoplenty:half_slab_magic" },
"half=top,variant=f": { "model": "biomesoplenty:upper_slab_magic" },
"half=bottom,variant=g": { "model": "biomesoplenty:half_slab_mangrove" },
"half=top,variant=g": { "model": "biomesoplenty:upper_slab_mangrove" },
"half=bottom,variant=h": { "model": "biomesoplenty:half_slab_palm" },
"half=top,variant=h": { "model": "biomesoplenty:upper_slab_palm" }
}
}

View file

@ -0,0 +1,20 @@
{
"variants": {
"half=bottom,variant=a": { "model": "biomesoplenty:half_slab_redwood" },
"half=top,variant=a": { "model": "biomesoplenty:upper_slab_redwood" },
"half=bottom,variant=b": { "model": "biomesoplenty:half_slab_willow" },
"half=top,variant=b": { "model": "biomesoplenty:upper_slab_willow" },
"half=bottom,variant=c": { "model": "biomesoplenty:half_slab_pine" },
"half=top,variant=c": { "model": "biomesoplenty:upper_slab_pine" },
"half=bottom,variant=d": { "model": "biomesoplenty:half_slab_hell_bark" },
"half=top,variant=d": { "model": "biomesoplenty:upper_slab_hell_bark" },
"half=bottom,variant=e": { "model": "biomesoplenty:half_slab_jacaranda" },
"half=top,variant=e": { "model": "biomesoplenty:upper_slab_jacaranda" },
"half=bottom,variant=f": { "model": "biomesoplenty:half_slab_mahogany" },
"half=top,variant=f": { "model": "biomesoplenty:upper_slab_mahogany" },
"half=bottom,variant=g": { "model": "biomesoplenty:half_slab_giant_flower" },
"half=top,variant=g": { "model": "biomesoplenty:upper_slab_giant_flower" },
"half=bottom,variant=h": { "model": "biomesoplenty:half_slab_dead" },
"half=top,variant=h": { "model": "biomesoplenty:upper_slab_dead" }
}
}

View file

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

View file

@ -0,0 +1,8 @@
{
"parent": "block/half_slab",
"textures": {
"bottom": "biomesoplenty:blocks/dead_planks",
"top": "biomesoplenty:blocks/dead_planks",
"side": "biomesoplenty:blocks/dead_planks"
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "block/half_slab",
"textures": {
"bottom": "biomesoplenty:blocks/giant_flower_planks",
"top": "biomesoplenty:blocks/giant_flower_planks",
"side": "biomesoplenty:blocks/giant_flower_planks"
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "block/upper_slab",
"textures": {
"bottom": "biomesoplenty:blocks/dead_planks",
"top": "biomesoplenty:blocks/dead_planks",
"side": "biomesoplenty:blocks/dead_planks"
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "block/upper_slab",
"textures": {
"bottom": "biomesoplenty:blocks/giant_flower_planks",
"top": "biomesoplenty:blocks/giant_flower_planks",
"side": "biomesoplenty:blocks/giant_flower_planks"
}
}

View file

@ -0,0 +1,11 @@
{
"parent": "biomesoplenty:block/half_slab_dead",
"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/giant_flower_planks",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

View file

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