Пример #1
0
        public virtual void DoLogin(net.minecraft.src.Packet1Login packet1login)
        {
            net.minecraft.src.EntityPlayerMP entityplayermp = mcServer.serverConfigurationManager.Login(this, packet1login.username);
            if (entityplayermp != null)
            {
                mcServer.serverConfigurationManager.ReadPlayerDataFromFile(entityplayermp);
                entityplayermp.SetWorldHandler(mcServer.GetWorldServer(entityplayermp.dimension));

                //TODO: Cleanup all java.lang.StringBuilder instances
                //logger.Info((new java.lang.StringBuilder()).Append(GetUserAndIPString()).Append(" logged in with entity id ").Append(entityplayermp.entityId).Append(" at (").Append(entityplayermp.posX).Append(", ").Append(entityplayermp.posY).Append(", ").Append(entityplayermp.posZ).Append(")").ToString());
                logger.Info($"{GetUserAndIPString()} logged in with entity id {entityplayermp.entityId} at ({entityplayermp.posX}, {entityplayermp.posY}, {entityplayermp.posZ})");

                net.minecraft.src.WorldServer      worldserver      = mcServer.GetWorldServer(entityplayermp.dimension);
                net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
                net.minecraft.src.NetServerHandler netserverhandler = new net.minecraft.src.NetServerHandler(mcServer, netManager, entityplayermp);

                netserverhandler.SendPacket(new net.minecraft.src.Packet1Login(string.Empty, entityplayermp.entityId, worldserver.GetSeed(), unchecked ((byte)worldserver.worldProvider.worldType)));
                netserverhandler.SendPacket(new net.minecraft.src.Packet6SpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));

                mcServer.serverConfigurationManager.Func_28170_a(entityplayermp, worldserver);

                //TODO: Defer login message to hook
                //mcServer.configManager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat((new java.lang.StringBuilder()).Append("\xf7e").Append(entityplayermp.username).Append(" joined the game.").ToString()));
                mcServer.serverConfigurationManager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat($"§e{entityplayermp.username} joined the game."));
                mcServer.serverConfigurationManager.PlayerLoggedIn(entityplayermp);

                netserverhandler.TeleportTo(entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ, entityplayermp.rotationYaw, entityplayermp.rotationPitch);
                mcServer.networkServer.AddPlayer(netserverhandler);

                netserverhandler.SendPacket(new net.minecraft.src.Packet4UpdateTime(worldserver.GetWorldTime()));

                entityplayermp.Func_20057_k();
            }
            finishedProcessing = true;
        }
Пример #2
0
 public EntityPlayer(net.minecraft.src.World world)
     : base(world)
 {
     // Referenced classes of package net.minecraft.src:
     //            EntityLiving, InventoryPlayer, ContainerPlayer, World,
     //            ChunkCoordinates, DataWatcher, Container, StatList,
     //            MathHelper, AxisAlignedBB, Entity, ItemStack,
     //            Item, EntityItem, Material, NBTTagCompound,
     //            NBTTagList, EntityMob, EntityArrow, EntityCreeper,
     //            EntityGhast, EntityWolf, EnumStatus, WorldProvider,
     //            BlockBed, Block, IChunkProvider, EntityMinecart,
     //            AchievementList, EntityBoat, EntityPig, EntityFish,
     //            IInventory, TileEntityFurnace, TileEntityDispenser, TileEntitySign,
     //            StatBase
     inventory                 = new net.minecraft.src.InventoryPlayer(this);
     field_9152_am             = 0;
     score                     = 0;
     isSwinging                = false;
     swingProgressInt          = 0;
     timeUntilPortal           = 20;
     inPortal                  = false;
     damageRemainder           = 0;
     fishEntity                = null;
     personalCraftingInventory = new net.minecraft.src.ContainerPlayer(inventory, !world.singleplayerWorld);
     currentCraftingInventory  = personalCraftingInventory;
     yOffset                   = 1.62F;
     net.minecraft.src.ChunkCoordinates chunkcoordinates = world.GetSpawnPoint();
     SetLocationAndAngles((double)chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 1, (double)chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F);
     health         = 20;
     entityType     = "humanoid";
     field_9117_aI  = 180F;
     fireResistance = 20;
     texture        = "/mob/char.png";
 }
Пример #3
0
 public static net.minecraft.src.ChunkCoordinates Func_25051_a(net.minecraft.src.World
                                                               world, net.minecraft.src.ChunkCoordinates chunkcoordinates)
 {
     net.minecraft.src.IChunkProvider ichunkprovider = world.GetChunkProvider();
     ichunkprovider.LoadChunk(chunkcoordinates.posX - 3 >> 4, chunkcoordinates.posZ -
                              3 >> 4);
     ichunkprovider.LoadChunk(chunkcoordinates.posX + 3 >> 4, chunkcoordinates.posZ -
                              3 >> 4);
     ichunkprovider.LoadChunk(chunkcoordinates.posX - 3 >> 4, chunkcoordinates.posZ +
                              3 >> 4);
     ichunkprovider.LoadChunk(chunkcoordinates.posX + 3 >> 4, chunkcoordinates.posZ +
                              3 >> 4);
     if (world.GetBlockId(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates
                          .posZ) != net.minecraft.src.Block.BED.ID)
     {
         return(null);
     }
     else
     {
         net.minecraft.src.ChunkCoordinates chunkcoordinates1 = net.minecraft.src.BlockBed
                                                                .Func_22021_g(world, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates
                                                                              .posZ, 0);
         return(chunkcoordinates1);
     }
 }
 public virtual net.minecraft.src.EntityPlayerMP RecreatePlayerEntity(net.minecraft.src.EntityPlayerMP
                                                                      entityplayermp, int i)
 {
     mcServer.GetEntityTracker(entityplayermp.dimension).RemoveTrackedPlayerSymmetric(
         entityplayermp);
     mcServer.GetEntityTracker(entityplayermp.dimension).UntrackEntity(entityplayermp);
     GetPlayerManager(entityplayermp.dimension).RemovePlayer(entityplayermp);
     playerEntities.Remove(entityplayermp);
     mcServer.GetWorldServer(entityplayermp.dimension).RemovePlayer(entityplayermp);
     net.minecraft.src.ChunkCoordinates chunkcoordinates = entityplayermp.GetSpawnChunk
                                                               ();
     entityplayermp.dimension = i;
     net.minecraft.src.EntityPlayerMP entityplayermp1 = new net.minecraft.src.EntityPlayerMP
                                                            (mcServer, mcServer.GetWorldServer(entityplayermp.dimension), entityplayermp.username
                                                            , new net.minecraft.src.ItemInWorldManager(mcServer.GetWorldServer(entityplayermp
                                                                                                                               .dimension)));
     entityplayermp1.entityId         = entityplayermp.entityId;
     entityplayermp1.netServerHandler = entityplayermp.netServerHandler;
     net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp
                                                                         .dimension);
     if (chunkcoordinates != null)
     {
         net.minecraft.src.ChunkCoordinates chunkcoordinates1 = net.minecraft.src.EntityPlayer
                                                                .Func_25051_a(mcServer.GetWorldServer(entityplayermp.dimension), chunkcoordinates
                                                                              );
         if (chunkcoordinates1 != null)
         {
             entityplayermp1.SetLocationAndAngles((float)chunkcoordinates1.posX + 0.5F, (float
                                                                                         )chunkcoordinates1.posY + 0.1F, (float)chunkcoordinates1.posZ + 0.5F, 0.0F, 0.0F
                                                  );
             entityplayermp1.SetSpawnChunk(chunkcoordinates);
         }
         else
         {
             entityplayermp1.netServerHandler.SendPacket(new net.minecraft.src.Packet70Bed
                                                             (0));
         }
     }
     worldserver.chunkProviderServer.LoadChunk((int)entityplayermp1.posX >> 4, (int)entityplayermp1
                                               .posZ >> 4);
     for (; worldserver.GetCollidingBoundingBoxes(entityplayermp1, entityplayermp1.boundingBox
                                                  ).Count != 0; entityplayermp1.SetPosition(entityplayermp1.posX, entityplayermp1.
                                                                                            posY + 1.0D, entityplayermp1.posZ))
     {
     }
     entityplayermp1.netServerHandler.SendPacket(new net.minecraft.src.Packet9Respawn
                                                     (unchecked ((byte)entityplayermp1.dimension)));
     entityplayermp1.netServerHandler.TeleportTo(entityplayermp1.posX, entityplayermp1
                                                 .posY, entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch
                                                 );
     Func_28170_a(entityplayermp1, worldserver);
     GetPlayerManager(entityplayermp1.dimension).AddPlayer(entityplayermp1);
     worldserver.AddEntity(entityplayermp1);
     playerEntities.Add(entityplayermp1);
     entityplayermp1.Func_20057_k();
     entityplayermp1.Func_22068_s();
     return(entityplayermp1);
 }
Пример #5
0
 public virtual void SetSpawnChunk(net.minecraft.src.ChunkCoordinates chunkcoordinates
                                   )
 {
     if (chunkcoordinates != null)
     {
         spawnChunk = new net.minecraft.src.ChunkCoordinates(chunkcoordinates);
     }
     else
     {
         spawnChunk = null;
     }
 }
Пример #6
0
        public virtual void Func_374_c(int i, int j)
        {
            net.minecraft.src.ChunkCoordinates chunkcoordinates = world.GetSpawnPoint();
            int   k = (i * 16 + 8) - chunkcoordinates.posX;
            int   l = (j * 16 + 8) - chunkcoordinates.posZ;
            short c = 128;//'\200';

            if (k < -c || k > c || l < -c || l > c)
            {
                field_725_a.Add(net.minecraft.src.ChunkCoordIntPair.ChunkXZ2Int(i, j));
            }
        }
Пример #7
0
 public override bool Equals(object obj)
 {
     if (!(obj is net.minecraft.src.ChunkCoordinates))
     {
         return(false);
     }
     else
     {
         net.minecraft.src.ChunkCoordinates chunkcoordinates = (net.minecraft.src.ChunkCoordinates
                                                                )obj;
         return(posX == chunkcoordinates.posX && posY == chunkcoordinates.posY && posZ ==
                chunkcoordinates.posZ);
     }
 }
Пример #8
0
 public virtual void WakeUpPlayer(bool resetSleepTimer, bool updateAllPlayersSleeping, bool setSpawnAtBed)
 {
     if (!sleeping)
     {
         return;            // CRAFTBUKKIT: Can't leave bed if not in one
     }
     SetSize(0.6F, 1.8F);
     ResetHeight();
     net.minecraft.src.ChunkCoordinates chunkcoordinates  = playerLocation;
     net.minecraft.src.ChunkCoordinates chunkcoordinates1 = playerLocation;
     if (chunkcoordinates != null && worldObj.GetBlockId(chunkcoordinates.posX, chunkcoordinates
                                                         .posY, chunkcoordinates.posZ) == net.minecraft.src.Block.BED.ID)
     {
         net.minecraft.src.BlockBed.Func_22022_a(worldObj, chunkcoordinates.posX, chunkcoordinates
                                                 .posY, chunkcoordinates.posZ, false);
         net.minecraft.src.ChunkCoordinates chunkcoordinates2 = net.minecraft.src.BlockBed
                                                                .Func_22021_g(worldObj, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates
                                                                              .posZ, 0);
         if (chunkcoordinates2 == null)
         {
             chunkcoordinates2 = new net.minecraft.src.ChunkCoordinates(chunkcoordinates.posX,
                                                                        chunkcoordinates.posY + 1, chunkcoordinates.posZ);
         }
         SetPosition((float)chunkcoordinates2.posX + 0.5F, (float)chunkcoordinates2.posY +
                     yOffset + 0.1F, (float)chunkcoordinates2.posZ + 0.5F);
     }
     sleeping = false;
     if (!worldObj.singleplayerWorld && updateAllPlayersSleeping)
     {
         worldObj.UpdateAllPlayersSleepingFlag();
     }
     if (resetSleepTimer)
     {
         sleepTimer = 0;
     }
     else
     {
         sleepTimer = 100;
     }
     if (setSpawnAtBed)
     {
         SetSpawnChunk(playerLocation);
     }
 }
Пример #9
0
 public virtual int CompareChunkCoordinate(net.minecraft.src.ChunkCoordinates chunkcoordinates
                                           )
 {
     if (posY == chunkcoordinates.posY)
     {
         if (posZ == chunkcoordinates.posZ)
         {
             return(posX - chunkcoordinates.posX);
         }
         else
         {
             return(posZ - chunkcoordinates.posZ);
         }
     }
     else
     {
         return(posY - chunkcoordinates.posY);
     }
 }
Пример #10
0
 private void UpdateRideDistanceStatistics(double d, double d1, double d2)
 {
     if (ridingEntity != null)
     {
         int i = (int)System.Math.Round(net.minecraft.src.MathHelper.Sqrt_double(d * d + d1 * d1 + d2 * d2) * 100F);
         if (i > 0)
         {
             if (ridingEntity is net.minecraft.src.EntityMinecart)
             {
                 AddStat(net.minecraft.src.StatList.StatMinecartOneCm, i);
                 if (field_27995_d == null)
                 {
                     field_27995_d = new net.minecraft.src.ChunkCoordinates(net.minecraft.src.MathHelper
                                                                            .Floor_double(posX), net.minecraft.src.MathHelper.Floor_double(posY), net.minecraft.src.MathHelper
                                                                            .Floor_double(posZ));
                 }
                 else
                 {
                     if (field_27995_d.GetSqDistanceTo(net.minecraft.src.MathHelper.Floor_double(posX)
                                                       , net.minecraft.src.MathHelper.Floor_double(posY), net.minecraft.src.MathHelper.
                                                       Floor_double(posZ)) >= 1000D)
                     {
                         AddStat(net.minecraft.src.AchievementList.aOnARail, 1);
                     }
                 }
             }
             else
             {
                 if (ridingEntity is net.minecraft.src.EntityBoat)
                 {
                     AddStat(net.minecraft.src.StatList.StatBoatOneCm, i);
                 }
                 else
                 {
                     if (ridingEntity is net.minecraft.src.EntityPig)
                     {
                         AddStat(net.minecraft.src.StatList.StatPigOneCm, i);
                     }
                 }
             }
         }
     }
 }
Пример #11
0
        public EntityPlayerMP(net.minecraft.server.MinecraftServer minecraftserver, net.minecraft.src.World
                              world, string s, net.minecraft.src.ItemInWorldManager iteminworldmanager)
            : base(world)
        {
            // Referenced classes of package net.minecraft.src:
            //            EntityPlayer, ICrafting, ItemStack, ItemInWorldManager,
            //            World, ChunkCoordinates, WorldProvider, WorldServer,
            //            Container, Packet5PlayerInventory, EntityTracker, InventoryPlayer,
            //            EntityArrow, Item, NetServerHandler, ItemMapBase,
            //            ChunkCoordIntPair, Packet51MapChunk, TileEntity, PropertyManager,
            //            ServerConfigurationManager, Packet8UpdateHealth, Entity, EntityItem,
            //            Packet22Collect, Packet18Animation, EnumStatus, Packet17Sleep,
            //            Packet39AttachEntity, Packet100OpenWindow, ContainerWorkbench, IInventory,
            //            ContainerChest, TileEntityFurnace, ContainerFurnace, TileEntityDispenser,
            //            ContainerDispenser, SlotCrafting, Packet103SetSlot, Packet104WindowItems,
            //            Packet105UpdateProgressbar, Packet101CloseWindow, StatBase, Packet200Statistic,
            //            StringTranslate, Packet3Chat
            chunkCoordIntPairQueue   = new List <ChunkCoordIntPair>();
            playerChunkCoordIntPairs = new HashSet <ChunkCoordIntPair>();
            lastHealth      = unchecked ((int)(0xfa0a1f01));
            ticksOfInvuln   = 60;
            currentWindowId = 0;
            iteminworldmanager.thisPlayer = this;
            itemInWorldManager            = iteminworldmanager;
            net.minecraft.src.ChunkCoordinates chunkcoordinates = world.GetSpawnPoint();
            int i = chunkcoordinates.posX;
            int j = chunkcoordinates.posZ;
            int k = chunkcoordinates.posY;

            if (!world.worldProvider.worldHasSky)
            {
                i += rand.Next(20) - 10;
                k  = world.FindTopSolidBlock(i, j);
                j += rand.Next(20) - 10;
            }
            SetLocationAndAngles((double)i + 0.5D, k, (double)j + 0.5D, 0.0F, 0.0F);
            mcServer   = minecraftserver;
            stepHeight = 0.0F;
            username   = s;
            yOffset    = 0.0F;
        }
Пример #12
0
 protected internal override void ReadEntityFromNBT(net.minecraft.src.NBTTagCompound
                                                    nbttagcompound)
 {
     base.ReadEntityFromNBT(nbttagcompound);
     net.minecraft.src.NBTTagList nbttaglist = nbttagcompound.GetTagList("Inventory");
     inventory.ReadFromNBT(nbttaglist);
     dimension  = nbttagcompound.GetInteger("Dimension");
     sleeping   = nbttagcompound.GetBoolean("Sleeping");
     sleepTimer = nbttagcompound.GetShort("SleepTimer");
     if (sleeping)
     {
         playerLocation = new net.minecraft.src.ChunkCoordinates(net.minecraft.src.MathHelper
                                                                 .Floor_double(posX), net.minecraft.src.MathHelper.Floor_double(posY), net.minecraft.src.MathHelper
                                                                 .Floor_double(posZ));
         WakeUpPlayer(true, true, false);
     }
     if (nbttagcompound.HasKey("SpawnX") && nbttagcompound.HasKey("SpawnY") && nbttagcompound
         .HasKey("SpawnZ"))
     {
         spawnChunk = new net.minecraft.src.ChunkCoordinates(nbttagcompound.GetInteger("SpawnX"
                                                                                       ), nbttagcompound.GetInteger("SpawnY"), nbttagcompound.GetInteger("SpawnZ"));
     }
 }
Пример #13
0
 public static int PerformSpawning(net.minecraft.src.World var0, bool var1, bool var2
                                   )
 {
     if (!var1 && !var2)
     {
         return(0);
     }
     else
     {
         eligibleChunksForSpawning.Clear();
         int var3;
         int var6;
         for (var3 = 0; var3 < var0.playerEntities.Count; ++var3)
         {
             net.minecraft.src.EntityPlayer var4 = (net.minecraft.src.EntityPlayer)var0.playerEntities
                                                   [var3];
             int var5 = net.minecraft.src.MathHelper.Floor_double(var4.posX / 16.0D);
             var6 = net.minecraft.src.MathHelper.Floor_double(var4.posZ / 16.0D);
             byte var7 = 8;
             for (int var8 = -var7; var8 <= var7; ++var8)
             {
                 for (int var9 = -var7; var9 <= var7; ++var9)
                 {
                     eligibleChunksForSpawning.Add(new net.minecraft.src.ChunkCoordIntPair(var8 + var5, var9 + var6));
                 }
             }
         }
         var3 = 0;
         net.minecraft.src.ChunkCoordinates   var35 = var0.GetSpawnPoint();
         net.minecraft.src.EnumCreatureType[] var36 = net.minecraft.src.EnumCreatureType.Values();
         var6 = var36.Length;
         for (int var37 = 0; var37 < var6; ++var37)
         {
             net.minecraft.src.EnumCreatureType var38 = var36[var37];
             if ((!var38.Func_21103_d() || var2) && (var38.Func_21103_d() || var1) && var0.CountEntities
                     (var38.GetCreatureClass()) <= var38.GetMaxNumberOfCreature() * eligibleChunksForSpawning
                 .Count / 256)
             {
                 System.Collections.IEnumerator var39 = eligibleChunksForSpawning.GetEnumerator();
                 while (var39.MoveNext())
                 {
                     net.minecraft.src.ChunkCoordIntPair var10 = (net.minecraft.src.ChunkCoordIntPair)
                                                                 var39.Current;
                     net.minecraft.src.BiomeGenBase var11 = var0.GetWorldChunkManager().Func_4066_a(var10
                                                                                                    );
                     System.Collections.IList var12 = var11.GetSpawnableList(var38);
                     if (var12 != null && var12.Count > 0)
                     {
                         int var13 = 0;
                         net.minecraft.src.SpawnListEntry var15;
                         for (System.Collections.IEnumerator var14 = var12.GetEnumerator(); var14.MoveNext
                                  (); var13 += var15.spawnRarityRate)
                         {
                             var15 = (net.minecraft.src.SpawnListEntry)var14.Current;
                         }
                         int var40 = var0.rand.Next(var13);
                         var15 = (net.minecraft.src.SpawnListEntry)var12[0];
                         System.Collections.IEnumerator var16 = var12.GetEnumerator();
                         while (var16.MoveNext())
                         {
                             net.minecraft.src.SpawnListEntry var17 = (net.minecraft.src.SpawnListEntry)var16.
                                                                      Current;
                             var40 -= var17.spawnRarityRate;
                             if (var40 < 0)
                             {
                                 var15 = var17;
                                 break;
                             }
                         }
                         net.minecraft.src.ChunkPosition var41 = GetRandomSpawningPointInChunk(var0, var10
                                                                                               .X * 16, var10.Z * 16);
                         int var42 = var41.x;
                         int var18 = var41.y;
                         int var19 = var41.z;
                         if (!var0.IsBlockNormalCube(var42, var18, var19) && var0.GetBlockMaterial(var42,
                                                                                                   var18, var19) == var38.GetCreatureMaterial())
                         {
                             int var20 = 0;
                             for (int var21 = 0; var21 < 3; ++var21)
                             {
                                 int  var22 = var42;
                                 int  var23 = var18;
                                 int  var24 = var19;
                                 byte var25 = 6;
                                 for (int var26 = 0; var26 < 4; ++var26)
                                 {
                                     var22 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     var23 += var0.rand.Next(1) - var0.rand.Next(1);
                                     var24 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     if (Func_21167_a(var38, var0, var22, var23, var24))
                                     {
                                         float var27 = (float)var22 + 0.5F;
                                         float var28 = (float)var23;
                                         float var29 = (float)var24 + 0.5F;
                                         if (var0.GetClosestPlayer((double)var27, (double)var28, (double)var29, 24.0D) ==
                                             null)
                                         {
                                             float var30 = var27 - (float)var35.posX;
                                             float var31 = var28 - (float)var35.posY;
                                             float var32 = var29 - (float)var35.posZ;
                                             float var33 = var30 * var30 + var31 * var31 + var32 * var32;
                                             if (var33 >= 576.0F)
                                             {
                                                 net.minecraft.src.EntityLiving var43;
                                                 try
                                                 {
                                                     var43 = (net.minecraft.src.EntityLiving)(var15.entityClass.GetConstructor(new System.Type[] { typeof(net.minecraft.src.World) }).Invoke(new object[] { var0 }));
                                                 }
                                                 catch (System.Exception var34)
                                                 {
                                                     Sharpen.Runtime.PrintStackTrace(var34);
                                                     return(var3);
                                                 }
                                                 var43.SetLocationAndAngles((double)var27, (double)var28, (double)var29, var0.rand
                                                                            .NextFloat() * 360.0F, 0.0F);
                                                 if (var43.GetCanSpawnHere())
                                                 {
                                                     ++var20;
                                                     var0.AddEntity(var43);
                                                     Func_21166_a(var43, var0, var27, var28, var29);
                                                     if (var20 >= var43.GetMaxSpawnedInChunk())
                                                     {
                                                         goto label113_continue;
                                                     }
                                                 }
                                                 var3 += var20;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     label113_continue :;
                 }
                 label113_break :;
             }
         }
         return(var3);
     }
 }
Пример #14
0
        public virtual net.minecraft.src.EnumStatus GoToSleep(int i, int j, int k)
        {
            if (!worldObj.singleplayerWorld)
            {
                if (IsSleeping() || !IsEntityAlive())
                {
                    return(net.minecraft.src.EnumStatus.OTHER_PROBLEM);
                }
                if (worldObj.worldProvider.sleepDisallowed)
                {
                    return(net.minecraft.src.EnumStatus.NOT_POSSIBLE_HERE);
                }
                if (worldObj.IsDaytime())
                {
                    return(net.minecraft.src.EnumStatus.NOT_POSSIBLE_NOW);
                }
                if (System.Math.Abs(posX - (double)i) > 3D || System.Math.Abs(posY - (double)j) >
                    2D || System.Math.Abs(posZ - (double)k) > 3D)
                {
                    return(net.minecraft.src.EnumStatus.TOO_FAR_AWAY);
                }
            }
            SetSize(0.2F, 0.2F);
            yOffset = 0.2F;
            if (worldObj.BlockExists(i, j, k))
            {
                int   l  = worldObj.GetBlockMetadata(i, j, k);
                int   i1 = net.minecraft.src.BlockBed.Func_22019_c(l);
                float f  = 0.5F;
                float f1 = 0.5F;
                switch (i1)
                {
                case 0:
                {
                    // '\0'
                    f1 = 0.9F;
                    break;
                }

                case 2:
                {
                    // '\002'
                    f1 = 0.1F;
                    break;
                }

                case 1:
                {
                    // '\001'
                    f = 0.1F;
                    break;
                }

                case 3:
                {
                    // '\003'
                    f = 0.9F;
                    break;
                }
                }
                Func_22059_e(i1);
                SetPosition((float)i + f, (float)j + 0.9375F, (float)k + f1);
            }
            else
            {
                SetPosition((float)i + 0.5F, (float)j + 0.9375F, (float)k + 0.5F);
            }
            sleeping       = true;
            sleepTimer     = 0;
            playerLocation = new net.minecraft.src.ChunkCoordinates(i, j, k);
            motionX        = motionZ = motionY = 0.0D;
            if (!worldObj.singleplayerWorld)
            {
                worldObj.UpdateAllPlayersSleepingFlag();
            }
            return(net.minecraft.src.EnumStatus.OK);
        }
Пример #15
0
        public static bool PerformSleepSpawning(net.minecraft.src.World world, List <EntityPlayer> list)
        {
            bool flag = false;

            net.minecraft.src.Pathfinder   pathfinder = new net.minecraft.src.Pathfinder(world);
            System.Collections.IEnumerator iterator   = list.GetEnumerator();
            do
            {
                if (!iterator.MoveNext())
                {
                    break;
                }
                net.minecraft.src.EntityPlayer entityplayer = (net.minecraft.src.EntityPlayer)iterator
                                                              .Current;
                System.Type[] aclass = field_22213_a;
                if (aclass != null && aclass.Length != 0)
                {
                    bool flag1 = false;
                    int  i     = 0;
                    while (i < 20 && !flag1)
                    {
                        int j = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posX) + world.rand
                                 .NextInt(32)) - world.rand.Next(32);
                        int k = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posZ) + world.rand
                                 .NextInt(32)) - world.rand.Next(32);
                        int l = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posY) + world.rand
                                 .NextInt(16)) - world.rand.Next(16);
                        if (l < 1)
                        {
                            l = 1;
                        }
                        else
                        {
                            if (l > 128)
                            {
                                l = 128;
                            }
                        }
                        int i1 = world.rand.Next(aclass.Length);
                        int j1;
                        for (j1 = l; j1 > 2 && !world.IsBlockNormalCube(j, j1 - 1, k); j1--)
                        {
                        }
                        for (; !Func_21167_a(net.minecraft.src.EnumCreatureType.monster, world, j, j1, k) &&
                             j1 < l + 16 && j1 < 128; j1++)
                        {
                        }
                        if (j1 >= l + 16 || j1 >= 128)
                        {
                            j1 = l;
                        }
                        else
                        {
                            float f  = (float)j + 0.5F;
                            float f1 = j1;
                            float f2 = (float)k + 0.5F;
                            net.minecraft.src.EntityLiving entityliving;
                            try
                            {
                                entityliving = (net.minecraft.src.EntityLiving)(aclass[i1].GetConstructor(new System.Type[] { Sharpen.Runtime.GetClassForType(typeof(net.minecraft.src.World)) }).Invoke(new object[] { world }));
                            }
                            catch (System.Exception exception)
                            {
                                Sharpen.Runtime.PrintStackTrace(exception);
                                return(flag);
                            }
                            entityliving.SetLocationAndAngles(f, f1, f2, world.rand.NextFloat() * 360F, 0.0F);
                            if (entityliving.GetCanSpawnHere())
                            {
                                net.minecraft.src.PathEntity pathentity = pathfinder.CreateEntityPathTo(entityliving
                                                                                                        , entityplayer, 32F);
                                if (pathentity != null && pathentity.pathLength > 1)
                                {
                                    net.minecraft.src.PathPoint pathpoint = pathentity.Func_22211_c();
                                    if (System.Math.Abs((double)pathpoint.xCoord - entityplayer.posX) < 1.5D && System.Math
                                        .Abs((double)pathpoint.zCoord - entityplayer.posZ) < 1.5D && System.Math.Abs((double
                                                                                                                      )pathpoint.yCoord - entityplayer.posY) < 1.5D)
                                    {
                                        net.minecraft.src.ChunkCoordinates chunkcoordinates = net.minecraft.src.BlockBed.
                                                                                              Func_22021_g(world, net.minecraft.src.MathHelper.Floor_double(entityplayer.posX)
                                                                                                           , net.minecraft.src.MathHelper.Floor_double(entityplayer.posY), net.minecraft.src.MathHelper
                                                                                                           .Floor_double(entityplayer.posZ), 1);
                                        if (chunkcoordinates == null)
                                        {
                                            chunkcoordinates = new net.minecraft.src.ChunkCoordinates(j, j1 + 1, k);
                                        }
                                        entityliving.SetLocationAndAngles((float)chunkcoordinates.posX + 0.5F, chunkcoordinates
                                                                          .posY, (float)chunkcoordinates.posZ + 0.5F, 0.0F, 0.0F);
                                        world.AddEntity(entityliving);
                                        Func_21166_a(entityliving, world, (float)chunkcoordinates.posX + 0.5F, chunkcoordinates
                                                     .posY, (float)chunkcoordinates.posZ + 0.5F);
                                        entityplayer.WakeUpPlayer(true, false, false);
                                        entityliving.PlayLivingSound();
                                        flag  = true;
                                        flag1 = true;
                                    }
                                }
                            }
                        }
                        i++;
                    }
                }
            }while (true);
            return(flag);
        }
Пример #16
0
 public ChunkCoordinates(net.minecraft.src.ChunkCoordinates chunkcoordinates)
 {
     posX = chunkcoordinates.posX;
     posY = chunkcoordinates.posY;
     posZ = chunkcoordinates.posZ;
 }
Пример #17
0
        /// <exception cref="System.IO.IOException"/>
        private static void WriteWatchableObject(java.io.DataOutputStream dataoutputstream, net.minecraft.src.WatchableObject watchableobject)
        {
            int i = (watchableobject.GetObjectType() << 5 | watchableobject.GetDataValueId()
                     & 0x1f) & 0xff;

            dataoutputstream.WriteByte(i);
            switch (watchableobject.GetObjectType())
            {
            case 0:
            {
                // '\0'
                dataoutputstream.WriteByte(((byte)watchableobject.GetObject()));
                break;
            }

            case 1:
            {
                // '\001'
                dataoutputstream.WriteShort(((short)watchableobject.GetObject()));
                break;
            }

            case 2:
            {
                // '\002'
                dataoutputstream.WriteInt(((int)watchableobject.GetObject()));
                break;
            }

            case 3:
            {
                // '\003'
                dataoutputstream.WriteFloat(((float)watchableobject.GetObject()));
                break;
            }

            case 4:
            {
                // '\004'
                net.minecraft.src.Packet.WriteString((string)watchableobject.GetObject(), dataoutputstream
                                                     );
                break;
            }

            case 5:
            {
                // '\005'
                net.minecraft.src.ItemStack itemstack = (net.minecraft.src.ItemStack)watchableobject
                                                        .GetObject();
                dataoutputstream.WriteShort(itemstack.GetItem().ID);
                dataoutputstream.WriteByte(itemstack.stackSize);
                dataoutputstream.WriteShort(itemstack.GetItemDamage());
                break;
            }

            case 6:
            {
                // '\006'
                net.minecraft.src.ChunkCoordinates chunkcoordinates = (net.minecraft.src.ChunkCoordinates
                                                                       )watchableobject.GetObject();
                dataoutputstream.WriteInt(chunkcoordinates.posX);
                dataoutputstream.WriteInt(chunkcoordinates.posY);
                dataoutputstream.WriteInt(chunkcoordinates.posZ);
                break;
            }
            }
        }
Пример #18
0
        public override bool BlockActivated(net.minecraft.src.World world, int i, int j,
                                            int k, net.minecraft.src.EntityPlayer entityplayer)
        {
            if (world.singleplayerWorld)
            {
                return(true);
            }
            int l = world.GetBlockMetadata(i, j, k);

            if (!Func_22020_d(l))
            {
                int i1 = Func_22019_c(l);
                i += field_22023_a[i1][0];
                k += field_22023_a[i1][1];
                if (world.GetBlockId(i, j, k) != ID)
                {
                    return(true);
                }
                l = world.GetBlockMetadata(i, j, k);
            }
            if (!world.worldProvider.Func_28108_d())
            {
                double d  = (double)i + 0.5D;
                double d1 = (double)j + 0.5D;
                double d2 = (double)k + 0.5D;
                world.SetBlockWithNotify(i, j, k, 0);
                int j1 = Func_22019_c(l);
                i += field_22023_a[j1][0];
                k += field_22023_a[j1][1];
                if (world.GetBlockId(i, j, k) == ID)
                {
                    world.SetBlockWithNotify(i, j, k, 0);
                    d  = (d + (double)i + 0.5D) / 2D;
                    d1 = (d1 + (double)j + 0.5D) / 2D;
                    d2 = (d2 + (double)k + 0.5D) / 2D;
                }
                world.NewExplosion(null, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, 5F, true
                                   );
                return(true);
            }
            if (Func_22018_f(l))
            {
                net.minecraft.src.EntityPlayer entityplayer1 = null;
                System.Collections.IEnumerator iterator      = world.playerEntities.GetEnumerator();
                do
                {
                    if (!iterator.MoveNext())
                    {
                        break;
                    }
                    net.minecraft.src.EntityPlayer entityplayer2 = (net.minecraft.src.EntityPlayer)iterator
                                                                   .Current;
                    if (entityplayer2.IsSleeping())
                    {
                        net.minecraft.src.ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;
                        if (chunkcoordinates.posX == i && chunkcoordinates.posY == j && chunkcoordinates.
                            posZ == k)
                        {
                            entityplayer1 = entityplayer2;
                        }
                    }
                }while (true);
                if (entityplayer1 == null)
                {
                    Func_22022_a(world, i, j, k, false);
                }
                else
                {
                    entityplayer.Func_22061_a("tile.bed.occupied");
                    return(true);
                }
            }
            net.minecraft.src.EnumStatus enumstatus = entityplayer.GoToSleep(i, j, k);
            if (enumstatus == net.minecraft.src.EnumStatus.OK)
            {
                Func_22022_a(world, i, j, k, true);
                return(true);
            }
            if (enumstatus == net.minecraft.src.EnumStatus.NOT_POSSIBLE_NOW)
            {
                entityplayer.Func_22061_a("tile.bed.noSleep");
            }
            return(true);
        }
Пример #19
0
        public override void HandlePlace(net.minecraft.src.Packet15Place packet15place)
        {
            net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity
                                                                                .dimension);
            net.minecraft.src.ItemStack itemstack = playerEntity.inventory.GetCurrentItem();
            bool flag = worldserver.weirdIsOpCache = worldserver.worldProvider.worldType != 0 ||
                                                     mcServer.serverConfigurationManager.IsOp(playerEntity.username);

            if (packet15place.direction == 255)
            {
                if (itemstack == null)
                {
                    return;
                }
                playerEntity.itemInWorldManager.Func_6154_a(playerEntity, worldserver, itemstack);
            }
            else
            {
                int i = packet15place.xPosition;
                int j = packet15place.yPosition;
                int k = packet15place.zPosition;
                int l = packet15place.direction;
                net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
                int i1 = (int)net.minecraft.src.MathHelper.Abs(i - chunkcoordinates.posX);
                int j1 = (int)net.minecraft.src.MathHelper.Abs(k - chunkcoordinates.posZ);
                if (i1 > j1)
                {
                    j1 = i1;
                }
                if (hasMoved && playerEntity.GetDistanceSq((double)i + 0.5D, (double)j + 0.5D, (double
                                                                                                )k + 0.5D) < 64D && (j1 > 16 || flag))
                {
                    playerEntity.itemInWorldManager.ActiveBlockOrUseItem(playerEntity, worldserver, itemstack
                                                                         , i, j, k, l);
                }
                playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                             (i, j, k, worldserver));
                if (l == 0)
                {
                    j--;
                }
                if (l == 1)
                {
                    j++;
                }
                if (l == 2)
                {
                    k--;
                }
                if (l == 3)
                {
                    k++;
                }
                if (l == 4)
                {
                    i--;
                }
                if (l == 5)
                {
                    i++;
                }
                playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                             (i, j, k, worldserver));
            }
            itemstack = playerEntity.inventory.GetCurrentItem();
            if (itemstack != null && itemstack.stackSize == 0)
            {
                playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
            }
            playerEntity.isChangingQuantityOnly = true;
            playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = net.minecraft.src.ItemStack
                                                                                       .CloneStack(playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem
                                                                                                   ]);
            net.minecraft.src.Slot slot = playerEntity.currentCraftingInventory.Func_20127_a(
                playerEntity.inventory, playerEntity.inventory.currentItem);
            playerEntity.currentCraftingInventory.UpdateCraftingMatrix();
            playerEntity.isChangingQuantityOnly = false;
            if (!net.minecraft.src.ItemStack.AreItemStacksEqual(playerEntity.inventory.GetCurrentItem
                                                                    (), packet15place.itemStack))
            {
                SendPacket(new net.minecraft.src.Packet103SetSlot(playerEntity.currentCraftingInventory
                                                                  .windowId, slot.id, playerEntity.inventory.GetCurrentItem()));
            }
            worldserver.weirdIsOpCache = false;
        }
Пример #20
0
        public override void HandleBlockDig(net.minecraft.src.Packet14BlockDig packet14blockdig)
        {
            if (playerEntity.isDead)
            {
                return;                      // CRAFTBUKKIT
            }
            net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity
                                                                                .dimension);
            if (packet14blockdig.status == 4)
            {
                playerEntity.DropCurrentItem();
                return;
            }
            bool flag = worldserver.weirdIsOpCache = worldserver.worldProvider.worldType != 0 ||
                                                     mcServer.serverConfigurationManager.IsOp(playerEntity.username);
            bool flag1 = false;

            if (packet14blockdig.status == 0)
            {
                flag1 = true;
            }
            if (packet14blockdig.status == 2)
            {
                flag1 = true;
            }
            int i = packet14blockdig.xPosition;
            int j = packet14blockdig.yPosition;
            int k = packet14blockdig.zPosition;

            if (flag1)
            {
                double d  = playerEntity.posX - ((double)i + 0.5D);
                double d1 = playerEntity.posY - ((double)j + 0.5D);
                double d3 = playerEntity.posZ - ((double)k + 0.5D);
                double d5 = d * d + d1 * d1 + d3 * d3;
                if (d5 > 36D)
                {
                    return;
                }
            }
            net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
            int l  = (int)net.minecraft.src.MathHelper.Abs(i - chunkcoordinates.posX);
            int i1 = (int)net.minecraft.src.MathHelper.Abs(k - chunkcoordinates.posZ);

            if (l > i1)
            {
                i1 = l;
            }
            if (packet14blockdig.status == 0)
            {
                if (i1 > 16 || flag)
                {
                    playerEntity.itemInWorldManager.Func_324_a(i, j, k, packet14blockdig.face);
                }
                else
                {
                    playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                                 (i, j, k, worldserver));
                }
            }
            else
            {
                if (packet14blockdig.status == 2)
                {
                    playerEntity.itemInWorldManager.Func_22045_b(i, j, k);
                    if (worldserver.GetBlockId(i, j, k) != 0)
                    {
                        playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                                     (i, j, k, worldserver));
                    }
                }
                else
                {
                    if (packet14blockdig.status == 3)
                    {
                        double d2 = playerEntity.posX - ((double)i + 0.5D);
                        double d4 = playerEntity.posY - ((double)j + 0.5D);
                        double d6 = playerEntity.posZ - ((double)k + 0.5D);
                        double d7 = d2 * d2 + d4 * d4 + d6 * d6;
                        if (d7 < 256D)
                        {
                            playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                                         (i, j, k, worldserver));
                        }
                    }
                }
            }
            worldserver.weirdIsOpCache = false;
        }