Example #1
0
        public virtual void removeChunkBlockTileEntity(int i, int j, int k)
        {
            var chunkposition = new ChunkPosition(i, j, k);

            if (isChunkLoaded)
            {
                worldObj.loadedTileEntityList.remove(chunkTileEntityMap.remove(chunkposition));
            }
        }
Example #2
0
        public virtual TileEntity getChunkBlockTileEntity_(int i, int j, int k)
        {
            var chunkposition = new ChunkPosition(i, j, k);
            var tileentity    = (TileEntity)chunkTileEntityMap.get(chunkposition);

            if (tileentity == null)
            {
                int l = getBlockID(i, j, k);
                if (!Block.isBlockContainer[l])
                {
                    return(null);
                }
                var blockcontainer = (BlockContainer)Block.blocksList[l];
                blockcontainer.onBlockAdded(worldObj, xPosition * 16 + i, j, zPosition * 16 + k);
                tileentity = (TileEntity)chunkTileEntityMap.get(chunkposition);
            }
            return(tileentity);
        }
Example #3
0
        public virtual TileEntity getChunkBlockTileEntity(int i, int j, int k)
        {
            var position = new ChunkPosition(i, j, k);
            var entity   = (TileEntity)chunkTileEntityMap.get(position);

            if (entity != null)
            {
                return(entity);
            }
            int index = getBlockID(i, j, k);

            if (!Block.isBlockContainer[index])
            {
                return(null);
            }
            (Block.blocksList[index]).onBlockAdded(worldObj, (xPosition * 0x10) + i, j,
                                                   (zPosition * 0x10) + k);
            return((TileEntity)chunkTileEntityMap.get(position));
        }
Example #4
0
 private MinecartTrackLogic getMinecartTrackLogic(ChunkPosition chunkposition)
 {
     if (worldObj.getBlockId(chunkposition.x, chunkposition.y, chunkposition.z) == minecartTrack.blockID)
     {
         return(new MinecartTrackLogic(minecartTrack, worldObj, chunkposition.x, chunkposition.y, chunkposition.z));
     }
     if (worldObj.getBlockId(chunkposition.x, chunkposition.y + 1, chunkposition.z) == minecartTrack.blockID)
     {
         return(new MinecartTrackLogic(minecartTrack, worldObj, chunkposition.x, chunkposition.y + 1,
                                       chunkposition.z));
     }
     if (worldObj.getBlockId(chunkposition.x, chunkposition.y - 1, chunkposition.z) == minecartTrack.blockID)
     {
         return(new MinecartTrackLogic(minecartTrack, worldObj, chunkposition.x, chunkposition.y - 1,
                                       chunkposition.z));
     }
     else
     {
         return(null);
     }
 }
Example #5
0
        public virtual void setChunkBlockTileEntity(int i, int j, int k, TileEntity tileentity)
        {
            var chunkposition = new ChunkPosition(i, j, k);

            tileentity.worldObj = worldObj;
            tileentity.xCoord   = xPosition * 16 + i;
            tileentity.yCoord   = j;
            tileentity.zCoord   = zPosition * 16 + k;
            if (getBlockID(i, j, k) == 0 || !(Block.blocksList[getBlockID(i, j, k)] is BlockContainer))
            {
                [email protected]("Attempted to place a tile entity where there was no entity tile!");
                return;
            }
            if (isChunkLoaded)
            {
                if (chunkTileEntityMap.get(chunkposition) != null)
                {
                    worldObj.loadedTileEntityList.remove(chunkTileEntityMap.get(chunkposition));
                }
                worldObj.loadedTileEntityList.add(tileentity);
            }
            chunkTileEntityMap.put(chunkposition, tileentity);
        }
Example #6
0
        public static int performSpawning(World var0, bool var1, bool var2)
        {
            if (!var1 && !var2)
            {
                return(0);
            }
            else
            {
                eligibleChunksForSpawning.clear();

                int var3;
                int var6;
                for (var3 = 0; var3 < var0.playerEntities.size(); ++var3)
                {
                    var var4 = (EntityPlayer)var0.playerEntities.get(var3);
                    int var5 = MathHelper.floor_double(var4.posX / 16.0D);
                    var6 = 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 ChunkCoordIntPair(var8 + var5, var9 + var6));
                        }
                    }
                }

                var3 = 0;
                ChunkCoordinates   var33 = var0.func_22078_l();
                EnumCreatureType[] var34 = EnumCreatureType.values();
                var6 = var34.Length;

                for (int var35 = 0; var35 < var6; ++var35)
                {
                    EnumCreatureType var36 = var34[var35];
                    if ((!var36.func_21103_d() || var2) && (var36.func_21103_d() || var1) &&
                        var0.countEntities(var36.getCreatureClass()) <=
                        var36.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256)
                    {
                        Iterator var37 = eligibleChunksForSpawning.iterator();

                        while (var37.hasNext())
                        {
                            var            var10 = (ChunkCoordIntPair)var37.next();
                            MobSpawnerBase var11 = var0.getWorldChunkManager().func_4066_a(var10);
                            Class[]        var12 = var11.getEntitiesForType(var36);
                            if (var12 != null && var12.Length != 0)
                            {
                                int           var13 = var0.rand.nextInt(var12.Length);
                                ChunkPosition var14 = getRandomSpawningPointInChunk(var0, var10.chunkXPos * 16,
                                                                                    var10.chunkZPos * 16);
                                int var15 = var14.x;
                                int var16 = var14.y;
                                int var17 = var14.z;
                                if (!var0.isBlockOpaqueCube(var15, var16, var17) &&
                                    var0.getBlockMaterial(var15, var16, var17) == var36.getCreatureMaterial())
                                {
                                    int var18 = 0;

                                    for (int var19 = 0; var19 < 3; ++var19)
                                    {
                                        int  var20 = var15;
                                        int  var21 = var16;
                                        int  var22 = var17;
                                        byte var23 = 6;

                                        for (int var24 = 0; var24 < 4; ++var24)
                                        {
                                            var20 += var0.rand.nextInt(var23) - var0.rand.nextInt(var23);
                                            var21 += var0.rand.nextInt(1) - var0.rand.nextInt(1);
                                            var22 += var0.rand.nextInt(var23) - var0.rand.nextInt(var23);
                                            if (func_21167_a(var36, var0, var20, var21, var22))
                                            {
                                                float var25 = var20 + 0.5F;
                                                float var26 = var21;
                                                float var27 = var22 + 0.5F;
                                                if (
                                                    var0.getClosestPlayer(var25, var26, var27,
                                                                          24.0D) == null)
                                                {
                                                    float var28 = var25 - var33.posX;
                                                    float var29 = var26 - var33.posY;
                                                    float var30 = var27 - var33.posZ;
                                                    float var31 = var28 * var28 + var29 * var29 + var30 * var30;
                                                    if (var31 >= 576.0F)
                                                    {
                                                        EntityLiving var38;
                                                        try
                                                        {
                                                            var38 =
                                                                (EntityLiving)
                                                                var12[var13].getConstructor(new Class[] { typeof(World) })
                                                                .newInstance(new object[] { var0 });
                                                        }
                                                        catch (Exception var32)
                                                        {
                                                            var32.printStackTrace();
                                                            return(var3);
                                                        }

                                                        var38.setLocationAndAngles(var25, var26,
                                                                                   var27,
                                                                                   var0.rand.nextFloat() * 360.0F, 0.0F);
                                                        if (var38.getCanSpawnHere())
                                                        {
                                                            ++var18;
                                                            var0.entityJoinedWorld(var38);
                                                            func_21166_a(var38, var0, var25, var26, var27);
                                                            if (var18 >= var38.getMaxSpawnedInChunk())
                                                            {
                                                                continue;
                                                            }
                                                        }

                                                        var3 += var18;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(var3);
            }
        }
Example #7
0
 private MinecartTrackLogic getMinecartTrackLogic(ChunkPosition chunkposition)
 {
     if (worldObj.getBlockId(chunkposition.x, chunkposition.y, chunkposition.z) == minecartTrack.blockID)
     {
         return new MinecartTrackLogic(minecartTrack, worldObj, chunkposition.x, chunkposition.y, chunkposition.z);
     }
     if (worldObj.getBlockId(chunkposition.x, chunkposition.y + 1, chunkposition.z) == minecartTrack.blockID)
     {
         return new MinecartTrackLogic(minecartTrack, worldObj, chunkposition.x, chunkposition.y + 1,
                                       chunkposition.z);
     }
     if (worldObj.getBlockId(chunkposition.x, chunkposition.y - 1, chunkposition.z) == minecartTrack.blockID)
     {
         return new MinecartTrackLogic(minecartTrack, worldObj, chunkposition.x, chunkposition.y - 1,
                                       chunkposition.z);
     }
     else
     {
         return null;
     }
 }
Example #8
0
 public virtual void setChunkBlockTileEntity(int i, int j, int k, TileEntity tileentity)
 {
     var chunkposition = new ChunkPosition(i, j, k);
     tileentity.worldObj = worldObj;
     tileentity.xCoord = xPosition*16 + i;
     tileentity.yCoord = j;
     tileentity.zCoord = zPosition*16 + k;
     if (getBlockID(i, j, k) == 0 || !(Block.blocksList[getBlockID(i, j, k)] is BlockContainer))
     {
         [email protected]("Attempted to place a tile entity where there was no entity tile!");
         return;
     }
     if (isChunkLoaded)
     {
         if (chunkTileEntityMap.get(chunkposition) != null)
         {
             worldObj.loadedTileEntityList.remove(chunkTileEntityMap.get(chunkposition));
         }
         worldObj.loadedTileEntityList.add(tileentity);
     }
     chunkTileEntityMap.put(chunkposition, tileentity);
 }
Example #9
0
 public virtual void removeChunkBlockTileEntity(int i, int j, int k)
 {
     var chunkposition = new ChunkPosition(i, j, k);
     if (isChunkLoaded)
     {
         worldObj.loadedTileEntityList.remove(chunkTileEntityMap.remove(chunkposition));
     }
 }
Example #10
0
 public virtual TileEntity getChunkBlockTileEntity_(int i, int j, int k)
 {
     var chunkposition = new ChunkPosition(i, j, k);
     var tileentity = (TileEntity) chunkTileEntityMap.get(chunkposition);
     if (tileentity == null)
     {
         int l = getBlockID(i, j, k);
         if (!Block.isBlockContainer[l])
         {
             return null;
         }
         var blockcontainer = (BlockContainer) Block.blocksList[l];
         blockcontainer.onBlockAdded(worldObj, xPosition*16 + i, j, zPosition*16 + k);
         tileentity = (TileEntity) chunkTileEntityMap.get(chunkposition);
     }
     return tileentity;
 }
Example #11
0
 public virtual TileEntity getChunkBlockTileEntity(int i, int j, int k)
 {
     var position = new ChunkPosition(i, j, k);
     var entity = (TileEntity) chunkTileEntityMap.get(position);
     if (entity != null)
     {
         return entity;
     }
     int index = getBlockID(i, j, k);
     if (!Block.isBlockContainer[index])
     {
         return null;
     }
     (Block.blocksList[index]).onBlockAdded(worldObj, (xPosition*0x10) + i, j,
                                            (zPosition*0x10) + k);
     return (TileEntity) chunkTileEntityMap.get(position);
 }