Add kelp
This commit is contained in:
parent
8fb205d30d
commit
591bdebe5e
13 changed files with 175 additions and 60 deletions
|
@ -18,6 +18,7 @@ public class BOPBlocks
|
|||
public static Block bamboo;
|
||||
public static Block bone_segment;
|
||||
public static Block coral;
|
||||
public static Block seaweed;
|
||||
public static Block gem_block;
|
||||
public static Block gem_ore;
|
||||
public static Block hive;
|
||||
|
|
|
@ -116,8 +116,6 @@ public class BOPItems
|
|||
|
||||
// TODO: public static Item ancientStaff;
|
||||
// TODO: public static Item bop_bucket;
|
||||
// TODO: public static Item flower_band;
|
||||
// TODO: public static Item flippers;
|
||||
|
||||
|
||||
}
|
|
@ -70,7 +70,7 @@ public class BlockCoral extends BlockDecoration
|
|||
// set some defaults
|
||||
this.setHardness(0.6F);
|
||||
this.setStepSound(Block.soundTypeSand);
|
||||
this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F);
|
||||
this.setBlockBoundsByRadiusAndHeight(0.4F, 0.8F); // TODO: account for offset
|
||||
this.setDefaultState( this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(VARIANT, CoralType.PINK) );
|
||||
|
||||
}
|
||||
|
|
160
src/main/java/biomesoplenty/common/block/BlockSeaweed.java
Normal file
160
src/main/java/biomesoplenty/common/block/BlockSeaweed.java
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*******************************************************************************
|
||||
* 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 static net.minecraft.block.BlockLiquid.LEVEL;
|
||||
import biomesoplenty.api.block.BOPBlocks;
|
||||
import biomesoplenty.api.block.IBOPBlock;
|
||||
import biomesoplenty.common.item.ItemBOPBlock;
|
||||
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.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockSeaweed extends BlockDecoration implements IBOPBlock
|
||||
{
|
||||
|
||||
// TODO: is it supposed to grow?
|
||||
|
||||
public static enum SeaweedType implements IStringSerializable
|
||||
{
|
||||
KELP;
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.getName();
|
||||
}
|
||||
};
|
||||
|
||||
public static enum SeaweedPosition implements IStringSerializable
|
||||
{
|
||||
SINGLE, BOTTOM, MIDDLE, TOP;
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", SeaweedType.class);
|
||||
public static final PropertyEnum POSITION = PropertyEnum.create("position", SeaweedPosition.class);
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { LEVEL, POSITION, VARIANT });}
|
||||
|
||||
|
||||
// implement IBOPBlock
|
||||
@Override
|
||||
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
|
||||
@Override
|
||||
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
|
||||
@Override
|
||||
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
|
||||
@Override
|
||||
public IProperty[] getNonRenderingProperties() { return new IProperty[] {LEVEL}; }
|
||||
@Override
|
||||
public String getStateName(IBlockState state) {
|
||||
SeaweedType type = (SeaweedType)state.getValue(VARIANT);
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
|
||||
public BlockSeaweed()
|
||||
{
|
||||
super(Material.water);
|
||||
|
||||
// set some defaults
|
||||
this.setStepSound(Block.soundTypeSand);
|
||||
this.setDefaultState( this.blockState.getBaseState().withProperty(LEVEL, 15).withProperty(POSITION, SeaweedPosition.SINGLE).withProperty(VARIANT, SeaweedType.KELP) );
|
||||
}
|
||||
|
||||
// examine neighbors to figure out the SeaweedPosition value
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
boolean seaweedAbove = (worldIn.getBlockState(pos.up()).getBlock() == this);
|
||||
boolean seaweedBelow = (worldIn.getBlockState(pos.down()).getBlock() == this);
|
||||
SeaweedPosition position;
|
||||
if (seaweedAbove && seaweedBelow) {position = SeaweedPosition.MIDDLE;}
|
||||
else if (seaweedAbove) {position = SeaweedPosition.BOTTOM;}
|
||||
else if (seaweedBelow) {position = SeaweedPosition.TOP;}
|
||||
else {position = SeaweedPosition.SINGLE;}
|
||||
return state.withProperty(POSITION, position);
|
||||
}
|
||||
|
||||
// map from state to meta and vice verca - note the LEVEL and POSITION properties are ignored
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(VARIANT, SeaweedType.values()[meta]);
|
||||
}
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((SeaweedType) state.getValue(VARIANT)).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
this.setBlockBoundsByRadiusAndHeightWithXZOffset(0.4F, 0.8F, pos);
|
||||
}
|
||||
|
||||
|
||||
// require water or seaweed above and earth or seaweed below
|
||||
@Override
|
||||
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
|
||||
IBlockState stateAbove = world.getBlockState(pos.up());
|
||||
Block blockAbove = stateAbove.getBlock();
|
||||
IBlockState stateBelow = world.getBlockState(pos.down());
|
||||
Block blockBelow = stateBelow.getBlock();
|
||||
|
||||
boolean hasWaterAbove = (blockAbove == Blocks.water || blockAbove == Blocks.flowing_water);
|
||||
boolean sameSeaweedAbove = ( (blockAbove == this) && ((SeaweedType)state.getValue(VARIANT) == (SeaweedType)stateAbove.getValue(VARIANT)) );
|
||||
boolean hasEarthBelow = (blockBelow == Blocks.dirt || blockBelow == BOPBlocks.dirt || blockBelow == BOPBlocks.mud || blockBelow == Blocks.sand || blockBelow == Blocks.sponge || blockBelow == Blocks.stone || blockBelow == Blocks.clay || blockBelow == Blocks.gravel);
|
||||
boolean sameSeaweedBelow = ( (blockBelow == this) && ((SeaweedType)state.getValue(VARIANT) == (SeaweedType)stateBelow.getValue(VARIANT)) );
|
||||
|
||||
return (hasWaterAbove || sameSeaweedAbove) && (hasEarthBelow || sameSeaweedBelow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
return this.getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
world.setBlockState(pos, Blocks.water.getDefaultState() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -53,6 +53,7 @@ public class ModBlocks
|
|||
bamboo = registerBlock( new BlockBamboo(), "bamboo" );
|
||||
bone_segment = registerBlock( new BlockBones(), "bone_segment" );
|
||||
coral = registerBlock( new BlockCoral(), "coral" );
|
||||
seaweed = registerBlock( new BlockSeaweed(), "seaweed" );
|
||||
gem_block = registerBlock( new BlockGem(), "gem_block" );
|
||||
gem_ore = registerBlock( new BlockGemOre(), "gem_ore" );
|
||||
hive = registerBlock( new BlockHive(), "hive" );
|
||||
|
|
|
@ -192,7 +192,7 @@ public class ModCrafting
|
|||
GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.bamboo, 8), new Object [] {" #", "# ", '#', new ItemStack(BOPBlocks.bamboo_thatching)});
|
||||
GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.bamboo, 8), new Object [] {"# ", " #", '#', new ItemStack(BOPBlocks.bamboo_thatching)});
|
||||
GameRegistry.addShapedRecipe(new ItemStack(BOPItems.jar_empty, 3, 0), new Object[] {"# #", "# #", "###", '#', Blocks.glass});
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.ambrosia), new Object[] {new ItemStack(BOPItems.pixie_dust), new ItemStack(Items.potionitem, 1, 0), BlockBOPFlower.paging.getVariantItem(BOPFlowers.MINERS_DELIGHT), /* TODO: add kelp new ItemStack(BOPCBlocks.coral1, 1, 11), */ BlockBOPPlant.paging.getVariantItem(BOPPlants.ROOT), new ItemStack(BOPItems.crystal_shard), new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.HONEY.ordinal()), new ItemStack(BOPItems.berries), Items.sugar});
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(BOPItems.ambrosia), new Object[] {new ItemStack(BOPItems.pixie_dust), new ItemStack(Items.potionitem, 1, 0), BlockBOPFlower.paging.getVariantItem(BOPFlowers.MINERS_DELIGHT), new ItemStack(BOPBlocks.seaweed, 1, BlockSeaweed.SeaweedType.KELP.ordinal()), BlockBOPPlant.paging.getVariantItem(BOPPlants.ROOT), new ItemStack(BOPItems.crystal_shard), new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.HONEY.ordinal()), new ItemStack(BOPItems.berries), Items.sugar});
|
||||
GameRegistry.addShapedRecipe(new ItemStack(BOPBlocks.flesh), new Object[] {"##", "##", '#', new ItemStack(BOPItems.fleshchunk)});
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.rotten_flesh), new Object[] {"FFF", "FPF", "FFF", 'F', new ItemStack(BOPItems.fleshchunk), 'P', new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.POISON.ordinal())});
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"variants": {
|
||||
"position=single,variant=kelp": { "model": "biomesoplenty:kelp_single" },
|
||||
"position=bottom,variant=kelp": { "model": "biomesoplenty:kelp_bottom" },
|
||||
"position=middle,variant=kelp": { "model": "biomesoplenty:kelp_middle" },
|
||||
"position=top,variant=kelp": { "model": "biomesoplenty:kelp_top" }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "block/cross",
|
||||
"textures": {
|
||||
"cross": "biomesoplenty:blocks/kelp"
|
||||
"cross": "biomesoplenty:blocks/kelp_single"
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "biomesoplenty:blocks/kelp"
|
||||
"layer0": "biomesoplenty:blocks/kelp_middle"
|
||||
},
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "biomesoplenty:blocks/kelp_bottom"
|
||||
},
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "biomesoplenty:blocks/kelp_middle"
|
||||
},
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "biomesoplenty:blocks/kelp_top"
|
||||
},
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B |
Loading…
Reference in a new issue