示例#1
0
        public virtual void readFromNBT(NBTTagCompound nbttagcompound)
        {
            NBTTagList nbttaglist  = nbttagcompound.getTagList("Pos");
            NBTTagList nbttaglist1 = nbttagcompound.getTagList("Motion");
            NBTTagList nbttaglist2 = nbttagcompound.getTagList("Rotation");

            setPosition(0.0D, 0.0D, 0.0D);
            motionX = ((NBTTagDouble)nbttaglist1.tagAt(0)).doubleValue;
            motionY = ((NBTTagDouble)nbttaglist1.tagAt(1)).doubleValue;
            motionZ = ((NBTTagDouble)nbttaglist1.tagAt(2)).doubleValue;
            if (Math.abs(motionX) > 10D)
            {
                motionX = 0.0D;
            }
            if (Math.abs(motionY) > 10D)
            {
                motionY = 0.0D;
            }
            if (Math.abs(motionZ) > 10D)
            {
                motionZ = 0.0D;
            }
            prevPosX          = lastTickPosX = posX = ((NBTTagDouble)nbttaglist.tagAt(0)).doubleValue;
            prevPosY          = lastTickPosY = posY = ((NBTTagDouble)nbttaglist.tagAt(1)).doubleValue;
            prevPosZ          = lastTickPosZ = posZ = ((NBTTagDouble)nbttaglist.tagAt(2)).doubleValue;
            prevRotationYaw   = rotationYaw = ((NBTTagFloat)nbttaglist2.tagAt(0)).floatValue % 6.283185F;
            prevRotationPitch = rotationPitch = ((NBTTagFloat)nbttaglist2.tagAt(1)).floatValue % 6.283185F;
            fallDistance      = nbttagcompound.getFloat("FallDistance");
            fire     = nbttagcompound.getShort("Fire");
            air      = nbttagcompound.getShort("Air");
            onGround = nbttagcompound.getBoolean("OnGround");
            setPosition(posX, posY, posZ);
            readEntityFromNBT(nbttagcompound);
        }
示例#2
0
        public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound)
        {
            int i     = nbttagcompound.getInteger("xPos");
            int j     = nbttagcompound.getInteger("zPos");
            var chunk = new Chunk(world, i, j);

            chunk.blocks             = nbttagcompound.getByteArray("Blocks");
            chunk.data               = new NibbleArray(nbttagcompound.getByteArray("Data"));
            chunk.skylightMap        = new NibbleArray(nbttagcompound.getByteArray("SkyLight"));
            chunk.blocklightMap      = new NibbleArray(nbttagcompound.getByteArray("BlockLight"));
            chunk.heightMap          = nbttagcompound.getByteArray("HeightMap");
            chunk.isTerrainPopulated = nbttagcompound.getBoolean("TerrainPopulated");
            if (!chunk.data.isValid())
            {
                chunk.data = new NibbleArray(chunk.blocks.Length);
            }
            if (chunk.heightMap == null || !chunk.skylightMap.isValid())
            {
                chunk.heightMap   = new byte[256];
                chunk.skylightMap = new NibbleArray(chunk.blocks.Length);
                chunk.func_353_b();
            }
            if (!chunk.blocklightMap.isValid())
            {
                chunk.blocklightMap = new NibbleArray(chunk.blocks.Length);
                chunk.func_348_a();
            }
            NBTTagList nbttaglist = nbttagcompound.getTagList("Entities");

            if (nbttaglist != null)
            {
                for (int k = 0; k < nbttaglist.tagCount(); k++)
                {
                    var    nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(k);
                    Entity entity          = EntityList.createEntityFromNBT(nbttagcompound1, world);
                    chunk.hasEntities = true;
                    if (entity != null)
                    {
                        chunk.addEntity(entity);
                    }
                }
            }
            NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");

            if (nbttaglist1 != null)
            {
                for (int l = 0; l < nbttaglist1.tagCount(); l++)
                {
                    var        nbttagcompound2 = (NBTTagCompound)nbttaglist1.tagAt(l);
                    TileEntity tileentity      = TileEntity.createAndLoadEntity(nbttagcompound2);
                    if (tileentity != null)
                    {
                        chunk.func_349_a(tileentity);
                    }
                }
            }
            return(chunk);
        }
示例#3
0
 public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound)
 {
     int i = nbttagcompound.getInteger("xPos");
     int j = nbttagcompound.getInteger("zPos");
     var chunk = new Chunk(world, i, j);
     chunk.blocks = nbttagcompound.getByteArray("Blocks");
     chunk.data = new NibbleArray(nbttagcompound.getByteArray("Data"));
     chunk.skylightMap = new NibbleArray(nbttagcompound.getByteArray("SkyLight"));
     chunk.blocklightMap = new NibbleArray(nbttagcompound.getByteArray("BlockLight"));
     chunk.heightMap = nbttagcompound.getByteArray("HeightMap");
     chunk.isTerrainPopulated = nbttagcompound.getBoolean("TerrainPopulated");
     if (!chunk.data.isValid())
     {
         chunk.data = new NibbleArray(chunk.blocks.Length);
     }
     if (chunk.heightMap == null || !chunk.skylightMap.isValid())
     {
         chunk.heightMap = new byte[256];
         chunk.skylightMap = new NibbleArray(chunk.blocks.Length);
         chunk.func_353_b();
     }
     if (!chunk.blocklightMap.isValid())
     {
         chunk.blocklightMap = new NibbleArray(chunk.blocks.Length);
         chunk.func_348_a();
     }
     NBTTagList nbttaglist = nbttagcompound.getTagList("Entities");
     if (nbttaglist != null)
     {
         for (int k = 0; k < nbttaglist.tagCount(); k++)
         {
             var nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(k);
             Entity entity = EntityList.createEntityFromNBT(nbttagcompound1, world);
             chunk.hasEntities = true;
             if (entity != null)
             {
                 chunk.addEntity(entity);
             }
         }
     }
     NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");
     if (nbttaglist1 != null)
     {
         for (int l = 0; l < nbttaglist1.tagCount(); l++)
         {
             var nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
             TileEntity tileentity = TileEntity.createAndLoadEntity(nbttagcompound2);
             if (tileentity != null)
             {
                 chunk.func_349_a(tileentity);
             }
         }
     }
     return chunk;
 }
示例#4
0
        public override void readEntityFromNBT(NBTTagCompound nbttagcompound)
        {
            base.readEntityFromNBT(nbttagcompound);
            NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory");

            inventory.readFromNBT(nbttaglist);
            dimension  = nbttagcompound.getInteger("Dimension");
            sleeping   = nbttagcompound.getBoolean("Sleeping");
            sleepTimer = nbttagcompound.getShort("SleepTimer");
            if (sleeping)
            {
                playerLocation = new ChunkCoordinates(MathHelper.floor_double(posX), MathHelper.floor_double(posY),
                                                      MathHelper.floor_double(posZ));
                wakeUpPlayer(true, true);
            }
        }
示例#5
0
        public override void readFromNBT(NBTTagCompound nbttagcompound)
        {
            base.readFromNBT(nbttagcompound);
            NBTTagList nbttaglist = nbttagcompound.getTagList("Items");

            dispenserContents = new ItemStack[getSizeInventory()];
            for (int i = 0; i < nbttaglist.tagCount(); i++)
            {
                var nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                int j = nbttagcompound1.getByte("Slot") & 0xff;
                if (j >= 0 && j < dispenserContents.Length)
                {
                    dispenserContents[j] = new ItemStack(nbttagcompound1);
                }
            }
        }
示例#6
0
 public override void readEntityFromNBT(NBTTagCompound nbttagcompound)
 {
     minecartType = nbttagcompound.getInteger("Type");
     if (minecartType == 2)
     {
         pushX = nbttagcompound.getDouble("PushX");
         pushZ = nbttagcompound.getDouble("PushZ");
         fuel  = nbttagcompound.getShort("Fuel");
     }
     else if (minecartType == 1)
     {
         NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
         cargoItems = new ItemStack[getSizeInventory()];
         for (int i = 0; i < nbttaglist.tagCount(); i++)
         {
             var nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
             int j = nbttagcompound1.getByte("Slot") & 0xff;
             if (j >= 0 && j < cargoItems.Length)
             {
                 cargoItems[j] = new ItemStack(nbttagcompound1);
             }
         }
     }
 }
示例#7
0
 public override void readEntityFromNBT(NBTTagCompound nbttagcompound)
 {
     base.readEntityFromNBT(nbttagcompound);
     NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory");
     inventory.readFromNBT(nbttaglist);
     dimension = nbttagcompound.getInteger("Dimension");
     sleeping = nbttagcompound.getBoolean("Sleeping");
     sleepTimer = nbttagcompound.getShort("SleepTimer");
     if (sleeping)
     {
         playerLocation = new ChunkCoordinates(MathHelper.floor_double(posX), MathHelper.floor_double(posY),
                                               MathHelper.floor_double(posZ));
         wakeUpPlayer(true, true);
     }
 }
示例#8
0
文件: Entity.cs 项目: riverar/Crafty
 public virtual void readFromNBT(NBTTagCompound nbttagcompound)
 {
     NBTTagList nbttaglist = nbttagcompound.getTagList("Pos");
     NBTTagList nbttaglist1 = nbttagcompound.getTagList("Motion");
     NBTTagList nbttaglist2 = nbttagcompound.getTagList("Rotation");
     setPosition(0.0D, 0.0D, 0.0D);
     motionX = ((NBTTagDouble) nbttaglist1.tagAt(0)).doubleValue;
     motionY = ((NBTTagDouble) nbttaglist1.tagAt(1)).doubleValue;
     motionZ = ((NBTTagDouble) nbttaglist1.tagAt(2)).doubleValue;
     if (Math.abs(motionX) > 10D)
     {
         motionX = 0.0D;
     }
     if (Math.abs(motionY) > 10D)
     {
         motionY = 0.0D;
     }
     if (Math.abs(motionZ) > 10D)
     {
         motionZ = 0.0D;
     }
     prevPosX = lastTickPosX = posX = ((NBTTagDouble) nbttaglist.tagAt(0)).doubleValue;
     prevPosY = lastTickPosY = posY = ((NBTTagDouble) nbttaglist.tagAt(1)).doubleValue;
     prevPosZ = lastTickPosZ = posZ = ((NBTTagDouble) nbttaglist.tagAt(2)).doubleValue;
     prevRotationYaw = rotationYaw = ((NBTTagFloat) nbttaglist2.tagAt(0)).floatValue%6.283185F;
     prevRotationPitch = rotationPitch = ((NBTTagFloat) nbttaglist2.tagAt(1)).floatValue%6.283185F;
     fallDistance = nbttagcompound.getFloat("FallDistance");
     fire = nbttagcompound.getShort("Fire");
     air = nbttagcompound.getShort("Air");
     onGround = nbttagcompound.getBoolean("OnGround");
     setPosition(posX, posY, posZ);
     readEntityFromNBT(nbttagcompound);
 }
示例#9
0
 public override void readEntityFromNBT(NBTTagCompound nbttagcompound)
 {
     minecartType = nbttagcompound.getInteger("Type");
     if (minecartType == 2)
     {
         pushX = nbttagcompound.getDouble("PushX");
         pushZ = nbttagcompound.getDouble("PushZ");
         fuel = nbttagcompound.getShort("Fuel");
     }
     else if (minecartType == 1)
     {
         NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
         cargoItems = new ItemStack[getSizeInventory()];
         for (int i = 0; i < nbttaglist.tagCount(); i++)
         {
             var nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
             int j = nbttagcompound1.getByte("Slot") & 0xff;
             if (j >= 0 && j < cargoItems.Length)
             {
                 cargoItems[j] = new ItemStack(nbttagcompound1);
             }
         }
     }
 }
示例#10
0
 public override void readFromNBT(NBTTagCompound nbttagcompound)
 {
     base.readFromNBT(nbttagcompound);
     NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
     dispenserContents = new ItemStack[getSizeInventory()];
     for (int i = 0; i < nbttaglist.tagCount(); i++)
     {
         var nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
         int j = nbttagcompound1.getByte("Slot") & 0xff;
         if (j >= 0 && j < dispenserContents.Length)
         {
             dispenserContents[j] = new ItemStack(nbttagcompound1);
         }
     }
 }