Java Code Examples for net.minecraftforge.event.entity.player.PlayerEvent#Clone
The following examples show how to use
net.minecraftforge.event.entity.player.PlayerEvent#Clone .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CivilizationHandlers.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
@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()); }
Example 2
Source File: CyberwareDataHandler.java From Cyberware with MIT License | 6 votes |
@SubscribeEvent public void playerDeathEvent(PlayerEvent.Clone event) { EntityPlayer p = event.getEntityPlayer(); EntityPlayer o = event.getOriginal(); if (event.isWasDeath()) { if (p.worldObj.getWorldInfo().getGameRulesInstance().getBoolean(KEEP_WARE_GAMERULE)) { if (CyberwareAPI.hasCapability(o) && CyberwareAPI.hasCapability(o)) { CyberwareAPI.getCapability(p).deserializeNBT(CyberwareAPI.getCapability(o).serializeNBT()); } } } else { if (CyberwareAPI.hasCapability(o) && CyberwareAPI.hasCapability(o)) { CyberwareAPI.getCapability(p).deserializeNBT(CyberwareAPI.getCapability(o).serializeNBT()); } } }
Example 3
Source File: PlayerPropertyEvents.java From YouTubeModdingTutorial with MIT License | 5 votes |
@SubscribeEvent public void onPlayerCloned(PlayerEvent.Clone event) { if (event.isWasDeath()) { // We need to copyFrom the capabilities if (event.getOriginal().hasCapability(PlayerProperties.PLAYER_MANA, null)) { PlayerMana oldStore = event.getOriginal().getCapability(PlayerProperties.PLAYER_MANA, null); PlayerMana newStore = PlayerProperties.getPlayerMana(event.getEntityPlayer()); newStore.copyFrom(oldStore); } } }
Example 4
Source File: ItemBrainUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent public void handleClone(PlayerEvent.Clone event) { if (event.isWasDeath()) { EntityPlayer p = event.getOriginal(); if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 0)) && !p.worldObj.getGameRules().getBoolean("keepInventory")) { /*float range = 5F; List<EntityXPOrb> orbs = p.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(p.posX - range, p.posY - range, p.posZ - range, p.posX + p.width + range, p.posY + p.height + range, p.posZ + p.width + range)); for (EntityXPOrb orb : orbs) { orb.setDead(); }*/ if (!p.worldObj.isRemote) { ItemStack stack = new ItemStack(CyberwareContent.expCapsule); NBTTagCompound c = new NBTTagCompound(); c.setInteger("xp", p.experienceTotal); stack.setTagCompound(c); EntityItem item = new EntityItem(p.worldObj, p.posX, p.posY, p.posZ, stack); p.worldObj.spawnEntityInWorld(item); } } else if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 2)) && !p.worldObj.getGameRules().getBoolean("keepInventory")) { event.getEntityPlayer().addExperience((int) (Math.min(100, p.experienceLevel * 7) * .9F)); } } }
Example 5
Source File: EventSoulBound.java From Levels with GNU General Public License v2.0 | 5 votes |
@SubscribeEvent public void onPlayerClone(PlayerEvent.Clone event) { if (event.isWasDeath()) { EntityPlayer player = event.getEntityPlayer(); player.inventory.copyInventory(event.getOriginal().inventory); } }
Example 6
Source File: ProxyCommon.java From WearableBackpacks with MIT License | 5 votes |
@SubscribeEvent public void onPlayerClone(PlayerEvent.Clone event) { // This comes into play when the "keepInventory" gamerule is on. // In that case, onLivingDeath will keep the backpack information, // so we can transfer it to the new player entity. IBackpack originalBackpack = BackpackHelper.getBackpack(event.getOriginal()); if (originalBackpack == null) return; EntityPlayer player = event.getEntityPlayer(); IBackpack clonedBackpack = player.getCapability(IBackpack.CAPABILITY, null); clonedBackpack.setStack(originalBackpack.getStack()); clonedBackpack.setData(originalBackpack.getData()); }