本文整理汇总了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); } }
*/
}
示例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());
}
}
示例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 );
}
}
示例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.
}
示例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);
}
}
}
示例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;
}
}
}
}
示例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());
}
}
示例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;
}
}
}
示例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;
}
}
}
}
示例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);
}
}
示例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);
}
示例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Невозможно установить устройство!");
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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")));
}
}
}