/* Place bushes on dirt, grass, or other bushes only */ @Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (side != 1) return false; else if (player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack)) { Block block = Block.blocksList[world.getBlockId(x, y, z)]; if (block != null && (block.canSustainPlant( world, x, y, z, ForgeDirection.UP, (IPlantable) NContent.netherBerryBush) || block == Block.netherrack) && world.isAirBlock(x, y + 1, z)) { world.setBlock(x, y + 1, z, NContent.netherBerryBush.blockID, stack.getItemDamage() % 4, 3); if (!player.capabilities.isCreativeMode) stack.stackSize--; if (!world.isRemote) world.playAuxSFX(2001, x, y, z, NContent.netherBerryBush.blockID); return true; } else return false; } else return false; }
/** ********** MAIN ********** */ @Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int dir, float par8, float par9, float par10) { if (dir != 1) { return false; } else if (player.canPlayerEdit(x, y, z, dir, stack) && player.canPlayerEdit(x, y + 1, z, dir, stack)) { if (BlockCheck.canSustainPlant( world, x, y, z, ForgeDirection.UP, GrowthCraftHops.hopVine.getBlock()) && BlockCheck.isRope(world, x, y + 1, z)) { world.setBlock(x, y + 1, z, GrowthCraftHops.hopVine.getBlock()); --stack.stackSize; return true; } else { return false; } } else { return false; } }
@Override public boolean onItemUse( ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (itemstack != null && itemstack.getItemDamage() == 0) { if (side == 1 && player.canPlayerEdit(x, y, z, side, itemstack) && player.canPlayerEdit(x, y + 1, z, side, itemstack)) { Block block = world.getBlock(x, y, z); if (block != Blocks.bedrock && block.canSustainPlant(world, x, y, z, ForgeDirection.UP, this) && world.isAirBlock(x, y + 1, z)) { world.setBlock(x, y + 1, z, getPlant(world, x, y, z)); --itemstack.stackSize; return true; } } return false; } return super.onItemUse(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ); }
public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 != 1) { return false; } else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) { int var11 = par3World.getBlockId(par4, par5, par6); if (var11 == this.soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6)) { par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType); --par1ItemStack.stackSize; return true; } else { return false; } } else { return false; } }
public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 != 1) { return false; } else { ++par5; Block block = this.doorBlock; if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) { if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) { return false; } else { int i1 = MathHelper.floor_double( (double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; ItemDoor.placeDoorBlock(par3World, par4, par5, par6, i1, block); --par1ItemStack.stackSize; return true; } } else { return false; } } }
@Override public boolean onItemUse( ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (!ReikaWorldHelper.softBlocks(world.getBlock(x, y, z))) { if (side == 0) --y; if (side == 1) ++y; if (side == 2) --z; if (side == 3) ++z; if (side == 4) --x; if (side == 5) ++x; } Block idbelow = world.getBlock(x, y - 1, z); if ((!ReikaWorldHelper.softBlocks(world.getBlock(x, y, z))) || !ReikaPlantHelper.SAPLING.canPlantAt(world, x, y, z)) return false; if (!player.canPlayerEdit(x, y, z, 0, item)) return false; else { if (!player.capabilities.isCreativeMode) --item.stackSize; world.setBlock(x, y, z, ChromaBlocks.PLANT.getBlockInstance(), item.getItemDamage() % 16, 3); ReikaSoundHelper.playPlaceSound(world, x, y, z, Blocks.grass); return true; } }
@Override public boolean onItemUse( ItemStack items, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (items.getItemDamage() > 0) return false; if (!ReikaWorldHelper.softBlocks(world.getBlockId(x, y, z)) && world.getBlockMaterial(x, y, z) != Material.water && world.getBlockMaterial(x, y, z) != Material.lava) { if (side == 0) --y; if (side == 1) ++y; if (side == 2) --z; if (side == 3) ++z; if (side == 4) --x; if (side == 5) ++x; } if ((!ReikaWorldHelper.softBlocks(world.getBlockId(x, y, z))) || world.getBlockId(x, y - 1, z) != Block.tilledField.blockID) return false; if (!player.canPlayerEdit(x, y, z, 0, items)) return false; else { if (!player.capabilities.isCreativeMode) --items.stackSize; ReikaWorldHelper.legacySetBlockWithNotify(world, x, y, z, RotaryCraft.canola.blockID); return true; } }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) { Block block = world.getBlock(i, j, k); if (block == Blocks.snow_layer) side = 1; else { if (side == 0) --j; else if (side == 1) ++j; else if (side == 2) --k; else if (side == 3) ++k; else if (side == 4) --i; else if (side == 5) ++i; } if (!player.canPlayerEdit(i, j, k, side, stack) || stack.stackSize == 0) return false; if (!world.isRemote) world.setBlock(i, j, k, Blocks.flowing_water, 0, 3); if (!player.capabilities.isCreativeMode) stack.damageItem(1, player); return true; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ public ItemStack onItemRightClick( ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); if (movingobjectposition == null) { return par1ItemStack; } else { if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { return par1ItemStack; } if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) { return par1ItemStack; } if (par2World.getBlockMaterial(i, j, k) == Material.water && par2World.getBlockMetadata(i, j, k) == 0 && par2World.isAirBlock(i, j + 1, k)) { par2World.setBlock(i, j + 1, k, Block.waterlily.blockID); if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } } } return par1ItemStack; } }
public static boolean useHunger( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par, String tag) { if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); NBTTagCompound nbtData = stack.getTagCompound(); if (nbtData == null) { stack.getTagCompound().setInteger(tag, 0); } int points = stack.getTagCompound().getInteger(tag); if (!player.canPlayerEdit(x, y, z, par, stack)) { return false; } Block block = world.getBlock(x, y, z); if (block == Calculator.amethystLeaf) { int meta = world.getBlockMetadata(x, y, z); if (meta > 2) { points += 1; if (!world.isRemote) { world.setBlockMetadataWithNotify(x, y, z, 0, 2); } nbtData.setInteger(tag, points); } } return true; }
/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 == 0) { return false; } else if (par7 == 1) { return false; } else { int i1 = Direction.facingToDirection[par7]; EntityTCItemFrame entityhanging = this.createHangingEntity(par3World, par4, par5, par6, i1); if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { if (entityhanging != null && entityhanging.onValidSurface()) { if (!par3World.isRemote) { par3World.spawnEntityInWorld(entityhanging); } --par1ItemStack.stackSize; } return true; } } }
/** * Called when a Block is right-clicked with this Item * * @param pos The block being right-clicked * @param side The side being right-clicked */ public boolean onItemUse( ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (side != EnumFacing.UP) { return false; } else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) { return false; } else if (worldIn .getBlockState(pos) .getBlock() .canSustainPlant(worldIn, pos, EnumFacing.UP, this) && worldIn.isAirBlock(pos.up())) { worldIn.setBlockState(pos.up(), this.crops.getDefaultState()); --stack.stackSize; return true; } else { return false; } }
public void onServerBlockActivated( World world, EntityPlayer entityplayer, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (!entityplayer.canPlayerEdit(x >> 3, y >> 3, z >> 3, side, entityplayer.getHeldItem())) { return; } if (entityplayer.getHeldItem() != null && entityplayer.getHeldItem().getItem() instanceof ItemLittleBlocksWand) { return; } if (this.canPlayerPlaceBlockOrUseItem(world, entityplayer)) { try { BlockUtil.onServerBlockActivated( world, entityplayer, entityplayer.getCurrentEquippedItem(), x, y, z, side, hitX, hitY, hitZ); } catch (ClassCastException e) { FMLCommonHandler.instance().getFMLLogger().warn(e.getLocalizedMessage()); } } }
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { // We invoke PlayerControllerMP.onPlayerRightClick() from here so that Minecraft // will invoke onItemUseFirst() on the client side. We'll tell it to pass the // request to the server, which will make sure that rift-related changes are // reflected on the server. if (!world.isRemote) { return stack; } MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true); if (hit != null) { int hx = hit.blockX; int hy = hit.blockY; int hz = hit.blockZ; NewDimData dimension = PocketManager.createDimensionData(world); DimLink link = dimension.getLink(hx, hy, hz); if (world.getBlock(hx, hy, hz) == mod_pocketDim.blockRift && link != null && player.canPlayerEdit(hx, hy, hz, hit.sideHit, stack)) { // Invoke onPlayerRightClick() FMLClientHandler.instance() .getClient() .playerController .onPlayerRightClick(player, world, stack, hx, hy, hz, hit.sideHit, hit.hitVec); } } return stack; }
/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (this.field_150948_b) { return super.onItemUse( par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } else if (par1ItemStack.stackSize == 0) { return false; } else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { Block block = par3World.getBlock(par4, par5, par6); int i1 = par3World.getBlockMetadata(par4, par5, par6); int j1 = i1 & 7; boolean flag = (i1 & 8) != 0; if ((par7 == 1 && !flag || par7 == 0 && flag) && block == this.field_150949_c && j1 == par1ItemStack.getItemDamage()) { if (par3World.checkNoEntityCollision( this.field_150947_d.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.field_150947_d, j1, 3)) { par3World.playSoundEffect( (double) ((float) par4 + 0.5F), (double) ((float) par5 + 0.5F), (double) ((float) par6 + 0.5F), this.field_150947_d.stepSound.func_150496_b(), (this.field_150947_d.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150947_d.stepSound.getPitch() * 0.8F); --par1ItemStack.stackSize; } return true; } else { return this.func_150946_a( par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse( par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } } }
@Override public boolean onItemUse( ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (!player.canPlayerEdit(x, y, z, side, itemStack)) return false; UseTrowelEvent event = new UseTrowelEvent(player, itemStack, world, x, y, z); if (MinecraftForge.EVENT_BUS.post(event)) return false; if (event.getResult() == Event.Result.ALLOW) { itemStack.damageItem(1, player); return true; } if (side == 0) return false; Block block = world.getBlock(x, y, z); if (block instanceof BlockGarden) { player.openGui(GardenCore.instance, GuiHandler.gardenLayoutGuiID, world, x, y, z); return true; } else if (block instanceof IPlantProxy) { IPlantProxy proxy = (IPlantProxy) block; TileEntityGarden te = proxy.getGardenEntity(world, x, y, z); if (te != null) { player.openGui( GardenCore.instance, GuiHandler.gardenLayoutGuiID, world, te.xCoord, te.yCoord, te.zCoord); return true; } } /*if (world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) { Block.SoundType stepSound = ModBlocks.gardenSoil.stepSound; world.playSoundEffect( + .5f, y + .5f, z + .5f, stepSound.getStepResourcePath(), (stepSound.getVolume() + .5f) / 2, stepSound.getPitch() * .8f); if (!world.isRemote) { world.setBlock(x, y, z, ModBlocks.gardenSoil); itemStack.damageItem(1, player); } return true; }*/ return false; }
/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 == 0) { --par5; } if (par7 == 1) { ++par5; } if (par7 == 2) { --par6; } if (par7 == 3) { ++par6; } if (par7 == 4) { --par4; } if (par7 == 5) { ++par4; } if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { Block var11 = par3World.getBlock(par4, par5, par6); if (var11 == Blocks.air) { if (par3World.isRemote == false) { EntityDreadFowl temp = new EntityDreadFowl(par3World); temp.setLocationAndAngles(par4, par5, par6, par3World.rand.nextFloat() * 360.0F, 0.0F); temp.setTamed(true); temp.setOwner(par2EntityPlayer.getCommandSenderName()); par3World.spawnEntityInWorld(temp); } if (!par2EntityPlayer.capabilities.isCreativeMode) { par2EntityPlayer.inventory.consumeInventoryItem(this); } } return true; } }
@Override public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { // We want to use onItemUseFirst() here so that this code will run on the server side, // so we don't need the client to send link-related updates to the server. Still, // check whether we have a rift in sight before passing the request over. // On integrated servers, the link won't be removed immediately because of the rift // removal animation. That means we'll have a chance to check for the link before // it's deleted. Otherwise the Rift Remover's durability wouldn't drop. MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true); if (hit != null) { x = hit.blockX; y = hit.blockY; z = hit.blockZ; NewDimData dimension = PocketManager.createDimensionData(world); DimLink link = dimension.getLink(x, y, z); if (world.getBlock(x, y, z) == mod_pocketDim.blockRift && link != null && player.canPlayerEdit(x, y, z, side, stack)) { // Tell the rift's tile entity to do its removal animation TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity != null && tileEntity instanceof TileEntityRift) { ((TileEntityRift) tileEntity).shouldClose = true; tileEntity.markDirty(); } else if (!world.isRemote) { // Only set the block to air on the server side so that we don't // tell the server to remove the rift block before it can use the // Rift Remover. Otherwise, it won't know to reduce durability. world.setBlockToAir(x, y, z); } if (world.isRemote) { // Tell the server about this return false; } else { if (!player.capabilities.isCreativeMode) { stack.damageItem(1, player); } player.worldObj.playSoundAtEntity(player, mod_pocketDim.modid + ":riftClose", 0.8f, 1); } } } return true; }
public boolean onItemUse( ItemStack itemstack, EntityPlayer par2EntityPlayer, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 != 1) { return false; } else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, itemstack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, itemstack)) { int var8 = world.getBlockId(par4, par5, par6); if (var8 == Block.tilledField.blockID && world.isAirBlock(par4, par5 + 1, par6)) { if (itemstack.getItemDamage() == 1) { world.setBlock(par4, par5 + 1, par6, this.oniGar, 4, 2); } else if (itemstack.getItemDamage() == 2) { world.setBlock(par4, par5 + 1, par6, this.oniGar, 8, 2); } else if (itemstack.getItemDamage() == 4) { world.setBlock(par4, par5 + 1, par6, this.pTGinger, 0, 2); } else if (itemstack.getItemDamage() == 5) { world.setBlock(par4, par5 + 1, par6, this.pTGinger, 4, 2); } else if (itemstack.getItemDamage() == 6) { world.setBlock(par4, par5 + 1, par6, this.pTGinger, 8, 2); } else if (itemstack.getItemDamage() == 9) { world.setBlock(par4, par5 + 1, par6, this.wChestnut, 8, 2); } --itemstack.stackSize; return true; } else { return false; } } else { return false; } }
public boolean onItemUse( ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (world.isRemote) { return true; } else if (side != 1) { // not the top of a block return false; } else { y++; Block blockToPlace = mod_jaffas.blockSink; int direction = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; direction = (direction + 3) % 4; if (player.canPlayerEdit(x, y, z, side, item) && player.canPlayerEdit(x, y + 1, z, side, item)) { if (world.isAirBlock(x, y, z) && world.isAirBlock(x, y + 1, z)) { world.setBlockAndMetadataWithNotify(x, y, z, blockToPlace.blockID, direction); --item.stackSize; return true; } else { return false; } } else { return false; } } }
/** Called when a Block is right-clicked with this Item */ public boolean onItemUse( ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (side == EnumFacing.DOWN) { return false; } else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid()) { return false; } else { pos = pos.offset(side); if (!playerIn.canPlayerEdit(pos, side, stack)) { return false; } else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos)) { return false; } else if (worldIn.isRemote) { return true; } else { if (side == EnumFacing.UP) { int i = MathHelper.floor_double( (double) ((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; worldIn.setBlockState( pos, Blocks.standing_sign .getDefaultState() .withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3); } else { worldIn.setBlockState( pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3); } --stack.stackSize; TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack)) { playerIn.openEditSign((TileEntitySign) tileentity); } return true; } } }
/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack var1, EntityPlayer var2, World var3, int var4, int var5, int var6, int var7, float var8, float var9, float var10) { if (!var2.canPlayerEdit(var4, var5, var6, var7, var1)) { return false; } else { UseHoeEvent var11 = new UseHoeEvent(var2, var1, var3, var4, var5, var6); if (MinecraftForge.EVENT_BUS.post(var11)) { return false; } else if (var11.getResult() == Result.ALLOW) { var1.damageItem(1, var2); return true; } else { int var12 = var3.getBlockId(var4, var5, var6); int var13 = var3.getBlockId(var4, var5 + 1, var6); if ((var7 == 0 || var13 != 0 || var12 != Block.grass.blockID) && var12 != Block.dirt.blockID) { return false; } else { Block var14 = Block.tilledField; var3.playSoundEffect( (double) ((float) var4 + 0.5F), (double) ((float) var5 + 0.5F), (double) ((float) var6 + 0.5F), var14.stepSound.getStepSound(), (var14.stepSound.getVolume() + 1.0F) / 2.0F, var14.stepSound.getPitch() * 0.8F); if (var3.isRemote) { return true; } else { var3.setBlock(var4, var5, var6, var14.blockID); var1.damageItem(1, var2); return true; } } } } }
public boolean onItemUse( ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (side == 0) { y--; } if (side == 1) { y++; } if (side == 2) { z--; } if (side == 3) { z++; } if (side == 4) { x--; } if (side == 5) { x++; } if (!player.canPlayerEdit(x, y, z, side, itemstack)) { return false; } else { if (world.isAirBlock(x, y, z)) { world.playSoundEffect( (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "fire.ignite", 1F, itemRand.nextFloat() * 0.4F + 0.8F); world.setBlock(x, y, z, ModBlocks.darkaxFire); } itemstack.damageItem(1, player); return true; } }
/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 == 0) { --par5; } if (par7 == 1) { ++par5; } if (par7 == 2) { --par6; } if (par7 == 3) { ++par6; } if (par7 == 4) { --par4; } if (par7 == 5) { ++par4; } if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { int i1 = par3World.getBlockId(par4, par5, par6); if (i1 == 0) { par3World.setBlock(par4, par5, par6, Block.dirt.blockID); } par1ItemStack.damageItem(1, par2EntityPlayer); return true; } }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (!player.canPlayerEdit(pos.offset(side), side, stack)) { return false; } else { int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, player, world, pos); if (hook != 0) return hook > 0; IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if (side != EnumFacing.DOWN && world.isAirBlock(pos.up())) { if (block == Blocks.grass) { return this.useHoe(stack, player, world, pos, Blocks.farmland.getDefaultState()); } if (block == Blocks.dirt) { switch (SwitchDirtType.TYPE_LOOKUP[ ((BlockDirt.DirtType) iblockstate.getValue(BlockDirt.VARIANT)).ordinal()]) { case 1: return this.useHoe(stack, player, world, pos, Blocks.farmland.getDefaultState()); case 2: return this.useHoe( stack, player, world, pos, Blocks.dirt .getDefaultState() .withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); } } } return false; } }
public boolean onItemUse( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (!par2EntityPlayer.canPlayerEdit(x, y, z, side, par1ItemStack)) { return false; } // System.out.println(par1ItemStack.getItem().getUnlocalizedName()); if (par1ItemStack.getItem().getUnlocalizedName().contains("paintBrush16")) { return false; } int damageValue = par1ItemStack.getItemDamage(); int metaData = 15 - par1ItemStack.getItem().getMetadata(damageValue); Block block = par3World.getBlock(x, y, z); // System.out.println(metaData+" "+damageValue); boolean recoloured = false; if (damageValue != MAX_USES) { recoloured = block.recolourBlock(par3World, x, y, z, ForgeDirection.getOrientation(side), metaData); } if (recoloured) { par1ItemStack.damageItem(1, par2EntityPlayer); damageValue = par1ItemStack.getItemDamage(); } if (damageValue >= MAX_USES) { par2EntityPlayer.inventory.mainInventory[par2EntityPlayer.inventory.currentItem] = ThutItems.brushes[16].copy(); par2EntityPlayer.inventory.mainInventory[par2EntityPlayer.inventory.currentItem] .setItemDamage(0); } return recoloured; // */ }
@Override public boolean onItemUse( ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { if (world.isRemote) { return true; } ForgeDirection dir = ForgeDirection.values()[side]; int placeX = x + dir.offsetX; int placeY = y + dir.offsetY; int placeZ = z + dir.offsetZ; if (player.canPlayerEdit(placeX, placeY, placeZ, side, itemStack) && world.isAirBlock(placeX, placeY, placeZ) && PainterUtil.getSourceBlock(itemStack) != null) { world.setBlock(placeX, placeY, placeZ, EnderIO.blockConduitBundle); IConduitBundle bundle = (IConduitBundle) world.getTileEntity(placeX, placeY, placeZ); Block facadeID = PainterUtil.getSourceBlock(itemStack); int facadeMeta = PainterUtil.getSourceBlockMetadata(itemStack); facadeMeta = PainterUtil.adjustFacadeMetadata(facadeID, facadeMeta, side); bundle.setFacadeId(facadeID); bundle.setFacadeMetadata(facadeMeta); bundle.setFacadeType(FacadeType.values()[itemStack.getItemDamage()]); ConduitUtil.playStepSound(facadeID.stepSound, world, x, y, z); if (!player.capabilities.isCreativeMode) { itemStack.stackSize--; } return true; } return false; }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (stack.stackSize == 0) return false; else if (!player.canPlayerEdit(x, y, z, side, stack)) return false; else { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); boolean flag = meta == 1; if (block == field_150939_a && (side == 1 && !flag || side == 0 && flag)) { if (world.checkNoEntityCollision( field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, field_150939_a, 2, 3)) { world.playSoundEffect( x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F); stack.stackSize--; } return true; } else return func_150946_a(stack, player, world, x, y, z, side) ? true : super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); } }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float xHit, float yHit, float zHit) { if (!player.canPlayerEdit(x, y, z, side, player.getCurrentEquippedItem())) { return false; } if (!world.isRemote) { ItemStack stack = player.getCurrentEquippedItem(); if (stack != null && stack.getItem() == ModItems.mannequinTool) { return false; } if (stack != null && stack.getItem() == Items.name_tag) { TileEntity te = world.getTileEntity(x, y, z); ; if (te != null && te instanceof TileEntityMannequin) { if (stack.getItem() == Items.name_tag) { ((TileEntityMannequin) te).setOwner(player.getCurrentEquippedItem()); } } } else { FMLNetworkHandler.openGui( player, ArmourersWorkshop.instance, LibGuiIds.MANNEQUIN, world, x, y, z); } } if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() == ModItems.mannequinTool) { return false; } return true; }
/** * Callback for item usage. If the item does something special on right clicking, he will have one * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse( ItemStack var1, EntityPlayer var2, World var3, int var4, int var5, int var6, int var7, float var8, float var9, float var10) { int var11 = var3.getBlockId(var4, var5, var6); if (var11 == Block.snow.blockID && (var3.getBlockMetadata(var4, var5, var6) & 7) < 1) { var7 = 1; } else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID) { if (var7 == 0) { --var5; } if (var7 == 1) { ++var5; } if (var7 == 2) { --var6; } if (var7 == 3) { ++var6; } if (var7 == 4) { --var4; } if (var7 == 5) { ++var4; } } if (!var2.canPlayerEdit(var4, var5, var6, var7, var1)) { return false; } else if (var1.stackSize == 0) { return false; } else { if (var3.canPlaceEntityOnSide( this.spawnID, var4, var5, var6, false, var7, (Entity) null, var1)) { Block var12 = Block.blocksList[this.spawnID]; int var13 = var12.onBlockPlaced(var3, var4, var5, var6, var7, var8, var9, var10, 0); if (var3.setBlock(var4, var5, var6, this.spawnID, var13, 3)) { if (var3.getBlockId(var4, var5, var6) == this.spawnID) { Block.blocksList[this.spawnID].onBlockPlacedBy(var3, var4, var5, var6, var2, var1); Block.blocksList[this.spawnID].onPostBlockPlaced(var3, var4, var5, var6, var13); } var3.playSoundEffect( (double) ((float) var4 + 0.5F), (double) ((float) var5 + 0.5F), (double) ((float) var6 + 0.5F), var12.stepSound.getPlaceSound(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F); --var1.stackSize; } } return true; } }