當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。