Java Code Examples for net.minecraft.entity.player.EntityPlayer#getEntityData()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#getEntityData() .
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: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@SubscribeEvent @SuppressWarnings("unchecked") public void onWorldTick(TickEvent.ServerTickEvent event) { if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER) return; if (EtFuturum.enablePlayerSkinOverlay) if (playerLoggedInCooldown != null) if (--playerLoggedInCooldown <= 0) { for (World world : MinecraftServer.getServer().worldServers) for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) { NBTTagCompound nbt = player.getEntityData(); if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) { boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY); EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex)); } } playerLoggedInCooldown = null; } }
Example 2
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 6 votes |
private void updateKnockbackResistance(int artifactKnockbackCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldKnockbackCount = playerData.getInteger("artifactKnockbackCount"); if(oldKnockbackCount != artifactKnockbackCount) { String uu = playerData.getString("artifactKnockbackUUID"); UUID knockbackID; if(uu.equals("")) { knockbackID = UUID.randomUUID(); playerData.setString("artifactKnockbackUUID", knockbackID.toString()); } else { knockbackID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.knockbackResistance); atinst.removeModifier(new AttributeModifier(knockbackID, "KnockbackComponent", 0.2F * oldKnockbackCount, 0)); atinst.applyModifier(new AttributeModifier(knockbackID, "KnockbackComponent", 0.2F * artifactKnockbackCount, 0)); playerData.setInteger("artifactKnockbackCount", artifactKnockbackCount); } }
Example 3
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 6 votes |
private void updateSpeedBoost(int artifactSpeedBoostCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldSpeedBoostCount = playerData.getInteger("artifactSpeedBoostCount"); if(oldSpeedBoostCount != artifactSpeedBoostCount) { String uu = playerData.getString("artifactSpeedBoostUUID"); UUID speedID; if(uu.equals("")) { speedID = UUID.randomUUID(); playerData.setString("artifactSpeedBoostUUID", speedID.toString()); } else { speedID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed); atinst.removeModifier(new AttributeModifier(speedID, "SpeedBoostComponent", 0.05F * oldSpeedBoostCount, 2)); atinst.applyModifier(new AttributeModifier(speedID, "SpeedBoostComponent", 0.05F * artifactSpeedBoostCount, 2)); playerData.setInteger("artifactSpeedBoostCount", artifactSpeedBoostCount); } }
Example 4
Source File: NewRenderPlayer.java From Et-Futurum with The Unlicense | 5 votes |
private void setModel(EntityPlayer player) { boolean isAlex; NBTTagCompound nbt = player.getEntityData(); if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY); else isAlex = PlayerModelManager.isPlayerModelAlex(getEntityTexture(player)); mainModel = isAlex ? ALEX : STEVE; modelBipedMain = (ModelBiped) mainModel; }
Example 5
Source File: SetPlayerModelCommand.java From Et-Futurum with The Unlicense | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args) { if (args.length != 1 || !"alex".equals(args[0].toLowerCase()) && !"steve".equals(args[0].toLowerCase())) throw new WrongUsageException(getCommandUsage(sender)); if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; NBTTagCompound nbt = player.getEntityData(); boolean isAlex = "alex".equals(args[0].toLowerCase()); nbt.setBoolean(MODEL_KEY, isAlex); EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex)); } }
Example 6
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
/** * Method called to tame an entity, it will check that the player has slots * for taming, increase the taming count of the player, add the * player.username as the owner of the entity, and name the entity. * * @param ep * @param entity * @return */ public static boolean tameWithName(EntityPlayer ep, MoCIMoCreature entity) { //System.out.println("number of pets for " + ep + " = " + count + "limit = " + MoCreatures.proxy.getMaxTamed()); int max = 0; if (MoCreatures.proxy.enableOwnership) { max = MoCreatures.proxy.maxTamed; int count = MoCTools.numberTamedByPlayer(ep); if (isThisPlayerAnOP(ep)) { max = MoCreatures.proxy.maxOPTamed; } if (count >= max) { String message = "\2474" + ep.username + " can not tame more creatures, limit of " + max + " reached"; MoCServerPacketHandler.sendMsgToPlayer((EntityPlayerMP) ep, message); return false; } else { if (!entity.getOwnerName().equals(ep.username)) { NBTTagCompound nbtt = ep.getEntityData(); nbtt.setInteger("NumberTamed", count + 1); } } entity.setOwner(ep.username); } if (MoCreatures.isServer()) { MoCServerPacketHandler.sendNameGUI((EntityPlayerMP) ep, ((Entity) entity).entityId); } entity.setTamed(true); return true; }
Example 7
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
/** * returns the number of entities already tamed by the player ep * * @param ep * @return */ public static int numberTamedByPlayer(EntityPlayer ep) { NBTTagCompound nbtt = ep.getEntityData(); int count = nbtt.getInteger("NumberTamed"); return count; }
Example 8
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
/** * Decreases the number of entity tamed by the player by 1 * * @param ep */ public static void reduceTamedByPlayer(EntityPlayer ep) { int count = MoCTools.numberTamedByPlayer(ep); //System.out.println("tamed entities for online player " + ep.username + " =" + count); NBTTagCompound nbtt = ep.getEntityData(); count--; if (count < 0) { count = 0; } //System.out.println("reducing tamed count for player " + ep.username + " the count now is " + count); nbtt.setInteger("NumberTamed", count); }
Example 9
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 5 votes |
private void updateHealthBoost(int artifactHealthBoostCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldHealthBoostCount = playerData.getInteger("artifactHealthBoostCount"); if(oldHealthBoostCount != artifactHealthBoostCount) { String uu = playerData.getString("artifactHealthBoostUUID"); UUID healthID; if(uu.equals("")) { healthID = UUID.randomUUID(); playerData.setString("artifactHealthBoostUUID", healthID.toString()); } else { healthID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.maxHealth); atinst.removeModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * oldHealthBoostCount, 0)); atinst.applyModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * artifactHealthBoostCount, 0)); if(player.getHealth() > player.getMaxHealth()) { player.setHealth(player.getMaxHealth()); } int diff = (artifactHealthBoostCount - oldHealthBoostCount); if(diff > 0 && player.getHealth() < player.getMaxHealth()) { player.heal(5*diff); } playerData.setInteger("artifactHealthBoostCount", artifactHealthBoostCount); } }