Java 类net.minecraftforge.event.entity.player.PlayerEvent 实例源码

项目:Loot-Slash-Conquer    文件:CapabilityPlayerStats.java   
@SubscribeEvent
public void playerClone(PlayerEvent.Clone event) 
{
    IStats oldStats = getStats(event.getOriginal());
    IStats newStats = getStats(event.getEntityLiving());

    if (newStats != null && oldStats != null)
    {
        newStats.setMana(oldStats.getMana());
        newStats.setMaxMana(oldStats.getMaxMana());
        newStats.setManaPerSecond(oldStats.getManaPerSecond());

        newStats.setMagicalPower(oldStats.getMagicalPower());

        newStats.setHealthPerSecond(oldStats.getHealthPerSecond());

        newStats.setCriticalChance(oldStats.getCriticalChance());
        newStats.setCriticalDamage(oldStats.getCriticalDamage());
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event) {
    if (!EtFuturum.enableEnchants)
        return;
    try {
        File file = event.getPlayerFile(Reference.MOD_ID);
        if (!file.exists()) {
            file.createNewFile();
            return;
        }

        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = br.readLine();
        if (line != null) {
            int seed = Integer.parseInt(line);
            ContainerEnchantment.seeds.put(event.playerUUID, seed);
            br.close();
        }
    } catch (Exception e) {
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void onPlayerSaveFromFileEvent(PlayerEvent.SaveToFile event) {
    if (!EtFuturum.enableEnchants)
        return;
    try {
        File file = event.getPlayerFile(Reference.MOD_ID);
        if (!file.exists()) {
            file.createNewFile();
            return;
        }

        Integer seed = ContainerEnchantment.seeds.get(event.playerUUID);
        if (seed != null) {
            BufferedWriter bw = new BufferedWriter(new FileWriter(file));
            bw.write(seed.toString());
            bw.close();
        }
    } catch (IOException e) {
    }
}
项目:HazardsLib    文件:CommonEventHandler.java   
@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone event)
{
    PlayerTracker tracker = TrackerManager.lookupTracker(event.original);

    if (tracker != null) {
        HazardsLib.modLog.info("Changing tracker owner for: '" + event.entity.getCommandSenderName() + "'...");
        tracker.owner = event.entityPlayer;

        if (event.wasDeath) {
            tracker.resetData();
            TrackerManager.saveTracker(tracker);
        }

        tracker.loadFromNBT();
    }

    if (event.wasDeath) {
        doDeath(event.entityPlayer);
        doDeath(event.original);
    }
}
项目:uniquecrops    文件:UCEventHandlerServer.java   
@SubscribeEvent
public void checkPlayerNBT(PlayerEvent.Clone event) {

    if (!event.isWasDeath())
        return;

    EntityPlayer old = event.getOriginal();
    EntityPlayer player = event.getEntityPlayer();

    NBTTagCompound oldtag = old.getEntityData();
    NBTTagCompound tag = player.getEntityData();
    if (oldtag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) {
        tag.setTag(GrowthSteps.TAG_GROWTHSTAGES, oldtag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10).copy());
    }
    if (oldtag.hasKey("hasSacrificed"))
        tag.setBoolean("hasSacrificed", oldtag.getBoolean("hasSacrificed"));
    if (oldtag.hasKey(SeedBehavior.TAG_ABSTRACT))
        tag.setInteger(SeedBehavior.TAG_ABSTRACT, oldtag.getInteger(SeedBehavior.TAG_ABSTRACT));
}
项目:Mods    文件:TF2EventsClient.java   
@SubscribeEvent
public void playerName(PlayerEvent.NameFormat event) {
    if(Minecraft.getMinecraft().player != null && WeaponsCapability.get(event.getEntityPlayer()).isDisguised()) {
        String username=WeaponsCapability.get(event.getEntityPlayer()).getDisguiseType().substring(2);

        if(TF2Util.isOnSameTeam(Minecraft.getMinecraft().player, event.getEntityPlayer())) {
            event.setDisplayname(event.getDisplayname()+" ["+username+"]");
        }
        else {
            if(WeaponsCapability.get(event.getEntityPlayer()).getDisguiseType().startsWith("M:")) {
                if(event.getEntityPlayer().getCapability(TF2weapons.WEAPONS_CAP, null).entityDisguise != null){
                    event.setDisplayname(TextFormatting.RESET+event.getEntityPlayer().getCapability(TF2weapons.WEAPONS_CAP, null).entityDisguise.getDisplayName().getFormattedText());
                }
                else
                    event.setDisplayname(TextFormatting.RESET+I18n.format("entity."+username+".name"));

            }
            else
                event.setDisplayname(ScorePlayerTeam.formatPlayerName(Minecraft.getMinecraft().world.getScoreboard().getPlayersTeam(username), username));
        }
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void craftItem(net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent event) {
    ItemStack withPattern=ItemStack.EMPTY;
    ItemStack noPattern=ItemStack.EMPTY;
    for(int i=0; i<event.craftMatrix.getSizeInventory();i++){
        ItemStack stack=event.craftMatrix.getStackInSlot(i);
        if(!stack.isEmpty() && stack.getItem() instanceof ItemBanner){
            if(TileEntityBanner.getPatterns(stack)>0){
                withPattern=stack;
            }
            else{
                noPattern=stack;
            }
            if(!withPattern.isEmpty()&&!noPattern.isEmpty()){
                withPattern.shrink(1);
            }
        }
    }
}
项目:ExPetrum    文件:ExPHandlerServer.java   
@SubscribeEvent
public void onClientLogIn(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
{
    // Should be always true but mods can throw this event at any time...
    if (event.player instanceof EntityPlayerMP)
    {
        if (FMLCommonHandler.instance().getMinecraftServerInstance().isDedicatedServer())
        {
            SettingsManager.restoreAllClientData();
        }
        else
        {
            SettingsManager.sendSettingsToClient((EntityPlayerMP) event.player);
        }
    }
}
项目:ExtraUtilities    文件:EventHandlerServer.java   
@SubscribeEvent
public void persistSoulDrain(final PlayerEvent.Clone event) {
    if (event.entityPlayer.worldObj.isRemote || ExtraUtils.permaSoulDrainOff) {
        return;
    }
    final EntityPlayer original = event.original;
    EntityPlayer clone = event.entityPlayer;
    AttributeModifier attr = original.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()).getModifier(ItemSoul.uuid);
    if (attr == null) {
        attr = clone.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()).getModifier(ItemSoul.uuid);
        if (attr != null) {
            clone = event.original;
        }
    }
    if (attr != null) {
        try {
            clone.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()).applyModifier(attr);
        }
        catch (IllegalArgumentException ex) {}
    }
}
项目:ToroQuest    文件:CivilizationHandlers.java   
@SubscribeEvent
public void onDeath(PlayerEvent.Clone event) {
    if (event.getEntityPlayer().getEntityWorld().isRemote) {
        return;
    }

    PlayerCivilizationCapability newCap = PlayerCivilizationCapabilityImpl.get(event.getEntityPlayer());
    PlayerCivilizationCapability originalCap = PlayerCivilizationCapabilityImpl.get(event.getOriginal());

    if (originalCap == null) {
        return;
    }

    if (newCap == null) {
        throw new NullPointerException("missing player capability during clone");
    }

    // System.out.println("CLONE: " + originalCap.writeNBT());

    newCap.readNBT(originalCap.writeNBT());
}
项目:ToroQuest    文件:CivilizationHandlers.java   
@SubscribeEvent
public void onSave(PlayerEvent.SaveToFile event) {
    if (event.getEntityPlayer().getEntityWorld().isRemote) {
        return;
    }
    PlayerCivilizationCapability cap = PlayerCivilizationCapabilityImpl.get(event.getEntityPlayer());
    if (cap == null) {
        return;
    }

    NBTTagCompound civData = cap.writeNBT();

    // System.out.println("SAVE: " + civData);

    if (civData == null || civData.getTag("reputations") == null || ((NBTTagList) civData.getTag("reputations")).tagCount() < 1) {
        // System.out.println("******************Not writing empty ToroQuest
        // data for player " + event.getEntityPlayer().getName());
        return;
    }

    event.getEntityPlayer().getEntityData().setTag(ToroQuest.MODID + ".playerCivilization", civData);
}
项目:ToroQuest    文件:CivilizationHandlers.java   
@SubscribeEvent
public void onLoad(PlayerEvent.LoadFromFile event) {
    if (event.getEntityPlayer().getEntityWorld().isRemote) {
        return;
    }

    PlayerCivilizationCapability cap = PlayerCivilizationCapabilityImpl.get(event.getEntityPlayer());
    if (cap == null) {
        return;
    }

    NBTTagCompound c = event.getEntityPlayer().getEntityData().getCompoundTag(ToroQuest.MODID + ".playerCivilization");

    if (c == null) {
        // System.out.println("******************Missing civ data on load");
    } else {
        System.out.println("LOAD: " + c.toString());
    }

    cap.readNBT(c);
}
项目:Malgra    文件:MalgraEventHandler.java   
@SubscribeEvent
public void onClonePlayer(PlayerEvent.Clone event) {
       if (event.isWasDeath()) {
           final CapabilityMana.IMana manaOriginal = event.getOriginal().getCapability(CapabilityMana.MANA, null);
           final CapabilityMana.IMana manaNew = event.getEntityPlayer().getCapability(CapabilityMana.MANA, null);
           manaNew.setMana(manaOriginal.getMana());
           manaNew.setMaxMana(manaOriginal.getMaxMana());

           final CapabilityResearchPoints.IResearchPoints researchPointsOriginal = event.getOriginal().getCapability(CapabilityResearchPoints.RESEARCHPOINTS, null);
           final CapabilityResearchPoints.IResearchPoints researchPointsNew = event.getEntityPlayer().getCapability(CapabilityResearchPoints.RESEARCHPOINTS, null);
           researchPointsNew.setResearchPoints(researchPointsOriginal.getResearchPoints());

           final CapabilityResearchActivites.IResearchActivities researchActivitesOriginal = event.getOriginal().getCapability(CapabilityResearchActivites.RESEARCHACTIVITIES, null);
           final CapabilityResearchActivites.IResearchActivities researchActivitesNew = event.getEntityPlayer().getCapability(CapabilityResearchActivites.RESEARCHACTIVITIES, null);
           researchActivitesNew.setMinedBlocks(researchActivitesOriginal.getMinedBlocks());

       }
   }
项目:MC-Prefab    文件:ModEventHandler.java   
/**
 * This occurs when a player dies and is used to make sure that a player does not get a duplicate starting house.
 * @param event
 */
@SubscribeEvent
public static void onClone(PlayerEvent.Clone event) 
{
    if (event.getEntityPlayer() instanceof EntityPlayerMP)
    {
        // Don't add the tag unless the house item was added. This way it can be added if the feature is turned on.
        // When the player is cloned, make sure to copy the tag. If this is not done the item can be given to the player again if they die before the log out and log back in.
        NBTTagCompound originalTag = event.getOriginal().getEntityData();

        // Use the server configuration to determine if the house should be added for this player.
        if (Prefab.proxy.proxyConfiguration.addHouseItem)
        {
            if (originalTag.hasKey(EntityPlayerConfiguration.PLAYER_ENTITY_TAG))
            {
                NBTTagCompound newPlayerTag = event.getEntityPlayer().getEntityData();
                newPlayerTag.setTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG, originalTag.getTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG));

                // Send the persist tag to the client.
                Prefab.network.sendTo(new PlayerEntityTagMessage(originalTag.getCompoundTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG)), (EntityPlayerMP)event.getEntityPlayer());
            }
        }
    }
}
项目:geomastery    文件:BlockEvents.java   
/** Adjusts block breaking speed. */
@SubscribeEvent
public void playerBreakSpeed(PlayerEvent.BreakSpeed event) {

    Block block = event.getState().getBlock();
    ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
    String toolRequired = block.getHarvestTool(event.getState());

    // Make axe and pickaxe blocks unbreakable without tool
    if (("axe".equals(toolRequired) &&
            !(stack.getItem() instanceof ItemAxe)) ||
            ("pickaxe".equals(toolRequired) &&
            !(stack.getItem() instanceof ItemPickaxe))) {

        event.setCanceled(true);
    }
}
项目:InfinityLib    文件:CapabilityHandler.java   
@SubscribeEvent
@SuppressWarnings("unused")
public void onPlayerClone(PlayerEvent.Clone event) {
    EntityPlayer oldPlayer = event.getOriginal();
    EntityPlayer newPlayer = event.getEntityPlayer();
    if(oldPlayer != null && newPlayer != null && !oldPlayer.getEntityWorld().isRemote) {
        List<ICapabilityImplementation<ICapabilityProvider, ? extends ISerializable>> list = this.map.get(oldPlayer.getClass());
        if(list == null) {
            return;
        }
        list.stream()
                .filter(impl -> EntityPlayer.class.isAssignableFrom(impl.getCarrierClass()))
                .filter(impl -> oldPlayer.hasCapability(impl.getCapability(), null))
                .forEach(impl -> {
                    ISerializable oldProps = oldPlayer.getCapability(impl.getCapability(), null);
                    ISerializable newProps = oldPlayer.getCapability(impl.getCapability(), null);
                    if(newProps != null && oldProps != null) {
                        newProps.readFromNBT(oldProps.writeToNBT());
                    }
                });
    }
}
项目:Factorization    文件:BlockUndo.java   
private boolean canUndo(PlayerEvent event, BlockPos pos, Block block, IBlockState bs) {
    final EntityPlayer player = event.entityPlayer;
    List<PlacedBlock> coords = recentlyPlaced.get(getName(player));
    if (coords == null) return false;

    int w = FzUtil.getWorldDimension(player.worldObj);
    for (PlacedBlock hot : coords) {
        if (hot.w == w && hot.pos.equals(pos)) {
            if (hash(bs) != hot.idmd) {
                continue;
            }
            return true;
        }
    }
    return false;
}
项目:Cyclic    文件:UtilPlayerInventoryFilestorage.java   
public static void playerSetupOnLoad(PlayerEvent.LoadFromFile event) {
  EntityPlayer player = event.getEntityPlayer();
  clearPlayerInventory(player);
  File playerFile = getPlayerFile(ext, event.getPlayerDirectory(), event.getEntityPlayer().getDisplayNameString());
  if (!playerFile.exists()) {
    File fileNew = event.getPlayerFile(ext);
    if (fileNew.exists()) {
      try {
        Files.copy(fileNew, playerFile);
        fileNew.delete();
        File fb = event.getPlayerFile(extback);
        if (fb.exists())
          fb.delete();
      }
      catch (IOException e) {}
    }
  }
  loadPlayerInventory(event.getEntityPlayer(), playerFile, getPlayerFile(extback, event.getPlayerDirectory(), event.getEntityPlayer().getDisplayNameString()));
  playerEntityIds.add(event.getEntityPlayer().getEntityId());
}
项目:KeyCraft    文件:SubscribeOnDead.java   
/**
 * ���������ʱ������ҵ�����Skill�Լ�ŷ����������¡��Respawn�Ժ�������
 * �ڴ�ĩ�ػص�������ʱҲ�����PlayerEvent.Clone��PlayerRespawnEvent�����������PlayerChangedDimensionEvent
 */
@SubscribeEvent
   public void OnDeadClone(PlayerEvent.Clone event) {
    final EntityPlayer _old = event.original;
    final EntityPlayer _new = event.entityPlayer;

    final NBTTagCompound newData = _new.getEntityData();
    // ���������ŷ�����������л�����������䣬������10
    final int newAuroraPoint = event.wasDeath ? Math.max(RewriteHelper.getAuroraPoint(_old) - 10, 0) : RewriteHelper.getAuroraPoint(_old);
    newData.setInteger("SkillPoint", newAuroraPoint);
    for (Skill i : RewriteHelper.SKILLS) {
        final String name = "Skill" + String.format("%03d", i.id);
        newData.setBoolean(name, RewriteHelper.hasSkill(_old, i.id));
    }

    // ������л������ͬ����@RewriteNetwork.SendSyncPacket.onPlayerRespawn
}
项目:OverpoweredInventory    文件:UtilPlayerInventoryFilestorage.java   
public static void playerSetupOnLoad(PlayerEvent.LoadFromFile event) {
  EntityPlayer player = event.getEntityPlayer();
  clearPlayerInventory(player);
  File playerFile = getPlayerFile(EXT, event.getPlayerDirectory(), event.getEntityPlayer());
  if (!playerFile.exists()) {
    File fileNew = event.getPlayerFile(EXT);
    if (fileNew.exists()) {
      try {
        Files.copy(fileNew, playerFile);
        ModInv.logger.info("Using and converting UUID savefile for " + player.getDisplayNameString());
        fileNew.delete();
        File fb = event.getPlayerFile(EXTBK);
        if (fb.exists())
          fb.delete();
      }
      catch (IOException e) {
      }
    }
  }
  loadPlayerInventory(event.getEntityPlayer(), playerFile, getPlayerFile(EXTBK, event.getPlayerDirectory(), event.getEntityPlayer()));
  playerEntityIds.add(event.getEntityPlayer().getEntityId());
}
项目:ClockworkPhase2    文件:PlayerHandler.java   
/**
 * Copies data to the new player when respawning after death.
 */
@SubscribeEvent
public void onPlayerRespawning(PlayerEvent.Clone event)
{
    if(event.isWasDeath())
    {
        EntityPlayer original = event.getOriginal();
        EntityPlayer newPlayer = event.getEntityPlayer();
        ITemporalToolbeltHandler temporalToolbeltHandler = original.getCapability(TEMPORAL_TOOLBELT, EnumFacing.DOWN);
        ITemporalToolbeltHandler newTemporalToolbeltHandler = newPlayer.getCapability(TEMPORAL_TOOLBELT, EnumFacing.DOWN);
        if(temporalToolbeltHandler != null && newTemporalToolbeltHandler != null)
        {
            newTemporalToolbeltHandler.setRowCount(temporalToolbeltHandler.getRowCount());
            for(int i = 0; i < temporalToolbeltHandler.getRowCount(); i++)
            {
                newTemporalToolbeltHandler.setRow(i, temporalToolbeltHandler.getRow(i));
            }
        }
    }
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event) {
    if (!EtFuturum.enableEnchants)
        return;
    try {
        File file = event.getPlayerFile(Reference.MOD_ID);
        if (!file.exists()) {
            file.createNewFile();
            return;
        }

        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = br.readLine();
        if (line != null) {
            int seed = Integer.parseInt(line);
            ContainerEnchantment.seeds.put(event.playerUUID, seed);
            br.close();
        }
    } catch (Exception e) {
    }
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void onPlayerSaveFromFileEvent(PlayerEvent.SaveToFile event) {
    if (!EtFuturum.enableEnchants)
        return;
    try {
        File file = event.getPlayerFile(Reference.MOD_ID);
        if (!file.exists()) {
            file.createNewFile();
            return;
        }

        Integer seed = ContainerEnchantment.seeds.get(event.playerUUID);
        if (seed != null) {
            BufferedWriter bw = new BufferedWriter(new FileWriter(file));
            bw.write(seed.toString());
            bw.close();
        }
    } catch (IOException e) {
    }
}
项目:Cybernetica    文件:PlayerEventHandler.java   
/**
 * Restores the saved implants to the player giving the impression they are not removable
 * @param e the PlayerEvent.Clone event
 */
@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.Clone e) {
    //The PlayerEvent.Clone gets called both on death and dimension travel so only if the event was called on
    //player's actual death and our hashmap has the player's name (used as the key) do we restore their implants
    if (e.wasDeath && savedImplants.containsKey(e.original.getDisplayName())) {
        //Simultaneously get and remove the implants stored in our hashmap
        ArrayList<EntityItem> implants = savedImplants.remove(e.original.getDisplayName());

        //Iterate through the arraylist and equip all of the implants
        for (EntityItem i : implants) {
            ItemStack implantStack = i.getEntityItem();
            Implant implantItem = (Implant) implantStack.getItem();
            e.entityPlayer.setCurrentItemOrArmor(3 - implantItem.armorType + 1, implantStack);
        }
    }
}
项目:rpginventory    文件:RPGEventHooks.java   
@SubscribeEvent
public void BreakSpeed(PlayerEvent.BreakSpeed evt) {

    /* Increases Block-breaking speed while wearing emerald ring (right slot) */
    if (evt.entityPlayer != null) {
        PlayerRpgInventory inv = PlayerRpgInventory.get(evt.entityPlayer);

        if(inv.getShield() != null && evt.entityPlayer.isSneaking())
            evt.newSpeed = -1f;

        ItemStack ringa = inv.getRing1();
        if ((ringa != null)&& ringa.getItem().equals(RpgInventoryMod.ringem))
            evt.newSpeed = evt.originalSpeed * 4;

    }
}
项目:MateriaMuto    文件:AlchemicalBagHandler.java   
@SubscribeEvent
public void onPlayerLoad(PlayerEvent.LoadFromFile event) {
    File file = new File(event.playerDirectory, event.entityPlayer.getCommandSenderName() + "." + FILE_SUFFIX);
    NBTTagCompound nbtTagCompound = new NBTTagCompound();

    InventoryAlchemicalBag[] array = new InventoryAlchemicalBag[16];

    if (file.exists()) {
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            nbtTagCompound = CompressedStreamTools.readCompressed(fileInputStream);
        } catch (IOException ignored) {
        }
    }

    for (int i = 0; i < 16; i++) {
        NBTTagCompound dataTag = nbtTagCompound.getCompoundTag(ItemAlchemicalBag.COLORS[i]);
        InventoryAlchemicalBag inventoryAlchemicalBag = new InventoryAlchemicalBag(i);
        inventoryAlchemicalBag.readFromNBT(dataTag);
        array[i] = inventoryAlchemicalBag;
    }

    inventoryMap.put(event.entity.getCommandSenderName(), array);
}
项目:D3Core    文件:DevPerks.java   
@SubscribeEvent
public void nameFormatEvent(PlayerEvent.NameFormat event)
{
    try
    {
        if (D3Core.isDebug()) update();
        if (perks.has(event.getUsername()))
        {
            JsonObject perk = perks.getAsJsonObject(event.getUsername());
            if (perk.has("displayname")) event.setDisplayname(perk.get("displayname").getAsString());
            doHat(perk, event.getEntityPlayer());
        }
    }
    catch (Exception e)
    {
        if (D3Core.isDebug()) e.printStackTrace();
    }
}
项目:D3Core    文件:DevPerks.java   
@SubscribeEvent
public void cloneEvent(PlayerEvent.Clone event)
{
    try
    {
        if (D3Core.isDebug()) update();
        if (perks.has(event.getOriginal().getName()))
        {
            JsonObject perk = perks.getAsJsonObject(event.getOriginal().getName());
            doHat(perk, event.getEntityPlayer());
        }
    }
    catch (Exception e)
    {
        if (D3Core.isDebug()) e.printStackTrace();
    }
}
项目:CosmeticArmor    文件:PlayerEventHandler.java   
@SubscribeEvent
public void onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) {
    if (!event.player.worldObj.isRemote) {
        for (int i=0; i<4; i++) {
            // Send logged in Player's armor to all other players
            PlayerHandler.getArmor(event.player).syncSlotToClients(i);

            // Send all other Player's armor to logged in player
            for (Object obj : FMLServerHandler.instance().getServer().getConfigurationManager().playerEntityList) {
                InventoryArmor inventoryArmor = PlayerHandler.getArmor((EntityPlayer) obj);
                PacketSyncArmor packetSyncArmor = new PacketSyncArmor();
                packetSyncArmor.entityId = ((EntityPlayer)obj).getEntityId();
                packetSyncArmor.slot = i;
                packetSyncArmor.itemStack = inventoryArmor.getStackInSlot(i);
                PacketHandler.INSTANCE.sendTo(packetSyncArmor, (EntityPlayerMP) obj);
            }
        }
    }
}
项目:SamsPowerups    文件:ModCommands.java   
@SubscribeEvent
public void onClonePlayer(PlayerEvent.Clone event) 
{ 
    if(event.wasDeath)//false means switched dimensions
    {
        if(CommandSimpleWaypoints.PERSIST_DEATH)
        {
            CommandSimpleWaypoints.overwriteForPlayer(event.entityPlayer, CommandSimpleWaypoints.getForPlayer(event.original));
        }

        if(CommandTodoList.PERSIST_DEATH)
        {
            CommandTodoList.setTodoForPlayer(event.entityPlayer, CommandTodoList.getTodoForPlayer(event.original));
        }
    }
}
项目:RuneMagic    文件:EventHandlerEntity.java   
@SubscribeEvent
public void playerTick(PlayerEvent.LivingUpdateEvent event) {

    //player events
    if (event.entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer)event.entity;

        InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
        for (int a=0;a<baubles.getSizeInventory();a++) {
            if (baubles.getStackInSlot(a)!=null && baubles.getStackInSlot(a).getItem() instanceof IBauble) {
                ((IBauble)baubles.getStackInSlot(a).getItem()).onWornTick(baubles.getStackInSlot(a), player);
            }
        }

    }

}
项目:Allomancy    文件:CommonEventHandler.java   
@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone event) {
    AllomancyCapability oldCap = AllomancyCapability.forPlayer(event.getOriginal()); // the dead player's cap
    AllomancyCapability cap = AllomancyCapability.forPlayer(event.getEntityPlayer()); // the clone's cap
    if (oldCap.getAllomancyPower() >= 0) {
        cap.setAllomancyPower(oldCap.getAllomancyPower()); // make sure the new player has the same mistborn status
        Registry.network.sendTo(new AllomancyPowerPacket(oldCap.getAllomancyPower()), (EntityPlayerMP) event.getEntity());
    }
    if (event.getEntityPlayer().world.getGameRules().getBoolean("keepInventory") || !event.isWasDeath()) { // if keepInventory is true, or they didn't die, allow them to keep their metals, too
        for (int i = 0; i < 8; i++) {
            cap.setMetalAmounts(i, oldCap.getMetalAmounts(i));
            Registry.network.sendTo(new AllomancyCapabilityPacket(cap, event.getEntity().getEntityId()), (EntityPlayerMP) event.getEntity());

        }
    }
}
项目:Loot-Slash-Conquer    文件:CapabilityPlayerInformation.java   
@SubscribeEvent
public void playerClone(PlayerEvent.Clone event) 
{
    IPlayerInformation oldInfo = getPlayerInformation(event.getOriginal());
    IPlayerInformation newInfo = getPlayerInformation(event.getEntityLiving());

    if (newInfo != null && oldInfo != null)
    {
        newInfo.setPlayerClass(oldInfo.getPlayerClass());
        newInfo.setPlayerLevel(oldInfo.getPlayerLevel());
        newInfo.setPlayerExperience(oldInfo.getPlayerExperience());
        newInfo.setSkillPoints(oldInfo.getSkillPoints());

        // stats
        newInfo.setStrengthStat(oldInfo.getStrengthStat());
        newInfo.setAgilityStat(oldInfo.getAgilityStat());
        newInfo.setDexterityStat(oldInfo.getDexterityStat());
        newInfo.setIntelligenceStat(oldInfo.getIntelligenceStat());
        newInfo.setWisdomStat(oldInfo.getWisdomStat());
        newInfo.setFortitudeStat(oldInfo.getFortitudeStat());

        newInfo.setBonusStrengthStat(oldInfo.getBonusStrengthStat());
        newInfo.setBonusAgilityStat(oldInfo.getBonusAgilityStat());
        newInfo.setBonusDexterityStat(oldInfo.getBonusDexterityStat());
        newInfo.setBonusIntelligenceStat(oldInfo.getBonusIntelligenceStat());
        newInfo.setBonusWisdomStat(oldInfo.getBonusWisdomStat());
        newInfo.setBonusFortitudeStat(oldInfo.getBonusFortitudeStat());

        LootSlashConquer.LOGGER.info("Hello!");

        LootSlashConquer.network.sendTo(new PacketUpdatePlayerInformation((PlayerInformation) newInfo), (EntityPlayerMP) event.getEntityLiving());
    }
}
项目:Loot-Slash-Conquer    文件:CapabilityPlayerInformation.java   
@SubscribeEvent
public void onPlayerRespawn(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent event)
{
    PlayerInformation playerInfo = (PlayerInformation) event.player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
    Stats statsCap = (Stats) event.player.getCapability(CapabilityPlayerStats.STATS, null);

    if (playerInfo != null && statsCap != null)
    {
        statsCap.setMana(statsCap.getMaxMana());

        LootSlashConquer.network.sendTo(new PacketUpdatePlayerInformation(playerInfo), (EntityPlayerMP) event.player);
        LootSlashConquer.network.sendTo(new PacketUpdateStats(statsCap), (EntityPlayerMP) event.player);
    }
}
项目:Loot-Slash-Conquer    文件:CapabilityCurrentAbilities.java   
@SubscribeEvent
public void playerClone(PlayerEvent.Clone event) 
{
    ICurrentAbilities oldAbilities = getCurrentAbilities(event.getOriginal());
    ICurrentAbilities newAbilities = getCurrentAbilities(event.getEntityLiving());

    if (newAbilities != null && oldAbilities != null)
    {
        newAbilities.setAbilityInSlot(1, oldAbilities.getAbilityFromSlot(1));
        newAbilities.setAbilityInSlot(2, oldAbilities.getAbilityFromSlot(2));
        newAbilities.setAbilityInSlot(3, oldAbilities.getAbilityFromSlot(3));
        newAbilities.setAbilityInSlot(4, oldAbilities.getAbilityFromSlot(4));
    }
}
项目:pnc-repressurized    文件:PlayerEventSensor.java   
@Override
public int emitRedstoneOnEvent(Event event, TileEntity sensor, int range, String textboxText) {
    if (event instanceof PlayerEvent) {
        EntityPlayer player = ((PlayerEvent) event).getEntityPlayer();
        if (Math.abs(player.posX - sensor.getPos().getX() + 0.5D) < range + 0.5D && Math.abs(player.posY - sensor.getPos().getY() + 0.5D) < range + 0.5D && Math.abs(player.posZ - sensor.getPos().getZ() + 0.5D) < range + 0.5D) {
            return emitRedstoneOnEvent((PlayerEvent) event, sensor, range);
        }
    }
    return 0;
}
项目:pnc-repressurized    文件:PlayerAttackSensor.java   
@Override
public int emitRedstoneOnEvent(PlayerEvent event, TileEntity sensor, int range) {
    if (event instanceof AttackEntityEvent) {
        return 15;
    }
    return 0;
}
项目:pnc-repressurized    文件:PlayerItemPickupSensor.java   
@Override
public int emitRedstoneOnEvent(PlayerEvent event, TileEntity sensor, int range) {
    if (event instanceof EntityItemPickupEvent) {
        return 15;
    }
    return 0;
}
项目:Bewitchment    文件:DivinationEvents.java   
@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.Clone event) {
    EntityPlayer newPlayer = event.getEntityPlayer();
    EntityPlayer oldPlayer = event.getOriginal();
    CapabilityDivination newPlayerData = newPlayer.getCapability(CapabilityDivination.CAPABILITY, null);
    CapabilityDivination oldPlayerData = oldPlayer.getCapability(CapabilityDivination.CAPABILITY, null);
    newPlayerData.setFortune(oldPlayerData.getFortune());
}
项目:PAYDAY    文件:MEventHandler.java   
@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone e) {
    NBTTagCompound nbt = new NBTTagCompound();

    PlayerData.get(e.original).saveReviveRelevantNBTData(nbt, e.wasDeath);
    PlayerData.get(e.entityPlayer).loadNBTData(nbt);
}