当前位置: 首页>>代码示例>>Java>>正文


Java PlayerInteractEvent.LeftClickBlock方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.LeftClickBlock方法的具体用法?Java PlayerInteractEvent.LeftClickBlock怎么用?Java PlayerInteractEvent.LeftClickBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.LeftClickBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: playerLeftClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void playerLeftClick(PlayerInteractEvent.LeftClickBlock event) {
	if (!event.getEntityPlayer().capabilities.isCreativeMode && event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockDoor && event.getWorld().getBlockState(event.getPos()).getMaterial() == Material.WOOD) {
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1);
	}
	
	if (!event.getEntityPlayer().capabilities.isCreativeMode && event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockDoor && event.getWorld().getBlockState(event.getPos()).getMaterial() == Material.IRON) {
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
		event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
	}
}
 
开发者ID:Zundrel,项目名称:How-Bout-That-Furniture,代码行数:19,代码来源:FurnitureEventHandler.java

示例2: interaction

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void interaction(
        final PlayerInteractEvent.LeftClickBlock event )
{
    if (BitDrawers.config.debugTrace) {
        Vec3d vec = event.getHitVec();
        BDLogger.info("Left Click %s %s %f %f %f", resultToString(event.getUseItem()), resultToString(event.getUseBlock()), vec.xCoord, vec.yCoord, vec.zCoord);
    }
    if ( event.getEntityPlayer() != null && event.getUseItem() != Event.Result.DENY )
    {
        final ItemStack is = event.getItemStack();
        if ( is != null && (is.getItem() instanceof ItemChiseledBit) && event.getWorld().isRemote)
        {
            Block target = event.getWorld().getBlockState(event.getPos()).getBlock();
            if (target instanceof BlockBitDrawers) {
                target.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
            }
            if (BitDrawers.config.debugTrace)
                BDLogger.info("Bit Left Click");
        }
    }
}
 
开发者ID:Belgabor,项目名称:DrawersBits,代码行数:23,代码来源:PlayerEventHandler.java

示例3: onHit

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
  EntityPlayer player = event.getEntityPlayer();
  ItemStack held = player.getHeldItem(event.getHand());
  if (held.getItem() == this) {
    //did we turn it off? is the visible timer still going?
    if (ActionType.getTimeout(held) > 0) {
      return;
    }
    ActionType.setTimeout(held);
    event.setCanceled(true);
    UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS, 0.1F);
    if (!player.getEntityWorld().isRemote) { // server side
      ActionType.toggle(held);
      UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:19,代码来源:BaseItemChargeScepter.java

示例4: onHit

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
  EntityPlayer player = event.getEntityPlayer();
  ItemStack held = player.getHeldItem(event.getHand());
  if (held != null && held.getItem() == this) {
    if (ActionType.getTimeout(held) > 0) {
      //without a timeout, this fires every tick. so you 'hit once' and get this happening 6 times
      return;
    }
    ActionType.setTimeout(held);
    event.setCanceled(true);
    UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS);
    if (!player.getEntityWorld().isRemote) { // server side
      ActionType.toggle(held);
      UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:19,代码来源:ItemRandomizer.java

示例5: onHit

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
  EntityPlayer player = event.getEntityPlayer();
  ItemStack held = player.getHeldItem(event.getHand());
  if (held != null && held.getItem() == this) {
    //did we turn it off? is the visible timer still going?
    if (ActionType.getTimeout(held) > 0) {
      return;
    }
    ActionType.setTimeout(held);
    event.setCanceled(true);
    UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS, 0.3F);
    if (!player.getEntityWorld().isRemote) { // server side
      ActionType.toggle(held);
      UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:19,代码来源:ItemPlayerLauncher.java

示例6: onHit

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
  EntityPlayer player = event.getEntityPlayer();
  ItemStack held = player.getHeldItem(event.getHand());
  if (!held.isEmpty() && held.getItem() == this) {
    if (ActionType.getTimeout(held) > 0) {
      //without a timeout, this fires every tick. so you 'hit once' and get this happening 6 times
      return;
    }
    ActionType.setTimeout(held);
    event.setCanceled(true);
    UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS);
    if (!player.getEntityWorld().isRemote) { // server side
      ActionType.toggle(held);
      UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:19,代码来源:ItemBuildSwapper.java

示例7: onLeftClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
  BlockPos pos = event.getPos();
  World world = event.getWorld();
  EntityPlayer player = event.getEntityPlayer();
  ItemStack stack = event.getItemStack();//    ItemStack stack = player.getHeldItem(event.getHand());
  if (player.isSneaking() == false && world.getTileEntity(pos) instanceof TileEntityVector
      && stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockVectorPlate) {
    IBlockState iblockstate = world.getBlockState(pos);
    Block block = iblockstate.getBlock();
    TileEntityVector tile = (TileEntityVector) world.getTileEntity(pos);
    if (stack.hasTagCompound()) {
      ((BlockVectorPlate) block).saveStackDataTotile(stack, tile);
      if (world.isRemote)
        UtilChat.addChatMessage(player, "tile.plate_vector.copied");
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:19,代码来源:BlockVectorPlate.java

示例8: onLeftClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
{
    EntityPlayer player = event.getEntityPlayer();
    
    if(player == null) return;
    
    ItemStack stackIn = event.getItemStack();
    if (stackIn == null || stackIn.isEmpty() || !(stackIn.getItem() instanceof PlacementItem)) return;

    PlacementResult result = PlacementHandler.doLeftClickBlock(player, event.getPos(), event.getFace(), event.getHitVec(), stackIn);
    
    if(!result.shouldInputEventsContinue())
    {
        result.apply(stackIn, player);
        event.setCanceled(true);
    }
}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:19,代码来源:CommonEventHandler.java

示例9: onLeftClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
{
    ItemStack is = ItemInstrument.getUsableInstrument(event.getEntityPlayer());
    if(!is.isEmpty() && !(!event.getEntityPlayer().getHeldItemMainhand().isEmpty() && !event.getEntityPlayer().getHeldItemOffhand().isEmpty()))
    {
        stopPlayingTrack(event.getEntityPlayer());
    }
}
 
开发者ID:iChun,项目名称:Clef,代码行数:10,代码来源:EventHandlerClient.java

示例10: stopUsing

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void stopUsing(PlayerInteractEvent.LeftClickBlock event) {
	if (!TF2Util.canInteract(event.getEntityLiving())) {
		event.setCanceled(true);
	}
	event.getEntityPlayer().removePotionEffect(TF2weapons.charging);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:8,代码来源:TF2EventsCommon.java

示例11: onInteractLeftClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onInteractLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
{
	if (event.getEntityPlayer() != null)
	{
		if (event.getEntityPlayer().isPotionActive(ExPPotions.stunned))
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:12,代码来源:ExPHandlerServer.java

示例12: cancelLeftClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void cancelLeftClick(final PlayerInteractEvent.LeftClickBlock event) {
    if (EventHandler.blockClickEvent) {
    	EventHandler.blockClickEvent = false;
        event.setUseBlock(Event.Result.DENY);
    }
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:8,代码来源:EventHandler.java

示例13: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
    // Disallow creating or destroying events in the player structure:
    if (event instanceof PlayerInteractEvent.LeftClickBlock)
    {
        // Destroy block
        if (blockInBounds(event.getPos(), this.sourceBounds))
            event.setCanceled(true);
    }
    else if (event instanceof PlayerInteractEvent.RightClickBlock)
    {
        // Place block - need to work out *where* the block would be placed.
        // This code was cribbed from ItemBlock.onItemUse()
        IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
        Block block = iblockstate.getBlock();
        EnumFacing side = event.getFace();
        BlockPos pos = event.getPos();
        if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
        {
            side = EnumFacing.UP;
        }
        else if (!block.isReplaceable(event.getWorld(), pos))
        {
            pos = pos.offset(side);
        }
        if (blockInBounds(pos, this.sourceBounds))
            event.setCanceled(true);
    }
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:31,代码来源:BuildBattleDecoratorImplementation.java

示例14: onINteractOnAir

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onINteractOnAir(PlayerInteractEvent.LeftClickBlock e) {
    if (e.getEntityLiving() instanceof EntityPlayer) {
        if (!e.getEntityLiving().getCapability(ITrigger_item_Provider.TRIGGER_ITEM, null).getInteraction()) {

            e.setCanceled(true);
            e.setUseBlock(Event.Result.DENY);
            e.setUseItem(Event.Result.DENY);
        }
    }
}
 
开发者ID:Hoijima,项目名称:Fallout_Equestria,代码行数:12,代码来源:CommonEventHandler.java

示例15: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent.LeftClickBlock event){
    EntityPlayer player = event.getEntityPlayer();
    for(int i = 0; i < player.inventory.getSizeInventory(); i++){
        ItemStack stack = player.inventory.getStackInSlot(i);
        if(stack != null && stack.getItem() instanceof ItemToolbelt){
            ItemToolbelt.selectBestTool(player, i);
            return;
        }
    }
}
 
开发者ID:KodyJKing,项目名称:RandomToolKit,代码行数:12,代码来源:ModEvents.java


注:本文中的net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。