| 1 | package net.minecraft.item;
|
| 2 |
|
| 3 | import net.minecraft.block.Block;
|
| 4 | import net.minecraft.block.BlockLiquid;
|
| 5 | import net.minecraft.block.material.Material;
|
| 6 | import net.minecraft.block.state.IBlockState;
|
| 7 | import net.minecraft.entity.player.EntityPlayer;
|
| 8 | import net.minecraft.init.Blocks;
|
| 9 | import net.minecraft.stats.StatList;
|
| 10 | import net.minecraft.util.BlockPos;
|
| 11 | import net.minecraft.util.MovingObjectPosition;
|
| 12 | import net.minecraft.world.World;
|
| 13 |
|
| 14 | public class ItemLilyPad extends ItemColored
|
| 15 | {
|
| 16 | public ItemLilyPad(Block block)
|
| 17 | {
|
| 18 | super(block, false);
|
| 19 | }
|
| 20 |
|
| 21 | /**
|
| 22 | * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
| 23 | */
|
| 24 | public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
|
| 25 | {
|
| 26 | MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
|
| 27 |
|
| 28 | if (movingobjectposition == null)
|
| 29 | {
|
| 30 | return itemStackIn;
|
| 31 | }
|
| 32 | else
|
| 33 | {
|
| 34 | if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
| 35 | {
|
| 36 | BlockPos blockpos = movingobjectposition.getBlockPos();
|
| 37 |
|
| 38 | if (!worldIn.isBlockModifiable(playerIn, blockpos))
|
| 39 | {
|
| 40 | return itemStackIn;
|
| 41 | }
|
| 42 |
|
| 43 | if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
|
| 44 | {
|
| 45 | return itemStackIn;
|
| 46 | }
|
| 47 |
|
| 48 | BlockPos blockpos1 = blockpos.up();
|
| 49 | IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
| 50 |
|
| 51 | if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
|
| 52 | {
|
| 53 | worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());
|
| 54 |
|
| 55 | if (!playerIn.capabilities.isCreativeMode)
|
| 56 | {
|
| 57 | --itemStackIn.stackSize;
|
| 58 | }
|
| 59 |
|
| 60 | playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
|
| 61 | }
|
| 62 | }
|
| 63 |
|
| 64 | return itemStackIn;
|
| 65 | }
|
| 66 | }
|
| 67 |
|
| 68 | public int getColorFromItemStack(ItemStack stack, int renderPass)
|
| 69 | {
|
| 70 | return Blocks.waterlily.getRenderColor(Blocks.waterlily.getStateFromMeta(stack.getMetadata()));
|
| 71 | }
|
| 72 | }
|
| 73 |
|