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

项目:Aether-Legacy    文件:PlayerAetherEvents.java   
@SubscribeEvent
public void onPlayerCloned(Clone event)
{
    PlayerAether original = PlayerAether.get(event.getOriginal());

    PlayerAether newPlayer = PlayerAether.get(event.getEntityPlayer());

    NBTTagCompound data = new NBTTagCompound();

    if (original != null)
    {
        original.saveNBTData(data);

        if (newPlayer != null)
        {
            newPlayer.portalCooldown = original.portalCooldown;
            newPlayer.loadNBTData(data);
        }
    }
}
项目:morecommands    文件:CommonHandler.java   
/**
 * Invoked when a player is cloned. This is the case when he dies or beats the game and will be respawned
 * The problem with that is that a new player instance will be created for the player which is bad because all settings
 * are lost. Receiving this event allows to copy the settings to the new player object
 */
@SubscribeEvent
public void clonePlayer(Clone event) {
    if (!(event.getEntityPlayer() instanceof EntityPlayerMP) || !(event.getOriginal() instanceof EntityPlayerMP)) return;
    ServerPlayerSettings settings = event.getOriginal().getCapability(PlayerSettings.SETTINGS_CAP_SERVER, null);
    ServerPlayerSettings settings2 = event.getEntityPlayer().getCapability(PlayerSettings.SETTINGS_CAP_SERVER, null);

    AppliedPatches pp1 = event.getOriginal().getCapability(AppliedPatches.PATCHES_CAPABILITY, null);
    AppliedPatches pp2 = event.getEntityPlayer().getCapability(AppliedPatches.PATCHES_CAPABILITY, null);

    if (settings2 != null) //Should never be null
        settings2.init((EntityPlayerMP) event.getEntityPlayer(), settings);

    if (settings != null)
        for (ChatChannel channel : settings.chatChannels)
            channel.replaceRespawnedPlayer((EntityPlayerMP) event.getOriginal(), (EntityPlayerMP) event.getEntityPlayer());

    if (pp1 != pp2)
        pp2.copyFrom(pp1);

    MoreCommands.INSTANCE.getPacketDispatcher().sendS14RemoteWorld((EntityPlayerMP) event.getEntityPlayer(), event.getEntityPlayer().world.getSaveHandler().getWorldDirectory().getName());
}
项目:Bewitchment    文件:BrewEvents.java   
@SubscribeEvent
public void onPlayerClone(Clone event) {
    if (!event.isWasDeath()) {
        final EntityPlayer oldPlayer = event.getOriginal();
        final EntityPlayer newPlayer = event.getEntityPlayer();

        Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(oldPlayer);
        optional.ifPresent(oldStorage -> BrewStorageHandler.getBrewStorage(newPlayer).ifPresent(newStorage -> {
            newStorage.setBrewMap(oldStorage.getBrewMap());
            newStorage.syncToNear(newPlayer);
        }));
    }
}
项目:AbyssalCraft    文件:AbyssalCraftEventHooks.java   
@SubscribeEvent
public void onClonePlayer(Clone event) {
    if(event.isWasDeath())
        event.getEntityPlayer().getCapability(NecromancyCapabilityProvider.NECROMANCY_CAP, null).copy(event.getOriginal().getCapability(NecromancyCapabilityProvider.NECROMANCY_CAP, null));
}
项目:rpginventory    文件:RPGEventHooks.java   
@SubscribeEvent
public void onClone(Clone evt){

    if (evt.entityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")){

        NBTTagCompound tag = new NBTTagCompound();

        PlayerRpgInventory.get(evt.entityPlayer).writeToNBT(tag);

        PlayerRpgInventory.get(evt.original).loadNBTData(tag);

    }
}