當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerEvent.Clone方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.PlayerEvent.Clone方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerEvent.Clone方法的具體用法?Java PlayerEvent.Clone怎麽用?Java PlayerEvent.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.PlayerEvent的用法示例。


在下文中一共展示了PlayerEvent.Clone方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playerClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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());
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:21,代碼來源:CapabilityPlayerStats.java

示例2: onPlayerClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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);
	}
}
 
開發者ID:TwilightWingsStudio,項目名稱:HazardsLib,代碼行數:23,代碼來源:CommonEventHandler.java

示例3: checkPlayerNBT

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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));
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:20,代碼來源:UCEventHandlerServer.java

示例4: persistSoulDrain

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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) {}
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:22,代碼來源:EventHandlerServer.java

示例5: onDeath

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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());
}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:22,代碼來源:CivilizationHandlers.java

示例6: onClonePlayer

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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());

       }
   }
 
開發者ID:Ohrm,項目名稱:Malgra,代碼行數:19,代碼來源:MalgraEventHandler.java

示例7: onPlayerClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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());
                    }
                });
    }
}
 
開發者ID:InfinityRaider,項目名稱:InfinityLib,代碼行數:23,代碼來源:CapabilityHandler.java

示例8: OnDeadClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/**
 * ���������ʱ������ҵ�����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
}
 
開發者ID:NullaDev,項目名稱:KeyCraft,代碼行數:21,代碼來源:SubscribeOnDead.java

示例9: onPlayerRespawning

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/**
 * 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));
            }
        }
    }
}
 
開發者ID:Lumaceon,項目名稱:ClockworkPhase2,代碼行數:23,代碼來源:PlayerHandler.java

示例10: onPlayerRespawn

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
/**
 * 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);
        }
    }
}
 
開發者ID:Aurilux,項目名稱:Cybernetica,代碼行數:21,代碼來源:PlayerEventHandler.java

示例11: cloneEvent

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:DoubleDoorDevelopment,項目名稱:D3Core,代碼行數:18,代碼來源:DevPerks.java

示例12: onClonePlayer

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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));
		}
	}
}
 
開發者ID:PrinceOfAmber,項目名稱:SamsPowerups,代碼行數:17,代碼來源:ModCommands.java

示例13: onPlayerClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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());

        }
    }
}
 
開發者ID:legobmw99,項目名稱:Allomancy,代碼行數:17,代碼來源:CommonEventHandler.java

示例14: playerClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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());
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:34,代碼來源:CapabilityPlayerInformation.java

示例15: playerClone

import net.minecraftforge.event.entity.player.PlayerEvent; //導入方法依賴的package包/類
@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));
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:15,代碼來源:CapabilityCurrentAbilities.java


注:本文中的net.minecraftforge.event.entity.player.PlayerEvent.Clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。