Java 类net.minecraftforge.event.entity.player.FillBucketEvent 实例源码

项目:pnc-repressurized    文件:EventHandlerPneumaticCraft.java   
@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());
                }
            }
        }
    }
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
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;
}
项目:FFS    文件:TankManager.java   
@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);
}
项目:blockbuster    文件:ActionHandler.java   
/**
 * 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);
        }
    }
}
项目:Hard-Science    文件:CommonEventHandler.java   
/**
 * 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);
                }
            }
        }
    }
}
项目:GriefGuardian    文件:ClaimGuardEventHandler.java   
@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(), 
                "");
}
项目:Magitech    文件:BlockMagi.java   
@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);
                }
            }
        }
    }
}
项目:OpenModsLib    文件:SingleFluidBucketFillHandler.java   
@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);
        }
    }
}
项目:minecraft-quiverbow    文件:AquaAccelerator.java   
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
      }
  }
项目:minecraft-territorialdealings    文件:EventListener.java   
@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
    }
}
项目:minecraft-territorialdealings    文件:EventListener.java   
@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
    }
}
项目:4Space-5    文件:EventHandlerGC.java   
@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);
}
项目:TerrafirmaPunk-Tweaks    文件:PlayerInteractionHandler.java   
@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);
        }
    }
}
项目:DartCraft2    文件:BucketHandler.java   
@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);
}
项目:Enterprise    文件:FluidPrefab.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

        ItemStack result = fillCustomBucket(event.world, event.target);

        if (result == null)
                return;

        event.result = result;
        event.setResult(Result.ALLOW);
}
项目:WeirdScience    文件:BucketEventManager.java   
@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;
        }
    }
}
项目:M4thThings    文件:BucketHandler.java   
@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);
}
项目:Minestrappolation-4    文件:MEventHandler.java   
@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);
    }
}
项目:Production-Line    文件:PLEvent.java   
@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));
        }
    }
}
项目:AdvancedRocketry    文件:BucketHandler.java   
@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);
    }
}
项目:Yamcl    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill( FillBucketEvent event )
{

  ItemStack result = fillCustomBucket( event.world, event.target );

  if( result == null )
    return;

  event.result = result;
  event.setResult( Result.ALLOW );
}
项目:RidiculousWorld    文件:RWEventHandler.java   
@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;
        }

    }

}
项目:MC-MineAPI.Java    文件:FluidBucketTemplate.java   
@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 );
    }
}
项目:Nincrafty-Things    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

    ItemStack result = fillCustomBucket(event.world, event.target);

    if (result == null)
        return;

    event.result = result;
    event.setResult(Result.ALLOW);
}
项目:FusionReactor    文件:BucketHandler.java   
@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);
}
项目:SecureCraftProtect    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event)
{
    ItemStack result = fillCustomBucket(event.world, event.target);

    if (result == null) return;

    event.result = result;
    event.setResult(Result.ALLOW);
}
项目:TectoCraft    文件:TectoHandler.java   
@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);
}
项目:ZeroQuest    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

        ItemStack result = fillCustomBucket(event.world, event.target);

        if (result == null)
                return;

        event.result = result;
        event.setResult(Result.ALLOW);
}
项目:ZeroQuest    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

    ItemStack result = fillCustomBucket(event.world, event.target);

    if (result == null) {
        return;
    }

    event.result = result;
    event.setResult(Result.ALLOW);
}
项目:FlowstoneEnergy    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

    ItemStack result = fillCustomBucket(event.world, event.target);

    if (result == null)
        return;

    event.result = result;
    event.setResult(Result.ALLOW);
}
项目:GelsPlus    文件:EventHandler.java   
@SubscribeEvent
public void bucketFillEvent(FillBucketEvent event) {
    ItemStack result = fillCustomBucket(event.world, event.target);
    if (result == null)
        return;
    event.result = result;
    event.setResult(Result.ALLOW);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@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);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@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);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@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);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@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);
}
项目:SecurityCraft    文件:ForgeEventHandler.java   
@SubscribeEvent
public void onBucketUsed(FillBucketEvent event){
    ItemStack result = fillBucket(event.world, event.target);
    if(result == null){ return; }
    event.result = result;
    event.setResult(Result.ALLOW);

}
项目:SecurityCraft    文件:SCEventHandler.java   
@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);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
public void onBucketUsed(FillBucketEvent event){
    ItemStack result = fillBucket(event.world, event.target);
    if(result == null)
        return;
    event.result = result;
    event.setResult(Result.ALLOW);
}
项目:EnergizedPower    文件:BucketHandler.java   
@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);
    }
}
项目:CustomItems    文件:BucketHandler.java   
@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);
}