@SubscribeEvent public void onFillBucket(FillBucketEvent event) { RayTraceResult rtr = event.getTarget(); if (rtr != null) { Block b = event.getWorld().getBlockState(rtr.getBlockPos()).getBlock(); if (b instanceof IFluidBlock) { Fluid fluid = ((IFluidBlock) b).getFluid(); ItemStack filled = FluidUtil.getFilledBucket(new FluidStack(fluid, 1000)); if (!filled.isEmpty()) { event.setFilledBucket(FluidUtil.getFilledBucket(new FluidStack(fluid, 1000))); event.getWorld().setBlockToAir(rtr.getBlockPos()); event.setResult(Result.ALLOW); if (TileEntityRefinery.isInputFluidValid(fluid, 4) && event.getEntityPlayer() instanceof EntityPlayerMP) { AdvancementTriggers.OIL_BUCKET.trigger((EntityPlayerMP) event.getEntityPlayer()); } } } } }
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target) { FillBucketEvent event = new FillBucketEvent(player, stack, world, target); if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack); if (event.getResult() == Result.ALLOW) { if (player.capabilities.isCreativeMode) return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); if (--stack.stackSize <= 0) return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket()); if (!player.inventory.addItemStackToInventory(event.getFilledBucket())) player.dropItem(event.getFilledBucket(), false); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); } return null; }
@SubscribeEvent public void onFillBucket(FillBucketEvent event) { if(event.getEntityPlayer().isSneaking()) { return; } if(event.getTarget() == null) { return; } BlockPos pos = event.getTarget().getBlockPos(); if(!isPartOfTank(event.getWorld(), pos)) { return; } event.setCanceled(true); }
/** * Event listener for bucket using. When you place water or lava with * bucket it doesn't considered place block action like with any other * types of blocks. * * So here's my hack for placing water and lava blocks. */ @SubscribeEvent public void onPlayerUseBucket(FillBucketEvent event) { EntityPlayer player = event.getEntityPlayer(); List<Action> events = CommonProxy.manager.getActions(player); RayTraceResult target = event.getTarget(); if (!player.worldObj.isRemote && events != null && target != null && target.typeOfHit == Type.BLOCK) { Item bucket = event.getEmptyBucket().getItem(); BlockPos pos = target.getBlockPos().offset(target.sideHit); if (bucket == Items.LAVA_BUCKET) { this.placeBlock(events, pos, Blocks.FLOWING_LAVA, 0); } else if (bucket == Items.WATER_BUCKET) { this.placeBlock(events, pos, Blocks.FLOWING_WATER, 0); } } }
/** * Troll user if they attempt to put volcanic lava in a bucket. */ @SubscribeEvent(priority = EventPriority.HIGH) public static void onFillBucket(FillBucketEvent event) { if(event.getEntityPlayer() != null && !event.getWorld().isRemote) { RayTraceResult target = event.getTarget(); if(target != null && target.typeOfHit == RayTraceResult.Type.BLOCK) { if(target.getBlockPos() != null) { IBlockState state = event.getWorld().getBlockState(target.getBlockPos()); if(state.getBlock() instanceof LavaBlock) { event.getEntityPlayer().sendMessage(new TextComponentString(DENIALS[ThreadLocalRandom.current().nextInt(DENIALS.length)])); event.setCanceled(true); } } } } }
@SubscribeEvent public void onBucketFillAttempt(FillBucketEvent event){ if (event.entityPlayer.worldObj.isRemote) return; if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.USE_ITEMS, event.target.func_178782_a().getX(), event.target.func_178782_a().getY(), event.target.func_178782_a().getZ())) event.setCanceled(true); else GriefGuardian._dal.logAction( (EntityPlayerMP)event.entityPlayer, Actions.ITEM_USE, (int)Math.floor(event.entity.posX), (int)Math.floor(event.entity.posY), (int)Math.floor(event.entity.posZ), event.entityPlayer.getCurrentEquippedItem(), ""); }
@ForgeSubscribe /** * Called by ItemBucket when it tries to fill a bucket * @param evt */ public void bucketFill(FillBucketEvent evt) { if (evt.current.getItem().equals(Item.bucketEmpty) && evt.target.typeOfHit == EnumMovingObjectType.TILE) { if (evt.world.canMineBlock(evt.entityPlayer, evt.target.blockX, evt.target.blockY, evt.target.blockZ)) { if (evt.entityPlayer.canPlayerEdit(evt.target.blockX, evt.target.blockY, evt.target.blockZ, evt.target.sideHit, evt.current)) { if (evt.world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ) == blockID) { evt.world.setBlockToAir(evt.target.blockX, evt.target.blockY, evt.target.blockZ); evt.result = new ItemStack(Magitech.instance.magibucket); evt.setResult(Result.ALLOW); } } } } }
@SubscribeEvent(priority = EventPriority.HIGH) public void onBucketFill(FillBucketEvent evt) { if (evt.getResult() != Result.DEFAULT) return; if (evt.getEmptyBucket().getItem() != EMPTY_BUCKET) return; final RayTraceResult target = evt.getTarget(); if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK) return; final TileEntity te = evt.getWorld().getTileEntity(target.getBlockPos()); if (te == null) return; if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit)) { final IFluidHandler source = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit); final FluidStack drained = source.drain(containedFluid, false); if (containedFluid.isFluidStackIdentical(drained)) { source.drain(containedFluid, true); evt.setFilledBucket(filledBucket.copy()); evt.setResult(Result.ALLOW); } } }
private void checkReloadFromWater(ItemStack stack, World world, EntityPlayer player) { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true); FillBucketEvent event = new FillBucketEvent(player, stack, world, movingobjectposition); if (MinecraftForge.EVENT_BUS.post(event)) { return; } MovingObjectPosition movObj = this.getMovingObjectPositionFromPlayer(world, player, true); if (movObj == null) { return; } // Didn't click on anything in particular else { if (movObj.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { int x = movObj.blockX; int y = movObj.blockY; int z = movObj.blockZ; if (!world.canMineBlock(player, x, y, z)) { return; } // Not allowed to mine this, getting out of here if (!player.canPlayerEdit(x, y, z, movObj.sideHit, stack)) { return; } // Not allowed to edit this, getting out of here Material material = world.getBlock(x, y, z).getMaterial(); int meta = world.getBlockMetadata(x, y, z); // Is this water? if (material == Material.water && meta == 0) { world.setBlockToAir(x, y, z); stack.setItemDamage(0); return; } // else, not water } // else, didn't click on a block } }
@SubscribeEvent public void onBucketUse(FillBucketEvent event) { if (event.getWorld().isRemote) { return; } RayTraceResult target = event.getTarget(); if (target == null) { return; } // Nevermind? BlockPos pos = target.getBlockPos(); if (pos == null) { return; } // Nevermind? Main.console("[TERRITORIAL DEALINGS] Bucket used by player " + event.getEntityPlayer().getName() + " at x " + pos.getX() + " / y " + pos.getY() + " / z " + pos.getZ() + "."); Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(pos); if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer(), chunk)) // Checks out { Main.console("[TERRITORIAL DEALINGS] Player is allowed to edit this chunk. Doing nothing."); } else { Main.console("[TERRITORIAL DEALINGS] Player is not allowed to edit this chunk. Cancelling."); event.setCanceled(true); // Not having it } }
@SubscribeEvent public void onBucketUse(FillBucketEvent event) { if (event.getWorld().isRemote) { return; } // Not doing this on client side RayTraceResult target = event.getTarget(); if (target == null) { return; } // Nevermind? BlockPos pos = target.getBlockPos(); if (pos == null) { return; } // Nevermind? Main.console("Bucket used by player " + event.getEntityPlayer().getName() + " (ID " + event.getEntityPlayer().getGameProfile().getId() + ") at x" + pos.getX() + " y" + pos.getY() + " z" + pos.getZ() + "."); Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(pos); if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer().worldObj, event.getEntityPlayer(), chunk)) // Checks out { Main.console("Player is allowed to edit this chunk. Doing nothing."); } else { Main.console("Player is not allowed to edit this chunk. Cancelling."); event.setCanceled(true); // Not having it } }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { MovingObjectPosition pos = event.target; ItemStack ret = fillBucket(event.world, pos); if (ret == null) { return; } event.result = ret; event.setResult(Result.ALLOW); }
@SubscribeEvent public void onFillBucket(FillBucketEvent event) { ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem(); if(event.getResult() != Result.DENY && itemInHand.getItem() == TFCItems.woodenBucketEmpty) { if(event.result != null && event.result.getItem() == BuildCraftEnergy.bucketOil) { event.result = new ItemStack(TFPItems.CustomBucketOil); } } }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { ItemStack result = fillCustomBucket(event.world, event.target); if (result == null) return; event.result = result; event.setResult(Event.Result.ALLOW); }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { ItemStack result = fillCustomBucket(event.world, event.target); if (result == null) return; event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void bucketFill(FillBucketEvent event) { //Prevent stupid shit in single player. if(!event.world.isRemote){ MovingObjectPosition target = event.target; //Have we clicked a tile with an empty bucket? if (event.current.getItem() == Items.bucket && event.target.typeOfHit == MovingObjectType.BLOCK) { //Is there an entry for this block's ID? if(fluidToBucket.get(event.world.getBlock(target.blockX, target.blockY, target.blockZ)) != null) { //Set our event's item to our fluid. event.result = fluidToBucket.get(event.world.getBlock(target.blockX, target.blockY, target.blockZ)).copy(); //Allow this to happen. event.setResult(Result.ALLOW); //Set the block to 0 so we don't just have infinite liquid. event.world.setBlockToAir(target.blockX, target.blockY, target.blockZ); } else { //Nothing we recognize. return; } } else { //Not an acceptable event. return; } } }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { IBlockState block = event.world.getBlockState(event.target.getBlockPos()); if (block.getBlock() == MBlocks.magma) { event.result = new ItemStack(MBlocks.magmaBucket); event.world.setBlockToAir(event.target.getBlockPos()); event.setResult(Result.ALLOW); } }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { if (event.getEntityPlayer() != null) { Biome biome = event.getWorld().getBiomeForCoordsBody(event.getTarget().getBlockPos()); if (biome == Biomes.OCEAN || biome == Biomes.DEEP_OCEAN || biome == Biomes.FROZEN_OCEAN) { event.setResult(Event.Result.ALLOW); event.setFilledBucket(new ItemStack(PLItems.saltWaterBucket)); } } }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ); Item bucket = bucketMap.get(block); if(bucket != null && event.world.getBlockMetadata(event.target.blockX, event.target.blockY, event.target.blockZ) == 0) { event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); event.result = new ItemStack(bucket); bucket.hasContainerItem(event.result); event.setResult(Result.ALLOW); } }
@SubscribeEvent public void onBucketFill( FillBucketEvent event ) { ItemStack result = fillCustomBucket( event.world, event.target ); if( result == null ) return; event.result = result; event.setResult( Result.ALLOW ); }
@SubscribeEvent public void fillBucket(FillBucketEvent event) { if(event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { if(event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ) == RidiculousBlocks.liquidTimeBlock && event.world.getBlockMetadata(event.target.blockX, event.target.blockY, event.target.blockZ) == 0) { event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); event.result = new ItemStack(RidiculousItems.timeBucket); event.setResult(Event.Result.ALLOW); return; } } }
@ForgeSubscribe public void onBucketFill(FillBucketEvent event) // NO_UCD (unused code) { ItemStack result = fillCustomBucket( event.world, event.target ); if (result != null) { event.result = result; event.setResult( Result.ALLOW ); } }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { ItemStack result = fillCustomBucket(event.world, event.target); if (result == null) { return; } event.result = result; event.setResult(Event.Result.ALLOW); }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onBucketFill(FillBucketEvent event) { ItemStack result = fillCustomBucket(event.world, event.target); if (result == null) return; event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void onBucketFill(FillBucketEvent event) { ItemStack result = fillCustomBucket(event.world, event.target); if (result == null) { return; } event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void bucketFillEvent(FillBucketEvent event) { ItemStack result = fillCustomBucket(event.world, event.target); if (result == null) return; event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void onBucketUsed(FillBucketEvent event){ if(event.getTarget() == null) return; ItemStack result = fillBucket(event.getWorld(), event.getTarget().getBlockPos()); if(result == null) return; event.setFilledBucket(result); event.setResult(Result.ALLOW); }
@SubscribeEvent public void onBucketUsed(FillBucketEvent event){ if(event.getTarget() == null) return; ItemStack result = fillBucket(event.getWorld(), event.getTarget().getBlockPos()); if(result == ItemStack.EMPTY) return; event.setFilledBucket(result); event.setResult(Result.ALLOW); }
@SubscribeEvent public void onBucketUsed(FillBucketEvent event){ ItemStack result = fillBucket(event.world, event.target.getBlockPos()); if(result == null) return; event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void onBucketUsed(FillBucketEvent event){ ItemStack result = fillBucket(event.world, event.target); if(result == null){ return; } event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void onBucketUsed(FillBucketEvent event){ ItemStack result = fillBucket(event.world, event.target); if(result == null) return; event.result = result; event.setResult(Result.ALLOW); }
@SubscribeEvent public void onFillBucket(FillBucketEvent event) { Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ); if (block == ModBlocks.energizedWater) { event.result = new ItemStack(ModItems.energizedWaterBucket); event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); event.setResult(Result.ALLOW); } }