diff --git a/src/main/java/biomesoplenty/api/item/BOPItems.java b/src/main/java/biomesoplenty/api/item/BOPItems.java index 53b57592a..b8f3a6e2b 100644 --- a/src/main/java/biomesoplenty/api/item/BOPItems.java +++ b/src/main/java/biomesoplenty/api/item/BOPItems.java @@ -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; diff --git a/src/main/java/biomesoplenty/common/block/BlockFoliage.java b/src/main/java/biomesoplenty/common/block/BlockFoliage.java index ac70ccf3b..d3b07a80b 100644 --- a/src/main/java/biomesoplenty/common/block/BlockFoliage.java +++ b/src/main/java/biomesoplenty/common/block/BlockFoliage.java @@ -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; } diff --git a/src/main/java/biomesoplenty/common/init/ModItems.java b/src/main/java/biomesoplenty/common/init/ModItems.java index 96a556c8a..576967c3a 100644 --- a/src/main/java/biomesoplenty/common/init/ModItems.java +++ b/src/main/java/biomesoplenty/common/init/ModItems.java @@ -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? diff --git a/src/main/resources/assets/biomesoplenty/models/item/berries.json b/src/main/resources/assets/biomesoplenty/models/item/berries.json new file mode 100644 index 000000000..cfb02d38b --- /dev/null +++ b/src/main/resources/assets/biomesoplenty/models/item/berries.json @@ -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 ] + } + } +} diff --git a/src/main/resources/assets/biomesoplenty/textures/items/berries.png b/src/main/resources/assets/biomesoplenty/textures/items/berries.png new file mode 100644 index 000000000..9e6f7bca3 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/berries.png differ