From ec4bac4004bb67ee764a1401852863077d8dc8aa Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Mon, 6 Apr 2015 21:23:40 +0100 Subject: [PATCH] Add berries --- .../java/biomesoplenty/api/item/BOPItems.java | 1 + .../common/block/BlockFoliage.java | 32 +++++++++++++++--- .../biomesoplenty/common/init/ModItems.java | 1 + .../biomesoplenty/models/item/berries.json | 18 ++++++++++ .../biomesoplenty/textures/items/berries.png | Bin 0 -> 383 bytes 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/assets/biomesoplenty/models/item/berries.json create mode 100644 src/main/resources/assets/biomesoplenty/textures/items/berries.png 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 0000000000000000000000000000000000000000..9e6f7bca3aa1a350acaebbdd8417b4f663629864 GIT binary patch literal 383 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjGL736~_k^`TL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3Q$0figD*u3fvSFc zx;Tbd_%H1{$i)~a(x%TXy-?>$hsl(j6wO4%$Q7DmW=U^Fr}T;^3GIvx{FBy+5O?*1i7npXW9IW!WC+Z%LE@p@luUw`+E-JI&RelOWIW=gN1}{D!aV za;NyKy^fppCwhU*>khufFXl*ltPg&1-^#;p@`C+>)lVayMQAxrn4uDIM{L4vi4*6H z?{j-Jr9QlwRXDA!@rT8^r#Cd%ju+nB-sQm|xmwg<_QSxnkK$H-5K1$ABHmX1ZD)8& z6W5DS#nY@?`gxRUxI|_Oux{F8e73xCzJo&mXXpJCCut!S&Og?Yxe{z3^uszqUsv?t V?pf`wIly3G@O1TaS?83{1OP*tl=uJu literal 0 HcmV?d00001