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


Java PlayerEvent类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.gameevent.PlayerEvent的典型用法代码示例。如果您正苦于以下问题:Java PlayerEvent类的具体用法?Java PlayerEvent怎么用?Java PlayerEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onPlayerLoggedIn

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
{
	PlayerInformation playerInfo = (PlayerInformation) event.player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
	Stats statsCap = (Stats) event.player.getCapability(CapabilityPlayerStats.STATS, null);

	if (playerInfo != null && playerInfo.getPlayerClass() == 0 && statsCap != null && statsCap.getMaxMana() == 0)
	{
		// send Class Selection gui to client on first join.
		LootSlashConquer.network.sendTo(new PacketClassGui(), (EntityPlayerMP) event.player);
		
		// setup max mana + send it to client.
		statsCap.setMaxMana(100);
		statsCap.setMana(statsCap.getMaxMana());
		statsCap.setManaPerSecond(5);
		statsCap.setHealthPerSecond(1);
		LootSlashConquer.network.sendTo(new PacketUpdateStats(statsCap), (EntityPlayerMP) event.player);
	}
	else if (playerInfo != null && playerInfo.getPlayerClass() > 0)
		LootSlashConquer.network.sendTo(new PacketUpdatePlayerInformation(playerInfo), (EntityPlayerMP) event.player);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:22,代码来源:EventPlayerLoggedIn.java

示例2: onPlayerLogin

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){
    if(DifficultyManager.enabled && ProgressiveDifficulty.oldConfigExists){
        TextComponentString linkComponent = new TextComponentString("[Progressive Difficulty Wiki]");
        ITextComponent[] chats = new ITextComponent[]{
                new TextComponentString("[ProgressiveDifficulty] It looks like you have a version 1.0 " +
                        "config file. Please check out the Progressive Difficulty Wiki for instructions on how" +
                        " to migrate to a version 2.0 config file."),
                linkComponent
        };
        ClickEvent goLinkEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,"https://github.com/talandar/ProgressiveDifficulty/wiki/2.0-Transition");
        linkComponent.getStyle().setClickEvent(goLinkEvent);
        linkComponent.getStyle().setColor(TextFormatting.BLUE);
        linkComponent.getStyle().setUnderlined(true);
        ChatUtil.sendChat(event.player,chats);
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:18,代码来源:EventHandler.java

示例3: playerJoin

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerJoin(PlayerEvent.PlayerLoggedInEvent event) {
    ItemStack guideBookStack = new ItemStack(Items.WRITTEN_BOOK, 1);
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString("title", new TextComponentTranslation("book.title.guide").getFormattedText());
    nbt.setString("author", new TextComponentTranslation("book.author.guide").getFormattedText());
    nbt.setInteger("generation", 2);
    NBTTagList nbtList = new NBTTagList();
    for (int index = 0; index <= 15; index++)
        nbtList.appendTag(new NBTTagString(String.format("{\"text\": \"%s\"}", new TextComponentTranslation(String.format("book.pages.guide.%d", index)).getFormattedText())));
    nbt.setTag("pages", nbtList);
    guideBookStack.setTagCompound(nbt);
    if (!event.player.getEntityData().getBoolean("genera.joined_before")) {
        event.player.getEntityData().setBoolean("genera.joined_before", true);
        event.player.getEntityData().setInteger("genera.sacrifices_made", 0);
        event.player.addItemStackToInventory(guideBookStack);
    }
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:19,代码来源:EventHandler.java

示例4: getPlayer

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
public static EntityPlayer getPlayer(Event event)
{
	if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer)
		return (EntityPlayer)((LivingEvent)event).getEntity();
	if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent)
		return HarshenCastle.proxy.getPlayer();
	if(event instanceof PlayerTickEvent)
		return ((PlayerTickEvent)event).player;
	if(event instanceof PlayerEvent)
		return ((PlayerEvent)event).player;
	if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent)
		return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer();
	if(event instanceof PlayerPunchedEvent)
		return ((PlayerPunchedEvent)event).attacker;
	if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource()))
		return getPlayerFromSource(((LivingDropsEvent)event).getSource());
	return null;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:19,代码来源:HarshenUtils.java

示例5: PlayerLoggedOut

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
 public void PlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent evt) {

if(Main.debug==1)System.out.println(evt.player.getName() + " called PlayentLoggedOut");
MinecraftServer minecraftServer = FMLServerHandler.instance().getServer();
String brut = minecraftServer.getPlayerList().getPlayerByUsername(evt.player.getName()).connection.getNetworkManager().getRemoteAddress().toString().replaceAll("/", "");
int lenght = brut.length();
brut = brut.substring(0, lenght-6);


if(Integer.parseInt((String) Main.config.get("iplogin")) > 0 && !Main.ips.containsKey(brut) && Main.logged.contains(evt.player.getName())){
	Main.ips.put(brut, 0);
	}


Main.logged.remove(evt.player.getName());
Main.posX.remove(evt.player.getName());
Main.posY.remove(evt.player.getName());
Main.posZ.remove(evt.player.getName());
Main.time.remove(evt.player.getName());
}
 
开发者ID:Fungie2134,项目名称:AuthMod,代码行数:22,代码来源:PlayerLoggedOut.java

示例6: onLogin

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onLogin(PlayerEvent.PlayerLoggedInEvent event) {
	if (FMLCommonHandler.instance().getMinecraftServerInstance() != null)
		if (event.player instanceof EntityPlayerMP) {
			Overlord.logDebug("Sending " + event.player.getName() + " client their squads.");
			PacketDispatcher.sendTo(new SetSquadsMessage(Squads.getInstance().getSquadsFor(event.player.getUniqueID())), (EntityPlayerMP) event.player);
			if (ConfigValues.TEAMHACK) {
				ScorePlayerTeam team = event.player.getEntityWorld().getScoreboard().getTeam(event.player.getName());
				//noinspection ConstantConditions
				if (team == null) {
					team = event.player.getEntityWorld().getScoreboard().createTeam(event.player.getName());
					team.setColor(TextFormatting.values()[teamColor++ % 15]);
				}
				event.player.getEntityWorld().getScoreboard().addPlayerToTeam(event.player.getName(), team.getName());
			}
		}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Overlord,代码行数:18,代码来源:CommonEvents.java

示例7: onPlayerLoggedInEvent

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent e)
{
    if(!e.player.world.isRemote)
    {
        SavedData data = SavedData.get(e.player.world);
        if(data != null)
        {
            ChunkLoaders cl = data.getChunkLoaders();
            cl.updateLoginTimestamp(e.player.getUniqueID().toString(), System.currentTimeMillis());
            data.setChunkLoaders(cl);

            // Enable all of the chunk loaders this player owns
            for(ChunkLoaderPos loaderPos : cl.getLoaders())
            {
                ChunkLoaderTileEntity te = (ChunkLoaderTileEntity)e.player.world.getTileEntity(loaderPos.pos);
                if(te != null)
                {
                    te.enable();
                }
            }
        }
    }
}
 
开发者ID:CorwinJV,项目名称:AChunkLoader,代码行数:25,代码来源:PlayerActivity.java

示例8: onPlayerLogin

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent e) {
	if (MCFlux.UPDATE_CHECK_FINISHED && !MCFlux.NEWER_VERSION.isEmpty() && e.player instanceof EntityPlayerMP)
		MCFluxNetwork.to(Msg.newVersion(MCFlux.NEWER_VERSION), (EntityPlayerMP) e.player);
	if (SpecialEventHandler.getEventStatus() == SpecialEventHandler.EventStatus.DOWNLOADED) {
		final SpecialEventReceiver ser = e.player.getCapability(SpecialEventReceiver.SELF_CAP, null);
		if (ser != null) {
			final int[] seids = SpecialEventHandler.getEventIDs();
			for (int l : seids) {
				if (ser.alreadyReceived(l))
					continue;
				final ItemStack is = new ItemStack(MCFluxResources.SPECIAL);
				is.setTagInfo("seid", new NBTTagInt(l));
				e.player.dropItem(is, false, true);
				ser.addReceived(l);
			}
		}
	}
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:20,代码来源:MCFluxEvents.java

示例9: onJoin

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void onJoin(PlayerEvent.PlayerLoggedInEvent e) {
    if (e.player.getCapability(FTJFactoryProvider.FTJ_CAPABILITY, null).getFTJ()) {
        ISkillsCapability skills = e.player.getCapability(SkillsFactoryProvider.SKILLS_CAPABILITY, null);
        ILevelCapability lvl = e.player.getCapability(LEVEL_CAPABILITY, null);
        ISpechialCapability spe = e.player.getCapability(SpechialFactoryProvider.SPECHIAL_CAPABILITY, null);
        Item lvliningCrystal = ItemInit.lvlingCrystall;
        ItemStack lvlingcrystallS = new ItemStack(lvliningCrystal);
        lvlingcrystallS.setCount(1);
        e.player.inventory.addItemStackToInventory(lvlingcrystallS);
        e.player.getCapability(WaterFactoryProvider.WATER_CAPABILITY, null).setWater(100);
        lvl.initNewplayer();
        skills.setAll(10);
        spe.setAll(0);
        e.player.getCapability(FTJFactoryProvider.FTJ_CAPABILITY, null).setFTJ(false);
    }
    e.player.getCapability(IAdvProvider.Adv_Inv, null).updateClient(e.player);
    updatePlayerSpechial(e.player);
    updatePlayerSkills(e.player);
    updatePlayerLevel(e.player);
}
 
开发者ID:Hoijima,项目名称:Fallout_Equestria,代码行数:22,代码来源:UpdateEvents.java

示例10: playerLoggedIn

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
    {
        // Give the first achievement, because it is stupid and nobody cares.
        // If you're using this mod, you've probably opened your inventory before anyways.
        StatUtil.IFzStat stat = StatUtil.load(event.player, AchievementList.openInventory);
        if (stat.get() <= 0 && FMLCommonHandler.instance().getSide() == Side.CLIENT) {
            stat.set(-1);
            stat.set(300); // Literally, hundreds of times! :D
            Core.logInfo("Achievement Get! %s, you've opened your inventory hundreds of times already! Yes! You're welcome!", event.player.getName());
            // NORELEASE: Verify this works.
        }
    }
    {
        MinecraftServer ms = MinecraftServer.getServer();
        if (ms != null && ms.getTickCounter() >= ms.tickTimeArray.length) {
            //Startup time is ignored; early birds will get a TPS packet soon enough
            MiscNet.channel.sendTo(MiscNet.makeTpsReportPacket(getTpsRatio()), (EntityPlayerMP) event.player);
        }
    }
    fixReachDistance((EntityPlayerMP)event.player);
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:23,代码来源:MiscellaneousNonsense.java

示例11: onCrafting

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event) {
    //TODO: Extractify
    EntityPlayer player = event.player;
    ItemStack stack = event.crafting;
    IInventory craftMatrix = event.craftMatrix;
    for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
        ItemStack here = craftMatrix.getStackInSlot(i);
        if (here == null) {
            continue;
        }
        Item item = here.getItem();
        if (item instanceof IActOnCraft) {
            ((IActOnCraft) item).onCraft(here, craftMatrix, i, stack, player);
        }
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:18,代码来源:Registry.java

示例12: onPlayerLogin

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event)
{
    NBTTagCompound tag = EntityHelper.getPlayerPersistentData(event.player, "GuiltTripSave");
    int size = tag.getInteger("size");
    for(int i = 0; i < size; i++)
    {
        ArrayList<KillInfo> kills = GuiltTrip.eventHandlerServer.playerKills.get(event.player.getName());
        if(kills == null)
        {
            kills = new ArrayList<>();
            GuiltTrip.eventHandlerServer.playerKills.put(event.player.getName(), kills);
        }

        kills.add(KillInfo.createKillInfoFromTag(tag.getCompoundTag("kill_" + i)));
    }
    GuiltTrip.eventHandlerServer.updatePlayersOnKill(event.player.getName(), null);
    GuiltTrip.eventHandlerServer.updatePlayersOnKill(null, event.player.getName());
}
 
开发者ID:iChun,项目名称:GuiltTrip,代码行数:20,代码来源:EventHandlerServer.java

示例13: PlayerLoggedInEvent

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void PlayerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) {
	if (event.player instanceof EntityPlayerMP) {
		recalcTeams();

		WarsMod.proxy.genTag(event.player);

		int totalKills = event.player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG).getInteger("warsmod_totalKill");
		int killStreak = event.player.getEntityData().getInteger("warsmod_killstreak");
		int deaths = event.player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG).getInteger("warsmod_deaths");

		PacketDispatcher.sendTo(new PacketKills(totalKills, killStreak, deaths), (EntityPlayerMP) event.player);

		PacketDispatcher.sendTo(new PacketTeams(redPlayers, greenPlayers, bluePlayers, yellowPlayers), (EntityPlayerMP) event.player);

		WarsSavedData savedWarsData = WarsSavedData.get(event.player.worldObj);
		ItemStack playerBoots = event.player.inventory.getStackInSlot(36);// playerMP.inventory.armorItemInSlot(0);
		if (playerBoots == null) {
			if (!savedWarsData.editMode.editModeToggle) {
				scheduleDelayedGui((EntityPlayerMP) event.player);
			}
		}
	}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Wars-Mod,代码行数:25,代码来源:CommonEvents.java

示例14: PlayerRespawnEvent

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void PlayerRespawnEvent(PlayerEvent.PlayerRespawnEvent event) {
	recalcTeams();

	int totalKills = event.player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG).getInteger("warsmod_totalKill");
	int killStreak = event.player.getEntityData().getInteger("warsmod_killstreak");
	int deaths = event.player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG).getInteger("warsmod_deaths");

	PacketDispatcher.sendTo(new PacketKills(totalKills, killStreak, deaths), (EntityPlayerMP) event.player);

	PacketDispatcher.sendTo(new PacketTeams(redPlayers, greenPlayers, bluePlayers, yellowPlayers), (EntityPlayerMP) event.player);

	WarsSavedData savedWarsData = WarsSavedData.get(event.player.worldObj);
	if (!savedWarsData.editMode.editModeToggle) {
		PacketDispatcher.sendTo(new PacketOpenTeamSelect(), (EntityPlayerMP) event.player);
	}

}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Wars-Mod,代码行数:19,代码来源:CommonEvents.java

示例15: event

import net.minecraftforge.fml.common.gameevent.PlayerEvent; //导入依赖的package包/类
@SubscribeEvent
public void event(PlayerEvent.ItemCraftedEvent e) {
    if (e.crafting.getItem() instanceof Bag) {
        giveAchievement(e.player, Achievements.firstBag);
        Bag bag = (Bag) e.crafting.getItem();
        Bagginses.analytics.eventDesign("BagCrafted:" + bag.getType().name().toLowerCase() + bag.getColor() + ":" + (isSoulBound(e.crafting) ? "soulbound" : "notSoulbound"), Bagginses.analytics.userPrefix());
        if (((Bag) e.crafting.getItem()).getType() == BagTypes.VOID) {
            giveAchievement(e.player, Achievements.voidBag);
        }
        else if(((Bag) e.crafting.getItem()).getType() == BagTypes.ENDER) {
            giveAchievement(e.player, Achievements.enderBag);
        }
        else if (((Bag) e.crafting.getItem()).getType() == BagTypes.TIER2) {
            giveAchievement(e.player, Achievements.tier2Bag);
        }
        else if (((Bag) e.crafting.getItem()).getType() == BagTypes.TIER3) {
            giveAchievement(e.player, Achievements.tier3Bag);
        }
    }
}
 
开发者ID:lorddusk,项目名称:Bagginses,代码行数:21,代码来源:AchievementEventHandler.java


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