@Override public void readFromNBT(NBTTagCompound tagCom) { TEC.idToUsername.clear(); NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10); for (int i = 0; i < idUsernameTag.tagCount(); i++) { NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i); TEC.idToUsername.put( UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName")); } TEC.aspectBuffer.clear(); NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10); for (int i = 0; i < bufferTag.tagCount(); i++) { NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i); UUID playerID = UUID.fromString(idedBuffer.getString("playerID")); NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10); for (int j = 0; j < playersBuffer.tagCount(); j++) { NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j); NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan"); ScanResult scan = new ScanResult( scanTag.getByte("type"), scanTag.getInteger("id"), scanTag.getInteger("meta"), EntityList.createEntityFromNBT( scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)), scanTag.getString("phenomena")); TEC.addAspect( playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent")); } } }
@Override public boolean onItemUse( ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { if (world.isRemote) { return true; } if (!containsSoul(itemstack)) { return false; } if (player == null) { return false; } Entity mob; NBTTagCompound root = itemstack.stackTagCompound; if (root.hasKey("isStub")) { String entityId = root.getString("id"); mob = EntityList.createEntityByName(entityId, world); } else { mob = EntityList.createEntityFromNBT(root, world); } if (mob == null) { return true; } mob.readFromNBT(root); Block blk = world.getBlock(x, y, z); double spawnX = x + Facing.offsetsXForSide[side] + 0.5; double spawnY = y + Facing.offsetsYForSide[side]; double spawnZ = z + Facing.offsetsZForSide[side] + 0.5; if (side == ForgeDirection.UP.ordinal() && (blk instanceof BlockFence || blk instanceof BlockWall)) { spawnY += 0.5; } mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0); boolean spaceClear = world.checkNoEntityCollision(mob.boundingBox) && world.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty(); if (!spaceClear) { return false; } if (itemstack.hasDisplayName() && mob instanceof EntityLiving) { ((EntityLiving) mob).setCustomNameTag(itemstack.getDisplayName()); } world.spawnEntityInWorld(mob); if (mob instanceof EntityLiving) { ((EntityLiving) mob).playLivingSound(); } Entity riddenByEntity = mob.riddenByEntity; while (riddenByEntity != null) { riddenByEntity.setLocationAndAngles( spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F); world.spawnEntityInWorld(riddenByEntity); if (riddenByEntity instanceof EntityLiving) { ((EntityLiving) riddenByEntity).playLivingSound(); } riddenByEntity = riddenByEntity.riddenByEntity; } if (!player.capabilities.isCreativeMode) { if (itemstack.stackSize > 1) { itemstack.stackSize--; player.inventory.addItemStackToInventory(new ItemStack(this)); player.inventoryContainer.detectAndSendChanges(); } else { itemstack.setTagCompound(null); } } return true; }
public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP playerIn) { GameProfile var3 = playerIn.getGameProfile(); PlayerProfileCache var4 = this.mcServer.getPlayerProfileCache(); GameProfile var5 = var4.func_152652_a(var3.getId()); String var6 = var5 == null ? var3.getName() : var5.getName(); var4.func_152649_a(var3); NBTTagCompound var7 = this.readPlayerDataFromFile(playerIn); playerIn.setWorld(this.mcServer.worldServerForDimension(playerIn.dimension)); playerIn.theItemInWorldManager.setWorld((WorldServer) playerIn.worldObj); String var8 = "local"; if (netManager.getRemoteAddress() != null) { var8 = netManager.getRemoteAddress().toString(); } logger.info( playerIn.getName() + "[" + var8 + "] logged in with entity id " + playerIn.getEntityId() + " at (" + playerIn.posX + ", " + playerIn.posY + ", " + playerIn.posZ + ")"); WorldServer var9 = this.mcServer.worldServerForDimension(playerIn.dimension); WorldInfo var10 = var9.getWorldInfo(); BlockPos var11 = var9.getSpawnPoint(); this.func_72381_a(playerIn, (EntityPlayerMP) null, var9); NetHandlerPlayServer var12 = new NetHandlerPlayServer(this.mcServer, netManager, playerIn); var12.sendPacket( new S01PacketJoinGame( playerIn.getEntityId(), playerIn.theItemInWorldManager.getGameType(), var10.isHardcoreModeEnabled(), var9.provider.getDimensionId(), var9.getDifficulty(), this.getMaxPlayers(), var10.getTerrainType(), var9.getGameRules().getGameRuleBooleanValue("reducedDebugInfo"))); var12.sendPacket( new S3FPacketCustomPayload( "MC|Brand", (new PacketBuffer(Unpooled.buffer())) .writeString(this.getServerInstance().getServerModName()))); var12.sendPacket( new S41PacketServerDifficulty(var10.getDifficulty(), var10.isDifficultyLocked())); var12.sendPacket(new S05PacketSpawnPosition(var11)); var12.sendPacket(new S39PacketPlayerAbilities(playerIn.capabilities)); var12.sendPacket(new S09PacketHeldItemChange(playerIn.inventory.currentItem)); playerIn.getStatFile().func_150877_d(); playerIn.getStatFile().func_150884_b(playerIn); this.func_96456_a((ServerScoreboard) var9.getScoreboard(), playerIn); this.mcServer.refreshStatusNextTick(); ChatComponentTranslation var13; if (!playerIn.getName().equalsIgnoreCase(var6)) { var13 = new ChatComponentTranslation( "multiplayer.player.joined.renamed", new Object[] {playerIn.getDisplayName(), var6}); } else { var13 = new ChatComponentTranslation( "multiplayer.player.joined", new Object[] {playerIn.getDisplayName()}); } var13.getChatStyle().setColor(EnumChatFormatting.YELLOW); this.sendChatMsg(var13); this.playerLoggedIn(playerIn); var12.setPlayerLocation( playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch); this.updateTimeAndWeatherForPlayer(playerIn, var9); if (this.mcServer.getResourcePackUrl().length() > 0) { playerIn.func_175397_a( this.mcServer.getResourcePackUrl(), this.mcServer.getResourcePackHash()); } Iterator var14 = playerIn.getActivePotionEffects().iterator(); while (var14.hasNext()) { PotionEffect var15 = (PotionEffect) var14.next(); var12.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), var15)); } playerIn.addSelfToInternalCraftingInventory(); if (var7 != null && var7.hasKey("Riding", 10)) { Entity var16 = EntityList.createEntityFromNBT(var7.getCompoundTag("Riding"), var9); if (var16 != null) { var16.forceSpawn = true; var9.spawnEntityInWorld(var16); playerIn.mountEntity(var16); var16.forceSpawn = false; } } }
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) { if (par2ArrayOfStr.length >= 1) { String var3 = par2ArrayOfStr[0]; double var4 = (double) par1ICommandSender.getCommandSenderPosition().posX + 0.5D; double var6 = (double) par1ICommandSender.getCommandSenderPosition().posY; double var8 = (double) par1ICommandSender.getCommandSenderPosition().posZ + 0.5D; if (par2ArrayOfStr.length >= 4) { var4 = func_110666_a(par1ICommandSender, var4, par2ArrayOfStr[1]); var6 = func_110666_a(par1ICommandSender, var6, par2ArrayOfStr[2]); var8 = func_110666_a(par1ICommandSender, var8, par2ArrayOfStr[3]); } World var10 = par1ICommandSender.getEntityWorld(); if (!var10.blockExists((int) var4, (int) var6, (int) var8)) { notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]); } else { NBTTagCompound var11 = new NBTTagCompound(); boolean var12 = false; if (par2ArrayOfStr.length >= 5) { IChatComponent var13 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4); try { NBTBase var14 = JsonToNBT.func_150315_a(var13.getUnformattedText()); if (!(var14 instanceof NBTTagCompound)) { notifyAdmins( par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"}); return; } var11 = (NBTTagCompound) var14; var12 = true; } catch (NBTException var17) { notifyAdmins( par1ICommandSender, "commands.summon.tagError", new Object[] {var17.getMessage()}); return; } } var11.setString("id", var3); Entity var18 = EntityList.createEntityFromNBT(var11, var10); if (var18 != null) { var18.setLocationAndAngles(var4, var6, var8, var18.rotationYaw, var18.rotationPitch); if (!var12 && var18 instanceof EntityLiving) { ((EntityLiving) var18).onSpawnWithEgg((IEntityLivingData) null); } var10.spawnEntityInWorld(var18); Entity var19 = var18; for (NBTTagCompound var15 = var11; var15.func_150297_b("Riding", 10); var15 = var15.getCompoundTag("Riding")) { Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), var10); if (var16 != null) { var16.setLocationAndAngles(var4, var6, var8, var16.rotationYaw, var16.rotationPitch); var10.spawnEntityInWorld(var16); var19.mountEntity(var16); } var19 = var16; } notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]); } else { notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]); } } } else { throw new WrongUsageException("commands.summon.usage", new Object[0]); } }