diff --git a/src/main/java/vazkii/botania/common/block/BlockCocoon.java b/src/main/java/vazkii/botania/common/block/BlockCocoon.java
index 5f9388372..70080657c 100644
--- a/src/main/java/vazkii/botania/common/block/BlockCocoon.java
+++ b/src/main/java/vazkii/botania/common/block/BlockCocoon.java
@@ -15,20 +15,24 @@ import java.util.List;
import javax.annotation.Nonnull;
+import mezz.jei.util.FakeClientWorld;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
+import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import net.minecraft.world.WorldServer;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileCocoon;
@@ -71,13 +75,27 @@ public class BlockCocoon extends BlockMod implements ILexiconable {
@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 item = player.getHeldItem(hand);
- if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && !item.isEmpty() && item.getItem() == Items.EMERALD) {
- if(!player.capabilities.isCreativeMode)
- item.shrink(1);
- cocoon.emeraldsGiven++;
- world.playEvent(2005, pos, 6 + world.rand.nextInt(4));
+ ItemStack stack = player.getHeldItem(hand);
+ 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)
+ stack.shrink(1);
+ cocoon.emeraldsGiven++;
+ world.playEvent(2005, pos, 6 + world.rand.nextInt(4));
+ } else if(item == Items.CHORUS_FRUIT && cocoon.chorusFruitGiven < TileCocoon.MAX_CHORUS_FRUITS) {
+ if(!player.capabilities.isCreativeMode)
+ 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);
+ }
+ }
+
+ return true;
}
+
return false;
}
diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java
index e12a13433..9d3f8799f 100644
--- a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java
+++ b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java
@@ -10,8 +10,9 @@
*/
package vazkii.botania.common.block.tile;
-import net.minecraft.block.Block;
import net.minecraft.entity.EntityAgeable;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.monster.EntityShulker;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityHorse;
@@ -22,19 +23,26 @@ import net.minecraft.entity.passive.EntityRabbit;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
+import net.minecraft.item.EnumDyeColor;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.datasync.DataParameter;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
+import net.minecraftforge.fml.relauncher.ReflectionHelper;
+import vazkii.botania.common.lib.LibObfuscation;
public class TileCocoon extends TileMod {
private static final String TAG_TIME_PASSED = "timePassed";
private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven";
+ private static final String TAG_CHORUS_FRUIT_GIVEN = "chorusFruitGiven";
public static final int TOTAL_TIME = 2400;
public static final int MAX_EMERALDS = 20;
+ public static final int MAX_CHORUS_FRUITS = 20;
public int timePassed;
public int emeraldsGiven;
+ public int chorusFruitGiven;
@Override
public void update() {
@@ -45,14 +53,16 @@ public class TileCocoon extends TileMod {
private void hatch() {
if(!world.isRemote) {
- world.playEvent(2001, pos, Block.getStateId(getBlockType().getStateFromMeta(getBlockMetadata())));
- world.setBlockToAir(pos);
+ world.destroyBlock(pos, false);
- EntityAgeable entity = null;
+ EntityLiving entity = null;
float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS);
+ float shulkerChance = Math.min(1F, (float) chorusFruitGiven / (float) MAX_CHORUS_FRUITS);
- if(Math.random() < villagerChance) {
+ if(Math.random() < shulkerChance) {
+ entity = new EntityShulker(world);
+ } else if(Math.random() < villagerChance) {
EntityVillager villager = new EntityVillager(world);
VillagerRegistry.setRandomProfession(villager, world.rand);
entity = villager;
@@ -97,7 +107,8 @@ public class TileCocoon extends TileMod {
if(entity != null) {
entity.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
- entity.setGrowingAge(-24000);
+ if(entity instanceof EntityAgeable)
+ ((EntityAgeable) entity).setGrowingAge(-24000);
world.spawnEntity(entity);
entity.spawnExplosionParticle();
}
@@ -108,12 +119,14 @@ public class TileCocoon extends TileMod {
public void writePacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_TIME_PASSED, timePassed);
cmp.setInteger(TAG_EMERALDS_GIVEN, emeraldsGiven);
+ cmp.setInteger(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven);
}
@Override
public void readPacketNBT(NBTTagCompound cmp) {
timePassed = cmp.getInteger(TAG_TIME_PASSED);
emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN);
+ chorusFruitGiven = cmp.getInteger(TAG_CHORUS_FRUIT_GIVEN);
}
}
diff --git a/src/main/resources/assets/botania/lang/en_us.lang b/src/main/resources/assets/botania/lang/en_us.lang
index 0178b41f3..27a143f2a 100644
--- a/src/main/resources/assets/botania/lang/en_us.lang
+++ b/src/main/resources/assets/botania/lang/en_us.lang
@@ -2779,7 +2779,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 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.
What could come out of such experiment is anyone's guess, really.
botania.page.cocoon2=New World, Perfect World
# -- MANASTORM CHARGE