Add berries

This commit is contained in:
Cheeserolls 2015-04-06 21:23:40 +01:00
parent 66c6cc3a10
commit ec4bac4004
5 changed files with 47 additions and 5 deletions

View File

@ -24,6 +24,7 @@ public class BOPItems
public static Item filled_honeycomb;
public static Item gem;
public static Item ash;
public static Item berries;
public static Item sacred_oak_door;
public static Item cherry_door;

View File

@ -132,8 +132,7 @@ public class BlockFoliage extends BlockDecoration implements IShearable
case BERRYBUSH:
// BERRYBUSH always drops berries
// TODO: change from peach to berries once item is implemented
ret.add(new ItemStack(BOPItems.peach));
ret.add(new ItemStack(BOPItems.berries));
default:
break;
@ -267,6 +266,26 @@ public class BlockFoliage extends BlockDecoration implements IShearable
}
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
super.updateTick(worldIn, pos, state, rand);
switch ((FoliageType) state.getValue(VARIANT))
{
case BUSH:
// every now and then berries grow on a bush
if (rand.nextInt(80) > 0 && worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
worldIn.setBlockState(pos, state.withProperty(VARIANT, FoliageType.BERRYBUSH));
}
break;
default:
break;
}
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
@ -291,8 +310,8 @@ public class BlockFoliage extends BlockDecoration implements IShearable
{
case BERRYBUSH:
// an activated berry bush turns into a regular bush and drops a berry
worldIn.setBlockState(pos, this.getDefaultState().withProperty(VARIANT, FoliageType.BUSH));
EntityItem berries = new EntityItem(worldIn, (double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), new ItemStack(BOPItems.peach)); // TODO implement berry instead of peach
worldIn.setBlockState(pos, state.withProperty(VARIANT, FoliageType.BUSH));
EntityItem berries = new EntityItem(worldIn, (double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), new ItemStack(BOPItems.berries));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(berries);
@ -327,12 +346,15 @@ public class BlockFoliage extends BlockDecoration implements IShearable
switch ((FoliageType) state.getValue(VARIANT))
{
case BERRYBUSH:
// BERRYBUSH gives a regular bush when sheared
// BERRYBUSH gives a regular bush and a berry when sheared
ret.add(new ItemStack(this, 1, this.getMetaFromState(this.getDefaultState().withProperty(VARIANT, FoliageType.BUSH))));
ret.add(new ItemStack(BOPItems.berries, 1));
break;
default:
// default is to get the block unaltered
ret.add(new ItemStack(this, 1, this.getMetaFromState(state)));
break;
}
return ret;
}

View File

@ -49,6 +49,7 @@ public class ModItems
filled_honeycomb = registerItem(new ItemFood(3, 0.4F, false), "filled_honeycomb");
gem = registerItem(new ItemGem(), "gem");
ash = registerItem(new Item(), "ash");
berries = registerItem(new ItemFood(1, 0.1F, false), "berries");
// armor
// TODO: do we really want durability of -1? does that mean it lasts forever?

View File

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "biomesoplenty:items/berries"
},
"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 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B