diff --git a/src/main/java/vazkii/botania/common/block/BlockCocoon.java b/src/main/java/vazkii/botania/common/block/BlockCocoon.java index 84877e90e..457499e47 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCocoon.java +++ b/src/main/java/vazkii/botania/common/block/BlockCocoon.java @@ -14,6 +14,8 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -69,22 +71,40 @@ public class BlockCocoon extends BlockMod implements ILexiconable { public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } + + @Override + public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity e) { + if(!world.isRemote && e instanceof EntityItem) { + EntityItem item = (EntityItem) e; + ItemStack stack = item.getItem(); + addStack(world, pos, stack, false); + + if(stack.isEmpty()) + item.setDead(); + } + } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing s, float xs, float ys, float zs) { - TileCocoon cocoon = (TileCocoon) world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); Item item = stack.getItem(); + return addStack(world, pos, stack, player.capabilities.isCreativeMode); + } + + private boolean addStack(World world, BlockPos pos, ItemStack stack, boolean creative) { + TileCocoon cocoon = (TileCocoon) world.getTileEntity(pos); + Item item = stack.getItem(); + if(cocoon != null && (item == Items.EMERALD || item == Items.CHORUS_FRUIT)) { if(!world.isRemote) { if(item == Items.EMERALD && cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS) { - if(!player.capabilities.isCreativeMode) + if(!creative) stack.shrink(1); cocoon.emeraldsGiven++; - world.playEvent(2005, pos, 6 + world.rand.nextInt(4)); + ((WorldServer) world).spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.5); } else if(item == Items.CHORUS_FRUIT && cocoon.chorusFruitGiven < TileCocoon.MAX_CHORUS_FRUITS) { - if(!player.capabilities.isCreativeMode) + if(!creative) stack.shrink(1); cocoon.chorusFruitGiven++; ((WorldServer) world).spawnParticle(EnumParticleTypes.PORTAL, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 32, 0, 0, 0, 0.5); @@ -93,7 +113,7 @@ public class BlockCocoon extends BlockMod implements ILexiconable { return true; } - + return false; } diff --git a/src/main/resources/assets/botania/lang/en_us.lang b/src/main/resources/assets/botania/lang/en_us.lang index 9ce900787..dc6206e4a 100644 --- a/src/main/resources/assets/botania/lang/en_us.lang +++ b/src/main/resources/assets/botania/lang/en_us.lang @@ -2768,7 +2768,7 @@ botania.page.canopyDrum1=The Pinking Drum botania.entry.cocoon=Cocoon of Caprice botania.tagline.cocoon=Hatch your own animals botania.page.cocoon0=A cocoon is usually a symbol of change, of evolution.
Creating a &1Cocoon of Caprice&0 and placing it down will slowly evolve the rudimentary contents inside it into a &1Baby Animal&0. More often than not the animal hatched will be a farm animal, but on rare ocasions, different animals such as &1Wolves&0 or &1Horses&0 may be created. -botania.page.cocoon1=Speculation says that giving the cocoon &1Emeralds&0 or &1Chorus Fruit&0 influences the outcome towards something a bit different.
What could come out of such experiment is anyone's guess, really. +botania.page.cocoon1=Speculation says that giving the cocoon &1Emeralds&0 or &1Chorus Fruit&0 influences the outcome towards something a bit different.
Giving the items can be done via a right click or simply dropping them on it.
What could come out of such experiment is anyone's guess, really. botania.page.cocoon2=New World, Perfect World # -- MANASTORM CHARGE