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

项目:connor41-etfuturum2    文件:GrassPath.java   
public static void onPlayerInteract(PlayerInteractEvent event) {
    if (EtFuturum.enableGrassPath)
        if (event.entityPlayer != null) {
            World world = event.entityPlayer.worldObj;
            if (event.action == Action.RIGHT_CLICK_BLOCK)
                if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) {
                    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
                    if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) {
                        world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path);
                        event.entityPlayer.swingItem();
                        stack.damageItem(1, event.entityPlayer);
                        world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
                    }
                }
        }
}
项目:EnderCore    文件:RightClickCropHandler.java   
@SubscribeEvent
public void handleCropRightClick(PlayerInteractEvent event) {
  int x = event.x, y = event.y, z = event.z;
  Block block = event.world.getBlock(x, y, z);
  int meta = event.world.getBlockMetadata(x, y, z);
  if (ConfigHandler.allowCropRC && event.action == Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.getHeldItem() == null || !event.entityPlayer.isSneaking())) {
    for (PlantInfo info : plants) {
      if (info.blockInst == block && meta == info.meta) {
        if (event.world.isRemote) {
          event.entityPlayer.swingItem();
        } else {
          currentPlant = info;
          block.dropBlockAsItem(event.world, x, y, z, meta, 0);
          currentPlant = null;
          event.world.setBlockMetadataWithNotify(x, y, z, info.resetMeta, 3);
          event.setCanceled(true);
        }
        break;
      }
    }
  }
}
项目:TechNodefirmacraftMod    文件:PlayerInteractHandler.java   
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.entityPlayer.worldObj.isRemote)
        return;

    ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();
    if (itemInHand == null) {
        return;
    }
    //Disable interaction between Mek and OpenBlock tanks and TFC Barrels or Vessels **Dupe bug***
    boolean validAction = event.action == Action.RIGHT_CLICK_BLOCK;

    if(validAction) {
        Block target = event.world.getBlock(event.x, event.y, event.z);
        if (target == TFCBlocks.barrel || target == TFCBlocks.vessel) {
            String name = itemInHand.getUnlocalizedName();
            if (name.contains("tile.openblocks.tank") || name.contains("tile.MachineBlock2.PortableTank") ||
                    name.contains("ImmersiveEngineering.drill") || name.contains("ImmersiveEngineering.chemthrower")
                    || name.contains("ImmersiveEngineering.jerrycan") || name.contains("MachineBlock2")){
                event.setCanceled(true);
                return;
            }
        }
    }
}
项目:Et-Futurum    文件:GrassPath.java   
public static void onPlayerInteract(PlayerInteractEvent event) {
    if (EtFuturum.enableGrassPath)
        if (event.entityPlayer != null) {
            World world = event.entityPlayer.worldObj;
            if (event.action == Action.RIGHT_CLICK_BLOCK)
                if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) {
                    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
                    if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) {
                        world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path);
                        event.entityPlayer.swingItem();
                        stack.damageItem(1, event.entityPlayer);
                        world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
                    }
                }
        }
}
项目:ThaumicEnergistics    文件:ItemFocusAEWrench.java   
/**
 * Called when the player left-clicks
 */
@Override
public boolean onEntitySwing( final EntityLivingBase entity, final ItemStack wandStack )
{
    // Is the entity a player?
    if( entity instanceof EntityPlayer )
    {
        // Cast to player
        EntityPlayer player = (EntityPlayer)entity;

        // Ray trace
        MovingObjectPosition position = this.getMovingObjectPositionFromPlayer( player.worldObj, player, true );

        // Was a block hit?
        if( ( position != null ) && ( position.typeOfHit == MovingObjectType.BLOCK ) )
        {
            // Use the focus
            return this.onUse( player.worldObj, player, position, wandStack, Action.LEFT_CLICK_BLOCK );
        }
    }

    return false;

}
项目:MyTown2    文件:ProtectionHandlers.java   
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent ev) {
    if(ev.entity.worldObj.isRemote || ev.isCanceled()) {
        return;
    }
    int x = (int) Math.floor(ev.target.posX);
    int y = (int) Math.floor(ev.target.posY);
    int z = (int) Math.floor(ev.target.posZ);

    Resident res = MyTownUniverse.instance.getOrMakeResident(ev.entityPlayer);
    ProtectionManager.checkInteraction(ev.target, res, ev);
    if(!ev.isCanceled() && ev.entityPlayer.getHeldItem() != null) {
        BlockPos bp = new BlockPos(x, y, z, ev.target.dimension);
        ProtectionManager.checkUsage(ev.entityPlayer.getHeldItem(), res, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, bp, -1, ev);
    }
}
项目:Gizmos    文件:ForgeEventHandler.java   
@SubscribeEvent
public void onInteract(PlayerInteractEvent pie){
    if(pie.action==Action.RIGHT_CLICK_BLOCK) {
        ItemStack i=pie.entityPlayer.getCurrentEquippedItem();

        if(i!=null && i.getItem().equals(Items.flint_and_steel)){
            PortalHandler.establishPortal(pie.world, pie.x, pie.y, pie.z, pie.face);
        }

        if(Properties.enableSimpleSetSpawn 
                && pie.world instanceof WorldServer
                && pie.world.getBlock(pie.x, pie.y, pie.z)==Blocks.bed) {
            ChunkCoordinates bedPosition=new ChunkCoordinates(pie.x, pie.y, pie.z);
            pie.entityPlayer.setSpawnChunk(bedPosition, false);
            pie.entityPlayer.addChatComponentMessage(new ChatComponentText("Spawn reset to ("+pie.x+", "+pie.y+", "+pie.z+")"));            }
    }
}
项目:Open-Exchange    文件:ItemBlockManipulator.java   
@SubscribeEvent
public void onPlayerInteractEvent(PlayerInteractEvent event) {
  if (Util.isClientSide()) {
    if (event.action != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    EntityPlayer player = event.entityPlayer;
    if (player == null) {
      return;
    }
    if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBlockManipulator) || player.getHeldItem().stackTagCompound == null || !(player.getHeldItem().getItem() instanceof OEItemInterface)) {
      return;
    }
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setInteger("x", event.x);
    nbt.setInteger("y", event.y);
    nbt.setInteger("z", event.z);
    nbt.setInteger("face", event.face);// Bottom = 0, Top = 1, Sides = 2-5
    NetworkUtil.sendToServer(Channel.BlockManipulater, nbt);
    event.setCanceled(true);
  }
}
项目:PneumaticCraft    文件:CoordTrackUpgradeHandler.java   
@SubscribeEvent
public boolean onPlayerInteract(PlayerInteractEvent event){
    if(event.action == Action.RIGHT_CLICK_BLOCK && isListeningToCoordTrackerSetting) {
        isListeningToCoordTrackerSetting = false;
        ForgeDirection dir = ForgeDirection.getOrientation(event.face);
        reset();
        ItemStack stack = event.entityPlayer.getCurrentArmor(3);
        if(stack != null) {
            NBTTagCompound tag = NBTUtil.getCompoundTag(stack, "CoordTracker");
            tag.setInteger("dimID", event.entity.worldObj.provider.dimensionId);
            tag.setInteger("x", event.x + dir.offsetX);
            tag.setInteger("y", event.y + dir.offsetY);
            tag.setInteger("z", event.z + dir.offsetZ);
        }
        NetworkHandler.sendToServer(new PacketCoordTrackUpdate(event.entity.worldObj, event.x + dir.offsetX, event.y + dir.offsetY, event.z + dir.offsetZ));
    }
    return false;
}
项目:ThaumOres    文件:TOEvents.java   
@SubscribeEvent
public void eventPlayerInteractEvent(PlayerInteractEvent event) {
    World world = event.world;
    int x = event.x;
    int y = event.y;
    int z = event.z;
    EntityPlayer player = event.entityPlayer;
    if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) {
        if (TOConfig.debugEnable && TOConfig.debugScanner && !world.isRemote
                && event.action.equals(Action.RIGHT_CLICK_BLOCK) && player.capabilities.isCreativeMode) {
            int radius = TOConfig.debugRemoverScannerRadius;
            int[] counter = new int[] { 0, 0, 0, 0, 0, 0 };
            for (int xx = x - radius; xx < x + radius; xx++)
                for (int zz = z - radius; zz < z + radius; zz++)
                    for (int yy = 0; yy < 257; yy++)
                        if ((world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre)
                                && world.getBlockMetadata(xx, yy, zz) < 6)
                            counter[world.getBlockMetadata(xx, yy, zz)]++;
            String text = "[DEBUG " + ThaumOresMod.NAME + "] Scanned blocks at " + x + ";" + z + " with radius "
                    + radius;
            for (int meta = 0; meta < 6; meta++)
                text += "\n Count ores with meta " + meta + " = " + counter[meta];
            for (String string : text.split("\n")) {
                ThaumOresMod.log.info(string);
                player.addChatMessage(new ChatComponentText(string));
            }
        }
    }
}
项目:Pathways    文件:PlayerInteractEventHandler.java   
public static InteractionType getInteractionType(final PlayerInteractEvent event) {

            if (event.action != Action.RIGHT_CLICK_BLOCK)
                return Nothing;

            if(event.entityPlayer.capabilities.isCreativeMode) {
                final ItemStack held = event.entityPlayer.getHeldItem();
                if(held != null && held.getItem() == CONFIGURE_ITEM) {
                    return Configure;
                }
            }

            return Use;
        }
项目:Torchieeeeness    文件:TorchEventHandler.java   
@SubscribeEvent
    public void playerInteractEventHandler(PlayerInteractEvent event)
    {
//      if(event.world.isRemote)
//      {
            //generate the json file
//          generateJson();
            // get players held item
            ItemStack heldItem = event.entityPlayer.inventory.getCurrentItem();
            //Toggle mode on key press
            if(event.world.isRemote)
            {
                if (event.action == Action.RIGHT_CLICK_AIR && key.config.isPressed())
                {
                    //Load the json file
//                  load();
                    if(clientSetting != 3)
                        clientSetting++;
                    if(clientSetting >= 3)
                        clientSetting = 0;
                    event.entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("torchieeeeness_key" + clientSetting)));
                    // Save the json file
//                  save();
                    PacketHandler.INSTANCE.sendToServer(new MessageSettings(clientSetting));
                }
//          }
        }

        if(serverSetting != 0 && !(event.world.getTileEntity(event.x, event.y, event.z) instanceof TileEntity))
        {
            if(serverSetting == 1)
                placeAnything(event);
            if(serverSetting == 2)
                placeOnlyTorchs(event);
        }
    }
项目:FusionWarfare    文件:WrenchEvent.java   
@SubscribeEvent
public void onWrenchBlock(PlayerInteractEvent event) {

    if (!event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {

        EntityPlayer player = event.entityPlayer;
        ItemStack itemInHand = player.getCurrentEquippedItem();

        if (player.isSneaking() && itemInHand != null && itemInHand.getItem() == InitItems.wrench) {
            wrenchBlock(new Location(event.world, event.x, event.y, event.z), player);
        }
    }
}
项目:burlapcraft    文件:HandlerEvents.java   
@SubscribeEvent
public void placeBlockEvent(PlayerInteractEvent event) {
    EntityPlayer p = event.entityPlayer;
    if(event.action == Action.RIGHT_CLICK_BLOCK) {
        Block clickedBlock = HelperActions.getBlock(event.x, event.y, event.z);
        if (HelperActions.blockIsOneOf(clickedBlock, HelperActions.unbreakableBlocks) && event.y < p.posY) {
            List<HelperPos> blockPoss = new ArrayList<HelperPos>();
            blockPoss.add(new HelperPos(event.x, event.y + 1, event.z));
            blockPoss.add(new HelperPos(event.x, event.y, event.z + 1));
            blockPoss.add(new HelperPos(event.x, event.y, event.z - 1));
            blockPoss.add(new HelperPos(event.x + 1, event.y, event.z));
            blockPoss.add(new HelperPos(event.x - 1, event.y, event.z));

            for (HelperPos pos : blockPoss) {
                String key = pos.x + "," + pos.y + "," + pos.z;
                if (HelperActions.blockIsOneOf(HelperActions.getBlock(pos), HelperActions.mineableBlocks) && 
                        !MinecraftStateGeneratorHelper.blockNameMap.containsKey(key)) {
                    int blockID = HelperActions.getBlockId(pos.x, pos.y, pos.z);
                    ArrayList<String> blockNames = MinecraftStateGeneratorHelper.invBlockNameMap.get(blockID);
                    if (blockNames != null && blockNames.size() == 1) {
                        MinecraftStateGeneratorHelper.blockNameMap.put(key, blockNames.get(0));
                        MinecraftStateGeneratorHelper.invBlockNameMap.remove(blockID);
                    }
                    else {
                        if(blockNames != null) {
                            MinecraftStateGeneratorHelper.blockNameMap.put(key, blockNames.get(0));
                            blockNames.remove(0);
                        }
                    }
                    break;
                }
            }
        }
    }
}
项目:AdvancedRocketry    文件:PlanetEventHandler.java   
@SubscribeEvent
public void blockPlaceEvent(PlayerInteractEvent event) {
    ForgeDirection direction = ForgeDirection.getOrientation(event.face);
    if(!event.world.isRemote && Action.RIGHT_CLICK_BLOCK == event.action && event.entityPlayer != null  && AtmosphereHandler.getOxygenHandler(event.world.provider.dimensionId) != null &&
            !AtmosphereHandler.getOxygenHandler(event.world.provider.dimensionId).getAtmosphereType(event.x + direction.offsetX, event.y + direction.offsetY, event.z + direction.offsetZ).allowsCombustion()) {

        if(event.entityPlayer.getCurrentEquippedItem() != null) {
            if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.torch) && 
                    event.world.getBlock(event.x, event.y, event.z).isSideSolid(event.world, event.x, event.y, event.z, direction)) {
                event.setCanceled(true);
                event.world.setBlock(event.x + direction.offsetX, event.y + direction.offsetY, event.z + direction.offsetZ, AdvancedRocketryBlocks.blockUnlitTorch);
            }
            else if(zmaster587.advancedRocketry.api.Configuration.torchBlocks.contains(Block.getBlockFromItem(event.entityPlayer.getCurrentEquippedItem().getItem())) )
                event.setCanceled(true);
            else if(event.entityPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.fire_charge || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.blaze_powder || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.blaze_rod || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.lava_bucket)
                event.setCanceled(true);
        }
    }

    if(!event.world.isRemote && event.entityPlayer != null && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() == Items.bed && event.world.provider instanceof WorldProviderPlanet) {
        AdvancedRocketryItems.itemAstroBed.onItemUse( event.entityPlayer.getCurrentEquippedItem(),  event.entityPlayer,  event.entityPlayer.worldObj, event.x, event.y, event.z, event.face, 0, 0, 0);
        event.setCanceled(true);
    }

    if(!event.world.isRemote && event.entityPlayer != null && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(AdvancedRocketryBlocks.blockGenericSeat) && event.world.getBlock(event.x, event.y, event.z) == Blocks.tnt) {
        event.entityPlayer.triggerAchievement(ARAchivements.beerOnTheSun);
    }
}
项目:GlassWorks    文件:CropEvent.java   
@SubscribeEvent
public void PlayerRightClickEvent(PlayerInteractEvent event)
{
    if(ConfigHandler.allowCropFeature)
    {
        EntityPlayer player = event.entityPlayer;
        World world = event.world;
        Block crop = world.getBlock(event.x, event.y, event.z);
        int cropMeta = world.getBlockMetadata(event.x, event.y, event.z);
        int dropRate = event.world.rand.nextInt(3) + 1;
        ItemStack drops = new ItemStack(crop.getItemDropped(cropMeta, event.world.rand, Short.MAX_VALUE), dropRate);


        if(player.getCurrentEquippedItem() == null && event.action == Action.RIGHT_CLICK_BLOCK && crop != null)
        {   
            if(crop instanceof BlockCrops && cropMeta >= 7)
            {
                event.entityPlayer.swingItem();
                if(!world.isRemote)
                {
                    EntityItem droppedItem = new EntityItem(world, event.x, event.y, event.z, drops);
                    world.setBlockMetadataWithNotify(event.x, event.y, event.z, 0, 3);
                    world.spawnEntityInWorld(droppedItem);
                }
            }
        }
    }
}
项目:AntiqueAtlasApiExample    文件:CustomTilePlacer.java   
@SubscribeEvent
public void onPlayerRightClickBlock(PlayerInteractEvent event) {
    if (!event.entity.worldObj.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {
        AtlasAPI.getTileAPI().putCustomGlobalTile(event.entity.worldObj,
                customTileName, event.x >> 4, event.z >> 4);
    }
}
项目:copycore    文件:TweakDoubleDoorInteraction.java   
@SubscribeEvent(priority=EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
    BlockDoor door = (BlockDoor)Blocks.wooden_door;
    BlockLocation loc = BlockLocation.get(event.world, event.x, event.y, event.z);

    if ((event.action != Action.RIGHT_CLICK_BLOCK) ||
        event.entityPlayer.isSneaking() ||
        !(loc.getBlock() == door)) return;

    int direction = getDoorOrientation(door, loc);
    boolean isOpen = isDoorOpen(door, loc);
    boolean isMirrored = isDoorMirrored(door, loc);

    int i = (isMirrored ? -1 : 1);
    switch (direction) {
        case 0: loc = loc.relative(0, 0,  i); break;
        case 1: loc = loc.relative(-i, 0, 0); break;
        case 2: loc = loc.relative(0, 0, -i); break;
        case 3: loc = loc.relative( i, 0, 0); break;
    }

    if ((loc.getBlock() == door) &&
        (getDoorOrientation(door, loc) == direction) &&
        (isDoorOpen(door, loc) == isOpen) &&
        (isDoorMirrored(door, loc) != isMirrored))
        door.onBlockActivated(loc.world, loc.x, loc.y, loc.z, event.entityPlayer, event.face, 0, 0, 0);
}
项目:Chisel    文件:ChiselEventHandler.java   
@SubscribeEvent
public void playerInteract(PlayerInteractEvent event) {
    if (event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) {
        if (placing.get() != null)
            return;//for mods that do dumb stuff and call this event like MFR
        placing.set(event);
        if (place(event.entityPlayer, event.entityPlayer.worldObj))
            event.setCanceled(true);
        placing.set(null);
    }
}
项目:ThaumicEnergistics    文件:ItemFocusAEWrench.java   
/**
 * Called when the player right-clicks
 */
@Override
public ItemStack onFocusRightClick( final ItemStack wandStack, final World world, final EntityPlayer player, final MovingObjectPosition position )
{

    // Was a block hit?
    if( ( position != null ) && ( position.typeOfHit == MovingObjectType.BLOCK ) )
    {
        // Use the focus
        this.onUse( world, player, position, wandStack, Action.RIGHT_CLICK_BLOCK );
    }

    return wandStack;
}
项目:MyTown2    文件:ProtectionHandlers.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onAE2PartPlace(AE2PartPlaceEvent ev) {
    if (ev.world.isRemote || ev.isCanceled()) {
        return;
    }

    Resident res = MyTownUniverse.instance.getOrMakeResident(ev.player);
    if(ev.player.getHeldItem() != null) {
        ProtectionManager.checkUsage(ev.player.getHeldItem(), res, Action.RIGHT_CLICK_BLOCK, new BlockPos(ev.x, ev.y, ev.z, ev.world.provider.dimensionId), ev.face, ev);
    }
}
项目:MyTown2    文件:ProtectionHandlers.java   
private BlockPos createBlockPos(PlayerInteractEvent ev) {
    int x, y, z;

    if (ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
        x = (int) Math.floor(ev.entityPlayer.posX);
        y = (int) Math.floor(ev.entityPlayer.posY);
        z = (int) Math.floor(ev.entityPlayer.posZ);
    } else {
        x = ev.x;
        y = ev.y;
        z = ev.z;
    }
    return new BlockPos(x, y, z, ev.world.provider.dimensionId);
}
项目:Cauldron    文件:NetHandlerPlayServer.java   
public void processUseEntity(C02PacketUseEntity p_147340_1_)
{
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    Entity entity = p_147340_1_.func_149564_a(worldserver);
    this.playerEntity.func_143004_u();

    if (entity != null)
    {
        boolean flag = this.playerEntity.canEntityBeSeen(entity);
        double d0 = 36.0D;

        if (!flag)
        {
            d0 = 9.0D;
        }

        if (this.playerEntity.getDistanceSqToEntity(entity) < d0)
        {
            if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.INTERACT)
            {
                this.playerEntity.interactWith(entity);
            }
            else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK)
            {
                if (entity instanceof EntityItem || entity instanceof EntityXPOrb || entity instanceof EntityArrow || entity == this.playerEntity)
                {
                    this.kickPlayerFromServer("Attempting to attack an invalid entity");
                    this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " tried to attack an invalid entity");
                    return;
                }

                this.playerEntity.attackTargetEntityWithCurrentItem(entity);
            }
        }
    }
}
项目:IceAndShadow2    文件:NyxEventHandlerCold.java   
@SubscribeEvent
public void onPlayerTriesToStartFires(PlayerInteractEvent e) {
    if (e.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
        return;
    if (e.entityPlayer.dimension == IaSFlags.dim_nyx_id && !e.entityPlayer.capabilities.isCreativeMode) {

        boolean flaque = false;
        if (e.entityPlayer.getEquipmentInSlot(0) == null)
            return;

        Object id = e.entityPlayer.getEquipmentInSlot(0).getItem();
        if (id == Items.flint_and_steel) {
            flaque = true;
        } else if (id == Items.fire_charge) {
            flaque = true;
        } else if (id instanceof ItemBlock) {
            id = ((ItemBlock) id).field_150939_a;
            if (id == Blocks.fire) {
                flaque = true;
            } else if (id == Blocks.torch) {
                flaque = true;
            }
        }

        // DO NOT SIMPLIFY!
        if (flaque && !e.isCanceled()) {
            e.setCanceled(true);
            if (id == Blocks.torch) {
                IaSPlayerHelper.messagePlayer(e.entityPlayer, "It's far too cold to light a torch in Nyx.");
            } else {
                IaSPlayerHelper.messagePlayer(e.entityPlayer, "It's far too cold to start a fire that way in Nyx.");
            }
        }
    }

}
项目:IceAndShadow2    文件:NyxEventHandlerCold.java   
@SubscribeEvent
public void onPlayerTriesToUseFurnace(PlayerInteractEvent e) {
    if (e.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
        return;
    if (e.entityPlayer.dimension == IaSFlags.dim_nyx_id && !e.entityPlayer.capabilities.isCreativeMode) {
        final Block bl = e.world.getBlock(e.x, e.y, e.z);
        if (bl instanceof BlockFurnace || e.world.getTileEntity(e.x, e.y, e.x) instanceof TileEntityFurnace) {
            e.setCanceled(true);
            IaSPlayerHelper.messagePlayer(e.entityPlayer,
                    "It's too cold to light that furnace here. Find another way to smelt.");
        }
    }
}
项目:IceAndShadow2    文件:NyxEventHandlerCold.java   
@SubscribeEvent
public void onTryToPlant(PlayerInteractEvent e) {
    if (e.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
        return;
    if (e.entity.dimension == IaSFlags.dim_nyx_id && !e.entityPlayer.capabilities.isCreativeMode) {
        boolean isplant = false;
        final ItemStack ite = e.entityPlayer.getEquipmentInSlot(0);
        if (ite == null)
            return;
        if (ite.getItem() instanceof IPlantable) {
            isplant = true;
        } else if (ite.getItem() instanceof ItemBlock)
            if (((ItemBlock) ite.getItem()).field_150939_a instanceof IPlantable) {
                isplant = true;
            }

        // DO NOT SIMPLIFY!
        if (isplant && !e.isCanceled()) {
            final boolean dirt = e.world.getBlock(e.x, e.y, e.z) == NyxBlocks.dirt;
            ForgeDirection.getOrientation(e.face);
            e.setCanceled(!dirt);
            if (!dirt) {
                IaSPlayerHelper.messagePlayer(e.entityPlayer, "There's no way that this will grow in this realm.");
            }
        }
    }
}
项目:TeamCore    文件:PlayerEvent.java   
@ForgeSubscribe
public void playerInteract(PlayerInteractEvent event) {
    if (event.action == Action.RIGHT_CLICK_BLOCK) {
        int id = event.entityPlayer.worldObj.getBlockId(event.x, event.y, event.z);
        if (id == TeamConfig.teamSelectionId) {
            int meta = event.entityPlayer.worldObj.getBlockMetadata(event.x, event.y, event.z);
            if (listener != null) {
                listener.interact(event.entityPlayer, meta, event.x, event.y, event.z);
            }
        }
    }
}
项目:MinesweeperMod    文件:ForgeEventHandler.java   
/**
 * Used to open a Minesweeper block in creative, when the player is holding a (vanilla) sword.
 * @param event
 */
@SubscribeEvent
public void onPlayerClick(PlayerInteractEvent event){
    EntityPlayer player = event.entityPlayer;
    if (player.capabilities.isCreativeMode) {
        if (isSword(player.getCurrentEquippedItem())) {
        Block block = player.worldObj.getBlock(event.x, event.y, event.z);
        if(event.action == Action.LEFT_CLICK_BLOCK && block == MinesweeperMod.blockMinesweeper) {
            block.onBlockClicked(player.worldObj, event.x, event.y, event.z, player);
            event.setCanceled(true);
        }
        }
    }
}
项目:PneumaticCraft    文件:FMPPlacementListener.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void playerInteract(PlayerInteractEvent event){
    if(!Config.convertMultipartsToBlocks && event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) {
        if(placing.get() != null) return;//for mods that do dumb stuff and call this event like MFR
        placing.set(event);
        if(place(event.entityPlayer, event.entityPlayer.worldObj)) event.setCanceled(true);
        placing.set(null);
    }
}
项目:mobycraft    文件:MainCommand.java   
@SubscribeEvent
public void containerWand(PlayerInteractEvent event) {
    EntityPlayer player = event.entityPlayer;

    if (!event.action.equals(Action.RIGHT_CLICK_BLOCK)
            && !event.action.equals(Action.LEFT_CLICK_BLOCK)) {
        return;
    }

    if (player.getHeldItem() == null
            || player.getHeldItem().getItem() != Mobycraft.container_wand) {
        return;
    }

    sender = player;
    World world = event.world;
    BlockPos pos = event.pos;

    if (world.getBlockState(pos).getBlock() != Blocks.wall_sign
            && world.getBlockState(pos).getBlock() != Blocks.standing_sign) {
        return;
    }

    TileEntitySign sign = (TileEntitySign) world.getTileEntity(pos);

    if (!sign.signText[0].getUnformattedText().contains("Name:")) {
        return;
    }

    String name = sign.signText[1].getUnformattedText().concat(
            sign.signText[2].getUnformattedText().concat(
                    sign.signText[3].getUnformattedText()));


    Container container = listCommands.getWithName(name);

    if (container == null) {
        return;
    }

    lifecycleCommands.removeContainer(container.getId());
    sendConfirmMessage("Removed container with name \"" + name + "\"");

    buildCommands.updateContainers(false);
}
项目:TRHS_Club_Mod_2016    文件:ForgeEventFactory.java   
@Deprecated
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face)
{
    return onPlayerInteract(player, action, x, y, z, face, null);
}
项目:TRHS_Club_Mod_2016    文件:ForgeEventFactory.java   
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face, World world)
{
    PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face, world);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
项目:FissionWarfare    文件:SecurityEvent.java   
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {

    if (!event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {

        TileEntity tileEntity = event.world.getTileEntity(event.x, event.y, event.z);

        if (tileEntity instanceof ISecurity) {

            ISecurity security = (ISecurity) tileEntity;

            security.getSecurityProfile().cleanTeam(event.world);

            if (!security.getSecurityProfile().isSameTeam(event.entityPlayer) && !event.entityPlayer.capabilities.isCreativeMode) {

                ChatUtil.printFWMessage(EnumChatFormatting.RED, "This unit doesn't belong to you!", event.entityPlayer);
                event.setCanceled(true);
            }
        }
    }
}
项目:TerrafirmaPunk-Tweaks    文件:PlayerInteractionHandler.java   
@SubscribeEvent
public void onBlockPlaced(PlayerInteractEvent event)
{
    if (event.entityPlayer.worldObj.isRemote)
        return;

    ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();

    if(itemInHand == null)
        return;

    if(event.action == Action.RIGHT_CLICK_BLOCK && event.getResult() != Result.DENY)
    {
        if(Loader.isModLoaded("Steamcraft"))
        {
            if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(SteamcraftBlocks.boiler) && ConfigSettings.FSPBoilerWaterFix)
            {
                event.setCanceled(true);
                handleBlockPlacement(event.entityPlayer, event.entityLiving, event.world, TFPBlocks.tweakedboiler, event.x, event.y, event.z, event.face);
            }           
            else if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(SteamcraftBlocks.flashBoiler) && ConfigSettings.FSPFlashBoilerWaterFix)
            {
                event.setCanceled(true);
                switch(event.face)
                {
                    case 0: PlaceBlock(event.entityLiving, event.world, event.x, event.y - 1, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
                    case 1: PlaceBlock(event.entityLiving, event.world, event.x, event.y + 1, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
                    case 2: PlaceBlock(event.entityLiving, event.world, event.x, event.y, event.z - 1, TFPBlocks.tweakedFlashBoiler, 0); break;
                    case 3: PlaceBlock(event.entityLiving, event.world, event.x, event.y, event.z + 1, TFPBlocks.tweakedFlashBoiler, 0); break;
                    case 4: PlaceBlock(event.entityLiving, event.world, event.x - 1, event.y, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
                    case 5: PlaceBlock(event.entityLiving, event.world, event.x + 1, event.y, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
                    default: break;
                }           

                if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
                    event.entityPlayer.setCurrentItemOrArmor(0, null);
                else
                    event.entityPlayer.getCurrentEquippedItem().stackSize--;
            }
        }

        if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.chest))
        {
            event.setCanceled(true);

            if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
                event.entityPlayer.setCurrentItemOrArmor(0, null);
            else
                event.entityPlayer.getCurrentEquippedItem().stackSize--;
        }
    }
}
项目:CauldronGit    文件:ForgeEventFactory.java   
@Deprecated
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face)
{
    return onPlayerInteract(player, action, x, y, z, face, null);
}
项目:CauldronGit    文件:ForgeEventFactory.java   
public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face, World world)
{
    PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face, world);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
项目:CivCraft    文件:EventListner.java   
@SubscribeEvent
public void blockRightClicked(PlayerInteractEvent event) {
    if (event.action != Action.RIGHT_CLICK_BLOCK)
        return;
    CraftUtils.addPlayerToChunk(event.world, event.pos, event.entityPlayer);
}
项目:FusionWarfare    文件:SecurityEvent.java   
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {

    if (!event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {

        TileEntity tileEntity = event.world.getTileEntity(event.x, event.y, event.z);

        if (tileEntity instanceof ISecurity) {

            ISecurity security = (ISecurity) tileEntity;

            if (event.world.getTileEntity(event.x, event.y - 1, event.z) instanceof TileEntityReinforcedDoor) {

                onPlayerInteract(new PlayerInteractEvent(event.entityPlayer, event.action, event.x, event.y - 1, event.z, event.face, event.world));
            }

            if (!security.isSameTeam(event.entityPlayer.getTeam())) {

                event.entityPlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This unit doesn't belong to you!"));
                event.setCanceled(true);
            }
        }
    }
}
项目:Minestrappolation-4    文件:CEventHandler.java   
@SubscribeEvent(priority = EventPriority.HIGH)
@SideOnly(Side.SERVER)
public void chunksterInteract(PlayerInteractEvent event)
{

    if (event.action == Action.RIGHT_CLICK_BLOCK)
    {
        if (ChunkProtector.isChunkOwned(event.world.getChunkFromBlockCoords(event.pos).xPosition,
                                        event.world.getChunkFromBlockCoords(event.pos).zPosition))
        {
            if (!ChunkProtector
                     .canEditChunk(event.entityPlayer, event.world.getChunkFromBlockCoords(event.pos).xPosition,
                                   event.world.getChunkFromBlockCoords(event.pos).zPosition))
            {
                if (ChunkProtector.getProtectionData(event.world.getChunkFromBlockCoords(event.pos).xPosition,
                                                     event.world.getChunkFromBlockCoords(
                                                         event.pos).zPosition).redstoneUseable)
                {
                    Block block = event.world.getBlockState(event.pos).getBlock();
                    if (block == Blocks.lever || block instanceof BlockDoor || block instanceof BlockButton)
                    {

                    }
                    else
                    {
                        event.setCanceled(true);
                        event.entityPlayer.addChatMessage(
                            new ChatComponentText("�cThis chunk is owned by " + ChunkProtector.getProtectionData(
                                event.world.getChunkFromBlockCoords(event.pos).xPosition,
                                event.world.getChunkFromBlockCoords(event.pos).zPosition).owner));
                    }
                }
                else
                {
                    event.setCanceled(true);
                    event.entityPlayer.addChatMessage(
                        new ChatComponentText("�cThis chunk is owned by " + ChunkProtector.getProtectionData(
                            event.world.getChunkFromBlockCoords(event.pos).xPosition,
                            event.world.getChunkFromBlockCoords(event.pos).zPosition).owner));
                }
            }
        }
    }
}
项目:ModJam4    文件:HarkenEvents.java   
private boolean actionWasRightClick(Action action) {
    return (action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK);
}