mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 13:09:42 +00:00
The cocoon of caprice can now accept items from drops.
This commit is contained in:
1 parent
7ea4b802a1
commit
06134d2acf
2 files changed
+26
-6
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.<br>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.<br>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.<br>Giving the items can be done via a right click or simply dropping them on it.<br>What could come out of such experiment is anyone's guess, really.
|
||||
botania.page.cocoon2=New World, Perfect World
|
||||
|
||||
# -- MANASTORM CHARGE
|
||||
|
||||
Reference in new issue
Block a user