Add fruit_block and variants apple/persimmon/peach/pear
|
@ -35,4 +35,5 @@ public class BOPBlocks
|
|||
public static Block waterlily;
|
||||
public static Block dirt;
|
||||
public static Block stone_formations;
|
||||
public static Block fruit_block;
|
||||
}
|
||||
|
|
|
@ -16,4 +16,7 @@ public class BOPItems
|
|||
public static Item mudball;
|
||||
public static Item turnip;
|
||||
public static Item turnip_seeds;
|
||||
public static Item persimmon;
|
||||
public static Item peach;
|
||||
public static Item pear;
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*******************************************************************************
|
||||
* 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 java.util.Random;
|
||||
|
||||
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.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import biomesoplenty.api.block.BOPPlant;
|
||||
import biomesoplenty.api.item.BOPItems;
|
||||
|
||||
public class BlockFruit extends BOPPlant
|
||||
{
|
||||
public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", FruitType.class);
|
||||
|
||||
public BlockFruit()
|
||||
{
|
||||
super(Material.plants);
|
||||
this.setStepSound(soundTypeGrass);
|
||||
this.setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 1.0F, 0.75F);
|
||||
//this.setCreativeTab(null);
|
||||
}
|
||||
|
||||
@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, FruitType.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
// only one property to worry about, the variant, so just map [0 => STALAGMITE, 1 => STALACTITE]
|
||||
return ((FruitType) 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 ((FruitType) state.getValue(VARIANT_PROP)).getName() + "_block";
|
||||
}
|
||||
|
||||
// only allow fruit to hang from leaves
|
||||
@Override
|
||||
public boolean canBlockStay(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
Block blockAbove = world.getBlockState(pos.up()).getBlock();
|
||||
return blockAbove == Blocks.leaves || blockAbove == Blocks.leaves2; /* TODO: add BOP leave types - maybe check the material instead? */
|
||||
}
|
||||
|
||||
// In creative mode, pick block to get the fruit item
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Item item = ((FruitType) state.getValue(VARIANT_PROP)).getItem();
|
||||
int meta = damageDropped(state);
|
||||
return new ItemStack(item, 1, meta);
|
||||
}
|
||||
|
||||
// fruit blocks drop the corresponding fruit item when broken
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return ((FruitType) state.getValue(VARIANT_PROP)).getItem();
|
||||
}
|
||||
|
||||
// prevent fruit block meta value affecting fruit item dropped
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// enum representing the fruit variants
|
||||
// TODO: take outside the class so it can be reused in leaves?
|
||||
public static enum FruitType implements IStringSerializable
|
||||
{
|
||||
|
||||
APPLE, PERSIMMON, PEACH, PEAR;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
|
||||
// get the item dropped when this type of fruit block is broken/picked
|
||||
public Item getItem() {
|
||||
switch (this)
|
||||
{
|
||||
case PERSIMMON:
|
||||
return BOPItems.persimmon;
|
||||
case PEACH:
|
||||
return BOPItems.peach;
|
||||
case PEAR:
|
||||
return BOPItems.pear;
|
||||
case APPLE: default:
|
||||
return Items.apple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -30,6 +30,7 @@ import biomesoplenty.common.block.BlockBOPStone;
|
|||
import biomesoplenty.common.block.BlockBamboo;
|
||||
import biomesoplenty.common.block.BlockBones;
|
||||
import biomesoplenty.common.block.BlockCoral;
|
||||
import biomesoplenty.common.block.BlockFruit;
|
||||
import biomesoplenty.common.block.BlockGem;
|
||||
import biomesoplenty.common.block.BlockGemOre;
|
||||
import biomesoplenty.common.block.BlockHive;
|
||||
|
@ -68,6 +69,7 @@ public class ModBlocks
|
|||
waterlily = registerBlock(new BlockBOPLilypad(), "waterlily");
|
||||
dirt = registerBlock(new BlockBOPDirt(), "dirt");
|
||||
stone_formations = registerBlock(new BlockStoneFormations(),"stone_formations");
|
||||
fruit_block = registerBlock(new BlockFruit(), "fruit_block");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ public class ModItems
|
|||
mudball = registerItem(new ItemMudball(),"mudball");
|
||||
turnip_seeds = registerItem(new ItemSeeds(BOPBlocks.turnip_block, Blocks.farmland),"turnip_seeds");
|
||||
turnip = registerItem(new ItemFood(3, 0.4F, false),"turnip");
|
||||
persimmon = registerItem(new ItemFood(5, 0.2F, false),"persimmon");
|
||||
peach = registerItem(new ItemFood(5, 0.5F, false),"peach");
|
||||
pear = registerItem(new ItemFood(5, 0.3F, false),"pear");
|
||||
}
|
||||
|
||||
private static Item registerItem(Item item, String name)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"variants": {
|
||||
"variant=apple": { "model": "biomesoplenty:apple_block" },
|
||||
"variant=persimmon": { "model": "biomesoplenty:persimmon_block" },
|
||||
"variant=peach": { "model": "biomesoplenty:peach_block" },
|
||||
"variant=pear": { "model": "biomesoplenty:pear_block" }
|
||||
}
|
||||
}
|
|
@ -143,7 +143,15 @@ tile.dirt.coarse_silty_dirt.name=Coarse Silty Dirt
|
|||
tile.stone_formations.stalagmite.name=Stalagmite
|
||||
tile.stone_formations.stalactite.name=Stalactite
|
||||
|
||||
tile.fruit_block.apple_block.name=Apple Block
|
||||
tile.fruit_block.persimmon_block.name=Persimmon Block
|
||||
tile.fruit_block.peach_block.name=Peach Block
|
||||
tile.fruit_block.pear_block.name=Pear Block
|
||||
|
||||
item.fleshchunk.name=Chunk of Flesh
|
||||
item.mudball.name=Mud Ball
|
||||
item.turnip.name=Turnip
|
||||
item.turnip_seeds.name=Turnip Seeds
|
||||
item.turnip_seeds.name=Turnip Seeds
|
||||
item.persimmon.name=Persimmon
|
||||
item.peach.name=Peach
|
||||
item.pear.name=Pear
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cross",
|
||||
"textures": {
|
||||
"cross": "biomesoplenty:blocks/apple_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cross",
|
||||
"textures": {
|
||||
"cross": "biomesoplenty:blocks/peach_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cross",
|
||||
"textures": {
|
||||
"cross": "biomesoplenty:blocks/pear_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "block/cross",
|
||||
"textures": {
|
||||
"cross": "biomesoplenty:blocks/persimmon_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "biomesoplenty:items/peach"
|
||||
},
|
||||
"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:items/pear"
|
||||
},
|
||||
"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:items/persimmon"
|
||||
},
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 329 B |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 317 B |
After Width: | Height: | Size: 312 B |
After Width: | Height: | Size: 355 B |
After Width: | Height: | Size: 364 B |
After Width: | Height: | Size: 351 B |