@Inject(method = "trySpawnGolem", at = @At("HEAD"), cancellable = true)
 private void checkChunkBeforeTrySpawnGolem(World world, BlockPos pos, CallbackInfo callbackInfo) {
   final Chunk chunk = world.getChunkFromBlockCoords(pos);
   if (chunk == null || chunk.isEmpty() || !chunk.isTerrainPopulated()) {
     callbackInfo.cancel();
   }
 }
Example #2
0
  public void updateMapData(World par1World, Entity par2Entity, MapData par3MapData) {
    if (par1World.provider.dimensionId == par3MapData.dimension
        && par2Entity instanceof EntityPlayer) {
      int var4 = 1 << par3MapData.scale;
      int var5 = par3MapData.xCenter;
      int var6 = par3MapData.zCenter;
      int var7 = MathHelper.floor_double(par2Entity.posX - (double) var5) / var4 + 64;
      int var8 = MathHelper.floor_double(par2Entity.posZ - (double) var6) / var4 + 64;
      int var9 = 128 / var4;

      if (par1World.provider.hasNoSky) {
        var9 /= 2;
      }

      MapData.MapInfo var10 = par3MapData.func_82568_a((EntityPlayer) par2Entity);
      ++var10.field_82569_d;

      for (int var11 = var7 - var9 + 1; var11 < var7 + var9; ++var11) {
        if ((var11 & 15) == (var10.field_82569_d & 15)) {
          int var12 = 255;
          int var13 = 0;
          double var14 = 0.0D;

          for (int var16 = var8 - var9 - 1; var16 < var8 + var9; ++var16) {
            if (var11 >= 0 && var16 >= -1 && var11 < 128 && var16 < 128) {
              int var17 = var11 - var7;
              int var18 = var16 - var8;
              boolean var19 = var17 * var17 + var18 * var18 > (var9 - 2) * (var9 - 2);
              int var20 = (var5 / var4 + var11 - 64) * var4;
              int var21 = (var6 / var4 + var16 - 64) * var4;
              HashMultiset var22 = HashMultiset.create();
              Chunk var23 = par1World.getChunkFromBlockCoords(var20, var21);

              if (!var23.isEmpty()) {
                int var24 = var20 & 15;
                int var25 = var21 & 15;
                int var26 = 0;
                double var27 = 0.0D;
                int var29;

                if (par1World.provider.hasNoSky) {
                  var29 = var20 + var21 * 231871;
                  var29 = var29 * var29 * 31287121 + var29 * 11;

                  if ((var29 >> 20 & 1) == 0) {
                    var22.add(Blocks.dirt.getMapColor(0), 10);
                  } else {
                    var22.add(Blocks.stone.getMapColor(0), 100);
                  }

                  var27 = 100.0D;
                } else {
                  for (var29 = 0; var29 < var4; ++var29) {
                    for (int var30 = 0; var30 < var4; ++var30) {
                      int var31 = var23.getHeightValue(var29 + var24, var30 + var25) + 1;
                      Block var32 = Blocks.air;
                      int var33 = 0;

                      if (var31 > 1) {
                        do {
                          --var31;
                          var32 = var23.func_150810_a(var29 + var24, var31, var30 + var25);
                          var33 = var23.getBlockMetadata(var29 + var24, var31, var30 + var25);
                        } while (var32.getMapColor(var33) == MapColor.field_151660_b && var31 > 0);

                        if (var31 > 0 && var32.getMaterial().isLiquid()) {
                          int var34 = var31 - 1;
                          Block var35;

                          do {
                            var35 = var23.func_150810_a(var29 + var24, var34--, var30 + var25);
                            ++var26;
                          } while (var34 > 0 && var35.getMaterial().isLiquid());
                        }
                      }

                      var27 += (double) var31 / (double) (var4 * var4);
                      var22.add(var32.getMapColor(var33));
                    }
                  }
                }

                var26 /= var4 * var4;
                double var36 =
                    (var27 - var14) * 4.0D / (double) (var4 + 4)
                        + ((double) (var11 + var16 & 1) - 0.5D) * 0.4D;
                byte var39 = 1;

                if (var36 > 0.6D) {
                  var39 = 2;
                }

                if (var36 < -0.6D) {
                  var39 = 0;
                }

                MapColor var38 =
                    (MapColor)
                        Iterables.getFirst(
                            Multisets.copyHighestCountFirst(var22), MapColor.field_151660_b);

                if (var38 == MapColor.field_151662_n) {
                  var36 = (double) var26 * 0.1D + (double) (var11 + var16 & 1) * 0.2D;
                  var39 = 1;

                  if (var36 < 0.5D) {
                    var39 = 2;
                  }

                  if (var36 > 0.9D) {
                    var39 = 0;
                  }
                }

                var14 = var27;

                if (var16 >= 0
                    && var17 * var17 + var18 * var18 < var9 * var9
                    && (!var19 || (var11 + var16 & 1) != 0)) {
                  byte var37 = par3MapData.colors[var11 + var16 * 128];
                  byte var40 = (byte) (var38.colorIndex * 4 + var39);

                  if (var37 != var40) {
                    if (var12 > var16) {
                      var12 = var16;
                    }

                    if (var13 < var16) {
                      var13 = var16;
                    }

                    par3MapData.colors[var11 + var16 * 128] = var40;
                  }
                }
              }
            }
          }

          if (var12 <= var13) {
            par3MapData.setColumnDirty(var11, var12, var13);
          }
        }
      }
    }
  }