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


Java PlayerInteractEvent.getWorld方法代码示例

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


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

示例1: 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

示例2: onBlockInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockInteract(PlayerInteractEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState blockstate = world.getBlockState(pos);
    EntityPlayer player = event.getEntityPlayer();

    if (blockstate.getBlock() instanceof BlockBanner) {
        EnumHand hand = EnumHand.MAIN_HAND;
        ItemStack stack = player.getHeldItemMainhand();
        BlockBanner bannerblock = (BlockBanner) blockstate.getBlock();

        if (stack.isEmpty() && player.isSneaking() && player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()) {
            ItemStack bannerstack = bannerblock.getItem(world, pos, blockstate);
            player.swingArm(hand);

            world.removeTileEntity(pos);
            world.setBlockToAir(pos);

            player.setItemStackToSlot(EntityEquipmentSlot.HEAD, bannerstack);

            if (!event.getWorld().isRemote) {
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:28,代码来源:AssortedHandler.java

示例3: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SubscribeEvent(priority = EventPriority.LOW)
	public void onPlayerInteract(PlayerInteractEvent event) {
		if(event.getEntityPlayer() !=null && event.getWorld() !=null && event instanceof RightClickBlock){
			BlockPos pos = EntityUtil.getEntityLookedBlock(event.getEntityPlayer(), (float)CrystalMod.proxy.getReachDistanceForPlayer(event.getEntityPlayer()));
			if(pos !=null){
				if(event.getWorld().isBlockLoaded(pos)){
					IBlockState state = event.getWorld().getBlockState(pos);
					if(state.getBlock() == Blocks.WOOL && ItemStackTools.isValid(event.getEntityPlayer().getHeldItem(event.getHand())) && ItemUtil.itemStackMatchesOredict(event.getEntityPlayer().getHeldItem(event.getHand()), "slimeball")){
						
						int waterCt = 0;
						for(EnumFacing face : EnumFacing.VALUES){
							IBlockState state2 = event.getWorld().getBlockState(pos.offset(face));
							if(state2 !=null && state2.getBlock().getMaterial(state2) == Material.WATER){
								waterCt++;
							}
						}
						
						if(waterCt >= 4){
							event.getWorld().setBlockState(pos, Blocks.SPONGE.getDefaultState());
							event.getEntityPlayer().swingArm(event.getHand());
							
							if (!event.getWorld().isRemote)
		                    {
								event.getWorld().playEvent(2001, pos, Block.getStateId(state));
		                    }
							
							if(!event.getEntityPlayer().capabilities.isCreativeMode)
							event.getEntityPlayer().setHeldItem(event.getHand(), ItemUtil.consumeItem(event.getEntityPlayer().getHeldItem(event.getHand())));
						}
					}
				}
			}
		}
	}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:36,代码来源:EventHandler.java

示例4: securityCanceler

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
/** This method will cancel unauthorized access to the storage system */
private void securityCanceler(PlayerInteractEvent e) {
	World w = e.getWorld();
	IBlockState state = w.getBlockState(e.getPos());
	Block b = state.getBlock();
	TileEntitySecurityBox tile;
	EntityPlayer p = e.getEntityPlayer();

	if (b instanceof StorageMultiblock) {
		if ((tile = EZStorageUtils.findSecurityBox(new BlockRef(b, e.getPos().getX(), e.getPos().getY(), e.getPos().getZ()), w, null)) != null) {
			if (!tile.isPlayerAllowed(p))
				e.setCanceled(true); // cancel everything
		}
	}
}
 
开发者ID:zerofall,项目名称:EZStorage2,代码行数:16,代码来源:SecurityEvents.java

示例5: stopBedUse

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void stopBedUse(PlayerInteractEvent e){
    if(!e.getWorld().isRemote) {
        if (e.getWorld().getBlockState(e.getPos()).getBlock() == Blocks.BED && ConfigurationFile.clickingBedSetsSpawnPoint) {
            e.getEntityPlayer().setSpawnPoint(e.getPos(), true);
            e.getEntityPlayer().bedLocation = e.getPos();
            e.getEntityPlayer().addChatComponentMessage(new TextComponentTranslation("Spawn point set!"));
            if (ConfigurationFile.stopBedUse && !e.getEntity().getEntityWorld().isDaytime()) {
                e.getEntityPlayer().addChatComponentMessage(new TextComponentTranslation("You don't feel tired enough to sleep.."));
                e.setCanceled(true);
            }
        }
    }
}
 
开发者ID:baileyholl,项目名称:Event-Tweaks,代码行数:15,代码来源:InteractEventHandler.java

示例6: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
  if (signSkullName) {
    EntityPlayer entityPlayer = event.getEntityPlayer();
    BlockPos pos = event.getPos();
    World worldObj = event.getWorld();
    if (pos == null) {
      return;
    }
    // event has no hand??
    // and no item stack. and right click rarely works. known bug
    // http://www.minecraftforge.net/forum/index.php?topic=37416.0
    ItemStack held = entityPlayer.getHeldItemMainhand();
    if (held == null) {
      held = entityPlayer.getHeldItemOffhand();
    }
    TileEntity container = worldObj.getTileEntity(pos);
    if (held != null && held.getItem() == Items.SKULL && held.getItemDamage() == Const.skull_player && container != null && container instanceof TileEntitySign) {
      TileEntitySign sign = (TileEntitySign) container;
      String firstLine = sign.signText[0].getUnformattedText();
      if (firstLine == null) {
        firstLine = "";
      }
      if (firstLine.isEmpty() || firstLine.split(" ").length == 0) {
        held.setTagCompound(null);
      }
      else {
        firstLine = firstLine.split(" ")[0];
        NBTTagCompound nbt = UtilNBT.getItemStackNBT(held);
        nbt.setString(Const.SkullOwner, firstLine);
      }
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:35,代码来源:PlayerAbilitiesModule.java

示例7: onPlayerClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
    public void onPlayerClick(PlayerInteractEvent event) {
        if (event instanceof PlayerInteractEvent.RightClickEmpty) return;

        ItemStack heldItem = event.getEntityPlayer().getHeldItem(event.getHand());

        IBlockState interactedBlockState = event.getWorld().getBlockState(event.getPos());
        Block interactedBlock = interactedBlockState.getBlock();
        if (!event.getEntityPlayer().capabilities.isCreativeMode || !event.getEntityPlayer().canUseCommand(2, "securityStation")) {
            if (event.getWorld() != null && !event.getWorld().isRemote) {
                if (interactedBlock != Blockss.SECURITY_STATION || event instanceof PlayerInteractEvent.LeftClickBlock) {
                    boolean tryingToPlaceSecurityStation = heldItem.getItem() instanceof ItemBlock && ((ItemBlock) heldItem.getItem()).getBlock() == Blockss.SECURITY_STATION;
                    int blockingStations = PneumaticCraftUtils.getProtectingSecurityStations(event.getWorld(), event.getPos(), event.getEntityPlayer(), true, tryingToPlaceSecurityStation);
                    if (blockingStations > 0) {
                        event.setCanceled(true);
                        event.getEntityPlayer().sendStatusMessage(
                                new TextComponentTranslation(
                                        tryingToPlaceSecurityStation ? "message.securityStation.stationPlacementPrevented" : "message.securityStation.accessPrevented",
                                        blockingStations), false);
                    }
                }
            }
        }

        if (!event.isCanceled() && event instanceof PlayerInteractEvent.RightClickBlock && !event.getWorld().isRemote) {
            if (event.getEntityPlayer().isSneaking() && (interactedBlock == Blockss.ELEVATOR_CALLER || interactedBlock == Blockss.CHARGING_STATION)) {
                // work around the fact that Block#onBlockActivated doesn't get called server-side when sneaking
                event.setCanceled(interactedBlock.onBlockActivated(event.getWorld(), event.getPos(), interactedBlockState, event.getEntityPlayer(), event.getHand(), event.getFace(), 0, 0, 0));
            } else if (ModInteractionUtilImplementation.getInstance().isModdedWrench(heldItem)) {
                // when player clicks with a modded wrench, enforce our rotation behaviour and cancel default behaviour
                // (which is probably to call the "vanilla" rotateBlock(), which doesn't get any player information)
                if (interactedBlock instanceof IPneumaticWrenchable) {
                    ((IPneumaticWrenchable) interactedBlock).rotateBlock(event.getWorld(), event.getEntityPlayer(), event.getPos(), event.getFace());
                    event.setCanceled(true);
                }
            }
        }

//        if (!event.isCanceled() && interactedBlock == Blocks.COBBLESTONE) {
//            AdvancementUtils.checkFor9x9(event.getEntityPlayer(), event.getPos());
//        }
    }
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:43,代码来源:EventHandlerPneumaticCraft.java

示例8: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
    public void onPlayerInteract(PlayerInteractEvent evt) {
        // only handle right clicks on blocks
        // TODO: port for 1.9
//        if (evt.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
//            return;
//        }
        
        BlockPos pos = evt.getPos();
        World world = evt.getWorld();
        IBlockState state = world.getBlockState(pos);
        Block block = world.getBlockState(pos).getBlock();
        
        // don't interact with vanilla egg blocks if configured
        if (DragonMounts.instance.getConfig().isDisableBlockOverride() &&
                block == Blocks.DRAGON_EGG) {
            return;
        }
        
        // ignore non-egg blocks
        if (block != Blocks.DRAGON_EGG && block != BlockDragonBreedEgg.INSTANCE) {
            return;
        }
        
        // deny action
        evt.setResult(Event.Result.DENY);
        
        // clear dragon egg block
        world.setBlockToAir(pos);

        // create dragon egg entity on server
        if (!world.isRemote) { // this was inverted, i.e. evt.world.isRemote, but it should surely be this way
            EntityTameableDragon dragon = new EntityTameableDragon(world);
            dragon.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
            dragon.getReproductionHelper().setBreeder(evt.getEntityPlayer());
            dragon.getLifeStageHelper().setLifeStage(EnumDragonLifeStage.EGG);
            
            // set breed type (custom dragon egg only, otherwise use default breed)
            if (block == BlockDragonBreedEgg.INSTANCE) {
                EnumDragonBreed breed = state.getValue(BlockDragonBreedEgg.BREED);
                dragon.getBreedHelper().setBreedType(breed);
            }
            
            world.spawnEntityInWorld(dragon);
        }
    }
 
开发者ID:ata4,项目名称:dragon-mounts,代码行数:47,代码来源:DragonEggBlockHandler.java


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