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