當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerInteractEvent.setCanceled方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInteractEvent.setCanceled方法的具體用法?Java PlayerInteractEvent.setCanceled怎麽用?Java PlayerInteractEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.setCanceled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void playerInteract(PlayerInteractEvent event) {
	// System.out.println(event.toString());
	// System.out.println("PlayerInteractEvent,HandType="+event.getHand()+",PlayerAciveHand="+event.getEntityPlayer().getActiveHand());
	if (event.isCancelable() && event.getEntityPlayer().getEntityData().hasKey("renderViewCamera")) {
		event.setCanceled(true);
		return;
	}
	/*
	 * if(event instanceof
	 * PlayerInteractEvent.EntityInteract&&((PlayerInteractEvent.
	 * EntityInteract) event).getTarget() instanceof EntityTripod){ Entity
	 * target=((PlayerInteractEvent.EntityInteract) event).getTarget();
	 * EntityPlayer player =event.getEntityPlayer(); if
	 * (!player.isSneaking()) { if (player.getEntityWorld().isRemote) {
	 * System.out.println("123");
	 * Minecraft.getMinecraft().setRenderViewEntity(target); }
	 * player.getEntityData().setInteger("renderViewCamera",
	 * target.getEntityId()); }else{
	 * player.getEntityData().setInteger("usingGui", target.getEntityId());
	 * player.openGui(MineCamera.instance,
	 * GuiElementLoader.GUI_TRIPOD_CAMERA, target.getEntityWorld(),
	 * (int)target.posX, (int)target.posY, (int)target.posZ); } }
	 */
}
 
開發者ID:PorPit,項目名稱:MineCamera,代碼行數:26,代碼來源:EventLoader.java

示例2: dueProcess

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
private void dueProcess(PlayerInteractEvent event, BiFunction<RegionSelector<?, ?>, Vector3i, String> selector) {
    if (event.getWorld().isRemote) {
        // don't process on client
        // perhaps we can cancel on client if we do config sync
        return;
    }

    if (event.getItemStack().getItem() == HardVoxConfig.getSelectionWand()) {
        // cancel event, fire selection
        event.setCanceled(true);

        WorldServer ws = (WorldServer) event.getWorld();
        SessionManager.getInstance()
                .getSession(ws.getMinecraftServer(), event.getEntityPlayer())
                .performRegionCommand(sel -> selector.apply(sel, VecBridge.toFlow(event.getPos())));
        // send an update to the player so the block re-appears?
        ws.getPlayerChunkMap().markBlockForUpdate(event.getPos());
    }
}
 
開發者ID:kenzierocks,項目名稱:HardVox,代碼行數:20,代碼來源:SelectionListener.java

示例3: handleClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
private void handleClick(
		final PlayerInteractEvent e )
{
	final SupressionState current = getState( e.getEntityPlayer() ).get( e.getEntityPlayer() );

	if ( current == null || current.suppress == false )
	{
		// if nothing is set, or supression isn't on, then we don't care.
		return;
	}

	if ( current.hand == e.getHand() )
	{
		// if we here suppression is on, was it the correct hand?
		e.setCanceled( true );
	}
}
 
開發者ID:AlgorithmX2,項目名稱:Ambidextrous,代碼行數:18,代碼來源:EventPlayerInteract.java

示例4: removeMask

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void removeMask(PlayerInteractEvent event) {
    if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return;
    final EntityPlayer player = event.entityPlayer;
    if (player.worldObj.isRemote) return;
    if (!player.isSneaking()) return;
    if (player.getHeldItem() != null) return;
    final ItemStack helmet = player.getCurrentArmor(3);
    if (helmet == null || !(helmet.getItem() == this)) return;
    if (!isBowed(player)) return;

    player.setCurrentItemOrArmor(4, null);
    player.setCurrentItemOrArmor(0, helmet);
    event.setCanceled(true);
    Core.proxy.updatePlayerInventory(player); // Only seems necessary for removal specifically.
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:17,代碼來源:ItemMatrixProgrammer.java

示例5: onPlayerInteractEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onPlayerInteractEvent(PlayerInteractEvent event) {
    ItemStack heldItem = event.entityPlayer.getHeldItem();
    if (heldItem == null || heldItem.getItem() == null) {
        return;
    }
    if (event.entityPlayer.isSneaking() && WrenchChecker.isAWrench(heldItem.getItem())) {
        // If the block is protected we prevent sneak-wrenching it.
        ProtectedBlocks protectedBlocks = ProtectedBlocks.getProtectedBlocks(event.world);
        BlockPos pos = event.pos;
        if (protectedBlocks != null && protectedBlocks.isProtected(event.world, pos)) {
            event.setCanceled(true);
        }
    }

}
 
開發者ID:romelo333,項目名稱:notenoughwands1.8.8,代碼行數:17,代碼來源:ForgeEventHandlers.java

示例6: handleCropRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@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;
      }
    }
  }
}
 
開發者ID:SleepyTrousers,項目名稱:EnderCore,代碼行數:23,代碼來源:RightClickCropHandler.java

示例7: playerInteractEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void playerInteractEvent(PlayerInteractEvent event) {
	if (event.world != null && event.pos != null) {
		nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact(
			WorldConverter.instance().toNova(event.world),
			VectorConverter.instance().toNova(event.pos),
			EntityConverter.instance().toNova(event.entityPlayer),
			nova.core.event.PlayerEvent.Interact.Action.values()[event.action.ordinal()]
		);

		Game.events().publish(evt);

		event.useBlock = Event.Result.values()[evt.useBlock.ordinal()];
		event.useItem = Event.Result.values()[evt.useItem.ordinal()];
		event.setCanceled(evt.isCanceled());
	}
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:18,代碼來源:ForgeEventHandler.java

示例8: use

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void use(PlayerInteractEvent event){
	ItemStack item = event.entityPlayer.getEquipmentInSlot(0);
	if(item == null)
		return;
	if(item.hasTagCompound())
		if(item.getTagCompound().hasKey("Fidelis"))
		{
			String fidelisID = item.getTagCompound().getString("Fidelis");
			if(event.entityPlayer.getGameProfile().getId().toString().equals(fidelisID))
				return;
			else if(fidelisID.equals(""))
			{
				item.getTagCompound().setString("Fidelis", event.entityPlayer.getGameProfile().getId().toString());
				item.getTagCompound().setString("FidelisDisplay", event.entityPlayer.getDisplayName());
			}
			else{
				event.setCanceled(true);
				event.useItem = Result.DENY;
			}
		}
}
 
開發者ID:UnderMybrella,項目名稱:Fidelis,代碼行數:23,代碼來源:Fidelis.java

示例9: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@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;
			}
		}
	}
}
 
開發者ID:AnodeCathode,項目名稱:TechNodefirmacraftMod,代碼行數:27,代碼來源:PlayerInteractHandler.java

示例10: interact

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void interact(PlayerInteractEvent evt){

	EntityPlayer p = evt.entityPlayer;
	PlayerRpgInventory inv = PlayerRpgInventory.get(p);
	ItemStack shield = inv.getShield();

	if(shield == null)
		return;

	ItemRpgInvArmor theShield = (ItemRpgInvArmor) shield.getItem();

	if(inv.isBlocking() && p.isSneaking()){
		evt.setResult(Result.DENY);
		evt.setCanceled(true);
	}
}
 
開發者ID:ArtixAllMighty,項目名稱:rpginventory,代碼行數:18,代碼來源:RPGEventHooks.java

示例11: onPlayerUsesBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
//make sure it gets trigered first to prevent handeling from other mods
public void onPlayerUsesBlock(PlayerInteractEvent event) {
	String key = "";
	if (event.world.isRemote)
		return;
	EntityPlayer player = event.entityPlayer;
	PlayerResearch research = PlayerResearch.get(player);
	if (player.getCurrentEquippedItem() != null)
		key = EurekaAPI.API.getKey(player.getCurrentEquippedItem());
	if (!research.isFinished(key) && !key.equals("")) {
		ItemStack stack = player.getCurrentEquippedItem().copy();
		stack.stackSize = 1;
		dropItems(event.world, event.x, event.y, event.z, EurekaAPI.API.getDrops(stack));
		if (event.entityPlayer.getCurrentEquippedItem().stackSize > 1)
			event.entityPlayer.getCurrentEquippedItem().stackSize--;
		else
			event.entityPlayer.destroyCurrentEquippedItem();
		event.setCanceled(true);
	}

	key = EurekaAPI.API.getKey(event.world.getBlock(event.x, event.y, event.z));
	if (key != null && !key.equals("") && !research.isFinished(key))
		event.setCanceled(true);
}
 
開發者ID:AEnterprise,項目名稱:Eureka,代碼行數:26,代碼來源:EventHandler.java

示例12: onEntityPlaceTE

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@ForgeSubscribe
@SideOnly(Side.SERVER)
public void onEntityPlaceTE (PlayerInteractEvent event) {
    if (event.entityPlayer.worldObj.getChunkFromBlockCoords(event.x, event.z).chunkTileEntityMap.size() >= Apocalyptic.tePerChunk && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.worldObj.getBlockTileEntity(event.x, event.y, event.z) == null || event.entityPlayer.isSneaking())) {
        if (event.entityLiving.getHeldItem() != null && (TileEntities.contains(event.entityLiving.getHeldItem().getItem().itemID) || ((event.entityLiving.getHeldItem().getItem().itemID < 4096) && Block.blocksList[event.entityLiving.getHeldItem().getItem().itemID].hasTileEntity()))) {
            event.setCanceled(true);
            event.entityPlayer.addChatMessage("\2474\u0414\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442\u043E \u043C\u0430\u043A\u0441. \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E TE \u0432 \u0447\u0430\u043D\u043A\u0435");
        }
    }
    if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.entityLiving.getHeldItem() != null) {
        if ((event.entityLiving.getHeldItem().itemID == 1407 || event.entityLiving.getHeldItem().itemID == 223) && (event.entityPlayer.worldObj.provider.dimensionId != 0)) {
            event.setCanceled(true);
            event.entityPlayer.addChatMessage("\2474Невозможно установить устройство!");
        }
        if (event.entityLiving.getHeldItem().itemID == 2007 && event.entityLiving.getHeldItem().getItemDamage() == 2 && event.entityPlayer.worldObj.provider.dimensionId == 4) {
            event.setCanceled(true);
            event.entityPlayer.addChatMessage("\2474Невозможно установить устройство!");
        }
    }
}
 
開發者ID:kunik-ru,項目名稱:Apocalyptic,代碼行數:21,代碼來源:EventPlayerPlaceTE.java

示例13: onPlayerInteractEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@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);
  }
}
 
開發者ID:ictrobot,項目名稱:Open-Exchange,代碼行數:23,代碼來源:ItemBlockManipulator.java

示例14: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
	EntityPlayer player = event.getEntityPlayer();
	if (player != null && player.getHealth() <= 0f) {
		if (!(event instanceof PlayerInteractEvent.RightClickEmpty || event instanceof PlayerInteractEvent.LeftClickEmpty)) {
			event.setCanceled(true);
		}
	}
}
 
開發者ID:blay09,項目名稱:HardcoreRevival,代碼行數:10,代碼來源:RestrictionHandler.java

示例15: PlayerInteraction

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void PlayerInteraction(PlayerInteractEvent evt) {
	if(Main.debug==1)System.out.println(evt.getEntity().getName() + " called InteractEvent  " + evt.getEntity().toString());
	if(evt.getEntity() instanceof EntityPlayer && !Main.logged.contains(evt.getEntity().getName())){
		
		evt.setCanceled(true);
		if(Main.passwords.containsKey(evt.getEntityPlayer().getName())){
			evt.getEntityPlayer().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
		} else {
		evt.getEntityPlayer().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
		}
	}
}
 
開發者ID:Fungie2134,項目名稱:AuthMod,代碼行數:14,代碼來源:PlayerInteract.java


注:本文中的net.minecraftforge.event.entity.player.PlayerInteractEvent.setCanceled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。