diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 000000000..e2bcd05b7 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Created-By: 1.6.0 +Main-Class: net.minecraft.server.MinecraftServer + diff --git a/README.md b/README.md new file mode 100644 index 000000000..6b7186d98 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +mc-dev +====== + +This repository contains [automatically generated](https://github.com/Bukkit/Bukkit-MinecraftServer/) decompiled sources of a (internally renamed) minecraft_server.jar. The original minecraft_server.jar (and therefor this code) is copyrighted by [Mojang AB](http://www.mojang.com). diff --git a/net/minecraft/server/AxisAlignedBB.java b/net/minecraft/server/AxisAlignedBB.java new file mode 100644 index 000000000..735e82e09 --- /dev/null +++ b/net/minecraft/server/AxisAlignedBB.java @@ -0,0 +1,350 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +public class AxisAlignedBB { + + private static List g = new ArrayList(); + private static int h = 0; + public double a; + public double b; + public double c; + public double d; + public double e; + public double f; + + public static AxisAlignedBB a(double d0, double d1, double d2, double d3, double d4, double d5) { + return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); + } + + public static void a() { + h = 0; + } + + public static AxisAlignedBB b(double d0, double d1, double d2, double d3, double d4, double d5) { + if (h >= g.size()) { + g.add(a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D)); + } + + return ((AxisAlignedBB) g.get(h++)).c(d0, d1, d2, d3, d4, d5); + } + + private AxisAlignedBB(double d0, double d1, double d2, double d3, double d4, double d5) { + this.a = d0; + this.b = d1; + this.c = d2; + this.d = d3; + this.e = d4; + this.f = d5; + } + + public AxisAlignedBB c(double d0, double d1, double d2, double d3, double d4, double d5) { + this.a = d0; + this.b = d1; + this.c = d2; + this.d = d3; + this.e = d4; + this.f = d5; + return this; + } + + public AxisAlignedBB a(double d0, double d1, double d2) { + double d3 = this.a; + double d4 = this.b; + double d5 = this.c; + double d6 = this.d; + double d7 = this.e; + double d8 = this.f; + + if (d0 < 0.0D) { + d3 += d0; + } + + if (d0 > 0.0D) { + d6 += d0; + } + + if (d1 < 0.0D) { + d4 += d1; + } + + if (d1 > 0.0D) { + d7 += d1; + } + + if (d2 < 0.0D) { + d5 += d2; + } + + if (d2 > 0.0D) { + d8 += d2; + } + + return b(d3, d4, d5, d6, d7, d8); + } + + public AxisAlignedBB b(double d0, double d1, double d2) { + double d3 = this.a - d0; + double d4 = this.b - d1; + double d5 = this.c - d2; + double d6 = this.d + d0; + double d7 = this.e + d1; + double d8 = this.f + d2; + + return b(d3, d4, d5, d6, d7, d8); + } + + public AxisAlignedBB c(double d0, double d1, double d2) { + return b(this.a + d0, this.b + d1, this.c + d2, this.d + d0, this.e + d1, this.f + d2); + } + + public double a(AxisAlignedBB axisalignedbb, double d0) { + if (axisalignedbb.e > this.b && axisalignedbb.b < this.e) { + if (axisalignedbb.f > this.c && axisalignedbb.c < this.f) { + double d1; + + if (d0 > 0.0D && axisalignedbb.d <= this.a) { + d1 = this.a - axisalignedbb.d; + if (d1 < d0) { + d0 = d1; + } + } + + if (d0 < 0.0D && axisalignedbb.a >= this.d) { + d1 = this.d - axisalignedbb.a; + if (d1 > d0) { + d0 = d1; + } + } + + return d0; + } else { + return d0; + } + } else { + return d0; + } + } + + public double b(AxisAlignedBB axisalignedbb, double d0) { + if (axisalignedbb.d > this.a && axisalignedbb.a < this.d) { + if (axisalignedbb.f > this.c && axisalignedbb.c < this.f) { + double d1; + + if (d0 > 0.0D && axisalignedbb.e <= this.b) { + d1 = this.b - axisalignedbb.e; + if (d1 < d0) { + d0 = d1; + } + } + + if (d0 < 0.0D && axisalignedbb.b >= this.e) { + d1 = this.e - axisalignedbb.b; + if (d1 > d0) { + d0 = d1; + } + } + + return d0; + } else { + return d0; + } + } else { + return d0; + } + } + + public double c(AxisAlignedBB axisalignedbb, double d0) { + if (axisalignedbb.d > this.a && axisalignedbb.a < this.d) { + if (axisalignedbb.e > this.b && axisalignedbb.b < this.e) { + double d1; + + if (d0 > 0.0D && axisalignedbb.f <= this.c) { + d1 = this.c - axisalignedbb.f; + if (d1 < d0) { + d0 = d1; + } + } + + if (d0 < 0.0D && axisalignedbb.c >= this.f) { + d1 = this.f - axisalignedbb.c; + if (d1 > d0) { + d0 = d1; + } + } + + return d0; + } else { + return d0; + } + } else { + return d0; + } + } + + public boolean a(AxisAlignedBB axisalignedbb) { + return axisalignedbb.d > this.a && axisalignedbb.a < this.d ? (axisalignedbb.e > this.b && axisalignedbb.b < this.e ? axisalignedbb.f > this.c && axisalignedbb.c < this.f : false) : false; + } + + public AxisAlignedBB d(double d0, double d1, double d2) { + this.a += d0; + this.b += d1; + this.c += d2; + this.d += d0; + this.e += d1; + this.f += d2; + return this; + } + + public AxisAlignedBB e(double d0, double d1, double d2) { + double d3 = this.a; + double d4 = this.b; + double d5 = this.c; + double d6 = this.d; + double d7 = this.e; + double d8 = this.f; + + if (d0 < 0.0D) { + d3 -= d0; + } + + if (d0 > 0.0D) { + d6 -= d0; + } + + if (d1 < 0.0D) { + d4 -= d1; + } + + if (d1 > 0.0D) { + d7 -= d1; + } + + if (d2 < 0.0D) { + d5 -= d2; + } + + if (d2 > 0.0D) { + d8 -= d2; + } + + return b(d3, d4, d5, d6, d7, d8); + } + + public AxisAlignedBB b() { + return b(this.a, this.b, this.c, this.d, this.e, this.f); + } + + public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { + Vec3D vec3d2 = vec3d.a(vec3d1, this.a); + Vec3D vec3d3 = vec3d.a(vec3d1, this.d); + Vec3D vec3d4 = vec3d.b(vec3d1, this.b); + Vec3D vec3d5 = vec3d.b(vec3d1, this.e); + Vec3D vec3d6 = vec3d.c(vec3d1, this.c); + Vec3D vec3d7 = vec3d.c(vec3d1, this.f); + + if (!this.a(vec3d2)) { + vec3d2 = null; + } + + if (!this.a(vec3d3)) { + vec3d3 = null; + } + + if (!this.b(vec3d4)) { + vec3d4 = null; + } + + if (!this.b(vec3d5)) { + vec3d5 = null; + } + + if (!this.c(vec3d6)) { + vec3d6 = null; + } + + if (!this.c(vec3d7)) { + vec3d7 = null; + } + + Vec3D vec3d8 = null; + + if (vec3d2 != null && (vec3d8 == null || vec3d.b(vec3d2) < vec3d.b(vec3d8))) { + vec3d8 = vec3d2; + } + + if (vec3d3 != null && (vec3d8 == null || vec3d.b(vec3d3) < vec3d.b(vec3d8))) { + vec3d8 = vec3d3; + } + + if (vec3d4 != null && (vec3d8 == null || vec3d.b(vec3d4) < vec3d.b(vec3d8))) { + vec3d8 = vec3d4; + } + + if (vec3d5 != null && (vec3d8 == null || vec3d.b(vec3d5) < vec3d.b(vec3d8))) { + vec3d8 = vec3d5; + } + + if (vec3d6 != null && (vec3d8 == null || vec3d.b(vec3d6) < vec3d.b(vec3d8))) { + vec3d8 = vec3d6; + } + + if (vec3d7 != null && (vec3d8 == null || vec3d.b(vec3d7) < vec3d.b(vec3d8))) { + vec3d8 = vec3d7; + } + + if (vec3d8 == null) { + return null; + } else { + byte b0 = -1; + + if (vec3d8 == vec3d2) { + b0 = 4; + } + + if (vec3d8 == vec3d3) { + b0 = 5; + } + + if (vec3d8 == vec3d4) { + b0 = 0; + } + + if (vec3d8 == vec3d5) { + b0 = 1; + } + + if (vec3d8 == vec3d6) { + b0 = 2; + } + + if (vec3d8 == vec3d7) { + b0 = 3; + } + + return new MovingObjectPosition(0, 0, 0, b0, vec3d8); + } + } + + private boolean a(Vec3D vec3d) { + return vec3d == null ? false : vec3d.b >= this.b && vec3d.b <= this.e && vec3d.c >= this.c && vec3d.c <= this.f; + } + + private boolean b(Vec3D vec3d) { + return vec3d == null ? false : vec3d.a >= this.a && vec3d.a <= this.d && vec3d.c >= this.c && vec3d.c <= this.f; + } + + private boolean c(Vec3D vec3d) { + return vec3d == null ? false : vec3d.a >= this.a && vec3d.a <= this.d && vec3d.b >= this.b && vec3d.b <= this.e; + } + + public void b(AxisAlignedBB axisalignedbb) { + this.a = axisalignedbb.a; + this.b = axisalignedbb.b; + this.c = axisalignedbb.c; + this.d = axisalignedbb.d; + this.e = axisalignedbb.e; + this.f = axisalignedbb.f; + } +} diff --git a/net/minecraft/server/Block.java b/net/minecraft/server/Block.java new file mode 100644 index 000000000..155184862 --- /dev/null +++ b/net/minecraft/server/Block.java @@ -0,0 +1,439 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.Random; + +public class Block { + + public static final StepSound e = new StepSound("stone", 1.0F, 1.0F); + public static final StepSound f = new StepSound("wood", 1.0F, 1.0F); + public static final StepSound g = new StepSound("gravel", 1.0F, 1.0F); + public static final StepSound h = new StepSound("grass", 1.0F, 1.0F); + public static final StepSound i = new StepSound("stone", 1.0F, 1.0F); + public static final StepSound j = new StepSound("stone", 1.0F, 1.5F); + public static final StepSound k = new StepSoundStone("stone", 1.0F, 1.0F); + public static final StepSound l = new StepSound("cloth", 1.0F, 1.0F); + public static final StepSound m = new StepSoundSand("sand", 1.0F, 1.0F); + public static final Block[] n = new Block[256]; + public static final boolean[] o = new boolean[256]; + public static final boolean[] p = new boolean[256]; + public static final boolean[] q = new boolean[256]; + public static final int[] r = new int[256]; + public static final boolean[] s = new boolean[256]; + public static final int[] t = new int[256]; + public static final Block STONE = (new BlockStone(1, 1)).c(1.5F).b(10.0F).a(i); + public static final BlockGrass GRASS = (BlockGrass) (new BlockGrass(2)).c(0.6F).a(h); + public static final Block DIRT = (new BlockDirt(3, 2)).c(0.5F).a(g); + public static final Block COBBLESTONE = (new Block(4, 16, Material.d)).c(2.0F).b(10.0F).a(i); + public static final Block WOOD = (new Block(5, 4, Material.c)).c(2.0F).b(5.0F).a(f); + public static final Block SAPLING = (new BlockSapling(6, 15)).c(0.0F).a(h); + public static final Block BEDROCK = (new Block(7, 17, Material.d)).c(-1.0F).b(6000000.0F).a(i); + public static final Block WATER = (new BlockFlowing(8, Material.f)).c(100.0F).c(3); + public static final Block STATIONARY_WATER = (new BlockStationary(9, Material.f)).c(100.0F).c(3); + public static final Block LAVA = (new BlockFlowing(10, Material.g)).c(0.0F).a(1.0F).c(255); + public static final Block STATIONARY_LAVA = (new BlockStationary(11, Material.g)).c(100.0F).a(1.0F).c(255); + public static final Block SAND = (new BlockSand(12, 18)).c(0.5F).a(m); + public static final Block GRAVEL = (new BlockGravel(13, 19)).c(0.6F).a(g); + public static final Block GOLD_ORE = (new BlockOre(14, 32)).c(3.0F).b(5.0F).a(i); + public static final Block IRON_ORE = (new BlockOre(15, 33)).c(3.0F).b(5.0F).a(i); + public static final Block COAL_ORE = (new BlockOre(16, 34)).c(3.0F).b(5.0F).a(i); + public static final Block LOG = (new BlockLog(17)).c(2.0F).a(f); + public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).c(1).a(h); + public static final Block SPONGE = (new BlockSponge(19)).c(0.6F).a(h); + public static final Block GLASS = (new BlockGlass(20, 49, Material.o, false)).c(0.3F).a(k); + public static final Block O = null; + public static final Block P = null; + public static final Block Q = null; + public static final Block R = null; + public static final Block S = null; + public static final Block T = null; + public static final Block U = null; + public static final Block V = null; + public static final Block W = null; + public static final Block X = null; + public static final Block Y = null; + public static final Block Z = null; + public static final Block aa = null; + public static final Block ab = null; + public static final Block WOOL = (new Block(35, 64, Material.k)).c(0.8F).a(l); + public static final Block ad = null; + public static final BlockFlower YELLOW_FLOWER = (BlockFlower) (new BlockFlower(37, 13)).c(0.0F).a(h); + public static final BlockFlower RED_ROSE = (BlockFlower) (new BlockFlower(38, 12)).c(0.0F).a(h); + public static final BlockFlower BROWN_MUSHROOM = (BlockFlower) (new BlockMushroom(39, 29)).c(0.0F).a(h).a(0.125F); + public static final BlockFlower RED_MUSHROOM = (BlockFlower) (new BlockMushroom(40, 28)).c(0.0F).a(h); + public static final Block GOLD_BLOCK = (new BlockOreBlock(41, 39)).c(3.0F).b(10.0F).a(j); + public static final Block IRON_BLOCK = (new BlockOreBlock(42, 38)).c(5.0F).b(10.0F).a(j); + public static final Block DOUBLE_STEP = (new BlockStep(43, true)).c(2.0F).b(10.0F).a(i); + public static final Block STEP = (new BlockStep(44, false)).c(2.0F).b(10.0F).a(i); + public static final Block BRICK = (new Block(45, 7, Material.d)).c(2.0F).b(10.0F).a(i); + public static final Block TNT = (new BlockTNT(46, 8)).c(0.0F).a(h); + public static final Block BOOKSHELF = (new BlockBookshelf(47, 35)).c(1.5F).a(f); + public static final Block MOSSY_COBBLESTONE = (new Block(48, 36, Material.d)).c(2.0F).b(10.0F).a(i); + public static final Block OBSIDIAN = (new BlockObsidian(49, 37)).c(10.0F).b(2000.0F).a(i); + public static final Block TORCH = (new BlockTorch(50, 80)).c(0.0F).a(0.9375F).a(f); + public static final BlockFire FIRE = (BlockFire) ((BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(f)); + public static final Block MOB_SPAWNER = (new BlockMobSpawner(52, 65)).c(5.0F).a(j); + public static final Block WOOD_STAIRS = new BlockStairs(53, WOOD); + public static final Block CHEST = (new BlockChest(54)).c(2.5F).a(f); + public static final Block REDSTONE_WIRE = (new BlockRedstoneWire(55, 84)).c(0.0F).a(e); + public static final Block DIAMOND_ORE = (new BlockOre(56, 50)).c(3.0F).b(5.0F).a(i); + public static final Block DIAMOND_BLOCK = (new BlockOreBlock(57, 40)).c(5.0F).b(10.0F).a(j); + public static final Block WORKBENCH = (new BlockWorkbench(58)).c(2.5F).a(f); + public static final Block CROPS = (new BlockCrops(59, 88)).c(0.0F).a(h); + public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(g); + public static final Block FURNACE = (new BlockFurnace(61, false)).c(3.5F).a(i); + public static final Block BURNING_FURNACE = (new BlockFurnace(62, true)).c(3.5F).a(i).a(0.875F); + public static final Block SIGN_POST = (new BlockSign(63, TileEntitySign.class, true)).c(1.0F).a(f); + public static final Block WOODEN_DOOR = (new BlockDoor(64, Material.c)).c(3.0F).a(f); + public static final Block LADDER = (new BlockLadder(65, 83)).c(0.4F).a(f); + public static final Block RAILS = (new BlockMinecartTrack(66, 128)).c(0.7F).a(j); + public static final Block COBBLESTONE_STAIRS = new BlockStairs(67, COBBLESTONE); + public static final Block WALL_SIGN = (new BlockSign(68, TileEntitySign.class, false)).c(1.0F).a(f); + public static final Block LEVER = (new BlockLever(69, 96)).c(0.5F).a(f); + public static final Block STONE_PLATE = (new BlockPressurePlate(70, STONE.bb, EnumMobType.MOBS)).c(0.5F).a(i); + public static final Block IRON_DOOR_BLOCK = (new BlockDoor(71, Material.e)).c(5.0F).a(j); + public static final Block WOOD_PLATE = (new BlockPressurePlate(72, WOOD.bb, EnumMobType.EVERYTHING)).c(0.5F).a(f); + public static final Block REDSTONE_ORE = (new BlockRedstoneOre(73, 51, false)).c(3.0F).b(5.0F).a(i); + public static final Block GLOWING_REDSTONE_ORE = (new BlockRedstoneOre(74, 51, true)).a(0.625F).c(3.0F).b(5.0F).a(i); + public static final Block REDSTONE_TORCH_OFF = (new BlockRedstoneTorch(75, 115, false)).c(0.0F).a(f); + public static final Block REDSTONE_TORCH_ON = (new BlockRedstoneTorch(76, 99, true)).c(0.0F).a(0.5F).a(f); + public static final Block STONE_BUTTON = (new BlockButton(77, STONE.bb)).c(0.5F).a(i); + public static final Block SNOW = (new BlockSnow(78, 66)).c(0.1F).a(l); + public static final Block ICE = (new BlockIce(79, 67)).c(0.5F).c(3).a(k); + public static final Block SNOW_BLOCK = (new BlockSnowBlock(80, 66)).c(0.2F).a(l); + public static final Block CACTUS = (new BlockCactus(81, 70)).c(0.4F).a(l); + public static final Block CLAY = (new BlockClay(82, 72)).c(0.6F).a(g); + public static final Block SUGAR_CANE_BLOCK = (new BlockReed(83, 73)).c(0.0F).a(h); + public static final Block JUKEBOX = (new BlockJukeBox(84, 74)).c(2.0F).b(10.0F).a(i); + public static final Block FENCE = (new BlockFence(85, 4)).c(2.0F).b(5.0F).a(f); + public int bb; + public final int bc; + protected float bd; + protected float be; + public double bf; + public double bg; + public double bh; + public double bi; + public double bj; + public double bk; + public StepSound bl; + public float bm; + public final Material bn; + public float bo; + + protected Block(int i, Material material) { + this.bl = e; + this.bm = 1.0F; + this.bo = 0.6F; + if (n[i] != null) { + throw new IllegalArgumentException("Slot " + i + " is already occupied by " + n[i] + " when adding " + this); + } else { + this.bn = material; + n[i] = this; + this.bc = i; + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + p[i] = this.b(); + r[i] = this.b() ? 255 : 0; + s[i] = this.f(); + q[i] = false; + } + } + + protected Block(int i, int j, Material material) { + this(i, material); + this.bb = j; + } + + protected Block a(StepSound stepsound) { + this.bl = stepsound; + return this; + } + + protected Block c(int i) { + r[this.bc] = i; + return this; + } + + protected Block a(float f) { + t[this.bc] = (int) (15.0F * f); + return this; + } + + protected Block b(float f) { + this.be = f * 3.0F; + return this; + } + + private boolean f() { + return false; + } + + public int a() { + return 0; + } + + protected Block c(float f) { + this.bd = f; + if (this.be < f * 5.0F) { + this.be = f * 5.0F; + } + + return this; + } + + protected void a(boolean flag) { + o[this.bc] = flag; + } + + public void a(float f, float f1, float f2, float f3, float f4, float f5) { + this.bf = (double) f; + this.bg = (double) f1; + this.bh = (double) f2; + this.bi = (double) f3; + this.bj = (double) f4; + this.bk = (double) f5; + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return l == 0 && this.bg > 0.0D ? true : (l == 1 && this.bj < 1.0D ? true : (l == 2 && this.bh > 0.0D ? true : (l == 3 && this.bk < 1.0D ? true : (l == 4 && this.bf > 0.0D ? true : (l == 5 && this.bi < 1.0D ? true : !iblockaccess.d(i, j, k)))))); + } + + public int a(int i) { + return this.bb; + } + + public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) { + AxisAlignedBB axisalignedbb1 = this.d(world, i, j, k); + + if (axisalignedbb1 != null && axisalignedbb.a(axisalignedbb1)) { + arraylist.add(axisalignedbb1); + } + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return AxisAlignedBB.b((double) i + this.bf, (double) j + this.bg, (double) k + this.bh, (double) i + this.bi, (double) j + this.bj, (double) k + this.bk); + } + + public boolean b() { + return true; + } + + public boolean a(int i, boolean flag) { + return this.e(); + } + + public boolean e() { + return true; + } + + public void a(World world, int i, int j, int k, Random random) {} + + public void a(World world, int i, int j, int k, int l) {} + + public void b(World world, int i, int j, int k, int l) {} + + public int c() { + return 10; + } + + public void e(World world, int i, int j, int k) {} + + public void b(World world, int i, int j, int k) {} + + public int a(Random random) { + return 1; + } + + public int a(int i, Random random) { + return this.bc; + } + + public float a(EntityHuman entityhuman) { + return this.bd < 0.0F ? 0.0F : (!entityhuman.b(this) ? 1.0F / this.bd / 100.0F : entityhuman.a(this) / this.bd / 30.0F); + } + + public void a_(World world, int i, int j, int k, int l) { + this.a(world, i, j, k, l, 1.0F); + } + + public void a(World world, int i, int j, int k, int l, float f) { + if (!world.x) { + int i1 = this.a(world.m); + + for (int j1 = 0; j1 < i1; ++j1) { + if (world.m.nextFloat() <= f) { + int k1 = this.a(l, world.m); + + if (k1 > 0) { + float f1 = 0.7F; + double d0 = (double) (world.m.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; + double d1 = (double) (world.m.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; + double d2 = (double) (world.m.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; + EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(k1)); + + entityitem.ad = 10; + world.a((Entity) entityitem); + } + } + } + } + } + + public float a(Entity entity) { + return this.be / 5.0F; + } + + public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { + this.a((IBlockAccess) world, i, j, k); + vec3d = vec3d.c((double) (-i), (double) (-j), (double) (-k)); + vec3d1 = vec3d1.c((double) (-i), (double) (-j), (double) (-k)); + Vec3D vec3d2 = vec3d.a(vec3d1, this.bf); + Vec3D vec3d3 = vec3d.a(vec3d1, this.bi); + Vec3D vec3d4 = vec3d.b(vec3d1, this.bg); + Vec3D vec3d5 = vec3d.b(vec3d1, this.bj); + Vec3D vec3d6 = vec3d.c(vec3d1, this.bh); + Vec3D vec3d7 = vec3d.c(vec3d1, this.bk); + + if (!this.a(vec3d2)) { + vec3d2 = null; + } + + if (!this.a(vec3d3)) { + vec3d3 = null; + } + + if (!this.b(vec3d4)) { + vec3d4 = null; + } + + if (!this.b(vec3d5)) { + vec3d5 = null; + } + + if (!this.c(vec3d6)) { + vec3d6 = null; + } + + if (!this.c(vec3d7)) { + vec3d7 = null; + } + + Vec3D vec3d8 = null; + + if (vec3d2 != null && (vec3d8 == null || vec3d.a(vec3d2) < vec3d.a(vec3d8))) { + vec3d8 = vec3d2; + } + + if (vec3d3 != null && (vec3d8 == null || vec3d.a(vec3d3) < vec3d.a(vec3d8))) { + vec3d8 = vec3d3; + } + + if (vec3d4 != null && (vec3d8 == null || vec3d.a(vec3d4) < vec3d.a(vec3d8))) { + vec3d8 = vec3d4; + } + + if (vec3d5 != null && (vec3d8 == null || vec3d.a(vec3d5) < vec3d.a(vec3d8))) { + vec3d8 = vec3d5; + } + + if (vec3d6 != null && (vec3d8 == null || vec3d.a(vec3d6) < vec3d.a(vec3d8))) { + vec3d8 = vec3d6; + } + + if (vec3d7 != null && (vec3d8 == null || vec3d.a(vec3d7) < vec3d.a(vec3d8))) { + vec3d8 = vec3d7; + } + + if (vec3d8 == null) { + return null; + } else { + byte b0 = -1; + + if (vec3d8 == vec3d2) { + b0 = 4; + } + + if (vec3d8 == vec3d3) { + b0 = 5; + } + + if (vec3d8 == vec3d4) { + b0 = 0; + } + + if (vec3d8 == vec3d5) { + b0 = 1; + } + + if (vec3d8 == vec3d6) { + b0 = 2; + } + + if (vec3d8 == vec3d7) { + b0 = 3; + } + + return new MovingObjectPosition(i, j, k, b0, vec3d8.c((double) i, (double) j, (double) k)); + } + } + + private boolean a(Vec3D vec3d) { + return vec3d == null ? false : vec3d.b >= this.bg && vec3d.b <= this.bj && vec3d.c >= this.bh && vec3d.c <= this.bk; + } + + private boolean b(Vec3D vec3d) { + return vec3d == null ? false : vec3d.a >= this.bf && vec3d.a <= this.bi && vec3d.c >= this.bh && vec3d.c <= this.bk; + } + + private boolean c(Vec3D vec3d) { + return vec3d == null ? false : vec3d.a >= this.bf && vec3d.a <= this.bi && vec3d.b >= this.bg && vec3d.b <= this.bj; + } + + public void c(World world, int i, int j, int k) {} + + public boolean a(World world, int i, int j, int k) { + int l = world.a(i, j, k); + + return l == 0 || n[l].bn.d(); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + return false; + } + + public void b(World world, int i, int j, int k, Entity entity) {} + + public void c(World world, int i, int j, int k, int l) {} + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) {} + + public void a(World world, int i, int j, int k, Entity entity, Vec3D vec3d) {} + + public void a(IBlockAccess iblockaccess, int i, int j, int k) {} + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return false; + } + + public boolean d() { + return false; + } + + public void a(World world, int i, int j, int k, Entity entity) {} + + public boolean d(World world, int i, int j, int k, int l) { + return false; + } + + public boolean f(World world, int i, int j, int k) { + return true; + } + + static { + for (int i = 0; i < 256; ++i) { + if (n[i] != null) { + Item.c[i] = new ItemBlock(i - 256); + } + } + } +} diff --git a/net/minecraft/server/BlockBookshelf.java b/net/minecraft/server/BlockBookshelf.java new file mode 100644 index 000000000..8ca1ccf13 --- /dev/null +++ b/net/minecraft/server/BlockBookshelf.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockBookshelf extends Block { + + public BlockBookshelf(int i, int j) { + super(i, j, Material.c); + } + + public int a(int i) { + return i <= 1 ? 4 : this.bb; + } + + public int a(Random random) { + return 0; + } +} diff --git a/net/minecraft/server/BlockBreakable.java b/net/minecraft/server/BlockBreakable.java new file mode 100644 index 000000000..abb487f2a --- /dev/null +++ b/net/minecraft/server/BlockBreakable.java @@ -0,0 +1,21 @@ +package net.minecraft.server; + +public class BlockBreakable extends Block { + + private boolean a; + + protected BlockBreakable(int i, int j, Material material, boolean flag) { + super(i, j, material); + this.a = flag; + } + + public boolean b() { + return false; + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + int i1 = iblockaccess.a(i, j, k); + + return !this.a && i1 == this.bc ? false : super.a(iblockaccess, i, j, k, l); + } +} diff --git a/net/minecraft/server/BlockButton.java b/net/minecraft/server/BlockButton.java new file mode 100644 index 000000000..2e2b7a427 --- /dev/null +++ b/net/minecraft/server/BlockButton.java @@ -0,0 +1,228 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockButton extends Block { + + protected BlockButton(int i, int j) { + super(i, j, Material.n); + this.a(true); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public int c() { + return 20; + } + + public boolean b() { + return false; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i - 1, j, k) ? true : (world.d(i + 1, j, k) ? true : (world.d(i, j, k - 1) ? true : world.d(i, j, k + 1))); + } + + public void c(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + int j1 = i1 & 8; + + i1 &= 7; + if (l == 2 && world.d(i, j, k + 1)) { + i1 = 4; + } + + if (l == 3 && world.d(i, j, k - 1)) { + i1 = 3; + } + + if (l == 4 && world.d(i + 1, j, k)) { + i1 = 2; + } + + if (l == 5 && world.d(i - 1, j, k)) { + i1 = 1; + } + + world.b(i, j, k, i1 + j1); + } + + public void e(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + world.b(i, j, k, 1); + } else if (world.d(i + 1, j, k)) { + world.b(i, j, k, 2); + } else if (world.d(i, j, k - 1)) { + world.b(i, j, k, 3); + } else if (world.d(i, j, k + 1)) { + world.b(i, j, k, 4); + } + + this.g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (this.g(world, i, j, k)) { + int i1 = world.b(i, j, k) & 7; + boolean flag = false; + + if (!world.d(i - 1, j, k) && i1 == 1) { + flag = true; + } + + if (!world.d(i + 1, j, k) && i1 == 2) { + flag = true; + } + + if (!world.d(i, j, k - 1) && i1 == 3) { + flag = true; + } + + if (!world.d(i, j, k + 1) && i1 == 4) { + flag = true; + } + + if (flag) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + if (!this.a(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + return false; + } else { + return true; + } + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.b(i, j, k); + int i1 = l & 7; + boolean flag = (l & 8) > 0; + float f = 0.375F; + float f1 = 0.625F; + float f2 = 0.1875F; + float f3 = 0.125F; + + if (flag) { + f3 = 0.0625F; + } + + if (i1 == 1) { + this.a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); + } else if (i1 == 2) { + this.a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); + } else if (i1 == 3) { + this.a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); + } else if (i1 == 4) { + this.a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); + } + } + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) { + this.a(world, i, j, k, entityhuman); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + int l = world.b(i, j, k); + int i1 = l & 7; + int j1 = 8 - (l & 8); + + if (j1 == 0) { + return true; + } else { + world.b(i, j, k, i1 + j1); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); + world.g(i, j, k, this.bc); + if (i1 == 1) { + world.g(i - 1, j, k, this.bc); + } else if (i1 == 2) { + world.g(i + 1, j, k, this.bc); + } else if (i1 == 3) { + world.g(i, j, k - 1, this.bc); + } else if (i1 == 4) { + world.g(i, j, k + 1, this.bc); + } else { + world.g(i, j - 1, k, this.bc); + } + + world.h(i, j, k, this.bc); + return true; + } + } + + public void b(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + if ((l & 8) > 0) { + world.g(i, j, k, this.bc); + int i1 = l & 7; + + if (i1 == 1) { + world.g(i - 1, j, k, this.bc); + } else if (i1 == 2) { + world.g(i + 1, j, k, this.bc); + } else if (i1 == 3) { + world.g(i, j, k - 1, this.bc); + } else if (i1 == 4) { + world.g(i, j, k + 1, this.bc); + } else { + world.g(i, j - 1, k, this.bc); + } + } + + super.b(world, i, j, k); + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return (iblockaccess.b(i, j, k) & 8) > 0; + } + + public boolean d(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 & 8) == 0) { + return false; + } else { + int j1 = i1 & 7; + + return j1 == 5 && l == 1 ? true : (j1 == 4 && l == 2 ? true : (j1 == 3 && l == 3 ? true : (j1 == 2 && l == 4 ? true : j1 == 1 && l == 5))); + } + } + + public boolean d() { + return true; + } + + public void a(World world, int i, int j, int k, Random random) { + int l = world.b(i, j, k); + + if ((l & 8) != 0) { + world.b(i, j, k, l & 7); + world.g(i, j, k, this.bc); + int i1 = l & 7; + + if (i1 == 1) { + world.g(i - 1, j, k, this.bc); + } else if (i1 == 2) { + world.g(i + 1, j, k, this.bc); + } else if (i1 == 3) { + world.g(i, j, k - 1, this.bc); + } else if (i1 == 4) { + world.g(i, j, k + 1, this.bc); + } else { + world.g(i, j - 1, k, this.bc); + } + + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); + world.b(i, j, k, i, j, k); + } + } +} diff --git a/net/minecraft/server/BlockCactus.java b/net/minecraft/server/BlockCactus.java new file mode 100644 index 000000000..8813fda0a --- /dev/null +++ b/net/minecraft/server/BlockCactus.java @@ -0,0 +1,81 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockCactus extends Block { + + protected BlockCactus(int i, int j) { + super(i, j, Material.u); + this.a(true); + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.a(i, j + 1, k) == 0) { + int l; + + for (l = 1; world.a(i, j - l, k) == this.bc; ++l) { + ; + } + + if (l < 3) { + int i1 = world.b(i, j, k); + + if (i1 == 15) { + world.d(i, j + 1, k, this.bc); + world.b(i, j, k, 0); + } else { + world.b(i, j, k, i1 + 1); + } + } + } + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + float f = 0.0625F; + + return AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f)); + } + + public int a(int i) { + return i == 1 ? this.bb - 1 : (i == 0 ? this.bb + 1 : this.bb); + } + + public boolean b() { + return false; + } + + public int a() { + return 13; + } + + public boolean a(World world, int i, int j, int k) { + return !super.a(world, i, j, k) ? false : this.f(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (!this.f(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + + public boolean f(World world, int i, int j, int k) { + if (world.c(i - 1, j, k).a()) { + return false; + } else if (world.c(i + 1, j, k).a()) { + return false; + } else if (world.c(i, j, k - 1).a()) { + return false; + } else if (world.c(i, j, k + 1).a()) { + return false; + } else { + int l = world.a(i, j - 1, k); + + return l == Block.CACTUS.bc || l == Block.SAND.bc; + } + } + + public void a(World world, int i, int j, int k, Entity entity) { + entity.a((Entity) null, 1); + } +} diff --git a/net/minecraft/server/BlockChest.java b/net/minecraft/server/BlockChest.java new file mode 100644 index 000000000..38b8d03dc --- /dev/null +++ b/net/minecraft/server/BlockChest.java @@ -0,0 +1,115 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockChest extends BlockContainer { + + private Random a = new Random(); + + protected BlockChest(int i) { + super(i, Material.c); + this.bb = 26; + } + + public int a(int i) { + return i == 1 ? this.bb - 1 : (i == 0 ? this.bb - 1 : (i == 3 ? this.bb + 1 : this.bb)); + } + + public boolean a(World world, int i, int j, int k) { + int l = 0; + + if (world.a(i - 1, j, k) == this.bc) { + ++l; + } + + if (world.a(i + 1, j, k) == this.bc) { + ++l; + } + + if (world.a(i, j, k - 1) == this.bc) { + ++l; + } + + if (world.a(i, j, k + 1) == this.bc) { + ++l; + } + + return l > 1 ? false : (this.g(world, i - 1, j, k) ? false : (this.g(world, i + 1, j, k) ? false : (this.g(world, i, j, k - 1) ? false : !this.g(world, i, j, k + 1)))); + } + + private boolean g(World world, int i, int j, int k) { + return world.a(i, j, k) != this.bc ? false : (world.a(i - 1, j, k) == this.bc ? true : (world.a(i + 1, j, k) == this.bc ? true : (world.a(i, j, k - 1) == this.bc ? true : world.a(i, j, k + 1) == this.bc))); + } + + public void b(World world, int i, int j, int k) { + TileEntityChest tileentitychest = (TileEntityChest) world.k(i, j, k); + + for (int l = 0; l < tileentitychest.a(); ++l) { + ItemStack itemstack = tileentitychest.a(l); + + if (itemstack != null) { + float f = this.a.nextFloat() * 0.8F + 0.1F; + float f1 = this.a.nextFloat() * 0.8F + 0.1F; + float f2 = this.a.nextFloat() * 0.8F + 0.1F; + + while (itemstack.a > 0) { + int i1 = this.a.nextInt(21) + 10; + + if (i1 > itemstack.a) { + i1 = itemstack.a; + } + + itemstack.a -= i1; + EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.c, i1, itemstack.d)); + float f3 = 0.05F; + + entityitem.o = (double) ((float) this.a.nextGaussian() * f3); + entityitem.p = (double) ((float) this.a.nextGaussian() * f3 + 0.2F); + entityitem.q = (double) ((float) this.a.nextGaussian() * f3); + world.a((Entity) entityitem); + } + } + } + + super.b(world, i, j, k); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + Object object = (TileEntityChest) world.k(i, j, k); + + if (world.d(i, j + 1, k)) { + return true; + } else if (world.a(i - 1, j, k) == this.bc && world.d(i - 1, j + 1, k)) { + return true; + } else if (world.a(i + 1, j, k) == this.bc && world.d(i + 1, j + 1, k)) { + return true; + } else if (world.a(i, j, k - 1) == this.bc && world.d(i, j + 1, k - 1)) { + return true; + } else if (world.a(i, j, k + 1) == this.bc && world.d(i, j + 1, k + 1)) { + return true; + } else { + if (world.a(i - 1, j, k) == this.bc) { + object = new InventoryLargeChest("Large chest", (TileEntityChest) world.k(i - 1, j, k), (IInventory) object); + } + + if (world.a(i + 1, j, k) == this.bc) { + object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.k(i + 1, j, k)); + } + + if (world.a(i, j, k - 1) == this.bc) { + object = new InventoryLargeChest("Large chest", (TileEntityChest) world.k(i, j, k - 1), (IInventory) object); + } + + if (world.a(i, j, k + 1) == this.bc) { + object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.k(i, j, k + 1)); + } + + entityhuman.a((IInventory) object); + return true; + } + } + + protected TileEntity a_() { + return new TileEntityChest(); + } +} diff --git a/net/minecraft/server/BlockClay.java b/net/minecraft/server/BlockClay.java new file mode 100644 index 000000000..3b41d03a8 --- /dev/null +++ b/net/minecraft/server/BlockClay.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockClay extends Block { + + public BlockClay(int i, int j) { + super(i, j, Material.v); + } + + public int a(int i, Random random) { + return Item.CLAY_BALL.aS; + } + + public int a(Random random) { + return 4; + } +} diff --git a/net/minecraft/server/BlockContainer.java b/net/minecraft/server/BlockContainer.java new file mode 100644 index 000000000..d90bffe65 --- /dev/null +++ b/net/minecraft/server/BlockContainer.java @@ -0,0 +1,25 @@ +package net.minecraft.server; + +public abstract class BlockContainer extends Block { + + protected BlockContainer(int i, Material material) { + super(i, material); + q[i] = true; + } + + protected BlockContainer(int i, int j, Material material) { + super(i, j, material); + } + + public void e(World world, int i, int j, int k) { + super.e(world, i, j, k); + world.a(i, j, k, this.a_()); + } + + public void b(World world, int i, int j, int k) { + super.b(world, i, j, k); + world.l(i, j, k); + } + + protected abstract TileEntity a_(); +} diff --git a/net/minecraft/server/BlockCrops.java b/net/minecraft/server/BlockCrops.java new file mode 100644 index 000000000..dc1d190b2 --- /dev/null +++ b/net/minecraft/server/BlockCrops.java @@ -0,0 +1,106 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockCrops extends BlockFlower { + + protected BlockCrops(int i, int j) { + super(i, j); + this.bb = j; + this.a(true); + float f = 0.5F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + } + + protected boolean b(int i) { + return i == Block.SOIL.bc; + } + + public void a(World world, int i, int j, int k, Random random) { + super.a(world, i, j, k, random); + if (world.h(i, j + 1, k) >= 9) { + int l = world.b(i, j, k); + + if (l < 7) { + float f = this.h(world, i, j, k); + + if (random.nextInt((int) (100.0F / f)) == 0) { + ++l; + world.b(i, j, k, l); + } + } + } + } + + private float h(World world, int i, int j, int k) { + float f = 1.0F; + int l = world.a(i, j, k - 1); + int i1 = world.a(i, j, k + 1); + int j1 = world.a(i - 1, j, k); + int k1 = world.a(i + 1, j, k); + int l1 = world.a(i - 1, j, k - 1); + int i2 = world.a(i + 1, j, k - 1); + int j2 = world.a(i + 1, j, k + 1); + int k2 = world.a(i - 1, j, k + 1); + boolean flag = j1 == this.bc || k1 == this.bc; + boolean flag1 = l == this.bc || i1 == this.bc; + boolean flag2 = l1 == this.bc || i2 == this.bc || j2 == this.bc || k2 == this.bc; + + for (int l2 = i - 1; l2 <= i + 1; ++l2) { + for (int i3 = k - 1; i3 <= k + 1; ++i3) { + int j3 = world.a(l2, j - 1, i3); + float f1 = 0.0F; + + if (j3 == Block.SOIL.bc) { + f1 = 1.0F; + if (world.b(l2, j - 1, i3) > 0) { + f1 = 3.0F; + } + } + + if (l2 != i || i3 != k) { + f1 /= 4.0F; + } + + f += f1; + } + } + + if (flag2 || flag && flag1) { + f /= 2.0F; + } + + return f; + } + + public int a() { + return 6; + } + + public void a(World world, int i, int j, int k, int l) { + super.a(world, i, j, k, l); + + for (int i1 = 0; i1 < 3; ++i1) { + if (world.m.nextInt(15) <= l) { + float f = 0.7F; + float f1 = world.m.nextFloat() * f + (1.0F - f) * 0.5F; + float f2 = world.m.nextFloat() * f + (1.0F - f) * 0.5F; + float f3 = world.m.nextFloat() * f + (1.0F - f) * 0.5F; + EntityItem entityitem = new EntityItem(world, (double) ((float) i + f1), (double) ((float) j + f2), (double) ((float) k + f3), new ItemStack(Item.SEEDS)); + + entityitem.ad = 10; + world.a((Entity) entityitem); + } + } + } + + public int a(int i, Random random) { + System.out.println("Get resource: " + i); + return i == 7 ? Item.WHEAT.aS : -1; + } + + public int a(Random random) { + return 1; + } +} diff --git a/net/minecraft/server/BlockDirt.java b/net/minecraft/server/BlockDirt.java new file mode 100644 index 000000000..ce26e43a8 --- /dev/null +++ b/net/minecraft/server/BlockDirt.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +public class BlockDirt extends Block { + + protected BlockDirt(int i, int j) { + super(i, j, Material.b); + } +} diff --git a/net/minecraft/server/BlockDoor.java b/net/minecraft/server/BlockDoor.java new file mode 100644 index 000000000..93b174d43 --- /dev/null +++ b/net/minecraft/server/BlockDoor.java @@ -0,0 +1,171 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockDoor extends Block { + + protected BlockDoor(int i, Material material) { + super(i, material); + this.bb = 97; + if (material == Material.e) { + ++this.bb; + } + + float f = 0.5F; + float f1 = 1.0F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + } + + public boolean b() { + return false; + } + + public int a() { + return 7; + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + this.a((IBlockAccess) world, i, j, k); + return super.d(world, i, j, k); + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + this.b(this.d(iblockaccess.b(i, j, k))); + } + + public void b(int i) { + float f = 0.1875F; + + this.a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); + if (i == 0) { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + + if (i == 1) { + this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + if (i == 2) { + this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + + if (i == 3) { + this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) { + this.a(world, i, j, k, entityhuman); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + if (this.bn == Material.e) { + return true; + } else { + int l = world.b(i, j, k); + + if ((l & 8) != 0) { + if (world.a(i, j - 1, k) == this.bc) { + this.a(world, i, j - 1, k, entityhuman); + } + + return true; + } else { + if (world.a(i, j + 1, k) == this.bc) { + world.b(i, j + 1, k, (l ^ 4) + 8); + } + + world.b(i, j, k, l ^ 4); + world.b(i, j - 1, k, i, j, k); + if (Math.random() < 0.5D) { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.m.nextFloat() * 0.1F + 0.9F); + } else { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.m.nextFloat() * 0.1F + 0.9F); + } + + return true; + } + } + } + + public void a(World world, int i, int j, int k, boolean flag) { + int l = world.b(i, j, k); + + if ((l & 8) != 0) { + if (world.a(i, j - 1, k) == this.bc) { + this.a(world, i, j - 1, k, flag); + } + } else { + boolean flag1 = (world.b(i, j, k) & 4) > 0; + + if (flag1 != flag) { + if (world.a(i, j + 1, k) == this.bc) { + world.b(i, j + 1, k, (l ^ 4) + 8); + } + + world.b(i, j, k, l ^ 4); + world.b(i, j - 1, k, i, j, k); + if (Math.random() < 0.5D) { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.m.nextFloat() * 0.1F + 0.9F); + } else { + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.m.nextFloat() * 0.1F + 0.9F); + } + } + } + } + + public void b(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 & 8) != 0) { + if (world.a(i, j - 1, k) != this.bc) { + world.d(i, j, k, 0); + } + + if (l > 0 && Block.n[l].d()) { + this.b(world, i, j - 1, k, l); + } + } else { + boolean flag = false; + + if (world.a(i, j + 1, k) != this.bc) { + world.d(i, j, k, 0); + flag = true; + } + + if (!world.d(i, j - 1, k)) { + world.d(i, j, k, 0); + flag = true; + if (world.a(i, j + 1, k) == this.bc) { + world.d(i, j + 1, k, 0); + } + } + + if (flag) { + this.a_(world, i, j, k, i1); + } else if (l > 0 && Block.n[l].d()) { + boolean flag1 = world.n(i, j, k) || world.n(i, j + 1, k); + + this.a(world, i, j, k, flag1); + } + } + } + + public int a(int i, Random random) { + return (i & 8) != 0 ? 0 : (this.bn == Material.e ? Item.IRON_DOOR.aS : Item.WOOD_DOOR.aS); + } + + public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { + this.a((IBlockAccess) world, i, j, k); + return super.a(world, i, j, k, vec3d, vec3d1); + } + + public int d(int i) { + return (i & 4) == 0 ? i - 1 & 3 : i & 3; + } + + public boolean a(World world, int i, int j, int k) { + return j >= 127 ? false : world.d(i, j - 1, k) && super.a(world, i, j, k) && super.a(world, i, j + 1, k); + } +} diff --git a/net/minecraft/server/BlockFence.java b/net/minecraft/server/BlockFence.java new file mode 100644 index 000000000..e3f5920a8 --- /dev/null +++ b/net/minecraft/server/BlockFence.java @@ -0,0 +1,26 @@ +package net.minecraft.server; + +import java.util.ArrayList; + +public class BlockFence extends Block { + + public BlockFence(int i, int j) { + super(i, j, Material.c); + } + + public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) { + arraylist.add(AxisAlignedBB.b((double) i, (double) j, (double) k, (double) (i + 1), (double) j + 1.5D, (double) (k + 1))); + } + + public boolean a(World world, int i, int j, int k) { + return world.a(i, j - 1, k) == this.bc ? false : (!world.c(i, j - 1, k).a() ? false : super.a(world, i, j, k)); + } + + public boolean b() { + return false; + } + + public int a() { + return 11; + } +} diff --git a/net/minecraft/server/BlockFire.java b/net/minecraft/server/BlockFire.java new file mode 100644 index 000000000..cd6ed3db9 --- /dev/null +++ b/net/minecraft/server/BlockFire.java @@ -0,0 +1,162 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockFire extends Block { + + private int[] a = new int[256]; + private int[] b = new int[256]; + + protected BlockFire(int i, int j) { + super(i, j, Material.l); + this.a(Block.WOOD.bc, 5, 20); + this.a(Block.LOG.bc, 5, 5); + this.a(Block.LEAVES.bc, 30, 60); + this.a(Block.BOOKSHELF.bc, 30, 20); + this.a(Block.TNT.bc, 15, 100); + this.a(Block.WOOL.bc, 30, 60); + this.a(true); + } + + private void a(int i, int j, int k) { + this.a[i] = j; + this.b[i] = k; + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public int a() { + return 3; + } + + public int a(Random random) { + return 0; + } + + public int c() { + return 10; + } + + public void a(World world, int i, int j, int k, Random random) { + int l = world.b(i, j, k); + + if (l < 15) { + world.b(i, j, k, l + 1); + world.h(i, j, k, this.bc); + } + + if (!this.g(world, i, j, k)) { + if (!world.d(i, j - 1, k) || l > 3) { + world.d(i, j, k, 0); + } + } else if (!this.b(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { + world.d(i, j, k, 0); + } else { + if (l % 2 == 0 && l > 2) { + this.a(world, i + 1, j, k, 300, random); + this.a(world, i - 1, j, k, 300, random); + this.a(world, i, j - 1, k, 200, random); + this.a(world, i, j + 1, k, 250, random); + this.a(world, i, j, k - 1, 300, random); + this.a(world, i, j, k + 1, 300, random); + + for (int i1 = i - 1; i1 <= i + 1; ++i1) { + for (int j1 = k - 1; j1 <= k + 1; ++j1) { + for (int k1 = j - 1; k1 <= j + 4; ++k1) { + if (i1 != i || k1 != j || j1 != k) { + int l1 = 100; + + if (k1 > j + 1) { + l1 += (k1 - (j + 1)) * 100; + } + + int i2 = this.h(world, i1, k1, j1); + + if (i2 > 0 && random.nextInt(l1) <= i2) { + world.d(i1, k1, j1, this.bc); + } + } + } + } + } + } + } + } + + private void a(World world, int i, int j, int k, int l, Random random) { + int i1 = this.b[world.a(i, j, k)]; + + if (random.nextInt(l) < i1) { + boolean flag = world.a(i, j, k) == Block.TNT.bc; + + if (random.nextInt(2) == 0) { + world.d(i, j, k, this.bc); + } else { + world.d(i, j, k, 0); + } + + if (flag) { + Block.TNT.a(world, i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + return this.b(world, i + 1, j, k) ? true : (this.b(world, i - 1, j, k) ? true : (this.b(world, i, j - 1, k) ? true : (this.b(world, i, j + 1, k) ? true : (this.b(world, i, j, k - 1) ? true : this.b(world, i, j, k + 1))))); + } + + private int h(World world, int i, int j, int k) { + byte b0 = 0; + + if (world.a(i, j, k) != 0) { + return 0; + } else { + int l = this.f(world, i + 1, j, k, b0); + + l = this.f(world, i - 1, j, k, l); + l = this.f(world, i, j - 1, k, l); + l = this.f(world, i, j + 1, k, l); + l = this.f(world, i, j, k - 1, l); + l = this.f(world, i, j, k + 1, l); + return l; + } + } + + public boolean e() { + return false; + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { + return this.a[iblockaccess.a(i, j, k)] > 0; + } + + public int f(World world, int i, int j, int k, int l) { + int i1 = this.a[world.a(i, j, k)]; + + return i1 > l ? i1 : l; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i, j - 1, k) || this.g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) { + world.d(i, j, k, 0); + } + } + + public void e(World world, int i, int j, int k) { + if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) { + world.d(i, j, k, 0); + } else { + world.h(i, j, k, this.bc); + } + } +} diff --git a/net/minecraft/server/BlockFlower.java b/net/minecraft/server/BlockFlower.java new file mode 100644 index 000000000..b3c387dbc --- /dev/null +++ b/net/minecraft/server/BlockFlower.java @@ -0,0 +1,55 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockFlower extends Block { + + protected BlockFlower(int i, int j) { + super(i, Material.i); + this.bb = j; + this.a(true); + float f = 0.2F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f); + } + + public boolean a(World world, int i, int j, int k) { + return this.b(world.a(i, j - 1, k)); + } + + protected boolean b(int i) { + return i == Block.GRASS.bc || i == Block.DIRT.bc || i == Block.SOIL.bc; + } + + public void b(World world, int i, int j, int k, int l) { + super.b(world, i, j, k, l); + this.g(world, i, j, k); + } + + public void a(World world, int i, int j, int k, Random random) { + this.g(world, i, j, k); + } + + protected final void g(World world, int i, int j, int k) { + if (!this.f(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + + public boolean f(World world, int i, int j, int k) { + return (world.h(i, j, k) >= 8 || world.g(i, j, k)) && this.b(world.a(i, j - 1, k)); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public int a() { + return 1; + } +} diff --git a/net/minecraft/server/BlockFlowing.java b/net/minecraft/server/BlockFlowing.java new file mode 100644 index 000000000..287b8f9fb --- /dev/null +++ b/net/minecraft/server/BlockFlowing.java @@ -0,0 +1,275 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockFlowing extends BlockFluids { + + int a = 0; + boolean[] b = new boolean[4]; + int[] c = new int[4]; + + protected BlockFlowing(int i, Material material) { + super(i, material); + } + + private void i(World world, int i, int j, int k) { + int i = world.b(i, j, k); + + world.a(i, j, k, this.bc + 1, i); + world.b(i, j, k, i, j, k); + world.f(i, j, k); + } + + public void a(World world, int i, int j, int k, Random random) { + if (this.bc != 10 && this.bc != 11 || world.a(i, j - 1, k) <= 1) { + int i = this.g(world, i, j, k); + boolean j = true; + int l; + + if (i > 0) { + byte arrayOfBoolean = -100; + + this.a = 0; + int arrayOfBoolean1 = this.e(world, i - 1, j, k, arrayOfBoolean); + + arrayOfBoolean1 = this.e(world, i + 1, j, k, arrayOfBoolean1); + arrayOfBoolean1 = this.e(world, i, j, k - 1, arrayOfBoolean1); + arrayOfBoolean1 = this.e(world, i, j, k + 1, arrayOfBoolean1); + l = arrayOfBoolean1 + this.d; + if (l >= 8 || arrayOfBoolean1 < 0) { + l = -1; + } + + if (this.g(world, i, j + 1, k) >= 0) { + int i1 = this.g(world, i, j + 1, k); + + if (i1 >= 8) { + l = i1; + } else { + l = i1 + 8; + } + } + + if (this.a >= 2 && this.bn == Material.f) { + if (world.d(i, j - 1, k)) { + l = 0; + } else if (world.c(i, j - 1, k) == this.bn && world.b(i, j, k) == 0) { + l = 0; + } + } + + if (this.bn == Material.g && i < 8 && l < 8 && l > i && random.nextInt(4) != 0) { + l = i; + j = false; + } + + if (l != i) { + i = l; + if (l < 0) { + world.d(i, j, k, 0); + } else { + world.b(i, j, k, l); + world.h(i, j, k, this.bc); + world.g(i, j, k, this.bc); + } + } else if (j) { + this.i(world, i, j, k); + } + } else { + this.i(world, i, j, k); + } + + if (this.l(world, i, j - 1, k)) { + if (i >= 8) { + world.b(i, j - 1, k, this.bc, i); + } else { + world.b(i, j - 1, k, this.bc, i + 8); + } + } else if (i >= 0 && (i == 0 || this.k(world, i, j - 1, k))) { + boolean[] arrayOfBoolean2 = this.j(world, i, j, k); + + l = i + this.d; + if (i >= 8) { + l = 1; + } + + if (l >= 8) { + return; + } + + if (arrayOfBoolean2[0]) { + this.f(world, i - 1, j, k, l); + } + + if (arrayOfBoolean2[1]) { + this.f(world, i + 1, j, k, l); + } + + if (arrayOfBoolean2[2]) { + this.f(world, i, j, k - 1, l); + } + + if (!arrayOfBoolean2[3]) { + return; + } + + this.f(world, i, j, k + 1, l); + } + } + } + + private void f(World world, int i, int j, int k, int l) { + if (this.l(world, i, j, k)) { + int i = world.a(i, j, k); + + if (i > 0) { + if (this.bn == Material.g) { + this.h(world, i, j, k); + } else { + Block.n[i].a_(world, i, j, k, world.b(i, j, k)); + } + } + + world.b(i, j, k, this.bc, l); + } + } + + private int a(World world, int i, int j, int k, int l, int i1) { + int i = 1000; + + for (int j = 0; j < 4; ++j) { + if ((j != 0 || i1 != 1) && (j != 1 || i1 != 0) && (j != 2 || i1 != 3) && (j != 3 || i1 != 2)) { + int k = i; + int i1 = k; + + if (j == 0) { + k = i - 1; + } + + if (j == 1) { + ++k; + } + + if (j == 2) { + i1 = k - 1; + } + + if (j == 3) { + ++i1; + } + + if (!this.k(world, k, j, i1) && (world.c(k, j, i1) != this.bn || world.b(k, j, i1) != 0)) { + if (!this.k(world, k, j - 1, i1)) { + return l; + } + + if (l < 4) { + int i2 = this.a(world, k, j, i1, l + 1, j); + + if (i2 < i) { + i = i2; + } + } + } + } + } + + return i; + } + + private boolean[] j(World world, int i, int j, int k) { + int i; + int j; + + for (i = 0; i < 4; ++i) { + this.c[i] = 1000; + j = i; + int l = k; + + if (i == 0) { + j = i - 1; + } + + if (i == 1) { + ++j; + } + + if (i == 2) { + l = k - 1; + } + + if (i == 3) { + ++l; + } + + if (!this.k(world, j, j, l) && (world.c(j, j, l) != this.bn || world.b(j, j, l) != 0)) { + if (!this.k(world, j, j - 1, l)) { + this.c[i] = 0; + } else { + this.c[i] = this.a(world, j, j, l, 1, i); + } + } + } + + i = this.c[0]; + + for (j = 1; j < 4; ++j) { + if (this.c[j] < i) { + i = this.c[j]; + } + } + + for (j = 0; j < 4; ++j) { + this.b[j] = this.c[j] == i; + } + + return this.b; + } + + private boolean k(World world, int i, int j, int k) { + int i = world.a(i, j, k); + + if (i != Block.WOODEN_DOOR.bc && i != Block.IRON_DOOR_BLOCK.bc && i != Block.SIGN_POST.bc && i != Block.LADDER.bc && i != Block.SUGAR_CANE_BLOCK.bc) { + if (i == 0) { + return false; + } else { + Material localiq = Block.n[i].bn; + + return localiq.a(); + } + } else { + return true; + } + } + + protected int e(World world, int i, int j, int k, int l) { + int i = this.g(world, i, j, k); + + if (i < 0) { + return l; + } else { + if (i == 0) { + ++this.a; + } + + if (i >= 8) { + i = 0; + } + + return l >= 0 && i >= l ? l : i; + } + } + + private boolean l(World world, int i, int j, int k) { + Material localiq = world.c(i, j, k); + + return localiq == this.bn ? false : (localiq == Material.g ? false : !this.k(world, i, j, k)); + } + + public void e(World world, int i, int j, int k) { + super.e(world, i, j, k); + if (world.a(i, j, k) == this.bc) { + world.h(i, j, k, this.bc); + } + } +} diff --git a/net/minecraft/server/BlockFluids.java b/net/minecraft/server/BlockFluids.java new file mode 100644 index 000000000..a4d5aedec --- /dev/null +++ b/net/minecraft/server/BlockFluids.java @@ -0,0 +1,240 @@ +package net.minecraft.server; + +import java.util.Random; + +public abstract class BlockFluids extends Block { + + protected int d = 1; + + protected BlockFluids(int i, Material material) { + super(i, (material == Material.g ? 14 : 12) * 16 + 13, material); + float f = 0.0F; + float f1 = 0.0F; + + if (material == Material.g) { + this.d = 2; + } + + this.a(0.0F + f1, 0.0F + f, 0.0F + f1, 1.0F + f1, 1.0F + f, 1.0F + f1); + this.a(true); + } + + public static float b(int i) { + if (i >= 8) { + i = 0; + } + + float f = (float) (i + 1) / 9.0F; + + return f; + } + + public int a(int i) { + return i != 0 && i != 1 ? this.bb + 1 : this.bb; + } + + protected int g(World world, int i, int j, int k) { + return world.c(i, j, k) != this.bn ? -1 : world.b(i, j, k); + } + + protected int b(IBlockAccess iblockaccess, int i, int j, int k) { + if (iblockaccess.c(i, j, k) != this.bn) { + return -1; + } else { + int l = iblockaccess.b(i, j, k); + + if (l >= 8) { + l = 0; + } + + return l; + } + } + + public boolean b() { + return false; + } + + public boolean a(int i, boolean flag) { + return flag && i == 0; + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + Material material = iblockaccess.c(i, j, k); + + return material == this.bn ? false : (material == Material.r ? false : (l == 1 ? true : super.a(iblockaccess, i, j, k, l))); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public int a() { + return 4; + } + + public int a(int i, Random random) { + return 0; + } + + public int a(Random random) { + return 0; + } + + private Vec3D c(IBlockAccess iblockaccess, int i, int j, int k) { + Vec3D vec3d = Vec3D.b(0.0D, 0.0D, 0.0D); + int l = this.b(iblockaccess, i, j, k); + + for (int i1 = 0; i1 < 4; ++i1) { + int j1 = i; + int k1 = k; + + if (i1 == 0) { + j1 = i - 1; + } + + if (i1 == 1) { + k1 = k - 1; + } + + if (i1 == 2) { + ++j1; + } + + if (i1 == 3) { + ++k1; + } + + int l1 = this.b(iblockaccess, j1, j, k1); + int i2; + + if (l1 < 0) { + if (!iblockaccess.c(j1, j, k1).c()) { + l1 = this.b(iblockaccess, j1, j - 1, k1); + if (l1 >= 0) { + i2 = l1 - (l - 8); + vec3d = vec3d.c((double) ((j1 - i) * i2), (double) ((j - j) * i2), (double) ((k1 - k) * i2)); + } + } + } else if (l1 >= 0) { + i2 = l1 - l; + vec3d = vec3d.c((double) ((j1 - i) * i2), (double) ((j - j) * i2), (double) ((k1 - k) * i2)); + } + } + + if (iblockaccess.b(i, j, k) >= 8) { + boolean flag = false; + + if (flag || this.a(iblockaccess, i, j, k - 1, 2)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i, j, k + 1, 3)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i - 1, j, k, 4)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i + 1, j, k, 5)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i, j + 1, k - 1, 2)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i, j + 1, k + 1, 3)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i - 1, j + 1, k, 4)) { + flag = true; + } + + if (flag || this.a(iblockaccess, i + 1, j + 1, k, 5)) { + flag = true; + } + + if (flag) { + vec3d = vec3d.b().c(0.0D, -6.0D, 0.0D); + } + } + + vec3d = vec3d.b(); + return vec3d; + } + + public void a(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { + Vec3D vec3d1 = this.c(world, i, j, k); + + vec3d.a += vec3d1.a; + vec3d.b += vec3d1.b; + vec3d.c += vec3d1.c; + } + + public int c() { + return this.bn == Material.f ? 5 : (this.bn == Material.g ? 30 : 0); + } + + public void a(World world, int i, int j, int k, Random random) { + super.a(world, i, j, k, random); + } + + public void e(World world, int i, int j, int k) { + this.i(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + this.i(world, i, j, k); + } + + private void i(World world, int i, int j, int k) { + if (world.a(i, j, k) == this.bc) { + if (this.bn == Material.g) { + boolean flag = false; + + if (flag || world.c(i, j, k - 1) == Material.f) { + flag = true; + } + + if (flag || world.c(i, j, k + 1) == Material.f) { + flag = true; + } + + if (flag || world.c(i - 1, j, k) == Material.f) { + flag = true; + } + + if (flag || world.c(i + 1, j, k) == Material.f) { + flag = true; + } + + if (flag || world.c(i, j + 1, k) == Material.f) { + flag = true; + } + + if (flag) { + int l = world.b(i, j, k); + + if (l == 0) { + world.d(i, j, k, Block.OBSIDIAN.bc); + } else if (l <= 4) { + world.d(i, j, k, Block.COBBLESTONE.bc); + } + + this.h(world, i, j, k); + } + } + } + } + + protected void h(World world, int i, int j, int k) { + world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.m.nextFloat() - world.m.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) { + world.a("largesmoke", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + } + } +} diff --git a/net/minecraft/server/BlockFurnace.java b/net/minecraft/server/BlockFurnace.java new file mode 100644 index 000000000..98d471409 --- /dev/null +++ b/net/minecraft/server/BlockFurnace.java @@ -0,0 +1,78 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockFurnace extends BlockContainer { + + private final boolean a; + + protected BlockFurnace(int i, boolean flag) { + super(i, Material.d); + this.a = flag; + this.bb = 45; + } + + public int a(int i, Random random) { + return Block.FURNACE.bc; + } + + public void e(World world, int i, int j, int k) { + super.e(world, i, j, k); + this.g(world, i, j, k); + } + + private void g(World world, int i, int j, int k) { + int l = world.a(i, j, k - 1); + int i1 = world.a(i, j, k + 1); + int j1 = world.a(i - 1, j, k); + int k1 = world.a(i + 1, j, k); + byte b0 = 3; + + if (Block.p[l] && !Block.p[i1]) { + b0 = 3; + } + + if (Block.p[i1] && !Block.p[l]) { + b0 = 2; + } + + if (Block.p[j1] && !Block.p[k1]) { + b0 = 5; + } + + if (Block.p[k1] && !Block.p[j1]) { + b0 = 4; + } + + world.b(i, j, k, b0); + } + + public int a(int i) { + return i == 1 ? Block.STONE.bc : (i == 0 ? Block.STONE.bc : (i == 3 ? this.bb - 1 : this.bb)); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.k(i, j, k); + + entityhuman.a(tileentityfurnace); + return true; + } + + public static void a(boolean flag, World world, int i, int j, int k) { + int l = world.b(i, j, k); + TileEntity tileentity = world.k(i, j, k); + + if (flag) { + world.d(i, j, k, Block.BURNING_FURNACE.bc); + } else { + world.d(i, j, k, Block.FURNACE.bc); + } + + world.b(i, j, k, l); + world.a(i, j, k, tileentity); + } + + protected TileEntity a_() { + return new TileEntityFurnace(); + } +} diff --git a/net/minecraft/server/BlockGlass.java b/net/minecraft/server/BlockGlass.java new file mode 100644 index 000000000..35d1887a9 --- /dev/null +++ b/net/minecraft/server/BlockGlass.java @@ -0,0 +1,14 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockGlass extends BlockBreakable { + + public BlockGlass(int i, int j, Material material, boolean flag) { + super(i, j, material, flag); + } + + public int a(Random random) { + return 0; + } +} diff --git a/net/minecraft/server/BlockGrass.java b/net/minecraft/server/BlockGrass.java new file mode 100644 index 000000000..6c8a0f7bf --- /dev/null +++ b/net/minecraft/server/BlockGrass.java @@ -0,0 +1,34 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockGrass extends Block { + + protected BlockGrass(int i) { + super(i, Material.b); + this.bb = 3; + this.a(true); + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.h(i, j + 1, k) < 4 && world.c(i, j + 1, k).b()) { + if (random.nextInt(4) != 0) { + return; + } + + world.d(i, j, k, Block.DIRT.bc); + } else if (world.h(i, j + 1, k) >= 9) { + int l = i + random.nextInt(3) - 1; + int i1 = j + random.nextInt(5) - 3; + int j1 = k + random.nextInt(3) - 1; + + if (world.a(l, i1, j1) == Block.DIRT.bc && world.h(l, i1 + 1, j1) >= 4 && !world.c(l, i1 + 1, j1).b()) { + world.d(l, i1, j1, Block.GRASS.bc); + } + } + } + + public int a(int i, Random random) { + return Block.DIRT.a(0, random); + } +} diff --git a/net/minecraft/server/BlockGravel.java b/net/minecraft/server/BlockGravel.java new file mode 100644 index 000000000..5108bae8b --- /dev/null +++ b/net/minecraft/server/BlockGravel.java @@ -0,0 +1,14 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockGravel extends BlockSand { + + public BlockGravel(int i, int j) { + super(i, j); + } + + public int a(int i, Random random) { + return random.nextInt(10) == 0 ? Item.FLINT.aS : this.bc; + } +} diff --git a/net/minecraft/server/BlockIce.java b/net/minecraft/server/BlockIce.java new file mode 100644 index 000000000..d0dd3976a --- /dev/null +++ b/net/minecraft/server/BlockIce.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockIce extends BlockBreakable { + + public BlockIce(int i, int j) { + super(i, j, Material.r, false); + this.bo = 0.98F; + this.a(true); + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return super.a(iblockaccess, i, j, k, 1 - l); + } + + public void b(World world, int i, int j, int k) { + Material material = world.c(i, j - 1, k); + + if (material.c() || material.d()) { + world.d(i, j, k, Block.WATER.bc); + } + } + + public int a(Random random) { + return 0; + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11 - Block.r[this.bc]) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, Block.STATIONARY_WATER.bc); + } + } +} diff --git a/net/minecraft/server/BlockJukeBox.java b/net/minecraft/server/BlockJukeBox.java new file mode 100644 index 000000000..7e039b691 --- /dev/null +++ b/net/minecraft/server/BlockJukeBox.java @@ -0,0 +1,47 @@ +package net.minecraft.server; + +public class BlockJukeBox extends Block { + + protected BlockJukeBox(int i, int j) { + super(i, j, Material.c); + } + + public int a(int i) { + return this.bb + (i == 1 ? 1 : 0); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + int l = world.b(i, j, k); + + if (l > 0) { + this.f(world, i, j, k, l); + return true; + } else { + return false; + } + } + + public void f(World world, int i, int j, int k, int l) { + world.a((String) null, i, j, k); + world.b(i, j, k, 0); + int i1 = Item.GOLD_RECORD.aS + l - 1; + float f = 0.7F; + double d0 = (double) (world.m.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (world.m.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; + double d2 = (double) (world.m.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1)); + + entityitem.ad = 10; + world.a((Entity) entityitem); + } + + public void a(World world, int i, int j, int k, int l, float f) { + if (!world.x) { + if (l > 0) { + this.f(world, i, j, k, l); + } + + super.a(world, i, j, k, l, f); + } + } +} diff --git a/net/minecraft/server/BlockLadder.java b/net/minecraft/server/BlockLadder.java new file mode 100644 index 000000000..fd14b38dc --- /dev/null +++ b/net/minecraft/server/BlockLadder.java @@ -0,0 +1,99 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockLadder extends Block { + + protected BlockLadder(int i, int j) { + super(i, j, Material.n); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + int l = world.b(i, j, k); + float f = 0.125F; + + if (l == 2) { + this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + + if (l == 3) { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + + if (l == 4) { + this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + if (l == 5) { + this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + + return super.d(world, i, j, k); + } + + public boolean b() { + return false; + } + + public int a() { + return 8; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i - 1, j, k) ? true : (world.d(i + 1, j, k) ? true : (world.d(i, j, k - 1) ? true : world.d(i, j, k + 1))); + } + + public void c(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 == 0 || l == 2) && world.d(i, j, k + 1)) { + i1 = 2; + } + + if ((i1 == 0 || l == 3) && world.d(i, j, k - 1)) { + i1 = 3; + } + + if ((i1 == 0 || l == 4) && world.d(i + 1, j, k)) { + i1 = 4; + } + + if ((i1 == 0 || l == 5) && world.d(i - 1, j, k)) { + i1 = 5; + } + + world.b(i, j, k, i1); + } + + public void b(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + boolean flag = false; + + if (i1 == 2 && world.d(i, j, k + 1)) { + flag = true; + } + + if (i1 == 3 && world.d(i, j, k - 1)) { + flag = true; + } + + if (i1 == 4 && world.d(i + 1, j, k)) { + flag = true; + } + + if (i1 == 5 && world.d(i - 1, j, k)) { + flag = true; + } + + if (!flag) { + this.a_(world, i, j, k, i1); + world.d(i, j, k, 0); + } + + super.b(world, i, j, k, l); + } + + public int a(Random random) { + return 1; + } +} diff --git a/net/minecraft/server/BlockLeaves.java b/net/minecraft/server/BlockLeaves.java new file mode 100644 index 000000000..045aa1d8e --- /dev/null +++ b/net/minecraft/server/BlockLeaves.java @@ -0,0 +1,116 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockLeaves extends BlockLeavesBase { + + private int b; + private int c = 0; + + protected BlockLeaves(int i, int j) { + super(i, j, Material.h, false); + this.b = j; + this.a(true); + } + + public void b(World world, int i, int j, int k, int l) { + this.c = 0; + this.g(world, i, j, k); + super.b(world, i, j, k, l); + } + + public void e(World world, int i, int j, int k, int l) { + if (world.a(i, j, k) == this.bc) { + int i1 = world.b(i, j, k); + + if (i1 != 0 && i1 == l - 1) { + this.g(world, i, j, k); + } + } + } + + public void g(World world, int i, int j, int k) { + if (this.c++ < 100) { + int l = world.c(i, j - 1, k).a() ? 16 : 0; + int i1 = world.b(i, j, k); + + if (i1 == 0) { + i1 = 1; + world.b(i, j, k, 1); + } + + l = this.f(world, i, j - 1, k, l); + l = this.f(world, i, j, k - 1, l); + l = this.f(world, i, j, k + 1, l); + l = this.f(world, i - 1, j, k, l); + l = this.f(world, i + 1, j, k, l); + int j1 = l - 1; + + if (j1 < 10) { + j1 = 1; + } + + if (j1 != i1) { + world.b(i, j, k, j1); + this.e(world, i, j - 1, k, i1); + this.e(world, i, j + 1, k, i1); + this.e(world, i, j, k - 1, i1); + this.e(world, i, j, k + 1, i1); + this.e(world, i - 1, j, k, i1); + this.e(world, i + 1, j, k, i1); + } + } + } + + private int f(World world, int i, int j, int k, int l) { + int i1 = world.a(i, j, k); + + if (i1 == Block.LOG.bc) { + return 16; + } else { + if (i1 == this.bc) { + int j1 = world.b(i, j, k); + + if (j1 != 0 && j1 > l) { + return j1; + } + } + + return l; + } + } + + public void a(World world, int i, int j, int k, Random random) { + int l = world.b(i, j, k); + + if (l == 0) { + this.c = 0; + this.g(world, i, j, k); + } else if (l == 1) { + this.h(world, i, j, k); + } else if (random.nextInt(10) == 0) { + this.g(world, i, j, k); + } + } + + private void h(World world, int i, int j, int k) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + + public int a(Random random) { + return random.nextInt(20) == 0 ? 1 : 0; + } + + public int a(int i, Random random) { + return Block.SAPLING.bc; + } + + public boolean b() { + return !this.a; + } + + public void b(World world, int i, int j, int k, Entity entity) { + super.b(world, i, j, k, entity); + } +} diff --git a/net/minecraft/server/BlockLeavesBase.java b/net/minecraft/server/BlockLeavesBase.java new file mode 100644 index 000000000..352b9c00e --- /dev/null +++ b/net/minecraft/server/BlockLeavesBase.java @@ -0,0 +1,21 @@ +package net.minecraft.server; + +public class BlockLeavesBase extends Block { + + protected boolean a; + + protected BlockLeavesBase(int i, int j, Material material, boolean flag) { + super(i, j, material); + this.a = flag; + } + + public boolean b() { + return false; + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + int i1 = iblockaccess.a(i, j, k); + + return !this.a && i1 == this.bc ? false : super.a(iblockaccess, i, j, k, l); + } +} diff --git a/net/minecraft/server/BlockLever.java b/net/minecraft/server/BlockLever.java new file mode 100644 index 000000000..348d1d94d --- /dev/null +++ b/net/minecraft/server/BlockLever.java @@ -0,0 +1,199 @@ +package net.minecraft.server; + +public class BlockLever extends Block { + + protected BlockLever(int i, int j) { + super(i, j, Material.n); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public int a() { + return 12; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i - 1, j, k) ? true : (world.d(i + 1, j, k) ? true : (world.d(i, j, k - 1) ? true : (world.d(i, j, k + 1) ? true : world.d(i, j - 1, k)))); + } + + public void c(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + int j1 = i1 & 8; + + i1 &= 7; + if (l == 1 && world.d(i, j - 1, k)) { + i1 = 5 + world.m.nextInt(2); + } + + if (l == 2 && world.d(i, j, k + 1)) { + i1 = 4; + } + + if (l == 3 && world.d(i, j, k - 1)) { + i1 = 3; + } + + if (l == 4 && world.d(i + 1, j, k)) { + i1 = 2; + } + + if (l == 5 && world.d(i - 1, j, k)) { + i1 = 1; + } + + world.b(i, j, k, i1 + j1); + } + + public void e(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + world.b(i, j, k, 1); + } else if (world.d(i + 1, j, k)) { + world.b(i, j, k, 2); + } else if (world.d(i, j, k - 1)) { + world.b(i, j, k, 3); + } else if (world.d(i, j, k + 1)) { + world.b(i, j, k, 4); + } else if (world.d(i, j - 1, k)) { + world.b(i, j, k, 5 + world.m.nextInt(2)); + } + + this.g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (this.g(world, i, j, k)) { + int i1 = world.b(i, j, k) & 7; + boolean flag = false; + + if (!world.d(i - 1, j, k) && i1 == 1) { + flag = true; + } + + if (!world.d(i + 1, j, k) && i1 == 2) { + flag = true; + } + + if (!world.d(i, j, k - 1) && i1 == 3) { + flag = true; + } + + if (!world.d(i, j, k + 1) && i1 == 4) { + flag = true; + } + + if (!world.d(i, j - 1, k) && i1 == 5) { + flag = true; + } + + if (flag) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + if (!this.a(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + return false; + } else { + return true; + } + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.b(i, j, k) & 7; + float f = 0.1875F; + + if (l == 1) { + this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } else if (l == 2) { + this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } else if (l == 3) { + this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } else if (l == 4) { + this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } else { + f = 0.25F; + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); + } + } + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) { + this.a(world, i, j, k, entityhuman); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + int l = world.b(i, j, k); + int i1 = l & 7; + int j1 = 8 - (l & 8); + + world.b(i, j, k, i1 + j1); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 > 0 ? 0.6F : 0.5F); + world.g(i, j, k, this.bc); + if (i1 == 1) { + world.g(i - 1, j, k, this.bc); + } else if (i1 == 2) { + world.g(i + 1, j, k, this.bc); + } else if (i1 == 3) { + world.g(i, j, k - 1, this.bc); + } else if (i1 == 4) { + world.g(i, j, k + 1, this.bc); + } else { + world.g(i, j - 1, k, this.bc); + } + + return true; + } + + public void b(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + if ((l & 8) > 0) { + world.g(i, j, k, this.bc); + int i1 = l & 7; + + if (i1 == 1) { + world.g(i - 1, j, k, this.bc); + } else if (i1 == 2) { + world.g(i + 1, j, k, this.bc); + } else if (i1 == 3) { + world.g(i, j, k - 1, this.bc); + } else if (i1 == 4) { + world.g(i, j, k + 1, this.bc); + } else { + world.g(i, j - 1, k, this.bc); + } + } + + super.b(world, i, j, k); + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return (iblockaccess.b(i, j, k) & 8) > 0; + } + + public boolean d(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if ((i1 & 8) == 0) { + return false; + } else { + int j1 = i1 & 7; + + return j1 == 5 && l == 1 ? true : (j1 == 4 && l == 2 ? true : (j1 == 3 && l == 3 ? true : (j1 == 2 && l == 4 ? true : j1 == 1 && l == 5))); + } + } + + public boolean d() { + return true; + } +} diff --git a/net/minecraft/server/BlockLog.java b/net/minecraft/server/BlockLog.java new file mode 100644 index 000000000..05751d315 --- /dev/null +++ b/net/minecraft/server/BlockLog.java @@ -0,0 +1,23 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockLog extends Block { + + protected BlockLog(int i) { + super(i, Material.c); + this.bb = 20; + } + + public int a(Random random) { + return 1; + } + + public int a(int i, Random random) { + return Block.LOG.bc; + } + + public int a(int i) { + return i == 1 ? 21 : (i == 0 ? 21 : 20); + } +} diff --git a/net/minecraft/server/BlockMinecartTrack.java b/net/minecraft/server/BlockMinecartTrack.java new file mode 100644 index 000000000..a8be4183e --- /dev/null +++ b/net/minecraft/server/BlockMinecartTrack.java @@ -0,0 +1,87 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockMinecartTrack extends Block { + + protected BlockMinecartTrack(int i, int j) { + super(i, j, Material.n); + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { + this.a((IBlockAccess) world, i, j, k); + return super.a(world, i, j, k, vec3d, vec3d1); + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.b(i, j, k); + + if (l >= 2 && l <= 5) { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F); + } else { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + } + } + + public int a() { + return 9; + } + + public int a(Random random) { + return 1; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i, j - 1, k); + } + + public void e(World world, int i, int j, int k) { + world.b(i, j, k, 15); + this.g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + boolean flag = false; + + if (!world.d(i, j - 1, k)) { + flag = true; + } + + if (i1 == 2 && !world.d(i + 1, j, k)) { + flag = true; + } + + if (i1 == 3 && !world.d(i - 1, j, k)) { + flag = true; + } + + if (i1 == 4 && !world.d(i, j, k - 1)) { + flag = true; + } + + if (i1 == 5 && !world.d(i, j, k + 1)) { + flag = true; + } + + if (flag) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } else if (l > 0 && Block.n[l].d() && MinecartTrackLogic.a(new MinecartTrackLogic(this, world, i, j, k)) == 3) { + this.g(world, i, j, k); + } + } + + private void g(World world, int i, int j, int k) { + (new MinecartTrackLogic(this, world, i, j, k)).a(world.n(i, j, k)); + } +} diff --git a/net/minecraft/server/BlockMobSpawner.java b/net/minecraft/server/BlockMobSpawner.java new file mode 100644 index 000000000..434e1c56c --- /dev/null +++ b/net/minecraft/server/BlockMobSpawner.java @@ -0,0 +1,26 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockMobSpawner extends BlockContainer { + + protected BlockMobSpawner(int i, int j) { + super(i, j, Material.d); + } + + protected TileEntity a_() { + return new TileEntityMobSpawner(); + } + + public int a(int i, Random random) { + return 0; + } + + public int a(Random random) { + return 0; + } + + public boolean b() { + return false; + } +} diff --git a/net/minecraft/server/BlockMushroom.java b/net/minecraft/server/BlockMushroom.java new file mode 100644 index 000000000..647e97a6a --- /dev/null +++ b/net/minecraft/server/BlockMushroom.java @@ -0,0 +1,19 @@ +package net.minecraft.server; + +public class BlockMushroom extends BlockFlower { + + protected BlockMushroom(int i, int j) { + super(i, j); + float f = 0.2F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); + } + + protected boolean b(int i) { + return Block.p[i]; + } + + public boolean f(World world, int i, int j, int k) { + return world.h(i, j, k) <= 13 && this.b(world.a(i, j - 1, k)); + } +} diff --git a/net/minecraft/server/BlockObsidian.java b/net/minecraft/server/BlockObsidian.java new file mode 100644 index 000000000..84c268838 --- /dev/null +++ b/net/minecraft/server/BlockObsidian.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockObsidian extends BlockStone { + + public BlockObsidian(int i, int j) { + super(i, j); + } + + public int a(Random random) { + return 1; + } + + public int a(int i, Random random) { + return Block.OBSIDIAN.bc; + } +} diff --git a/net/minecraft/server/BlockOre.java b/net/minecraft/server/BlockOre.java new file mode 100644 index 000000000..a3687cf91 --- /dev/null +++ b/net/minecraft/server/BlockOre.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockOre extends Block { + + public BlockOre(int i, int j) { + super(i, j, Material.d); + } + + public int a(int i, Random random) { + return this.bc == Block.COAL_ORE.bc ? Item.COAL.aS : (this.bc == Block.DIAMOND_ORE.bc ? Item.DIAMOND.aS : this.bc); + } + + public int a(Random random) { + return 1; + } +} diff --git a/net/minecraft/server/BlockOreBlock.java b/net/minecraft/server/BlockOreBlock.java new file mode 100644 index 000000000..fbfa5f938 --- /dev/null +++ b/net/minecraft/server/BlockOreBlock.java @@ -0,0 +1,13 @@ +package net.minecraft.server; + +public class BlockOreBlock extends Block { + + public BlockOreBlock(int i, int j) { + super(i, Material.e); + this.bb = j; + } + + public int a(int i) { + return i == 1 ? this.bb - 16 : (i == 0 ? this.bb + 16 : this.bb); + } +} diff --git a/net/minecraft/server/BlockPressurePlate.java b/net/minecraft/server/BlockPressurePlate.java new file mode 100644 index 000000000..a3fa98f90 --- /dev/null +++ b/net/minecraft/server/BlockPressurePlate.java @@ -0,0 +1,138 @@ +package net.minecraft.server; + +import java.util.List; +import java.util.Random; + +public class BlockPressurePlate extends Block { + + private EnumMobType a; + + protected BlockPressurePlate(int i, int j, EnumMobType enummobtype) { + super(i, j, Material.d); + this.a = enummobtype; + this.a(true); + float f = 0.0625F; + + this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); + } + + public int c() { + return 20; + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i, j - 1, k); + } + + public void e(World world, int i, int j, int k) {} + + public void b(World world, int i, int j, int k, int l) { + boolean flag = false; + + if (!world.d(i, j - 1, k)) { + flag = true; + } + + if (flag) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.b(i, j, k) != 0) { + this.g(world, i, j, k); + } + } + + public void a(World world, int i, int j, int k, Entity entity) { + if (world.b(i, j, k) != 1) { + this.g(world, i, j, k); + } + } + + private void g(World world, int i, int j, int k) { + boolean flag = world.b(i, j, k) == 1; + boolean flag1 = false; + float f = 0.125F; + List list = null; + + if (this.a == EnumMobType.EVERYTHING) { + list = world.b((Entity) null, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f))); + } + + if (this.a == EnumMobType.MOBS) { + list = world.a(EntityLiving.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f))); + } + + if (this.a == EnumMobType.PLAYERS) { + list = world.a(EntityHuman.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f))); + } + + if (list.size() > 0) { + flag1 = true; + } + + if (flag1 && !flag) { + world.b(i, j, k, 1); + world.g(i, j, k, this.bc); + world.g(i, j - 1, k, this.bc); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); + } + + if (!flag1 && flag) { + world.b(i, j, k, 0); + world.g(i, j, k, this.bc); + world.g(i, j - 1, k, this.bc); + world.b(i, j, k, i, j, k); + world.a((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); + } + + if (flag1) { + world.h(i, j, k, this.bc); + } + } + + public void b(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + if (l > 0) { + world.g(i, j, k, this.bc); + world.g(i, j - 1, k, this.bc); + } + + super.b(world, i, j, k); + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + boolean flag = iblockaccess.b(i, j, k) == 1; + float f = 0.0625F; + + if (flag) { + this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); + } else { + this.a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f); + } + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return iblockaccess.b(i, j, k) > 0; + } + + public boolean d(World world, int i, int j, int k, int l) { + return world.b(i, j, k) == 0 ? false : l == 1; + } + + public boolean d() { + return true; + } +} diff --git a/net/minecraft/server/BlockRedstoneOre.java b/net/minecraft/server/BlockRedstoneOre.java new file mode 100644 index 000000000..00fe9e539 --- /dev/null +++ b/net/minecraft/server/BlockRedstoneOre.java @@ -0,0 +1,96 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockRedstoneOre extends Block { + + private boolean a; + + public BlockRedstoneOre(int i, int j, boolean flag) { + super(i, j, Material.d); + if (flag) { + this.a(true); + } + + this.a = flag; + } + + public int c() { + return 30; + } + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) { + this.g(world, i, j, k); + super.b(world, i, j, k, entityhuman); + } + + public void b(World world, int i, int j, int k, Entity entity) { + this.g(world, i, j, k); + super.b(world, i, j, k, entity); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + this.g(world, i, j, k); + return super.a(world, i, j, k, entityhuman); + } + + private void g(World world, int i, int j, int k) { + this.h(world, i, j, k); + if (this.bc == Block.REDSTONE_ORE.bc) { + world.d(i, j, k, Block.GLOWING_REDSTONE_ORE.bc); + } + } + + public void a(World world, int i, int j, int k, Random random) { + if (this.bc == Block.GLOWING_REDSTONE_ORE.bc) { + world.d(i, j, k, Block.REDSTONE_ORE.bc); + } + } + + public int a(int i, Random random) { + return Item.REDSTONE.aS; + } + + public int a(Random random) { + return 4 + random.nextInt(2); + } + + private void h(World world, int i, int j, int k) { + Random random = world.m; + double d0 = 0.0625D; + + for (int l = 0; l < 6; ++l) { + double d1 = (double) ((float) i + random.nextFloat()); + double d2 = (double) ((float) j + random.nextFloat()); + double d3 = (double) ((float) k + random.nextFloat()); + + if (l == 0 && !world.d(i, j + 1, k)) { + d2 = (double) (j + 1) + d0; + } + + if (l == 1 && !world.d(i, j - 1, k)) { + d2 = (double) (j + 0) - d0; + } + + if (l == 2 && !world.d(i, j, k + 1)) { + d3 = (double) (k + 1) + d0; + } + + if (l == 3 && !world.d(i, j, k - 1)) { + d3 = (double) (k + 0) - d0; + } + + if (l == 4 && !world.d(i + 1, j, k)) { + d1 = (double) (i + 1) + d0; + } + + if (l == 5 && !world.d(i - 1, j, k)) { + d1 = (double) (i + 0) - d0; + } + + if (d1 < (double) i || d1 > (double) (i + 1) || d2 < 0.0D || d2 > (double) (j + 1) || d3 < (double) k || d3 > (double) (k + 1)) { + world.a("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); + } + } + } +} diff --git a/net/minecraft/server/BlockRedstoneTorch.java b/net/minecraft/server/BlockRedstoneTorch.java new file mode 100644 index 000000000..9270e4767 --- /dev/null +++ b/net/minecraft/server/BlockRedstoneTorch.java @@ -0,0 +1,128 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class BlockRedstoneTorch extends BlockTorch { + + private boolean a = false; + private static List b = new ArrayList(); + + private boolean a(World world, int i, int j, int k, boolean flag) { + if (flag) { + b.add(new RedstoneUpdateInfo(i, j, k, world.c)); + } + + int l = 0; + + for (int i1 = 0; i1 < b.size(); ++i1) { + RedstoneUpdateInfo redstoneupdateinfo = (RedstoneUpdateInfo) b.get(i1); + + if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k) { + ++l; + if (l >= 8) { + return true; + } + } + } + + return false; + } + + protected BlockRedstoneTorch(int i, int j, boolean flag) { + super(i, j); + this.a = flag; + this.a(true); + } + + public int c() { + return 2; + } + + public void e(World world, int i, int j, int k) { + if (world.b(i, j, k) == 0) { + super.e(world, i, j, k); + } + + if (this.a) { + world.g(i, j - 1, k, this.bc); + world.g(i, j + 1, k, this.bc); + world.g(i - 1, j, k, this.bc); + world.g(i + 1, j, k, this.bc); + world.g(i, j, k - 1, this.bc); + world.g(i, j, k + 1, this.bc); + } + } + + public void b(World world, int i, int j, int k) { + if (this.a) { + world.g(i, j - 1, k, this.bc); + world.g(i, j + 1, k, this.bc); + world.g(i - 1, j, k, this.bc); + world.g(i + 1, j, k, this.bc); + world.g(i, j, k - 1, this.bc); + world.g(i, j, k + 1, this.bc); + } + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + if (!this.a) { + return false; + } else { + int i1 = iblockaccess.b(i, j, k); + + return i1 == 5 && l == 1 ? false : (i1 == 3 && l == 3 ? false : (i1 == 4 && l == 2 ? false : (i1 == 1 && l == 5 ? false : i1 != 2 || l != 4))); + } + } + + private boolean g(World world, int i, int j, int k) { + int l = world.b(i, j, k); + + return l == 5 && world.j(i, j - 1, k, 0) ? true : (l == 3 && world.j(i, j, k - 1, 2) ? true : (l == 4 && world.j(i, j, k + 1, 3) ? true : (l == 1 && world.j(i - 1, j, k, 4) ? true : l == 2 && world.j(i + 1, j, k, 5)))); + } + + public void a(World world, int i, int j, int k, Random random) { + boolean flag = this.g(world, i, j, k); + + while (b.size() > 0 && world.c - ((RedstoneUpdateInfo) b.get(0)).d > 100L) { + b.remove(0); + } + + if (this.a) { + if (flag) { + world.b(i, j, k, Block.REDSTONE_TORCH_OFF.bc, world.b(i, j, k)); + if (this.a(world, i, j, k, true)) { + world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.m.nextFloat() - world.m.nextFloat()) * 0.8F); + + for (int l = 0; l < 5; ++l) { + double d0 = (double) i + random.nextDouble() * 0.6D + 0.2D; + double d1 = (double) j + random.nextDouble() * 0.6D + 0.2D; + double d2 = (double) k + random.nextDouble() * 0.6D + 0.2D; + + world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } + } else if (!flag && !this.a(world, i, j, k, false)) { + world.b(i, j, k, Block.REDSTONE_TORCH_ON.bc, world.b(i, j, k)); + } + } + + public void b(World world, int i, int j, int k, int l) { + super.b(world, i, j, k, l); + world.h(i, j, k, this.bc); + } + + public boolean d(World world, int i, int j, int k, int l) { + return l == 0 ? this.b((IBlockAccess) world, i, j, k, l) : false; + } + + public int a(int i, Random random) { + return Block.REDSTONE_TORCH_ON.bc; + } + + public boolean d() { + return true; + } +} diff --git a/net/minecraft/server/BlockRedstoneWire.java b/net/minecraft/server/BlockRedstoneWire.java new file mode 100644 index 000000000..dd55e7fff --- /dev/null +++ b/net/minecraft/server/BlockRedstoneWire.java @@ -0,0 +1,291 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockRedstoneWire extends Block { + + private boolean a = true; + + public BlockRedstoneWire(int i, int j) { + super(i, j, Material.n); + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public int a() { + return 5; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i, j - 1, k); + } + + private void g(World world, int i, int j, int k) { + int l = world.b(i, j, k); + int i1 = 0; + + this.a = false; + boolean flag = world.n(i, j, k); + + this.a = true; + int j1; + int k1; + int l1; + + if (flag) { + i1 = 15; + } else { + for (j1 = 0; j1 < 4; ++j1) { + k1 = i; + l1 = k; + if (j1 == 0) { + k1 = i - 1; + } + + if (j1 == 1) { + ++k1; + } + + if (j1 == 2) { + l1 = k - 1; + } + + if (j1 == 3) { + ++l1; + } + + i1 = this.f(world, k1, j, l1, i1); + if (world.d(k1, j, l1) && !world.d(i, j + 1, k)) { + i1 = this.f(world, k1, j + 1, l1, i1); + } else if (!world.d(k1, j, l1)) { + i1 = this.f(world, k1, j - 1, l1, i1); + } + } + + if (i1 > 0) { + --i1; + } else { + i1 = 0; + } + } + + if (l != i1) { + world.b(i, j, k, i1); + world.b(i, j, k, i, j, k); + if (i1 > 0) { + --i1; + } + + for (j1 = 0; j1 < 4; ++j1) { + k1 = i; + l1 = k; + int i2 = j - 1; + + if (j1 == 0) { + k1 = i - 1; + } + + if (j1 == 1) { + ++k1; + } + + if (j1 == 2) { + l1 = k - 1; + } + + if (j1 == 3) { + ++l1; + } + + if (world.d(k1, j, l1)) { + i2 += 2; + } + + int j2 = this.f(world, k1, j, l1, -1); + + if (j2 >= 0 && j2 != i1) { + this.g(world, k1, j, l1); + } + + j2 = this.f(world, k1, i2, l1, -1); + if (j2 >= 0 && j2 != i1) { + this.g(world, k1, i2, l1); + } + } + + if (l == 0 || i1 == 0) { + world.g(i, j, k, this.bc); + world.g(i - 1, j, k, this.bc); + world.g(i + 1, j, k, this.bc); + world.g(i, j, k - 1, this.bc); + world.g(i, j, k + 1, this.bc); + world.g(i, j - 1, k, this.bc); + world.g(i, j + 1, k, this.bc); + } + } + } + + private void h(World world, int i, int j, int k) { + if (world.a(i, j, k) == this.bc) { + world.g(i, j, k, this.bc); + world.g(i - 1, j, k, this.bc); + world.g(i + 1, j, k, this.bc); + world.g(i, j, k - 1, this.bc); + world.g(i, j, k + 1, this.bc); + world.g(i, j - 1, k, this.bc); + world.g(i, j + 1, k, this.bc); + } + } + + public void e(World world, int i, int j, int k) { + super.e(world, i, j, k); + this.g(world, i, j, k); + world.g(i, j + 1, k, this.bc); + world.g(i, j - 1, k, this.bc); + this.h(world, i - 1, j, k); + this.h(world, i + 1, j, k); + this.h(world, i, j, k - 1); + this.h(world, i, j, k + 1); + if (world.d(i - 1, j, k)) { + this.h(world, i - 1, j + 1, k); + } else { + this.h(world, i - 1, j - 1, k); + } + + if (world.d(i + 1, j, k)) { + this.h(world, i + 1, j + 1, k); + } else { + this.h(world, i + 1, j - 1, k); + } + + if (world.d(i, j, k - 1)) { + this.h(world, i, j + 1, k - 1); + } else { + this.h(world, i, j - 1, k - 1); + } + + if (world.d(i, j, k + 1)) { + this.h(world, i, j + 1, k + 1); + } else { + this.h(world, i, j - 1, k + 1); + } + } + + public void b(World world, int i, int j, int k) { + super.b(world, i, j, k); + world.g(i, j + 1, k, this.bc); + world.g(i, j - 1, k, this.bc); + this.g(world, i, j, k); + this.h(world, i - 1, j, k); + this.h(world, i + 1, j, k); + this.h(world, i, j, k - 1); + this.h(world, i, j, k + 1); + if (world.d(i - 1, j, k)) { + this.h(world, i - 1, j + 1, k); + } else { + this.h(world, i - 1, j - 1, k); + } + + if (world.d(i + 1, j, k)) { + this.h(world, i + 1, j + 1, k); + } else { + this.h(world, i + 1, j - 1, k); + } + + if (world.d(i, j, k - 1)) { + this.h(world, i, j + 1, k - 1); + } else { + this.h(world, i, j - 1, k - 1); + } + + if (world.d(i, j, k + 1)) { + this.h(world, i, j + 1, k + 1); + } else { + this.h(world, i, j - 1, k + 1); + } + } + + private int f(World world, int i, int j, int k, int l) { + if (world.a(i, j, k) != this.bc) { + return l; + } else { + int i1 = world.b(i, j, k); + + return i1 > l ? i1 : l; + } + } + + public void b(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + boolean flag = this.a(world, i, j, k); + + if (!flag) { + this.a_(world, i, j, k, i1); + world.d(i, j, k, 0); + } else { + this.g(world, i, j, k); + } + + super.b(world, i, j, k, l); + } + + public int a(int i, Random random) { + return Item.REDSTONE.aS; + } + + public boolean d(World world, int i, int j, int k, int l) { + return !this.a ? false : this.b((IBlockAccess) world, i, j, k, l); + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { + if (!this.a) { + return false; + } else if (iblockaccess.b(i, j, k) == 0) { + return false; + } else if (l == 1) { + return true; + } else { + boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k); + boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k); + boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1); + boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1); + + if (!iblockaccess.d(i, j + 1, k)) { + if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) { + flag = true; + } + + if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) { + flag1 = true; + } + + if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) { + flag2 = true; + } + + if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) { + flag3 = true; + } + } + + return !flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5 ? true : (l == 2 && flag2 && !flag && !flag1 ? true : (l == 3 && flag3 && !flag && !flag1 ? true : (l == 4 && flag && !flag2 && !flag3 ? true : l == 5 && flag1 && !flag2 && !flag3))); + } + } + + public boolean d() { + return this.a; + } + + public static boolean b(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.a(i, j, k); + + return l == Block.REDSTONE_WIRE.bc ? true : (l == 0 ? false : Block.n[l].d()); + } +} diff --git a/net/minecraft/server/BlockReed.java b/net/minecraft/server/BlockReed.java new file mode 100644 index 000000000..6bbf504ad --- /dev/null +++ b/net/minecraft/server/BlockReed.java @@ -0,0 +1,73 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockReed extends Block { + + protected BlockReed(int i, int j) { + super(i, Material.i); + this.bb = j; + float f = 0.375F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); + this.a(true); + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.a(i, j + 1, k) == 0) { + int l; + + for (l = 1; world.a(i, j - l, k) == this.bc; ++l) { + ; + } + + if (l < 3) { + int i1 = world.b(i, j, k); + + if (i1 == 15) { + world.d(i, j + 1, k, this.bc); + world.b(i, j, k, 0); + } else { + world.b(i, j, k, i1 + 1); + } + } + } + } + + public boolean a(World world, int i, int j, int k) { + int l = world.a(i, j - 1, k); + + return l == this.bc ? true : (l != Block.GRASS.bc && l != Block.DIRT.bc ? false : (world.c(i - 1, j - 1, k) == Material.f ? true : (world.c(i + 1, j - 1, k) == Material.f ? true : (world.c(i, j - 1, k - 1) == Material.f ? true : world.c(i, j - 1, k + 1) == Material.f)))); + } + + public void b(World world, int i, int j, int k, int l) { + this.g(world, i, j, k); + } + + protected final void g(World world, int i, int j, int k) { + if (!this.f(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + + public boolean f(World world, int i, int j, int k) { + return this.a(world, i, j, k); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public int a(int i, Random random) { + return Item.SUGAR_CANE.aS; + } + + public boolean b() { + return false; + } + + public int a() { + return 1; + } +} diff --git a/net/minecraft/server/BlockSand.java b/net/minecraft/server/BlockSand.java new file mode 100644 index 000000000..eb515f985 --- /dev/null +++ b/net/minecraft/server/BlockSand.java @@ -0,0 +1,56 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockSand extends Block { + + public static boolean a = false; + + public BlockSand(int i, int j) { + super(i, j, Material.m); + } + + public void e(World world, int i, int j, int k) { + world.h(i, j, k, this.bc); + } + + public void b(World world, int i, int j, int k, int l) { + world.h(i, j, k, this.bc); + } + + public void a(World world, int i, int j, int k, Random random) { + this.h(world, i, j, k); + } + + private void h(World world, int i, int j, int k) { + if (g(world, i, j - 1, k) && j >= 0) { + EntityFallingSand entityfallingsand = new EntityFallingSand(world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, this.bc); + + if (a) { + while (!entityfallingsand.B) { + entityfallingsand.b_(); + } + } else { + world.a((Entity) entityfallingsand); + } + } + } + + public int c() { + return 3; + } + + public static boolean g(World world, int i, int j, int k) { + int l = world.a(i, j, k); + + if (l == 0) { + return true; + } else if (l == Block.FIRE.bc) { + return true; + } else { + Material material = Block.n[l].bn; + + return material == Material.f ? true : material == Material.g; + } + } +} diff --git a/net/minecraft/server/BlockSapling.java b/net/minecraft/server/BlockSapling.java new file mode 100644 index 000000000..ad8452dfb --- /dev/null +++ b/net/minecraft/server/BlockSapling.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockSapling extends BlockFlower { + + protected BlockSapling(int i, int j) { + super(i, j); + float f = 0.4F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); + } + + public void a(World world, int i, int j, int k, Random random) { + super.a(world, i, j, k, random); + if (world.h(i, j + 1, k) >= 9 && random.nextInt(5) == 0) { + int l = world.b(i, j, k); + + if (l < 15) { + world.b(i, j, k, l + 1); + } else { + world.a(i, j, k, 0); + Object object = new WorldGenTrees(); + + if (random.nextInt(10) == 0) { + object = new WorldGenBigTree(); + } + + if (!((WorldGenerator) object).a(world, random, i, j, k)) { + world.a(i, j, k, this.bc); + } + } + } + } +} diff --git a/net/minecraft/server/BlockSign.java b/net/minecraft/server/BlockSign.java new file mode 100644 index 000000000..698ca355f --- /dev/null +++ b/net/minecraft/server/BlockSign.java @@ -0,0 +1,108 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockSign extends BlockContainer { + + private Class a; + private boolean b; + + protected BlockSign(int i, Class oclass, boolean flag) { + super(i, Material.c); + this.b = flag; + this.bb = 4; + this.a = oclass; + float f = 0.25F; + float f1 = 1.0F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public void a(IBlockAccess iblockaccess, int i, int j, int k) { + if (!this.b) { + int l = iblockaccess.b(i, j, k); + float f = 0.28125F; + float f1 = 0.78125F; + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.125F; + + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + if (l == 2) { + this.a(f2, f, 1.0F - f4, f3, f1, 1.0F); + } + + if (l == 3) { + this.a(f2, f, 0.0F, f3, f1, f4); + } + + if (l == 4) { + this.a(1.0F - f4, f, f2, 1.0F, f1, f3); + } + + if (l == 5) { + this.a(0.0F, f, f2, f4, f1, f3); + } + } + } + + public int a() { + return -1; + } + + public boolean b() { + return false; + } + + protected TileEntity a_() { + try { + return (TileEntity) this.a.newInstance(); + } catch (Exception exception) { + throw new RuntimeException(exception); + } + } + + public int a(int i, Random random) { + return Item.SIGN.aS; + } + + public void b(World world, int i, int j, int k, int l) { + boolean flag = false; + + if (this.b) { + if (!world.c(i, j - 1, k).a()) { + flag = true; + } + } else { + int i1 = world.b(i, j, k); + + flag = true; + if (i1 == 2 && world.c(i, j, k + 1).a()) { + flag = false; + } + + if (i1 == 3 && world.c(i, j, k - 1).a()) { + flag = false; + } + + if (i1 == 4 && world.c(i + 1, j, k).a()) { + flag = false; + } + + if (i1 == 5 && world.c(i - 1, j, k).a()) { + flag = false; + } + } + + if (flag) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + + super.b(world, i, j, k, l); + } +} diff --git a/net/minecraft/server/BlockSnow.java b/net/minecraft/server/BlockSnow.java new file mode 100644 index 000000000..19f88297b --- /dev/null +++ b/net/minecraft/server/BlockSnow.java @@ -0,0 +1,61 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockSnow extends Block { + + protected BlockSnow(int i, int j) { + super(i, j, Material.s); + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + this.a(true); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public boolean a(World world, int i, int j, int k) { + int l = world.a(i, j - 1, k); + + return l != 0 && Block.n[l].b() ? world.c(i, j - 1, k).c() : false; + } + + public void b(World world, int i, int j, int k, int l) { + this.g(world, i, j, k); + } + + private boolean g(World world, int i, int j, int k) { + if (!this.a(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + return false; + } else { + return true; + } + } + + public int a(int i, Random random) { + return Item.SNOW_BALL.aS; + } + + public int a(Random random) { + return 0; + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + Material material = iblockaccess.c(i, j, k); + + return l == 1 ? true : (material == this.bn ? false : super.a(iblockaccess, i, j, k, l)); + } +} diff --git a/net/minecraft/server/BlockSnowBlock.java b/net/minecraft/server/BlockSnowBlock.java new file mode 100644 index 000000000..b239c5a57 --- /dev/null +++ b/net/minecraft/server/BlockSnowBlock.java @@ -0,0 +1,26 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockSnowBlock extends Block { + + protected BlockSnowBlock(int i, int j) { + super(i, j, Material.t); + this.a(true); + } + + public int a(int i, Random random) { + return Item.SNOW_BALL.aS; + } + + public int a(Random random) { + return 4; + } + + public void a(World world, int i, int j, int k, Random random) { + if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } +} diff --git a/net/minecraft/server/BlockSoil.java b/net/minecraft/server/BlockSoil.java new file mode 100644 index 000000000..50462029f --- /dev/null +++ b/net/minecraft/server/BlockSoil.java @@ -0,0 +1,85 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockSoil extends Block { + + protected BlockSoil(int i) { + super(i, Material.b); + this.bb = 87; + this.a(true); + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F); + this.c(255); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return AxisAlignedBB.b((double) (i + 0), (double) (j + 0), (double) (k + 0), (double) (i + 1), (double) (j + 1), (double) (k + 1)); + } + + public boolean b() { + return false; + } + + public void a(World world, int i, int j, int k, Random random) { + if (random.nextInt(5) == 0) { + if (this.h(world, i, j, k)) { + world.b(i, j, k, 7); + } else { + int l = world.b(i, j, k); + + if (l > 0) { + world.b(i, j, k, l - 1); + } else if (!this.g(world, i, j, k)) { + world.d(i, j, k, Block.DIRT.bc); + } + } + } + } + + public void b(World world, int i, int j, int k, Entity entity) { + if (world.m.nextInt(4) == 0) { + world.d(i, j, k, Block.DIRT.bc); + } + } + + private boolean g(World world, int i, int j, int k) { + byte b0 = 0; + + for (int l = i - b0; l <= i + b0; ++l) { + for (int i1 = k - b0; i1 <= k + b0; ++i1) { + if (world.a(l, j + 1, i1) == Block.CROPS.bc) { + return true; + } + } + } + + return false; + } + + private boolean h(World world, int i, int j, int k) { + for (int l = i - 4; l <= i + 4; ++l) { + for (int i1 = j; i1 <= j + 1; ++i1) { + for (int j1 = k - 4; j1 <= k + 4; ++j1) { + if (world.c(l, i1, j1) == Material.f) { + return true; + } + } + } + } + + return false; + } + + public void b(World world, int i, int j, int k, int l) { + super.b(world, i, j, k, l); + Material material = world.c(i, j + 1, k); + + if (material.a()) { + world.d(i, j, k, Block.DIRT.bc); + } + } + + public int a(int i, Random random) { + return Block.DIRT.a(0, random); + } +} diff --git a/net/minecraft/server/BlockSponge.java b/net/minecraft/server/BlockSponge.java new file mode 100644 index 000000000..bb21cd76d --- /dev/null +++ b/net/minecraft/server/BlockSponge.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +public class BlockSponge extends Block { + + protected BlockSponge(int i) { + super(i, Material.j); + this.bb = 48; + } + + public void e(World world, int i, int j, int k) { + byte b0 = 2; + + for (int l = i - b0; l <= i + b0; ++l) { + for (int i1 = j - b0; i1 <= j + b0; ++i1) { + for (int j1 = k - b0; j1 <= k + b0; ++j1) { + if (world.c(l, i1, j1) == Material.f) { + ; + } + } + } + } + } + + public void b(World world, int i, int j, int k) { + byte b0 = 2; + + for (int l = i - b0; l <= i + b0; ++l) { + for (int i1 = j - b0; i1 <= j + b0; ++i1) { + for (int j1 = k - b0; j1 <= k + b0; ++j1) { + world.g(l, i1, j1, world.a(l, i1, j1)); + } + } + } + } +} diff --git a/net/minecraft/server/BlockStairs.java b/net/minecraft/server/BlockStairs.java new file mode 100644 index 000000000..1c11fc71b --- /dev/null +++ b/net/minecraft/server/BlockStairs.java @@ -0,0 +1,226 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.Random; + +public class BlockStairs extends Block { + + private Block a; + + protected BlockStairs(int i, Block block) { + super(i, block.bb, block.bn); + this.a = block; + this.c(block.bd); + this.b(block.be / 3.0F); + this.a(block.bl); + } + + public boolean b() { + return false; + } + + public int a() { + return 10; + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return super.a(iblockaccess, i, j, k, l); + } + + public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) { + int l = world.b(i, j, k); + + if (l == 0) { + this.a(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 1.0F); + super.a(world, i, j, k, axisalignedbb, arraylist); + this.a(0.5F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.a(world, i, j, k, axisalignedbb, arraylist); + } else if (l == 1) { + this.a(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, 1.0F); + super.a(world, i, j, k, axisalignedbb, arraylist); + this.a(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + super.a(world, i, j, k, axisalignedbb, arraylist); + } else if (l == 2) { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F); + super.a(world, i, j, k, axisalignedbb, arraylist); + this.a(0.0F, 0.0F, 0.5F, 1.0F, 1.0F, 1.0F); + super.a(world, i, j, k, axisalignedbb, arraylist); + } else if (l == 3) { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F); + super.a(world, i, j, k, axisalignedbb, arraylist); + this.a(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F); + super.a(world, i, j, k, axisalignedbb, arraylist); + } + + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void b(World world, int i, int j, int k, int l) { + if (!world.x) { + if (world.c(i, j + 1, k).a()) { + world.d(i, j, k, this.a.bc); + } else { + this.g(world, i, j, k); + this.g(world, i + 1, j - 1, k); + this.g(world, i - 1, j - 1, k); + this.g(world, i, j - 1, k - 1); + this.g(world, i, j - 1, k + 1); + this.g(world, i + 1, j + 1, k); + this.g(world, i - 1, j + 1, k); + this.g(world, i, j + 1, k - 1); + this.g(world, i, j + 1, k + 1); + } + + this.a.b(world, i, j, k, l); + } + } + + private void g(World world, int i, int j, int k) { + if (this.i(world, i, j, k)) { + byte b0 = -1; + + if (this.i(world, i + 1, j + 1, k)) { + b0 = 0; + } + + if (this.i(world, i - 1, j + 1, k)) { + b0 = 1; + } + + if (this.i(world, i, j + 1, k + 1)) { + b0 = 2; + } + + if (this.i(world, i, j + 1, k - 1)) { + b0 = 3; + } + + if (b0 < 0) { + if (this.h(world, i + 1, j, k) && !this.h(world, i - 1, j, k)) { + b0 = 0; + } + + if (this.h(world, i - 1, j, k) && !this.h(world, i + 1, j, k)) { + b0 = 1; + } + + if (this.h(world, i, j, k + 1) && !this.h(world, i, j, k - 1)) { + b0 = 2; + } + + if (this.h(world, i, j, k - 1) && !this.h(world, i, j, k + 1)) { + b0 = 3; + } + } + + if (b0 < 0) { + if (this.i(world, i - 1, j - 1, k)) { + b0 = 0; + } + + if (this.i(world, i + 1, j - 1, k)) { + b0 = 1; + } + + if (this.i(world, i, j - 1, k - 1)) { + b0 = 2; + } + + if (this.i(world, i, j - 1, k + 1)) { + b0 = 3; + } + } + + if (b0 >= 0) { + world.b(i, j, k, b0); + } + } + } + + private boolean h(World world, int i, int j, int k) { + return world.c(i, j, k).a(); + } + + private boolean i(World world, int i, int j, int k) { + int l = world.a(i, j, k); + + return l == 0 ? false : Block.n[l].a() == 10; + } + + public void b(World world, int i, int j, int k, EntityHuman entityhuman) { + this.a.b(world, i, j, k, entityhuman); + } + + public void a(World world, int i, int j, int k, int l) { + this.a.a(world, i, j, k, l); + } + + public float a(Entity entity) { + return this.a.a(entity); + } + + public int a(int i, Random random) { + return this.a.a(i, random); + } + + public int a(Random random) { + return this.a.a(random); + } + + public int a(int i) { + return this.a.a(i); + } + + public int c() { + return this.a.c(); + } + + public void a(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { + this.a.a(world, i, j, k, entity, vec3d); + } + + public boolean e() { + return this.a.e(); + } + + public boolean a(int i, boolean flag) { + return this.a.a(i, flag); + } + + public boolean a(World world, int i, int j, int k) { + return this.a.a(world, i, j, k); + } + + public void e(World world, int i, int j, int k) { + this.b(world, i, j, k, 0); + this.a.e(world, i, j, k); + } + + public void b(World world, int i, int j, int k) { + this.a.b(world, i, j, k); + } + + public void a(World world, int i, int j, int k, int l, float f) { + this.a.a(world, i, j, k, l, f); + } + + public void a_(World world, int i, int j, int k, int l) { + this.a.a_(world, i, j, k, l); + } + + public void b(World world, int i, int j, int k, Entity entity) { + this.a.b(world, i, j, k, entity); + } + + public void a(World world, int i, int j, int k, Random random) { + this.a.a(world, i, j, k, random); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + return this.a.a(world, i, j, k, entityhuman); + } + + public void c(World world, int i, int j, int k) { + this.a.c(world, i, j, k); + } +} diff --git a/net/minecraft/server/BlockStationary.java b/net/minecraft/server/BlockStationary.java new file mode 100644 index 000000000..967ba9769 --- /dev/null +++ b/net/minecraft/server/BlockStationary.java @@ -0,0 +1,56 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockStationary extends BlockFluids { + + protected BlockStationary(int i, Material material) { + super(i, material); + this.a(false); + if (material == Material.g) { + this.a(true); + } + } + + public void b(World world, int i, int j, int k, int l) { + super.b(world, i, j, k, l); + if (world.a(i, j, k) == this.bc) { + this.i(world, i, j, k); + } + } + + private void i(World world, int i, int j, int k) { + int i = world.b(i, j, k); + + world.h = true; + world.a(i, j, k, this.bc - 1, i); + world.b(i, j, k, i, j, k); + world.h(i, j, k, this.bc - 1); + world.h = false; + } + + public void a(World world, int i, int j, int k, Random random) { + if (this.bn == Material.g) { + int i = random.nextInt(3); + + for (int j = 0; j < i; ++j) { + i += random.nextInt(3) - 1; + ++j; + k += random.nextInt(3) - 1; + int k = world.a(i, j, k); + + if (k == 0) { + if (this.j(world, i - 1, j, k) || this.j(world, i + 1, j, k) || this.j(world, i, j, k - 1) || this.j(world, i, j, k + 1) || this.j(world, i, j - 1, k) || this.j(world, i, j + 1, k)) { + return; + } + } else if (Block.n[k].bn.c()) { + return; + } + } + } + } + + private boolean j(World world, int i, int j, int k) { + return world.c(i, j, k).e(); + } +} diff --git a/net/minecraft/server/BlockStep.java b/net/minecraft/server/BlockStep.java new file mode 100644 index 000000000..55d8a455c --- /dev/null +++ b/net/minecraft/server/BlockStep.java @@ -0,0 +1,57 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockStep extends Block { + + private boolean a; + + public BlockStep(int i, boolean flag) { + super(i, 6, Material.d); + this.a = flag; + if (!flag) { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + this.c(255); + } + + public int a(int i) { + return i <= 1 ? 6 : 5; + } + + public boolean b() { + return this.a; + } + + public void b(World world, int i, int j, int k, int l) { + if (this == Block.STEP) { + ; + } + } + + public void e(World world, int i, int j, int k) { + if (this != Block.STEP) { + super.e(world, i, j, k); + } + + int l = world.a(i, j - 1, k); + + if (l == STEP.bc) { + world.d(i, j, k, 0); + world.d(i, j - 1, k, Block.DOUBLE_STEP.bc); + } + } + + public int a(int i, Random random) { + return Block.STEP.bc; + } + + public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + if (this != Block.STEP) { + super.a(iblockaccess, i, j, k, l); + } + + return l == 1 ? true : (!super.a(iblockaccess, i, j, k, l) ? false : (l == 0 ? true : iblockaccess.a(i, j, k) != this.bc)); + } +} diff --git a/net/minecraft/server/BlockStone.java b/net/minecraft/server/BlockStone.java new file mode 100644 index 000000000..2134d70eb --- /dev/null +++ b/net/minecraft/server/BlockStone.java @@ -0,0 +1,14 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockStone extends Block { + + public BlockStone(int i, int j) { + super(i, j, Material.d); + } + + public int a(int i, Random random) { + return Block.COBBLESTONE.bc; + } +} diff --git a/net/minecraft/server/BlockTNT.java b/net/minecraft/server/BlockTNT.java new file mode 100644 index 000000000..61b234949 --- /dev/null +++ b/net/minecraft/server/BlockTNT.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockTNT extends Block { + + public BlockTNT(int i, int j) { + super(i, j, Material.p); + } + + public int a(int i) { + return i == 0 ? this.bb + 2 : (i == 1 ? this.bb + 1 : this.bb); + } + + public void b(World world, int i, int j, int k, int l) { + if (l > 0 && Block.n[l].d() && world.n(i, j, k)) { + this.a(world, i, j, k, 0); + world.d(i, j, k, 0); + } + } + + public int a(Random random) { + return 0; + } + + public void c(World world, int i, int j, int k) { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F); + + entitytntprimed.a = world.m.nextInt(entitytntprimed.a / 4) + entitytntprimed.a / 8; + world.a((Entity) entitytntprimed); + } + + public void a(World world, int i, int j, int k, int l) { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F); + + world.a((Entity) entitytntprimed); + world.a(entitytntprimed, "random.fuse", 1.0F, 1.0F); + } +} diff --git a/net/minecraft/server/BlockTorch.java b/net/minecraft/server/BlockTorch.java new file mode 100644 index 000000000..392d7a3b4 --- /dev/null +++ b/net/minecraft/server/BlockTorch.java @@ -0,0 +1,138 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockTorch extends Block { + + protected BlockTorch(int i, int j) { + super(i, j, Material.n); + this.a(true); + } + + public AxisAlignedBB d(World world, int i, int j, int k) { + return null; + } + + public boolean b() { + return false; + } + + public int a() { + return 2; + } + + public boolean a(World world, int i, int j, int k) { + return world.d(i - 1, j, k) ? true : (world.d(i + 1, j, k) ? true : (world.d(i, j, k - 1) ? true : (world.d(i, j, k + 1) ? true : world.d(i, j - 1, k)))); + } + + public void c(World world, int i, int j, int k, int l) { + int i1 = world.b(i, j, k); + + if (l == 1 && world.d(i, j - 1, k)) { + i1 = 5; + } + + if (l == 2 && world.d(i, j, k + 1)) { + i1 = 4; + } + + if (l == 3 && world.d(i, j, k - 1)) { + i1 = 3; + } + + if (l == 4 && world.d(i + 1, j, k)) { + i1 = 2; + } + + if (l == 5 && world.d(i - 1, j, k)) { + i1 = 1; + } + + world.b(i, j, k, i1); + } + + public void a(World world, int i, int j, int k, Random random) { + super.a(world, i, j, k, random); + if (world.b(i, j, k) == 0) { + this.e(world, i, j, k); + } + } + + public void e(World world, int i, int j, int k) { + if (world.d(i - 1, j, k)) { + world.b(i, j, k, 1); + } else if (world.d(i + 1, j, k)) { + world.b(i, j, k, 2); + } else if (world.d(i, j, k - 1)) { + world.b(i, j, k, 3); + } else if (world.d(i, j, k + 1)) { + world.b(i, j, k, 4); + } else if (world.d(i, j - 1, k)) { + world.b(i, j, k, 5); + } + + this.g(world, i, j, k); + } + + public void b(World world, int i, int j, int k, int l) { + if (this.g(world, i, j, k)) { + int i1 = world.b(i, j, k); + boolean flag = false; + + if (!world.d(i - 1, j, k) && i1 == 1) { + flag = true; + } + + if (!world.d(i + 1, j, k) && i1 == 2) { + flag = true; + } + + if (!world.d(i, j, k - 1) && i1 == 3) { + flag = true; + } + + if (!world.d(i, j, k + 1) && i1 == 4) { + flag = true; + } + + if (!world.d(i, j - 1, k) && i1 == 5) { + flag = true; + } + + if (flag) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + } + } + } + + private boolean g(World world, int i, int j, int k) { + if (!this.a(world, i, j, k)) { + this.a_(world, i, j, k, world.b(i, j, k)); + world.d(i, j, k, 0); + return false; + } else { + return true; + } + } + + public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { + int l = world.b(i, j, k) & 7; + float f = 0.15F; + + if (l == 1) { + this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } else if (l == 2) { + this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } else if (l == 3) { + this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } else if (l == 4) { + this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } else { + f = 0.1F; + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); + } + + return super.a(world, i, j, k, vec3d, vec3d1); + } +} diff --git a/net/minecraft/server/BlockWorkbench.java b/net/minecraft/server/BlockWorkbench.java new file mode 100644 index 000000000..90d09daa3 --- /dev/null +++ b/net/minecraft/server/BlockWorkbench.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +public class BlockWorkbench extends Block { + + protected BlockWorkbench(int i) { + super(i, Material.c); + this.bb = 59; + } + + public int a(int i) { + return i == 1 ? this.bb - 16 : (i == 0 ? Block.WOOD.a(0) : (i != 2 && i != 4 ? this.bb : this.bb + 1)); + } + + public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { + entityhuman.A(); + return true; + } +} diff --git a/net/minecraft/server/Chunk.java b/net/minecraft/server/Chunk.java new file mode 100644 index 000000000..fcc58eadd --- /dev/null +++ b/net/minecraft/server/Chunk.java @@ -0,0 +1,547 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +public class Chunk { + + public static boolean a; + public byte[] b; + public boolean c; + public World d; + public NibbleArray e; + public NibbleArray f; + public NibbleArray g; + public byte[] h; + public int i; + public final int j; + public final int k; + public Map l; + public List[] m; + public boolean n; + public boolean o; + public boolean p; + public boolean q; + public boolean r; + public long s; + + public Chunk(World world, int i, int j) { + this.l = new HashMap(); + this.m = new List[8]; + this.n = false; + this.o = false; + this.q = false; + this.r = false; + this.s = 0L; + this.d = world; + this.j = i; + this.k = j; + this.h = new byte[256]; + + for (int k = 0; k < this.m.length; ++k) { + this.m[k] = new ArrayList(); + } + } + + public Chunk(World world, byte[] abyte, int i, int j) { + this(world, i, j); + this.b = abyte; + this.e = new NibbleArray(abyte.length); + this.f = new NibbleArray(abyte.length); + this.g = new NibbleArray(abyte.length); + } + + public boolean a(int i, int j) { + return i == this.j && j == this.k; + } + + public int b(int i, int j) { + return this.h[j << 4 | i] & 255; + } + + public void a() {} + + public void b() { + int i = 127; + + int j; + int k; + + for (j = 0; j < 16; ++j) { + for (k = 0; k < 16; ++k) { + this.h[k << 4 | j] = -128; + this.g(j, 127, k); + if ((this.h[k << 4 | j] & 255) < i) { + i = this.h[k << 4 | j] & 255; + } + } + } + + this.i = i; + + for (j = 0; j < 16; ++j) { + for (k = 0; k < 16; ++k) { + this.c(j, k); + } + } + + this.o = true; + } + + private void c(int i, int j) { + int k = this.b(i, j); + int l = this.j * 16 + i; + int i1 = this.k * 16 + j; + + this.f(l - 1, i1, k); + this.f(l + 1, i1, k); + this.f(l, i1 - 1, k); + this.f(l, i1 + 1, k); + } + + private void f(int i, int j, int k) { + int l = this.d.c(i, j); + + if (l > k) { + this.d.a(EnumSkyBlock.SKY, i, k, j, i, l, j); + } else if (l < k) { + this.d.a(EnumSkyBlock.SKY, i, l, j, i, k, j); + } + + this.o = true; + } + + private void g(int i, int j, int k) { + int l = this.h[k << 4 | i] & 255; + int i1 = l; + + if (j > l) { + i1 = j; + } + + for (int j1 = i << 11 | k << 7; i1 > 0 && Block.r[this.b[j1 + i1 - 1]] == 0; --i1) { + ; + } + + if (i1 != l) { + this.d.f(i, k, i1, l); + this.h[k << 4 | i] = (byte) i1; + int k1; + int l1; + int i2; + + if (i1 < this.i) { + this.i = i1; + } else { + k1 = 127; + + for (l1 = 0; l1 < 16; ++l1) { + for (i2 = 0; i2 < 16; ++i2) { + if ((this.h[i2 << 4 | l1] & 255) < k1) { + k1 = this.h[i2 << 4 | l1] & 255; + } + } + } + + this.i = k1; + } + + k1 = this.j * 16 + i; + l1 = this.k * 16 + k; + if (i1 < l) { + for (i2 = i1; i2 < l; ++i2) { + this.f.a(i, i2, k, 15); + } + } else { + this.d.a(EnumSkyBlock.SKY, k1, l, l1, k1, i1, l1); + + for (i2 = l; i2 < i1; ++i2) { + this.f.a(i, i2, k, 0); + } + } + + i2 = 15; + + int j2; + + for (j2 = i1; i1 > 0 && i2 > 0; this.f.a(i, i1, k, i2)) { + --i1; + int k2 = Block.r[this.a(i, i1, k)]; + + if (k2 == 0) { + k2 = 1; + } + + i2 -= k2; + if (i2 < 0) { + i2 = 0; + } + } + + while (i1 > 0 && Block.r[this.a(i, i1 - 1, k)] == 0) { + --i1; + } + + if (i1 != j2) { + this.d.a(EnumSkyBlock.SKY, k1 - 1, i1, l1 - 1, k1 + 1, j2, l1 + 1); + } + + this.o = true; + } + } + + public int a(int i, int j, int k) { + return this.b[i << 11 | k << 7 | j]; + } + + public boolean a(int i, int j, int k, int l, int i1) { + byte b0 = (byte) l; + int j1 = this.h[k << 4 | i] & 255; + int k1 = this.b[i << 11 | k << 7 | j] & 255; + + if (k1 == l && this.e.a(i, j, k) == i1) { + return false; + } else { + int l1 = this.j * 16 + i; + int i2 = this.k * 16 + k; + + this.b[i << 11 | k << 7 | j] = b0; + if (k1 != 0 && !this.d.x) { + Block.n[k1].b(this.d, l1, j, i2); + } + + this.e.a(i, j, k, i1); + if (Block.r[b0] != 0) { + if (j >= j1) { + this.g(i, j + 1, k); + } + } else if (j == j1 - 1) { + this.g(i, j, k); + } + + this.d.a(EnumSkyBlock.SKY, l1, j, i2, l1, j, i2); + this.d.a(EnumSkyBlock.BLOCK, l1, j, i2, l1, j, i2); + this.c(i, k); + if (l != 0) { + Block.n[l].e(this.d, l1, j, i2); + } + + this.o = true; + return true; + } + } + + public boolean a(int i, int j, int k, int l) { + byte b0 = (byte) l; + int i1 = this.h[k << 4 | i] & 255; + int j1 = this.b[i << 11 | k << 7 | j] & 255; + + if (j1 == l) { + return false; + } else { + int k1 = this.j * 16 + i; + int l1 = this.k * 16 + k; + + this.b[i << 11 | k << 7 | j] = b0; + if (j1 != 0) { + Block.n[j1].b(this.d, k1, j, l1); + } + + this.e.a(i, j, k, 0); + if (Block.r[b0] != 0) { + if (j >= i1) { + this.g(i, j + 1, k); + } + } else if (j == i1 - 1) { + this.g(i, j, k); + } + + this.d.a(EnumSkyBlock.SKY, k1, j, l1, k1, j, l1); + this.d.a(EnumSkyBlock.BLOCK, k1, j, l1, k1, j, l1); + this.c(i, k); + if (l != 0 && !this.d.x) { + Block.n[l].e(this.d, k1, j, l1); + } + + this.o = true; + return true; + } + } + + public int b(int i, int j, int k) { + return this.e.a(i, j, k); + } + + public void b(int i, int j, int k, int l) { + this.o = true; + this.e.a(i, j, k, l); + } + + public int a(EnumSkyBlock enumskyblock, int i, int j, int k) { + return enumskyblock == EnumSkyBlock.SKY ? this.f.a(i, j, k) : (enumskyblock == EnumSkyBlock.BLOCK ? this.g.a(i, j, k) : 0); + } + + public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { + this.o = true; + if (enumskyblock == EnumSkyBlock.SKY) { + this.f.a(i, j, k, l); + } else { + if (enumskyblock != EnumSkyBlock.BLOCK) { + return; + } + + this.g.a(i, j, k, l); + } + } + + public int c(int i, int j, int k, int l) { + int i1 = this.f.a(i, j, k); + + if (i1 > 0) { + a = true; + } + + i1 -= l; + int j1 = this.g.a(i, j, k); + + if (j1 > i1) { + i1 = j1; + } + + return i1; + } + + public void a(Entity entity) { + if (!this.q) { + this.r = true; + int i = MathHelper.b(entity.l / 16.0D); + int j = MathHelper.b(entity.n / 16.0D); + + if (i != this.j || j != this.k) { + System.out.println("Wrong location! " + entity); + } + + int k = MathHelper.b(entity.m / 16.0D); + + if (k < 0) { + k = 0; + } + + if (k >= this.m.length) { + k = this.m.length - 1; + } + + entity.Z = true; + entity.aa = this.j; + entity.ab = k; + entity.ac = this.k; + this.m[k].add(entity); + } + } + + public void b(Entity entity) { + this.a(entity, entity.ab); + } + + public void a(Entity entity, int i) { + if (i < 0) { + i = 0; + } + + if (i >= this.m.length) { + i = this.m.length - 1; + } + + this.m[i].remove(entity); + } + + public boolean c(int i, int j, int k) { + return j >= (this.h[k << 4 | i] & 255); + } + + public TileEntity d(int i, int j, int k) { + ChunkPosition chunkposition = new ChunkPosition(i, j, k); + TileEntity tileentity = (TileEntity) this.l.get(chunkposition); + + if (tileentity == null) { + int l = this.a(i, j, k); + + if (!Block.q[l]) { + return null; + } + + BlockContainer blockcontainer = (BlockContainer) Block.n[l]; + + blockcontainer.e(this.d, this.j * 16 + i, j, this.k * 16 + k); + tileentity = (TileEntity) this.l.get(chunkposition); + } + + return tileentity; + } + + public void a(TileEntity tileentity) { + int i = tileentity.b - this.j * 16; + int j = tileentity.c; + int k = tileentity.d - this.k * 16; + + this.a(i, j, k, tileentity); + } + + public void a(int i, int j, int k, TileEntity tileentity) { + ChunkPosition chunkposition = new ChunkPosition(i, j, k); + + tileentity.a = this.d; + tileentity.b = this.j * 16 + i; + tileentity.c = j; + tileentity.d = this.k * 16 + k; + if (this.a(i, j, k) != 0 && Block.n[this.a(i, j, k)] instanceof BlockContainer) { + if (this.c) { + if (this.l.get(chunkposition) != null) { + this.d.b.remove(this.l.get(chunkposition)); + } + + this.d.b.add(tileentity); + } + + this.l.put(chunkposition, tileentity); + } else { + System.out.println("Attempted to place a tile entity where there was no entity tile!"); + } + } + + public void e(int i, int j, int k) { + ChunkPosition chunkposition = new ChunkPosition(i, j, k); + + if (this.c) { + this.d.b.remove(this.l.remove(chunkposition)); + } + } + + public void c() { + this.c = true; + this.d.b.addAll(this.l.values()); + + for (int i = 0; i < this.m.length; ++i) { + this.d.a(this.m[i]); + } + } + + public void d() { + this.c = false; + this.d.b.removeAll(this.l.values()); + + for (int i = 0; i < this.m.length; ++i) { + this.d.b(this.m[i]); + } + } + + public void e() { + this.o = true; + } + + public void a(Entity entity, AxisAlignedBB axisalignedbb, List list) { + int i = MathHelper.b((axisalignedbb.b - 2.0D) / 16.0D); + int j = MathHelper.b((axisalignedbb.e + 2.0D) / 16.0D); + + if (i < 0) { + i = 0; + } + + if (j >= this.m.length) { + j = this.m.length - 1; + } + + for (int k = i; k <= j; ++k) { + List list1 = this.m[k]; + + for (int l = 0; l < list1.size(); ++l) { + Entity entity1 = (Entity) list1.get(l); + + if (entity1 != entity && entity1.v.a(axisalignedbb)) { + list.add(entity1); + } + } + } + } + + public void a(Class oclass, AxisAlignedBB axisalignedbb, List list) { + int i = MathHelper.b((axisalignedbb.b - 2.0D) / 16.0D); + int j = MathHelper.b((axisalignedbb.e + 2.0D) / 16.0D); + + if (i < 0) { + i = 0; + } + + if (j >= this.m.length) { + j = this.m.length - 1; + } + + for (int k = i; k <= j; ++k) { + List list1 = this.m[k]; + + for (int l = 0; l < list1.size(); ++l) { + Entity entity = (Entity) list1.get(l); + + if (oclass.isAssignableFrom(entity.getClass()) && entity.v.a(axisalignedbb)) { + list.add(entity); + } + } + } + } + + public boolean a(boolean flag) { + return this.p ? false : (this.r && this.d.c != this.s ? true : this.o); + } + + public int a(byte[] abyte, int i, int j, int k, int l, int i1, int j1, int k1) { + int l1; + int i2; + int j2; + int k2; + + for (l1 = i; l1 < l; ++l1) { + for (i2 = k; i2 < j1; ++i2) { + j2 = l1 << 11 | i2 << 7 | j; + k2 = i1 - j; + System.arraycopy(this.b, j2, abyte, k1, k2); + k1 += k2; + } + } + + for (l1 = i; l1 < l; ++l1) { + for (i2 = k; i2 < j1; ++i2) { + j2 = (l1 << 11 | i2 << 7 | j) >> 1; + k2 = (i1 - j) / 2; + System.arraycopy(this.e.a, j2, abyte, k1, k2); + k1 += k2; + } + } + + for (l1 = i; l1 < l; ++l1) { + for (i2 = k; i2 < j1; ++i2) { + j2 = (l1 << 11 | i2 << 7 | j) >> 1; + k2 = (i1 - j) / 2; + System.arraycopy(this.g.a, j2, abyte, k1, k2); + k1 += k2; + } + } + + for (l1 = i; l1 < l; ++l1) { + for (i2 = k; i2 < j1; ++i2) { + j2 = (l1 << 11 | i2 << 7 | j) >> 1; + k2 = (i1 - j) / 2; + System.arraycopy(this.f.a, j2, abyte, k1, k2); + k1 += k2; + } + } + + return k1; + } + + public Random a(long i) { + return new Random(this.d.t + (long) (this.j * this.j * 4987142) + (long) (this.j * 5947611) + (long) (this.k * this.k) * 4392871L + (long) (this.k * 389711) ^ i); + } +} diff --git a/net/minecraft/server/ChunkCache.java b/net/minecraft/server/ChunkCache.java new file mode 100644 index 000000000..2b420f261 --- /dev/null +++ b/net/minecraft/server/ChunkCache.java @@ -0,0 +1,63 @@ +package net.minecraft.server; + +public class ChunkCache implements IBlockAccess { + + private int a; + private int b; + private Chunk[][] c; + private World d; + + public ChunkCache(World world, int i, int j, int k, int l, int i1, int j1) { + this.d = world; + this.a = i >> 4; + this.b = k >> 4; + int k1 = l >> 4; + int l1 = j1 >> 4; + + this.c = new Chunk[k1 - this.a + 1][l1 - this.b + 1]; + + for (int i2 = this.a; i2 <= k1; ++i2) { + for (int j2 = this.b; j2 <= l1; ++j2) { + this.c[i2 - this.a][j2 - this.b] = world.b(i2, j2); + } + } + } + + public int a(int i, int j, int k) { + if (j < 0) { + return 0; + } else if (j >= 128) { + return 0; + } else { + int l = (i >> 4) - this.a; + int i1 = (k >> 4) - this.b; + + return this.c[l][i1].a(i & 15, j, k & 15); + } + } + + public int b(int i, int j, int k) { + if (j < 0) { + return 0; + } else if (j >= 128) { + return 0; + } else { + int l = (i >> 4) - this.a; + int i1 = (k >> 4) - this.b; + + return this.c[l][i1].b(i & 15, j, k & 15); + } + } + + public Material c(int i, int j, int k) { + int l = this.a(i, j, k); + + return l == 0 ? Material.a : Block.n[l].bn; + } + + public boolean d(int i, int j, int k) { + Block block = Block.n[this.a(i, j, k)]; + + return block == null ? false : block.b(); + } +} diff --git a/net/minecraft/server/ChunkCoordIntPair.java b/net/minecraft/server/ChunkCoordIntPair.java new file mode 100644 index 000000000..fef7745b4 --- /dev/null +++ b/net/minecraft/server/ChunkCoordIntPair.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +public class ChunkCoordIntPair { + + public int a; + public int b; + + public ChunkCoordIntPair(int i, int j) { + this.a = i; + this.b = j; + } + + public int hashCode() { + return this.a << 8 | this.b; + } + + public boolean equals(Object object) { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) object; + + return chunkcoordintpair.a == this.a && chunkcoordintpair.b == this.b; + } + + public double a(Entity entity) { + double d0 = (double) (this.a * 16 + 8); + double d1 = (double) (this.b * 16 + 8); + double d2 = d0 - entity.l; + double d3 = d1 - entity.n; + + return d2 * d2 + d3 * d3; + } +} diff --git a/net/minecraft/server/ChunkCoordinates.java b/net/minecraft/server/ChunkCoordinates.java new file mode 100644 index 000000000..b614f445b --- /dev/null +++ b/net/minecraft/server/ChunkCoordinates.java @@ -0,0 +1,26 @@ +package net.minecraft.server; + +final class ChunkCoordinates { + + public final int a; + public final int b; + + public ChunkCoordinates(int i, int j) { + this.a = i; + this.b = j; + } + + public boolean equals(Object object) { + if (!(object instanceof ChunkCoordinates)) { + return false; + } else { + ChunkCoordinates chunkcoordinates = (ChunkCoordinates) object; + + return this.a == chunkcoordinates.a && this.b == chunkcoordinates.b; + } + } + + public int hashCode() { + return this.a << 16 ^ this.b; + } +} diff --git a/net/minecraft/server/ChunkLoader.java b/net/minecraft/server/ChunkLoader.java new file mode 100644 index 000000000..ce9b482b2 --- /dev/null +++ b/net/minecraft/server/ChunkLoader.java @@ -0,0 +1,220 @@ +package net.minecraft.server; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Iterator; + +public class ChunkLoader implements IChunkLoader { + + private File a; + private boolean b; + + public ChunkLoader(File file1, boolean flag) { + this.a = file1; + this.b = flag; + } + + private File a(int i, int j) { + String s = "c." + Integer.toString(i, 36) + "." + Integer.toString(j, 36) + ".dat"; + String s1 = Integer.toString(i & 63, 36); + String s2 = Integer.toString(j & 63, 36); + File file1 = new File(this.a, s1); + + if (!file1.exists()) { + if (!this.b) { + return null; + } + + file1.mkdir(); + } + + file1 = new File(file1, s2); + if (!file1.exists()) { + if (!this.b) { + return null; + } + + file1.mkdir(); + } + + file1 = new File(file1, s); + return !file1.exists() && !this.b ? null : file1; + } + + public Chunk a(World world, int i, int j) { + File file1 = this.a(i, j); + + if (file1 != null && file1.exists()) { + try { + FileInputStream fileinputstream = new FileInputStream(file1); + NBTTagCompound nbttagcompound = CompressedStreamTools.a((InputStream) fileinputstream); + + if (!nbttagcompound.a("Level")) { + System.out.println("Chunk file at " + i + "," + j + " is missing level data, skipping"); + return null; + } + + if (!nbttagcompound.j("Level").a("Blocks")) { + System.out.println("Chunk file at " + i + "," + j + " is missing block data, skipping"); + return null; + } + + Chunk chunk = a(world, nbttagcompound.j("Level")); + + if (!chunk.a(i, j)) { + System.out.println("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.j + ", " + chunk.k + ")"); + nbttagcompound.a("xPos", i); + nbttagcompound.a("zPos", j); + chunk = a(world, nbttagcompound.j("Level")); + } + + return chunk; + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + return null; + } + + public void a(World world, Chunk chunk) { + world.g(); + File file1 = this.a(chunk.j, chunk.k); + + if (file1.exists()) { + world.u -= file1.length(); + } + + try { + File file2 = new File(this.a, "tmp_chunk.dat"); + FileOutputStream fileoutputstream = new FileOutputStream(file2); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + nbttagcompound.a("Level", (NBTBase) nbttagcompound1); + this.a(chunk, world, nbttagcompound1); + CompressedStreamTools.a(nbttagcompound, (OutputStream) fileoutputstream); + fileoutputstream.close(); + if (file1.exists()) { + file1.delete(); + } + + file2.renameTo(file1); + world.u += file1.length(); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + public void a(Chunk chunk, World world, NBTTagCompound nbttagcompound) { + world.g(); + nbttagcompound.a("xPos", chunk.j); + nbttagcompound.a("zPos", chunk.k); + nbttagcompound.a("LastUpdate", world.c); + nbttagcompound.a("Blocks", chunk.b); + nbttagcompound.a("Data", chunk.e.a); + nbttagcompound.a("SkyLight", chunk.f.a); + nbttagcompound.a("BlockLight", chunk.g.a); + nbttagcompound.a("HeightMap", chunk.h); + nbttagcompound.a("TerrainPopulated", chunk.n); + chunk.r = false; + NBTTagList nbttaglist = new NBTTagList(); + + Iterator iterator; + NBTTagCompound nbttagcompound1; + + for (int i = 0; i < chunk.m.length; ++i) { + iterator = chunk.m[i].iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + + chunk.r = true; + nbttagcompound1 = new NBTTagCompound(); + if (entity.c(nbttagcompound1)) { + nbttaglist.a((NBTBase) nbttagcompound1); + } + } + } + + nbttagcompound.a("Entities", (NBTBase) nbttaglist); + NBTTagList nbttaglist1 = new NBTTagList(); + + iterator = chunk.l.values().iterator(); + + while (iterator.hasNext()) { + TileEntity tileentity = (TileEntity) iterator.next(); + + nbttagcompound1 = new NBTTagCompound(); + tileentity.b(nbttagcompound1); + nbttaglist1.a((NBTBase) nbttagcompound1); + } + + nbttagcompound.a("TileEntities", (NBTBase) nbttaglist1); + } + + public static Chunk a(World world, NBTTagCompound nbttagcompound) { + int i = nbttagcompound.d("xPos"); + int j = nbttagcompound.d("zPos"); + Chunk chunk = new Chunk(world, i, j); + + chunk.b = nbttagcompound.i("Blocks"); + chunk.e = new NibbleArray(nbttagcompound.i("Data")); + chunk.f = new NibbleArray(nbttagcompound.i("SkyLight")); + chunk.g = new NibbleArray(nbttagcompound.i("BlockLight")); + chunk.h = nbttagcompound.i("HeightMap"); + chunk.n = nbttagcompound.l("TerrainPopulated"); + if (!chunk.e.a()) { + chunk.e = new NibbleArray(chunk.b.length); + } + + if (chunk.h == null || !chunk.f.a()) { + chunk.h = new byte[256]; + chunk.f = new NibbleArray(chunk.b.length); + chunk.b(); + } + + if (!chunk.g.a()) { + chunk.g = new NibbleArray(chunk.b.length); + chunk.a(); + } + + NBTTagList nbttaglist = nbttagcompound.k("Entities"); + + if (nbttaglist != null) { + for (int k = 0; k < nbttaglist.b(); ++k) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(k); + Entity entity = EntityTypes.a(nbttagcompound1, world); + + chunk.r = true; + if (entity != null) { + chunk.a(entity); + } + } + } + + NBTTagList nbttaglist1 = nbttagcompound.k("TileEntities"); + + if (nbttaglist1 != null) { + for (int l = 0; l < nbttaglist1.b(); ++l) { + NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.a(l); + TileEntity tileentity = TileEntity.c(nbttagcompound2); + + if (tileentity != null) { + chunk.a(tileentity); + } + } + } + + return chunk; + } + + public void a() {} + + public void b() {} + + public void b(World world, Chunk chunk) {} +} diff --git a/net/minecraft/server/ChunkPosition.java b/net/minecraft/server/ChunkPosition.java new file mode 100644 index 000000000..f06aa9129 --- /dev/null +++ b/net/minecraft/server/ChunkPosition.java @@ -0,0 +1,28 @@ +package net.minecraft.server; + +public class ChunkPosition { + + public final int a; + public final int b; + public final int c; + + public ChunkPosition(int i, int j, int k) { + this.a = i; + this.b = j; + this.c = k; + } + + public boolean equals(Object object) { + if (!(object instanceof ChunkPosition)) { + return false; + } else { + ChunkPosition chunkposition = (ChunkPosition) object; + + return chunkposition.a == this.a && chunkposition.b == this.b && chunkposition.c == this.c; + } + } + + public int hashCode() { + return this.a * 8976890 + this.b * 981131 + this.c; + } +} diff --git a/net/minecraft/server/ChunkProviderGenerate.java b/net/minecraft/server/ChunkProviderGenerate.java new file mode 100644 index 000000000..43b682638 --- /dev/null +++ b/net/minecraft/server/ChunkProviderGenerate.java @@ -0,0 +1,492 @@ +package net.minecraft.server; + +import java.util.Random; + +public class ChunkProviderGenerate implements IChunkProvider { + + private Random j; + private NoiseGeneratorOctaves k; + private NoiseGeneratorOctaves l; + private NoiseGeneratorOctaves m; + private NoiseGeneratorOctaves n; + private NoiseGeneratorOctaves o; + public NoiseGeneratorOctaves a; + public NoiseGeneratorOctaves b; + public NoiseGeneratorOctaves c; + private World p; + private double[] q; + private double[] r = new double[256]; + private double[] s = new double[256]; + private double[] t = new double[256]; + private MapGenBase u = new MapGenCaves(); + double[] d; + double[] e; + double[] f; + double[] g; + double[] h; + int[][] i = new int[32][32]; + + public ChunkProviderGenerate(World world, long i) { + this.p = world; + this.j = new Random(i); + this.k = new NoiseGeneratorOctaves(this.j, 16); + this.l = new NoiseGeneratorOctaves(this.j, 16); + this.m = new NoiseGeneratorOctaves(this.j, 8); + this.n = new NoiseGeneratorOctaves(this.j, 4); + this.o = new NoiseGeneratorOctaves(this.j, 4); + this.a = new NoiseGeneratorOctaves(this.j, 10); + this.b = new NoiseGeneratorOctaves(this.j, 16); + this.c = new NoiseGeneratorOctaves(this.j, 8); + } + + public void a(int i, int j, byte[] abyte) { + byte b0 = 4; + byte b1 = 64; + int k = b0 + 1; + byte b2 = 17; + int l = b0 + 1; + + this.q = this.a(this.q, i * b0, 0, j * b0, k, b2, l); + + for (int i1 = 0; i1 < b0; ++i1) { + for (int j1 = 0; j1 < b0; ++j1) { + for (int k1 = 0; k1 < 16; ++k1) { + double d0 = 0.125D; + double d1 = this.q[((i1 + 0) * l + j1 + 0) * b2 + k1 + 0]; + double d2 = this.q[((i1 + 0) * l + j1 + 1) * b2 + k1 + 0]; + double d3 = this.q[((i1 + 1) * l + j1 + 0) * b2 + k1 + 0]; + double d4 = this.q[((i1 + 1) * l + j1 + 1) * b2 + k1 + 0]; + double d5 = (this.q[((i1 + 0) * l + j1 + 0) * b2 + k1 + 1] - d1) * d0; + double d6 = (this.q[((i1 + 0) * l + j1 + 1) * b2 + k1 + 1] - d2) * d0; + double d7 = (this.q[((i1 + 1) * l + j1 + 0) * b2 + k1 + 1] - d3) * d0; + double d8 = (this.q[((i1 + 1) * l + j1 + 1) * b2 + k1 + 1] - d4) * d0; + + for (int l1 = 0; l1 < 8; ++l1) { + double d9 = 0.25D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + + for (int i2 = 0; i2 < 4; ++i2) { + int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1; + short short1 = 128; + double d14 = 0.25D; + double d15 = d10; + double d16 = (d11 - d10) * d14; + + for (int k2 = 0; k2 < 4; ++k2) { + int l2 = 0; + + if (k1 * 8 + l1 < b1) { + if (this.p.d && k1 * 8 + l1 >= b1 - 1) { + l2 = Block.ICE.bc; + } else { + l2 = Block.STATIONARY_WATER.bc; + } + } + + if (d15 > 0.0D) { + l2 = Block.STONE.bc; + } + + abyte[j2] = (byte) l2; + j2 += short1; + d15 += d16; + } + + d10 += d12; + d11 += d13; + } + + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + public void b(int i, int j, byte[] abyte) { + byte b0 = 64; + double d0 = 0.03125D; + + this.r = this.n.a(this.r, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0, d0, 1.0D); + this.s = this.n.a(this.s, (double) (j * 16), 109.0134D, (double) (i * 16), 16, 1, 16, d0, 1.0D, d0); + this.t = this.o.a(this.t, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D); + + for (int k = 0; k < 16; ++k) { + for (int l = 0; l < 16; ++l) { + boolean flag = this.r[k + l * 16] + this.j.nextDouble() * 0.2D > 0.0D; + boolean flag1 = this.s[k + l * 16] + this.j.nextDouble() * 0.2D > 3.0D; + int i1 = (int) (this.t[k + l * 16] / 3.0D + 3.0D + this.j.nextDouble() * 0.25D); + int j1 = -1; + byte b1 = (byte) Block.GRASS.bc; + byte b2 = (byte) Block.DIRT.bc; + + for (int k1 = 127; k1 >= 0; --k1) { + int l1 = (k * 16 + l) * 128 + k1; + + if (k1 <= 0 + this.j.nextInt(6) - 1) { + abyte[l1] = (byte) Block.BEDROCK.bc; + } else { + byte b3 = abyte[l1]; + + if (b3 == 0) { + j1 = -1; + } else if (b3 == Block.STONE.bc) { + if (j1 == -1) { + if (i1 <= 0) { + b1 = 0; + b2 = (byte) Block.STONE.bc; + } else if (k1 >= b0 - 4 && k1 <= b0 + 1) { + b1 = (byte) Block.GRASS.bc; + b2 = (byte) Block.DIRT.bc; + if (flag1) { + b1 = 0; + } + + if (flag1) { + b2 = (byte) Block.GRAVEL.bc; + } + + if (flag) { + b1 = (byte) Block.SAND.bc; + } + + if (flag) { + b2 = (byte) Block.SAND.bc; + } + } + + if (k1 < b0 && b1 == 0) { + b1 = (byte) Block.STATIONARY_WATER.bc; + } + + j1 = i1; + if (k1 >= b0 - 1) { + abyte[l1] = b1; + } else { + abyte[l1] = b2; + } + } else if (j1 > 0) { + --j1; + abyte[l1] = b2; + } + } + } + } + } + } + } + + public Chunk b(int i, int j) { + this.j.setSeed((long) i * 341873128712L + (long) j * 132897987541L); + byte[] abyte = new byte['\u8000']; + Chunk chunk = new Chunk(this.p, abyte, i, j); + + this.a(i, j, abyte); + this.b(i, j, abyte); + this.u.a(this, this.p, i, j, abyte); + chunk.b(); + return chunk; + } + + private double[] a(double[] adouble, int i, int j, int k, int l, int i1, int j1) { + if (adouble == null) { + adouble = new double[l * i1 * j1]; + } + + double d0 = 684.412D; + double d1 = 684.412D; + + this.g = this.a.a(this.g, (double) i, (double) j, (double) k, l, 1, j1, 1.0D, 0.0D, 1.0D); + this.h = this.b.a(this.h, (double) i, (double) j, (double) k, l, 1, j1, 100.0D, 0.0D, 100.0D); + this.d = this.m.a(this.d, (double) i, (double) j, (double) k, l, i1, j1, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D); + this.e = this.k.a(this.e, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0); + this.f = this.l.a(this.f, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0); + int k1 = 0; + int l1 = 0; + + for (int i2 = 0; i2 < l; ++i2) { + for (int j2 = 0; j2 < j1; ++j2) { + double d2 = (this.g[l1] + 256.0D) / 512.0D; + + if (d2 > 1.0D) { + d2 = 1.0D; + } + + double d3 = 0.0D; + double d4 = this.h[l1] / 8000.0D; + + if (d4 < 0.0D) { + d4 = -d4; + } + + d4 = d4 * 3.0D - 3.0D; + if (d4 < 0.0D) { + d4 /= 2.0D; + if (d4 < -1.0D) { + d4 = -1.0D; + } + + d4 /= 1.4D; + d4 /= 2.0D; + d2 = 0.0D; + } else { + if (d4 > 1.0D) { + d4 = 1.0D; + } + + d4 /= 6.0D; + } + + d2 += 0.5D; + d4 = d4 * (double) i1 / 16.0D; + double d5 = (double) i1 / 2.0D + d4 * 4.0D; + + ++l1; + + for (int k2 = 0; k2 < i1; ++k2) { + double d6 = 0.0D; + double d7 = ((double) k2 - d5) * 12.0D / d2; + + if (d7 < 0.0D) { + d7 *= 4.0D; + } + + double d8 = this.e[k1] / 512.0D; + double d9 = this.f[k1] / 512.0D; + double d10 = (this.d[k1] / 10.0D + 1.0D) / 2.0D; + + if (d10 < 0.0D) { + d6 = d8; + } else if (d10 > 1.0D) { + d6 = d9; + } else { + d6 = d8 + (d9 - d8) * d10; + } + + d6 -= d7; + double d11; + + if (k2 > i1 - 4) { + d11 = (double) ((float) (k2 - (i1 - 4)) / 3.0F); + d6 = d6 * (1.0D - d11) + -10.0D * d11; + } + + if ((double) k2 < d3) { + d11 = (d3 - (double) k2) / 4.0D; + if (d11 < 0.0D) { + d11 = 0.0D; + } + + if (d11 > 1.0D) { + d11 = 1.0D; + } + + d6 = d6 * (1.0D - d11) + -10.0D * d11; + } + + adouble[k1] = d6; + ++k1; + } + } + } + + return adouble; + } + + public boolean a(int i, int j) { + return true; + } + + public void a(IChunkProvider ichunkprovider, int i, int j) { + BlockSand.a = true; + int k = i * 16; + int l = j * 16; + + this.j.setSeed(this.p.t); + long i1 = this.j.nextLong() / 2L * 2L + 1L; + long j1 = this.j.nextLong() / 2L * 2L + 1L; + + this.j.setSeed((long) i * i1 + (long) j * j1 ^ this.p.t); + double d0 = 0.25D; + + int k1; + int l1; + int i2; + int j2; + + for (k1 = 0; k1 < 8; ++k1) { + l1 = k + this.j.nextInt(16) + 8; + i2 = this.j.nextInt(128); + j2 = l + this.j.nextInt(16) + 8; + (new WorldGenDungeons()).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 10; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(128); + j2 = l + this.j.nextInt(16); + (new WorldGenClay(32)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 20; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(128); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.DIRT.bc, 32)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 10; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(128); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.GRAVEL.bc, 32)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 20; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(128); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.COAL_ORE.bc, 16)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 20; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(64); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.IRON_ORE.bc, 8)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 2; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(32); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.GOLD_ORE.bc, 8)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 8; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(16); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.REDSTONE_ORE.bc, 7)).a(this.p, this.j, l1, i2, j2); + } + + for (k1 = 0; k1 < 1; ++k1) { + l1 = k + this.j.nextInt(16); + i2 = this.j.nextInt(16); + j2 = l + this.j.nextInt(16); + (new WorldGenMinable(Block.DIAMOND_ORE.bc, 7)).a(this.p, this.j, l1, i2, j2); + } + + d0 = 0.5D; + k1 = (int) ((this.c.a((double) k * d0, (double) l * d0) / 8.0D + this.j.nextDouble() * 4.0D + 4.0D) / 3.0D); + if (k1 < 0) { + k1 = 0; + } + + if (this.j.nextInt(10) == 0) { + ++k1; + } + + Object object = new WorldGenTrees(); + + if (this.j.nextInt(10) == 0) { + object = new WorldGenBigTree(); + } + + int k2; + + for (i2 = 0; i2 < k1; ++i2) { + j2 = k + this.j.nextInt(16) + 8; + k2 = l + this.j.nextInt(16) + 8; + ((WorldGenerator) object).a(1.0D, 1.0D, 1.0D); + ((WorldGenerator) object).a(this.p, this.j, j2, this.p.c(j2, k2), k2); + } + + int l2; + + for (i2 = 0; i2 < 2; ++i2) { + j2 = k + this.j.nextInt(16) + 8; + k2 = this.j.nextInt(128); + l2 = l + this.j.nextInt(16) + 8; + (new WorldGenFlowers(Block.YELLOW_FLOWER.bc)).a(this.p, this.j, j2, k2, l2); + } + + if (this.j.nextInt(2) == 0) { + i2 = k + this.j.nextInt(16) + 8; + j2 = this.j.nextInt(128); + k2 = l + this.j.nextInt(16) + 8; + (new WorldGenFlowers(Block.RED_ROSE.bc)).a(this.p, this.j, i2, j2, k2); + } + + if (this.j.nextInt(4) == 0) { + i2 = k + this.j.nextInt(16) + 8; + j2 = this.j.nextInt(128); + k2 = l + this.j.nextInt(16) + 8; + (new WorldGenFlowers(Block.BROWN_MUSHROOM.bc)).a(this.p, this.j, i2, j2, k2); + } + + if (this.j.nextInt(8) == 0) { + i2 = k + this.j.nextInt(16) + 8; + j2 = this.j.nextInt(128); + k2 = l + this.j.nextInt(16) + 8; + (new WorldGenFlowers(Block.RED_MUSHROOM.bc)).a(this.p, this.j, i2, j2, k2); + } + + for (i2 = 0; i2 < 10; ++i2) { + j2 = k + this.j.nextInt(16) + 8; + k2 = this.j.nextInt(128); + l2 = l + this.j.nextInt(16) + 8; + (new WorldGenReed()).a(this.p, this.j, j2, k2, l2); + } + + for (i2 = 0; i2 < 1; ++i2) { + j2 = k + this.j.nextInt(16) + 8; + k2 = this.j.nextInt(128); + l2 = l + this.j.nextInt(16) + 8; + (new WorldGenCactus()).a(this.p, this.j, j2, k2, l2); + } + + for (i2 = 0; i2 < 50; ++i2) { + j2 = k + this.j.nextInt(16) + 8; + k2 = this.j.nextInt(this.j.nextInt(120) + 8); + l2 = l + this.j.nextInt(16) + 8; + (new WorldGenLiquids(Block.WATER.bc)).a(this.p, this.j, j2, k2, l2); + } + + for (i2 = 0; i2 < 20; ++i2) { + j2 = k + this.j.nextInt(16) + 8; + k2 = this.j.nextInt(this.j.nextInt(this.j.nextInt(112) + 8) + 8); + l2 = l + this.j.nextInt(16) + 8; + (new WorldGenLiquids(Block.LAVA.bc)).a(this.p, this.j, j2, k2, l2); + } + + for (i2 = k + 8 + 0; i2 < k + 8 + 16; ++i2) { + for (j2 = l + 8 + 0; j2 < l + 8 + 16; ++j2) { + k2 = this.p.d(i2, j2); + if (this.p.d && k2 > 0 && k2 < 128 && this.p.a(i2, k2, j2) == 0 && this.p.c(i2, k2 - 1, j2).c() && this.p.c(i2, k2 - 1, j2) != Material.r) { + this.p.d(i2, k2, j2, Block.SNOW.bc); + } + } + } + + BlockSand.a = false; + } + + public boolean a(boolean flag, IProgressUpdate iprogressupdate) { + return true; + } + + public boolean a() { + return false; + } + + public boolean b() { + return true; + } +} diff --git a/net/minecraft/server/ChunkProviderLoadOrGenerate.java b/net/minecraft/server/ChunkProviderLoadOrGenerate.java new file mode 100644 index 000000000..91a954c5e --- /dev/null +++ b/net/minecraft/server/ChunkProviderLoadOrGenerate.java @@ -0,0 +1,204 @@ +package net.minecraft.server; + +import java.io.IOException; + +public class ChunkProviderLoadOrGenerate implements IChunkProvider { + + private Chunk c; + private IChunkProvider d; + private IChunkLoader e; + private Chunk[] f = new Chunk[1024]; + private World g; + int a = -999999999; + int b = -999999999; + private Chunk h; + + public ChunkProviderLoadOrGenerate(World world, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { + this.c = new Chunk(world, new byte['\u8000'], 0, 0); + this.c.q = true; + this.c.p = true; + this.g = world; + this.e = ichunkloader; + this.d = ichunkprovider; + } + + public boolean a(int i, int j) { + if (i == this.a && j == this.b && this.h != null) { + return true; + } else { + int k = i & 31; + int l = j & 31; + int i1 = k + l * 32; + + return this.f[i1] != null && (this.f[i1] == this.c || this.f[i1].a(i, j)); + } + } + + public Chunk b(int i, int j) { + if (i == this.a && j == this.b && this.h != null) { + return this.h; + } else { + int k = i & 31; + int l = j & 31; + int i1 = k + l * 32; + + if (!this.a(i, j)) { + if (this.f[i1] != null) { + this.f[i1].d(); + this.b(this.f[i1]); + this.a(this.f[i1]); + } + + Chunk chunk = this.c(i, j); + + if (chunk == null) { + if (this.d == null) { + chunk = this.c; + } else { + chunk = this.d.b(i, j); + } + } + + this.f[i1] = chunk; + if (this.f[i1] != null) { + this.f[i1].c(); + } + + if (!this.f[i1].n && this.a(i + 1, j + 1) && this.a(i, j + 1) && this.a(i + 1, j)) { + this.a(this, i, j); + } + + if (this.a(i - 1, j) && !this.b(i - 1, j).n && this.a(i - 1, j + 1) && this.a(i, j + 1) && this.a(i - 1, j)) { + this.a(this, i - 1, j); + } + + if (this.a(i, j - 1) && !this.b(i, j - 1).n && this.a(i + 1, j - 1) && this.a(i, j - 1) && this.a(i + 1, j)) { + this.a(this, i, j - 1); + } + + if (this.a(i - 1, j - 1) && !this.b(i - 1, j - 1).n && this.a(i - 1, j - 1) && this.a(i, j - 1) && this.a(i - 1, j)) { + this.a(this, i - 1, j - 1); + } + } + + this.a = i; + this.b = j; + this.h = this.f[i1]; + return this.f[i1]; + } + } + + private Chunk c(int i, int j) { + if (this.e == null) { + return null; + } else { + try { + Chunk chunk = this.e.a(this.g, i, j); + + if (chunk != null) { + chunk.s = this.g.c; + } + + return chunk; + } catch (Exception exception) { + exception.printStackTrace(); + return null; + } + } + } + + private void a(Chunk chunk) { + if (this.e != null) { + try { + this.e.b(this.g, chunk); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + } + + private void b(Chunk chunk) { + if (this.e != null) { + try { + chunk.s = this.g.c; + this.e.a(this.g, chunk); + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + } + + public void a(IChunkProvider ichunkprovider, int i, int j) { + Chunk chunk = this.b(i, j); + + if (!chunk.n) { + chunk.n = true; + if (this.d != null) { + this.d.a(ichunkprovider, i, j); + chunk.e(); + } + } + } + + public boolean a(boolean flag, IProgressUpdate iprogressupdate) { + int i = 0; + int j = 0; + int k; + + if (iprogressupdate != null) { + for (k = 0; k < this.f.length; ++k) { + if (this.f[k] != null && this.f[k].a(flag)) { + ++j; + } + } + } + + k = 0; + + for (int l = 0; l < this.f.length; ++l) { + if (this.f[l] != null) { + if (flag && !this.f[l].p) { + this.a(this.f[l]); + } + + if (this.f[l].a(flag)) { + this.b(this.f[l]); + this.f[l].o = false; + ++i; + if (i == 2 && !flag) { + return false; + } + + if (iprogressupdate != null) { + ++k; + if (k % 10 == 0) { + iprogressupdate.a(k * 100 / j); + } + } + } + } + } + + if (flag) { + if (this.e == null) { + return true; + } + + this.e.b(); + } + + return true; + } + + public boolean a() { + if (this.e != null) { + this.e.a(); + } + + return this.d.a(); + } + + public boolean b() { + return true; + } +} diff --git a/net/minecraft/server/ChunkProviderServer.java b/net/minecraft/server/ChunkProviderServer.java new file mode 100644 index 000000000..81a302ba7 --- /dev/null +++ b/net/minecraft/server/ChunkProviderServer.java @@ -0,0 +1,205 @@ +package net.minecraft.server; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ChunkProviderServer implements IChunkProvider { + + private Set a = new HashSet(); + private Chunk b; + private IChunkProvider c; + private IChunkLoader d; + private Map e = new HashMap(); + private List f = new ArrayList(); + private WorldServer g; + + public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { + this.b = new Chunk(worldserver, new byte['\u8000'], 0, 0); + this.b.q = true; + this.b.p = true; + this.g = worldserver; + this.d = ichunkloader; + this.c = ichunkprovider; + } + + public boolean a(int i, int j) { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j); + + return this.e.containsKey(chunkcoordinates); + } + + public void c(int i, int j) { + int k = i * 16 + 8 - this.g.n; + int l = j * 16 + 8 - this.g.p; + byte b0 = 20; + + if (k < -b0 || k > b0 || l < -b0 || l > b0) { + this.a.add(new ChunkCoordinates(i, j)); + } + } + + public Chunk d(int i, int j) { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j); + + this.a.remove(new ChunkCoordinates(i, j)); + Chunk chunk = (Chunk) this.e.get(chunkcoordinates); + + if (chunk == null) { + chunk = this.e(i, j); + if (chunk == null) { + if (this.c == null) { + chunk = this.b; + } else { + chunk = this.c.b(i, j); + } + } + + this.e.put(chunkcoordinates, chunk); + this.f.add(chunk); + if (chunk != null) { + chunk.c(); + } + + if (!chunk.n && this.a(i + 1, j + 1) && this.a(i, j + 1) && this.a(i + 1, j)) { + this.a(this, i, j); + } + + if (this.a(i - 1, j) && !this.b(i - 1, j).n && this.a(i - 1, j + 1) && this.a(i, j + 1) && this.a(i - 1, j)) { + this.a(this, i - 1, j); + } + + if (this.a(i, j - 1) && !this.b(i, j - 1).n && this.a(i + 1, j - 1) && this.a(i, j - 1) && this.a(i + 1, j)) { + this.a(this, i, j - 1); + } + + if (this.a(i - 1, j - 1) && !this.b(i - 1, j - 1).n && this.a(i - 1, j - 1) && this.a(i, j - 1) && this.a(i - 1, j)) { + this.a(this, i - 1, j - 1); + } + } + + return chunk; + } + + public Chunk b(int i, int j) { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j); + Chunk chunk = (Chunk) this.e.get(chunkcoordinates); + + return chunk == null ? (this.g.w ? this.d(i, j) : this.b) : chunk; + } + + private Chunk e(int i, int j) { + if (this.d == null) { + return null; + } else { + try { + Chunk chunk = this.d.a(this.g, i, j); + + if (chunk != null) { + chunk.s = this.g.c; + } + + return chunk; + } catch (Exception exception) { + exception.printStackTrace(); + return null; + } + } + } + + private void a(Chunk chunk) { + if (this.d != null) { + try { + this.d.b(this.g, chunk); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + } + + private void b(Chunk chunk) { + if (this.d != null) { + try { + chunk.s = this.g.c; + this.d.a(this.g, chunk); + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + } + + public void a(IChunkProvider ichunkprovider, int i, int j) { + Chunk chunk = this.b(i, j); + + if (!chunk.n) { + chunk.n = true; + if (this.c != null) { + this.c.a(ichunkprovider, i, j); + chunk.e(); + } + } + } + + public boolean a(boolean flag, IProgressUpdate iprogressupdate) { + int i = 0; + + for (int j = 0; j < this.f.size(); ++j) { + Chunk chunk = (Chunk) this.f.get(j); + + if (flag && !chunk.p) { + this.a(chunk); + } + + if (chunk.a(flag)) { + this.b(chunk); + chunk.o = false; + ++i; + if (i == 2 && !flag) { + return false; + } + } + } + + if (flag) { + if (this.d == null) { + return true; + } + + this.d.b(); + } + + return true; + } + + public boolean a() { + if (!this.g.A) { + for (int i = 0; i < 16; ++i) { + if (!this.a.isEmpty()) { + ChunkCoordinates chunkcoordinates = (ChunkCoordinates) this.a.iterator().next(); + Chunk chunk = this.b(chunkcoordinates.a, chunkcoordinates.b); + + chunk.d(); + this.b(chunk); + this.a(chunk); + this.a.remove(chunkcoordinates); + this.e.remove(chunkcoordinates); + this.f.remove(chunk); + } + } + + if (this.d != null) { + this.d.a(); + } + } + + return this.c.a(); + } + + public boolean b() { + return !this.g.A; + } +} diff --git a/net/minecraft/server/CompressedStreamTools.java b/net/minecraft/server/CompressedStreamTools.java new file mode 100644 index 000000000..6f2be0b7d --- /dev/null +++ b/net/minecraft/server/CompressedStreamTools.java @@ -0,0 +1,83 @@ +package net.minecraft.server; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +public class CompressedStreamTools { + + public CompressedStreamTools() {} + + public static NBTTagCompound a(InputStream inputstream) { + DataInputStream datainputstream = new DataInputStream(new GZIPInputStream(inputstream)); + + NBTTagCompound nbttagcompound; + + try { + nbttagcompound = a((DataInput) datainputstream); + } finally { + datainputstream.close(); + } + + return nbttagcompound; + } + + public static void a(NBTTagCompound nbttagcompound, OutputStream outputstream) { + DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(outputstream)); + + try { + a(nbttagcompound, (DataOutput) dataoutputstream); + } finally { + dataoutputstream.close(); + } + } + + public static NBTTagCompound a(byte[] abyte) { + DataInputStream datainputstream = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte))); + + NBTTagCompound nbttagcompound; + + try { + nbttagcompound = a((DataInput) datainputstream); + } finally { + datainputstream.close(); + } + + return nbttagcompound; + } + + public static byte[] a(NBTTagCompound nbttagcompound) { + ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); + DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(bytearrayoutputstream)); + + try { + a(nbttagcompound, (DataOutput) dataoutputstream); + } finally { + dataoutputstream.close(); + } + + return bytearrayoutputstream.toByteArray(); + } + + public static NBTTagCompound a(DataInput datainput) { + NBTBase nbtbase = NBTBase.b(datainput); + + if (nbtbase instanceof NBTTagCompound) { + return (NBTTagCompound) nbtbase; + } else { + throw new IOException("Root tag must be a named compound tag"); + } + } + + public static void a(NBTTagCompound nbttagcompound, DataOutput dataoutput) { + NBTBase.a(nbttagcompound, dataoutput); + } +} diff --git a/net/minecraft/server/ConsoleLogFormatter.java b/net/minecraft/server/ConsoleLogFormatter.java new file mode 100644 index 000000000..e2f8793dc --- /dev/null +++ b/net/minecraft/server/ConsoleLogFormatter.java @@ -0,0 +1,51 @@ +package net.minecraft.server; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.SimpleDateFormat; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +final class ConsoleLogFormatter extends Formatter { + + private SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + ConsoleLogFormatter() {} + + public String format(LogRecord logrecord) { + StringBuilder stringbuilder = new StringBuilder(); + + stringbuilder.append(this.a.format(Long.valueOf(logrecord.getMillis()))); + Level level = logrecord.getLevel(); + + if (level == Level.FINEST) { + stringbuilder.append(" [FINEST] "); + } else if (level == Level.FINER) { + stringbuilder.append(" [FINER] "); + } else if (level == Level.FINE) { + stringbuilder.append(" [FINE] "); + } else if (level == Level.INFO) { + stringbuilder.append(" [INFO] "); + } else if (level == Level.WARNING) { + stringbuilder.append(" [WARNING] "); + } else if (level == Level.SEVERE) { + stringbuilder.append(" [SEVERE] "); + } else if (level == Level.SEVERE) { + stringbuilder.append(" [" + level.getLocalizedName() + "] "); + } + + stringbuilder.append(logrecord.getMessage()); + stringbuilder.append('\n'); + Throwable throwable = logrecord.getThrown(); + + if (throwable != null) { + StringWriter stringwriter = new StringWriter(); + + throwable.printStackTrace(new PrintWriter(stringwriter)); + stringbuilder.append(stringwriter.toString()); + } + + return stringbuilder.toString(); + } +} diff --git a/net/minecraft/server/ConsoleLogManager.java b/net/minecraft/server/ConsoleLogManager.java new file mode 100644 index 000000000..b55226229 --- /dev/null +++ b/net/minecraft/server/ConsoleLogManager.java @@ -0,0 +1,32 @@ +package net.minecraft.server; + +import java.util.logging.ConsoleHandler; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ConsoleLogManager { + + public static Logger a = Logger.getLogger("Minecraft"); + + public ConsoleLogManager() {} + + public static void a() { + ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter(); + + a.setUseParentHandlers(false); + ConsoleHandler consolehandler = new ConsoleHandler(); + + consolehandler.setFormatter(consolelogformatter); + a.addHandler(consolehandler); + + try { + FileHandler filehandler = new FileHandler("server.log"); + + filehandler.setFormatter(consolelogformatter); + a.addHandler(filehandler); + } catch (Exception exception) { + a.log(Level.WARNING, "Failed to log to server.log", exception); + } + } +} diff --git a/net/minecraft/server/Entity.java b/net/minecraft/server/Entity.java new file mode 100644 index 000000000..b6727a016 --- /dev/null +++ b/net/minecraft/server/Entity.java @@ -0,0 +1,828 @@ +package net.minecraft.server; + +import java.util.List; +import java.util.Random; + +public abstract class Entity { + + private static int a = 0; + public int c; + public double d; + public boolean e; + public Entity f; + public Entity g; + protected World h; + public double i; + public double j; + public double k; + public double l; + public double m; + public double n; + public double o; + public double p; + public double q; + public float r; + public float s; + public float t; + public float u; + public final AxisAlignedBB v; + public boolean w; + public boolean x; + public boolean y; + public boolean z; + public boolean A; + public boolean B; + public float C; + public float D; + public float E; + public float F; + public float G; + protected boolean H; + protected float I; + private int b; + public double J; + public double K; + public double L; + public float M; + public float N; + public boolean O; + public float P; + public boolean Q; + protected Random R; + public int S; + public int T; + public int U; + protected int V; + protected boolean W; + public int X; + public int Y; + private boolean ad; + private double ae; + private double af; + public boolean Z; + public int aa; + public int ab; + public int ac; + + public Entity(World world) { + this.c = a++; + this.d = 1.0D; + this.e = false; + this.v = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); + this.w = false; + this.z = false; + this.A = true; + this.B = false; + this.C = 0.0F; + this.D = 0.6F; + this.E = 1.8F; + this.F = 0.0F; + this.G = 0.0F; + this.H = true; + this.I = 0.0F; + this.b = 1; + this.M = 0.0F; + this.N = 0.0F; + this.O = false; + this.P = 0.0F; + this.Q = false; + this.R = new Random(); + this.S = 0; + this.T = 1; + this.U = 0; + this.V = 300; + this.W = false; + this.X = 0; + this.Y = 300; + this.ad = true; + this.Z = false; + this.h = world; + this.a(0.0D, 0.0D, 0.0D); + } + + public boolean equals(Object object) { + return object instanceof Entity ? ((Entity) object).c == this.c : false; + } + + public int hashCode() { + return this.c; + } + + public void j() { + this.B = true; + } + + protected void a(float f, float f1) { + this.D = f; + this.E = f1; + } + + protected void b(float f, float f1) { + this.r = f; + this.s = f1; + } + + public void a(double d0, double d1, double d2) { + this.l = d0; + this.m = d1; + this.n = d2; + float f = this.D / 2.0F; + float f1 = this.E; + + this.v.c(d0 - (double) f, d1 - (double) this.C + (double) this.M, d2 - (double) f, d0 + (double) f, d1 - (double) this.C + (double) this.M + (double) f1, d2 + (double) f); + } + + public void b_() { + this.k(); + } + + public void k() { + if (this.g != null && this.g.B) { + this.g = null; + } + + ++this.S; + this.F = this.G; + this.i = this.l; + this.j = this.m; + this.k = this.n; + this.u = this.s; + this.t = this.r; + if (this.o()) { + if (!this.W && !this.ad) { + float f = MathHelper.a(this.o * this.o * 0.20000000298023224D + this.p * this.p + this.q * this.q * 0.20000000298023224D) * 0.2F; + + if (f > 1.0F) { + f = 1.0F; + } + + this.h.a(this, "random.splash", f, 1.0F + (this.R.nextFloat() - this.R.nextFloat()) * 0.4F); + float f1 = (float) MathHelper.b(this.v.b); + + int i; + float f2; + float f3; + + for (i = 0; (float) i < 1.0F + this.D * 20.0F; ++i) { + f2 = (this.R.nextFloat() * 2.0F - 1.0F) * this.D; + f3 = (this.R.nextFloat() * 2.0F - 1.0F) * this.D; + this.h.a("bubble", this.l + (double) f2, (double) (f1 + 1.0F), this.n + (double) f3, this.o, this.p - (double) (this.R.nextFloat() * 0.2F), this.q); + } + + for (i = 0; (float) i < 1.0F + this.D * 20.0F; ++i) { + f2 = (this.R.nextFloat() * 2.0F - 1.0F) * this.D; + f3 = (this.R.nextFloat() * 2.0F - 1.0F) * this.D; + this.h.a("splash", this.l + (double) f2, (double) (f1 + 1.0F), this.n + (double) f3, this.o, this.p, this.q); + } + } + + this.I = 0.0F; + this.W = true; + this.U = 0; + } else { + this.W = false; + } + + if (this.U > 0) { + if (this.U % 20 == 0) { + this.a((Entity) null, 1); + } + + --this.U; + } + + if (this.q()) { + this.a((Entity) null, 10); + this.U = 600; + } + + if (this.m < -64.0D) { + this.l(); + } + + this.ad = false; + } + + protected void l() { + this.j(); + } + + public boolean b(double d0, double d1, double d2) { + AxisAlignedBB axisalignedbb = this.v.c(d0, d1, d2); + List list = this.h.a(this, axisalignedbb); + + return list.size() > 0 ? false : !this.h.b(axisalignedbb); + } + + public void c(double d0, double d1, double d2) { + if (this.O) { + this.v.d(d0, d1, d2); + this.l = (this.v.a + this.v.d) / 2.0D; + this.m = this.v.b + (double) this.C - (double) this.M; + this.n = (this.v.c + this.v.f) / 2.0D; + } else { + double d3 = this.l; + double d4 = this.n; + double d5 = d0; + double d6 = d1; + double d7 = d2; + AxisAlignedBB axisalignedbb = this.v.b(); + boolean flag = this.w && this.m(); + + if (flag) { + double d8; + + for (d8 = 0.05D; d0 != 0.0D && this.h.a(this, this.v.c(d0, -1.0D, 0.0D)).size() == 0; d5 = d0) { + if (d0 < d8 && d0 >= -d8) { + d0 = 0.0D; + } else if (d0 > 0.0D) { + d0 -= d8; + } else { + d0 += d8; + } + } + + for (; d2 != 0.0D && this.h.a(this, this.v.c(0.0D, -1.0D, d2)).size() == 0; d7 = d2) { + if (d2 < d8 && d2 >= -d8) { + d2 = 0.0D; + } else if (d2 > 0.0D) { + d2 -= d8; + } else { + d2 += d8; + } + } + } + + List list = this.h.a(this, this.v.a(d0, d1, d2)); + + for (int i = 0; i < list.size(); ++i) { + d1 = ((AxisAlignedBB) list.get(i)).b(this.v, d1); + } + + this.v.d(0.0D, d1, 0.0D); + if (!this.A && d6 != d1) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + boolean flag1 = this.w || d6 != d1 && d6 < 0.0D; + + int j; + + for (j = 0; j < list.size(); ++j) { + d0 = ((AxisAlignedBB) list.get(j)).a(this.v, d0); + } + + this.v.d(d0, 0.0D, 0.0D); + if (!this.A && d5 != d0) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + for (j = 0; j < list.size(); ++j) { + d2 = ((AxisAlignedBB) list.get(j)).c(this.v, d2); + } + + this.v.d(0.0D, 0.0D, d2); + if (!this.A && d7 != d2) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + double d9; + double d10; + int k; + + if (this.N > 0.0F && flag1 && this.M < 0.05F && (d5 != d0 || d7 != d2)) { + d9 = d0; + d10 = d1; + double d11 = d2; + + d0 = d5; + d1 = (double) this.N; + d2 = d7; + AxisAlignedBB axisalignedbb1 = this.v.b(); + + this.v.b(axisalignedbb); + list = this.h.a(this, this.v.a(d5, d1, d7)); + + for (k = 0; k < list.size(); ++k) { + d1 = ((AxisAlignedBB) list.get(k)).b(this.v, d1); + } + + this.v.d(0.0D, d1, 0.0D); + if (!this.A && d6 != d1) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + for (k = 0; k < list.size(); ++k) { + d0 = ((AxisAlignedBB) list.get(k)).a(this.v, d0); + } + + this.v.d(d0, 0.0D, 0.0D); + if (!this.A && d5 != d0) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + for (k = 0; k < list.size(); ++k) { + d2 = ((AxisAlignedBB) list.get(k)).c(this.v, d2); + } + + this.v.d(0.0D, 0.0D, d2); + if (!this.A && d7 != d2) { + d2 = 0.0D; + d1 = 0.0D; + d0 = 0.0D; + } + + if (d9 * d9 + d11 * d11 >= d0 * d0 + d2 * d2) { + d0 = d9; + d1 = d10; + d2 = d11; + this.v.b(axisalignedbb1); + } else { + this.M = (float) ((double) this.M + 0.5D); + } + } + + this.l = (this.v.a + this.v.d) / 2.0D; + this.m = this.v.b + (double) this.C - (double) this.M; + this.n = (this.v.c + this.v.f) / 2.0D; + this.x = d5 != d0 || d7 != d2; + this.y = d6 != d1; + this.w = d6 != d1 && d6 < 0.0D; + this.z = this.x || this.y; + if (this.w) { + if (this.I > 0.0F) { + this.a(this.I); + this.I = 0.0F; + } + } else if (d1 < 0.0D) { + this.I = (float) ((double) this.I - d1); + } + + if (d5 != d0) { + this.o = 0.0D; + } + + if (d6 != d1) { + this.p = 0.0D; + } + + if (d7 != d2) { + this.q = 0.0D; + } + + d9 = this.l - d3; + d10 = this.n - d4; + this.G = (float) ((double) this.G + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); + int l; + int i1; + int j1; + + if (this.H && !flag) { + l = MathHelper.b(this.l); + i1 = MathHelper.b(this.m - 0.20000000298023224D - (double) this.C); + j1 = MathHelper.b(this.n); + k = this.h.a(l, i1, j1); + if (this.G > (float) this.b && k > 0) { + ++this.b; + StepSound stepsound = Block.n[k].bl; + + if (this.h.a(l, i1 + 1, j1) == Block.SNOW.bc) { + stepsound = Block.SNOW.bl; + this.h.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); + } else if (!Block.n[k].bn.d()) { + this.h.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); + } + + Block.n[k].b(this.h, l, i1, j1, this); + } + } + + l = MathHelper.b(this.v.a); + i1 = MathHelper.b(this.v.b); + j1 = MathHelper.b(this.v.c); + k = MathHelper.b(this.v.d); + int k1 = MathHelper.b(this.v.e); + int l1 = MathHelper.b(this.v.f); + + for (int i2 = l; i2 <= k; ++i2) { + for (int j2 = i1; j2 <= k1; ++j2) { + for (int k2 = j1; k2 <= l1; ++k2) { + int l2 = this.h.a(i2, j2, k2); + + if (l2 > 0) { + Block.n[l2].a(this.h, i2, j2, k2, this); + } + } + } + } + + this.M *= 0.4F; + boolean flag2 = this.o(); + + if (this.h.c(this.v)) { + this.b(1); + if (!flag2) { + ++this.U; + if (this.U == 0) { + this.U = 300; + } + } + } else if (this.U <= 0) { + this.U = -this.T; + } + + if (flag2 && this.U > 0) { + this.h.a(this, "random.fizz", 0.7F, 1.6F + (this.R.nextFloat() - this.R.nextFloat()) * 0.4F); + this.U = -this.T; + } + } + } + + public boolean m() { + return false; + } + + public AxisAlignedBB n() { + return null; + } + + protected void b(int i) { + this.a((Entity) null, i); + } + + protected void a(float f) {} + + public boolean o() { + return this.h.a(this.v.b(0.0D, -0.4000000059604645D, 0.0D), Material.f, this); + } + + public boolean a(Material material) { + double d0 = this.m + (double) this.p(); + int i = MathHelper.b(this.l); + int j = MathHelper.d((float) MathHelper.b(d0)); + int k = MathHelper.b(this.n); + int l = this.h.a(i, j, k); + + if (l != 0 && Block.n[l].bn == material) { + float f = BlockFluids.b(this.h.b(i, j, k)) - 0.11111111F; + float f1 = (float) (j + 1) - f; + + return d0 < (double) f1; + } else { + return false; + } + } + + protected float p() { + return 0.0F; + } + + public boolean q() { + return this.h.a(this.v.b(0.0D, -0.4000000059604645D, 0.0D), Material.g); + } + + public void a(float f, float f1, float f2) { + float f3 = MathHelper.c(f * f + f1 * f1); + + if (f3 >= 0.01F) { + if (f3 < 1.0F) { + f3 = 1.0F; + } + + f3 = f2 / f3; + f *= f3; + f1 *= f3; + float f4 = MathHelper.a(this.r * 3.1415927F / 180.0F); + float f5 = MathHelper.b(this.r * 3.1415927F / 180.0F); + + this.o += (double) (f * f5 - f1 * f4); + this.q += (double) (f1 * f5 + f * f4); + } + } + + public float b(float f) { + int i = MathHelper.b(this.l); + double d0 = (this.v.e - this.v.b) * 0.66D; + int j = MathHelper.b(this.m - (double) this.C + d0); + int k = MathHelper.b(this.n); + + return this.h.j(i, j, k); + } + + public void b(double d0, double d1, double d2, float f, float f1) { + this.i = this.l = d0; + this.j = this.m = d1; + this.k = this.n = d2; + this.r = f; + this.s = f1; + this.M = 0.0F; + double d3 = (double) (this.t - f); + + if (d3 < -180.0D) { + this.t += 360.0F; + } + + if (d3 >= 180.0D) { + this.t -= 360.0F; + } + + this.a(this.l, this.m, this.n); + } + + public void c(double d0, double d1, double d2, float f, float f1) { + this.i = this.l = d0; + this.j = this.m = d1 + (double) this.C; + this.k = this.n = d2; + this.r = f; + this.s = f1; + this.a(this.l, this.m, this.n); + } + + public float a(Entity entity) { + float f = (float) (this.l - entity.l); + float f1 = (float) (this.m - entity.m); + float f2 = (float) (this.n - entity.n); + + return MathHelper.c(f * f + f1 * f1 + f2 * f2); + } + + public double d(double d0, double d1, double d2) { + double d3 = this.l - d0; + double d4 = this.m - d1; + double d5 = this.n - d2; + + return d3 * d3 + d4 * d4 + d5 * d5; + } + + public double e(double d0, double d1, double d2) { + double d3 = this.l - d0; + double d4 = this.m - d1; + double d5 = this.n - d2; + + return (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5); + } + + public double b(Entity entity) { + double d0 = this.l - entity.l; + double d1 = this.m - entity.m; + double d2 = this.n - entity.n; + + return d0 * d0 + d1 * d1 + d2 * d2; + } + + public void a(EntityHuman entityhuman) {} + + public void c(Entity entity) { + if (entity.f != this && entity.g != this) { + double d0 = entity.l - this.l; + double d1 = entity.n - this.n; + double d2 = MathHelper.a(d0, d1); + + if (d2 >= 0.009999999776482582D) { + d2 = (double) MathHelper.a(d2); + d0 /= d2; + d1 /= d2; + double d3 = 1.0D / d2; + + if (d3 > 1.0D) { + d3 = 1.0D; + } + + d0 *= d3; + d1 *= d3; + d0 *= 0.05000000074505806D; + d1 *= 0.05000000074505806D; + d0 *= (double) (1.0F - this.P); + d1 *= (double) (1.0F - this.P); + this.f(-d0, 0.0D, -d1); + entity.f(d0, 0.0D, d1); + } + } + } + + public void f(double d0, double d1, double d2) { + this.o += d0; + this.p += d1; + this.q += d2; + } + + public boolean a(Entity entity, int i) { + return false; + } + + public boolean c_() { + return false; + } + + public boolean r() { + return false; + } + + public void b(Entity entity, int i) {} + + public boolean c(NBTTagCompound nbttagcompound) { + String s = this.s(); + + if (!this.B && s != null) { + nbttagcompound.a("id", s); + this.d(nbttagcompound); + return true; + } else { + return false; + } + } + + public void d(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.l, this.m, this.n})); + nbttagcompound.a("Motion", (NBTBase) this.a(new double[] { this.o, this.p, this.q})); + nbttagcompound.a("Rotation", (NBTBase) this.a(new float[] { this.r, this.s})); + nbttagcompound.a("FallDistance", this.I); + nbttagcompound.a("Fire", (short) this.U); + nbttagcompound.a("Air", (short) this.Y); + nbttagcompound.a("OnGround", this.w); + this.a(nbttagcompound); + } + + public void e(NBTTagCompound nbttagcompound) { + NBTTagList nbttaglist = nbttagcompound.k("Pos"); + NBTTagList nbttaglist1 = nbttagcompound.k("Motion"); + NBTTagList nbttaglist2 = nbttagcompound.k("Rotation"); + + this.a(0.0D, 0.0D, 0.0D); + this.o = ((NBTTagDouble) nbttaglist1.a(0)).a; + this.p = ((NBTTagDouble) nbttaglist1.a(1)).a; + this.q = ((NBTTagDouble) nbttaglist1.a(2)).a; + this.i = this.J = this.l = ((NBTTagDouble) nbttaglist.a(0)).a; + this.j = this.K = this.m = ((NBTTagDouble) nbttaglist.a(1)).a; + this.k = this.L = this.n = ((NBTTagDouble) nbttaglist.a(2)).a; + this.t = this.r = ((NBTTagFloat) nbttaglist2.a(0)).a; + this.u = this.s = ((NBTTagFloat) nbttaglist2.a(1)).a; + this.I = nbttagcompound.f("FallDistance"); + this.U = nbttagcompound.c("Fire"); + this.Y = nbttagcompound.c("Air"); + this.w = nbttagcompound.l("OnGround"); + this.a(this.l, this.m, this.n); + this.b(nbttagcompound); + } + + protected final String s() { + return EntityTypes.b(this); + } + + protected abstract void b(NBTTagCompound nbttagcompound); + + protected abstract void a(NBTTagCompound nbttagcompound); + + protected NBTTagList a(double... adouble) { + NBTTagList nbttaglist = new NBTTagList(); + double[] adouble1 = adouble; + int i = adouble.length; + + for (int j = 0; j < i; ++j) { + double d0 = adouble1[j]; + + nbttaglist.a((NBTBase) (new NBTTagDouble(d0))); + } + + return nbttaglist; + } + + protected NBTTagList a(float... afloat) { + NBTTagList nbttaglist = new NBTTagList(); + float[] afloat1 = afloat; + int i = afloat.length; + + for (int j = 0; j < i; ++j) { + float f = afloat1[j]; + + nbttaglist.a((NBTBase) (new NBTTagFloat(f))); + } + + return nbttaglist; + } + + public EntityItem a(int i, int j) { + return this.a(i, j, 0.0F); + } + + public EntityItem a(int i, int j, float f) { + EntityItem entityitem = new EntityItem(this.h, this.l, this.m + (double) f, this.n, new ItemStack(i, j)); + + entityitem.ad = 10; + this.h.a((Entity) entityitem); + return entityitem; + } + + public boolean t() { + return !this.B; + } + + public boolean u() { + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.m + (double) this.p()); + int k = MathHelper.b(this.n); + + return this.h.d(i, j, k); + } + + public AxisAlignedBB d(Entity entity) { + return null; + } + + public void v() { + if (this.g.B) { + this.g = null; + } else { + this.o = 0.0D; + this.p = 0.0D; + this.q = 0.0D; + this.b_(); + this.g.w(); + this.af += (double) (this.g.r - this.g.t); + + for (this.ae += (double) (this.g.s - this.g.u); this.af >= 180.0D; this.af -= 360.0D) { + ; + } + + while (this.af < -180.0D) { + this.af += 360.0D; + } + + while (this.ae >= 180.0D) { + this.ae -= 360.0D; + } + + while (this.ae < -180.0D) { + this.ae += 360.0D; + } + + double d0 = this.af * 0.5D; + double d1 = this.ae * 0.5D; + float f = 10.0F; + + if (d0 > (double) f) { + d0 = (double) f; + } + + if (d0 < (double) (-f)) { + d0 = (double) (-f); + } + + if (d1 > (double) f) { + d1 = (double) f; + } + + if (d1 < (double) (-f)) { + d1 = (double) (-f); + } + + this.af -= d0; + this.ae -= d1; + this.r = (float) ((double) this.r + d0); + this.s = (float) ((double) this.s + d1); + } + } + + protected void w() { + this.f.a(this.l, this.m + this.h() + this.f.x(), this.n); + } + + public double x() { + return (double) this.C; + } + + public double h() { + return (double) this.E * 0.75D; + } + + public void e(Entity entity) { + this.ae = 0.0D; + this.af = 0.0D; + if (this.g == entity) { + this.g.f = null; + this.g = null; + this.c(entity.l, entity.v.b + (double) entity.E, entity.n, this.r, this.s); + } else { + if (this.g != null) { + this.g.f = null; + } + + if (entity.f != null) { + entity.f.g = null; + } + + this.g = entity; + entity.f = this; + } + } +} diff --git a/net/minecraft/server/EntityAnimal.java b/net/minecraft/server/EntityAnimal.java new file mode 100644 index 000000000..51a6d0389 --- /dev/null +++ b/net/minecraft/server/EntityAnimal.java @@ -0,0 +1,32 @@ +package net.minecraft.server; + +public abstract class EntityAnimal extends EntityCreature implements IAnimal { + + public EntityAnimal(World world) { + super(world); + } + + protected float a(int i, int j, int k) { + return this.h.a(i, j - 1, k) == Block.GRASS.bc ? 10.0F : this.h.j(i, j, k) - 0.5F; + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + public boolean a() { + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.v.b); + int k = MathHelper.b(this.n); + + return this.h.a(i, j - 1, k) == Block.GRASS.bc && this.h.h(i, j, k) > 8 && super.a(); + } + + public int b() { + return 120; + } +} diff --git a/net/minecraft/server/EntityArrow.java b/net/minecraft/server/EntityArrow.java new file mode 100644 index 000000000..77f03ad8c --- /dev/null +++ b/net/minecraft/server/EntityArrow.java @@ -0,0 +1,229 @@ +package net.minecraft.server; + +import java.util.List; + +public class EntityArrow extends Entity { + + private int b = -1; + private int ad = -1; + private int ae = -1; + private int af = 0; + private boolean ag = false; + public int a = 0; + private EntityLiving ah; + private int ai; + private int aj = 0; + + public EntityArrow(World world) { + super(world); + this.a(0.5F, 0.5F); + } + + public EntityArrow(World world, EntityLiving entityliving) { + super(world); + this.ah = entityliving; + this.a(0.5F, 0.5F); + this.c(entityliving.l, entityliving.m, entityliving.n, entityliving.r, entityliving.s); + this.l -= (double) (MathHelper.b(this.r / 180.0F * 3.1415927F) * 0.16F); + this.m -= 0.10000000149011612D; + this.n -= (double) (MathHelper.a(this.r / 180.0F * 3.1415927F) * 0.16F); + this.a(this.l, this.m, this.n); + this.C = 0.0F; + this.o = (double) (-MathHelper.a(this.r / 180.0F * 3.1415927F) * MathHelper.b(this.s / 180.0F * 3.1415927F)); + this.q = (double) (MathHelper.b(this.r / 180.0F * 3.1415927F) * MathHelper.b(this.s / 180.0F * 3.1415927F)); + this.p = (double) (-MathHelper.a(this.s / 180.0F * 3.1415927F)); + this.a(this.o, this.p, this.q, 1.5F, 1.0F); + } + + public void a(double d0, double d1, double d2, float f, float f1) { + float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); + + d0 /= (double) f2; + d1 /= (double) f2; + d2 /= (double) f2; + d0 += this.R.nextGaussian() * 0.007499999832361937D * (double) f1; + d1 += this.R.nextGaussian() * 0.007499999832361937D * (double) f1; + d2 += this.R.nextGaussian() * 0.007499999832361937D * (double) f1; + d0 *= (double) f; + d1 *= (double) f; + d2 *= (double) f; + this.o = d0; + this.p = d1; + this.q = d2; + float f3 = MathHelper.a(d0 * d0 + d2 * d2); + + this.t = this.r = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); + this.u = this.s = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); + this.ai = 0; + } + + public void b_() { + super.b_(); + if (this.a > 0) { + --this.a; + } + + if (this.ag) { + int i = this.h.a(this.b, this.ad, this.ae); + + if (i == this.af) { + ++this.ai; + if (this.ai == 1200) { + this.j(); + } + + return; + } + + this.ag = false; + this.o *= (double) (this.R.nextFloat() * 0.2F); + this.p *= (double) (this.R.nextFloat() * 0.2F); + this.q *= (double) (this.R.nextFloat() * 0.2F); + this.ai = 0; + this.aj = 0; + } else { + ++this.aj; + } + + Vec3D vec3d = Vec3D.b(this.l, this.m, this.n); + Vec3D vec3d1 = Vec3D.b(this.l + this.o, this.m + this.p, this.n + this.q); + MovingObjectPosition movingobjectposition = this.h.a(vec3d, vec3d1); + + vec3d = Vec3D.b(this.l, this.m, this.n); + vec3d1 = Vec3D.b(this.l + this.o, this.m + this.p, this.n + this.q); + if (movingobjectposition != null) { + vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); + } + + Entity entity = null; + List list = this.h.b((Entity) this, this.v.a(this.o, this.p, this.q).b(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + + float f; + + for (int j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if (entity1.c_() && (entity1 != this.ah || this.aj >= 5)) { + f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.v.b((double) f, (double) f, (double) f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); + + if (movingobjectposition1 != null) { + double d1 = vec3d.a(movingobjectposition1.f); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + float f1; + + if (movingobjectposition != null) { + if (movingobjectposition.g != null) { + if (movingobjectposition.g.a(this.ah, 4)) { + this.h.a(this, "random.drr", 1.0F, 1.2F / (this.R.nextFloat() * 0.2F + 0.9F)); + this.j(); + } else { + this.o *= -0.10000000149011612D; + this.p *= -0.10000000149011612D; + this.q *= -0.10000000149011612D; + this.r += 180.0F; + this.t += 180.0F; + this.aj = 0; + } + } else { + this.b = movingobjectposition.b; + this.ad = movingobjectposition.c; + this.ae = movingobjectposition.d; + this.af = this.h.a(this.b, this.ad, this.ae); + this.o = (double) ((float) (movingobjectposition.f.a - this.l)); + this.p = (double) ((float) (movingobjectposition.f.b - this.m)); + this.q = (double) ((float) (movingobjectposition.f.c - this.n)); + f1 = MathHelper.a(this.o * this.o + this.p * this.p + this.q * this.q); + this.l -= this.o / (double) f1 * 0.05000000074505806D; + this.m -= this.p / (double) f1 * 0.05000000074505806D; + this.n -= this.q / (double) f1 * 0.05000000074505806D; + this.h.a(this, "random.drr", 1.0F, 1.2F / (this.R.nextFloat() * 0.2F + 0.9F)); + this.ag = true; + this.a = 7; + } + } + + this.l += this.o; + this.m += this.p; + this.n += this.q; + f1 = MathHelper.a(this.o * this.o + this.q * this.q); + this.r = (float) (Math.atan2(this.o, this.q) * 180.0D / 3.1415927410125732D); + + for (this.s = (float) (Math.atan2(this.p, (double) f1) * 180.0D / 3.1415927410125732D); this.s - this.u < -180.0F; this.u -= 360.0F) { + ; + } + + while (this.s - this.u >= 180.0F) { + this.u += 360.0F; + } + + while (this.r - this.t < -180.0F) { + this.t -= 360.0F; + } + + while (this.r - this.t >= 180.0F) { + this.t += 360.0F; + } + + this.s = this.u + (this.s - this.u) * 0.2F; + this.r = this.t + (this.r - this.t) * 0.2F; + float f2 = 0.99F; + + f = 0.03F; + if (this.o()) { + for (int k = 0; k < 4; ++k) { + float f3 = 0.25F; + + this.h.a("bubble", this.l - this.o * (double) f3, this.m - this.p * (double) f3, this.n - this.q * (double) f3, this.o, this.p, this.q); + } + + f2 = 0.8F; + } + + this.o *= (double) f2; + this.p *= (double) f2; + this.q *= (double) f2; + this.p -= (double) f; + this.a(this.l, this.m, this.n); + } + + public void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("xTile", (short) this.b); + nbttagcompound.a("yTile", (short) this.ad); + nbttagcompound.a("zTile", (short) this.ae); + nbttagcompound.a("inTile", (byte) this.af); + nbttagcompound.a("shake", (byte) this.a); + nbttagcompound.a("inGround", (byte) (this.ag ? 1 : 0)); + } + + public void b(NBTTagCompound nbttagcompound) { + this.b = nbttagcompound.c("xTile"); + this.ad = nbttagcompound.c("yTile"); + this.ae = nbttagcompound.c("zTile"); + this.af = nbttagcompound.b("inTile") & 255; + this.a = nbttagcompound.b("shake") & 255; + this.ag = nbttagcompound.b("inGround") == 1; + } + + public void a(EntityHuman entityhuman) { + if (this.ag && this.ah == entityhuman && this.a <= 0 && entityhuman.aj.a(new ItemStack(Item.ARROW.aS, 1))) { + this.h.a(this, "random.pop", 0.2F, ((this.R.nextFloat() - this.R.nextFloat()) * 0.7F + 1.0F) * 2.0F); + entityhuman.c(this, 1); + this.j(); + } + } +} diff --git a/net/minecraft/server/EntityBoat.java b/net/minecraft/server/EntityBoat.java new file mode 100644 index 000000000..dd0508296 --- /dev/null +++ b/net/minecraft/server/EntityBoat.java @@ -0,0 +1,219 @@ +package net.minecraft.server; + +import java.util.List; + +public class EntityBoat extends Entity { + + public int a = 0; + public int b = 0; + public int ad = 1; + + public EntityBoat(World world) { + super(world); + this.e = true; + this.a(1.5F, 0.6F); + this.C = this.E / 2.0F; + this.H = false; + } + + public AxisAlignedBB d(Entity entity) { + return entity.v; + } + + public AxisAlignedBB n() { + return this.v; + } + + public boolean r() { + return true; + } + + public double h() { + return (double) this.E * 0.0D - 0.30000001192092896D; + } + + public boolean a(Entity entity, int i) { + this.ad = -this.ad; + this.b = 10; + this.a += i * 10; + if (this.a > 40) { + int j; + + for (j = 0; j < 3; ++j) { + this.a(Block.WOOD.bc, 1, 0.0F); + } + + for (j = 0; j < 2; ++j) { + this.a(Item.STICK.aS, 1, 0.0F); + } + + this.j(); + } + + return true; + } + + public boolean c_() { + return !this.B; + } + + public void b_() { + super.b_(); + if (this.b > 0) { + --this.b; + } + + if (this.a > 0) { + --this.a; + } + + this.i = this.l; + this.j = this.m; + this.k = this.n; + byte b0 = 5; + double d0 = 0.0D; + + for (int i = 0; i < b0; ++i) { + double d1 = this.v.b + (this.v.e - this.v.b) * (double) (i + 0) / (double) b0 - 0.125D; + double d2 = this.v.b + (this.v.e - this.v.b) * (double) (i + 1) / (double) b0 - 0.125D; + AxisAlignedBB axisalignedbb = AxisAlignedBB.b(this.v.a, d1, this.v.c, this.v.d, d2, this.v.f); + + if (this.h.b(axisalignedbb, Material.f)) { + d0 += 1.0D / (double) b0; + } + } + + double d3 = d0 * 2.0D - 1.0D; + + this.p += 0.03999999910593033D * d3; + if (this.f != null) { + this.o += this.f.o * 0.2D; + this.q += this.f.q * 0.2D; + } + + double d4 = 0.4D; + + if (this.o < -d4) { + this.o = -d4; + } + + if (this.o > d4) { + this.o = d4; + } + + if (this.q < -d4) { + this.q = -d4; + } + + if (this.q > d4) { + this.q = d4; + } + + if (this.w) { + this.o *= 0.5D; + this.p *= 0.5D; + this.q *= 0.5D; + } + + this.c(this.o, this.p, this.q); + double d5 = Math.sqrt(this.o * this.o + this.q * this.q); + double d6; + double d7; + + if (d5 > 0.15D) { + d6 = Math.cos((double) this.r * 3.141592653589793D / 180.0D); + d7 = Math.sin((double) this.r * 3.141592653589793D / 180.0D); + + for (int j = 0; (double) j < 1.0D + d5 * 60.0D; ++j) { + double d8 = (double) (this.R.nextFloat() * 2.0F - 1.0F); + double d9 = (double) (this.R.nextInt(2) * 2 - 1) * 0.7D; + double d10; + double d11; + + if (this.R.nextBoolean()) { + d10 = this.l - d6 * d8 * 0.8D + d7 * d9; + d11 = this.n - d7 * d8 * 0.8D - d6 * d9; + this.h.a("splash", d10, this.m - 0.125D, d11, this.o, this.p, this.q); + } else { + d10 = this.l + d6 + d7 * d8 * 0.7D; + d11 = this.n + d7 - d6 * d8 * 0.7D; + this.h.a("splash", d10, this.m - 0.125D, d11, this.o, this.p, this.q); + } + } + } + + if (this.x && d5 > 0.15D) { + this.j(); + + int k; + + for (k = 0; k < 3; ++k) { + this.a(Block.WOOD.bc, 1, 0.0F); + } + + for (k = 0; k < 2; ++k) { + this.a(Item.STICK.aS, 1, 0.0F); + } + } else { + this.o *= 0.9900000095367432D; + this.p *= 0.949999988079071D; + this.q *= 0.9900000095367432D; + } + + this.s = 0.0F; + d6 = (double) this.r; + d7 = this.i - this.l; + double d12 = this.k - this.n; + + if (d7 * d7 + d12 * d12 > 0.0010D) { + d6 = (double) ((float) (Math.atan2(d12, d7) * 180.0D / 3.141592653589793D)); + } + + double d13; + + for (d13 = d6 - (double) this.r; d13 >= 180.0D; d13 -= 360.0D) { + ; + } + + while (d13 < -180.0D) { + d13 += 360.0D; + } + + if (d13 > 20.0D) { + d13 = 20.0D; + } + + if (d13 < -20.0D) { + d13 = -20.0D; + } + + this.r = (float) ((double) this.r + d13); + this.b(this.r, this.s); + List list = this.h.b((Entity) this, this.v.b(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + + if (list != null && list.size() > 0) { + for (int l = 0; l < list.size(); ++l) { + Entity entity = (Entity) list.get(l); + + if (entity != this.f && entity.r() && entity instanceof EntityBoat) { + entity.c((Entity) this); + } + } + } + + if (this.f != null && this.f.B) { + this.f = null; + } + } + + protected void w() { + double d0 = Math.cos((double) this.r * 3.141592653589793D / 180.0D) * 0.4D; + double d1 = Math.sin((double) this.r * 3.141592653589793D / 180.0D) * 0.4D; + + this.f.a(this.l + d0, this.m + this.h() + this.f.x(), this.n + d1); + } + + protected void a(NBTTagCompound nbttagcompound) {} + + protected void b(NBTTagCompound nbttagcompound) {} +} diff --git a/net/minecraft/server/EntityChicken.java b/net/minecraft/server/EntityChicken.java new file mode 100644 index 000000000..29a15614a --- /dev/null +++ b/net/minecraft/server/EntityChicken.java @@ -0,0 +1,76 @@ +package net.minecraft.server; + +public class EntityChicken extends EntityAnimal { + + public boolean a = false; + public float b = 0.0F; + public float ad = 0.0F; + public float ae; + public float af; + public float ai = 1.0F; + public int aj; + + public EntityChicken(World world) { + super(world); + this.aC = "/mob/chicken.png"; + this.a(0.3F, 0.4F); + this.aM = 4; + this.aj = this.R.nextInt(6000) + 6000; + } + + public void y() { + super.y(); + this.af = this.b; + this.ae = this.ad; + this.ad = (float) ((double) this.ad + (double) (this.w ? -1 : 4) * 0.3D); + if (this.ad < 0.0F) { + this.ad = 0.0F; + } + + if (this.ad > 1.0F) { + this.ad = 1.0F; + } + + if (!this.w && this.ai < 1.0F) { + this.ai = 1.0F; + } + + this.ai = (float) ((double) this.ai * 0.9D); + if (!this.w && this.p < 0.0D) { + this.p *= 0.6D; + } + + this.b += this.ai * 2.0F; + if (!this.h.x && --this.aj <= 0) { + this.h.a(this, "mob.chickenplop", 1.0F, (this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F); + this.a(Item.EGG.aS, 1); + this.aj = this.R.nextInt(6000) + 6000; + } + } + + protected void a(float f) {} + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + protected String c() { + return "mob.chicken"; + } + + protected String d() { + return "mob.chickenhurt"; + } + + protected String e() { + return "mob.chickenhurt"; + } + + protected int g() { + return Item.FEATHER.aS; + } +} diff --git a/net/minecraft/server/EntityCow.java b/net/minecraft/server/EntityCow.java new file mode 100644 index 000000000..88dd67440 --- /dev/null +++ b/net/minecraft/server/EntityCow.java @@ -0,0 +1,40 @@ +package net.minecraft.server; + +public class EntityCow extends EntityAnimal { + + public boolean a = false; + + public EntityCow(World world) { + super(world); + this.aC = "/mob/cow.png"; + this.a(0.9F, 1.3F); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + protected String c() { + return "mob.cow"; + } + + protected String d() { + return "mob.cowhurt"; + } + + protected String e() { + return "mob.cowhurt"; + } + + protected float f() { + return 0.4F; + } + + protected int g() { + return Item.LEATHER.aS; + } +} diff --git a/net/minecraft/server/EntityCreature.java b/net/minecraft/server/EntityCreature.java new file mode 100644 index 000000000..459905a68 --- /dev/null +++ b/net/minecraft/server/EntityCreature.java @@ -0,0 +1,155 @@ +package net.minecraft.server; + +public class EntityCreature extends EntityLiving { + + private PathEntity a; + protected Entity ag; + protected boolean ah = false; + + public EntityCreature(World world) { + super(world); + } + + protected void d_() { + this.ah = false; + float f = 16.0F; + + if (this.ag == null) { + this.ag = this.i(); + if (this.ag != null) { + this.a = this.h.a(this, this.ag, f); + } + } else if (!this.ag.t()) { + this.ag = null; + } else { + float f1 = this.ag.a((Entity) this); + + if (this.g(this.ag)) { + this.a(this.ag, f1); + } + } + + if (!this.ah && this.ag != null && (this.a == null || this.R.nextInt(20) == 0)) { + this.a = this.h.a(this, this.ag, f); + } else if (this.a == null && this.R.nextInt(80) == 0 || this.R.nextInt(80) == 0) { + boolean flag = false; + int i = -1; + int j = -1; + int k = -1; + float f2 = -99999.0F; + + for (int l = 0; l < 10; ++l) { + int i1 = MathHelper.b(this.l + (double) this.R.nextInt(13) - 6.0D); + int j1 = MathHelper.b(this.m + (double) this.R.nextInt(7) - 3.0D); + int k1 = MathHelper.b(this.n + (double) this.R.nextInt(13) - 6.0D); + float f3 = this.a(i1, j1, k1); + + if (f3 > f2) { + f2 = f3; + i = i1; + j = j1; + k = k1; + flag = true; + } + } + + if (flag) { + this.a = this.h.a(this, i, j, k, 10.0F); + } + } + + int l1 = MathHelper.b(this.v.b); + boolean flag1 = this.o(); + boolean flag2 = this.q(); + + this.s = 0.0F; + if (this.a != null && this.R.nextInt(100) != 0) { + Vec3D vec3d = this.a.a(this); + double d0 = (double) (this.D * 2.0F); + + while (vec3d != null && vec3d.d(this.l, vec3d.b, this.n) < d0 * d0) { + this.a.a(); + if (this.a.b()) { + vec3d = null; + this.a = null; + } else { + vec3d = this.a.a(this); + } + } + + this.bg = false; + if (vec3d != null) { + double d1 = vec3d.a - this.l; + double d2 = vec3d.c - this.n; + double d3 = vec3d.b - (double) l1; + float f4 = (float) (Math.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F; + float f5 = f4 - this.r; + + for (this.be = this.bi; f5 < -180.0F; f5 += 360.0F) { + ; + } + + while (f5 >= 180.0F) { + f5 -= 360.0F; + } + + if (f5 > 30.0F) { + f5 = 30.0F; + } + + if (f5 < -30.0F) { + f5 = -30.0F; + } + + this.r += f5; + if (this.ah && this.ag != null) { + double d4 = this.ag.l - this.l; + double d5 = this.ag.n - this.n; + float f6 = this.r; + + this.r = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F; + f5 = (f6 - this.r + 90.0F) * 3.1415927F / 180.0F; + this.bd = -MathHelper.a(f5) * this.be * 1.0F; + this.be = MathHelper.b(f5) * this.be * 1.0F; + } + + if (d3 > 0.0D) { + this.bg = true; + } + } + + if (this.ag != null) { + this.b(this.ag, 30.0F); + } + + if (this.x) { + this.bg = true; + } + + if (this.R.nextFloat() < 0.8F && (flag1 || flag2)) { + this.bg = true; + } + } else { + super.d_(); + this.a = null; + } + } + + protected void a(Entity entity, float f) {} + + protected float a(int i, int j, int k) { + return 0.0F; + } + + protected Entity i() { + return null; + } + + public boolean a() { + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.v.b); + int k = MathHelper.b(this.n); + + return super.a() && this.a(i, j, k) >= 0.0F; + } +} diff --git a/net/minecraft/server/EntityCreeper.java b/net/minecraft/server/EntityCreeper.java new file mode 100644 index 000000000..59b43246b --- /dev/null +++ b/net/minecraft/server/EntityCreeper.java @@ -0,0 +1,74 @@ +package net.minecraft.server; + +public class EntityCreeper extends EntityMonster { + + int a; + int b; + int ad = 30; + int ae = -1; + + public EntityCreeper(World world) { + super(world); + this.aC = "/mob/creeper.png"; + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + protected void d_() { + this.b = this.a; + if (this.a > 0 && this.ae < 0) { + --this.a; + } + + if (this.ae >= 0) { + this.ae = 2; + } + + super.d_(); + if (this.ae != 1) { + this.ae = -1; + } + } + + protected String d() { + return "mob.creeper"; + } + + protected String e() { + return "mob.creeperdeath"; + } + + public void f(Entity entity) { + super.f(entity); + if (entity instanceof EntitySkeleton) { + this.a(Item.GOLD_RECORD.aS + this.R.nextInt(2), 1); + } + } + + protected void a(Entity entity, float f) { + if (this.ae <= 0 && f < 3.0F || this.ae > 0 && f < 7.0F) { + if (this.a == 0) { + this.h.a(this, "random.fuse", 1.0F, 0.5F); + } + + this.ae = 1; + ++this.a; + if (this.a == this.ad) { + this.h.a(this, this.l, this.m, this.n, 3.0F); + this.j(); + } + + this.ah = true; + } + } + + protected int g() { + return Item.SULPHUR.aS; + } +} diff --git a/net/minecraft/server/EntityFallingSand.java b/net/minecraft/server/EntityFallingSand.java new file mode 100644 index 000000000..02dd7e1fb --- /dev/null +++ b/net/minecraft/server/EntityFallingSand.java @@ -0,0 +1,75 @@ +package net.minecraft.server; + +public class EntityFallingSand extends Entity { + + public int a; + public int b = 0; + + public EntityFallingSand(World world) { + super(world); + } + + public EntityFallingSand(World world, float f, float f1, float f2, int i) { + super(world); + this.a = i; + this.e = true; + this.a(0.98F, 0.98F); + this.C = this.E / 2.0F; + this.a((double) f, (double) f1, (double) f2); + this.o = 0.0D; + this.p = 0.0D; + this.q = 0.0D; + this.H = false; + this.i = (double) f; + this.j = (double) f1; + this.k = (double) f2; + } + + public boolean c_() { + return !this.B; + } + + public void b_() { + if (this.a == 0) { + this.j(); + } else { + this.i = this.l; + this.j = this.m; + this.k = this.n; + ++this.b; + this.p -= 0.03999999910593033D; + this.c(this.o, this.p, this.q); + this.o *= 0.9800000190734863D; + this.p *= 0.9800000190734863D; + this.q *= 0.9800000190734863D; + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.m); + int k = MathHelper.b(this.n); + + if (this.h.a(i, j, k) == this.a) { + this.h.d(i, j, k, 0); + } + + if (this.w) { + this.o *= 0.699999988079071D; + this.q *= 0.699999988079071D; + this.p *= -0.5D; + this.j(); + if (!this.h.a(this.a, i, j, k, true) || !this.h.d(i, j, k, this.a)) { + this.a(this.a, 1); + } + } else if (this.b > 100) { + this.a(this.a, 1); + this.j(); + } + } + } + + protected void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Tile", (byte) this.a); + } + + protected void b(NBTTagCompound nbttagcompound) { + this.a = nbttagcompound.b("Tile") & 255; + } +} diff --git a/net/minecraft/server/EntityGiantZombie.java b/net/minecraft/server/EntityGiantZombie.java new file mode 100644 index 000000000..c51df1d7b --- /dev/null +++ b/net/minecraft/server/EntityGiantZombie.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +public class EntityGiantZombie extends EntityMonster { + + public EntityGiantZombie(World world) { + super(world); + this.aC = "/mob/zombie.png"; + this.bi = 0.5F; + this.af = 50; + this.aM *= 10; + this.C *= 6.0F; + this.a(this.D * 6.0F, this.E * 6.0F); + } + + protected float a(int i, int j, int k) { + return this.h.j(i, j, k) - 0.5F; + } +} diff --git a/net/minecraft/server/EntityHuman.java b/net/minecraft/server/EntityHuman.java new file mode 100644 index 000000000..d175ca56f --- /dev/null +++ b/net/minecraft/server/EntityHuman.java @@ -0,0 +1,242 @@ +package net.minecraft.server; + +import java.util.List; + +public class EntityHuman extends EntityLiving { + + public InventoryPlayer aj = new InventoryPlayer(this); + public byte ak = 0; + public int al = 0; + public float am; + public float an; + public boolean ao = false; + public int ap = 0; + public String aq; + private int a = 0; + + public EntityHuman(World world) { + super(world); + this.C = 1.62F; + this.c((double) world.n + 0.5D, (double) (world.o + 1), (double) world.p + 0.5D, 0.0F, 0.0F); + this.aM = 20; + this.aF = "humanoid"; + this.aE = 180.0F; + this.T = 20; + this.aC = "/char.png"; + } + + public void v() { + super.v(); + this.am = this.an; + this.an = 0.0F; + } + + protected void d_() { + if (this.ao) { + ++this.ap; + if (this.ap == 8) { + this.ap = 0; + this.ao = false; + } + } else { + this.ap = 0; + } + + this.aL = (float) this.ap / 8.0F; + } + + public void y() { + if (this.h.l == 0 && this.aM < 20 && this.S % 20 * 4 == 0) { + this.a(1); + } + + this.aj.c(); + this.am = this.an; + super.y(); + float f = MathHelper.a(this.o * this.o + this.q * this.q); + float f1 = (float) Math.atan(-this.p * 0.20000000298023224D) * 15.0F; + + if (f > 0.1F) { + f = 0.1F; + } + + if (!this.w || this.aM <= 0) { + f = 0.0F; + } + + if (this.w || this.aM <= 0) { + f1 = 0.0F; + } + + this.an += (f - this.an) * 0.4F; + this.aU += (f1 - this.aU) * 0.8F; + if (this.aM > 0) { + List list = this.h.b((Entity) this, this.v.b(1.0D, 0.0D, 1.0D)); + + if (list != null) { + for (int i = 0; i < list.size(); ++i) { + this.h((Entity) list.get(i)); + } + } + } + } + + private void h(Entity entity) { + entity.a(this); + } + + public void f(Entity entity) { + this.a(0.2F, 0.2F); + this.a(this.l, this.m, this.n); + this.p = 0.10000000149011612D; + if (this.aq.equals("Notch")) { + this.a(new ItemStack(Item.APPLE, 1), true); + } + + this.aj.f(); + if (entity != null) { + this.o = (double) (-MathHelper.b((this.aQ + this.r) * 3.1415927F / 180.0F) * 0.1F); + this.q = (double) (-MathHelper.a((this.aQ + this.r) * 3.1415927F / 180.0F) * 0.1F); + } else { + this.o = this.q = 0.0D; + } + + this.C = 0.1F; + } + + public void b(Entity entity, int i) { + this.al += i; + } + + public void a(ItemStack itemstack) { + this.a(itemstack, false); + } + + public void a(ItemStack itemstack, boolean flag) { + if (itemstack != null) { + EntityItem entityitem = new EntityItem(this.h, this.l, this.m - 0.30000001192092896D + (double) this.p(), this.n, itemstack); + + entityitem.ad = 40; + float f = 0.1F; + float f1; + + if (flag) { + f1 = this.R.nextFloat() * 0.5F; + float f2 = this.R.nextFloat() * 3.1415927F * 2.0F; + + entityitem.o = (double) (-MathHelper.a(f2) * f1); + entityitem.q = (double) (MathHelper.b(f2) * f1); + entityitem.p = 0.20000000298023224D; + } else { + f = 0.3F; + entityitem.o = (double) (-MathHelper.a(this.r / 180.0F * 3.1415927F) * MathHelper.b(this.s / 180.0F * 3.1415927F) * f); + entityitem.q = (double) (MathHelper.b(this.r / 180.0F * 3.1415927F) * MathHelper.b(this.s / 180.0F * 3.1415927F) * f); + entityitem.p = (double) (-MathHelper.a(this.s / 180.0F * 3.1415927F) * f + 0.1F); + f = 0.02F; + f1 = this.R.nextFloat() * 3.1415927F * 2.0F; + f *= this.R.nextFloat(); + entityitem.o += Math.cos((double) f1) * (double) f; + entityitem.p += (double) ((this.R.nextFloat() - this.R.nextFloat()) * 0.1F); + entityitem.q += Math.sin((double) f1) * (double) f; + } + + this.a(entityitem); + } + } + + protected void a(EntityItem entityitem) { + this.h.a((Entity) entityitem); + } + + public float a(Block block) { + float f = this.aj.a(block); + + if (this.a(Material.f)) { + f /= 5.0F; + } + + if (!this.w) { + f /= 5.0F; + } + + return f; + } + + public boolean b(Block block) { + return this.aj.b(block); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.k("Inventory"); + + this.aj.b(nbttaglist); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + nbttagcompound.a("Inventory", (NBTBase) this.aj.a(new NBTTagList())); + } + + public void a(IInventory iinventory) {} + + public void A() {} + + public void c(Entity entity, int i) {} + + protected float p() { + return 0.12F; + } + + public boolean a(Entity entity, int i) { + this.bc = 0; + if (this.aM <= 0) { + return false; + } else if ((float) this.X > (float) this.ar / 2.0F) { + return false; + } else { + if (entity instanceof EntityMonster || entity instanceof EntityArrow) { + if (this.h.l == 0) { + i = 0; + } + + if (this.h.l == 1) { + i = i / 3 + 1; + } + + if (this.h.l == 3) { + i = i * 3 / 2; + } + } + + int j = 25 - this.aj.e(); + int k = i * j + this.a; + + this.aj.b(i); + i = k / 25; + this.a = k % 25; + return i == 0 ? false : super.a(entity, i); + } + } + + public void a(TileEntityFurnace tileentityfurnace) {} + + public void a(TileEntitySign tileentitysign) {} + + public ItemStack B() { + return this.aj.b(); + } + + public void C() { + this.aj.a(this.aj.d, (ItemStack) null); + } + + public double x() { + return (double) (this.C - 0.5F); + } + + public void z() { + this.ap = -1; + this.ao = true; + } +} diff --git a/net/minecraft/server/EntityItem.java b/net/minecraft/server/EntityItem.java new file mode 100644 index 000000000..15aab5300 --- /dev/null +++ b/net/minecraft/server/EntityItem.java @@ -0,0 +1,196 @@ +package net.minecraft.server; + +public class EntityItem extends Entity { + + public ItemStack a; + private int af; + public int b = 0; + public int ad; + private int ag = 5; + public float ae = (float) (Math.random() * 3.141592653589793D * 2.0D); + + public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) { + super(world); + this.a(0.25F, 0.25F); + this.C = this.E / 2.0F; + this.a(d0, d1, d2); + this.a = itemstack; + this.r = (float) (Math.random() * 360.0D); + this.o = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D)); + this.p = 0.20000000298023224D; + this.q = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D)); + this.H = false; + } + + public EntityItem(World world) { + super(world); + this.a(0.25F, 0.25F); + this.C = this.E / 2.0F; + } + + public void b_() { + super.b_(); + if (this.ad > 0) { + --this.ad; + } + + this.i = this.l; + this.j = this.m; + this.k = this.n; + this.p -= 0.03999999910593033D; + if (this.h.c(MathHelper.b(this.l), MathHelper.b(this.m), MathHelper.b(this.n)) == Material.g) { + this.p = 0.20000000298023224D; + this.o = (double) ((this.R.nextFloat() - this.R.nextFloat()) * 0.2F); + this.q = (double) ((this.R.nextFloat() - this.R.nextFloat()) * 0.2F); + this.h.a(this, "random.fizz", 0.4F, 2.0F + this.R.nextFloat() * 0.4F); + } + + this.g(this.l, this.m, this.n); + this.o(); + this.c(this.o, this.p, this.q); + float f = 0.98F; + + if (this.w) { + f = 0.58800006F; + int i = this.h.a(MathHelper.b(this.l), MathHelper.b(this.v.b) - 1, MathHelper.b(this.n)); + + if (i > 0) { + f = Block.n[i].bo * 0.98F; + } + } + + this.o *= (double) f; + this.p *= 0.9800000190734863D; + this.q *= (double) f; + if (this.w) { + this.p *= -0.5D; + } + + ++this.af; + ++this.b; + if (this.b >= 6000) { + this.j(); + } + } + + public boolean o() { + return this.h.a(this.v, Material.f, this); + } + + private boolean g(double d0, double d1, double d2) { + int i = MathHelper.b(d0); + int j = MathHelper.b(d1); + int k = MathHelper.b(d2); + double d3 = d0 - (double) i; + double d4 = d1 - (double) j; + double d5 = d2 - (double) k; + + if (Block.p[this.h.a(i, j, k)]) { + boolean flag = !Block.p[this.h.a(i - 1, j, k)]; + boolean flag1 = !Block.p[this.h.a(i + 1, j, k)]; + boolean flag2 = !Block.p[this.h.a(i, j - 1, k)]; + boolean flag3 = !Block.p[this.h.a(i, j + 1, k)]; + boolean flag4 = !Block.p[this.h.a(i, j, k - 1)]; + boolean flag5 = !Block.p[this.h.a(i, j, k + 1)]; + byte b0 = -1; + double d6 = 9999.0D; + + if (flag && d3 < d6) { + d6 = d3; + b0 = 0; + } + + if (flag1 && 1.0D - d3 < d6) { + d6 = 1.0D - d3; + b0 = 1; + } + + if (flag2 && d4 < d6) { + d6 = d4; + b0 = 2; + } + + if (flag3 && 1.0D - d4 < d6) { + d6 = 1.0D - d4; + b0 = 3; + } + + if (flag4 && d5 < d6) { + d6 = d5; + b0 = 4; + } + + if (flag5 && 1.0D - d5 < d6) { + d6 = 1.0D - d5; + b0 = 5; + } + + float f = this.R.nextFloat() * 0.2F + 0.1F; + + if (b0 == 0) { + this.o = (double) (-f); + } + + if (b0 == 1) { + this.o = (double) f; + } + + if (b0 == 2) { + this.p = (double) (-f); + } + + if (b0 == 3) { + this.p = (double) f; + } + + if (b0 == 4) { + this.q = (double) (-f); + } + + if (b0 == 5) { + this.q = (double) f; + } + } + + return false; + } + + protected void b(int i) { + this.a((Entity) null, i); + } + + public boolean a(Entity entity, int i) { + this.ag -= i; + if (this.ag <= 0) { + this.j(); + } + + return false; + } + + public void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Health", (short) ((byte) this.ag)); + nbttagcompound.a("Age", (short) this.b); + nbttagcompound.a("Item", this.a.a(new NBTTagCompound())); + } + + public void b(NBTTagCompound nbttagcompound) { + this.ag = nbttagcompound.c("Health") & 255; + this.b = nbttagcompound.c("Age"); + NBTTagCompound nbttagcompound1 = nbttagcompound.j("Item"); + + this.a = new ItemStack(nbttagcompound1); + } + + public void a(EntityHuman entityhuman) { + if (!this.h.x) { + int i = this.a.a; + + if (this.ad == 0 && entityhuman.aj.a(this.a)) { + this.h.a(this, "random.pop", 0.2F, ((this.R.nextFloat() - this.R.nextFloat()) * 0.7F + 1.0F) * 2.0F); + entityhuman.c(this, i); + this.j(); + } + } + } +} diff --git a/net/minecraft/server/EntityList.java b/net/minecraft/server/EntityList.java new file mode 100644 index 000000000..8335e5987 --- /dev/null +++ b/net/minecraft/server/EntityList.java @@ -0,0 +1,160 @@ +package net.minecraft.server; + +public class EntityList { + + private transient EntityListEntry[] a = new EntityListEntry[16]; + private transient int b; + private int c = 12; + private final float d = 0.75F; + private transient volatile int e; + + public EntityList() {} + + private static int g(int i) { + i ^= i >>> 20 ^ i >>> 12; + return i ^ i >>> 7 ^ i >>> 4; + } + + private static int a(int i, int j) { + return i & j - 1; + } + + public Object a(int i) { + int j = g(i); + + for (EntityListEntry entitylistentry = this.a[a(j, this.a.length)]; entitylistentry != null; entitylistentry = entitylistentry.c) { + if (entitylistentry.a == i) { + return entitylistentry.b; + } + } + + return null; + } + + public boolean b(int i) { + return this.c(i) != null; + } + + final EntityListEntry c(int i) { + int j = g(i); + + for (EntityListEntry entitylistentry = this.a[a(j, this.a.length)]; entitylistentry != null; entitylistentry = entitylistentry.c) { + if (entitylistentry.a == i) { + return entitylistentry; + } + } + + return null; + } + + public void a(int i, Object object) { + int j = g(i); + int k = a(j, this.a.length); + + for (EntityListEntry entitylistentry = this.a[k]; entitylistentry != null; entitylistentry = entitylistentry.c) { + if (entitylistentry.a == i) { + entitylistentry.b = object; + } + } + + ++this.e; + this.a(j, i, object, k); + } + + private void h(int i) { + EntityListEntry[] aentitylistentry = this.a; + int j = aentitylistentry.length; + + if (j == 1073741824) { + this.c = Integer.MAX_VALUE; + } else { + EntityListEntry[] aentitylistentry1 = new EntityListEntry[i]; + + this.a(aentitylistentry1); + this.a = aentitylistentry1; + this.c = (int) ((float) i * this.d); + } + } + + private void a(EntityListEntry[] aentitylistentry) { + EntityListEntry[] aentitylistentry1 = this.a; + int i = aentitylistentry.length; + + for (int j = 0; j < aentitylistentry1.length; ++j) { + EntityListEntry entitylistentry = aentitylistentry1[j]; + + if (entitylistentry != null) { + aentitylistentry1[j] = null; + + EntityListEntry entitylistentry1; + + do { + entitylistentry1 = entitylistentry.c; + int k = a(entitylistentry.d, i); + + entitylistentry.c = aentitylistentry[k]; + aentitylistentry[k] = entitylistentry; + entitylistentry = entitylistentry1; + } while (entitylistentry1 != null); + } + } + } + + public Object d(int i) { + EntityListEntry entitylistentry = this.e(i); + + return entitylistentry == null ? null : entitylistentry.b; + } + + final EntityListEntry e(int i) { + int j = g(i); + int k = a(j, this.a.length); + EntityListEntry entitylistentry = this.a[k]; + + EntityListEntry entitylistentry1; + EntityListEntry entitylistentry2; + + for (entitylistentry1 = entitylistentry; entitylistentry1 != null; entitylistentry1 = entitylistentry2) { + entitylistentry2 = entitylistentry1.c; + if (entitylistentry1.a == i) { + ++this.e; + --this.b; + if (entitylistentry == entitylistentry1) { + this.a[k] = entitylistentry2; + } else { + entitylistentry.c = entitylistentry2; + } + + return entitylistentry1; + } + + entitylistentry = entitylistentry1; + } + + return entitylistentry1; + } + + public void a() { + ++this.e; + EntityListEntry[] aentitylistentry = this.a; + + for (int i = 0; i < aentitylistentry.length; ++i) { + aentitylistentry[i] = null; + } + + this.b = 0; + } + + private void a(int i, int j, Object object, int k) { + EntityListEntry entitylistentry = this.a[k]; + + this.a[k] = new EntityListEntry(i, j, object, entitylistentry); + if (this.b++ >= this.c) { + this.h(2 * this.a.length); + } + } + + static int f(int i) { + return g(i); + } +} diff --git a/net/minecraft/server/EntityListEntry.java b/net/minecraft/server/EntityListEntry.java new file mode 100644 index 000000000..59506d905 --- /dev/null +++ b/net/minecraft/server/EntityListEntry.java @@ -0,0 +1,53 @@ +package net.minecraft.server; + +class EntityListEntry { + + final int a; + Object b; + EntityListEntry c; + final int d; + + EntityListEntry(int i, int j, Object object, EntityListEntry entitylistentry) { + this.b = object; + this.c = entitylistentry; + this.a = j; + this.d = i; + } + + public final int a() { + return this.a; + } + + public final Object b() { + return this.b; + } + + public final boolean equals(Object object) { + if (!(object instanceof EntityListEntry)) { + return false; + } else { + EntityListEntry entitylistentry = (EntityListEntry) object; + Integer integer = Integer.valueOf(this.a()); + Integer integer1 = Integer.valueOf(entitylistentry.a()); + + if (integer == integer1 || integer != null && integer.equals(integer1)) { + Object object1 = this.b(); + Object object2 = entitylistentry.b(); + + if (object1 == object2 || object1 != null && object1.equals(object2)) { + return true; + } + } + + return false; + } + } + + public final int hashCode() { + return EntityList.f(this.a); + } + + public final String toString() { + return this.a() + "=" + this.b(); + } +} diff --git a/net/minecraft/server/EntityLiving.java b/net/minecraft/server/EntityLiving.java new file mode 100644 index 000000000..0f866bb65 --- /dev/null +++ b/net/minecraft/server/EntityLiving.java @@ -0,0 +1,743 @@ +package net.minecraft.server; + +import java.util.List; + +public class EntityLiving extends Entity { + + public int ar = 20; + public float as; + public float at; + public float au; + public float av = 0.0F; + public float aw = 0.0F; + protected float ax; + protected float ay; + protected float az; + protected float aA; + protected boolean aB = true; + protected String aC = "/char.png"; + protected boolean aD = true; + protected float aE = 0.0F; + protected String aF = null; + protected float aG = 1.0F; + protected int aH = 0; + protected float aI = 0.0F; + public boolean aJ = false; + public float aK; + public float aL; + public int aM = 10; + public int aN; + private int a; + public int aO; + public int aP; + public float aQ = 0.0F; + public int aR = 0; + public int aS = 0; + public float aT; + public float aU; + protected boolean aV = false; + public int aW = -1; + public float aX = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D); + public float aY; + public float aZ; + public float ba; + private int b; + private double ad; + private double ae; + private double af; + private double ag; + private double ah; + float bb = 0.0F; + protected int bc = 0; + protected float bd; + protected float be; + protected float bf; + protected boolean bg = false; + protected float bh = 0.0F; + protected float bi = 0.7F; + private Entity ai; + private int aj = 0; + + public EntityLiving(World world) { + super(world); + this.e = true; + this.au = (float) (Math.random() + 1.0D) * 0.01F; + this.a(this.l, this.m, this.n); + this.as = (float) Math.random() * 12398.0F; + this.r = (float) (Math.random() * 3.1415927410125732D * 2.0D); + this.at = 1.0F; + this.N = 0.5F; + } + + protected boolean g(Entity entity) { + return this.h.a(Vec3D.b(this.l, this.m + (double) this.p(), this.n), Vec3D.b(entity.l, entity.m + (double) entity.p(), entity.n)) == null; + } + + public boolean c_() { + return !this.B; + } + + public boolean r() { + return !this.B; + } + + protected float p() { + return this.E * 0.85F; + } + + public int b() { + return 80; + } + + public void k() { + this.aK = this.aL; + super.k(); + if (this.R.nextInt(1000) < this.a++) { + this.a = -this.b(); + String s = this.c(); + + if (s != null) { + this.h.a(this, s, this.f(), (this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F); + } + } + + if (this.t() && this.u()) { + this.a((Entity) null, 1); + } + + int i; + + if (this.t() && this.a(Material.f)) { + --this.Y; + if (this.Y == -20) { + this.Y = 0; + + for (i = 0; i < 8; ++i) { + float f = this.R.nextFloat() - this.R.nextFloat(); + float f1 = this.R.nextFloat() - this.R.nextFloat(); + float f2 = this.R.nextFloat() - this.R.nextFloat(); + + this.h.a("bubble", this.l + (double) f, this.m + (double) f1, this.n + (double) f2, this.o, this.p, this.q); + } + + this.a((Entity) null, 2); + } + + this.U = 0; + } else { + this.Y = this.V; + } + + this.aT = this.aU; + if (this.aS > 0) { + --this.aS; + } + + if (this.aO > 0) { + --this.aO; + } + + if (this.X > 0) { + --this.X; + } + + if (this.aM <= 0) { + ++this.aR; + if (this.aR > 20) { + this.G(); + this.j(); + + for (i = 0; i < 20; ++i) { + double d0 = this.R.nextGaussian() * 0.02D; + double d1 = this.R.nextGaussian() * 0.02D; + double d2 = this.R.nextGaussian() * 0.02D; + + this.h.a("explode", this.l + (double) (this.R.nextFloat() * this.D * 2.0F) - (double) this.D, this.m + (double) (this.R.nextFloat() * this.E), this.n + (double) (this.R.nextFloat() * this.D * 2.0F) - (double) this.D, d0, d1, d2); + } + } + } + + this.aA = this.az; + this.aw = this.av; + this.t = this.r; + this.u = this.s; + } + + public void D() { + for (int i = 0; i < 20; ++i) { + double d0 = this.R.nextGaussian() * 0.02D; + double d1 = this.R.nextGaussian() * 0.02D; + double d2 = this.R.nextGaussian() * 0.02D; + double d3 = 10.0D; + + this.h.a("explode", this.l + (double) (this.R.nextFloat() * this.D * 2.0F) - (double) this.D - d0 * d3, this.m + (double) (this.R.nextFloat() * this.E) - d1 * d3, this.n + (double) (this.R.nextFloat() * this.D * 2.0F) - (double) this.D - d2 * d3, d0, d1, d2); + } + } + + public void v() { + super.v(); + this.ax = this.ay; + this.ay = 0.0F; + } + + public void b_() { + super.b_(); + this.y(); + double d0 = this.l - this.i; + double d1 = this.n - this.k; + float f = MathHelper.a(d0 * d0 + d1 * d1); + float f1 = this.av; + float f2 = 0.0F; + + this.ax = this.ay; + float f3 = 0.0F; + + if (f > 0.05F) { + f3 = 1.0F; + f2 = f * 3.0F; + f1 = (float) Math.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; + } + + if (this.aL > 0.0F) { + f1 = this.r; + } + + if (!this.w) { + f3 = 0.0F; + } + + this.ay += (f3 - this.ay) * 0.3F; + + float f4; + + for (f4 = f1 - this.av; f4 < -180.0F; f4 += 360.0F) { + ; + } + + while (f4 >= 180.0F) { + f4 -= 360.0F; + } + + this.av += f4 * 0.3F; + + float f5; + + for (f5 = this.r - this.av; f5 < -180.0F; f5 += 360.0F) { + ; + } + + while (f5 >= 180.0F) { + f5 -= 360.0F; + } + + boolean flag = f5 < -90.0F || f5 >= 90.0F; + + if (f5 < -75.0F) { + f5 = -75.0F; + } + + if (f5 >= 75.0F) { + f5 = 75.0F; + } + + this.av = this.r - f5; + if (f5 * f5 > 2500.0F) { + this.av += f5 * 0.2F; + } + + if (flag) { + f2 *= -1.0F; + } + + while (this.r - this.t < -180.0F) { + this.t -= 360.0F; + } + + while (this.r - this.t >= 180.0F) { + this.t += 360.0F; + } + + while (this.av - this.aw < -180.0F) { + this.aw -= 360.0F; + } + + while (this.av - this.aw >= 180.0F) { + this.aw += 360.0F; + } + + while (this.s - this.u < -180.0F) { + this.u -= 360.0F; + } + + while (this.s - this.u >= 180.0F) { + this.u += 360.0F; + } + + this.az += f2; + } + + protected void a(float f, float f1) { + super.a(f, f1); + } + + public void a(int i) { + if (this.aM > 0) { + this.aM += i; + if (this.aM > 20) { + this.aM = 20; + } + + this.X = this.ar / 2; + } + } + + public boolean a(Entity entity, int i) { + if (this.h.x) { + i = 0; + } + + this.bc = 0; + if (this.aM <= 0) { + return false; + } else { + this.aZ = 1.5F; + if ((float) this.X > (float) this.ar / 2.0F) { + if (this.aN - i >= this.aM) { + return false; + } + + this.aM = this.aN - i; + } else { + this.aN = this.aM; + this.X = this.ar; + this.aM -= i; + this.aO = this.aP = 10; + } + + this.aQ = 0.0F; + if (entity != null) { + double d0 = entity.l - this.l; + + double d1; + + for (d1 = entity.n - this.n; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { + d0 = (Math.random() - Math.random()) * 0.01D; + } + + this.aQ = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.r; + this.a(entity, i, d0, d1); + } else { + this.aQ = (float) ((int) (Math.random() * 2.0D) * 180); + } + + if (this.aM <= 0) { + this.h.a(this, this.e(), this.f(), (this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F); + this.f(entity); + } else { + this.h.a(this, this.d(), this.f(), (this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F); + } + + return true; + } + } + + protected float f() { + return 1.0F; + } + + protected String c() { + return null; + } + + protected String d() { + return "random.hurt"; + } + + protected String e() { + return "random.hurt"; + } + + public void a(Entity entity, int i, double d0, double d1) { + float f = MathHelper.a(d0 * d0 + d1 * d1); + float f1 = 0.4F; + + this.o /= 2.0D; + this.p /= 2.0D; + this.q /= 2.0D; + this.o -= d0 / (double) f * (double) f1; + this.p += 0.4000000059604645D; + this.q -= d1 / (double) f * (double) f1; + if (this.p > 0.4000000059604645D) { + this.p = 0.4000000059604645D; + } + } + + public void f(Entity entity) { + if (this.aH > 0 && entity != null) { + entity.b(this, this.aH); + } + + this.aV = true; + int i = this.g(); + + if (i > 0) { + int j = this.R.nextInt(3); + + for (int k = 0; k < j; ++k) { + this.a(i, 1); + } + } + } + + protected int g() { + return 0; + } + + protected void a(float f) { + int i = (int) Math.ceil((double) (f - 3.0F)); + + if (i > 0) { + this.a((Entity) null, i); + int j = this.h.a(MathHelper.b(this.l), MathHelper.b(this.m - 0.20000000298023224D - (double) this.C), MathHelper.b(this.n)); + + if (j > 0) { + StepSound stepsound = Block.n[j].bl; + + this.h.a(this, stepsound.c(), stepsound.a() * 0.5F, stepsound.b() * 0.75F); + } + } + } + + public void c(float f, float f1) { + double d0; + + if (this.o()) { + d0 = this.m; + this.a(f, f1, 0.02F); + this.c(this.o, this.p, this.q); + this.o *= 0.800000011920929D; + this.p *= 0.800000011920929D; + this.q *= 0.800000011920929D; + this.p -= 0.02D; + if (this.x && this.b(this.o, this.p + 0.6000000238418579D - this.m + d0, this.q)) { + this.p = 0.30000001192092896D; + } + } else if (this.q()) { + d0 = this.m; + this.a(f, f1, 0.02F); + this.c(this.o, this.p, this.q); + this.o *= 0.5D; + this.p *= 0.5D; + this.q *= 0.5D; + this.p -= 0.02D; + if (this.x && this.b(this.o, this.p + 0.6000000238418579D - this.m + d0, this.q)) { + this.p = 0.30000001192092896D; + } + } else { + float f2 = 0.91F; + + if (this.w) { + f2 = 0.54600006F; + int i = this.h.a(MathHelper.b(this.l), MathHelper.b(this.v.b) - 1, MathHelper.b(this.n)); + + if (i > 0) { + f2 = Block.n[i].bo * 0.91F; + } + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + + this.a(f, f1, this.w ? 0.1F * f3 : 0.02F); + f2 = 0.91F; + if (this.w) { + f2 = 0.54600006F; + int j = this.h.a(MathHelper.b(this.l), MathHelper.b(this.v.b) - 1, MathHelper.b(this.n)); + + if (j > 0) { + f2 = Block.n[j].bo * 0.91F; + } + } + + if (this.E()) { + this.I = 0.0F; + if (this.p < -0.15D) { + this.p = -0.15D; + } + } + + this.c(this.o, this.p, this.q); + if (this.x && this.E()) { + this.p = 0.2D; + } + + this.p -= 0.08D; + this.p *= 0.9800000190734863D; + this.o *= (double) f2; + this.q *= (double) f2; + } + + this.aY = this.aZ; + d0 = this.l - this.i; + double d1 = this.n - this.k; + float f4 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F; + + if (f4 > 1.0F) { + f4 = 1.0F; + } + + this.aZ += (f4 - this.aZ) * 0.4F; + this.ba += this.aZ; + } + + public boolean E() { + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.v.b); + int k = MathHelper.b(this.n); + + return this.h.a(i, j, k) == Block.LADDER.bc || this.h.a(i, j + 1, k) == Block.LADDER.bc; + } + + public void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Health", (short) this.aM); + nbttagcompound.a("HurtTime", (short) this.aO); + nbttagcompound.a("DeathTime", (short) this.aR); + nbttagcompound.a("AttackTime", (short) this.aS); + } + + public void b(NBTTagCompound nbttagcompound) { + this.aM = nbttagcompound.c("Health"); + if (!nbttagcompound.a("Health")) { + this.aM = 10; + } + + this.aO = nbttagcompound.c("HurtTime"); + this.aR = nbttagcompound.c("DeathTime"); + this.aS = nbttagcompound.c("AttackTime"); + } + + public boolean t() { + return !this.B && this.aM > 0; + } + + public void y() { + if (this.b > 0) { + double d0 = this.l + (this.ad - this.l) / (double) this.b; + double d1 = this.m + (this.ae - this.m) / (double) this.b; + double d2 = this.n + (this.af - this.n) / (double) this.b; + + double d3; + + for (d3 = this.ag - (double) this.r; d3 < -180.0D; d3 += 360.0D) { + ; + } + + while (d3 >= 180.0D) { + d3 -= 360.0D; + } + + this.r = (float) ((double) this.r + d3 / (double) this.b); + this.s = (float) ((double) this.s + (this.ah - (double) this.s) / (double) this.b); + --this.b; + this.a(d0, d1, d2); + this.b(this.r, this.s); + } + + if (this.aM <= 0) { + this.bg = false; + this.bd = 0.0F; + this.be = 0.0F; + this.bf = 0.0F; + } else if (!this.aJ) { + this.d_(); + } + + boolean flag = this.o(); + boolean flag1 = this.q(); + + if (this.bg) { + if (flag) { + this.p += 0.03999999910593033D; + } else if (flag1) { + this.p += 0.03999999910593033D; + } else if (this.w) { + this.F(); + } + } + + this.bd *= 0.98F; + this.be *= 0.98F; + this.bf *= 0.9F; + this.c(this.bd, this.be); + List list = this.h.b((Entity) this, this.v.b(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); ++i) { + Entity entity = (Entity) list.get(i); + + if (entity.r()) { + entity.c((Entity) this); + } + } + } + } + + protected void F() { + this.p = 0.41999998688697815D; + } + + protected void d_() { + ++this.bc; + EntityHuman entityhuman = this.h.a(this, -1.0D); + + if (entityhuman != null) { + double d0 = entityhuman.l - this.l; + double d1 = entityhuman.m - this.m; + double d2 = entityhuman.n - this.n; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d3 > 16384.0D) { + this.j(); + } + + if (this.bc > 600 && this.R.nextInt(800) == 0) { + if (d3 < 1024.0D) { + this.bc = 0; + } else { + this.j(); + } + } + } + + this.bd = 0.0F; + this.be = 0.0F; + float f = 8.0F; + + if (this.R.nextFloat() < 0.02F) { + entityhuman = this.h.a(this, (double) f); + if (entityhuman != null) { + this.ai = entityhuman; + this.aj = 10 + this.R.nextInt(20); + } else { + this.bf = (this.R.nextFloat() - 0.5F) * 20.0F; + } + } + + if (this.ai != null) { + this.b(this.ai, 10.0F); + if (this.aj-- <= 0 || this.ai.B || this.ai.b((Entity) this) > (double) (f * f)) { + this.ai = null; + } + } else { + if (this.R.nextFloat() < 0.05F) { + this.bf = (this.R.nextFloat() - 0.5F) * 20.0F; + } + + this.r += this.bf; + this.s = this.bh; + } + + boolean flag = this.o(); + boolean flag1 = this.q(); + + if (flag || flag1) { + this.bg = this.R.nextFloat() < 0.8F; + } + } + + public void b(Entity entity, float f) { + double d0 = entity.l - this.l; + double d1 = entity.n - this.n; + double d2; + + if (entity instanceof EntityLiving) { + EntityLiving entityliving = (EntityLiving) entity; + + d2 = entityliving.m + (double) entityliving.p() - (this.m + (double) this.p()); + } else { + d2 = (entity.v.b + entity.v.e) / 2.0D - (this.m + (double) this.p()); + } + + double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1); + float f1 = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F; + float f2 = (float) (Math.atan2(d2, d3) * 180.0D / 3.1415927410125732D); + + this.s = this.b(this.s, f2, f); + this.r = this.b(this.r, f1, f); + } + + private float b(float f, float f1, float f2) { + float f3; + + for (f3 = f1 - f; f3 < -180.0F; f3 += 360.0F) { + ; + } + + while (f3 >= 180.0F) { + f3 -= 360.0F; + } + + if (f3 > f2) { + f3 = f2; + } + + if (f3 < -f2) { + f3 = -f2; + } + + return f + f3; + } + + public void G() {} + + public boolean a() { + return this.h.a(this.v) && this.h.a((Entity) this, this.v).size() == 0 && !this.h.b(this.v); + } + + protected void l() { + this.a((Entity) null, 4); + } + + public Vec3D c(float f) { + if (f == 1.0F) { + return Vec3D.b(this.l, this.m, this.n); + } else { + double d0 = this.i + (this.l - this.i) * (double) f; + double d1 = this.j + (this.m - this.j) * (double) f; + double d2 = this.k + (this.n - this.k) * (double) f; + + return Vec3D.b(d0, d1, d2); + } + } + + public Vec3D d(float f) { + float f1; + float f2; + float f3; + float f4; + + if (f == 1.0F) { + f1 = MathHelper.b(-this.r * 0.017453292F - 3.1415927F); + f2 = MathHelper.a(-this.r * 0.017453292F - 3.1415927F); + f3 = -MathHelper.b(-this.s * 0.017453292F); + f4 = MathHelper.a(-this.s * 0.017453292F); + return Vec3D.b((double) (f2 * f3), (double) f4, (double) (f1 * f3)); + } else { + f1 = this.u + (this.s - this.u) * f; + f2 = this.t + (this.r - this.t) * f; + f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F); + f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F); + float f5 = -MathHelper.b(-f1 * 0.017453292F); + float f6 = MathHelper.a(-f1 * 0.017453292F); + + return Vec3D.b((double) (f4 * f5), (double) f6, (double) (f3 * f5)); + } + } + + public MovingObjectPosition a(double d0, float f) { + Vec3D vec3d = this.c(f); + Vec3D vec3d1 = this.d(f); + Vec3D vec3d2 = vec3d.c(vec3d1.a * d0, vec3d1.b * d0, vec3d1.c * d0); + + return this.h.a(vec3d, vec3d2); + } +} diff --git a/net/minecraft/server/EntityMinecart.java b/net/minecraft/server/EntityMinecart.java new file mode 100644 index 000000000..4c4965029 --- /dev/null +++ b/net/minecraft/server/EntityMinecart.java @@ -0,0 +1,594 @@ +package net.minecraft.server; + +import java.util.List; + +public class EntityMinecart extends Entity implements IInventory { + + private ItemStack[] ai; + public int a; + public int b; + public int ad; + private boolean aj; + public int ae; + public int af; + public double ag; + public double ah; + private static final int[][][] ak = new int[][][] { { { 0, 0, -1}, { 0, 0, 1}}, { { -1, 0, 0}, { 1, 0, 0}}, { { -1, -1, 0}, { 1, 0, 0}}, { { -1, 0, 0}, { 1, -1, 0}}, { { 0, 0, -1}, { 0, -1, 1}}, { { 0, -1, -1}, { 0, 0, 1}}, { { 0, 0, 1}, { 1, 0, 0}}, { { 0, 0, 1}, { -1, 0, 0}}, { { 0, 0, -1}, { -1, 0, 0}}, { { 0, 0, -1}, { 1, 0, 0}}}; + private int al; + private double am; + private double an; + private double ao; + private double ap; + private double aq; + + public EntityMinecart(World world) { + super(world); + this.ai = new ItemStack[36]; + this.a = 0; + this.b = 0; + this.ad = 1; + this.aj = false; + this.e = true; + this.a(0.98F, 0.7F); + this.C = this.E / 2.0F; + this.H = false; + } + + public AxisAlignedBB d(Entity entity) { + return entity.v; + } + + public AxisAlignedBB n() { + return this.v; + } + + public boolean r() { + return true; + } + + public EntityMinecart(World world, double d0, double d1, double d2, int i) { + this(world); + this.a(d0, d1 + (double) this.C, d2); + this.o = 0.0D; + this.p = 0.0D; + this.q = 0.0D; + this.i = d0; + this.j = d1; + this.k = d2; + this.ae = i; + } + + public double h() { + return (double) this.E * 0.0D - 0.30000001192092896D; + } + + public boolean a(Entity entity, int i) { + this.ad = -this.ad; + this.b = 10; + this.a += i * 10; + if (this.a > 40) { + this.a(Item.MINECART.aS, 1, 0.0F); + if (this.ae == 1) { + this.a(Block.CHEST.bc, 1, 0.0F); + } else if (this.ae == 2) { + this.a(Block.FURNACE.bc, 1, 0.0F); + } + + this.j(); + } + + return true; + } + + public boolean c_() { + return !this.B; + } + + public void j() { + for (int i = 0; i < this.a(); ++i) { + ItemStack itemstack = this.a(i); + + if (itemstack != null) { + float f = this.R.nextFloat() * 0.8F + 0.1F; + float f1 = this.R.nextFloat() * 0.8F + 0.1F; + float f2 = this.R.nextFloat() * 0.8F + 0.1F; + + while (itemstack.a > 0) { + int j = this.R.nextInt(21) + 10; + + if (j > itemstack.a) { + j = itemstack.a; + } + + itemstack.a -= j; + EntityItem entityitem = new EntityItem(this.h, this.l + (double) f, this.m + (double) f1, this.n + (double) f2, new ItemStack(itemstack.c, j, itemstack.d)); + float f3 = 0.05F; + + entityitem.o = (double) ((float) this.R.nextGaussian() * f3); + entityitem.p = (double) ((float) this.R.nextGaussian() * f3 + 0.2F); + entityitem.q = (double) ((float) this.R.nextGaussian() * f3); + this.h.a((Entity) entityitem); + } + } + } + + super.j(); + } + + public void b_() { + double d0; + + if (this.h.x) { + if (this.al > 0) { + double d1 = this.l + (this.am - this.l) / (double) this.al; + double d2 = this.m + (this.an - this.m) / (double) this.al; + double d3 = this.n + (this.ao - this.n) / (double) this.al; + + for (d0 = this.ap - (double) this.r; d0 < -180.0D; d0 += 360.0D) { + ; + } + + while (d0 >= 180.0D) { + d0 -= 360.0D; + } + + this.r = (float) ((double) this.r + d0 / (double) this.al); + this.s = (float) ((double) this.s + (this.aq - (double) this.s) / (double) this.al); + --this.al; + this.a(d1, d2, d3); + this.b(this.r, this.s); + } else { + this.a(this.l, this.m, this.n); + this.b(this.r, this.s); + } + } else { + if (this.b > 0) { + --this.b; + } + + if (this.a > 0) { + --this.a; + } + + this.i = this.l; + this.j = this.m; + this.k = this.n; + this.p -= 0.03999999910593033D; + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.m); + int k = MathHelper.b(this.n); + + if (this.h.a(i, j - 1, k) == Block.RAILS.bc) { + --j; + } + + double d4 = 0.4D; + boolean flag = false; + + d0 = 0.0078125D; + if (this.h.a(i, j, k) == Block.RAILS.bc) { + Vec3D vec3d = this.g(this.l, this.m, this.n); + int l = this.h.b(i, j, k); + + this.m = (double) j; + if (l >= 2 && l <= 5) { + this.m = (double) (j + 1); + } + + if (l == 2) { + this.o -= d0; + } + + if (l == 3) { + this.o += d0; + } + + if (l == 4) { + this.q += d0; + } + + if (l == 5) { + this.q -= d0; + } + + int[][] aint = ak[l]; + double d5 = (double) (aint[1][0] - aint[0][0]); + double d6 = (double) (aint[1][2] - aint[0][2]); + double d7 = Math.sqrt(d5 * d5 + d6 * d6); + double d8 = this.o * d5 + this.q * d6; + + if (d8 < 0.0D) { + d5 = -d5; + d6 = -d6; + } + + double d9 = Math.sqrt(this.o * this.o + this.q * this.q); + + this.o = d9 * d5 / d7; + this.q = d9 * d6 / d7; + double d10 = 0.0D; + double d11 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; + double d12 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; + double d13 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; + double d14 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; + + d5 = d13 - d11; + d6 = d14 - d12; + double d15; + double d16; + double d17; + + if (d5 == 0.0D) { + this.l = (double) i + 0.5D; + d10 = this.n - (double) k; + } else if (d6 == 0.0D) { + this.n = (double) k + 0.5D; + d10 = this.l - (double) i; + } else { + d15 = this.l - d11; + d17 = this.n - d12; + d16 = (d15 * d5 + d17 * d6) * 2.0D; + d10 = d16; + } + + this.l = d11 + d5 * d10; + this.n = d12 + d6 * d10; + this.a(this.l, this.m + (double) this.C, this.n); + d15 = this.o; + d17 = this.q; + if (this.f != null) { + d15 *= 0.75D; + d17 *= 0.75D; + } + + if (d15 < -d4) { + d15 = -d4; + } + + if (d15 > d4) { + d15 = d4; + } + + if (d17 < -d4) { + d17 = -d4; + } + + if (d17 > d4) { + d17 = d4; + } + + this.c(d15, 0.0D, d17); + if (aint[0][1] != 0 && MathHelper.b(this.l) - i == aint[0][0] && MathHelper.b(this.n) - k == aint[0][2]) { + this.a(this.l, this.m + (double) aint[0][1], this.n); + } else if (aint[1][1] != 0 && MathHelper.b(this.l) - i == aint[1][0] && MathHelper.b(this.n) - k == aint[1][2]) { + this.a(this.l, this.m + (double) aint[1][1], this.n); + } + + if (this.f != null) { + this.o *= 0.996999979019165D; + this.p *= 0.0D; + this.q *= 0.996999979019165D; + } else { + if (this.ae == 2) { + d16 = (double) MathHelper.a(this.ag * this.ag + this.ah * this.ah); + if (d16 > 0.01D) { + flag = true; + this.ag /= d16; + this.ah /= d16; + double d18 = 0.04D; + + this.o *= 0.800000011920929D; + this.p *= 0.0D; + this.q *= 0.800000011920929D; + this.o += this.ag * d18; + this.q += this.ah * d18; + } else { + this.o *= 0.8999999761581421D; + this.p *= 0.0D; + this.q *= 0.8999999761581421D; + } + } + + this.o *= 0.9599999785423279D; + this.p *= 0.0D; + this.q *= 0.9599999785423279D; + } + + Vec3D vec3d1 = this.g(this.l, this.m, this.n); + + if (vec3d1 != null && vec3d != null) { + double d19 = (vec3d.b - vec3d1.b) * 0.05D; + + d9 = Math.sqrt(this.o * this.o + this.q * this.q); + if (d9 > 0.0D) { + this.o = this.o / d9 * (d9 + d19); + this.q = this.q / d9 * (d9 + d19); + } + + this.a(this.l, vec3d1.b, this.n); + } + + int i1 = MathHelper.b(this.l); + int j1 = MathHelper.b(this.n); + + if (i1 != i || j1 != k) { + d9 = Math.sqrt(this.o * this.o + this.q * this.q); + this.o = d9 * (double) (i1 - i); + this.q = d9 * (double) (j1 - k); + } + + if (this.ae == 2) { + double d20 = (double) MathHelper.a(this.ag * this.ag + this.ah * this.ah); + + if (d20 > 0.01D && this.o * this.o + this.q * this.q > 0.0010D) { + this.ag /= d20; + this.ah /= d20; + if (this.ag * this.o + this.ah * this.q < 0.0D) { + this.ag = 0.0D; + this.ah = 0.0D; + } else { + this.ag = this.o; + this.ah = this.q; + } + } + } + } else { + if (this.o < -d4) { + this.o = -d4; + } + + if (this.o > d4) { + this.o = d4; + } + + if (this.q < -d4) { + this.q = -d4; + } + + if (this.q > d4) { + this.q = d4; + } + + if (this.w) { + this.o *= 0.5D; + this.p *= 0.5D; + this.q *= 0.5D; + } + + this.c(this.o, this.p, this.q); + if (!this.w) { + this.o *= 0.949999988079071D; + this.p *= 0.949999988079071D; + this.q *= 0.949999988079071D; + } + } + + this.s = 0.0F; + double d21 = this.i - this.l; + double d22 = this.k - this.n; + + if (d21 * d21 + d22 * d22 > 0.0010D) { + this.r = (float) (Math.atan2(d22, d21) * 180.0D / 3.141592653589793D); + if (this.aj) { + this.r += 180.0F; + } + } + + double d23; + + for (d23 = (double) (this.r - this.t); d23 >= 180.0D; d23 -= 360.0D) { + ; + } + + while (d23 < -180.0D) { + d23 += 360.0D; + } + + if (d23 < -170.0D || d23 >= 170.0D) { + this.r += 180.0F; + this.aj = !this.aj; + } + + this.b(this.r, this.s); + List list = this.h.b((Entity) this, this.v.b(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + + if (list != null && list.size() > 0) { + for (int k1 = 0; k1 < list.size(); ++k1) { + Entity entity = (Entity) list.get(k1); + + if (entity != this.f && entity.r() && entity instanceof EntityMinecart) { + entity.c((Entity) this); + } + } + } + + if (this.f != null && this.f.B) { + this.f = null; + } + + if (flag && this.R.nextInt(4) == 0) { + --this.af; + if (this.af < 0) { + this.ag = this.ah = 0.0D; + } + + this.h.a("largesmoke", this.l, this.m + 0.8D, this.n, 0.0D, 0.0D, 0.0D); + } + } + } + + public Vec3D g(double d0, double d1, double d2) { + int i = MathHelper.b(d0); + int j = MathHelper.b(d1); + int k = MathHelper.b(d2); + + if (this.h.a(i, j - 1, k) == Block.RAILS.bc) { + --j; + } + + if (this.h.a(i, j, k) == Block.RAILS.bc) { + int l = this.h.b(i, j, k); + + d1 = (double) j; + if (l >= 2 && l <= 5) { + d1 = (double) (j + 1); + } + + int[][] aint = ak[l]; + double d3 = 0.0D; + double d4 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; + double d5 = (double) j + 0.5D + (double) aint[0][1] * 0.5D; + double d6 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; + double d7 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; + double d8 = (double) j + 0.5D + (double) aint[1][1] * 0.5D; + double d9 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; + double d10 = d7 - d4; + double d11 = (d8 - d5) * 2.0D; + double d12 = d9 - d6; + + if (d10 == 0.0D) { + d0 = (double) i + 0.5D; + d3 = d2 - (double) k; + } else if (d12 == 0.0D) { + d2 = (double) k + 0.5D; + d3 = d0 - (double) i; + } else { + double d13 = d0 - d4; + double d14 = d2 - d6; + double d15 = (d13 * d10 + d14 * d12) * 2.0D; + + d3 = d15; + } + + d0 = d4 + d10 * d3; + d1 = d5 + d11 * d3; + d2 = d6 + d12 * d3; + if (d11 < 0.0D) { + ++d1; + } + + if (d11 > 0.0D) { + d1 += 0.5D; + } + + return Vec3D.b(d0, d1, d2); + } else { + return null; + } + } + + protected void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Type", this.ae); + if (this.ae == 2) { + nbttagcompound.a("PushX", this.ag); + nbttagcompound.a("PushZ", this.ah); + nbttagcompound.a("Fuel", (short) this.af); + } else if (this.ae == 1) { + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.ai.length; ++i) { + if (this.ai[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + nbttagcompound1.a("Slot", (byte) i); + this.ai[i].a(nbttagcompound1); + nbttaglist.a((NBTBase) nbttagcompound1); + } + } + + nbttagcompound.a("Items", (NBTBase) nbttaglist); + } + } + + protected void b(NBTTagCompound nbttagcompound) { + this.ae = nbttagcompound.d("Type"); + if (this.ae == 2) { + this.ag = nbttagcompound.g("PushX"); + this.ah = nbttagcompound.g("PushZ"); + this.af = nbttagcompound.c("Fuel"); + } else if (this.ae == 1) { + NBTTagList nbttaglist = nbttagcompound.k("Items"); + + this.ai = new ItemStack[this.a()]; + + for (int i = 0; i < nbttaglist.b(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); + int j = nbttagcompound1.b("Slot") & 255; + + if (j >= 0 && j < this.ai.length) { + this.ai[j] = new ItemStack(nbttagcompound1); + } + } + } + } + + public void c(Entity entity) { + if (entity != this.f) { + if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.ae == 0 && this.o * this.o + this.q * this.q > 0.01D && this.f == null && entity.g == null) { + entity.e((Entity) this); + } + + double d0 = entity.l - this.l; + double d1 = entity.n - this.n; + double d2 = d0 * d0 + d1 * d1; + + if (d2 >= 9.999999747378752E-5D) { + d2 = (double) MathHelper.a(d2); + d0 /= d2; + d1 /= d2; + double d3 = 1.0D / d2; + + if (d3 > 1.0D) { + d3 = 1.0D; + } + + d0 *= d3; + d1 *= d3; + d0 *= 0.10000000149011612D; + d1 *= 0.10000000149011612D; + d0 *= (double) (1.0F - this.P); + d1 *= (double) (1.0F - this.P); + d0 *= 0.5D; + d1 *= 0.5D; + if (entity instanceof EntityMinecart) { + double d4 = entity.o + this.o; + double d5 = entity.q + this.q; + + if (((EntityMinecart) entity).ae == 2 && this.ae != 2) { + this.o *= 0.20000000298023224D; + this.q *= 0.20000000298023224D; + this.f(entity.o - d0, 0.0D, entity.q - d1); + entity.o *= 0.699999988079071D; + entity.q *= 0.699999988079071D; + } else if (((EntityMinecart) entity).ae != 2 && this.ae == 2) { + entity.o *= 0.20000000298023224D; + entity.q *= 0.20000000298023224D; + entity.f(this.o + d0, 0.0D, this.q + d1); + this.o *= 0.699999988079071D; + this.q *= 0.699999988079071D; + } else { + d4 /= 2.0D; + d5 /= 2.0D; + this.o *= 0.20000000298023224D; + this.q *= 0.20000000298023224D; + this.f(d4 - d0, 0.0D, d5 - d1); + entity.o *= 0.20000000298023224D; + entity.q *= 0.20000000298023224D; + entity.f(d4 + d0, 0.0D, d5 + d1); + } + } else { + this.f(-d0, 0.0D, -d1); + entity.f(d0 / 4.0D, 0.0D, d1 / 4.0D); + } + } + } + } + + public int a() { + return 27; + } + + public ItemStack a(int i) { + return this.ai[i]; + } +} diff --git a/net/minecraft/server/EntityMonster.java b/net/minecraft/server/EntityMonster.java new file mode 100644 index 000000000..6e2ceacf0 --- /dev/null +++ b/net/minecraft/server/EntityMonster.java @@ -0,0 +1,83 @@ +package net.minecraft.server; + +public class EntityMonster extends EntityCreature implements IMonster { + + protected int af = 2; + + public EntityMonster(World world) { + super(world); + this.aM = 20; + } + + public void y() { + float f = this.b(1.0F); + + if (f > 0.5F) { + this.bc += 2; + } + + super.y(); + } + + public void b_() { + super.b_(); + if (this.h.l == 0) { + this.j(); + } + } + + protected Entity i() { + EntityHuman entityhuman = this.h.a(this, 16.0D); + + return entityhuman != null && this.g(entityhuman) ? entityhuman : null; + } + + public boolean a(Entity entity, int i) { + if (super.a(entity, i)) { + if (this.f != entity && this.g != entity) { + if (entity != this) { + this.ag = entity; + } + + return true; + } else { + return true; + } + } else { + return false; + } + } + + protected void a(Entity entity, float f) { + if ((double) f < 2.5D && entity.v.e > this.v.b && entity.v.b < this.v.e) { + this.aS = 20; + entity.a(this, this.af); + } + } + + protected float a(int i, int j, int k) { + return 0.5F - this.h.j(i, j, k); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + public boolean a() { + int i = MathHelper.b(this.l); + int j = MathHelper.b(this.v.b); + int k = MathHelper.b(this.n); + + if (this.h.a(EnumSkyBlock.SKY, i, j, k) > this.R.nextInt(32)) { + return false; + } else { + int l = this.h.h(i, j, k); + + return l <= this.R.nextInt(8) && super.a(); + } + } +} diff --git a/net/minecraft/server/EntityPainting.java b/net/minecraft/server/EntityPainting.java new file mode 100644 index 000000000..b6927d9b6 --- /dev/null +++ b/net/minecraft/server/EntityPainting.java @@ -0,0 +1,220 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +public class EntityPainting extends Entity { + + private int ad; + public int a; + private int ae; + private int af; + private int ag; + public EnumArt b; + + public EntityPainting(World world) { + super(world); + this.ad = 0; + this.a = 0; + this.C = 0.0F; + this.a(0.5F, 0.5F); + } + + public EntityPainting(World world, int i, int j, int k, int l) { + this(world); + this.ae = i; + this.af = j; + this.ag = k; + ArrayList arraylist = new ArrayList(); + EnumArt[] aenumart = EnumArt.values(); + int i1 = aenumart.length; + + for (int j1 = 0; j1 < i1; ++j1) { + EnumArt enumart = aenumart[j1]; + + this.b = enumart; + this.a(l); + if (this.b()) { + arraylist.add(enumart); + } + } + + if (arraylist.size() > 0) { + this.b = (EnumArt) arraylist.get(this.R.nextInt(arraylist.size())); + } + + this.a(l); + } + + public void a(int i) { + this.a = i; + this.t = this.r = (float) (i * 90); + float f = (float) this.b.z; + float f1 = (float) this.b.A; + float f2 = (float) this.b.z; + + if (i != 0 && i != 2) { + f = 0.5F; + } else { + f2 = 0.5F; + } + + f /= 32.0F; + f1 /= 32.0F; + f2 /= 32.0F; + float f3 = (float) this.ae + 0.5F; + float f4 = (float) this.af + 0.5F; + float f5 = (float) this.ag + 0.5F; + float f6 = 0.5625F; + + if (i == 0) { + f5 -= f6; + } + + if (i == 1) { + f3 -= f6; + } + + if (i == 2) { + f5 += f6; + } + + if (i == 3) { + f3 += f6; + } + + if (i == 0) { + f3 -= this.c(this.b.z); + } + + if (i == 1) { + f5 += this.c(this.b.z); + } + + if (i == 2) { + f3 += this.c(this.b.z); + } + + if (i == 3) { + f5 -= this.c(this.b.z); + } + + f4 += this.c(this.b.A); + this.a((double) f3, (double) f4, (double) f5); + float f7 = -0.00625F; + + this.v.c((double) (f3 - f - f7), (double) (f4 - f1 - f7), (double) (f5 - f2 - f7), (double) (f3 + f + f7), (double) (f4 + f1 + f7), (double) (f5 + f2 + f7)); + } + + private float c(int i) { + return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F); + } + + public void b_() { + if (this.ad++ == 100 && !this.b()) { + this.ad = 0; + this.j(); + this.h.a((Entity) (new EntityItem(this.h, this.l, this.m, this.n, new ItemStack(Item.PAINTING)))); + } + } + + public boolean b() { + if (this.h.a((Entity) this, this.v).size() > 0) { + return false; + } else { + int i = this.b.z / 16; + int j = this.b.A / 16; + int k = this.ae; + int l = this.af; + int i1 = this.ag; + + if (this.a == 0) { + k = MathHelper.b(this.l - (double) ((float) this.b.z / 32.0F)); + } + + if (this.a == 1) { + i1 = MathHelper.b(this.n - (double) ((float) this.b.z / 32.0F)); + } + + if (this.a == 2) { + k = MathHelper.b(this.l - (double) ((float) this.b.z / 32.0F)); + } + + if (this.a == 3) { + i1 = MathHelper.b(this.n - (double) ((float) this.b.z / 32.0F)); + } + + l = MathHelper.b(this.m - (double) ((float) this.b.A / 32.0F)); + + int j1; + + for (int k1 = 0; k1 < i; ++k1) { + for (j1 = 0; j1 < j; ++j1) { + Material material; + + if (this.a != 0 && this.a != 2) { + material = this.h.c(this.ae, l + j1, i1 + k1); + } else { + material = this.h.c(k + k1, l + j1, this.ag); + } + + if (!material.a()) { + return false; + } + } + } + + List list = this.h.b((Entity) this, this.v); + + for (j1 = 0; j1 < list.size(); ++j1) { + if (list.get(j1) instanceof EntityPainting) { + return false; + } + } + + return true; + } + } + + public boolean c_() { + return true; + } + + public boolean a(Entity entity, int i) { + this.j(); + this.h.a((Entity) (new EntityItem(this.h, this.l, this.m, this.n, new ItemStack(Item.PAINTING)))); + return true; + } + + public void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Dir", (byte) this.a); + nbttagcompound.a("Motive", this.b.y); + nbttagcompound.a("TileX", this.ae); + nbttagcompound.a("TileY", this.af); + nbttagcompound.a("TileZ", this.ag); + } + + public void b(NBTTagCompound nbttagcompound) { + this.a = nbttagcompound.b("Dir"); + this.ae = nbttagcompound.d("TileX"); + this.af = nbttagcompound.d("TileY"); + this.ag = nbttagcompound.d("TileZ"); + String s = nbttagcompound.h("Motive"); + EnumArt[] aenumart = EnumArt.values(); + int i = aenumart.length; + + for (int j = 0; j < i; ++j) { + EnumArt enumart = aenumart[j]; + + if (enumart.y.equals(s)) { + this.b = enumart; + } + } + + if (this.b == null) { + this.b = EnumArt.KEBAB; + } + + this.a(this.a); + } +} diff --git a/net/minecraft/server/EntityPig.java b/net/minecraft/server/EntityPig.java new file mode 100644 index 000000000..03c12aecd --- /dev/null +++ b/net/minecraft/server/EntityPig.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +public class EntityPig extends EntityAnimal { + + public boolean a = false; + + public EntityPig(World world) { + super(world); + this.aC = "/mob/pig.png"; + this.a(0.9F, 0.9F); + this.a = false; + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + nbttagcompound.a("Saddle", this.a); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + this.a = nbttagcompound.l("Saddle"); + } + + protected String c() { + return "mob.pig"; + } + + protected String d() { + return "mob.pig"; + } + + protected String e() { + return "mob.pigdeath"; + } + + protected int g() { + return Item.PORK.aS; + } +} diff --git a/net/minecraft/server/EntityPlayer.java b/net/minecraft/server/EntityPlayer.java new file mode 100644 index 000000000..09ed1d50c --- /dev/null +++ b/net/minecraft/server/EntityPlayer.java @@ -0,0 +1,110 @@ +package net.minecraft.server; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +public class EntityPlayer extends EntityHuman { + + public NetServerHandler a; + public MinecraftServer b; + public ItemInWorldManager ad; + public double ae; + public double af; + public List ag = new LinkedList(); + public Set ah = new HashSet(); + public double ai; + + public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) { + super(world); + int i = world.n + this.R.nextInt(20) - 10; + int j = world.p + this.R.nextInt(20) - 10; + int k = world.d(i, j); + + this.c((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F); + this.b = minecraftserver; + this.N = 0.0F; + iteminworldmanager.a = this; + this.aq = s; + this.ad = iteminworldmanager; + this.C = 0.0F; + } + + public void b_() {} + + public void f(Entity entity) {} + + public boolean a(Entity entity, int i) { + return false; + } + + public void a(int i) {} + + public void i() { + super.b_(); + ChunkCoordIntPair chunkcoordintpair = null; + double d0 = 0.0D; + + for (int i = 0; i < this.ag.size(); ++i) { + ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) this.ag.get(i); + double d1 = chunkcoordintpair1.a(this); + + if (i == 0 || d1 < d0) { + chunkcoordintpair = chunkcoordintpair1; + d0 = chunkcoordintpair1.a(this); + } + } + + if (chunkcoordintpair != null) { + boolean flag = false; + + if (d0 < 1024.0D) { + flag = true; + } + + if (this.a.b() < 2) { + flag = true; + } + + if (flag) { + this.ag.remove(chunkcoordintpair); + this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.b.e))); + List list = this.b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16); + + for (int j = 0; j < list.size(); ++j) { + TileEntity tileentity = (TileEntity) list.get(j); + + this.a.b((Packet) (new Packet59ComplexEntity(tileentity.b, tileentity.c, tileentity.d, tileentity))); + } + } + } + } + + public void y() { + this.o = this.p = this.q = 0.0D; + this.bg = false; + super.y(); + } + + public void c(Entity entity, int i) { + if (!entity.B && entity instanceof EntityItem) { + this.a.b((Packet) (new Packet17AddToInventory(((EntityItem) entity).a, i))); + this.b.k.a(entity, new Packet22Collect(entity.c, this.c)); + } + + super.c(entity, i); + } + + public void z() { + if (!this.ao) { + this.ap = -1; + this.ao = true; + this.b.k.a(this, new Packet18ArmAnimation(this, 1)); + } + } + + protected float p() { + return 1.62F; + } +} diff --git a/net/minecraft/server/EntitySheep.java b/net/minecraft/server/EntitySheep.java new file mode 100644 index 000000000..c5716685a --- /dev/null +++ b/net/minecraft/server/EntitySheep.java @@ -0,0 +1,51 @@ +package net.minecraft.server; + +public class EntitySheep extends EntityAnimal { + + public boolean a = false; + + public EntitySheep(World world) { + super(world); + this.aC = "/mob/sheep.png"; + this.a(0.9F, 1.3F); + } + + public boolean a(Entity entity, int i) { + if (!this.a && entity instanceof EntityLiving) { + this.a = true; + int j = 1 + this.R.nextInt(3); + + for (int k = 0; k < j; ++k) { + EntityItem entityitem = this.a(Block.WOOL.bc, 1, 1.0F); + + entityitem.p += (double) (this.R.nextFloat() * 0.05F); + entityitem.o += (double) ((this.R.nextFloat() - this.R.nextFloat()) * 0.1F); + entityitem.q += (double) ((this.R.nextFloat() - this.R.nextFloat()) * 0.1F); + } + } + + return super.a(entity, i); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + nbttagcompound.a("Sheared", this.a); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + this.a = nbttagcompound.l("Sheared"); + } + + protected String c() { + return "mob.sheep"; + } + + protected String d() { + return "mob.sheep"; + } + + protected String e() { + return "mob.sheep"; + } +} diff --git a/net/minecraft/server/EntitySkeleton.java b/net/minecraft/server/EntitySkeleton.java new file mode 100644 index 000000000..130f54d80 --- /dev/null +++ b/net/minecraft/server/EntitySkeleton.java @@ -0,0 +1,68 @@ +package net.minecraft.server; + +public class EntitySkeleton extends EntityMonster { + + public EntitySkeleton(World world) { + super(world); + this.aC = "/mob/skeleton.png"; + } + + protected String c() { + return "mob.skeleton"; + } + + protected String d() { + return "mob.skeletonhurt"; + } + + protected String e() { + return "mob.skeletonhurt"; + } + + public void y() { + if (this.h.a()) { + float f = this.b(1.0F); + + if (f > 0.5F && this.h.g(MathHelper.b(this.l), MathHelper.b(this.m), MathHelper.b(this.n)) && this.R.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { + this.U = 300; + } + } + + super.y(); + } + + protected void a(Entity entity, float f) { + if (f < 10.0F) { + double d0 = entity.l - this.l; + double d1 = entity.n - this.n; + + if (this.aS == 0) { + EntityArrow entityarrow = new EntityArrow(this.h, this); + + ++entityarrow.m; + double d2 = entity.m - 0.20000000298023224D - entityarrow.m; + float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F; + + this.h.a(this, "random.bow", 1.0F, 1.0F / (this.R.nextFloat() * 0.4F + 0.8F)); + this.h.a((Entity) entityarrow); + entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F); + this.aS = 30; + } + + this.r = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F; + this.ah = true; + } + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + protected int g() { + return Item.ARROW.aS; + } +} diff --git a/net/minecraft/server/EntitySlime.java b/net/minecraft/server/EntitySlime.java new file mode 100644 index 000000000..dfdc7c495 --- /dev/null +++ b/net/minecraft/server/EntitySlime.java @@ -0,0 +1,133 @@ +package net.minecraft.server; + +public class EntitySlime extends EntityLiving implements IMonster { + + public float a; + public float b; + private int ae = 0; + public int ad = 1; + + public EntitySlime(World world) { + super(world); + this.aC = "/mob/slime.png"; + this.ad = 1 << this.R.nextInt(3); + this.C = 0.0F; + this.ae = this.R.nextInt(20) + 10; + this.c(this.ad); + } + + public void c(int i) { + this.ad = i; + this.a(0.6F * (float) i, 0.6F * (float) i); + this.aM = i * i; + this.a(this.l, this.m, this.n); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + nbttagcompound.a("Size", this.ad - 1); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + this.ad = nbttagcompound.d("Size") + 1; + } + + public void b_() { + this.b = this.a; + boolean flag = this.w; + + super.b_(); + if (this.w && !flag) { + for (int i = 0; i < this.ad * 8; ++i) { + float f = this.R.nextFloat() * 3.1415927F * 2.0F; + float f1 = this.R.nextFloat() * 0.5F + 0.5F; + float f2 = MathHelper.a(f) * (float) this.ad * 0.5F * f1; + float f3 = MathHelper.b(f) * (float) this.ad * 0.5F * f1; + + this.h.a("slime", this.l + (double) f2, this.v.b, this.n + (double) f3, 0.0D, 0.0D, 0.0D); + } + + if (this.ad > 2) { + this.h.a(this, "mob.slime", this.f(), ((this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F) / 0.8F); + } + + this.a = -0.5F; + } + + this.a *= 0.6F; + } + + protected void d_() { + EntityHuman entityhuman = this.h.a(this, 16.0D); + + if (entityhuman != null) { + this.b(entityhuman, 10.0F); + } + + if (this.w && this.ae-- <= 0) { + this.ae = this.R.nextInt(20) + 10; + if (entityhuman != null) { + this.ae /= 3; + } + + this.bg = true; + if (this.ad > 1) { + this.h.a(this, "mob.slime", this.f(), ((this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F) * 0.8F); + } + + this.a = 1.0F; + this.bd = 1.0F - this.R.nextFloat() * 2.0F; + this.be = (float) (1 * this.ad); + } else { + this.bg = false; + if (this.w) { + this.bd = this.be = 0.0F; + } + } + } + + public void j() { + if (this.ad > 1 && this.aM == 0) { + for (int i = 0; i < 4; ++i) { + float f = ((float) (i % 2) - 0.5F) * (float) this.ad / 4.0F; + float f1 = ((float) (i / 2) - 0.5F) * (float) this.ad / 4.0F; + EntitySlime entityslime = new EntitySlime(this.h); + + entityslime.c(this.ad / 2); + entityslime.c(this.l + (double) f, this.m + 0.5D, this.n + (double) f1, this.R.nextFloat() * 360.0F, 0.0F); + this.h.a((Entity) entityslime); + } + } + + super.j(); + } + + public void a(EntityHuman entityhuman) { + if (this.ad > 1 && this.g(entityhuman) && (double) this.a((Entity) entityhuman) < 0.6D * (double) this.ad && entityhuman.a(this, this.ad)) { + this.h.a(this, "mob.slimeattack", 1.0F, (this.R.nextFloat() - this.R.nextFloat()) * 0.2F + 1.0F); + } + } + + protected String d() { + return "mob.slime"; + } + + protected String e() { + return "mob.slime"; + } + + protected int g() { + return this.ad == 1 ? Item.SLIME_BALL.aS : 0; + } + + public boolean a() { + Chunk chunk = this.h.a(MathHelper.b(this.l), MathHelper.b(this.m)); + + return (this.ad == 1 || this.h.l > 0) && this.R.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.m < 16.0D; + } + + protected float f() { + return 0.6F; + } +} diff --git a/net/minecraft/server/EntitySnowball.java b/net/minecraft/server/EntitySnowball.java new file mode 100644 index 000000000..485499809 --- /dev/null +++ b/net/minecraft/server/EntitySnowball.java @@ -0,0 +1,172 @@ +package net.minecraft.server; + +import java.util.List; + +public class EntitySnowball extends Entity { + + private int b = -1; + private int ad = -1; + private int ae = -1; + private int af = 0; + private boolean ag = false; + public int a = 0; + private EntityLiving ah; + private int ai; + private int aj = 0; + + public EntitySnowball(World world) { + super(world); + this.a(0.25F, 0.25F); + } + + public void b_() { + super.b_(); + if (this.a > 0) { + --this.a; + } + + if (this.ag) { + int i = this.h.a(this.b, this.ad, this.ae); + + if (i == this.af) { + ++this.ai; + if (this.ai == 1200) { + this.j(); + } + + return; + } + + this.ag = false; + this.o *= (double) (this.R.nextFloat() * 0.2F); + this.p *= (double) (this.R.nextFloat() * 0.2F); + this.q *= (double) (this.R.nextFloat() * 0.2F); + this.ai = 0; + this.aj = 0; + } else { + ++this.aj; + } + + Vec3D vec3d = Vec3D.b(this.l, this.m, this.n); + Vec3D vec3d1 = Vec3D.b(this.l + this.o, this.m + this.p, this.n + this.q); + MovingObjectPosition movingobjectposition = this.h.a(vec3d, vec3d1); + + vec3d = Vec3D.b(this.l, this.m, this.n); + vec3d1 = Vec3D.b(this.l + this.o, this.m + this.p, this.n + this.q); + if (movingobjectposition != null) { + vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); + } + + Entity entity = null; + List list = this.h.b((Entity) this, this.v.a(this.o, this.p, this.q).b(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + + int j; + float f; + + for (j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if (entity1.c_() && (entity1 != this.ah || this.aj >= 5)) { + f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.v.b((double) f, (double) f, (double) f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); + + if (movingobjectposition1 != null) { + double d1 = vec3d.a(movingobjectposition1.f); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) { + if (movingobjectposition.g != null && movingobjectposition.g.a(this.ah, 0)) { + ; + } + + for (j = 0; j < 8; ++j) { + this.h.a("snowballpoof", this.l, this.m, this.n, 0.0D, 0.0D, 0.0D); + } + + this.j(); + } + + this.l += this.o; + this.m += this.p; + this.n += this.q; + float f1 = MathHelper.a(this.o * this.o + this.q * this.q); + + this.r = (float) (Math.atan2(this.o, this.q) * 180.0D / 3.1415927410125732D); + + for (this.s = (float) (Math.atan2(this.p, (double) f1) * 180.0D / 3.1415927410125732D); this.s - this.u < -180.0F; this.u -= 360.0F) { + ; + } + + while (this.s - this.u >= 180.0F) { + this.u += 360.0F; + } + + while (this.r - this.t < -180.0F) { + this.t -= 360.0F; + } + + while (this.r - this.t >= 180.0F) { + this.t += 360.0F; + } + + this.s = this.u + (this.s - this.u) * 0.2F; + this.r = this.t + (this.r - this.t) * 0.2F; + float f2 = 0.99F; + + f = 0.03F; + if (this.o()) { + for (int k = 0; k < 4; ++k) { + float f3 = 0.25F; + + this.h.a("bubble", this.l - this.o * (double) f3, this.m - this.p * (double) f3, this.n - this.q * (double) f3, this.o, this.p, this.q); + } + + f2 = 0.8F; + } + + this.o *= (double) f2; + this.p *= (double) f2; + this.q *= (double) f2; + this.p -= (double) f; + this.a(this.l, this.m, this.n); + } + + public void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("xTile", (short) this.b); + nbttagcompound.a("yTile", (short) this.ad); + nbttagcompound.a("zTile", (short) this.ae); + nbttagcompound.a("inTile", (byte) this.af); + nbttagcompound.a("shake", (byte) this.a); + nbttagcompound.a("inGround", (byte) (this.ag ? 1 : 0)); + } + + public void b(NBTTagCompound nbttagcompound) { + this.b = nbttagcompound.c("xTile"); + this.ad = nbttagcompound.c("yTile"); + this.ae = nbttagcompound.c("zTile"); + this.af = nbttagcompound.b("inTile") & 255; + this.a = nbttagcompound.b("shake") & 255; + this.ag = nbttagcompound.b("inGround") == 1; + } + + public void a(EntityHuman entityhuman) { + if (this.ag && this.ah == entityhuman && this.a <= 0 && entityhuman.aj.a(new ItemStack(Item.ARROW.aS, 1))) { + this.h.a(this, "random.pop", 0.2F, ((this.R.nextFloat() - this.R.nextFloat()) * 0.7F + 1.0F) * 2.0F); + entityhuman.c(this, 1); + this.j(); + } + } +} diff --git a/net/minecraft/server/EntitySpider.java b/net/minecraft/server/EntitySpider.java new file mode 100644 index 000000000..e3c8dae1f --- /dev/null +++ b/net/minecraft/server/EntitySpider.java @@ -0,0 +1,73 @@ +package net.minecraft.server; + +public class EntitySpider extends EntityMonster { + + public EntitySpider(World world) { + super(world); + this.aC = "/mob/spider.png"; + this.a(1.4F, 0.9F); + this.bi = 0.8F; + } + + public double h() { + return (double) this.E * 0.75D - 0.5D; + } + + protected Entity i() { + float f = this.b(1.0F); + + if (f < 0.5F) { + double d0 = 16.0D; + + return this.h.a(this, d0); + } else { + return null; + } + } + + protected String c() { + return "mob.spider"; + } + + protected String d() { + return "mob.spider"; + } + + protected String e() { + return "mob.spiderdeath"; + } + + protected void a(Entity entity, float f) { + float f1 = this.b(1.0F); + + if (f1 > 0.5F && this.R.nextInt(100) == 0) { + this.ag = null; + } else { + if (f > 2.0F && f < 6.0F && this.R.nextInt(10) == 0) { + if (this.w) { + double d0 = entity.l - this.l; + double d1 = entity.n - this.n; + float f2 = MathHelper.a(d0 * d0 + d1 * d1); + + this.o = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.o * 0.20000000298023224D; + this.q = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.q * 0.20000000298023224D; + this.p = 0.4000000059604645D; + } + } else { + super.a(entity, f); + } + } + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + protected int g() { + return Item.STRING.aS; + } +} diff --git a/net/minecraft/server/EntityTNTPrimed.java b/net/minecraft/server/EntityTNTPrimed.java new file mode 100644 index 000000000..4ff535e15 --- /dev/null +++ b/net/minecraft/server/EntityTNTPrimed.java @@ -0,0 +1,69 @@ +package net.minecraft.server; + +public class EntityTNTPrimed extends Entity { + + public int a; + + public EntityTNTPrimed(World world) { + super(world); + this.a = 0; + this.e = true; + this.a(0.98F, 0.98F); + this.C = this.E / 2.0F; + } + + public EntityTNTPrimed(World world, float f, float f1, float f2) { + this(world); + this.a(f, f1, f2); + float f = (float) (Math.random() * 3.141592741012573D * 2.0D); + + this.o = (double) (-MathHelper.a(f * 3.141593F / 180.0F) * 0.02F); + this.p = 0.2000000029802322D; + this.q = (double) (-MathHelper.b(f * 3.141593F / 180.0F) * 0.02F); + this.H = false; + this.a = 80; + this.i = (double) f; + this.j = (double) f1; + this.k = (double) f2; + } + + public boolean c_() { + return !this.B; + } + + public void b_() { + this.i = this.l; + this.j = this.m; + this.k = this.n; + this.p -= 0.03999999910593033D; + this.c(this.o, this.p, this.q); + this.o *= 0.9800000190734863D; + this.p *= 0.9800000190734863D; + this.q *= 0.9800000190734863D; + if (this.w) { + this.o *= 0.699999988079071D; + this.q *= 0.699999988079071D; + this.p *= -0.5D; + } + + if (this.a-- <= 0) { + this.j(); + } else { + this.h.a("smoke", this.l, this.m + 0.5D, this.n, 0.0D, 0.0D, 0.0D); + } + } + + private void b() { + float f = 4.0F; + + this.h.a((Entity) null, this.l, this.m, this.n, f); + } + + protected void a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("Fuse", (byte) this.a); + } + + protected void b(NBTTagCompound nbttagcompound) { + this.a = nbttagcompound.b("Fuse"); + } +} diff --git a/net/minecraft/server/EntityTracker.java b/net/minecraft/server/EntityTracker.java new file mode 100644 index 000000000..f1b14830e --- /dev/null +++ b/net/minecraft/server/EntityTracker.java @@ -0,0 +1,101 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class EntityTracker { + + private Set a = new HashSet(); + private EntityList b = new EntityList(); + private MinecraftServer c; + private int d; + + public EntityTracker(MinecraftServer minecraftserver) { + this.c = minecraftserver; + this.d = minecraftserver.f.a(); + } + + public void a(Entity entity) { + if (entity instanceof EntityPlayer) { + this.a(entity, 512, 2); + EntityPlayer entityplayer = (EntityPlayer) entity; + Iterator iterator = this.a.iterator(); + + while (iterator.hasNext()) { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); + + if (entitytrackerentry.a != entityplayer) { + entitytrackerentry.a(entityplayer); + } + } + } else if (entity instanceof EntityItem) { + this.a(entity, 64, 20); + } else if (entity instanceof EntityMinecart) { + this.a(entity, 160, 4); + } else if (entity instanceof IAnimal) { + this.a(entity, 160, 2); + } + } + + public void a(Entity entity, int i, int j) { + if (i > this.d) { + i = this.d; + } + + if (this.b.b(entity.c)) { + throw new IllegalStateException("Entity is already tracked!"); + } else { + EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(entity, i, j); + + this.a.add(entitytrackerentry); + this.b.a(entity.c, entitytrackerentry); + entitytrackerentry.b(this.c.e.k); + } + } + + public void b(Entity entity) { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.b.d(entity.c); + + if (entitytrackerentry != null) { + this.a.remove(entitytrackerentry); + entitytrackerentry.a(); + } + } + + public void a() { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.a.iterator(); + + while (iterator.hasNext()) { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); + + entitytrackerentry.a(this.c.e.k); + if (entitytrackerentry.j && entitytrackerentry.a instanceof EntityPlayer) { + arraylist.add((EntityPlayer) entitytrackerentry.a); + } + } + + for (int i = 0; i < arraylist.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) arraylist.get(i); + Iterator iterator1 = this.a.iterator(); + + while (iterator1.hasNext()) { + EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next(); + + if (entitytrackerentry1.a != entityplayer) { + entitytrackerentry1.a(entityplayer); + } + } + } + } + + public void a(Entity entity, Packet packet) { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.b.a(entity.c); + + if (entitytrackerentry != null) { + entitytrackerentry.a(packet); + } + } +} diff --git a/net/minecraft/server/EntityTrackerEntry.java b/net/minecraft/server/EntityTrackerEntry.java new file mode 100644 index 000000000..2f5a2e192 --- /dev/null +++ b/net/minecraft/server/EntityTrackerEntry.java @@ -0,0 +1,172 @@ +package net.minecraft.server; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +public class EntityTrackerEntry { + + public Entity a; + public int b; + public int c; + public int d; + public int e; + public int f; + public int g; + public int h; + public int i = 0; + private double l; + private double m; + private double n; + private boolean o = false; + public boolean j = false; + public Set k = new HashSet(); + + public EntityTrackerEntry(Entity entity, int i, int j) { + this.a = entity; + this.b = i; + this.c = j; + this.d = MathHelper.b(entity.l * 32.0D); + this.e = MathHelper.b(entity.m * 32.0D); + this.f = MathHelper.b(entity.n * 32.0D); + this.g = MathHelper.d(entity.r * 256.0F / 360.0F); + this.h = MathHelper.d(entity.s * 256.0F / 360.0F); + } + + public boolean equals(Object object) { + return object instanceof EntityTrackerEntry ? ((EntityTrackerEntry) object).a.c == this.a.c : false; + } + + public int hashCode() { + return this.a.c; + } + + public void a(List list) { + this.j = false; + if (!this.o || this.a.d(this.l, this.m, this.n) > 16.0D) { + this.b(list); + this.l = this.a.l; + this.m = this.a.m; + this.n = this.a.n; + this.o = true; + this.j = true; + } + + if (this.i++ % this.c == 0) { + int i = MathHelper.b(this.a.l * 32.0D); + int j = MathHelper.b(this.a.m * 32.0D); + int k = MathHelper.b(this.a.n * 32.0D); + int l = MathHelper.d(this.a.r * 256.0F / 360.0F); + int i1 = MathHelper.d(this.a.s * 256.0F / 360.0F); + boolean flag = i != this.d || j != this.e || k != this.f; + boolean flag1 = l != this.g || i1 != this.h; + int j1 = i - this.d; + int k1 = j - this.e; + int l1 = k - this.f; + Object object = null; + + if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128) { + if (flag && flag1) { + object = new Packet33RelEntityMoveLook(this.a.c, (byte) j1, (byte) k1, (byte) l1, (byte) l, (byte) i1); + } else if (flag) { + object = new Packet31RelEntityMove(this.a.c, (byte) j1, (byte) k1, (byte) l1); + } else if (flag1) { + object = new Packet32EntityLook(this.a.c, (byte) l, (byte) i1); + } else { + object = new Packet30Entity(this.a.c); + } + } else { + object = new Packet34EntityTeleport(this.a.c, i, j, k, (byte) l, (byte) i1); + } + + if (object != null) { + this.a((Packet) object); + } + + this.d = i; + this.e = j; + this.f = k; + this.g = l; + this.h = i1; + } + } + + public void a(Packet packet) { + Iterator iterator = this.k.iterator(); + + while (iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer) iterator.next(); + + entityplayer.a.b(packet); + } + } + + public void a() { + this.a((Packet) (new Packet29DestroyEntity(this.a.c))); + } + + public void a(EntityPlayer entityplayer) { + if (entityplayer != this.a) { + double d0 = entityplayer.l - (double) (this.d / 32); + double d1 = entityplayer.n - (double) (this.f / 32); + + if (d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b) { + if (!this.k.contains(entityplayer)) { + this.k.add(entityplayer); + entityplayer.a.b(this.b()); + } + } else if (this.k.contains(entityplayer)) { + this.k.remove(entityplayer); + entityplayer.a.b((Packet) (new Packet29DestroyEntity(this.a.c))); + } + } + } + + public void b(List list) { + for (int i = 0; i < list.size(); ++i) { + this.a((EntityPlayer) list.get(i)); + } + } + + private Packet b() { + if (this.a instanceof EntityItem) { + EntityItem entityitem = (EntityItem) this.a; + Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem); + + entityitem.l = (double) packet21pickupspawn.b / 32.0D; + entityitem.m = (double) packet21pickupspawn.c / 32.0D; + entityitem.n = (double) packet21pickupspawn.d / 32.0D; + entityitem.o = (double) packet21pickupspawn.e / 128.0D; + entityitem.p = (double) packet21pickupspawn.f / 128.0D; + entityitem.q = (double) packet21pickupspawn.g / 128.0D; + return packet21pickupspawn; + } else if (this.a instanceof EntityPlayer) { + return new Packet20NamedEntitySpawn((EntityHuman) this.a); + } else { + if (this.a instanceof EntityMinecart) { + EntityMinecart entityminecart = (EntityMinecart) this.a; + + if (entityminecart.ae == 0) { + return new Packet23VehicleSpawn(this.a, 10); + } + + if (entityminecart.ae == 1) { + return new Packet23VehicleSpawn(this.a, 11); + } + + if (entityminecart.ae == 2) { + return new Packet23VehicleSpawn(this.a, 12); + } + } + + if (this.a instanceof EntityBoat) { + return new Packet23VehicleSpawn(this.a, 1); + } else if (this.a instanceof IAnimal) { + return new Packet24MobSpawn((EntityLiving) this.a); + } else { + throw new IllegalArgumentException("Don\'t know how to add " + this.a.getClass() + "!"); + } + } + } +} diff --git a/net/minecraft/server/EntityTypes.java b/net/minecraft/server/EntityTypes.java new file mode 100644 index 000000000..a9577da6e --- /dev/null +++ b/net/minecraft/server/EntityTypes.java @@ -0,0 +1,90 @@ +package net.minecraft.server; + +import java.util.HashMap; +import java.util.Map; + +public class EntityTypes { + + private static Map a = new HashMap(); + private static Map b = new HashMap(); + private static Map c = new HashMap(); + private static Map d = new HashMap(); + + public EntityTypes() {} + + private static void a(Class oclass, String s, int i) { + a.put(s, oclass); + b.put(oclass, s); + c.put(Integer.valueOf(i), oclass); + d.put(oclass, Integer.valueOf(i)); + } + + public static Entity a(String s, World world) { + Entity entity = null; + + try { + Class oclass = (Class) a.get(s); + + if (oclass != null) { + entity = (Entity) oclass.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + + return entity; + } + + public static Entity a(NBTTagCompound nbttagcompound, World world) { + Entity entity = null; + + try { + Class oclass = (Class) a.get(nbttagcompound.h("id")); + + if (oclass != null) { + entity = (Entity) oclass.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + + if (entity != null) { + entity.e(nbttagcompound); + } else { + System.out.println("Skipping Entity with id " + nbttagcompound.h("id")); + } + + return entity; + } + + public static int a(Entity entity) { + return ((Integer) d.get(entity.getClass())).intValue(); + } + + public static String b(Entity entity) { + return (String) b.get(entity.getClass()); + } + + static { + a(EntityArrow.class, "Arrow", 10); + a(EntitySnowball.class, "Snowball", 11); + a(EntityItem.class, "Item", 1); + a(EntityPainting.class, "Painting", 9); + a(EntityLiving.class, "Mob", 48); + a(EntityMonster.class, "Monster", 49); + a(EntityCreeper.class, "Creeper", 50); + a(EntitySkeleton.class, "Skeleton", 51); + a(EntitySpider.class, "Spider", 52); + a(EntityGiantZombie.class, "Giant", 53); + a(EntityZombie.class, "Zombie", 54); + a(EntitySlime.class, "Slime", 55); + a(EntityPig.class, "Pig", 90); + a(EntitySheep.class, "Sheep", 91); + a(EntityCow.class, "Cow", 91); + a(EntityChicken.class, "Chicken", 91); + a(EntityTNTPrimed.class, "PrimedTnt", 20); + a(EntityFallingSand.class, "FallingSand", 21); + a(EntityMinecart.class, "Minecart", 40); + a(EntityBoat.class, "Boat", 41); + } +} diff --git a/net/minecraft/server/EntityZombie.java b/net/minecraft/server/EntityZombie.java new file mode 100644 index 000000000..27f46e4ab --- /dev/null +++ b/net/minecraft/server/EntityZombie.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +public class EntityZombie extends EntityMonster { + + public EntityZombie(World world) { + super(world); + this.aC = "/mob/zombie.png"; + this.bi = 0.5F; + this.af = 5; + } + + public void y() { + if (this.h.a()) { + float f = this.b(1.0F); + + if (f > 0.5F && this.h.g(MathHelper.b(this.l), MathHelper.b(this.m), MathHelper.b(this.n)) && this.R.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { + this.U = 300; + } + } + + super.y(); + } + + protected String c() { + return "mob.zombie"; + } + + protected String d() { + return "mob.zombiehurt"; + } + + protected String e() { + return "mob.zombiedeath"; + } + + protected int g() { + return Item.FEATHER.aS; + } +} diff --git a/net/minecraft/server/EnumArt.java b/net/minecraft/server/EnumArt.java new file mode 100644 index 000000000..9eb6c944a --- /dev/null +++ b/net/minecraft/server/EnumArt.java @@ -0,0 +1,21 @@ +package net.minecraft.server; + +public enum EnumArt { + + KEBAB("Kebab", 0, "Kebab", 16, 16, 0, 0), AZTEC("Aztec", 1, "Aztec", 16, 16, 16, 0), ALBAN("Alban", 2, "Alban", 16, 16, 32, 0), AZTEC2("Aztec2", 3, "Aztec2", 16, 16, 48, 0), BOMB("Bomb", 4, "Bomb", 16, 16, 64, 0), PLANT("Plant", 5, "Plant", 16, 16, 80, 0), WASTELAND("Wasteland", 6, "Wasteland", 16, 16, 96, 0), POOL("Pool", 7, "Pool", 32, 16, 0, 32), COURBET("Courbet", 8, "Courbet", 32, 16, 32, 32), SEA("Sea", 9, "Sea", 32, 16, 64, 32), SUNSET("Sunset", 10, "Sunset", 32, 16, 96, 32), CREEBET("Creebet", 11, "Creebet", 32, 16, 128, 32), WANDERER("Wanderer", 12, "Wanderer", 16, 32, 0, 64), GRAHAM("Graham", 13, "Graham", 16, 32, 16, 64), MATCH("Match", 14, "Match", 32, 32, 0, 128), BUST("Bust", 15, "Bust", 32, 32, 32, 128), STAGE("Stage", 16, "Stage", 32, 32, 64, 128), VOID("Void", 17, "Void", 32, 32, 96, 128), SKULL_AND_ROSES("SkullAndRoses", 18, "SkullAndRoses", 32, 32, 128, 128), FIGHTERS("Fighters", 19, "Fighters", 64, 32, 0, 96), POINTER("Pointer", 20, "Pointer", 64, 64, 0, 192), PIGSCENE("Pigscene", 21, "Pigscene", 64, 64, 64, 192), BURNINGSKULL("Skeleton", 22, "Skeleton", 64, 48, 192, 64), SKELETON("DonkeyKong", 23, "DonkeyKong", 64, 48, 192, 112); + public final String y; + public final int z; + public final int A; + public final int B; + public final int C; + + private static final EnumArt[] D = new EnumArt[] { KEBAB, AZTEC, ALBAN, AZTEC2, BOMB, PLANT, WASTELAND, POOL, COURBET, SEA, SUNSET, CREEBET, WANDERER, GRAHAM, MATCH, BUST, STAGE, VOID, SKULL_AND_ROSES, FIGHTERS, POINTER, PIGSCENE, BURNINGSKULL, SKELETON}; + + private EnumArt(String s, int i, String s1, int j, int k, int l, int i1) { + this.y = s1; + this.z = j; + this.A = k; + this.B = l; + this.C = i1; + } +} diff --git a/net/minecraft/server/EnumMobType.java b/net/minecraft/server/EnumMobType.java new file mode 100644 index 000000000..b8da2b01c --- /dev/null +++ b/net/minecraft/server/EnumMobType.java @@ -0,0 +1,10 @@ +package net.minecraft.server; + +public enum EnumMobType { + + EVERYTHING("everything", 0), MOBS("mobs", 1), PLAYERS("players", 2); + + private static final EnumMobType[] d = new EnumMobType[] { EVERYTHING, MOBS, PLAYERS}; + + private EnumMobType(String s, int i) {} +} diff --git a/net/minecraft/server/EnumSkyBlock.java b/net/minecraft/server/EnumSkyBlock.java new file mode 100644 index 000000000..d34a61591 --- /dev/null +++ b/net/minecraft/server/EnumSkyBlock.java @@ -0,0 +1,13 @@ +package net.minecraft.server; + +public enum EnumSkyBlock { + + SKY("Sky", 0, 15), BLOCK("Block", 1, 0); + public final int c; + + private static final EnumSkyBlock[] d = new EnumSkyBlock[] { SKY, BLOCK}; + + private EnumSkyBlock(String s, int i, int j) { + this.c = j; + } +} diff --git a/net/minecraft/server/Explosion.java b/net/minecraft/server/Explosion.java new file mode 100644 index 000000000..a7256d686 --- /dev/null +++ b/net/minecraft/server/Explosion.java @@ -0,0 +1,141 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +public class Explosion { + + public Explosion() {} + + public void a(World world, Entity entity, double d0, double d1, double d2, float f) { + world.a(d0, d1, d2, "random.explode", 4.0F, (1.0F + (world.m.nextFloat() - world.m.nextFloat()) * 0.2F) * 0.7F); + HashSet hashset = new HashSet(); + float f1 = f; + byte b0 = 16; + + int i; + int j; + int k; + double d3; + double d4; + double d5; + + for (i = 0; i < b0; ++i) { + for (j = 0; j < b0; ++j) { + for (k = 0; k < b0; ++k) { + if (i == 0 || i == b0 - 1 || j == 0 || j == b0 - 1 || k == 0 || k == b0 - 1) { + double d6 = (double) ((float) i / ((float) b0 - 1.0F) * 2.0F - 1.0F); + double d7 = (double) ((float) j / ((float) b0 - 1.0F) * 2.0F - 1.0F); + double d8 = (double) ((float) k / ((float) b0 - 1.0F) * 2.0F - 1.0F); + double d9 = Math.sqrt(d6 * d6 + d7 * d7 + d8 * d8); + + d6 /= d9; + d7 /= d9; + d8 /= d9; + float f2 = f * (0.7F + world.m.nextFloat() * 0.6F); + + d3 = d0; + d4 = d1; + d5 = d2; + + for (float f3 = 0.3F; f2 > 0.0F; f2 -= f3 * 0.75F) { + int l = MathHelper.b(d3); + int i1 = MathHelper.b(d4); + int j1 = MathHelper.b(d5); + int k1 = world.a(l, i1, j1); + + if (k1 > 0) { + f2 -= (Block.n[k1].a(entity) + 0.3F) * f3; + } + + if (f2 > 0.0F) { + hashset.add(new ChunkPosition(l, i1, j1)); + } + + d3 += d6 * (double) f3; + d4 += d7 * (double) f3; + d5 += d8 * (double) f3; + } + } + } + } + } + + f *= 2.0F; + i = MathHelper.b(d0 - (double) f - 1.0D); + j = MathHelper.b(d0 + (double) f + 1.0D); + k = MathHelper.b(d1 - (double) f - 1.0D); + int l1 = MathHelper.b(d1 + (double) f + 1.0D); + int i2 = MathHelper.b(d2 - (double) f - 1.0D); + int j2 = MathHelper.b(d2 + (double) f + 1.0D); + List list = world.b(entity, AxisAlignedBB.b((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2)); + Vec3D vec3d = Vec3D.b(d0, d1, d2); + + double d10; + double d11; + double d12; + + for (int k2 = 0; k2 < list.size(); ++k2) { + Entity entity1 = (Entity) list.get(k2); + double d13 = entity1.e(d0, d1, d2) / (double) f; + + if (d13 <= 1.0D) { + d3 = entity1.l - d0; + d4 = entity1.m - d1; + d5 = entity1.n - d2; + d11 = (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5); + d3 /= d11; + d4 /= d11; + d5 /= d11; + d10 = (double) world.a(vec3d, entity1.v); + d12 = (1.0D - d13) * d10; + entity1.a(entity, (int) ((d12 * d12 + d12) / 2.0D * 8.0D * (double) f + 1.0D)); + entity1.o += d3 * d12; + entity1.p += d4 * d12; + entity1.q += d5 * d12; + } + } + + f = f1; + ArrayList arraylist = new ArrayList(); + + arraylist.addAll(hashset); + + for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) { + ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2); + int i3 = chunkposition.a; + int j3 = chunkposition.b; + int k3 = chunkposition.c; + int l3 = world.a(i3, j3, k3); + + for (int i4 = 0; i4 < 1; ++i4) { + d5 = (double) ((float) i3 + world.m.nextFloat()); + d11 = (double) ((float) j3 + world.m.nextFloat()); + d10 = (double) ((float) k3 + world.m.nextFloat()); + d12 = d5 - d0; + double d14 = d11 - d1; + double d15 = d10 - d2; + double d16 = (double) MathHelper.a(d12 * d12 + d14 * d14 + d15 * d15); + + d12 /= d16; + d14 /= d16; + d15 /= d16; + double d17 = 0.5D / (d16 / (double) f + 0.1D); + + d17 *= (double) (world.m.nextFloat() * world.m.nextFloat() + 0.3F); + d12 *= d17; + d14 *= d17; + d15 *= d17; + world.a("explode", (d5 + d0 * 1.0D) / 2.0D, (d11 + d1 * 1.0D) / 2.0D, (d10 + d2 * 1.0D) / 2.0D, d12, d14, d15); + world.a("smoke", d5, d11, d10, d12, d14, d15); + } + + if (l3 > 0) { + Block.n[l3].a(world, i3, j3, k3, world.b(i3, j3, k3), 0.3F); + world.d(i3, j3, k3, 0); + Block.n[l3].c(world, i3, j3, k3); + } + } + } +} diff --git a/net/minecraft/server/GuiLogFormatter.java b/net/minecraft/server/GuiLogFormatter.java new file mode 100644 index 000000000..6805b4288 --- /dev/null +++ b/net/minecraft/server/GuiLogFormatter.java @@ -0,0 +1,50 @@ +package net.minecraft.server; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +class GuiLogFormatter extends Formatter { + + final GuiLogOutputHandler a; + + GuiLogFormatter(GuiLogOutputHandler guilogoutputhandler) { + this.a = guilogoutputhandler; + } + + public String format(LogRecord logrecord) { + StringBuilder stringbuilder = new StringBuilder(); + Level level = logrecord.getLevel(); + + if (level == Level.FINEST) { + stringbuilder.append("[FINEST] "); + } else if (level == Level.FINER) { + stringbuilder.append("[FINER] "); + } else if (level == Level.FINE) { + stringbuilder.append("[FINE] "); + } else if (level == Level.INFO) { + stringbuilder.append("[INFO] "); + } else if (level == Level.WARNING) { + stringbuilder.append("[WARNING] "); + } else if (level == Level.SEVERE) { + stringbuilder.append("[SEVERE] "); + } else if (level == Level.SEVERE) { + stringbuilder.append("[" + level.getLocalizedName() + "] "); + } + + stringbuilder.append(logrecord.getMessage()); + stringbuilder.append('\n'); + Throwable throwable = logrecord.getThrown(); + + if (throwable != null) { + StringWriter stringwriter = new StringWriter(); + + throwable.printStackTrace(new PrintWriter(stringwriter)); + stringbuilder.append(stringwriter.toString()); + } + + return stringbuilder.toString(); + } +} diff --git a/net/minecraft/server/GuiLogOutputHandler.java b/net/minecraft/server/GuiLogOutputHandler.java new file mode 100644 index 000000000..8c7a2dae4 --- /dev/null +++ b/net/minecraft/server/GuiLogOutputHandler.java @@ -0,0 +1,38 @@ +package net.minecraft.server; + +import java.util.logging.Formatter; +import java.util.logging.Handler; +import java.util.logging.LogRecord; +import javax.swing.JTextArea; + +public class GuiLogOutputHandler extends Handler { + + private int[] b = new int[1024]; + private int c = 0; + Formatter a = new GuiLogFormatter(this); + private JTextArea d; + + public GuiLogOutputHandler(JTextArea jtextarea) { + this.setFormatter(this.a); + this.d = jtextarea; + } + + public void close() {} + + public void flush() {} + + public void publish(LogRecord logrecord) { + int i = this.d.getDocument().getLength(); + + this.d.append(this.a.format(logrecord)); + this.d.setCaretPosition(this.d.getDocument().getLength()); + int j = this.d.getDocument().getLength() - i; + + if (this.b[this.c] != 0) { + this.d.replaceRange("", 0, this.b[this.c]); + } + + this.b[this.c] = j; + this.c = (this.c + 1) % 1024; + } +} diff --git a/net/minecraft/server/GuiStatsComponent.java b/net/minecraft/server/GuiStatsComponent.java new file mode 100644 index 000000000..102e0d799 --- /dev/null +++ b/net/minecraft/server/GuiStatsComponent.java @@ -0,0 +1,60 @@ +package net.minecraft.server; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import javax.swing.JComponent; +import javax.swing.Timer; + +public class GuiStatsComponent extends JComponent { + + private int[] a = new int[256]; + private int b = 0; + private String[] c = new String[10]; + + public GuiStatsComponent() { + this.setPreferredSize(new Dimension(256, 196)); + this.setMinimumSize(new Dimension(256, 196)); + this.setMaximumSize(new Dimension(256, 196)); + (new Timer(500, new GuiStatsListener(this))).start(); + this.setBackground(Color.BLACK); + } + + private void a() { + long i = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + + System.gc(); + this.c[0] = "Memory use: " + i / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; + this.c[1] = "Threads: " + NetworkManager.b + " + " + NetworkManager.c; + this.a[this.b++ & 255] = (int) (i * 100L / Runtime.getRuntime().maxMemory()); + this.repaint(); + } + + public void paint(Graphics graphics) { + graphics.setColor(new Color(16777215)); + graphics.fillRect(0, 0, 256, 192); + + int i; + + for (i = 0; i < 256; ++i) { + int j = this.a[i + this.b & 255]; + + graphics.setColor(new Color(j + 28 << 16)); + graphics.fillRect(i, 100 - j, 1, j); + } + + graphics.setColor(Color.BLACK); + + for (i = 0; i < this.c.length; ++i) { + String s = this.c[i]; + + if (s != null) { + graphics.drawString(s, 32, 116 + i * 16); + } + } + } + + static void a(GuiStatsComponent guistatscomponent) { + guistatscomponent.a(); + } +} diff --git a/net/minecraft/server/GuiStatsListener.java b/net/minecraft/server/GuiStatsListener.java new file mode 100644 index 000000000..c3eae6b71 --- /dev/null +++ b/net/minecraft/server/GuiStatsListener.java @@ -0,0 +1,17 @@ +package net.minecraft.server; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +class GuiStatsListener implements ActionListener { + + final GuiStatsComponent a; + + GuiStatsListener(GuiStatsComponent guistatscomponent) { + this.a = guistatscomponent; + } + + public void actionPerformed(ActionEvent actionevent) { + GuiStatsComponent.a(this.a); + } +} diff --git a/net/minecraft/server/IAnimal.java b/net/minecraft/server/IAnimal.java new file mode 100644 index 000000000..78d391493 --- /dev/null +++ b/net/minecraft/server/IAnimal.java @@ -0,0 +1,3 @@ +package net.minecraft.server; + +public interface IAnimal {} diff --git a/net/minecraft/server/IBlockAccess.java b/net/minecraft/server/IBlockAccess.java new file mode 100644 index 000000000..bb8bd3542 --- /dev/null +++ b/net/minecraft/server/IBlockAccess.java @@ -0,0 +1,12 @@ +package net.minecraft.server; + +public interface IBlockAccess { + + int a(int i, int j, int k); + + int b(int i, int j, int k); + + Material c(int i, int j, int k); + + boolean d(int i, int j, int k); +} diff --git a/net/minecraft/server/IChunkLoader.java b/net/minecraft/server/IChunkLoader.java new file mode 100644 index 000000000..4dc523d5c --- /dev/null +++ b/net/minecraft/server/IChunkLoader.java @@ -0,0 +1,14 @@ +package net.minecraft.server; + +public interface IChunkLoader { + + Chunk a(World world, int i, int j); + + void a(World world, Chunk chunk); + + void b(World world, Chunk chunk); + + void a(); + + void b(); +} diff --git a/net/minecraft/server/IChunkProvider.java b/net/minecraft/server/IChunkProvider.java new file mode 100644 index 000000000..71e024047 --- /dev/null +++ b/net/minecraft/server/IChunkProvider.java @@ -0,0 +1,16 @@ +package net.minecraft.server; + +public interface IChunkProvider { + + boolean a(int i, int j); + + Chunk b(int i, int j); + + void a(IChunkProvider ichunkprovider, int i, int j); + + boolean a(boolean flag, IProgressUpdate iprogressupdate); + + boolean a(); + + boolean b(); +} diff --git a/net/minecraft/server/ICommandListener.java b/net/minecraft/server/ICommandListener.java new file mode 100644 index 000000000..49ac7e0ff --- /dev/null +++ b/net/minecraft/server/ICommandListener.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +public interface ICommandListener { + + void b(String s); + + String c(); +} diff --git a/net/minecraft/server/IInventory.java b/net/minecraft/server/IInventory.java new file mode 100644 index 000000000..cf30ad573 --- /dev/null +++ b/net/minecraft/server/IInventory.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +public interface IInventory { + + int a(); + + ItemStack a(int i); +} diff --git a/net/minecraft/server/IMonster.java b/net/minecraft/server/IMonster.java new file mode 100644 index 000000000..0891c78de --- /dev/null +++ b/net/minecraft/server/IMonster.java @@ -0,0 +1,3 @@ +package net.minecraft.server; + +public interface IMonster extends IAnimal {} diff --git a/net/minecraft/server/IProgressUpdate.java b/net/minecraft/server/IProgressUpdate.java new file mode 100644 index 000000000..e2765e3e4 --- /dev/null +++ b/net/minecraft/server/IProgressUpdate.java @@ -0,0 +1,10 @@ +package net.minecraft.server; + +public interface IProgressUpdate { + + void a(String s); + + void b(String s); + + void a(int i); +} diff --git a/net/minecraft/server/IUpdatePlayerListBox.java b/net/minecraft/server/IUpdatePlayerListBox.java new file mode 100644 index 000000000..c62e6f239 --- /dev/null +++ b/net/minecraft/server/IUpdatePlayerListBox.java @@ -0,0 +1,6 @@ +package net.minecraft.server; + +public interface IUpdatePlayerListBox { + + void a(); +} diff --git a/net/minecraft/server/IWorldAccess.java b/net/minecraft/server/IWorldAccess.java new file mode 100644 index 000000000..374258675 --- /dev/null +++ b/net/minecraft/server/IWorldAccess.java @@ -0,0 +1,22 @@ +package net.minecraft.server; + +public interface IWorldAccess { + + void a(int i, int j, int k); + + void a(int i, int j, int k, int l, int i1, int j1); + + void a(String s, double d0, double d1, double d2, float f, float f1); + + void a(String s, double d0, double d1, double d2, double d3, double d4, double d5); + + void a(Entity entity); + + void b(Entity entity); + + void a(); + + void a(String s, int i, int j, int k); + + void a(int i, int j, int k, TileEntity tileentity); +} diff --git a/net/minecraft/server/InventoryLargeChest.java b/net/minecraft/server/InventoryLargeChest.java new file mode 100644 index 000000000..747159784 --- /dev/null +++ b/net/minecraft/server/InventoryLargeChest.java @@ -0,0 +1,22 @@ +package net.minecraft.server; + +public class InventoryLargeChest implements IInventory { + + private String a; + private IInventory b; + private IInventory c; + + public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) { + this.a = s; + this.b = iinventory; + this.c = iinventory1; + } + + public int a() { + return this.b.a() + this.c.a(); + } + + public ItemStack a(int i) { + return i >= this.b.a() ? this.c.a(i - this.b.a()) : this.b.a(i); + } +} diff --git a/net/minecraft/server/InventoryPlayer.java b/net/minecraft/server/InventoryPlayer.java new file mode 100644 index 000000000..03920ded7 --- /dev/null +++ b/net/minecraft/server/InventoryPlayer.java @@ -0,0 +1,274 @@ +package net.minecraft.server; + +public class InventoryPlayer implements IInventory { + + public ItemStack[] a = new ItemStack[37]; + public ItemStack[] b = new ItemStack[4]; + public ItemStack[] c = new ItemStack[4]; + public int d = 0; + private EntityHuman f; + public boolean e = false; + + public InventoryPlayer(EntityHuman entityhuman) { + this.f = entityhuman; + } + + public ItemStack b() { + return this.a[this.d]; + } + + private int c(int i) { + for (int j = 0; j < this.a.length; ++j) { + if (this.a[j] != null && this.a[j].c == i && this.a[j].a < this.a[j].b() && this.a[j].a < this.d()) { + return j; + } + } + + return -1; + } + + private int g() { + for (int i = 0; i < this.a.length; ++i) { + if (this.a[i] == null) { + return i; + } + } + + return -1; + } + + private int a(int i, int j) { + int k = this.c(i); + + if (k < 0) { + k = this.g(); + } + + if (k < 0) { + return j; + } else { + if (this.a[k] == null) { + this.a[k] = new ItemStack(i, 0); + } + + int l = j; + + if (j > this.a[k].b() - this.a[k].a) { + l = this.a[k].b() - this.a[k].a; + } + + if (l > this.d() - this.a[k].a) { + l = this.d() - this.a[k].a; + } + + if (l == 0) { + return j; + } else { + j -= l; + this.a[k].a += l; + this.a[k].b = 5; + return j; + } + } + } + + public void c() { + for (int i = 0; i < this.a.length; ++i) { + if (this.a[i] != null && this.a[i].b > 0) { + --this.a[i].b; + } + } + } + + public boolean a(ItemStack itemstack) { + if (itemstack.d == 0) { + itemstack.a = this.a(itemstack.c, itemstack.a); + if (itemstack.a == 0) { + return true; + } + } + + int i = this.g(); + + if (i >= 0) { + this.a[i] = itemstack; + this.a[i].b = 5; + return true; + } else { + return false; + } + } + + public void a(int i, ItemStack itemstack) { + ItemStack[] aitemstack = this.a; + + if (i >= aitemstack.length) { + i -= aitemstack.length; + aitemstack = this.b; + } + + if (i >= aitemstack.length) { + i -= aitemstack.length; + aitemstack = this.c; + } + + aitemstack[i] = itemstack; + } + + public float a(Block block) { + float f = 1.0F; + + if (this.a[this.d] != null) { + f *= this.a[this.d].a(block); + } + + return f; + } + + public NBTTagList a(NBTTagList nbttaglist) { + int i; + NBTTagCompound nbttagcompound; + + for (i = 0; i < this.a.length; ++i) { + if (this.a[i] != null) { + nbttagcompound = new NBTTagCompound(); + nbttagcompound.a("Slot", (byte) i); + this.a[i].a(nbttagcompound); + nbttaglist.a((NBTBase) nbttagcompound); + } + } + + for (i = 0; i < this.b.length; ++i) { + if (this.b[i] != null) { + nbttagcompound = new NBTTagCompound(); + nbttagcompound.a("Slot", (byte) (i + 100)); + this.b[i].a(nbttagcompound); + nbttaglist.a((NBTBase) nbttagcompound); + } + } + + for (i = 0; i < this.c.length; ++i) { + if (this.c[i] != null) { + nbttagcompound = new NBTTagCompound(); + nbttagcompound.a("Slot", (byte) (i + 80)); + this.c[i].a(nbttagcompound); + nbttaglist.a((NBTBase) nbttagcompound); + } + } + + return nbttaglist; + } + + public void b(NBTTagList nbttaglist) { + this.a = new ItemStack[36]; + this.b = new ItemStack[4]; + this.c = new ItemStack[4]; + + for (int i = 0; i < nbttaglist.b(); ++i) { + NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i); + int j = nbttagcompound.b("Slot") & 255; + + if (j >= 0 && j < this.a.length) { + this.a[j] = new ItemStack(nbttagcompound); + } + + if (j >= 80 && j < this.c.length + 80) { + this.c[j - 80] = new ItemStack(nbttagcompound); + } + + if (j >= 100 && j < this.b.length + 100) { + this.b[j - 100] = new ItemStack(nbttagcompound); + } + } + } + + public int a() { + return this.a.length + 4; + } + + public ItemStack a(int i) { + ItemStack[] aitemstack = this.a; + + if (i >= aitemstack.length) { + i -= aitemstack.length; + aitemstack = this.b; + } + + if (i >= aitemstack.length) { + i -= aitemstack.length; + aitemstack = this.c; + } + + return aitemstack[i]; + } + + public int d() { + return 64; + } + + public boolean b(Block block) { + if (block.bn != Material.d && block.bn != Material.e && block.bn != Material.t && block.bn != Material.s) { + return true; + } else { + ItemStack itemstack = this.a(this.d); + + return itemstack != null ? itemstack.b(block) : false; + } + } + + public int e() { + int i = 0; + int j = 0; + int k = 0; + + for (int l = 0; l < this.b.length; ++l) { + if (this.b[l] != null && this.b[l].a() instanceof ItemArmor) { + int i1 = this.b[l].c(); + int j1 = this.b[l].d; + int k1 = i1 - j1; + + j += k1; + k += i1; + int l1 = ((ItemArmor) this.b[l].a()).aY; + + i += l1; + } + } + + if (k == 0) { + return 0; + } else { + return (i - 1) * j / k + 1; + } + } + + public void b(int i) { + for (int j = 0; j < this.b.length; ++j) { + if (this.b[j] != null && this.b[j].a() instanceof ItemArmor) { + this.b[j].a(i); + if (this.b[j].a == 0) { + this.b[j].a(this.f); + this.b[j] = null; + } + } + } + } + + public void f() { + int i; + + for (i = 0; i < this.a.length; ++i) { + if (this.a[i] != null) { + this.f.a(this.a[i], true); + this.a[i] = null; + } + } + + for (i = 0; i < this.b.length; ++i) { + if (this.b[i] != null) { + this.f.a(this.b[i], true); + this.b[i] = null; + } + } + } +} diff --git a/net/minecraft/server/Item.java b/net/minecraft/server/Item.java new file mode 100644 index 000000000..84e2d7e8e --- /dev/null +++ b/net/minecraft/server/Item.java @@ -0,0 +1,148 @@ +package net.minecraft.server; + +import java.util.Random; + +public class Item { + + protected static Random b = new Random(); + public static Item[] c = new Item[32000]; + public static Item IRON_SPADE = (new ItemSpade(0, 2)).a(82); + public static Item IRON_PICKAXE = (new ItemPickaxe(1, 2)).a(98); + public static Item IRON_AXE = (new ItemAxe(2, 2)).a(114); + public static Item FLINT_AND_STEEL = (new ItemFlintAndSteel(3)).a(5); + public static Item APPLE = (new ItemFood(4, 4)).a(10); + public static Item BOW = (new ItemBow(5)).a(21); + public static Item ARROW = (new Item(6)).a(37); + public static Item COAL = (new Item(7)).a(7); + public static Item DIAMOND = (new Item(8)).a(55); + public static Item IRON_INGOT = (new Item(9)).a(23); + public static Item GOLD_INGOT = (new Item(10)).a(39); + public static Item IRON_SWORD = (new ItemSword(11, 2)).a(66); + public static Item WOOD_SWORD = (new ItemSword(12, 0)).a(64); + public static Item WOOD_SPADE = (new ItemSpade(13, 0)).a(80); + public static Item WOOD_PICKAXE = (new ItemPickaxe(14, 0)).a(96); + public static Item WOOD_AXE = (new ItemAxe(15, 0)).a(112); + public static Item STONE_SWORD = (new ItemSword(16, 1)).a(65); + public static Item STONE_SPADE = (new ItemSpade(17, 1)).a(81); + public static Item STONE_PICKAXE = (new ItemPickaxe(18, 1)).a(97); + public static Item STONE_AXE = (new ItemAxe(19, 1)).a(113); + public static Item DIAMOND_SWORD = (new ItemSword(20, 3)).a(67); + public static Item DIAMOND_SPADE = (new ItemSpade(21, 3)).a(83); + public static Item DIAMOND_PICKAXE = (new ItemPickaxe(22, 3)).a(99); + public static Item DIAMOND_AXE = (new ItemAxe(23, 3)).a(115); + public static Item STICK = (new Item(24)).a(53).c(); + public static Item BOWL = (new Item(25)).a(71); + public static Item MUSHROOM_SOUP = (new ItemSoup(26, 10)).a(72); + public static Item GOLD_SWORD = (new ItemSword(27, 0)).a(68); + public static Item GOLD_SPADE = (new ItemSpade(28, 0)).a(84); + public static Item GOLD_PICKAXE = (new ItemPickaxe(29, 0)).a(100); + public static Item GOLD_AXE = (new ItemAxe(30, 0)).a(116); + public static Item STRING = (new Item(31)).a(8); + public static Item FEATHER = (new Item(32)).a(24); + public static Item SULPHUR = (new Item(33)).a(40); + public static Item WOOD_HOE = (new ItemHoe(34, 0)).a(128); + public static Item STONE_HOE = (new ItemHoe(35, 1)).a(129); + public static Item IRON_HOE = (new ItemHoe(36, 2)).a(130); + public static Item DIAMOND_HOE = (new ItemHoe(37, 3)).a(131); + public static Item GOLD_HOE = (new ItemHoe(38, 1)).a(132); + public static Item SEEDS = (new ItemSeeds(39, Block.CROPS.bc)).a(9); + public static Item WHEAT = (new Item(40)).a(25); + public static Item BREAD = (new ItemFood(41, 5)).a(41); + public static Item LEATHER_HELMET = (new ItemArmor(42, 0, 0, 0)).a(0); + public static Item LEATHER_CHESTPLATE = (new ItemArmor(43, 0, 0, 1)).a(16); + public static Item LEATHER_LEGGINGS = (new ItemArmor(44, 0, 0, 2)).a(32); + public static Item LEATHER_BOOTS = (new ItemArmor(45, 0, 0, 3)).a(48); + public static Item CHAINMAIL_HELMET = (new ItemArmor(46, 1, 1, 0)).a(1); + public static Item CHAINMAIL_CHESTPLATE = (new ItemArmor(47, 1, 1, 1)).a(17); + public static Item CHAINMAIL_LEGGINGS = (new ItemArmor(48, 1, 1, 2)).a(33); + public static Item CHAINMAIL_BOOTS = (new ItemArmor(49, 1, 1, 3)).a(49); + public static Item IRON_HELMET = (new ItemArmor(50, 2, 2, 0)).a(2); + public static Item IRON_CHESTPLATE = (new ItemArmor(51, 2, 2, 1)).a(18); + public static Item IRON_LEGGINGS = (new ItemArmor(52, 2, 2, 2)).a(34); + public static Item IRON_BOOTS = (new ItemArmor(53, 2, 2, 3)).a(50); + public static Item DIAMOND_HELMET = (new ItemArmor(54, 3, 3, 0)).a(3); + public static Item DIAMOND_CHESTPLATE = (new ItemArmor(55, 3, 3, 1)).a(19); + public static Item DIAMOND_LEGGINGS = (new ItemArmor(56, 3, 3, 2)).a(35); + public static Item DIAMOND_BOOTS = (new ItemArmor(57, 3, 3, 3)).a(51); + public static Item GOLD_HELMET = (new ItemArmor(58, 1, 4, 0)).a(4); + public static Item GOLD_CHESTPLATE = (new ItemArmor(59, 1, 4, 1)).a(20); + public static Item GOLD_LEGGINGS = (new ItemArmor(60, 1, 4, 2)).a(36); + public static Item GOLD_BOOTS = (new ItemArmor(61, 1, 4, 3)).a(52); + public static Item FLINT = (new Item(62)).a(6); + public static Item PORK = (new ItemFood(63, 3)).a(87); + public static Item GRILLED_PORK = (new ItemFood(64, 8)).a(88); + public static Item PAINTING = (new ItemPainting(65)).a(26); + public static Item GOLDEN_APPLE = (new ItemFood(66, 42)).a(11); + public static Item SIGN = (new ItemSign(67)).a(42); + public static Item WOOD_DOOR = (new ItemDoor(68, Material.c)).a(43); + public static Item BUCKET = (new ItemBucket(69, 0)).a(74); + public static Item WATER_BUCKET = (new ItemBucket(70, Block.WATER.bc)).a(75); + public static Item LAVA_BUCKET = (new ItemBucket(71, Block.LAVA.bc)).a(76); + public static Item MINECART = (new ItemMinecart(72, 0)).a(135); + public static Item SADDLE = (new ItemSaddle(73)).a(104); + public static Item IRON_DOOR = (new ItemDoor(74, Material.e)).a(44); + public static Item REDSTONE = (new ItemRedstone(75)).a(56); + public static Item SNOW_BALL = (new ItemSnowball(76)).a(14); + public static Item BOAT = (new ItemBoat(77)).a(136); + public static Item LEATHER = (new Item(78)).a(103); + public static Item MILK_BUCKET = (new ItemBucket(79, -1)).a(77); + public static Item CLAY_BRICK = (new Item(80)).a(22); + public static Item CLAY_BALL = (new Item(81)).a(57); + public static Item SUGAR_CANE = (new ItemReed(82, Block.SUGAR_CANE_BLOCK)).a(27); + public static Item PAPER = (new Item(83)).a(58); + public static Item BOOK = (new Item(84)).a(59); + public static Item SLIME_BALL = (new Item(85)).a(30); + public static Item STORAGE_MINECART = (new ItemMinecart(86, 1)).a(151); + public static Item POWERED_MINECART = (new ItemMinecart(87, 2)).a(167); + public static Item EGG = (new Item(88)).a(12); + public static Item COMPASS = (new Item(89)).a(54); + public static Item FISHING_ROD = (new Item(90)).a(69); + public static Item GOLD_RECORD = (new ItemRecord(2000, "13")).a(240); + public static Item GREEN_RECORD = (new ItemRecord(2001, "cat")).a(241); + public final int aS; + protected int aT = 64; + protected int aU = 32; + protected int aV; + protected boolean aW = false; + + protected Item(int i) { + this.aS = 256 + i; + if (c[256 + i] != null) { + System.out.println("CONFLICT @ " + i); + } + + c[256 + i] = this; + } + + public Item a(int i) { + this.aV = i; + return this; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + return false; + } + + public float a(ItemStack itemstack, Block block) { + return 1.0F; + } + + public int a() { + return this.aT; + } + + public int b() { + return this.aU; + } + + public void a(ItemStack itemstack, int i, int j, int k, int l) {} + + public boolean a(Block block) { + return false; + } + + public Item c() { + this.aW = true; + return this; + } +} diff --git a/net/minecraft/server/ItemArmor.java b/net/minecraft/server/ItemArmor.java new file mode 100644 index 000000000..7dbc16dc9 --- /dev/null +++ b/net/minecraft/server/ItemArmor.java @@ -0,0 +1,21 @@ +package net.minecraft.server; + +public class ItemArmor extends Item { + + private static final int[] ba = new int[] { 3, 8, 6, 3}; + private static final int[] bb = new int[] { 11, 16, 15, 13}; + public final int a; + public final int aX; + public final int aY; + public final int aZ; + + public ItemArmor(int i, int j, int k, int l) { + super(i); + this.a = j; + this.aX = l; + this.aZ = k; + this.aY = ba[l]; + this.aU = bb[l] * 3 << j; + this.aT = 1; + } +} diff --git a/net/minecraft/server/ItemAxe.java b/net/minecraft/server/ItemAxe.java new file mode 100644 index 000000000..02af89b4a --- /dev/null +++ b/net/minecraft/server/ItemAxe.java @@ -0,0 +1,10 @@ +package net.minecraft.server; + +public class ItemAxe extends ItemTool { + + private static Block[] aX = new Block[] { Block.WOOD, Block.BOOKSHELF, Block.LOG, Block.CHEST}; + + public ItemAxe(int i, int j) { + super(i, 3, j, aX); + } +} diff --git a/net/minecraft/server/ItemBlock.java b/net/minecraft/server/ItemBlock.java new file mode 100644 index 000000000..78f1da98e --- /dev/null +++ b/net/minecraft/server/ItemBlock.java @@ -0,0 +1,58 @@ +package net.minecraft.server; + +public class ItemBlock extends Item { + + private int a; + + public ItemBlock(int i) { + super(i); + this.a = i + 256; + this.a(Block.n[i + 256].a(2)); + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (world.a(i, j, k) == Block.SNOW.bc) { + l = 0; + } else { + if (l == 0) { + --j; + } + + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + } + + if (itemstack.a == 0) { + return false; + } else { + if (world.a(this.a, i, j, k, false)) { + Block block = Block.n[this.a]; + + if (world.d(i, j, k, this.a)) { + Block.n[this.a].c(world, i, j, k, l); + world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.bl.c(), (block.bl.a() + 1.0F) / 2.0F, block.bl.b() * 0.8F); + --itemstack.a; + } + } + + return true; + } + } +} diff --git a/net/minecraft/server/ItemBoat.java b/net/minecraft/server/ItemBoat.java new file mode 100644 index 000000000..3d85ffcd0 --- /dev/null +++ b/net/minecraft/server/ItemBoat.java @@ -0,0 +1,9 @@ +package net.minecraft.server; + +public class ItemBoat extends Item { + + public ItemBoat(int i) { + super(i); + this.aT = 1; + } +} diff --git a/net/minecraft/server/ItemBow.java b/net/minecraft/server/ItemBow.java new file mode 100644 index 000000000..5347c5713 --- /dev/null +++ b/net/minecraft/server/ItemBow.java @@ -0,0 +1,9 @@ +package net.minecraft.server; + +public class ItemBow extends Item { + + public ItemBow(int i) { + super(i); + this.aT = 1; + } +} diff --git a/net/minecraft/server/ItemBucket.java b/net/minecraft/server/ItemBucket.java new file mode 100644 index 000000000..40be5ea14 --- /dev/null +++ b/net/minecraft/server/ItemBucket.java @@ -0,0 +1,56 @@ +package net.minecraft.server; + +public class ItemBucket extends Item { + + private int a; + + public ItemBucket(int i, int j) { + super(i); + this.aT = 1; + this.aU = 64; + this.a = j; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (l == 0) { + --j; + } + + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + + int i; + + if (this.a == 0) { + i = world.a(i, j, k); + if (i == 8 || i == 9 || i == 10 || i == 11) { + world.d(i, j, k, 0); + } + } + + i = world.a(i, j, k); + if (i == 0) { + world.d(i, j, k, this.a); + } + + itemstack.a(1); + return true; + } +} diff --git a/net/minecraft/server/ItemDoor.java b/net/minecraft/server/ItemDoor.java new file mode 100644 index 000000000..8e32cf8db --- /dev/null +++ b/net/minecraft/server/ItemDoor.java @@ -0,0 +1,76 @@ +package net.minecraft.server; + +public class ItemDoor extends Item { + + private Material a; + + public ItemDoor(int i, Material material) { + super(i); + this.a = material; + this.aU = 64; + this.aT = 1; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (l != 1) { + return false; + } else { + ++j; + Block block; + + if (this.a == Material.c) { + block = Block.WOODEN_DOOR; + } else { + block = Block.IRON_DOOR_BLOCK; + } + + if (!block.a(world, i, j, k)) { + return false; + } else { + int i1 = MathHelper.b((double) ((entityhuman.r + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + byte b0 = 0; + byte b1 = 0; + + if (i1 == 0) { + b1 = 1; + } + + if (i1 == 1) { + b0 = -1; + } + + if (i1 == 2) { + b1 = -1; + } + + if (i1 == 3) { + b0 = 1; + } + + int j1 = (world.d(i - b0, j, k - b1) ? 1 : 0) + (world.d(i - b0, j + 1, k - b1) ? 1 : 0); + int k1 = (world.d(i + b0, j, k + b1) ? 1 : 0) + (world.d(i + b0, j + 1, k + b1) ? 1 : 0); + boolean flag = world.a(i - b0, j, k - b1) == block.bc || world.a(i - b0, j + 1, k - b1) == block.bc; + boolean flag1 = world.a(i + b0, j, k + b1) == block.bc || world.a(i + b0, j + 1, k + b1) == block.bc; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (k1 > j1) { + flag2 = true; + } + + if (flag2) { + i1 = i1 - 1 & 3; + i1 += 4; + } + + world.d(i, j, k, block.bc); + world.b(i, j, k, i1); + world.d(i, j + 1, k, block.bc); + world.b(i, j + 1, k, i1 + 8); + --itemstack.a; + return true; + } + } + } +} diff --git a/net/minecraft/server/ItemFlintAndSteel.java b/net/minecraft/server/ItemFlintAndSteel.java new file mode 100644 index 000000000..2e5849360 --- /dev/null +++ b/net/minecraft/server/ItemFlintAndSteel.java @@ -0,0 +1,56 @@ +package net.minecraft.server; + +public class ItemFlintAndSteel extends Item { + + public ItemFlintAndSteel(int i) { + super(i); + this.aT = 1; + this.aU = 64; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + int dbl = world.a(i, j, k); + + if (dbl == 52 || dbl == 46) { + world.d(i, j, k, 0); + } + + if (dbl == 7 && j > 5) { + world.d(i, j, k, 0); + } + + if (l == 0) { + --j; + } + + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + + int i = world.a(i, j, k); + + if (i == 0) { + world.d(i, j, k, 20); + world.d(i, j, k, 0); + } + + itemstack.a(1); + return true; + } +} diff --git a/net/minecraft/server/ItemFood.java b/net/minecraft/server/ItemFood.java new file mode 100644 index 000000000..7e1ab4983 --- /dev/null +++ b/net/minecraft/server/ItemFood.java @@ -0,0 +1,12 @@ +package net.minecraft.server; + +public class ItemFood extends Item { + + private int a; + + public ItemFood(int i, int j) { + super(i); + this.a = j; + this.aT = 1; + } +} diff --git a/net/minecraft/server/ItemHoe.java b/net/minecraft/server/ItemHoe.java new file mode 100644 index 000000000..f13d6caf0 --- /dev/null +++ b/net/minecraft/server/ItemHoe.java @@ -0,0 +1,41 @@ +package net.minecraft.server; + +public class ItemHoe extends Item { + + public ItemHoe(int i, int j) { + super(i); + this.aT = 1; + this.aU = 32 << j; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + int i1 = world.a(i, j, k); + Material material = world.c(i, j + 1, k); + + if ((material.a() || i1 != Block.GRASS.bc) && i1 != Block.DIRT.bc) { + return false; + } else { + Block block = Block.SOIL; + + world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.bl.c(), (block.bl.a() + 1.0F) / 2.0F, block.bl.b() * 0.8F); + world.d(i, j, k, block.bc); + itemstack.a(1); + if (world.m.nextInt(8) == 0 && i1 == Block.GRASS.bc) { + byte b0 = 1; + + for (int j1 = 0; j1 < b0; ++j1) { + float f = 0.7F; + float f1 = world.m.nextFloat() * f + (1.0F - f) * 0.5F; + float f2 = 1.2F; + float f3 = world.m.nextFloat() * f + (1.0F - f) * 0.5F; + EntityItem entityitem = new EntityItem(world, (double) ((float) i + f1), (double) ((float) j + f2), (double) ((float) k + f3), new ItemStack(Item.SEEDS)); + + entityitem.ad = 10; + world.a((Entity) entityitem); + } + } + + return true; + } + } +} diff --git a/net/minecraft/server/ItemInWorldManager.java b/net/minecraft/server/ItemInWorldManager.java new file mode 100644 index 000000000..7c01aef6e --- /dev/null +++ b/net/minecraft/server/ItemInWorldManager.java @@ -0,0 +1,107 @@ +package net.minecraft.server; + +public class ItemInWorldManager { + + private World b; + public EntityHuman a; + private float c; + private float d = 0.0F; + private int e = 0; + private float f = 0.0F; + private int g; + private int h; + private int i; + + public ItemInWorldManager(World world) { + this.b = world; + } + + public void a(int i, int j, int k) { + int l = this.b.a(i, j, k); + + if (l > 0 && this.d == 0.0F) { + Block.n[l].b(this.b, i, j, k, this.a); + } + + if (l > 0 && Block.n[l].a(this.a) >= 1.0F) { + this.c(i, j, k); + } + } + + public void a() { + this.d = 0.0F; + this.e = 0; + } + + public void a(int i, int j, int k, int l) { + if (this.e > 0) { + --this.e; + } else { + if (i == this.g && j == this.h && k == this.i) { + int i1 = this.b.a(i, j, k); + + if (i1 == 0) { + return; + } + + Block block = Block.n[i1]; + + this.d += block.a(this.a); + ++this.f; + if (this.d >= 1.0F) { + this.c(i, j, k); + this.d = 0.0F; + this.c = 0.0F; + this.f = 0.0F; + this.e = 5; + } + } else { + this.d = 0.0F; + this.c = 0.0F; + this.f = 0.0F; + this.g = i; + this.h = j; + this.i = k; + } + } + } + + public boolean b(int i, int j, int k) { + Block block = Block.n[this.b.a(i, j, k)]; + int l = this.b.b(i, j, k); + boolean flag = this.b.d(i, j, k, 0); + + if (block != null && flag) { + block.a(this.b, i, j, k, l); + } + + return flag; + } + + public boolean c(int i, int j, int k) { + int l = this.b.a(i, j, k); + int i1 = this.b.b(i, j, k); + boolean flag = this.b(i, j, k); + ItemStack itemstack = this.a.B(); + + if (itemstack != null) { + itemstack.a(l, i, j, k); + if (itemstack.a == 0) { + itemstack.a(this.a); + this.a.C(); + } + } + + if (flag && this.a.b(Block.n[l])) { + Block.n[l].a_(this.b, i, j, k, i1); + } + + return flag; + } + + public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) { + int i1 = world.a(i, j, k); + + return i1 > 0 && Block.n[i1].a(world, i, j, k, entityhuman) ? true : (itemstack == null ? false : itemstack.a(entityhuman, world, i, j, k, l)); + } +} diff --git a/net/minecraft/server/ItemMinecart.java b/net/minecraft/server/ItemMinecart.java new file mode 100644 index 000000000..db35c2c44 --- /dev/null +++ b/net/minecraft/server/ItemMinecart.java @@ -0,0 +1,24 @@ +package net.minecraft.server; + +public class ItemMinecart extends Item { + + public int a; + + public ItemMinecart(int i, int j) { + super(i); + this.aT = 1; + this.a = j; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + int i1 = world.a(i, j, k); + + if (i1 == Block.RAILS.bc) { + world.a((Entity) (new EntityMinecart(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.a))); + --itemstack.a; + return true; + } else { + return false; + } + } +} diff --git a/net/minecraft/server/ItemPainting.java b/net/minecraft/server/ItemPainting.java new file mode 100644 index 000000000..a1e3aea4d --- /dev/null +++ b/net/minecraft/server/ItemPainting.java @@ -0,0 +1,40 @@ +package net.minecraft.server; + +public class ItemPainting extends Item { + + public ItemPainting(int i) { + super(i); + this.aU = 64; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (l == 0) { + return false; + } else if (l == 1) { + return false; + } else { + byte b0 = 0; + + if (l == 4) { + b0 = 1; + } + + if (l == 3) { + b0 = 2; + } + + if (l == 5) { + b0 = 3; + } + + EntityPainting entitypainting = new EntityPainting(world, i, j, k, b0); + + if (entitypainting.b()) { + world.a((Entity) entitypainting); + --itemstack.a; + } + + return true; + } + } +} diff --git a/net/minecraft/server/ItemPickaxe.java b/net/minecraft/server/ItemPickaxe.java new file mode 100644 index 000000000..1f2453b40 --- /dev/null +++ b/net/minecraft/server/ItemPickaxe.java @@ -0,0 +1,16 @@ +package net.minecraft.server; + +public class ItemPickaxe extends ItemTool { + + private static Block[] aX = new Block[] { Block.COBBLESTONE, Block.DOUBLE_STEP, Block.STEP, Block.STONE, Block.MOSSY_COBBLESTONE, Block.IRON_ORE, Block.IRON_BLOCK, Block.COAL_ORE, Block.GOLD_BLOCK, Block.GOLD_ORE, Block.DIAMOND_ORE, Block.DIAMOND_BLOCK, Block.ICE}; + private int aY; + + public ItemPickaxe(int i, int j) { + super(i, 2, j, aX); + this.aY = j; + } + + public boolean a(Block block) { + return block == Block.OBSIDIAN ? this.aY == 3 : (block != Block.DIAMOND_BLOCK && block != Block.DIAMOND_ORE ? (block != Block.GOLD_BLOCK && block != Block.GOLD_ORE ? (block != Block.IRON_BLOCK && block != Block.IRON_ORE ? (block != Block.REDSTONE_ORE && block != Block.GLOWING_REDSTONE_ORE ? (block.bn == Material.d ? true : block.bn == Material.e) : this.aY >= 2) : this.aY >= 1) : this.aY >= 2) : this.aY >= 2); + } +} diff --git a/net/minecraft/server/ItemRecord.java b/net/minecraft/server/ItemRecord.java new file mode 100644 index 000000000..38d525cb3 --- /dev/null +++ b/net/minecraft/server/ItemRecord.java @@ -0,0 +1,23 @@ +package net.minecraft.server; + +public class ItemRecord extends Item { + + private String a; + + protected ItemRecord(int i, String s) { + super(i); + this.a = s; + this.aT = 1; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (world.a(i, j, k) == Block.JUKEBOX.bc && world.b(i, j, k) == 0) { + world.b(i, j, k, this.aS - Item.GOLD_RECORD.aS + 1); + world.a(this.a, i, j, k); + --itemstack.a; + return true; + } else { + return false; + } + } +} diff --git a/net/minecraft/server/ItemRedstone.java b/net/minecraft/server/ItemRedstone.java new file mode 100644 index 000000000..60cf84695 --- /dev/null +++ b/net/minecraft/server/ItemRedstone.java @@ -0,0 +1,45 @@ +package net.minecraft.server; + +public class ItemRedstone extends Item { + + public ItemRedstone(int i) { + super(i); + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (l == 0) { + --j; + } + + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + + if (world.a(i, j, k) != 0) { + return false; + } else { + if (Block.REDSTONE_WIRE.a(world, i, j, k)) { + --itemstack.a; + world.d(i, j, k, Block.REDSTONE_WIRE.bc); + } + + return true; + } + } +} diff --git a/net/minecraft/server/ItemReed.java b/net/minecraft/server/ItemReed.java new file mode 100644 index 000000000..1f47741e8 --- /dev/null +++ b/net/minecraft/server/ItemReed.java @@ -0,0 +1,57 @@ +package net.minecraft.server; + +public class ItemReed extends Item { + + private int a; + + public ItemReed(int i, Block block) { + super(i); + this.a = block.bc; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (world.a(i, j, k) == Block.SNOW.bc) { + l = 0; + } else { + if (l == 0) { + --j; + } + + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + } + + if (itemstack.a == 0) { + return false; + } else { + if (world.a(this.a, i, j, k, false)) { + Block block = Block.n[this.a]; + + if (world.d(i, j, k, this.a)) { + Block.n[this.a].c(world, i, j, k, l); + world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.bl.c(), (block.bl.a() + 1.0F) / 2.0F, block.bl.b() * 0.8F); + --itemstack.a; + } + } + + return true; + } + } +} diff --git a/net/minecraft/server/ItemSaddle.java b/net/minecraft/server/ItemSaddle.java new file mode 100644 index 000000000..034324444 --- /dev/null +++ b/net/minecraft/server/ItemSaddle.java @@ -0,0 +1,10 @@ +package net.minecraft.server; + +public class ItemSaddle extends Item { + + public ItemSaddle(int i) { + super(i); + this.aT = 1; + this.aU = 64; + } +} diff --git a/net/minecraft/server/ItemSeeds.java b/net/minecraft/server/ItemSeeds.java new file mode 100644 index 000000000..2423e0dbe --- /dev/null +++ b/net/minecraft/server/ItemSeeds.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +public class ItemSeeds extends Item { + + private int a; + + public ItemSeeds(int i, int j) { + super(i); + this.a = j; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (l != 1) { + return false; + } else { + int i1 = world.a(i, j, k); + + if (i1 == Block.SOIL.bc) { + world.d(i, j + 1, k, this.a); + --itemstack.a; + return true; + } else { + return false; + } + } + } +} diff --git a/net/minecraft/server/ItemSign.java b/net/minecraft/server/ItemSign.java new file mode 100644 index 000000000..039435062 --- /dev/null +++ b/net/minecraft/server/ItemSign.java @@ -0,0 +1,52 @@ +package net.minecraft.server; + +public class ItemSign extends Item { + + public ItemSign(int i) { + super(i); + this.aU = 64; + this.aT = 1; + } + + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { + if (l == 0) { + return false; + } else if (!world.c(i, j, k).a()) { + return false; + } else { + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + + if (!Block.SIGN_POST.a(world, i, j, k)) { + return false; + } else { + if (l == 1) { + world.b(i, j, k, Block.SIGN_POST.bc, MathHelper.b((double) ((entityhuman.r + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15); + } else { + world.b(i, j, k, Block.WALL_SIGN.bc, l); + } + + --itemstack.a; + entityhuman.a((TileEntitySign) world.k(i, j, k)); + return true; + } + } + } +} diff --git a/net/minecraft/server/ItemSnowball.java b/net/minecraft/server/ItemSnowball.java new file mode 100644 index 000000000..47bd624bc --- /dev/null +++ b/net/minecraft/server/ItemSnowball.java @@ -0,0 +1,9 @@ +package net.minecraft.server; + +public class ItemSnowball extends Item { + + public ItemSnowball(int i) { + super(i); + this.aT = 16; + } +} diff --git a/net/minecraft/server/ItemSoup.java b/net/minecraft/server/ItemSoup.java new file mode 100644 index 000000000..c9b0dc1af --- /dev/null +++ b/net/minecraft/server/ItemSoup.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +public class ItemSoup extends ItemFood { + + public ItemSoup(int i, int j) { + super(i, j); + } +} diff --git a/net/minecraft/server/ItemSpade.java b/net/minecraft/server/ItemSpade.java new file mode 100644 index 000000000..1d898a8f4 --- /dev/null +++ b/net/minecraft/server/ItemSpade.java @@ -0,0 +1,14 @@ +package net.minecraft.server; + +public class ItemSpade extends ItemTool { + + private static Block[] aX = new Block[] { Block.GRASS, Block.DIRT, Block.SAND, Block.GRAVEL, Block.SNOW, Block.SNOW_BLOCK, Block.CLAY}; + + public ItemSpade(int i, int j) { + super(i, 1, j, aX); + } + + public boolean a(Block block) { + return block == Block.SNOW ? true : block == Block.SNOW_BLOCK; + } +} diff --git a/net/minecraft/server/ItemStack.java b/net/minecraft/server/ItemStack.java new file mode 100644 index 000000000..2b82618f1 --- /dev/null +++ b/net/minecraft/server/ItemStack.java @@ -0,0 +1,106 @@ +package net.minecraft.server; + +public final class ItemStack { + + public int a; + public int b; + public int c; + public int d; + + public ItemStack(Block block) { + this(block, 1); + } + + public ItemStack(Block block, int i) { + this(block.bc, i); + } + + public ItemStack(Item item) { + this(item, 1); + } + + public ItemStack(Item item, int i) { + this(item.aS, i); + } + + public ItemStack(int i) { + this(i, 1); + } + + public ItemStack(int i, int j) { + this.a = 0; + this.c = i; + this.a = j; + } + + public ItemStack(int i, int j, int k) { + this.a = 0; + this.c = i; + this.a = j; + this.d = k; + } + + public ItemStack(NBTTagCompound nbttagcompound) { + this.a = 0; + this.b(nbttagcompound); + } + + public Item a() { + return Item.c[this.c]; + } + + public boolean a(EntityHuman entityhuman, World world, int i, int j, int k, int l) { + return this.a().a(this, entityhuman, world, i, j, k, l); + } + + public float a(Block block) { + return this.a().a(this, block); + } + + public NBTTagCompound a(NBTTagCompound nbttagcompound) { + nbttagcompound.a("id", (short) this.c); + nbttagcompound.a("Count", (byte) this.a); + nbttagcompound.a("Damage", (short) this.d); + return nbttagcompound; + } + + public void b(NBTTagCompound nbttagcompound) { + this.c = nbttagcompound.c("id"); + this.a = nbttagcompound.b("Count"); + this.d = nbttagcompound.c("Damage"); + } + + public int b() { + return this.a().a(); + } + + public int c() { + return Item.c[this.c].b(); + } + + public void a(int i) { + this.d += i; + if (this.d > this.c()) { + --this.a; + if (this.a < 0) { + this.a = 0; + } + + this.d = 0; + } + } + + public void a(int i, int j, int k, int l) { + Item.c[this.c].a(this, i, j, k, l); + } + + public boolean b(Block block) { + return Item.c[this.c].a(block); + } + + public void a(EntityHuman entityhuman) {} + + public ItemStack d() { + return new ItemStack(this.c, this.a, this.d); + } +} diff --git a/net/minecraft/server/ItemSword.java b/net/minecraft/server/ItemSword.java new file mode 100644 index 000000000..f42df691f --- /dev/null +++ b/net/minecraft/server/ItemSword.java @@ -0,0 +1,25 @@ +package net.minecraft.server; + +public class ItemSword extends Item { + + private int a; + + public ItemSword(int i, int j) { + super(i); + this.aT = 1; + this.aU = 32 << j; + if (j == 3) { + this.aU *= 4; + } + + this.a = 4 + j * 2; + } + + public float a(ItemStack itemstack, Block block) { + return 1.5F; + } + + public void a(ItemStack itemstack, int i, int j, int k, int l) { + itemstack.a(2); + } +} diff --git a/net/minecraft/server/ItemTool.java b/net/minecraft/server/ItemTool.java new file mode 100644 index 000000000..5e42b456a --- /dev/null +++ b/net/minecraft/server/ItemTool.java @@ -0,0 +1,37 @@ +package net.minecraft.server; + +public class ItemTool extends Item { + + private Block[] aX; + private float aY = 4.0F; + private int aZ; + protected int a; + + public ItemTool(int i, int j, int k, Block[] ablock) { + super(i); + this.a = k; + this.aX = ablock; + this.aT = 1; + this.aU = 32 << k; + if (k == 3) { + this.aU *= 4; + } + + this.aY = (float) ((k + 1) * 2); + this.aZ = j + k; + } + + public float a(ItemStack itemstack, Block block) { + for (int i = 0; i < this.aX.length; ++i) { + if (this.aX[i] == block) { + return this.aY; + } + } + + return 1.0F; + } + + public void a(ItemStack itemstack, int i, int j, int k, int l) { + itemstack.a(1); + } +} diff --git a/net/minecraft/server/MapGenBase.java b/net/minecraft/server/MapGenBase.java new file mode 100644 index 000000000..931cd018a --- /dev/null +++ b/net/minecraft/server/MapGenBase.java @@ -0,0 +1,28 @@ +package net.minecraft.server; + +import java.util.Random; + +public class MapGenBase { + + protected int a = 8; + protected Random b = new Random(); + + public MapGenBase() {} + + public void a(ChunkProviderGenerate chunkprovidergenerate, World world, int i, int j, byte[] abyte) { + int k = this.a; + + this.b.setSeed(world.t); + long l = this.b.nextLong() / 2L * 2L + 1L; + long i1 = this.b.nextLong() / 2L * 2L + 1L; + + for (int j1 = i - k; j1 <= i + k; ++j1) { + for (int k1 = j - k; k1 <= j + k; ++k1) { + this.b.setSeed((long) j1 * l + (long) k1 * i1 ^ world.t); + this.a(world, j1, k1, i, j, abyte); + } + } + } + + protected void a(World world, int i, int j, int k, int l, byte[] abyte) {} +} diff --git a/net/minecraft/server/MapGenCaves.java b/net/minecraft/server/MapGenCaves.java new file mode 100644 index 000000000..76596ffc4 --- /dev/null +++ b/net/minecraft/server/MapGenCaves.java @@ -0,0 +1,198 @@ +package net.minecraft.server; + +import java.util.Random; + +public class MapGenCaves extends MapGenBase { + + public MapGenCaves() {} + + protected void a(int i, int j, byte[] abyte, double d0, double d1, double d2) { + this.a(i, j, abyte, d0, d1, d2, 1.0F + this.b.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D); + } + + protected void a(int i, int j, byte[] abyte, double d0, double d1, double d2, float f, float f1, float f2, int k, int l, double d3) { + double d4 = (double) (i * 16 + 8); + double d5 = (double) (j * 16 + 8); + float f3 = 0.0F; + float f4 = 0.0F; + Random random = new Random(this.b.nextLong()); + + if (l <= 0) { + int i1 = this.a * 16 - 16; + + l = i1 - random.nextInt(i1 / 4); + } + + boolean flag = false; + + if (k == -1) { + k = l / 2; + flag = true; + } + + int j1 = random.nextInt(l / 2) + l / 4; + + for (boolean flag1 = random.nextInt(6) == 0; k < l; ++k) { + double d6 = 1.5D + (double) (MathHelper.a((float) k * 3.1415927F / (float) l) * f * 1.0F); + double d7 = d6 * d3; + float f5 = MathHelper.b(f2); + float f6 = MathHelper.a(f2); + + d0 += (double) (MathHelper.b(f1) * f5); + d1 += (double) f6; + d2 += (double) (MathHelper.a(f1) * f5); + if (flag1) { + f2 *= 0.92F; + } else { + f2 *= 0.7F; + } + + f2 += f4 * 0.1F; + f1 += f3 * 0.1F; + f4 *= 0.9F; + f3 *= 0.75F; + f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; + f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; + if (!flag && k == j1 && f > 1.0F) { + this.a(i, j, abyte, d0, d1, d2, random.nextFloat() * 0.5F + 0.5F, f1 - 1.5707964F, f2 / 3.0F, k, l, 1.0D); + this.a(i, j, abyte, d0, d1, d2, random.nextFloat() * 0.5F + 0.5F, f1 + 1.5707964F, f2 / 3.0F, k, l, 1.0D); + return; + } + + if (flag || random.nextInt(4) != 0) { + double d8 = d0 - d4; + double d9 = d2 - d5; + double d10 = (double) (l - k); + double d11 = (double) (f + 2.0F + 16.0F); + + if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) { + return; + } + + if (d0 >= d4 - 16.0D - d6 * 2.0D && d2 >= d5 - 16.0D - d6 * 2.0D && d0 <= d4 + 16.0D + d6 * 2.0D && d2 <= d5 + 16.0D + d6 * 2.0D) { + int k1 = MathHelper.b(d0 - d6) - i * 16 - 1; + int l1 = MathHelper.b(d0 + d6) - i * 16 + 1; + int i2 = MathHelper.b(d1 - d7) - 1; + int j2 = MathHelper.b(d1 + d7) + 1; + int k2 = MathHelper.b(d2 - d6) - j * 16 - 1; + int l2 = MathHelper.b(d2 + d6) - j * 16 + 1; + + if (k1 < 0) { + k1 = 0; + } + + if (l1 > 16) { + l1 = 16; + } + + if (i2 < 1) { + i2 = 1; + } + + if (j2 > 120) { + j2 = 120; + } + + if (k2 < 0) { + k2 = 0; + } + + if (l2 > 16) { + l2 = 16; + } + + boolean flag2 = false; + + int i3; + int j3; + + for (j3 = k1; !flag2 && j3 < l1; ++j3) { + for (int k3 = k2; !flag2 && k3 < l2; ++k3) { + for (int l3 = j2 + 1; !flag2 && l3 >= i2 - 1; --l3) { + i3 = (j3 * 16 + k3) * 128 + l3; + if (l3 >= 0 && l3 < 128) { + if (abyte[i3] == Block.WATER.bc || abyte[i3] == Block.STATIONARY_WATER.bc) { + flag2 = true; + } + + if (l3 != i2 - 1 && j3 != k1 && j3 != l1 - 1 && k3 != k2 && k3 != l2 - 1) { + l3 = i2; + } + } + } + } + } + + if (!flag2) { + for (j3 = k1; j3 < l1; ++j3) { + double d12 = ((double) (j3 + i * 16) + 0.5D - d0) / d6; + + for (i3 = k2; i3 < l2; ++i3) { + double d13 = ((double) (i3 + j * 16) + 0.5D - d2) / d6; + int i4 = (j3 * 16 + i3) * 128 + j2; + boolean flag3 = false; + + for (int j4 = j2 - 1; j4 >= i2; --j4) { + double d14 = ((double) j4 + 0.5D - d1) / d7; + + if (d14 > -0.7D && d12 * d12 + d14 * d14 + d13 * d13 < 1.0D) { + byte b0 = abyte[i4]; + + if (b0 == Block.GRASS.bc) { + flag3 = true; + } + + if (b0 == Block.STONE.bc || b0 == Block.DIRT.bc || b0 == Block.GRASS.bc) { + if (j4 < 10) { + abyte[i4] = (byte) Block.LAVA.bc; + } else { + abyte[i4] = 0; + if (flag3 && abyte[i4 - 1] == Block.DIRT.bc) { + abyte[i4 - 1] = (byte) Block.GRASS.bc; + } + } + } + } + + --i4; + } + } + } + + if (flag) { + break; + } + } + } + } + } + } + + protected void a(World world, int i, int j, int k, int l, byte[] abyte) { + int i1 = this.b.nextInt(this.b.nextInt(this.b.nextInt(40) + 1) + 1); + + if (this.b.nextInt(15) != 0) { + i1 = 0; + } + + for (int j1 = 0; j1 < i1; ++j1) { + double d0 = (double) (i * 16 + this.b.nextInt(16)); + double d1 = (double) this.b.nextInt(this.b.nextInt(120) + 8); + double d2 = (double) (j * 16 + this.b.nextInt(16)); + int k1 = 1; + + if (this.b.nextInt(4) == 0) { + this.a(k, l, abyte, d0, d1, d2); + k1 += this.b.nextInt(4); + } + + for (int l1 = 0; l1 < k1; ++l1) { + float f = this.b.nextFloat() * 3.1415927F * 2.0F; + float f1 = (this.b.nextFloat() - 0.5F) * 2.0F / 8.0F; + float f2 = this.b.nextFloat() * 2.0F + this.b.nextFloat(); + + this.a(k, l, abyte, d0, d1, d2, f2, f, f1, 0, 0, 1.0D); + } + } + } +} diff --git a/net/minecraft/server/Material.java b/net/minecraft/server/Material.java new file mode 100644 index 000000000..0dd86fa9b --- /dev/null +++ b/net/minecraft/server/Material.java @@ -0,0 +1,55 @@ +package net.minecraft.server; + +public class Material { + + public static final Material a = new MaterialTransparent(); + public static final Material b = new Material(); + public static final Material c = (new Material()).f(); + public static final Material d = new Material(); + public static final Material e = new Material(); + public static final Material f = new MaterialLiquid(); + public static final Material g = new MaterialLiquid(); + public static final Material h = (new Material()).f(); + public static final Material i = new MaterialLogic(); + public static final Material j = new Material(); + public static final Material k = (new Material()).f(); + public static final Material l = new MaterialTransparent(); + public static final Material m = new Material(); + public static final Material n = new MaterialLogic(); + public static final Material o = new Material(); + public static final Material p = (new Material()).f(); + public static final Material q = new Material(); + public static final Material r = new Material(); + public static final Material s = new MaterialLogic(); + public static final Material t = new Material(); + public static final Material u = new Material(); + public static final Material v = new Material(); + private boolean w; + + public Material() {} + + public boolean d() { + return false; + } + + public boolean a() { + return true; + } + + public boolean b() { + return true; + } + + public boolean c() { + return true; + } + + private Material f() { + this.w = true; + return this; + } + + public boolean e() { + return this.w; + } +} diff --git a/net/minecraft/server/MaterialLiquid.java b/net/minecraft/server/MaterialLiquid.java new file mode 100644 index 000000000..f82f588c1 --- /dev/null +++ b/net/minecraft/server/MaterialLiquid.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +public class MaterialLiquid extends Material { + + public MaterialLiquid() {} + + public boolean d() { + return true; + } + + public boolean c() { + return false; + } + + public boolean a() { + return false; + } +} diff --git a/net/minecraft/server/MaterialLogic.java b/net/minecraft/server/MaterialLogic.java new file mode 100644 index 000000000..ee3993799 --- /dev/null +++ b/net/minecraft/server/MaterialLogic.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +public class MaterialLogic extends Material { + + public MaterialLogic() {} + + public boolean a() { + return false; + } + + public boolean b() { + return false; + } + + public boolean c() { + return false; + } +} diff --git a/net/minecraft/server/MaterialTransparent.java b/net/minecraft/server/MaterialTransparent.java new file mode 100644 index 000000000..f04a0a0d7 --- /dev/null +++ b/net/minecraft/server/MaterialTransparent.java @@ -0,0 +1,18 @@ +package net.minecraft.server; + +public class MaterialTransparent extends Material { + + public MaterialTransparent() {} + + public boolean a() { + return false; + } + + public boolean b() { + return false; + } + + public boolean c() { + return false; + } +} diff --git a/net/minecraft/server/MathHelper.java b/net/minecraft/server/MathHelper.java new file mode 100644 index 000000000..0a40cba30 --- /dev/null +++ b/net/minecraft/server/MathHelper.java @@ -0,0 +1,58 @@ +package net.minecraft.server; + +public class MathHelper { + + private static float[] a = new float[65536]; + + public MathHelper() {} + + public static final float a(float f) { + return a[(int) (f * 10430.378F) & '\uffff']; + } + + public static final float b(float f) { + return a[(int) (f * 10430.378F + 16384.0F) & '\uffff']; + } + + public static final float c(float f) { + return (float) Math.sqrt((double) f); + } + + public static final float a(double d0) { + return (float) Math.sqrt(d0); + } + + public static int d(float f) { + int i = (int) f; + + return f < (float) i ? i - 1 : i; + } + + public static int b(double d0) { + int i = (int) d0; + + return d0 < (double) i ? i - 1 : i; + } + + public static float e(float f) { + return f >= 0.0F ? f : -f; + } + + public static double a(double d0, double d1) { + if (d0 < 0.0D) { + d0 = -d0; + } + + if (d1 < 0.0D) { + d1 = -d1; + } + + return d0 > d1 ? d0 : d1; + } + + static { + for (int i = 0; i < 65536; ++i) { + a[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D); + } + } +} diff --git a/net/minecraft/server/MetadataChunkBlock.java b/net/minecraft/server/MetadataChunkBlock.java new file mode 100644 index 000000000..e338586f4 --- /dev/null +++ b/net/minecraft/server/MetadataChunkBlock.java @@ -0,0 +1,183 @@ +package net.minecraft.server; + +public class MetadataChunkBlock { + + public final EnumSkyBlock a; + public int b; + public int c; + public int d; + public int e; + public int f; + public int g; + + public MetadataChunkBlock(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1) { + this.a = enumskyblock; + this.b = i; + this.c = j; + this.d = k; + this.e = l; + this.f = i1; + this.g = j1; + } + + public void a(World world) { + int i = this.e - this.b; + int j = this.f - this.c; + int k = this.g - this.d; + int l = i * j * k; + + if (l <= '\u8000') { + for (int i1 = this.b; i1 <= this.e; ++i1) { + for (int j1 = this.d; j1 <= this.g; ++j1) { + if (world.e(i1, 0, j1)) { + for (int k1 = this.c; k1 <= this.f; ++k1) { + if (k1 >= 0 && k1 < 128) { + int l1 = world.a(this.a, i1, k1, j1); + boolean flag = false; + int i2 = world.a(i1, k1, j1); + int j2 = Block.r[i2]; + + if (j2 == 0) { + j2 = 1; + } + + int k2 = 0; + + if (this.a == EnumSkyBlock.SKY) { + if (world.i(i1, k1, j1)) { + k2 = 15; + } + } else if (this.a == EnumSkyBlock.BLOCK) { + k2 = Block.t[i2]; + } + + int l2; + int i3; + + if (j2 >= 15 && k2 == 0) { + i3 = 0; + } else { + l2 = world.a(this.a, i1 - 1, k1, j1); + int j3 = world.a(this.a, i1 + 1, k1, j1); + int k3 = world.a(this.a, i1, k1 - 1, j1); + int l3 = world.a(this.a, i1, k1 + 1, j1); + int i4 = world.a(this.a, i1, k1, j1 - 1); + int j4 = world.a(this.a, i1, k1, j1 + 1); + + i3 = l2; + if (j3 > l2) { + i3 = j3; + } + + if (k3 > i3) { + i3 = k3; + } + + if (l3 > i3) { + i3 = l3; + } + + if (i4 > i3) { + i3 = i4; + } + + if (j4 > i3) { + i3 = j4; + } + + i3 -= j2; + if (i3 < 0) { + i3 = 0; + } + + if (k2 > i3) { + i3 = k2; + } + } + + if (l1 != i3) { + world.b(this.a, i1, k1, j1, i3); + l2 = i3 - 1; + if (l2 < 0) { + l2 = 0; + } + + world.a(this.a, i1 - 1, k1, j1, l2); + world.a(this.a, i1, k1 - 1, j1, l2); + world.a(this.a, i1, k1, j1 - 1, l2); + if (i1 + 1 >= this.e) { + world.a(this.a, i1 + 1, k1, j1, l2); + } + + if (k1 + 1 >= this.f) { + world.a(this.a, i1, k1 + 1, j1, l2); + } + + if (j1 + 1 >= this.g) { + world.a(this.a, i1, k1, j1 + 1, l2); + } + } + } + } + } + } + } + } + } + + public boolean a(int i, int j, int k, int l, int i1, int j1) { + if (i >= this.b && j >= this.c && k >= this.d && l <= this.e && i1 <= this.f && j1 <= this.g) { + return true; + } else { + byte b0 = 1; + + if (i >= this.b - b0 && j >= this.c - b0 && k >= this.d - b0 && l <= this.e + b0 && i1 <= this.f + b0 && j1 <= this.g + b0) { + int k1 = this.e - this.b; + int l1 = this.f - this.c; + int i2 = this.g - this.d; + + if (i > this.b) { + i = this.b; + } + + if (j > this.c) { + j = this.c; + } + + if (k > this.d) { + k = this.d; + } + + if (l < this.e) { + l = this.e; + } + + if (i1 < this.f) { + i1 = this.f; + } + + if (j1 < this.g) { + j1 = this.g; + } + + int j2 = l - i; + int k2 = i1 - j; + int l2 = j1 - k; + int i3 = k1 * l1 * i2; + int j3 = j2 * k2 * l2; + + if (j3 - i3 <= 2) { + this.b = i; + this.c = j; + this.d = k; + this.e = l; + this.f = i1; + this.g = j1; + return true; + } + } + + return false; + } + } +} diff --git a/net/minecraft/server/MinecartTrackLogic.java b/net/minecraft/server/MinecartTrackLogic.java new file mode 100644 index 000000000..00f72494a --- /dev/null +++ b/net/minecraft/server/MinecartTrackLogic.java @@ -0,0 +1,331 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +class MinecartTrackLogic { + + private World b; + private int c; + private int d; + private int e; + private int f; + private List g; + + final BlockMinecartTrack a; + + public MinecartTrackLogic(BlockMinecartTrack blockminecarttrack, World world, int i, int j, int k) { + this.a = blockminecarttrack; + this.g = new ArrayList(); + this.b = world; + this.c = i; + this.d = j; + this.e = k; + this.f = world.b(i, j, k); + this.a(); + } + + private void a() { + this.g.clear(); + if (this.f == 0) { + this.g.add(new ChunkPosition(this.c, this.d, this.e - 1)); + this.g.add(new ChunkPosition(this.c, this.d, this.e + 1)); + } else if (this.f == 1) { + this.g.add(new ChunkPosition(this.c - 1, this.d, this.e)); + this.g.add(new ChunkPosition(this.c + 1, this.d, this.e)); + } else if (this.f == 2) { + this.g.add(new ChunkPosition(this.c - 1, this.d, this.e)); + this.g.add(new ChunkPosition(this.c + 1, this.d + 1, this.e)); + } else if (this.f == 3) { + this.g.add(new ChunkPosition(this.c - 1, this.d + 1, this.e)); + this.g.add(new ChunkPosition(this.c + 1, this.d, this.e)); + } else if (this.f == 4) { + this.g.add(new ChunkPosition(this.c, this.d + 1, this.e - 1)); + this.g.add(new ChunkPosition(this.c, this.d, this.e + 1)); + } else if (this.f == 5) { + this.g.add(new ChunkPosition(this.c, this.d, this.e - 1)); + this.g.add(new ChunkPosition(this.c, this.d + 1, this.e + 1)); + } else if (this.f == 6) { + this.g.add(new ChunkPosition(this.c + 1, this.d, this.e)); + this.g.add(new ChunkPosition(this.c, this.d, this.e + 1)); + } else if (this.f == 7) { + this.g.add(new ChunkPosition(this.c - 1, this.d, this.e)); + this.g.add(new ChunkPosition(this.c, this.d, this.e + 1)); + } else if (this.f == 8) { + this.g.add(new ChunkPosition(this.c - 1, this.d, this.e)); + this.g.add(new ChunkPosition(this.c, this.d, this.e - 1)); + } else if (this.f == 9) { + this.g.add(new ChunkPosition(this.c + 1, this.d, this.e)); + this.g.add(new ChunkPosition(this.c, this.d, this.e - 1)); + } + } + + private void b() { + for (int i = 0; i < this.g.size(); ++i) { + MinecartTrackLogic minecarttracklogic = this.a((ChunkPosition) this.g.get(i)); + + if (minecarttracklogic != null && minecarttracklogic.b(this)) { + this.g.set(i, new ChunkPosition(minecarttracklogic.c, minecarttracklogic.d, minecarttracklogic.e)); + } else { + this.g.remove(i--); + } + } + } + + private boolean a(int i, int j, int k) { + return this.b.a(i, j, k) == this.a.bc ? true : (this.b.a(i, j + 1, k) == this.a.bc ? true : this.b.a(i, j - 1, k) == this.a.bc); + } + + private MinecartTrackLogic a(ChunkPosition chunkposition) { + return this.b.a(chunkposition.a, chunkposition.b, chunkposition.c) == this.a.bc ? new MinecartTrackLogic(this.a, this.b, chunkposition.a, chunkposition.b, chunkposition.c) : (this.b.a(chunkposition.a, chunkposition.b + 1, chunkposition.c) == this.a.bc ? new MinecartTrackLogic(this.a, this.b, chunkposition.a, chunkposition.b + 1, chunkposition.c) : (this.b.a(chunkposition.a, chunkposition.b - 1, chunkposition.c) == this.a.bc ? new MinecartTrackLogic(this.a, this.b, chunkposition.a, chunkposition.b - 1, chunkposition.c) : null)); + } + + private boolean b(MinecartTrackLogic minecarttracklogic) { + for (int i = 0; i < this.g.size(); ++i) { + ChunkPosition chunkposition = (ChunkPosition) this.g.get(i); + + if (chunkposition.a == minecarttracklogic.c && chunkposition.c == minecarttracklogic.e) { + return true; + } + } + + return false; + } + + private boolean b(int i, int j, int k) { + for (int l = 0; l < this.g.size(); ++l) { + ChunkPosition chunkposition = (ChunkPosition) this.g.get(l); + + if (chunkposition.a == i && chunkposition.c == k) { + return true; + } + } + + return false; + } + + private int c() { + int i = 0; + + if (this.a(this.c, this.d, this.e - 1)) { + ++i; + } + + if (this.a(this.c, this.d, this.e + 1)) { + ++i; + } + + if (this.a(this.c - 1, this.d, this.e)) { + ++i; + } + + if (this.a(this.c + 1, this.d, this.e)) { + ++i; + } + + return i; + } + + private boolean c(MinecartTrackLogic minecarttracklogic) { + if (this.b(minecarttracklogic)) { + return true; + } else if (this.g.size() == 2) { + return false; + } else if (this.g.size() == 0) { + return true; + } else { + ChunkPosition chunkposition = (ChunkPosition) this.g.get(0); + + return minecarttracklogic.d == this.d && chunkposition.b == this.d ? true : true; + } + } + + private void d(MinecartTrackLogic minecarttracklogic) { + this.g.add(new ChunkPosition(minecarttracklogic.c, minecarttracklogic.d, minecarttracklogic.e)); + boolean flag = this.b(this.c, this.d, this.e - 1); + boolean flag1 = this.b(this.c, this.d, this.e + 1); + boolean flag2 = this.b(this.c - 1, this.d, this.e); + boolean flag3 = this.b(this.c + 1, this.d, this.e); + byte b0 = -1; + + if (flag || flag1) { + b0 = 0; + } + + if (flag2 || flag3) { + b0 = 1; + } + + if (flag1 && flag3 && !flag && !flag2) { + b0 = 6; + } + + if (flag1 && flag2 && !flag && !flag3) { + b0 = 7; + } + + if (flag && flag2 && !flag1 && !flag3) { + b0 = 8; + } + + if (flag && flag3 && !flag1 && !flag2) { + b0 = 9; + } + + if (b0 == 0) { + if (this.b.a(this.c, this.d + 1, this.e - 1) == this.a.bc) { + b0 = 4; + } + + if (this.b.a(this.c, this.d + 1, this.e + 1) == this.a.bc) { + b0 = 5; + } + } + + if (b0 == 1) { + if (this.b.a(this.c + 1, this.d + 1, this.e) == this.a.bc) { + b0 = 2; + } + + if (this.b.a(this.c - 1, this.d + 1, this.e) == this.a.bc) { + b0 = 3; + } + } + + if (b0 < 0) { + b0 = 0; + } + + this.b.b(this.c, this.d, this.e, b0); + } + + private boolean c(int i, int j, int k) { + MinecartTrackLogic minecarttracklogic = this.a(new ChunkPosition(i, j, k)); + + if (minecarttracklogic == null) { + return false; + } else { + minecarttracklogic.b(); + return minecarttracklogic.c(this); + } + } + + public void a(boolean flag) { + boolean flag1 = this.c(this.c, this.d, this.e - 1); + boolean flag2 = this.c(this.c, this.d, this.e + 1); + boolean flag3 = this.c(this.c - 1, this.d, this.e); + boolean flag4 = this.c(this.c + 1, this.d, this.e); + byte b0 = -1; + + if ((flag1 || flag2) && !flag3 && !flag4) { + b0 = 0; + } + + if ((flag3 || flag4) && !flag1 && !flag2) { + b0 = 1; + } + + if (flag2 && flag4 && !flag1 && !flag3) { + b0 = 6; + } + + if (flag2 && flag3 && !flag1 && !flag4) { + b0 = 7; + } + + if (flag1 && flag3 && !flag2 && !flag4) { + b0 = 8; + } + + if (flag1 && flag4 && !flag2 && !flag3) { + b0 = 9; + } + + if (b0 == -1) { + if (flag1 || flag2) { + b0 = 0; + } + + if (flag3 || flag4) { + b0 = 1; + } + + if (flag) { + if (flag2 && flag4) { + b0 = 6; + } + + if (flag3 && flag2) { + b0 = 7; + } + + if (flag4 && flag1) { + b0 = 9; + } + + if (flag1 && flag3) { + b0 = 8; + } + } else { + if (flag1 && flag3) { + b0 = 8; + } + + if (flag4 && flag1) { + b0 = 9; + } + + if (flag3 && flag2) { + b0 = 7; + } + + if (flag2 && flag4) { + b0 = 6; + } + } + } + + if (b0 == 0) { + if (this.b.a(this.c, this.d + 1, this.e - 1) == this.a.bc) { + b0 = 4; + } + + if (this.b.a(this.c, this.d + 1, this.e + 1) == this.a.bc) { + b0 = 5; + } + } + + if (b0 == 1) { + if (this.b.a(this.c + 1, this.d + 1, this.e) == this.a.bc) { + b0 = 2; + } + + if (this.b.a(this.c - 1, this.d + 1, this.e) == this.a.bc) { + b0 = 3; + } + } + + if (b0 < 0) { + b0 = 0; + } + + this.f = b0; + this.a(); + this.b.b(this.c, this.d, this.e, b0); + + for (int i = 0; i < this.g.size(); ++i) { + MinecartTrackLogic minecarttracklogic = this.a((ChunkPosition) this.g.get(i)); + + if (minecarttracklogic != null) { + minecarttracklogic.b(); + if (minecarttracklogic.c(this)) { + minecarttracklogic.d(this); + } + } + } + } + + static int a(MinecartTrackLogic minecarttracklogic) { + return minecarttracklogic.c(); + } +} diff --git a/net/minecraft/server/MinecraftException.java b/net/minecraft/server/MinecraftException.java new file mode 100644 index 000000000..74f2d4008 --- /dev/null +++ b/net/minecraft/server/MinecraftException.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +public class MinecraftException extends RuntimeException { + + public MinecraftException(String s) { + super(s); + } +} diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java new file mode 100644 index 000000000..611b304bf --- /dev/null +++ b/net/minecraft/server/MinecraftServer.java @@ -0,0 +1,491 @@ +package net.minecraft.server; + +import java.awt.GraphicsEnvironment; +import java.io.File; +import java.io.IOException; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class MinecraftServer implements ICommandListener, Runnable { + + public static Logger a = Logger.getLogger("Minecraft"); + public static HashMap b = new HashMap(); + public NetworkListenThread c; + public PropertyManager d; + public WorldServer e; + public ServerConfigurationManager f; + private boolean m = true; + public boolean g = false; + int h = 0; + public String i; + public int j; + private List n = new ArrayList(); + private List o = Collections.synchronizedList(new ArrayList()); + public EntityTracker k; + public boolean l; + + public MinecraftServer() { + new ThreadSleepForever(this); + } + + private boolean d() { + ThreadCommandReader threadcommandreader = new ThreadCommandReader(this); + + threadcommandreader.setDaemon(true); + threadcommandreader.start(); + ConsoleLogManager.a(); + a.info("Starting minecraft server version 0.2.1"); + if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { + a.warning("**** NOT ENOUGH RAM!"); + a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); + } + + a.info("Loading properties"); + this.d = new PropertyManager(new File("server.properties")); + String s = this.d.a("server-ip", ""); + + this.l = this.d.a("online-mode", true); + InetAddress inetaddress = null; + + if (s.length() > 0) { + inetaddress = InetAddress.getByName(s); + } + + int i = this.d.a("server-port", 25565); + + a.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i); + + try { + this.c = new NetworkListenThread(this, inetaddress, i); + } catch (IOException ioexception) { + a.warning("**** FAILED TO BIND TO PORT!"); + a.log(Level.WARNING, "The exception was: " + ioexception.toString()); + a.warning("Perhaps a server is already running on that port?"); + return false; + } + + if (!this.l) { + a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + a.warning("The server will make no attempt to authenticate usernames. Beware."); + a.warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file."); + } + + this.f = new ServerConfigurationManager(this); + this.k = new EntityTracker(this); + String s1 = this.d.a("level-name", "world"); + + a.info("Preparing level \"" + s1 + "\""); + this.c(s1); + a.info("Done! For help, type \"help\" or \"?\""); + return true; + } + + private void c(String s) { + a.info("Preparing start region"); + this.e = new WorldServer(new File("."), s, this.d.a("monsters", false)); + this.e.a(new WorldManager(this)); + this.e.l = 1; + this.f.a(this.e); + byte b0 = 10; + + for (int i = -b0; i <= b0; ++i) { + this.a("Preparing spawn area", (i + b0) * 100 / (b0 + b0 + 1)); + + for (int j = -b0; j <= b0; ++j) { + if (!this.m) { + return; + } + + this.e.y.d((this.e.n >> 4) + i, (this.e.p >> 4) + j); + } + } + + this.e(); + } + + private void a(String s, int i) { + this.i = s; + this.j = i; + System.out.println(s + ": " + i + "%"); + } + + private void e() { + this.i = null; + this.j = 0; + } + + private void f() { + a.info("Saving chunks"); + this.e.a(true, (IProgressUpdate) null); + } + + private void g() { + a.info("Stopping server"); + if (this.f != null) { + this.f.d(); + } + + if (this.e != null) { + this.f(); + } + } + + public void a() { + this.m = false; + } + + public void run() { + try { + if (this.d()) { + long i = System.currentTimeMillis(); + long j = 0L; + + while (this.m) { + long k = System.currentTimeMillis(); + long l = k - i; + + if (l > 2000L) { + a.warning("Can\'t keep up! Did the system time change, or is the server overloaded?"); + l = 2000L; + } + + if (l < 0L) { + a.warning("Time ran backwards! Did the system time change?"); + l = 0L; + } + + j += l; + i = k; + + while (j > 50L) { + j -= 50L; + this.h(); + } + + Thread.sleep(1L); + } + } else { + while (this.m) { + this.b(); + + try { + Thread.sleep(10L); + } catch (InterruptedException interruptedexception) { + interruptedexception.printStackTrace(); + } + } + } + } catch (Exception exception) { + exception.printStackTrace(); + a.log(Level.SEVERE, "Unexpected exception", exception); + + while (this.m) { + this.b(); + + try { + Thread.sleep(10L); + } catch (InterruptedException interruptedexception1) { + interruptedexception1.printStackTrace(); + } + } + } finally { + this.g(); + this.g = true; + System.exit(0); + } + } + + private void h() { + ArrayList arraylist = new ArrayList(); + Iterator iterator = b.keySet().iterator(); + + while (iterator.hasNext()) { + String s = (String) iterator.next(); + int i = ((Integer) b.get(s)).intValue(); + + if (i > 0) { + b.put(s, Integer.valueOf(i - 1)); + } else { + arraylist.add(s); + } + } + + int j; + + for (j = 0; j < arraylist.size(); ++j) { + b.remove(arraylist.get(j)); + } + + AxisAlignedBB.a(); + Vec3D.a(); + ++this.h; + if (this.h % 20 == 0) { + this.f.a((Packet) (new Packet4UpdateTime(this.e.c))); + } + + this.e.e(); + + while (this.e.c()) { + ; + } + + this.e.b(); + this.c.a(); + this.f.b(); + this.k.a(); + + for (j = 0; j < this.n.size(); ++j) { + ((IUpdatePlayerListBox) this.n.get(j)).a(); + } + + try { + this.b(); + } catch (Exception exception) { + a.log(Level.WARNING, "Unexpected exception while parsing console command", exception); + } + } + + public void a(String s, ICommandListener icommandlistener) { + this.o.add(new ServerCommand(s, icommandlistener)); + } + + public void b() { + while (this.o.size() > 0) { + ServerCommand servercommand = (ServerCommand) this.o.remove(0); + String s = servercommand.a; + ICommandListener icommandlistener = servercommand.b; + String s1 = icommandlistener.c(); + + if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) { + if (s.toLowerCase().startsWith("list")) { + icommandlistener.b("Connected players: " + this.f.c()); + } else if (s.toLowerCase().startsWith("stop")) { + this.a(s1, "Stopping the server.."); + this.m = false; + } else if (s.toLowerCase().startsWith("save-all")) { + this.a(s1, "Forcing save.."); + this.e.a(true, (IProgressUpdate) null); + this.a(s1, "Save complete."); + } else if (s.toLowerCase().startsWith("save-off")) { + this.a(s1, "Disabling level saving.."); + this.e.A = true; + } else if (s.toLowerCase().startsWith("save-on")) { + this.a(s1, "Enabling level saving.."); + this.e.A = false; + } else { + String s2; + + if (s.toLowerCase().startsWith("op ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + this.f.e(s2); + this.a(s1, "Opping " + s2); + this.f.a(s2, "\u00A7eYou are now op!"); + } else if (s.toLowerCase().startsWith("deop ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + this.f.f(s2); + this.f.a(s2, "\u00A7eYou are no longer op!"); + this.a(s1, "De-opping " + s2); + } else if (s.toLowerCase().startsWith("ban-ip ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + this.f.c(s2); + this.a(s1, "Banning ip " + s2); + } else if (s.toLowerCase().startsWith("pardon-ip ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + this.f.d(s2); + this.a(s1, "Pardoning ip " + s2); + } else { + EntityPlayer entityplayer; + + if (s.toLowerCase().startsWith("ban ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + this.f.a(s2); + this.a(s1, "Banning " + s2); + entityplayer = this.f.h(s2); + if (entityplayer != null) { + entityplayer.a.c("Banned by admin"); + } + } else if (s.toLowerCase().startsWith("pardon ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + this.f.b(s2); + this.a(s1, "Pardoning " + s2); + } else if (s.toLowerCase().startsWith("kick ")) { + s2 = s.substring(s.indexOf(" ")).trim(); + entityplayer = null; + + for (int i = 0; i < this.f.b.size(); ++i) { + EntityPlayer entityplayer1 = (EntityPlayer) this.f.b.get(i); + + if (entityplayer1.aq.equalsIgnoreCase(s2)) { + entityplayer = entityplayer1; + } + } + + if (entityplayer != null) { + entityplayer.a.c("Kicked by admin"); + this.a(s1, "Kicking " + entityplayer.aq); + } else { + icommandlistener.b("Can\'t find user " + s2 + ". No kick."); + } + } else { + String[] astring; + EntityPlayer entityplayer2; + + if (s.toLowerCase().startsWith("tp ")) { + astring = s.split(" "); + if (astring.length == 3) { + entityplayer = this.f.h(astring[1]); + entityplayer2 = this.f.h(astring[2]); + if (entityplayer == null) { + icommandlistener.b("Can\'t find user " + astring[1] + ". No tp."); + } else if (entityplayer2 == null) { + icommandlistener.b("Can\'t find user " + astring[2] + ". No tp."); + } else { + entityplayer.a.a(entityplayer2.l, entityplayer2.m, entityplayer2.n, entityplayer2.r, entityplayer2.s); + this.a(s1, "Teleporting " + astring[1] + " to " + astring[2] + "."); + } + } else { + icommandlistener.b("Syntax error, please provice a source and a target."); + } + } else if (s.toLowerCase().startsWith("give ")) { + astring = s.split(" "); + if (astring.length != 3 && astring.length != 4) { + return; + } + + String s3 = astring[1]; + + entityplayer2 = this.f.h(s3); + if (entityplayer2 != null) { + try { + int j = Integer.parseInt(astring[2]); + + if (Item.c[j] != null) { + this.a(s1, "Giving " + entityplayer2.aq + " some " + j); + int k = 1; + + if (astring.length > 3) { + k = this.b(astring[3], 1); + } + + if (k < 1) { + k = 1; + } + + if (k > 64) { + k = 64; + } + + entityplayer2.a(new ItemStack(j, k)); + } else { + icommandlistener.b("There\'s no item with id " + j); + } + } catch (NumberFormatException numberformatexception) { + icommandlistener.b("There\'s no item with id " + astring[2]); + } + } else { + icommandlistener.b("Can\'t find user " + s3); + } + } else if (s.toLowerCase().startsWith("say ")) { + s = s.substring(s.indexOf(" ")).trim(); + a.info("[" + s1 + "] " + s); + this.f.a((Packet) (new Packet3Chat("\u00A7d[Server] " + s))); + } else if (s.toLowerCase().startsWith("tell ")) { + astring = s.split(" "); + if (astring.length >= 3) { + s = s.substring(s.indexOf(" ")).trim(); + s = s.substring(s.indexOf(" ")).trim(); + a.info("[" + s1 + "->" + astring[1] + "] " + s); + this.f.a((Packet) (new Packet3Chat("\u00A7d[Server] " + s))); + s = "\u00A77" + s1 + " whispers " + s; + a.info(s); + if (!this.f.a(astring[1], (Packet) (new Packet3Chat(s)))) { + icommandlistener.b("There\'s no player by that name online."); + } + } + } else { + a.info("Unknown console command. Type \"help\" for help."); + } + } + } + } + } else { + icommandlistener.b("To run the server without a gui, start it like this:"); + icommandlistener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui"); + icommandlistener.b("Console commands:"); + icommandlistener.b(" help or ? shows this message"); + icommandlistener.b(" kick removes a player from the server"); + icommandlistener.b(" ban bans a player from the server"); + icommandlistener.b(" pardon pardons a banned player so that they can connect again"); + icommandlistener.b(" ban-ip bans an IP address from the server"); + icommandlistener.b(" pardon-ip pardons a banned IP address so that they can connect again"); + icommandlistener.b(" op turns a player into an op"); + icommandlistener.b(" deop removes op status from a player"); + icommandlistener.b(" tp moves one player to the same location as another player"); + icommandlistener.b(" give [num] gives a player a resource"); + icommandlistener.b(" tell sends a private message to a player"); + icommandlistener.b(" stop gracefully stops the server"); + icommandlistener.b(" save-all forces a server-wide level save"); + icommandlistener.b(" save-off disables terrain saving (useful for backup scripts)"); + icommandlistener.b(" save-on re-enables terrain saving"); + icommandlistener.b(" list lists all currently connected players"); + icommandlistener.b(" say broadcasts a message to all players"); + } + } + } + + private void a(String s, String s1) { + String s2 = s + ": " + s1; + + this.f.i("\u00A77(" + s2 + ")"); + a.info(s2); + } + + private int b(String s, int i) { + try { + return Integer.parseInt(s); + } catch (NumberFormatException numberformatexception) { + return i; + } + } + + public void a(IUpdatePlayerListBox iupdateplayerlistbox) { + this.n.add(iupdateplayerlistbox); + } + + public static void main(String[] astring) { + try { + MinecraftServer minecraftserver = new MinecraftServer(); + + if (!GraphicsEnvironment.isHeadless() && (astring.length <= 0 || !astring[0].equals("nogui"))) { + ServerGUI.a(minecraftserver); + } + + (new ThreadServerApplication("Server thread", minecraftserver)).start(); + } catch (Exception exception) { + a.log(Level.SEVERE, "Failed to start the minecraft server", exception); + } + } + + public File a(String s) { + return new File(s); + } + + public void b(String s) { + a.info(s); + } + + public String c() { + return "CONSOLE"; + } + + public static boolean a(MinecraftServer minecraftserver) { + return minecraftserver.m; + } +} diff --git a/net/minecraft/server/MovingObjectPosition.java b/net/minecraft/server/MovingObjectPosition.java new file mode 100644 index 000000000..4f59582d2 --- /dev/null +++ b/net/minecraft/server/MovingObjectPosition.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +public class MovingObjectPosition { + + public int a; + public int b; + public int c; + public int d; + public int e; + public Vec3D f; + public Entity g; + + public MovingObjectPosition(int i, int j, int k, int l, Vec3D vec3d) { + this.a = 0; + this.b = i; + this.c = j; + this.d = k; + this.e = l; + this.f = Vec3D.b(vec3d.a, vec3d.b, vec3d.c); + } + + public MovingObjectPosition(Entity entity) { + this.a = 1; + this.g = entity; + this.f = Vec3D.b(entity.l, entity.m, entity.n); + } +} diff --git a/net/minecraft/server/NBTBase.java b/net/minecraft/server/NBTBase.java new file mode 100644 index 000000000..f6d5ff60b --- /dev/null +++ b/net/minecraft/server/NBTBase.java @@ -0,0 +1,128 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public abstract class NBTBase { + + private String a = null; + + public NBTBase() {} + + abstract void a(DataOutput dataoutput); + + abstract void a(DataInput datainput); + + public abstract byte a(); + + public String c() { + return this.a == null ? "" : this.a; + } + + public NBTBase m(String s) { + this.a = s; + return this; + } + + public static NBTBase b(DataInput datainput) { + byte b0 = datainput.readByte(); + + if (b0 == 0) { + return new NBTTagEnd(); + } else { + NBTBase nbtbase = a(b0); + + nbtbase.a = datainput.readUTF(); + nbtbase.a(datainput); + return nbtbase; + } + } + + public static void a(NBTBase nbtbase, DataOutput dataoutput) { + dataoutput.writeByte(nbtbase.a()); + if (nbtbase.a() != 0) { + dataoutput.writeUTF(nbtbase.c()); + nbtbase.a(dataoutput); + } + } + + public static NBTBase a(byte b0) { + switch (b0) { + case 0: + return new NBTTagEnd(); + + case 1: + return new NBTTagByte(); + + case 2: + return new NBTTagShort(); + + case 3: + return new NBTTagInt(); + + case 4: + return new NBTTagLong(); + + case 5: + return new NBTTagFloat(); + + case 6: + return new NBTTagDouble(); + + case 7: + return new NBTTagByteArray(); + + case 8: + return new NBTTagString(); + + case 9: + return new NBTTagList(); + + case 10: + return new NBTTagCompound(); + + default: + return null; + } + } + + public static String b(byte b0) { + switch (b0) { + case 0: + return "TAG_End"; + + case 1: + return "TAG_Byte"; + + case 2: + return "TAG_Short"; + + case 3: + return "TAG_Int"; + + case 4: + return "TAG_Long"; + + case 5: + return "TAG_Float"; + + case 6: + return "TAG_Double"; + + case 7: + return "TAG_Byte_Array"; + + case 8: + return "TAG_String"; + + case 9: + return "TAG_List"; + + case 10: + return "TAG_Compound"; + + default: + return "UNKNOWN"; + } + } +} diff --git a/net/minecraft/server/NBTTagByte.java b/net/minecraft/server/NBTTagByte.java new file mode 100644 index 000000000..fb5987771 --- /dev/null +++ b/net/minecraft/server/NBTTagByte.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagByte extends NBTBase { + + public byte a; + + public NBTTagByte() {} + + public NBTTagByte(byte b0) { + this.a = b0; + } + + void a(DataOutput dataoutput) { + dataoutput.writeByte(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readByte(); + } + + public byte a() { + return (byte) 1; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NBTTagByteArray.java b/net/minecraft/server/NBTTagByteArray.java new file mode 100644 index 000000000..e29709ff3 --- /dev/null +++ b/net/minecraft/server/NBTTagByteArray.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagByteArray extends NBTBase { + + public byte[] a; + + public NBTTagByteArray() {} + + public NBTTagByteArray(byte[] abyte) { + this.a = abyte; + } + + void a(DataOutput dataoutput) { + dataoutput.writeInt(this.a.length); + dataoutput.write(this.a); + } + + void a(DataInput datainput) { + int i = datainput.readInt(); + + this.a = new byte[i]; + datainput.readFully(this.a); + } + + public byte a() { + return (byte) 7; + } + + public String toString() { + return "[" + this.a.length + " bytes]"; + } +} diff --git a/net/minecraft/server/NBTTagCompound.java b/net/minecraft/server/NBTTagCompound.java new file mode 100644 index 000000000..a14495ae3 --- /dev/null +++ b/net/minecraft/server/NBTTagCompound.java @@ -0,0 +1,136 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class NBTTagCompound extends NBTBase { + + private Map a = new HashMap(); + + public NBTTagCompound() {} + + void a(DataOutput dataoutput) { + Iterator iterator = this.a.values().iterator(); + + while (iterator.hasNext()) { + NBTBase nbtbase = (NBTBase) iterator.next(); + + NBTBase.a(nbtbase, dataoutput); + } + + dataoutput.writeByte(0); + } + + void a(DataInput datainput) { + this.a.clear(); + + NBTBase nbtbase; + + while ((nbtbase = NBTBase.b(datainput)).a() != 0) { + this.a.put(nbtbase.c(), nbtbase); + } + } + + public byte a() { + return (byte) 10; + } + + public void a(String s, NBTBase nbtbase) { + this.a.put(s, nbtbase.m(s)); + } + + public void a(String s, byte b0) { + this.a.put(s, (new NBTTagByte(b0)).m(s)); + } + + public void a(String s, short short1) { + this.a.put(s, (new NBTTagShort(short1)).m(s)); + } + + public void a(String s, int i) { + this.a.put(s, (new NBTTagInt(i)).m(s)); + } + + public void a(String s, long i) { + this.a.put(s, (new NBTTagLong(i)).m(s)); + } + + public void a(String s, float f) { + this.a.put(s, (new NBTTagFloat(f)).m(s)); + } + + public void a(String s, double d0) { + this.a.put(s, (new NBTTagDouble(d0)).m(s)); + } + + public void a(String s, String s1) { + this.a.put(s, (new NBTTagString(s1)).m(s)); + } + + public void a(String s, byte[] abyte) { + this.a.put(s, (new NBTTagByteArray(abyte)).m(s)); + } + + public void a(String s, NBTTagCompound nbttagcompound) { + this.a.put(s, nbttagcompound.m(s)); + } + + public void a(String s, boolean flag) { + this.a(s, (byte) (flag ? 1 : 0)); + } + + public boolean a(String s) { + return this.a.containsKey(s); + } + + public byte b(String s) { + return !this.a.containsKey(s) ? 0 : ((NBTTagByte) this.a.get(s)).a; + } + + public short c(String s) { + return !this.a.containsKey(s) ? 0 : ((NBTTagShort) this.a.get(s)).a; + } + + public int d(String s) { + return !this.a.containsKey(s) ? 0 : ((NBTTagInt) this.a.get(s)).a; + } + + public long e(String s) { + return !this.a.containsKey(s) ? 0L : ((NBTTagLong) this.a.get(s)).a; + } + + public float f(String s) { + return !this.a.containsKey(s) ? 0.0F : ((NBTTagFloat) this.a.get(s)).a; + } + + public double g(String s) { + return !this.a.containsKey(s) ? 0.0D : ((NBTTagDouble) this.a.get(s)).a; + } + + public String h(String s) { + return !this.a.containsKey(s) ? "" : ((NBTTagString) this.a.get(s)).a; + } + + public byte[] i(String s) { + return !this.a.containsKey(s) ? new byte[0] : ((NBTTagByteArray) this.a.get(s)).a; + } + + public NBTTagCompound j(String s) { + return !this.a.containsKey(s) ? new NBTTagCompound() : (NBTTagCompound) this.a.get(s); + } + + public NBTTagList k(String s) { + return !this.a.containsKey(s) ? new NBTTagList() : (NBTTagList) this.a.get(s); + } + + public boolean l(String s) { + return this.b(s) != 0; + } + + public String toString() { + return "" + this.a.size() + " entries"; + } +} diff --git a/net/minecraft/server/NBTTagDouble.java b/net/minecraft/server/NBTTagDouble.java new file mode 100644 index 000000000..f11b368b0 --- /dev/null +++ b/net/minecraft/server/NBTTagDouble.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagDouble extends NBTBase { + + public double a; + + public NBTTagDouble() {} + + public NBTTagDouble(double d0) { + this.a = d0; + } + + void a(DataOutput dataoutput) { + dataoutput.writeDouble(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readDouble(); + } + + public byte a() { + return (byte) 6; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NBTTagEnd.java b/net/minecraft/server/NBTTagEnd.java new file mode 100644 index 000000000..18e516eb7 --- /dev/null +++ b/net/minecraft/server/NBTTagEnd.java @@ -0,0 +1,21 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagEnd extends NBTBase { + + public NBTTagEnd() {} + + void a(DataInput datainput) {} + + void a(DataOutput dataoutput) {} + + public byte a() { + return (byte) 0; + } + + public String toString() { + return "END"; + } +} diff --git a/net/minecraft/server/NBTTagFloat.java b/net/minecraft/server/NBTTagFloat.java new file mode 100644 index 000000000..31b7c80a9 --- /dev/null +++ b/net/minecraft/server/NBTTagFloat.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagFloat extends NBTBase { + + public float a; + + public NBTTagFloat() {} + + public NBTTagFloat(float f) { + this.a = f; + } + + void a(DataOutput dataoutput) { + dataoutput.writeFloat(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readFloat(); + } + + public byte a() { + return (byte) 5; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NBTTagInt.java b/net/minecraft/server/NBTTagInt.java new file mode 100644 index 000000000..50f4c3f5d --- /dev/null +++ b/net/minecraft/server/NBTTagInt.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagInt extends NBTBase { + + public int a; + + public NBTTagInt() {} + + public NBTTagInt(int i) { + this.a = i; + } + + void a(DataOutput dataoutput) { + dataoutput.writeInt(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readInt(); + } + + public byte a() { + return (byte) 3; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NBTTagList.java b/net/minecraft/server/NBTTagList.java new file mode 100644 index 000000000..e6557f3f4 --- /dev/null +++ b/net/minecraft/server/NBTTagList.java @@ -0,0 +1,64 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; +import java.util.ArrayList; +import java.util.List; + +public class NBTTagList extends NBTBase { + + private List a = new ArrayList(); + private byte b; + + public NBTTagList() {} + + void a(DataOutput dataoutput) { + if (this.a.size() > 0) { + this.b = ((NBTBase) this.a.get(0)).a(); + } else { + this.b = 1; + } + + dataoutput.writeByte(this.b); + dataoutput.writeInt(this.a.size()); + + for (int i = 0; i < this.a.size(); ++i) { + ((NBTBase) this.a.get(i)).a(dataoutput); + } + } + + void a(DataInput datainput) { + this.b = datainput.readByte(); + int i = datainput.readInt(); + + this.a = new ArrayList(); + + for (int j = 0; j < i; ++j) { + NBTBase nbtbase = NBTBase.a(this.b); + + nbtbase.a(datainput); + this.a.add(nbtbase); + } + } + + public byte a() { + return (byte) 9; + } + + public String toString() { + return "" + this.a.size() + " entries of type " + NBTBase.b(this.b); + } + + public void a(NBTBase nbtbase) { + this.b = nbtbase.a(); + this.a.add(nbtbase); + } + + public NBTBase a(int i) { + return (NBTBase) this.a.get(i); + } + + public int b() { + return this.a.size(); + } +} diff --git a/net/minecraft/server/NBTTagLong.java b/net/minecraft/server/NBTTagLong.java new file mode 100644 index 000000000..d1e932a2a --- /dev/null +++ b/net/minecraft/server/NBTTagLong.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagLong extends NBTBase { + + public long a; + + public NBTTagLong() {} + + public NBTTagLong(long i) { + this.a = i; + } + + void a(DataOutput dataoutput) { + dataoutput.writeLong(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readLong(); + } + + public byte a() { + return (byte) 4; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NBTTagShort.java b/net/minecraft/server/NBTTagShort.java new file mode 100644 index 000000000..26ad444b5 --- /dev/null +++ b/net/minecraft/server/NBTTagShort.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagShort extends NBTBase { + + public short a; + + public NBTTagShort() {} + + public NBTTagShort(short short1) { + this.a = short1; + } + + void a(DataOutput dataoutput) { + dataoutput.writeShort(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readShort(); + } + + public byte a() { + return (byte) 2; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NBTTagString.java b/net/minecraft/server/NBTTagString.java new file mode 100644 index 000000000..a87aec1e6 --- /dev/null +++ b/net/minecraft/server/NBTTagString.java @@ -0,0 +1,34 @@ +package net.minecraft.server; + +import java.io.DataInput; +import java.io.DataOutput; + +public class NBTTagString extends NBTBase { + + public String a; + + public NBTTagString() {} + + public NBTTagString(String s) { + this.a = s; + if (s == null) { + throw new IllegalArgumentException("Empty string not allowed"); + } + } + + void a(DataOutput dataoutput) { + dataoutput.writeUTF(this.a); + } + + void a(DataInput datainput) { + this.a = datainput.readUTF(); + } + + public byte a() { + return (byte) 8; + } + + public String toString() { + return "" + this.a; + } +} diff --git a/net/minecraft/server/NetHandler.java b/net/minecraft/server/NetHandler.java new file mode 100644 index 000000000..2fb35ba15 --- /dev/null +++ b/net/minecraft/server/NetHandler.java @@ -0,0 +1,112 @@ +package net.minecraft.server; + +public class NetHandler { + + public NetHandler() {} + + public void a(Packet51MapChunk packet51mapchunk) {} + + public void a(Packet packet) {} + + public void a(String s) {} + + public void a(Packet255KickDisconnect packet255kickdisconnect) { + this.a((Packet) packet255kickdisconnect); + } + + public void a(Packet1Login packet1login) { + this.a((Packet) packet1login); + } + + public void a(Packet10Flying packet10flying) { + this.a((Packet) packet10flying); + } + + public void a(Packet52MultiBlockChange packet52multiblockchange) { + this.a((Packet) packet52multiblockchange); + } + + public void a(Packet14BlockDig packet14blockdig) { + this.a((Packet) packet14blockdig); + } + + public void a(Packet53BlockChange packet53blockchange) { + this.a((Packet) packet53blockchange); + } + + public void a(Packet50PreChunk packet50prechunk) { + this.a((Packet) packet50prechunk); + } + + public void a(Packet20NamedEntitySpawn packet20namedentityspawn) { + this.a((Packet) packet20namedentityspawn); + } + + public void a(Packet30Entity packet30entity) { + this.a((Packet) packet30entity); + } + + public void a(Packet34EntityTeleport packet34entityteleport) { + this.a((Packet) packet34entityteleport); + } + + public void a(Packet15Place packet15place) { + this.a((Packet) packet15place); + } + + public void a(Packet16BlockItemSwitch packet16blockitemswitch) { + this.a((Packet) packet16blockitemswitch); + } + + public void a(Packet29DestroyEntity packet29destroyentity) { + this.a((Packet) packet29destroyentity); + } + + public void a(Packet21PickupSpawn packet21pickupspawn) { + this.a((Packet) packet21pickupspawn); + } + + public void a(Packet22Collect packet22collect) { + this.a((Packet) packet22collect); + } + + public void a(Packet3Chat packet3chat) { + this.a((Packet) packet3chat); + } + + public void a(Packet17AddToInventory packet17addtoinventory) { + this.a((Packet) packet17addtoinventory); + } + + public void a(Packet23VehicleSpawn packet23vehiclespawn) { + this.a((Packet) packet23vehiclespawn); + } + + public void a(Packet18ArmAnimation packet18armanimation) { + this.a((Packet) packet18armanimation); + } + + public void a(Packet2Handshake packet2handshake) { + this.a((Packet) packet2handshake); + } + + public void a(Packet24MobSpawn packet24mobspawn) { + this.a((Packet) packet24mobspawn); + } + + public void a(Packet4UpdateTime packet4updatetime) { + this.a((Packet) packet4updatetime); + } + + public void a(Packet5PlayerInventory packet5playerinventory) { + this.a((Packet) packet5playerinventory); + } + + public void a(Packet59ComplexEntity packet59complexentity) { + this.a((Packet) packet59complexentity); + } + + public void a(Packet6SpawnPosition packet6spawnposition) { + this.a((Packet) packet6spawnposition); + } +} diff --git a/net/minecraft/server/NetLoginHandler.java b/net/minecraft/server/NetLoginHandler.java new file mode 100644 index 000000000..2e84eae28 --- /dev/null +++ b/net/minecraft/server/NetLoginHandler.java @@ -0,0 +1,105 @@ +package net.minecraft.server; + +import java.net.Socket; +import java.util.Random; +import java.util.logging.Logger; + +public class NetLoginHandler extends NetHandler { + + public static Logger a = Logger.getLogger("Minecraft"); + private static Random d = new Random(); + public NetworkManager b; + public boolean c = false; + private MinecraftServer e; + private int f = 0; + private String g = null; + private Packet1Login h = null; + private String i = ""; + + public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) { + this.e = minecraftserver; + this.b = new NetworkManager(socket, s, this); + } + + public void a() { + if (this.h != null) { + this.b(this.h); + this.h = null; + } + + if (this.f++ == 100) { + this.b("Took too long to log in"); + } else { + this.b.a(); + } + } + + public void b(String s) { + a.info("Disconnecting " + this.b() + ": " + s); + this.b.a((Packet) (new Packet255KickDisconnect(s))); + this.b.c(); + this.c = true; + } + + public void a(Packet2Handshake packet2handshake) { + if (this.e.l) { + this.i = Long.toHexString(d.nextLong()); + this.b.a((Packet) (new Packet2Handshake(this.i))); + } else { + this.b.a((Packet) (new Packet2Handshake("-"))); + } + } + + public void a(Packet1Login packet1login) { + this.g = packet1login.b; + if (packet1login.a != 2) { + this.b("Outdated client!"); + } else { + if (!this.e.l) { + this.b(packet1login); + } else { + (new ThreadLoginVerifier(this, packet1login)).start(); + } + } + } + + public void b(Packet1Login packet1login) { + EntityPlayer entityplayer = this.e.f.a(this, packet1login.b, packet1login.c); + + if (entityplayer != null) { + a.info(this.b() + " logged in"); + NetServerHandler netserverhandler = new NetServerHandler(this.e, this.b, entityplayer); + + netserverhandler.b((Packet) (new Packet1Login("", "", 0))); + netserverhandler.b((Packet) (new Packet6SpawnPosition(this.e.e.n, this.e.e.o, this.e.e.p))); + this.e.f.a(entityplayer); + netserverhandler.a(entityplayer.l, entityplayer.m, entityplayer.n, entityplayer.r, entityplayer.s); + netserverhandler.d(); + this.e.c.a(netserverhandler); + netserverhandler.b((Packet) (new Packet4UpdateTime(this.e.e.c))); + } + + this.c = true; + } + + public void a(String s) { + a.info(this.b() + " lost connection"); + this.c = true; + } + + public void a(Packet packet) { + this.b("Protocol error"); + } + + public String b() { + return this.g != null ? this.g + " [" + this.b.b().toString() + "]" : this.b.b().toString(); + } + + static String a(NetLoginHandler netloginhandler) { + return netloginhandler.i; + } + + static Packet1Login a(NetLoginHandler netloginhandler, Packet1Login packet1login) { + return netloginhandler.h = packet1login; + } +} diff --git a/net/minecraft/server/NetServerHandler.java b/net/minecraft/server/NetServerHandler.java new file mode 100644 index 000000000..ee1ff020e --- /dev/null +++ b/net/minecraft/server/NetServerHandler.java @@ -0,0 +1,396 @@ +package net.minecraft.server; + +import java.util.logging.Logger; + +public class NetServerHandler extends NetHandler implements ICommandListener { + + public static Logger a = Logger.getLogger("Minecraft"); + public NetworkManager b; + public boolean c = false; + private MinecraftServer d; + private EntityPlayer e; + private int f = 0; + private double g; + private double h; + private double i; + private boolean j = true; + private String color; + private ItemStack k = null; + + public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { + this.d = minecraftserver; + this.b = networkmanager; + networkmanager.a((NetHandler) this); + this.e = entityplayer; + entityplayer.a = this; + this.color = Integer.toHexString((int) (Math.random() * 15.0D)); + } + + public void a() { + this.b.a(); + if (this.f++ % 20 == 0) { + this.b.a((Packet) (new Packet0KeepAlive())); + } + } + + public void c(String s) { + this.b.a((Packet) (new Packet255KickDisconnect(s))); + this.b.c(); + this.d.f.c(this.e); + this.c = true; + } + + public void a(Packet10Flying packet10flying) { + double d1; + + if (!this.j) { + d1 = packet10flying.b - this.h; + if (packet10flying.a == this.g && d1 * d1 < 0.01D && packet10flying.c == this.i) { + this.j = true; + } + } + + if (this.j) { + this.g = this.e.l; + this.h = this.e.m; + this.i = this.e.n; + d1 = this.e.l; + double d2 = this.e.m; + double d3 = this.e.n; + float f1 = this.e.r; + float f2 = this.e.s; + double d4; + + if (packet10flying.h) { + d1 = packet10flying.a; + d2 = packet10flying.b; + d3 = packet10flying.c; + d4 = packet10flying.d - packet10flying.b; + if (d4 > 1.65D || d4 < 0.1D) { + this.c("Illegal stance"); + a.warning(this.e.aq + " had an illegal stance: " + d4); + } + + this.e.ai = packet10flying.d; + } + + if (packet10flying.i) { + f1 = packet10flying.e; + f2 = packet10flying.f; + } + + this.e.i(); + this.e.M = 0.0F; + this.e.b(this.g, this.h, this.i, f1, f2); + d4 = d1 - this.e.l; + double d5 = d2 - this.e.m; + double d6 = d3 - this.e.n; + float f3 = 0.0625F; + boolean l = this.d.e.a(this.e, this.e.v.b().e((double) f3, (double) f3, (double) f3)).size() == 0; + + this.e.c(d4, d5, d6); + d4 = d1 - this.e.l; + d5 = d2 - this.e.m; + if (d5 > -0.5D || d5 < 0.5D) { + d5 = 0.0D; + } + + d6 = d3 - this.e.n; + double d7 = d4 * d4 + d5 * d5 + d6 * d6; + boolean i1 = false; + + if (d7 > 0.0625D) { + i1 = true; + a.warning(this.e.aq + " moved wrongly!"); + } + + this.e.b(d1, d2, d3, f1, f2); + boolean i2 = this.d.e.a(this.e, this.e.v.b().e((double) f3, (double) f3, (double) f3)).size() == 0; + + if (l && (i1 || !i2)) { + this.a(this.g, this.h, this.i, f1, f2); + return; + } + + this.e.w = packet10flying.g; + this.d.f.b(this.e); + } + } + + public void a(double d0, double d1, double d2, float f, float f1) { + this.j = false; + this.g = d0; + this.h = d1; + this.i = d2; + this.e.b(d0, d1, d2, f, f1); + this.e.a.b((Packet) (new Packet13PlayerLookMove(d0, d1 + 1.620000004768372D, d1, d2, f, f1, false))); + } + + public void a(Packet14BlockDig packet14blockdig) { + this.e.aj.a[this.e.aj.d] = this.k; + boolean bool = this.d.e.z = this.d.f.g(this.e.aq); + boolean l = false; + + if (packet14blockdig.e == 0) { + l = true; + } + + if (packet14blockdig.e == 1) { + l = true; + } + + if (l) { + double d1 = this.e.m; + + this.e.m = this.e.ai; + MovingObjectPosition i3 = this.e.a(4.0D, 1.0F); + + this.e.m = d1; + if (i3 == null) { + return; + } + + if (i3.b != packet14blockdig.a || i3.c != packet14blockdig.b || i3.d != packet14blockdig.c || i3.e != packet14blockdig.d) { + return; + } + } + + int i1 = packet14blockdig.a; + int i2 = packet14blockdig.b; + int i31 = packet14blockdig.c; + int i4 = packet14blockdig.d; + int i5 = (int) MathHelper.e((float) (i1 - this.d.e.n)); + int i6 = (int) MathHelper.e((float) (i31 - this.d.e.p)); + + if (i5 > i6) { + i6 = i5; + } + + if (packet14blockdig.e == 0) { + if (i6 > 16 || bool) { + this.e.ad.a(i1, i2, i31); + } + } else if (packet14blockdig.e == 2) { + this.e.ad.a(); + } else if (packet14blockdig.e == 1) { + if (i6 > 16 || bool) { + this.e.ad.a(i1, i2, i31, i4); + } + } else if (packet14blockdig.e == 3) { + double d2 = this.e.l - ((double) i1 + 0.5D); + double d3 = this.e.m - ((double) i2 + 0.5D); + double d4 = this.e.n - ((double) i31 + 0.5D); + double d5 = d2 * d2 + d3 * d3 + d4 * d4; + + if (d5 < 256.0D) { + this.e.a.b((Packet) (new Packet53BlockChange(i1, i2, i31, this.d.e))); + } + } + + this.d.e.z = false; + } + + public void a(Packet15Place packet15place) { + boolean bool = this.d.e.z = this.d.f.g(this.e.aq); + int l = packet15place.b; + int i1 = packet15place.c; + int i2 = packet15place.d; + int i3 = packet15place.e; + int i4 = (int) MathHelper.e((float) (l - this.d.e.n)); + int i5 = (int) MathHelper.e((float) (i2 - this.d.e.p)); + + if (i4 > i5) { + i5 = i4; + } + + if (i5 > 16 || bool) { + ItemStack localgp = packet15place.a >= 0 ? new ItemStack(packet15place.a) : null; + + this.e.ad.a(this.e, this.d.e, localgp, l, i1, i2, i3); + } + + this.e.a.b((Packet) (new Packet53BlockChange(l, i1, i2, this.d.e))); + this.d.e.z = false; + } + + public void a(String s) { + a.info(this.e.aq + " lost connection: " + s); + this.d.f.c(this.e); + this.c = true; + } + + public void a(Packet packet) { + a.warning(super.getClass() + " wasn\'t prepared to deal with a " + packet.getClass()); + this.c("Protocol error, unexpected packet"); + } + + public void b(Packet packet) { + this.b.a(packet); + } + + public void a(Packet16BlockItemSwitch packet16blockitemswitch) { + int l = packet16blockitemswitch.b; + + this.e.aj.d = this.e.aj.a.length - 1; + if (l == 0) { + this.k = null; + } else { + this.k = new ItemStack(l); + } + + this.e.aj.a[this.e.aj.d] = this.k; + this.d.k.a(this.e, new Packet16BlockItemSwitch(this.e.c, l)); + } + + public void a(Packet21PickupSpawn packet21pickupspawn) { + double d1 = (double) packet21pickupspawn.b / 32.0D; + double d2 = (double) packet21pickupspawn.c / 32.0D; + double d3 = (double) packet21pickupspawn.d / 32.0D; + EntityItem localfn = new EntityItem(this.d.e, d1, d2, d3, new ItemStack(packet21pickupspawn.h, packet21pickupspawn.i)); + + localfn.o = (double) packet21pickupspawn.e / 128.0D; + localfn.p = (double) packet21pickupspawn.f / 128.0D; + localfn.q = (double) packet21pickupspawn.g / 128.0D; + localfn.ad = 10; + this.d.e.a(localfn); + } + + public void a(Packet3Chat packet3chat) { + String str = packet3chat.a; + + if (str.length() > 100) { + this.c("Chat message too long"); + } else { + str = str.trim(); + + for (int l = 0; l < str.length(); ++l) { + if (" !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\'abcdefghijklmnopqrstuvwxyz{|}~⌂\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7ƒ\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB".indexOf(str.charAt(l)) < 0) { + this.c("Illegal characters in chat"); + return; + } + } + + if (str.startsWith("/")) { + this.d(str); + } else { + str = "<\u00A7" + this.color + this.e.aq + "\u00A7f> " + str; + a.info(str); + this.d.f.a((Packet) (new Packet3Chat(str))); + } + } + } + + private void d(String s) { + if (s.toLowerCase().startsWith("/me ")) { + s = "* " + this.e.aq + " " + s.substring(s.indexOf(" ")).trim(); + a.info(s); + this.d.f.a((Packet) (new Packet3Chat(s))); + } else if (s.toLowerCase().startsWith("/tell ")) { + String[] l = s.split(" "); + + if (l.length >= 3) { + s = s.substring(s.indexOf(" ")).trim(); + s = s.substring(s.indexOf(" ")).trim(); + s = "\u00A77" + this.e.aq + " whispers " + s; + a.info(s + " to " + l[1]); + if (!this.d.f.a(l[1], (Packet) (new Packet3Chat(s)))) { + this.b((Packet) (new Packet3Chat("\u00A7cThere\'s no player by that name online."))); + } + } + } else if (s.toLowerCase().startsWith("/color ")) { + String s1 = s.substring(s.indexOf(" ")).trim(); + + if (s1.matches("[0123456789abcdefABCDEF]")) { + this.color = s1; + this.b((Packet) (new Packet3Chat("\u00A7" + s1 + "Your color has changed to " + s1))); + } else { + this.b((Packet) (new Packet3Chat("\u00A7c/color only accepts a single hex digit."))); + this.b((Packet) (new Packet3Chat("Values: \u00A700\u00A711\u00A722\u00A733\u00A744\u00A755\u00A766\u00A777\u00A788\u00A799\u00A7AA\u00A7BB\u00A7CC\u00A7DD\u00A7EE\u00A7FF"))); + } + } else if (s.toLowerCase().equalsIgnoreCase("/color")) { + this.b((Packet) (new Packet3Chat("\u00A7cUse /color to change the color of your name."))); + this.b((Packet) (new Packet3Chat("Values: \u00A700\u00A711\u00A722\u00A733\u00A744\u00A755\u00A766\u00A777\u00A788\u00A799\u00A7AA\u00A7BB\u00A7CC\u00A7DD\u00A7EE\u00A7FF"))); + } else { + int i; + + if (s.toLowerCase().equalsIgnoreCase("/playerlist")) { + for (i = 0; i < this.d.f.b.size(); ++i) { + EntityPlayer str = (EntityPlayer) this.d.f.b.get(i); + + this.b((Packet) (new Packet3Chat("\u00A7" + str.a.color + str.aq))); + } + } else if (s.toLowerCase().equalsIgnoreCase("/help")) { + this.b((Packet) (new Packet3Chat("\u00A7e/home - return to the spawn point"))); + this.b((Packet) (new Packet3Chat("\u00A7e/playerlist - list the players on the server"))); + this.b((Packet) (new Packet3Chat("\u00A7e/tell - whisper to a player"))); + this.b((Packet) (new Packet3Chat("\u00A7e/color - change your name\'s color"))); + } else if (s.toLowerCase().equalsIgnoreCase("/home")) { + a.info(this.e.aq + " returned home"); + i = this.d.e.d(this.d.e.n, this.d.e.p); + this.a((double) this.d.e.n + 0.5D, (double) i + 1.5D, (double) this.d.e.p + 0.5D, 0.0F, 0.0F); + } else { + String s2; + + if (this.d.f.g(this.e.aq)) { + s2 = s.substring(1); + a.info(this.e.aq + " issued server command: " + s2); + this.d.a(s2, (ICommandListener) this); + } else { + s2 = s.substring(1); + a.info(this.e.aq + " tried command: " + s2); + } + } + } + } + + public void a(Packet18ArmAnimation packet18armanimation) { + if (packet18armanimation.b == 1) { + this.e.z(); + } + } + + public void a(Packet255KickDisconnect packet255kickdisconnect) { + this.b.a("Quitting"); + } + + public int b() { + return this.b.d(); + } + + public void b(String s) { + this.b((Packet) (new Packet3Chat("\u00A77" + s))); + } + + public String c() { + return this.e.aq; + } + + public void a(Packet5PlayerInventory packet5playerinventory) { + if (packet5playerinventory.a == -1) { + this.e.aj.a = packet5playerinventory.b; + } + + if (packet5playerinventory.a == -2) { + this.e.aj.c = packet5playerinventory.b; + } + + if (packet5playerinventory.a == -3) { + this.e.aj.b = packet5playerinventory.b; + } + } + + public void d() { + this.b.a((Packet) (new Packet5PlayerInventory(-1, this.e.aj.a))); + this.b.a((Packet) (new Packet5PlayerInventory(-2, this.e.aj.c))); + this.b.a((Packet) (new Packet5PlayerInventory(-3, this.e.aj.b))); + } + + public void a(Packet59ComplexEntity packet59complexentity) { + TileEntity localas = this.d.e.k(packet59complexentity.a, packet59complexentity.b, packet59complexentity.c); + + if (localas != null) { + localas.a(packet59complexentity.e); + localas.c(); + } + } +} diff --git a/net/minecraft/server/NetworkAcceptThread.java b/net/minecraft/server/NetworkAcceptThread.java new file mode 100644 index 000000000..72c969789 --- /dev/null +++ b/net/minecraft/server/NetworkAcceptThread.java @@ -0,0 +1,33 @@ +package net.minecraft.server; + +import java.io.IOException; +import java.net.Socket; + +class NetworkAcceptThread extends Thread { + + final MinecraftServer a; + + final NetworkListenThread b; + + NetworkAcceptThread(NetworkListenThread networklistenthread, String s, MinecraftServer minecraftserver) { + super(s); + this.b = networklistenthread; + this.a = minecraftserver; + } + + public void run() { + while (this.b.b) { + try { + Socket socket = NetworkListenThread.a(this.b).accept(); + + if (socket != null) { + NetLoginHandler netloginhandler = new NetLoginHandler(this.a, socket, "Connection #" + NetworkListenThread.b(this.b)); + + NetworkListenThread.a(this.b, netloginhandler); + } + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + } +} diff --git a/net/minecraft/server/NetworkListenThread.java b/net/minecraft/server/NetworkListenThread.java new file mode 100644 index 000000000..eda349163 --- /dev/null +++ b/net/minecraft/server/NetworkListenThread.java @@ -0,0 +1,86 @@ +package net.minecraft.server; + +import java.net.InetAddress; +import java.net.ServerSocket; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class NetworkListenThread { + + public static Logger a = Logger.getLogger("Minecraft"); + private ServerSocket d; + private Thread e; + public volatile boolean b = false; + private int f = 0; + private ArrayList g = new ArrayList(); + private ArrayList h = new ArrayList(); + public MinecraftServer c; + + public NetworkListenThread(MinecraftServer minecraftserver, InetAddress inetaddress, int i) { + this.c = minecraftserver; + this.d = new ServerSocket(i, 0, inetaddress); + this.d.setPerformancePreferences(0, 2, 1); + this.b = true; + this.e = new NetworkAcceptThread(this, "Listen thread", minecraftserver); + this.e.start(); + } + + public void a(NetServerHandler netserverhandler) { + this.h.add(netserverhandler); + } + + private void a(NetLoginHandler netloginhandler) { + if (netloginhandler == null) { + throw new IllegalArgumentException("Got null pendingconnection!"); + } else { + this.g.add(netloginhandler); + } + } + + public void a() { + int i; + + for (i = 0; i < this.g.size(); ++i) { + NetLoginHandler netloginhandler = (NetLoginHandler) this.g.get(i); + + try { + netloginhandler.a(); + } catch (Exception exception) { + netloginhandler.b("Internal server error"); + a.log(Level.WARNING, "Failed to handle packet: " + exception, exception); + } + + if (netloginhandler.c) { + this.g.remove(i--); + } + } + + for (i = 0; i < this.h.size(); ++i) { + NetServerHandler netserverhandler = (NetServerHandler) this.h.get(i); + + try { + netserverhandler.a(); + } catch (Exception exception1) { + netserverhandler.c("Internal server error"); + a.log(Level.WARNING, "Failed to handle packet: " + exception1, exception1); + } + + if (netserverhandler.c) { + this.h.remove(i--); + } + } + } + + static ServerSocket a(NetworkListenThread networklistenthread) { + return networklistenthread.d; + } + + static int b(NetworkListenThread networklistenthread) { + return networklistenthread.f++; + } + + static void a(NetworkListenThread networklistenthread, NetLoginHandler netloginhandler) { + networklistenthread.a(netloginhandler); + } +} diff --git a/net/minecraft/server/NetworkManager.java b/net/minecraft/server/NetworkManager.java new file mode 100644 index 000000000..6cd3c7580 --- /dev/null +++ b/net/minecraft/server/NetworkManager.java @@ -0,0 +1,217 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.net.Socket; +import java.net.SocketAddress; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +public class NetworkManager { + + public static final Object a = new Object(); + public static int b; + public static int c; + private Object d = new Object(); + private Socket e; + private DataInputStream f; + private DataOutputStream g; + private boolean h = true; + private List i = Collections.synchronizedList(new LinkedList()); + private List j = Collections.synchronizedList(new LinkedList()); + private List k = Collections.synchronizedList(new LinkedList()); + private NetHandler l; + private boolean m = false; + private Thread n; + private Thread o; + private boolean p = false; + private String q = ""; + private int r = 0; + private int s = 0; + private int t = 0; + + public NetworkManager(Socket socket, String s, NetHandler nethandler) { + this.e = socket; + this.l = nethandler; + socket.setTrafficClass(24); + this.f = new DataInputStream(socket.getInputStream()); + this.g = new DataOutputStream(socket.getOutputStream()); + this.o = new NetworkReaderThread(this, s + " read thread"); + this.n = new NetworkWriterThread(this, s + " write thread"); + this.o.start(); + this.n.start(); + } + + public void a(NetHandler nethandler) { + this.l = nethandler; + } + + public void a(Packet packet) { + if (!this.m) { + Object object = this.d; + + synchronized (this.d) { + this.s += packet.a() + 1; + if (packet.j) { + this.k.add(packet); + } else { + this.j.add(packet); + } + } + } + } + + private void e() { + try { + boolean flag = true; + Object object; + Packet packet; + + if (!this.j.isEmpty()) { + flag = false; + object = this.d; + synchronized (this.d) { + packet = (Packet) this.j.remove(0); + this.s -= packet.a() + 1; + } + + Packet.a(packet, this.g); + } + + if ((flag || this.t-- <= 0) && !this.k.isEmpty()) { + flag = false; + object = this.d; + synchronized (this.d) { + packet = (Packet) this.k.remove(0); + this.s -= packet.a() + 1; + } + + Packet.a(packet, this.g); + this.t = 50; + } + + if (flag) { + Thread.sleep(10L); + } + } catch (InterruptedException interruptedexception) { + ; + } catch (Exception exception) { + if (!this.p) { + this.a(exception); + } + } + } + + private void f() { + try { + Packet packet = Packet.b(this.f); + + if (packet != null) { + this.i.add(packet); + } else { + this.a("End of stream"); + } + } catch (Exception exception) { + if (!this.p) { + this.a(exception); + } + } + } + + private void a(Exception exception) { + exception.printStackTrace(); + this.a("Internal exception: " + exception.toString()); + } + + public void a(String s) { + if (this.h) { + this.p = true; + this.q = s; + (new NetworkMasterThread(this)).start(); + this.h = false; + + try { + this.f.close(); + } catch (Throwable throwable) { + ; + } + + try { + this.g.close(); + } catch (Throwable throwable1) { + ; + } + + try { + this.e.close(); + } catch (Throwable throwable2) { + ; + } + } + } + + public void a() { + if (this.s > 1048576) { + this.a("Send buffer overflow"); + } + + if (this.i.isEmpty()) { + if (this.r++ == 1200) { + this.a("Timed out"); + } + } else { + this.r = 0; + } + + int i = 100; + + while (!this.i.isEmpty() && i-- >= 0) { + Packet packet = (Packet) this.i.remove(0); + + packet.a(this.l); + } + + if (this.p && this.i.isEmpty()) { + this.l.a(this.q); + } + } + + public SocketAddress b() { + return this.e.getRemoteSocketAddress(); + } + + public void c() { + this.m = true; + this.o.interrupt(); + (new ThreadMonitorConnection(this)).start(); + } + + public int d() { + return this.k.size(); + } + + static boolean a(NetworkManager networkmanager) { + return networkmanager.h; + } + + static boolean b(NetworkManager networkmanager) { + return networkmanager.m; + } + + static void c(NetworkManager networkmanager) { + networkmanager.f(); + } + + static void d(NetworkManager networkmanager) { + networkmanager.e(); + } + + static Thread e(NetworkManager networkmanager) { + return networkmanager.o; + } + + static Thread f(NetworkManager networkmanager) { + return networkmanager.n; + } +} diff --git a/net/minecraft/server/NetworkMasterThread.java b/net/minecraft/server/NetworkMasterThread.java new file mode 100644 index 000000000..845488a9c --- /dev/null +++ b/net/minecraft/server/NetworkMasterThread.java @@ -0,0 +1,33 @@ +package net.minecraft.server; + +class NetworkMasterThread extends Thread { + + final NetworkManager a; + + NetworkMasterThread(NetworkManager networkmanager) { + this.a = networkmanager; + } + + public void run() { + try { + Thread.sleep(5000L); + if (NetworkManager.e(this.a).isAlive()) { + try { + NetworkManager.e(this.a).stop(); + } catch (Throwable throwable) { + ; + } + } + + if (NetworkManager.f(this.a).isAlive()) { + try { + NetworkManager.f(this.a).stop(); + } catch (Throwable throwable1) { + ; + } + } + } catch (InterruptedException interruptedexception) { + interruptedexception.printStackTrace(); + } + } +} diff --git a/net/minecraft/server/NetworkReaderThread.java b/net/minecraft/server/NetworkReaderThread.java new file mode 100644 index 000000000..852805571 --- /dev/null +++ b/net/minecraft/server/NetworkReaderThread.java @@ -0,0 +1,52 @@ +package net.minecraft.server; + +class NetworkReaderThread extends Thread { + + final NetworkManager a; + + NetworkReaderThread(NetworkManager networkmanager, String s) { + super(s); + this.a = networkmanager; + } + + public void run() { + Object object = NetworkManager.a; + + synchronized (NetworkManager.a) { + ++NetworkManager.b; + } + + while (true) { + boolean flag = false; + + try { + flag = true; + if (NetworkManager.a(this.a)) { + if (!NetworkManager.b(this.a)) { + NetworkManager.c(this.a); + continue; + } + + flag = false; + break; + } + + flag = false; + break; + } finally { + if (flag) { + Object object1 = NetworkManager.a; + + synchronized (NetworkManager.a) { + --NetworkManager.b; + } + } + } + } + + object = NetworkManager.a; + synchronized (NetworkManager.a) { + --NetworkManager.b; + } + } +} diff --git a/net/minecraft/server/NetworkWriterThread.java b/net/minecraft/server/NetworkWriterThread.java new file mode 100644 index 000000000..e422c727d --- /dev/null +++ b/net/minecraft/server/NetworkWriterThread.java @@ -0,0 +1,46 @@ +package net.minecraft.server; + +class NetworkWriterThread extends Thread { + + final NetworkManager a; + + NetworkWriterThread(NetworkManager networkmanager, String s) { + super(s); + this.a = networkmanager; + } + + public void run() { + Object object = NetworkManager.a; + + synchronized (NetworkManager.a) { + ++NetworkManager.c; + } + + while (true) { + boolean flag = false; + + try { + flag = true; + if (!NetworkManager.a(this.a)) { + flag = false; + break; + } + + NetworkManager.d(this.a); + } finally { + if (flag) { + Object object1 = NetworkManager.a; + + synchronized (NetworkManager.a) { + --NetworkManager.c; + } + } + } + } + + object = NetworkManager.a; + synchronized (NetworkManager.a) { + --NetworkManager.c; + } + } +} diff --git a/net/minecraft/server/NextTickListEntry.java b/net/minecraft/server/NextTickListEntry.java new file mode 100644 index 000000000..89dfcc2aa --- /dev/null +++ b/net/minecraft/server/NextTickListEntry.java @@ -0,0 +1,43 @@ +package net.minecraft.server; + +public class NextTickListEntry implements Comparable { + + private static long f = 0L; + public int a; + public int b; + public int c; + public int d; + public long e; + private long g; + + public NextTickListEntry(int i, int j, int k, int l) { + this.g = (long) (f++); + this.a = i; + this.b = j; + this.c = k; + this.d = l; + } + + public boolean equals(Object object) { + if (!(object instanceof NextTickListEntry)) { + return false; + } else { + NextTickListEntry nextticklistentry = (NextTickListEntry) object; + + return this.a == nextticklistentry.a && this.b == nextticklistentry.b && this.c == nextticklistentry.c && this.d == nextticklistentry.d; + } + } + + public int hashCode() { + return (this.a * 128 * 1024 + this.c * 128 + this.b) * 256 + this.d; + } + + public NextTickListEntry a(long i) { + this.e = i; + return this; + } + + public int a(NextTickListEntry nextticklistentry) { + return this.e < nextticklistentry.e ? -1 : (this.e > nextticklistentry.e ? 1 : (this.g < nextticklistentry.g ? -1 : (this.g > nextticklistentry.g ? 1 : 0))); + } +} diff --git a/net/minecraft/server/NibbleArray.java b/net/minecraft/server/NibbleArray.java new file mode 100644 index 000000000..186e8961d --- /dev/null +++ b/net/minecraft/server/NibbleArray.java @@ -0,0 +1,38 @@ +package net.minecraft.server; + +public class NibbleArray { + + public final byte[] a; + + public NibbleArray(int i) { + this.a = new byte[i >> 1]; + } + + public NibbleArray(byte[] abyte) { + this.a = abyte; + } + + public int a(int i, int j, int k) { + int l = i << 11 | k << 7 | j; + int i1 = l >> 1; + int j1 = l & 1; + + return j1 == 0 ? this.a[i1] & 15 : this.a[i1] >> 4 & 15; + } + + public void a(int i, int j, int k, int l) { + int i1 = i << 11 | k << 7 | j; + int j1 = i1 >> 1; + int k1 = i1 & 1; + + if (k1 == 0) { + this.a[j1] = (byte) (this.a[j1] & 240 | l & 15); + } else { + this.a[j1] = (byte) (this.a[j1] & 15 | (l & 15) << 4); + } + } + + public boolean a() { + return this.a != null; + } +} diff --git a/net/minecraft/server/NoiseGenerator.java b/net/minecraft/server/NoiseGenerator.java new file mode 100644 index 000000000..07827edee --- /dev/null +++ b/net/minecraft/server/NoiseGenerator.java @@ -0,0 +1,6 @@ +package net.minecraft.server; + +public abstract class NoiseGenerator { + + public NoiseGenerator() {} +} diff --git a/net/minecraft/server/NoiseGeneratorOctaves.java b/net/minecraft/server/NoiseGeneratorOctaves.java new file mode 100644 index 000000000..b4f7c8db1 --- /dev/null +++ b/net/minecraft/server/NoiseGeneratorOctaves.java @@ -0,0 +1,49 @@ +package net.minecraft.server; + +import java.util.Random; + +public class NoiseGeneratorOctaves extends NoiseGenerator { + + private NoiseGeneratorPerlin[] a; + private int b; + + public NoiseGeneratorOctaves(Random random, int i) { + this.b = i; + this.a = new NoiseGeneratorPerlin[i]; + + for (int j = 0; j < i; ++j) { + this.a[j] = new NoiseGeneratorPerlin(random); + } + } + + public double a(double d0, double d1) { + double d2 = 0.0D; + double d3 = 1.0D; + + for (int i = 0; i < this.b; ++i) { + d2 += this.a[i].a(d0 * d3, d1 * d3) / d3; + d3 /= 2.0D; + } + + return d2; + } + + public double[] a(double[] adouble, double d0, double d1, double d2, int i, int j, int k, double d3, double d4, double d5) { + if (adouble == null) { + adouble = new double[i * j * k]; + } else { + for (int l = 0; l < adouble.length; ++l) { + adouble[l] = 0.0D; + } + } + + double d6 = 1.0D; + + for (int i1 = 0; i1 < this.b; ++i1) { + this.a[i1].a(adouble, d0, d1, d2, i, j, k, d3 * d6, d4 * d6, d5 * d6, d6); + d6 /= 2.0D; + } + + return adouble; + } +} diff --git a/net/minecraft/server/NoiseGeneratorPerlin.java b/net/minecraft/server/NoiseGeneratorPerlin.java new file mode 100644 index 000000000..53a15de56 --- /dev/null +++ b/net/minecraft/server/NoiseGeneratorPerlin.java @@ -0,0 +1,173 @@ +package net.minecraft.server; + +import java.util.Random; + +public class NoiseGeneratorPerlin extends NoiseGenerator { + + private int[] d; + public double a; + public double b; + public double c; + + public NoiseGeneratorPerlin() { + this(new Random()); + } + + public NoiseGeneratorPerlin(Random random) { + this.d = new int[512]; + this.a = random.nextDouble() * 256.0D; + this.b = random.nextDouble() * 256.0D; + this.c = random.nextDouble() * 256.0D; + + int i; + + for (i = 0; i < 256; this.d[i] = i++) { + ; + } + + for (i = 0; i < 256; ++i) { + int j = random.nextInt(256 - i) + i; + int k = this.d[i]; + + this.d[i] = this.d[j]; + this.d[j] = k; + this.d[i + 256] = this.d[i]; + } + } + + public double a(double d0, double d1, double d2) { + double d3 = d0 + this.a; + double d4 = d1 + this.b; + double d5 = d2 + this.c; + int i = (int) d3; + int j = (int) d4; + int k = (int) d5; + + if (d3 < (double) i) { + --i; + } + + if (d4 < (double) j) { + --j; + } + + if (d5 < (double) k) { + --k; + } + + int l = i & 255; + int i1 = j & 255; + int j1 = k & 255; + + d3 -= (double) i; + d4 -= (double) j; + d5 -= (double) k; + double d6 = d3 * d3 * d3 * (d3 * (d3 * 6.0D - 15.0D) + 10.0D); + double d7 = d4 * d4 * d4 * (d4 * (d4 * 6.0D - 15.0D) + 10.0D); + double d8 = d5 * d5 * d5 * (d5 * (d5 * 6.0D - 15.0D) + 10.0D); + int k1 = this.d[l] + i1; + int l1 = this.d[k1] + j1; + int i2 = this.d[k1 + 1] + j1; + int j2 = this.d[l + 1] + i1; + int k2 = this.d[j2] + j1; + int l2 = this.d[j2 + 1] + j1; + + return this.b(d8, this.b(d7, this.b(d6, this.a(this.d[l1], d3, d4, d5), this.a(this.d[k2], d3 - 1.0D, d4, d5)), this.b(d6, this.a(this.d[i2], d3, d4 - 1.0D, d5), this.a(this.d[l2], d3 - 1.0D, d4 - 1.0D, d5))), this.b(d7, this.b(d6, this.a(this.d[l1 + 1], d3, d4, d5 - 1.0D), this.a(this.d[k2 + 1], d3 - 1.0D, d4, d5 - 1.0D)), this.b(d6, this.a(this.d[i2 + 1], d3, d4 - 1.0D, d5 - 1.0D), this.a(this.d[l2 + 1], d3 - 1.0D, d4 - 1.0D, d5 - 1.0D)))); + } + + public double b(double d0, double d1, double d2) { + return d1 + d0 * (d2 - d1); + } + + public double a(int i, double d0, double d1, double d2) { + int j = i & 15; + double d3 = j < 8 ? d0 : d1; + double d4 = j < 4 ? d1 : (j != 12 && j != 14 ? d2 : d0); + + return ((j & 1) == 0 ? d3 : -d3) + ((j & 2) == 0 ? d4 : -d4); + } + + public double a(double d0, double d1) { + return this.a(d0, d1, 0.0D); + } + + public void a(double[] adouble, double d0, double d1, double d2, int i, int j, int k, double d3, double d4, double d5, double d6) { + int l = 0; + double d7 = 1.0D / d6; + int i1 = -1; + boolean flag = false; + boolean flag1 = false; + boolean flag2 = false; + boolean flag3 = false; + boolean flag4 = false; + boolean flag5 = false; + double d8 = 0.0D; + double d9 = 0.0D; + double d10 = 0.0D; + double d11 = 0.0D; + + for (int j1 = 0; j1 < i; ++j1) { + double d12 = (d0 + (double) j1) * d3 + this.a; + int k1 = (int) d12; + + if (d12 < (double) k1) { + --k1; + } + + int l1 = k1 & 255; + + d12 -= (double) k1; + double d13 = d12 * d12 * d12 * (d12 * (d12 * 6.0D - 15.0D) + 10.0D); + + for (int i2 = 0; i2 < k; ++i2) { + double d14 = (d2 + (double) i2) * d5 + this.c; + int j2 = (int) d14; + + if (d14 < (double) j2) { + --j2; + } + + int k2 = j2 & 255; + + d14 -= (double) j2; + double d15 = d14 * d14 * d14 * (d14 * (d14 * 6.0D - 15.0D) + 10.0D); + + for (int l2 = 0; l2 < j; ++l2) { + double d16 = (d1 + (double) l2) * d4 + this.b; + int i3 = (int) d16; + + if (d16 < (double) i3) { + --i3; + } + + int j3 = i3 & 255; + + d16 -= (double) i3; + double d17 = d16 * d16 * d16 * (d16 * (d16 * 6.0D - 15.0D) + 10.0D); + + if (l2 == 0 || j3 != i1) { + i1 = j3; + int k3 = this.d[l1] + j3; + int l3 = this.d[k3] + k2; + int i4 = this.d[k3 + 1] + k2; + int j4 = this.d[l1 + 1] + j3; + int k4 = this.d[j4] + k2; + int l4 = this.d[j4 + 1] + k2; + + d8 = this.b(d13, this.a(this.d[l3], d12, d16, d14), this.a(this.d[k4], d12 - 1.0D, d16, d14)); + d9 = this.b(d13, this.a(this.d[i4], d12, d16 - 1.0D, d14), this.a(this.d[l4], d12 - 1.0D, d16 - 1.0D, d14)); + d10 = this.b(d13, this.a(this.d[l3 + 1], d12, d16, d14 - 1.0D), this.a(this.d[k4 + 1], d12 - 1.0D, d16, d14 - 1.0D)); + d11 = this.b(d13, this.a(this.d[i4 + 1], d12, d16 - 1.0D, d14 - 1.0D), this.a(this.d[l4 + 1], d12 - 1.0D, d16 - 1.0D, d14 - 1.0D)); + } + + double d18 = this.b(d17, d8, d9); + double d19 = this.b(d17, d10, d11); + double d20 = this.b(d15, d18, d19); + int i5 = l++; + + adouble[i5] += d20 * d7; + } + } + } + } +} diff --git a/net/minecraft/server/Packet.java b/net/minecraft/server/Packet.java new file mode 100644 index 000000000..9a97a48b8 --- /dev/null +++ b/net/minecraft/server/Packet.java @@ -0,0 +1,109 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public abstract class Packet { + + private static Map a = new HashMap(); + private static Map b = new HashMap(); + public boolean j = false; + + public Packet() {} + + static void a(int i, Class oclass) { + if (a.containsKey(Integer.valueOf(i))) { + throw new IllegalArgumentException("Duplicate packet id:" + i); + } else if (b.containsKey(oclass)) { + throw new IllegalArgumentException("Duplicate packet class:" + oclass); + } else { + a.put(Integer.valueOf(i), oclass); + b.put(oclass, Integer.valueOf(i)); + } + } + + public static Packet a(int i) { + try { + Class oclass = (Class) a.get(Integer.valueOf(i)); + + return oclass == null ? null : (Packet) oclass.newInstance(); + } catch (Exception exception) { + exception.printStackTrace(); + System.out.println("Skipping packet with id " + i); + return null; + } + } + + public final int b() { + return ((Integer) b.get(this.getClass())).intValue(); + } + + public static Packet b(DataInputStream datainputstream) { + int i = datainputstream.read(); + + if (i == -1) { + return null; + } else { + Packet packet = a(i); + + if (packet == null) { + throw new IOException("Bad packet id " + i); + } else { + packet.a(datainputstream); + return packet; + } + } + } + + public static void a(Packet packet, DataOutputStream dataoutputstream) { + dataoutputstream.write(packet.b()); + packet.a(dataoutputstream); + } + + public abstract void a(DataInputStream datainputstream); + + public abstract void a(DataOutputStream dataoutputstream); + + public abstract void a(NetHandler nethandler); + + public abstract int a(); + + static { + a(0, Packet0KeepAlive.class); + a(1, Packet1Login.class); + a(2, Packet2Handshake.class); + a(3, Packet3Chat.class); + a(4, Packet4UpdateTime.class); + a(5, Packet5PlayerInventory.class); + a(6, Packet6SpawnPosition.class); + a(10, Packet10Flying.class); + a(11, Packet11PlayerPosition.class); + a(12, Packet12PlayerLook.class); + a(13, Packet13PlayerLookMove.class); + a(14, Packet14BlockDig.class); + a(15, Packet15Place.class); + a(16, Packet16BlockItemSwitch.class); + a(17, Packet17AddToInventory.class); + a(18, Packet18ArmAnimation.class); + a(20, Packet20NamedEntitySpawn.class); + a(21, Packet21PickupSpawn.class); + a(22, Packet22Collect.class); + a(23, Packet23VehicleSpawn.class); + a(24, Packet24MobSpawn.class); + a(29, Packet29DestroyEntity.class); + a(30, Packet30Entity.class); + a(31, Packet31RelEntityMove.class); + a(32, Packet32EntityLook.class); + a(33, Packet33RelEntityMoveLook.class); + a(34, Packet34EntityTeleport.class); + a(50, Packet50PreChunk.class); + a(51, Packet51MapChunk.class); + a(52, Packet52MultiBlockChange.class); + a(53, Packet53BlockChange.class); + a(59, Packet59ComplexEntity.class); + a(255, Packet255KickDisconnect.class); + } +} diff --git a/net/minecraft/server/Packet0KeepAlive.java b/net/minecraft/server/Packet0KeepAlive.java new file mode 100644 index 000000000..06ff6604a --- /dev/null +++ b/net/minecraft/server/Packet0KeepAlive.java @@ -0,0 +1,19 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet0KeepAlive extends Packet { + + public Packet0KeepAlive() {} + + public void a(NetHandler nethandler) {} + + public void a(DataInputStream datainputstream) {} + + public void a(DataOutputStream dataoutputstream) {} + + public int a() { + return 0; + } +} diff --git a/net/minecraft/server/Packet10Flying.java b/net/minecraft/server/Packet10Flying.java new file mode 100644 index 000000000..3e80831ad --- /dev/null +++ b/net/minecraft/server/Packet10Flying.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet10Flying extends Packet { + + public double a; + public double b; + public double c; + public double d; + public float e; + public float f; + public boolean g; + public boolean h; + public boolean i; + + public Packet10Flying() {} + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public void a(DataInputStream datainputstream) { + this.g = datainputstream.read() != 0; + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.write(this.g ? 1 : 0); + } + + public int a() { + return 1; + } +} diff --git a/net/minecraft/server/Packet11PlayerPosition.java b/net/minecraft/server/Packet11PlayerPosition.java new file mode 100644 index 000000000..bbf5bc2f9 --- /dev/null +++ b/net/minecraft/server/Packet11PlayerPosition.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet11PlayerPosition extends Packet10Flying { + + public Packet11PlayerPosition() { + this.h = true; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readDouble(); + this.b = datainputstream.readDouble(); + this.d = datainputstream.readDouble(); + this.c = datainputstream.readDouble(); + super.a(datainputstream); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeDouble(this.a); + dataoutputstream.writeDouble(this.b); + dataoutputstream.writeDouble(this.d); + dataoutputstream.writeDouble(this.c); + super.a(dataoutputstream); + } + + public int a() { + return 33; + } +} diff --git a/net/minecraft/server/Packet12PlayerLook.java b/net/minecraft/server/Packet12PlayerLook.java new file mode 100644 index 000000000..0af8acbd3 --- /dev/null +++ b/net/minecraft/server/Packet12PlayerLook.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet12PlayerLook extends Packet10Flying { + + public Packet12PlayerLook() { + this.i = true; + } + + public void a(DataInputStream datainputstream) { + this.e = datainputstream.readFloat(); + this.f = datainputstream.readFloat(); + super.a(datainputstream); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeFloat(this.e); + dataoutputstream.writeFloat(this.f); + super.a(dataoutputstream); + } + + public int a() { + return 9; + } +} diff --git a/net/minecraft/server/Packet13PlayerLookMove.java b/net/minecraft/server/Packet13PlayerLookMove.java new file mode 100644 index 000000000..d3cb10e71 --- /dev/null +++ b/net/minecraft/server/Packet13PlayerLookMove.java @@ -0,0 +1,48 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet13PlayerLookMove extends Packet10Flying { + + public Packet13PlayerLookMove() { + this.i = true; + this.h = true; + } + + public Packet13PlayerLookMove(double d0, double d1, double d2, double d3, float f, float f1, boolean flag) { + this.a = d0; + this.b = d1; + this.d = d2; + this.c = d3; + this.e = f; + this.f = f1; + this.g = flag; + this.i = true; + this.h = true; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readDouble(); + this.b = datainputstream.readDouble(); + this.d = datainputstream.readDouble(); + this.c = datainputstream.readDouble(); + this.e = datainputstream.readFloat(); + this.f = datainputstream.readFloat(); + super.a(datainputstream); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeDouble(this.a); + dataoutputstream.writeDouble(this.b); + dataoutputstream.writeDouble(this.d); + dataoutputstream.writeDouble(this.c); + dataoutputstream.writeFloat(this.e); + dataoutputstream.writeFloat(this.f); + super.a(dataoutputstream); + } + + public int a() { + return 41; + } +} diff --git a/net/minecraft/server/Packet14BlockDig.java b/net/minecraft/server/Packet14BlockDig.java new file mode 100644 index 000000000..2568f298d --- /dev/null +++ b/net/minecraft/server/Packet14BlockDig.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet14BlockDig extends Packet { + + public int a; + public int b; + public int c; + public int d; + public int e; + + public Packet14BlockDig() {} + + public void a(DataInputStream datainputstream) { + this.e = datainputstream.read(); + this.a = datainputstream.readInt(); + this.b = datainputstream.read(); + this.c = datainputstream.readInt(); + this.d = datainputstream.read(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.write(this.e); + dataoutputstream.writeInt(this.a); + dataoutputstream.write(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.write(this.d); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 11; + } +} diff --git a/net/minecraft/server/Packet15Place.java b/net/minecraft/server/Packet15Place.java new file mode 100644 index 000000000..934b429b4 --- /dev/null +++ b/net/minecraft/server/Packet15Place.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet15Place extends Packet { + + public int a; + public int b; + public int c; + public int d; + public int e; + + public Packet15Place() {} + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readShort(); + this.b = datainputstream.readInt(); + this.c = datainputstream.read(); + this.d = datainputstream.readInt(); + this.e = datainputstream.read(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeShort(this.a); + dataoutputstream.writeInt(this.b); + dataoutputstream.write(this.c); + dataoutputstream.writeInt(this.d); + dataoutputstream.write(this.e); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 12; + } +} diff --git a/net/minecraft/server/Packet16BlockItemSwitch.java b/net/minecraft/server/Packet16BlockItemSwitch.java new file mode 100644 index 000000000..28442745f --- /dev/null +++ b/net/minecraft/server/Packet16BlockItemSwitch.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet16BlockItemSwitch extends Packet { + + public int a; + public int b; + + public Packet16BlockItemSwitch() {} + + public Packet16BlockItemSwitch(int i, int j) { + this.a = i; + this.b = j; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readShort(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeShort(this.b); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 6; + } +} diff --git a/net/minecraft/server/Packet17AddToInventory.java b/net/minecraft/server/Packet17AddToInventory.java new file mode 100644 index 000000000..637dbadcb --- /dev/null +++ b/net/minecraft/server/Packet17AddToInventory.java @@ -0,0 +1,42 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet17AddToInventory extends Packet { + + public int a; + public int b; + public int c; + + public Packet17AddToInventory() {} + + public Packet17AddToInventory(ItemStack itemstack, int i) { + this.a = itemstack.c; + this.b = i; + this.c = itemstack.d; + if (i == 0) { + boolean flag = true; + } + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readShort(); + this.b = datainputstream.readByte(); + this.c = datainputstream.readShort(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeShort(this.a); + dataoutputstream.writeByte(this.b); + dataoutputstream.writeShort(this.c); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 5; + } +} diff --git a/net/minecraft/server/Packet18ArmAnimation.java b/net/minecraft/server/Packet18ArmAnimation.java new file mode 100644 index 000000000..5c01d8e05 --- /dev/null +++ b/net/minecraft/server/Packet18ArmAnimation.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet18ArmAnimation extends Packet { + + public int a; + public int b; + + public Packet18ArmAnimation() {} + + public Packet18ArmAnimation(Entity entity, int i) { + this.a = entity.c; + this.b = i; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readByte(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeByte(this.b); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 5; + } +} diff --git a/net/minecraft/server/Packet1Login.java b/net/minecraft/server/Packet1Login.java new file mode 100644 index 000000000..633a7a2ca --- /dev/null +++ b/net/minecraft/server/Packet1Login.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet1Login extends Packet { + + public int a; + public String b; + public String c; + + public Packet1Login() {} + + public Packet1Login(String s, String s1, int i) { + this.b = s; + this.c = s1; + this.a = i; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readUTF(); + this.c = datainputstream.readUTF(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeUTF(this.b); + dataoutputstream.writeUTF(this.c); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 4 + this.b.length() + this.c.length() + 4; + } +} diff --git a/net/minecraft/server/Packet20NamedEntitySpawn.java b/net/minecraft/server/Packet20NamedEntitySpawn.java new file mode 100644 index 000000000..a52d579cc --- /dev/null +++ b/net/minecraft/server/Packet20NamedEntitySpawn.java @@ -0,0 +1,61 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet20NamedEntitySpawn extends Packet { + + public int a; + public String b; + public int c; + public int d; + public int e; + public byte f; + public byte g; + public int h; + + public Packet20NamedEntitySpawn() {} + + public Packet20NamedEntitySpawn(EntityHuman entityhuman) { + this.a = entityhuman.c; + this.b = entityhuman.aq; + this.c = MathHelper.b(entityhuman.l * 32.0D); + this.d = MathHelper.b(entityhuman.m * 32.0D); + this.e = MathHelper.b(entityhuman.n * 32.0D); + this.f = (byte) ((int) (entityhuman.r * 256.0F / 360.0F)); + this.g = (byte) ((int) (entityhuman.s * 256.0F / 360.0F)); + ItemStack itemstack = entityhuman.aj.b(); + + this.h = itemstack == null ? 0 : itemstack.c; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readUTF(); + this.c = datainputstream.readInt(); + this.d = datainputstream.readInt(); + this.e = datainputstream.readInt(); + this.f = datainputstream.readByte(); + this.g = datainputstream.readByte(); + this.h = datainputstream.readShort(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeUTF(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.writeInt(this.d); + dataoutputstream.writeInt(this.e); + dataoutputstream.writeByte(this.f); + dataoutputstream.writeByte(this.g); + dataoutputstream.writeShort(this.h); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 28; + } +} diff --git a/net/minecraft/server/Packet21PickupSpawn.java b/net/minecraft/server/Packet21PickupSpawn.java new file mode 100644 index 000000000..8201b2eee --- /dev/null +++ b/net/minecraft/server/Packet21PickupSpawn.java @@ -0,0 +1,63 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet21PickupSpawn extends Packet { + + public int a; + public int b; + public int c; + public int d; + public byte e; + public byte f; + public byte g; + public int h; + public int i; + + public Packet21PickupSpawn() {} + + public Packet21PickupSpawn(EntityItem entityitem) { + this.a = entityitem.c; + this.h = entityitem.a.c; + this.i = entityitem.a.a; + this.b = MathHelper.b(entityitem.l * 32.0D); + this.c = MathHelper.b(entityitem.m * 32.0D); + this.d = MathHelper.b(entityitem.n * 32.0D); + this.e = (byte) ((int) (entityitem.o * 128.0D)); + this.f = (byte) ((int) (entityitem.p * 128.0D)); + this.g = (byte) ((int) (entityitem.q * 128.0D)); + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.h = datainputstream.readShort(); + this.i = datainputstream.readByte(); + this.b = datainputstream.readInt(); + this.c = datainputstream.readInt(); + this.d = datainputstream.readInt(); + this.e = datainputstream.readByte(); + this.f = datainputstream.readByte(); + this.g = datainputstream.readByte(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeShort(this.h); + dataoutputstream.writeByte(this.i); + dataoutputstream.writeInt(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.writeInt(this.d); + dataoutputstream.writeByte(this.e); + dataoutputstream.writeByte(this.f); + dataoutputstream.writeByte(this.g); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 22; + } +} diff --git a/net/minecraft/server/Packet22Collect.java b/net/minecraft/server/Packet22Collect.java new file mode 100644 index 000000000..03692cb1a --- /dev/null +++ b/net/minecraft/server/Packet22Collect.java @@ -0,0 +1,35 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet22Collect extends Packet { + + public int a; + public int b; + + public Packet22Collect() {} + + public Packet22Collect(int i, int j) { + this.a = i; + this.b = j; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readInt(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeInt(this.b); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 8; + } +} diff --git a/net/minecraft/server/Packet23VehicleSpawn.java b/net/minecraft/server/Packet23VehicleSpawn.java new file mode 100644 index 000000000..357f9efb5 --- /dev/null +++ b/net/minecraft/server/Packet23VehicleSpawn.java @@ -0,0 +1,47 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet23VehicleSpawn extends Packet { + + public int a; + public int b; + public int c; + public int d; + public int e; + + public Packet23VehicleSpawn() {} + + public Packet23VehicleSpawn(Entity entity, int i) { + this.a = entity.c; + this.b = MathHelper.b(entity.l * 32.0D); + this.c = MathHelper.b(entity.m * 32.0D); + this.d = MathHelper.b(entity.n * 32.0D); + this.e = i; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.e = datainputstream.readByte(); + this.b = datainputstream.readInt(); + this.c = datainputstream.readInt(); + this.d = datainputstream.readInt(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeByte(this.e); + dataoutputstream.writeInt(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.writeInt(this.d); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 17; + } +} diff --git a/net/minecraft/server/Packet24MobSpawn.java b/net/minecraft/server/Packet24MobSpawn.java new file mode 100644 index 000000000..1e74caba4 --- /dev/null +++ b/net/minecraft/server/Packet24MobSpawn.java @@ -0,0 +1,55 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet24MobSpawn extends Packet { + + public int a; + public byte b; + public int c; + public int d; + public int e; + public byte f; + public byte g; + + public Packet24MobSpawn() {} + + public Packet24MobSpawn(EntityLiving entityliving) { + this.a = entityliving.c; + this.b = (byte) EntityTypes.a(entityliving); + this.c = MathHelper.b(entityliving.l * 32.0D); + this.d = MathHelper.b(entityliving.m * 32.0D); + this.e = MathHelper.b(entityliving.n * 32.0D); + this.f = (byte) ((int) (entityliving.r * 256.0F / 360.0F)); + this.g = (byte) ((int) (entityliving.s * 256.0F / 360.0F)); + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readByte(); + this.c = datainputstream.readInt(); + this.d = datainputstream.readInt(); + this.e = datainputstream.readInt(); + this.f = datainputstream.readByte(); + this.g = datainputstream.readByte(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeByte(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.writeInt(this.d); + dataoutputstream.writeInt(this.e); + dataoutputstream.writeByte(this.f); + dataoutputstream.writeByte(this.g); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 19; + } +} diff --git a/net/minecraft/server/Packet255KickDisconnect.java b/net/minecraft/server/Packet255KickDisconnect.java new file mode 100644 index 000000000..3033a415f --- /dev/null +++ b/net/minecraft/server/Packet255KickDisconnect.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet255KickDisconnect extends Packet { + + public String a; + + public Packet255KickDisconnect() {} + + public Packet255KickDisconnect(String s) { + this.a = s; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readUTF(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeUTF(this.a); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return this.a.length(); + } +} diff --git a/net/minecraft/server/Packet29DestroyEntity.java b/net/minecraft/server/Packet29DestroyEntity.java new file mode 100644 index 000000000..9e3f2b2ee --- /dev/null +++ b/net/minecraft/server/Packet29DestroyEntity.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet29DestroyEntity extends Packet { + + public int a; + + public Packet29DestroyEntity() {} + + public Packet29DestroyEntity(int i) { + this.a = i; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 4; + } +} diff --git a/net/minecraft/server/Packet2Handshake.java b/net/minecraft/server/Packet2Handshake.java new file mode 100644 index 000000000..4cd806e00 --- /dev/null +++ b/net/minecraft/server/Packet2Handshake.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet2Handshake extends Packet { + + public String a; + + public Packet2Handshake() {} + + public Packet2Handshake(String s) { + this.a = s; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readUTF(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeUTF(this.a); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 4 + this.a.length() + 4; + } +} diff --git a/net/minecraft/server/Packet30Entity.java b/net/minecraft/server/Packet30Entity.java new file mode 100644 index 000000000..ec173af38 --- /dev/null +++ b/net/minecraft/server/Packet30Entity.java @@ -0,0 +1,37 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet30Entity extends Packet { + + public int a; + public byte b; + public byte c; + public byte d; + public byte e; + public byte f; + public boolean g = false; + + public Packet30Entity() {} + + public Packet30Entity(int i) { + this.a = i; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 4; + } +} diff --git a/net/minecraft/server/Packet31RelEntityMove.java b/net/minecraft/server/Packet31RelEntityMove.java new file mode 100644 index 000000000..a8f1b8a3a --- /dev/null +++ b/net/minecraft/server/Packet31RelEntityMove.java @@ -0,0 +1,34 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet31RelEntityMove extends Packet30Entity { + + public Packet31RelEntityMove() {} + + public Packet31RelEntityMove(int i, byte b0, byte b1, byte b2) { + super(i); + this.b = b0; + this.c = b1; + this.d = b2; + } + + public void a(DataInputStream datainputstream) { + super.a(datainputstream); + this.b = datainputstream.readByte(); + this.c = datainputstream.readByte(); + this.d = datainputstream.readByte(); + } + + public void a(DataOutputStream dataoutputstream) { + super.a(dataoutputstream); + dataoutputstream.writeByte(this.b); + dataoutputstream.writeByte(this.c); + dataoutputstream.writeByte(this.d); + } + + public int a() { + return 7; + } +} diff --git a/net/minecraft/server/Packet32EntityLook.java b/net/minecraft/server/Packet32EntityLook.java new file mode 100644 index 000000000..a0cf35da1 --- /dev/null +++ b/net/minecraft/server/Packet32EntityLook.java @@ -0,0 +1,34 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet32EntityLook extends Packet30Entity { + + public Packet32EntityLook() { + this.g = true; + } + + public Packet32EntityLook(int i, byte b0, byte b1) { + super(i); + this.e = b0; + this.f = b1; + this.g = true; + } + + public void a(DataInputStream datainputstream) { + super.a(datainputstream); + this.e = datainputstream.readByte(); + this.f = datainputstream.readByte(); + } + + public void a(DataOutputStream dataoutputstream) { + super.a(dataoutputstream); + dataoutputstream.writeByte(this.e); + dataoutputstream.writeByte(this.f); + } + + public int a() { + return 6; + } +} diff --git a/net/minecraft/server/Packet33RelEntityMoveLook.java b/net/minecraft/server/Packet33RelEntityMoveLook.java new file mode 100644 index 000000000..b35affadb --- /dev/null +++ b/net/minecraft/server/Packet33RelEntityMoveLook.java @@ -0,0 +1,43 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet33RelEntityMoveLook extends Packet30Entity { + + public Packet33RelEntityMoveLook() { + this.g = true; + } + + public Packet33RelEntityMoveLook(int i, byte b0, byte b1, byte b2, byte b3, byte b4) { + super(i); + this.b = b0; + this.c = b1; + this.d = b2; + this.e = b3; + this.f = b4; + this.g = true; + } + + public void a(DataInputStream datainputstream) { + super.a(datainputstream); + this.b = datainputstream.readByte(); + this.c = datainputstream.readByte(); + this.d = datainputstream.readByte(); + this.e = datainputstream.readByte(); + this.f = datainputstream.readByte(); + } + + public void a(DataOutputStream dataoutputstream) { + super.a(dataoutputstream); + dataoutputstream.writeByte(this.b); + dataoutputstream.writeByte(this.c); + dataoutputstream.writeByte(this.d); + dataoutputstream.writeByte(this.e); + dataoutputstream.writeByte(this.f); + } + + public int a() { + return 9; + } +} diff --git a/net/minecraft/server/Packet34EntityTeleport.java b/net/minecraft/server/Packet34EntityTeleport.java new file mode 100644 index 000000000..da1c2b7e5 --- /dev/null +++ b/net/minecraft/server/Packet34EntityTeleport.java @@ -0,0 +1,60 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet34EntityTeleport extends Packet { + + public int a; + public int b; + public int c; + public int d; + public byte e; + public byte f; + + public Packet34EntityTeleport() {} + + public Packet34EntityTeleport(Entity entity) { + this.a = entity.c; + this.b = MathHelper.b(entity.l * 32.0D); + this.c = MathHelper.b(entity.m * 32.0D); + this.d = MathHelper.b(entity.n * 32.0D); + this.e = (byte) ((int) (entity.r * 256.0F / 360.0F)); + this.f = (byte) ((int) (entity.s * 256.0F / 360.0F)); + } + + public Packet34EntityTeleport(int i, int j, int k, int l, byte b0, byte b1) { + this.a = i; + this.b = j; + this.c = k; + this.d = l; + this.e = b0; + this.f = b1; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readInt(); + this.c = datainputstream.readInt(); + this.d = datainputstream.readInt(); + this.e = (byte) datainputstream.read(); + this.f = (byte) datainputstream.read(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeInt(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.writeInt(this.d); + dataoutputstream.write(this.e); + dataoutputstream.write(this.f); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 34; + } +} diff --git a/net/minecraft/server/Packet3Chat.java b/net/minecraft/server/Packet3Chat.java new file mode 100644 index 000000000..7f2ed1fd5 --- /dev/null +++ b/net/minecraft/server/Packet3Chat.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet3Chat extends Packet { + + public String a; + + public Packet3Chat() {} + + public Packet3Chat(String s) { + this.a = s; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readUTF(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeUTF(this.a); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return this.a.length(); + } +} diff --git a/net/minecraft/server/Packet4UpdateTime.java b/net/minecraft/server/Packet4UpdateTime.java new file mode 100644 index 000000000..693cb343c --- /dev/null +++ b/net/minecraft/server/Packet4UpdateTime.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet4UpdateTime extends Packet { + + public long a; + + public Packet4UpdateTime() {} + + public Packet4UpdateTime(long i) { + this.a = i; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readLong(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeLong(this.a); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 8; + } +} diff --git a/net/minecraft/server/Packet50PreChunk.java b/net/minecraft/server/Packet50PreChunk.java new file mode 100644 index 000000000..a8e7b9619 --- /dev/null +++ b/net/minecraft/server/Packet50PreChunk.java @@ -0,0 +1,40 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet50PreChunk extends Packet { + + public int a; + public int b; + public boolean c; + + public Packet50PreChunk() {} + + public Packet50PreChunk(int i, int j, boolean flag) { + this.j = true; + this.a = i; + this.b = j; + this.c = flag; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readInt(); + this.c = datainputstream.read() != 0; + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeInt(this.b); + dataoutputstream.write(this.c ? 1 : 0); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 9; + } +} diff --git a/net/minecraft/server/Packet51MapChunk.java b/net/minecraft/server/Packet51MapChunk.java new file mode 100644 index 000000000..43cc01d90 --- /dev/null +++ b/net/minecraft/server/Packet51MapChunk.java @@ -0,0 +1,89 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.zip.DataFormatException; +import java.util.zip.Deflater; +import java.util.zip.Inflater; + +public class Packet51MapChunk extends Packet { + + public int a; + public int b; + public int c; + public int d; + public int e; + public int f; + public byte[] g; + private int h; + + public Packet51MapChunk() { + this.j = true; + } + + public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, World world) { + this.j = true; + this.a = i; + this.b = j; + this.c = k; + this.d = l; + this.e = i1; + this.f = j1; + byte[] abyte = world.c(i, j, k, l, i1, j1); + Deflater deflater = new Deflater(1); + + try { + deflater.setInput(abyte); + deflater.finish(); + this.g = new byte[l * i1 * j1 * 5 / 2]; + this.h = deflater.deflate(this.g); + } finally { + deflater.end(); + } + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readShort(); + this.c = datainputstream.readInt(); + this.d = datainputstream.read() + 1; + this.e = datainputstream.read() + 1; + this.f = datainputstream.read() + 1; + int i = datainputstream.readInt(); + byte[] abyte = new byte[i]; + + datainputstream.readFully(abyte); + this.g = new byte[this.d * this.e * this.f * 5 / 2]; + Inflater inflater = new Inflater(); + + inflater.setInput(abyte); + + try { + inflater.inflate(this.g); + } catch (DataFormatException dataformatexception) { + throw new IOException("Bad compressed data format"); + } finally { + inflater.end(); + } + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeShort(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.write(this.d - 1); + dataoutputstream.write(this.e - 1); + dataoutputstream.write(this.f - 1); + dataoutputstream.writeInt(this.h); + dataoutputstream.write(this.g, 0, this.h); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 17 + this.h; + } +} diff --git a/net/minecraft/server/Packet52MultiBlockChange.java b/net/minecraft/server/Packet52MultiBlockChange.java new file mode 100644 index 000000000..af5b1e0f2 --- /dev/null +++ b/net/minecraft/server/Packet52MultiBlockChange.java @@ -0,0 +1,76 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet52MultiBlockChange extends Packet { + + public int a; + public int b; + public short[] c; + public byte[] d; + public byte[] e; + public int f; + + public Packet52MultiBlockChange() { + this.j = true; + } + + public Packet52MultiBlockChange(int i, int j, short[] ashort, int k, World world) { + this.j = true; + this.a = i; + this.b = j; + this.f = k; + this.c = new short[k]; + this.d = new byte[k]; + this.e = new byte[k]; + Chunk chunk = world.b(i, j); + + for (int l = 0; l < k; ++l) { + int i1 = ashort[l] >> 12 & 15; + int j1 = ashort[l] >> 8 & 15; + int k1 = ashort[l] & 255; + + this.c[l] = ashort[l]; + this.d[l] = (byte) chunk.a(i1, k1, j1); + this.e[l] = (byte) chunk.b(i1, k1, j1); + } + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readInt(); + this.f = datainputstream.readShort() & '\uffff'; + this.c = new short[this.f]; + this.d = new byte[this.f]; + this.e = new byte[this.f]; + + for (int i = 0; i < this.f; ++i) { + this.c[i] = datainputstream.readShort(); + } + + datainputstream.readFully(this.d); + datainputstream.readFully(this.e); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeInt(this.b); + dataoutputstream.writeShort((short) this.f); + + for (int i = 0; i < this.f; ++i) { + dataoutputstream.writeShort(this.c[i]); + } + + dataoutputstream.write(this.d); + dataoutputstream.write(this.e); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 10 + this.f * 4; + } +} diff --git a/net/minecraft/server/Packet53BlockChange.java b/net/minecraft/server/Packet53BlockChange.java new file mode 100644 index 000000000..3d68ac176 --- /dev/null +++ b/net/minecraft/server/Packet53BlockChange.java @@ -0,0 +1,50 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet53BlockChange extends Packet { + + public int a; + public int b; + public int c; + public int d; + public int e; + + public Packet53BlockChange() { + this.j = true; + } + + public Packet53BlockChange(int i, int j, int k, World world) { + this.j = true; + this.a = i; + this.b = j; + this.c = k; + this.d = world.a(i, j, k); + this.e = world.b(i, j, k); + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.read(); + this.c = datainputstream.readInt(); + this.d = datainputstream.read(); + this.e = datainputstream.read(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.write(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.write(this.d); + dataoutputstream.write(this.e); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 11; + } +} diff --git a/net/minecraft/server/Packet59ComplexEntity.java b/net/minecraft/server/Packet59ComplexEntity.java new file mode 100644 index 000000000..4f9d0f9c2 --- /dev/null +++ b/net/minecraft/server/Packet59ComplexEntity.java @@ -0,0 +1,60 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class Packet59ComplexEntity extends Packet { + + public int a; + public int b; + public int c; + public byte[] d; + public NBTTagCompound e; + + public Packet59ComplexEntity() { + this.j = true; + } + + public Packet59ComplexEntity(int i, int j, int k, TileEntity tileentity) { + this.j = true; + this.a = i; + this.b = j; + this.c = k; + this.e = new NBTTagCompound(); + tileentity.b(this.e); + + try { + this.d = CompressedStreamTools.a(this.e); + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readShort(); + this.c = datainputstream.readInt(); + int i = datainputstream.readShort() & '\uffff'; + + this.d = new byte[i]; + datainputstream.readFully(this.d); + this.e = CompressedStreamTools.a(this.d); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeShort(this.b); + dataoutputstream.writeInt(this.c); + dataoutputstream.writeShort((short) this.d.length); + dataoutputstream.write(this.d); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return this.d.length + 2 + 10; + } +} diff --git a/net/minecraft/server/Packet5PlayerInventory.java b/net/minecraft/server/Packet5PlayerInventory.java new file mode 100644 index 000000000..70a8a79fb --- /dev/null +++ b/net/minecraft/server/Packet5PlayerInventory.java @@ -0,0 +1,62 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet5PlayerInventory extends Packet { + + public int a; + public ItemStack[] b; + + public Packet5PlayerInventory() {} + + public Packet5PlayerInventory(int i, ItemStack[] aitemstack) { + this.a = i; + this.b = new ItemStack[aitemstack.length]; + + for (int j = 0; j < this.b.length; ++j) { + this.b[j] = aitemstack[j] == null ? null : aitemstack[j].d(); + } + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + short short1 = datainputstream.readShort(); + + this.b = new ItemStack[short1]; + + for (int i = 0; i < short1; ++i) { + short short2 = datainputstream.readShort(); + + if (short2 >= 0) { + byte b0 = datainputstream.readByte(); + short short3 = datainputstream.readShort(); + + this.b[i] = new ItemStack(short2, b0, short3); + } + } + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeShort(this.b.length); + + for (int i = 0; i < this.b.length; ++i) { + if (this.b[i] == null) { + dataoutputstream.writeShort(-1); + } else { + dataoutputstream.writeShort((short) this.b[i].c); + dataoutputstream.writeByte((byte) this.b[i].a); + dataoutputstream.writeShort((short) this.b[i].d); + } + } + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 6 + this.b.length * 5; + } +} diff --git a/net/minecraft/server/Packet6SpawnPosition.java b/net/minecraft/server/Packet6SpawnPosition.java new file mode 100644 index 000000000..0f759603b --- /dev/null +++ b/net/minecraft/server/Packet6SpawnPosition.java @@ -0,0 +1,39 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class Packet6SpawnPosition extends Packet { + + public int a; + public int b; + public int c; + + public Packet6SpawnPosition() {} + + public Packet6SpawnPosition(int i, int j, int k) { + this.a = i; + this.b = j; + this.c = k; + } + + public void a(DataInputStream datainputstream) { + this.a = datainputstream.readInt(); + this.b = datainputstream.readInt(); + this.c = datainputstream.readInt(); + } + + public void a(DataOutputStream dataoutputstream) { + dataoutputstream.writeInt(this.a); + dataoutputstream.writeInt(this.b); + dataoutputstream.writeInt(this.c); + } + + public void a(NetHandler nethandler) { + nethandler.a(this); + } + + public int a() { + return 12; + } +} diff --git a/net/minecraft/server/Path.java b/net/minecraft/server/Path.java new file mode 100644 index 000000000..496fe6729 --- /dev/null +++ b/net/minecraft/server/Path.java @@ -0,0 +1,128 @@ +package net.minecraft.server; + +public class Path { + + private PathPoint[] a = new PathPoint[1024]; + private int b = 0; + + public Path() {} + + public PathPoint a(PathPoint pathpoint) { + if (pathpoint.e >= 0) { + throw new IllegalStateException("OW KNOWS!"); + } else { + if (this.b == this.a.length) { + PathPoint[] apathpoint = new PathPoint[this.b << 1]; + + System.arraycopy(this.a, 0, apathpoint, 0, this.b); + this.a = apathpoint; + } + + this.a[this.b] = pathpoint; + pathpoint.e = this.b; + this.a(this.b++); + return pathpoint; + } + } + + public void a() { + this.b = 0; + } + + public PathPoint b() { + PathPoint pathpoint = this.a[0]; + + this.a[0] = this.a[--this.b]; + this.a[this.b] = null; + if (this.b > 0) { + this.b(0); + } + + pathpoint.e = -1; + return pathpoint; + } + + public void a(PathPoint pathpoint, float f) { + float f1 = pathpoint.h; + + pathpoint.h = f; + if (f < f1) { + this.a(pathpoint.e); + } else { + this.b(pathpoint.e); + } + } + + private void a(int i) { + PathPoint pathpoint = this.a[i]; + + int j; + + for (float f = pathpoint.h; i > 0; i = j) { + j = i - 1 >> 1; + PathPoint pathpoint1 = this.a[j]; + + if (f >= pathpoint1.h) { + break; + } + + this.a[i] = pathpoint1; + pathpoint1.e = i; + } + + this.a[i] = pathpoint; + pathpoint.e = i; + } + + private void b(int i) { + PathPoint pathpoint = this.a[i]; + float f = pathpoint.h; + + while (true) { + int j = 1 + (i << 1); + int k = j + 1; + + if (j >= this.b) { + break; + } + + PathPoint pathpoint1 = this.a[j]; + float f1 = pathpoint1.h; + PathPoint pathpoint2; + float f2; + + if (k >= this.b) { + pathpoint2 = null; + f2 = Float.POSITIVE_INFINITY; + } else { + pathpoint2 = this.a[k]; + f2 = pathpoint2.h; + } + + if (f1 < f2) { + if (f1 >= f) { + break; + } + + this.a[i] = pathpoint1; + pathpoint1.e = i; + i = j; + } else { + if (f2 >= f) { + break; + } + + this.a[i] = pathpoint2; + pathpoint2.e = i; + i = k; + } + } + + this.a[i] = pathpoint; + pathpoint.e = i; + } + + public boolean c() { + return this.b == 0; + } +} diff --git a/net/minecraft/server/PathEntity.java b/net/minecraft/server/PathEntity.java new file mode 100644 index 000000000..958b4d253 --- /dev/null +++ b/net/minecraft/server/PathEntity.java @@ -0,0 +1,29 @@ +package net.minecraft.server; + +public class PathEntity { + + private final PathPoint[] b; + public final int a; + private int c; + + public PathEntity(PathPoint[] apathpoint) { + this.b = apathpoint; + this.a = apathpoint.length; + } + + public void a() { + ++this.c; + } + + public boolean b() { + return this.c >= this.b.length; + } + + public Vec3D a(Entity entity) { + double d0 = (double) this.b[this.c].a + (double) ((int) (entity.D + 1.0F)) * 0.5D; + double d1 = (double) this.b[this.c].b; + double d2 = (double) this.b[this.c].c + (double) ((int) (entity.D + 1.0F)) * 0.5D; + + return Vec3D.b(d0, d1, d2); + } +} diff --git a/net/minecraft/server/PathPoint.java b/net/minecraft/server/PathPoint.java new file mode 100644 index 000000000..e24114df5 --- /dev/null +++ b/net/minecraft/server/PathPoint.java @@ -0,0 +1,46 @@ +package net.minecraft.server; + +public class PathPoint { + + public final int a; + public final int b; + public final int c; + public final int d; + int e = -1; + float f; + float g; + float h; + PathPoint i; + public boolean j = false; + + public PathPoint(int i, int j, int k) { + this.a = i; + this.b = j; + this.c = k; + this.d = i | j << 10 | k << 20; + } + + public float a(PathPoint pathpoint) { + float f = (float) (pathpoint.a - this.a); + float f1 = (float) (pathpoint.b - this.b); + float f2 = (float) (pathpoint.c - this.c); + + return MathHelper.c(f * f + f1 * f1 + f2 * f2); + } + + public boolean equals(Object object) { + return ((PathPoint) object).d == this.d; + } + + public int hashCode() { + return this.d; + } + + public boolean a() { + return this.e >= 0; + } + + public String toString() { + return this.a + ", " + this.b + ", " + this.c; + } +} diff --git a/net/minecraft/server/Pathfinder.java b/net/minecraft/server/Pathfinder.java new file mode 100644 index 000000000..7ca4a7d64 --- /dev/null +++ b/net/minecraft/server/Pathfinder.java @@ -0,0 +1,201 @@ +package net.minecraft.server; + +public class Pathfinder { + + private IBlockAccess a; + private Path b = new Path(); + private EntityList c = new EntityList(); + private PathPoint[] d = new PathPoint[32]; + + public Pathfinder(IBlockAccess iblockaccess) { + this.a = iblockaccess; + } + + public PathEntity a(Entity entity, Entity entity1, float f) { + return this.a(entity, entity1.l, entity1.v.b, entity1.n, f); + } + + public PathEntity a(Entity entity, int i, int j, int k, float f) { + return this.a(entity, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), f); + } + + private PathEntity a(Entity entity, double d0, double d1, double d2, float f) { + this.b.a(); + this.c.a(); + PathPoint pathpoint = this.a(MathHelper.b(entity.v.a), MathHelper.b(entity.v.b), MathHelper.b(entity.v.c)); + PathPoint pathpoint1 = this.a(MathHelper.b(d0 - (double) (entity.D / 2.0F)), MathHelper.b(d1), MathHelper.b(d2 - (double) (entity.D / 2.0F))); + PathPoint pathpoint2 = new PathPoint(MathHelper.d(entity.D + 1.0F), MathHelper.d(entity.E + 1.0F), MathHelper.d(entity.D + 1.0F)); + PathEntity pathentity = this.a(entity, pathpoint, pathpoint1, pathpoint2, f); + + return pathentity; + } + + private PathEntity a(Entity entity, PathPoint pathpoint, PathPoint pathpoint1, PathPoint pathpoint2, float f) { + pathpoint.f = 0.0F; + pathpoint.g = pathpoint.a(pathpoint1); + pathpoint.h = pathpoint.g; + this.b.a(); + this.b.a(pathpoint); + PathPoint pathpoint3 = pathpoint; + + while (!this.b.c()) { + PathPoint pathpoint4 = this.b.b(); + + if (pathpoint4.d == pathpoint1.d) { + return this.a(pathpoint, pathpoint1); + } + + if (pathpoint4.a(pathpoint1) < pathpoint3.a(pathpoint1)) { + pathpoint3 = pathpoint4; + } + + pathpoint4.j = true; + int i = this.b(entity, pathpoint4, pathpoint2, pathpoint1, f); + + for (int j = 0; j < i; ++j) { + PathPoint pathpoint5 = this.d[j]; + float f1 = pathpoint4.f + pathpoint4.a(pathpoint5); + + if (!pathpoint5.a() || f1 < pathpoint5.f) { + pathpoint5.i = pathpoint4; + pathpoint5.f = f1; + pathpoint5.g = pathpoint5.a(pathpoint1); + if (pathpoint5.a()) { + this.b.a(pathpoint5, pathpoint5.f + pathpoint5.g); + } else { + pathpoint5.h = pathpoint5.f + pathpoint5.g; + this.b.a(pathpoint5); + } + } + } + } + + if (pathpoint3 == pathpoint) { + return null; + } else { + return this.a(pathpoint, pathpoint3); + } + } + + private int b(Entity entity, PathPoint pathpoint, PathPoint pathpoint1, PathPoint pathpoint2, float f) { + int i = 0; + byte b0 = 0; + + if (this.a(entity, pathpoint.a, pathpoint.b + 1, pathpoint.c, pathpoint1) > 0) { + b0 = 1; + } + + PathPoint pathpoint3 = this.a(entity, pathpoint.a, pathpoint.b, pathpoint.c + 1, pathpoint1, b0); + PathPoint pathpoint4 = this.a(entity, pathpoint.a - 1, pathpoint.b, pathpoint.c, pathpoint1, b0); + PathPoint pathpoint5 = this.a(entity, pathpoint.a + 1, pathpoint.b, pathpoint.c, pathpoint1, b0); + PathPoint pathpoint6 = this.a(entity, pathpoint.a, pathpoint.b, pathpoint.c - 1, pathpoint1, b0); + + if (pathpoint3 != null && !pathpoint3.j && pathpoint3.a(pathpoint2) < f) { + this.d[i++] = pathpoint3; + } + + if (pathpoint4 != null && !pathpoint4.j && pathpoint4.a(pathpoint2) < f) { + this.d[i++] = pathpoint4; + } + + if (pathpoint5 != null && !pathpoint5.j && pathpoint5.a(pathpoint2) < f) { + this.d[i++] = pathpoint5; + } + + if (pathpoint6 != null && !pathpoint6.j && pathpoint6.a(pathpoint2) < f) { + this.d[i++] = pathpoint6; + } + + return i; + } + + private PathPoint a(Entity entity, int i, int j, int k, PathPoint pathpoint, int l) { + PathPoint pathpoint1 = null; + + if (this.a(entity, i, j, k, pathpoint) > 0) { + pathpoint1 = this.a(i, j, k); + } + + if (pathpoint1 == null && this.a(entity, i, j + l, k, pathpoint) > 0) { + pathpoint1 = this.a(i, j + l, k); + j += l; + } + + if (pathpoint1 != null) { + int i1 = 0; + + int j1; + + for (boolean flag = false; j > 0 && (j1 = this.a(entity, i, j - 1, k, pathpoint)) > 0; --j) { + if (j1 < 0) { + return null; + } + + ++i1; + if (i1 >= 4) { + return null; + } + } + + if (j > 0) { + pathpoint1 = this.a(i, j, k); + } + } + + return pathpoint1; + } + + private final PathPoint a(int i, int j, int k) { + int l = i | j << 10 | k << 20; + PathPoint pathpoint = (PathPoint) this.c.a(l); + + if (pathpoint == null) { + pathpoint = new PathPoint(i, j, k); + this.c.a(l, pathpoint); + } + + return pathpoint; + } + + private int a(Entity entity, int i, int j, int k, PathPoint pathpoint) { + for (int l = i; l < i + pathpoint.a; ++l) { + for (int i1 = j; i1 < j + pathpoint.b; ++i1) { + for (int j1 = k; j1 < k + pathpoint.c; ++j1) { + Material material = this.a.c(i, j, k); + + if (material.c()) { + return 0; + } + + if (material == Material.f || material == Material.g) { + return -1; + } + } + } + } + + return 1; + } + + private PathEntity a(PathPoint pathpoint, PathPoint pathpoint1) { + int i = 1; + + PathPoint pathpoint2; + + for (pathpoint2 = pathpoint1; pathpoint2.i != null; pathpoint2 = pathpoint2.i) { + ++i; + } + + PathPoint[] apathpoint = new PathPoint[i]; + + pathpoint2 = pathpoint1; + --i; + + for (apathpoint[i] = pathpoint1; pathpoint2.i != null; apathpoint[i] = pathpoint2) { + pathpoint2 = pathpoint2.i; + --i; + } + + return new PathEntity(apathpoint); + } +} diff --git a/net/minecraft/server/PlayerInstance.java b/net/minecraft/server/PlayerInstance.java new file mode 100644 index 000000000..ecb2e4e09 --- /dev/null +++ b/net/minecraft/server/PlayerInstance.java @@ -0,0 +1,175 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +class PlayerInstance { + + private List b; + private int c; + private int d; + private ChunkCoordIntPair e; + private short[] f; + private int g; + private int h; + private int i; + private int j; + private int k; + private int l; + private int m; + + final PlayerManager a; + + public PlayerInstance(PlayerManager playermanager, int i, int j) { + this.a = playermanager; + this.b = new ArrayList(); + this.f = new short[10]; + this.g = 0; + this.c = i; + this.d = j; + this.e = new ChunkCoordIntPair(i, j); + PlayerManager.a(playermanager).e.y.d(i, j); + } + + public void a(EntityPlayer entityplayer) { + if (this.b.contains(entityplayer)) { + throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.c + ", " + this.d); + } else { + entityplayer.ah.add(this.e); + entityplayer.a.b((Packet) (new Packet50PreChunk(this.e.a, this.e.b, true))); + this.b.add(entityplayer); + entityplayer.ag.add(this.e); + } + } + + public void b(EntityPlayer entityplayer) { + if (!this.b.contains(entityplayer)) { + (new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.c + ", " + this.d)).printStackTrace(); + } else { + this.b.remove(entityplayer); + if (this.b.size() == 0) { + long i = (long) this.c + 2147483647L | (long) this.d + 2147483647L << 32; + + PlayerManager.b(this.a).b(i); + if (this.g > 0) { + PlayerManager.c(this.a).remove(this); + } + + PlayerManager.a(this.a).e.y.c(this.c, this.d); + } + + entityplayer.ag.remove(this.e); + if (entityplayer.ah.contains(this.e)) { + entityplayer.a.b((Packet) (new Packet50PreChunk(this.c, this.d, false))); + } + } + } + + public void a(int i, int j, int k) { + if (this.g == 0) { + PlayerManager.c(this.a).add(this); + this.h = this.i = i; + this.j = this.k = j; + this.l = this.m = k; + } + + if (this.h > i) { + this.h = i; + } + + if (this.i < i) { + this.i = i; + } + + if (this.j > j) { + this.j = j; + } + + if (this.k < j) { + this.k = j; + } + + if (this.l > k) { + this.l = k; + } + + if (this.m < k) { + this.m = k; + } + + if (this.g < 10) { + short short1 = (short) (i << 12 | k << 8 | j); + + for (int l = 0; l < this.g; ++l) { + if (this.f[l] == short1) { + return; + } + } + + this.f[this.g++] = short1; + } + } + + public void a(Packet packet) { + for (int i = 0; i < this.b.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); + + if (entityplayer.ah.contains(this.e)) { + entityplayer.a.b(packet); + } + } + } + + public void a() { + if (this.g != 0) { + int i; + int j; + int k; + + if (this.g == 1) { + i = this.c * 16 + this.h; + j = this.j; + k = this.d * 16 + this.l; + this.a((Packet) (new Packet53BlockChange(i, j, k, PlayerManager.a(this.a).e))); + if (Block.q[PlayerManager.a(this.a).e.a(i, j, k)]) { + this.a((Packet) (new Packet59ComplexEntity(i, j, k, PlayerManager.a(this.a).e.k(i, j, k)))); + } + } else { + int l; + + if (this.g == 10) { + this.j = this.j / 2 * 2; + this.k = (this.k / 2 + 1) * 2; + i = this.h + this.c * 16; + j = this.j; + k = this.l + this.d * 16; + l = this.i - this.h + 1; + int i1 = this.k - this.j + 2; + int j1 = this.m - this.l + 1; + + this.a((Packet) (new Packet51MapChunk(i, j, k, l, i1, j1, PlayerManager.a(this.a).e))); + List list = PlayerManager.a(this.a).e.d(i, j, k, i + l, j + i1, k + j1); + + for (int k1 = 0; k1 < list.size(); ++k1) { + TileEntity tileentity = (TileEntity) list.get(k1); + + this.a((Packet) (new Packet59ComplexEntity(tileentity.b, tileentity.c, tileentity.d, tileentity))); + } + } else { + this.a((Packet) (new Packet52MultiBlockChange(this.c, this.d, this.f, this.g, PlayerManager.a(this.a).e))); + + for (i = 0; i < this.g; ++i) { + j = this.c * 16 + (this.g >> 12 & 15); + k = this.g & 255; + l = this.d * 16 + (this.g >> 8 & 15); + if (Block.q[PlayerManager.a(this.a).e.a(j, k, l)]) { + this.a((Packet) (new Packet59ComplexEntity(j, k, l, PlayerManager.a(this.a).e.k(j, k, l)))); + } + } + } + } + + this.g = 0; + } + } +} diff --git a/net/minecraft/server/PlayerList.java b/net/minecraft/server/PlayerList.java new file mode 100644 index 000000000..e30fc3d79 --- /dev/null +++ b/net/minecraft/server/PlayerList.java @@ -0,0 +1,137 @@ +package net.minecraft.server; + +public class PlayerList { + + private transient PlayerListEntry[] a = new PlayerListEntry[16]; + private transient int b; + private int c = 12; + private final float d = 0.75F; + private transient volatile int e; + + public PlayerList() {} + + private static int e(long i) { + return a((int) (i ^ i >>> 32)); + } + + private static int a(int i) { + i ^= i >>> 20 ^ i >>> 12; + return i ^ i >>> 7 ^ i >>> 4; + } + + private static int a(int i, int j) { + return i & j - 1; + } + + public Object a(long i) { + int j = e(i); + + for (PlayerListEntry playerlistentry = this.a[a(j, this.a.length)]; playerlistentry != null; playerlistentry = playerlistentry.c) { + if (playerlistentry.a == i) { + return playerlistentry.b; + } + } + + return null; + } + + public void a(long i, Object object) { + int j = e(i); + int k = a(j, this.a.length); + + for (PlayerListEntry playerlistentry = this.a[k]; playerlistentry != null; playerlistentry = playerlistentry.c) { + if (playerlistentry.a == i) { + playerlistentry.b = object; + } + } + + ++this.e; + this.a(j, i, object, k); + } + + private void b(int i) { + PlayerListEntry[] aplayerlistentry = this.a; + int j = aplayerlistentry.length; + + if (j == 1073741824) { + this.c = Integer.MAX_VALUE; + } else { + PlayerListEntry[] aplayerlistentry1 = new PlayerListEntry[i]; + + this.a(aplayerlistentry1); + this.a = aplayerlistentry1; + this.c = (int) ((float) i * this.d); + } + } + + private void a(PlayerListEntry[] aplayerlistentry) { + PlayerListEntry[] aplayerlistentry1 = this.a; + int i = aplayerlistentry.length; + + for (int j = 0; j < aplayerlistentry1.length; ++j) { + PlayerListEntry playerlistentry = aplayerlistentry1[j]; + + if (playerlistentry != null) { + aplayerlistentry1[j] = null; + + PlayerListEntry playerlistentry1; + + do { + playerlistentry1 = playerlistentry.c; + int k = a(playerlistentry.d, i); + + playerlistentry.c = aplayerlistentry[k]; + aplayerlistentry[k] = playerlistentry; + playerlistentry = playerlistentry1; + } while (playerlistentry1 != null); + } + } + } + + public Object b(long i) { + PlayerListEntry playerlistentry = this.c(i); + + return playerlistentry == null ? null : playerlistentry.b; + } + + final PlayerListEntry c(long i) { + int j = e(i); + int k = a(j, this.a.length); + PlayerListEntry playerlistentry = this.a[k]; + + PlayerListEntry playerlistentry1; + PlayerListEntry playerlistentry2; + + for (playerlistentry1 = playerlistentry; playerlistentry1 != null; playerlistentry1 = playerlistentry2) { + playerlistentry2 = playerlistentry1.c; + if (playerlistentry1.a == i) { + ++this.e; + --this.b; + if (playerlistentry == playerlistentry1) { + this.a[k] = playerlistentry2; + } else { + playerlistentry.c = playerlistentry2; + } + + return playerlistentry1; + } + + playerlistentry = playerlistentry1; + } + + return playerlistentry1; + } + + private void a(int i, long j, Object object, int k) { + PlayerListEntry playerlistentry = this.a[k]; + + this.a[k] = new PlayerListEntry(i, j, object, playerlistentry); + if (this.b++ >= this.c) { + this.b(2 * this.a.length); + } + } + + static int d(long i) { + return e(i); + } +} diff --git a/net/minecraft/server/PlayerListBox.java b/net/minecraft/server/PlayerListBox.java new file mode 100644 index 000000000..71e5b1955 --- /dev/null +++ b/net/minecraft/server/PlayerListBox.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +import java.util.Vector; +import javax.swing.JList; + +public class PlayerListBox extends JList implements IUpdatePlayerListBox { + + private MinecraftServer a; + private int b = 0; + + public PlayerListBox(MinecraftServer minecraftserver) { + this.a = minecraftserver; + minecraftserver.a((IUpdatePlayerListBox) this); + } + + public void a() { + if (this.b++ % 20 == 0) { + Vector vector = new Vector(); + + for (int i = 0; i < this.a.f.b.size(); ++i) { + vector.add(((EntityPlayer) this.a.f.b.get(i)).aq); + } + + this.setListData(vector); + } + } +} diff --git a/net/minecraft/server/PlayerListEntry.java b/net/minecraft/server/PlayerListEntry.java new file mode 100644 index 000000000..2466c69a5 --- /dev/null +++ b/net/minecraft/server/PlayerListEntry.java @@ -0,0 +1,53 @@ +package net.minecraft.server; + +class PlayerListEntry { + + final long a; + Object b; + PlayerListEntry c; + final int d; + + PlayerListEntry(int i, long j, Object object, PlayerListEntry playerlistentry) { + this.b = object; + this.c = playerlistentry; + this.a = j; + this.d = i; + } + + public final long a() { + return this.a; + } + + public final Object b() { + return this.b; + } + + public final boolean equals(Object object) { + if (!(object instanceof PlayerListEntry)) { + return false; + } else { + PlayerListEntry playerlistentry = (PlayerListEntry) object; + Long olong = Long.valueOf(this.a()); + Long olong1 = Long.valueOf(playerlistentry.a()); + + if (olong == olong1 || olong != null && olong.equals(olong1)) { + Object object1 = this.b(); + Object object2 = playerlistentry.b(); + + if (object1 == object2 || object1 != null && object1.equals(object2)) { + return true; + } + } + + return false; + } + } + + public final int hashCode() { + return PlayerList.d(this.a); + } + + public final String toString() { + return this.a() + "=" + this.b(); + } +} diff --git a/net/minecraft/server/PlayerManager.java b/net/minecraft/server/PlayerManager.java new file mode 100644 index 000000000..bba44f0fa --- /dev/null +++ b/net/minecraft/server/PlayerManager.java @@ -0,0 +1,150 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +public class PlayerManager { + + private List a = new ArrayList(); + private PlayerList b = new PlayerList(); + private List c = new ArrayList(); + private MinecraftServer d; + + public PlayerManager(MinecraftServer minecraftserver) { + this.d = minecraftserver; + } + + public void a() { + for (int i = 0; i < this.c.size(); ++i) { + ((PlayerInstance) this.c.get(i)).a(); + } + + this.c.clear(); + } + + private PlayerInstance a(int i, int j, boolean flag) { + long k = (long) i + 2147483647L | (long) j + 2147483647L << 32; + PlayerInstance playerinstance = (PlayerInstance) this.b.a(k); + + if (playerinstance == null && flag) { + playerinstance = new PlayerInstance(this, i, j); + this.b.a(k, playerinstance); + } + + return playerinstance; + } + + public void a(Packet packet, int i, int j, int k) { + int l = i >> 4; + int i1 = k >> 4; + PlayerInstance playerinstance = this.a(l, i1, false); + + if (playerinstance != null) { + playerinstance.a(packet); + } + } + + public void a(int i, int j, int k) { + int l = i >> 4; + int i1 = k >> 4; + PlayerInstance playerinstance = this.a(l, i1, false); + + if (playerinstance != null) { + playerinstance.a(i & 15, j, k & 15); + } + } + + public void a(EntityPlayer entityplayer) { + this.d.f.a((Packet) (new Packet3Chat("\u00A7e" + entityplayer.aq + " joined the game."))); + int i = (int) entityplayer.l >> 4; + int j = (int) entityplayer.n >> 4; + + entityplayer.ae = entityplayer.l; + entityplayer.af = entityplayer.n; + + for (int k = i - 10; k <= i + 10; ++k) { + for (int l = j - 10; l <= j + 10; ++l) { + this.a(k, l, true).a(entityplayer); + } + } + + this.a.add(entityplayer); + } + + public void b(EntityPlayer entityplayer) { + this.d.f.a((Packet) (new Packet3Chat("\u00A7e" + entityplayer.aq + " left the game."))); + int i = (int) entityplayer.l >> 4; + int j = (int) entityplayer.n >> 4; + + for (int k = i - 10; k <= i + 10; ++k) { + for (int l = j - 10; l <= j + 10; ++l) { + PlayerInstance playerinstance = this.a(k, l, false); + + if (playerinstance != null) { + playerinstance.b(entityplayer); + } + } + } + + this.a.remove(entityplayer); + } + + private boolean a(int i, int j, int k, int l) { + int i1 = i - k; + int j1 = j - l; + + return i1 >= -10 && i1 <= 10 ? j1 >= -10 && j1 <= 10 : false; + } + + public void c(EntityPlayer entityplayer) { + int i = (int) entityplayer.l >> 4; + int j = (int) entityplayer.n >> 4; + double d0 = entityplayer.ae - entityplayer.l; + double d1 = entityplayer.af - entityplayer.n; + double d2 = d0 * d0 + d1 * d1; + + if (d2 >= 64.0D) { + int k = (int) entityplayer.ae >> 4; + int l = (int) entityplayer.af >> 4; + int i1 = i - k; + int j1 = j - l; + + if (i1 != 0 || j1 != 0) { + for (int k1 = i - 10; k1 <= i + 10; ++k1) { + for (int l1 = j - 10; l1 <= j + 10; ++l1) { + if (!this.a(k1, l1, k, l)) { + this.a(k1, l1, true).a(entityplayer); + } + + if (!this.a(k1 - i1, l1 - j1, i, j)) { + PlayerInstance playerinstance = this.a(k1 - i1, l1 - j1, false); + + if (playerinstance != null) { + playerinstance.b(entityplayer); + } + } + } + } + + entityplayer.ae = entityplayer.l; + entityplayer.af = entityplayer.n; + } + } + } + + public int b() { + return 144; + } + + static MinecraftServer a(PlayerManager playermanager) { + return playermanager.d; + } + + static PlayerList b(PlayerManager playermanager) { + return playermanager.b; + } + + static List c(PlayerManager playermanager) { + return playermanager.c; + } +} diff --git a/net/minecraft/server/PlayerNBTManager.java b/net/minecraft/server/PlayerNBTManager.java new file mode 100644 index 000000000..ab4d90318 --- /dev/null +++ b/net/minecraft/server/PlayerNBTManager.java @@ -0,0 +1,54 @@ +package net.minecraft.server; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.logging.Logger; + +public class PlayerNBTManager { + + public static Logger a = Logger.getLogger("Minecraft"); + private File b; + + public PlayerNBTManager(File file1) { + this.b = file1; + file1.mkdir(); + } + + public void a(EntityPlayer entityplayer) { + try { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + entityplayer.d(nbttagcompound); + File file1 = new File(this.b, "_tmp_.dat"); + File file2 = new File(this.b, entityplayer.aq + ".dat"); + + CompressedStreamTools.a(nbttagcompound, (OutputStream) (new FileOutputStream(file1))); + if (file2.exists()) { + file2.delete(); + } + + file1.renameTo(file2); + } catch (Exception exception) { + a.warning("Failed to save player data for " + entityplayer.aq); + } + } + + public void b(EntityPlayer entityplayer) { + try { + File file1 = new File(this.b, entityplayer.aq + ".dat"); + + if (file1.exists()) { + NBTTagCompound nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1))); + + if (nbttagcompound != null) { + entityplayer.e(nbttagcompound); + } + } + } catch (Exception exception) { + a.warning("Failed to load player data for " + entityplayer.aq); + } + } +} diff --git a/net/minecraft/server/PropertyManager.java b/net/minecraft/server/PropertyManager.java new file mode 100644 index 000000000..a0060aa93 --- /dev/null +++ b/net/minecraft/server/PropertyManager.java @@ -0,0 +1,71 @@ +package net.minecraft.server; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class PropertyManager { + + public static Logger a = Logger.getLogger("Minecraft"); + private Properties b = new Properties(); + private File c; + + public PropertyManager(File file1) { + this.c = file1; + if (file1.exists()) { + try { + this.b.load(new FileInputStream(file1)); + } catch (Exception exception) { + a.log(Level.WARNING, "Failed to load " + file1, exception); + this.a(); + } + } else { + a.log(Level.WARNING, file1 + " does not exist"); + this.a(); + } + } + + public void a() { + a.log(Level.INFO, "Generating new properties file"); + this.b(); + } + + public void b() { + try { + this.b.store(new FileOutputStream(this.c), "Minecraft server properties"); + } catch (Exception exception) { + a.log(Level.WARNING, "Failed to save " + this.c, exception); + this.a(); + } + } + + public String a(String s, String s1) { + if (!this.b.containsKey(s)) { + this.b.setProperty(s, s1); + this.b(); + } + + return this.b.getProperty(s, s1); + } + + public int a(String s, int i) { + try { + return Integer.parseInt(this.a(s, "" + i)); + } catch (Exception exception) { + this.b.setProperty(s, "" + i); + return i; + } + } + + public boolean a(String s, boolean flag) { + try { + return Boolean.parseBoolean(this.a(s, "" + flag)); + } catch (Exception exception) { + this.b.setProperty(s, "" + flag); + return flag; + } + } +} diff --git a/net/minecraft/server/RedstoneUpdateInfo.java b/net/minecraft/server/RedstoneUpdateInfo.java new file mode 100644 index 000000000..1fbe56a90 --- /dev/null +++ b/net/minecraft/server/RedstoneUpdateInfo.java @@ -0,0 +1,16 @@ +package net.minecraft.server; + +class RedstoneUpdateInfo { + + int a; + int b; + int c; + long d; + + public RedstoneUpdateInfo(int i, int j, int k, long l) { + this.a = i; + this.b = j; + this.c = k; + this.d = l; + } +} diff --git a/net/minecraft/server/ServerCommand.java b/net/minecraft/server/ServerCommand.java new file mode 100644 index 000000000..2343d09a1 --- /dev/null +++ b/net/minecraft/server/ServerCommand.java @@ -0,0 +1,12 @@ +package net.minecraft.server; + +public class ServerCommand { + + public final String a; + public final ICommandListener b; + + public ServerCommand(String s, ICommandListener icommandlistener) { + this.a = s; + this.b = icommandlistener; + } +} diff --git a/net/minecraft/server/ServerConfigurationManager.java b/net/minecraft/server/ServerConfigurationManager.java new file mode 100644 index 000000000..6db308d0e --- /dev/null +++ b/net/minecraft/server/ServerConfigurationManager.java @@ -0,0 +1,321 @@ +package net.minecraft.server; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.logging.Logger; + +public class ServerConfigurationManager { + + public static Logger a = Logger.getLogger("Minecraft"); + public List b = new ArrayList(); + private MinecraftServer c; + private PlayerManager d; + private int e; + private Set f = new HashSet(); + private Set g = new HashSet(); + private Set h = new HashSet(); + private File i; + private File j; + private File k; + private PlayerNBTManager l; + + public ServerConfigurationManager(MinecraftServer minecraftserver) { + this.c = minecraftserver; + this.i = minecraftserver.a("banned-players.txt"); + this.j = minecraftserver.a("banned-ips.txt"); + this.k = minecraftserver.a("ops.txt"); + this.d = new PlayerManager(minecraftserver); + this.e = minecraftserver.d.a("max-players", 20); + this.e(); + this.g(); + this.i(); + this.f(); + this.h(); + this.j(); + } + + public void a(WorldServer worldserver) { + this.l = new PlayerNBTManager(new File(worldserver.s, "players")); + } + + public int a() { + return this.d.b(); + } + + public void a(EntityPlayer entityplayer) { + this.b.add(entityplayer); + this.l.b(entityplayer); + this.c.e.y.d((int) entityplayer.l >> 4, (int) entityplayer.n >> 4); + + while (this.c.e.a(entityplayer, entityplayer.v).size() != 0) { + entityplayer.a(entityplayer.l, entityplayer.m + 1.0D, entityplayer.n); + } + + this.c.e.a(entityplayer); + this.d.a(entityplayer); + } + + public void b(EntityPlayer entityplayer) { + this.d.c(entityplayer); + } + + public void c(EntityPlayer entityplayer) { + this.d.b(entityplayer); + this.l.a(entityplayer); + this.c.e.d(entityplayer); + this.b.remove(entityplayer); + } + + public EntityPlayer a(NetLoginHandler netloginhandler, String s, String s1) { + if (this.f.contains(s.trim().toLowerCase())) { + netloginhandler.b("You are banned from this server!"); + return null; + } else { + String s2 = netloginhandler.b.b().toString(); + + s2 = s2.substring(s2.indexOf("/") + 1); + s2 = s2.substring(0, s2.indexOf(":")); + if (this.g.contains(s2)) { + netloginhandler.b("Your IP address is banned from this server!"); + return null; + } else if (this.b.size() >= this.e) { + netloginhandler.b("The server is full!"); + return null; + } else { + for (int i = 0; i < this.b.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); + + if (entityplayer.aq.equalsIgnoreCase(s)) { + entityplayer.a.c("You logged in from another location"); + } + } + + return new EntityPlayer(this.c, this.c.e, s, new ItemInWorldManager(this.c.e)); + } + } + } + + public void b() { + this.d.a(); + } + + public void a(int i, int j, int k) { + this.d.a(i, j, k); + } + + public void a(Packet packet) { + for (int i = 0; i < this.b.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); + + entityplayer.a.b(packet); + } + } + + public String c() { + String s = ""; + + for (int i = 0; i < this.b.size(); ++i) { + if (i > 0) { + s = s + ", "; + } + + s = s + ((EntityPlayer) this.b.get(i)).aq; + } + + return s; + } + + public void a(String s) { + this.f.add(s.toLowerCase()); + this.f(); + } + + public void b(String s) { + this.f.remove(s.toLowerCase()); + this.f(); + } + + private void e() { + try { + this.f.clear(); + BufferedReader bufferedreader = new BufferedReader(new FileReader(this.i)); + String s = ""; + + while ((s = bufferedreader.readLine()) != null) { + this.f.add(s.trim().toLowerCase()); + } + + bufferedreader.close(); + } catch (Exception exception) { + a.warning("Failed to load ban list: " + exception); + } + } + + private void f() { + try { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.i, false)); + Iterator iterator = this.f.iterator(); + + while (iterator.hasNext()) { + String s = (String) iterator.next(); + + printwriter.println(s); + } + + printwriter.close(); + } catch (Exception exception) { + a.warning("Failed to save ban list: " + exception); + } + } + + public void c(String s) { + this.g.add(s.toLowerCase()); + this.h(); + } + + public void d(String s) { + this.g.remove(s.toLowerCase()); + this.h(); + } + + private void g() { + try { + this.g.clear(); + BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j)); + String s = ""; + + while ((s = bufferedreader.readLine()) != null) { + this.g.add(s.trim().toLowerCase()); + } + + bufferedreader.close(); + } catch (Exception exception) { + a.warning("Failed to load ip ban list: " + exception); + } + } + + private void h() { + try { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false)); + Iterator iterator = this.g.iterator(); + + while (iterator.hasNext()) { + String s = (String) iterator.next(); + + printwriter.println(s); + } + + printwriter.close(); + } catch (Exception exception) { + a.warning("Failed to save ip ban list: " + exception); + } + } + + public void e(String s) { + this.h.add(s.toLowerCase()); + this.j(); + } + + public void f(String s) { + this.h.remove(s.toLowerCase()); + this.j(); + } + + private void i() { + try { + this.h.clear(); + BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k)); + String s = ""; + + while ((s = bufferedreader.readLine()) != null) { + this.h.add(s.trim().toLowerCase()); + } + + bufferedreader.close(); + } catch (Exception exception) { + a.warning("Failed to load ip ban list: " + exception); + } + } + + private void j() { + try { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false)); + Iterator iterator = this.h.iterator(); + + while (iterator.hasNext()) { + String s = (String) iterator.next(); + + printwriter.println(s); + } + + printwriter.close(); + } catch (Exception exception) { + a.warning("Failed to save ip ban list: " + exception); + } + } + + public boolean g(String s) { + return this.h.contains(s.trim().toLowerCase()); + } + + public EntityPlayer h(String s) { + for (int i = 0; i < this.b.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); + + if (entityplayer.aq.equalsIgnoreCase(s)) { + return entityplayer; + } + } + + return null; + } + + public void a(String s, String s1) { + EntityPlayer entityplayer = this.h(s); + + if (entityplayer != null) { + entityplayer.a.b((Packet) (new Packet3Chat(s1))); + } + } + + public void i(String s) { + Packet3Chat packet3chat = new Packet3Chat(s); + + for (int i = 0; i < this.b.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); + + if (this.g(entityplayer.aq)) { + entityplayer.a.b((Packet) packet3chat); + } + } + } + + public boolean a(String s, Packet packet) { + EntityPlayer entityplayer = this.h(s); + + if (entityplayer != null) { + entityplayer.a.b(packet); + return true; + } else { + return false; + } + } + + public void a(int i, int j, int k, TileEntity tileentity) { + this.d.a(new Packet59ComplexEntity(i, j, k, tileentity), i, j, k); + } + + public void d() { + for (int i = 0; i < this.b.size(); ++i) { + this.l.a((EntityPlayer) this.b.get(i)); + } + } +} diff --git a/net/minecraft/server/ServerGUI.java b/net/minecraft/server/ServerGUI.java new file mode 100644 index 000000000..afd303761 --- /dev/null +++ b/net/minecraft/server/ServerGUI.java @@ -0,0 +1,98 @@ +package net.minecraft.server; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.logging.Logger; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; + +public class ServerGUI extends JComponent implements ICommandListener { + + public static Logger a = Logger.getLogger("Minecraft"); + private MinecraftServer b; + + public static void a(MinecraftServer minecraftserver) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception exception) { + ; + } + + ServerGUI servergui = new ServerGUI(minecraftserver); + JFrame jframe = new JFrame("Minecraft server"); + + jframe.add(servergui); + jframe.pack(); + jframe.setLocationRelativeTo((Component) null); + jframe.setVisible(true); + jframe.addWindowListener(new ServerWindowAdapter(minecraftserver)); + } + + public ServerGUI(MinecraftServer minecraftserver) { + this.b = minecraftserver; + this.setPreferredSize(new Dimension(854, 480)); + this.setLayout(new BorderLayout()); + + try { + this.add(this.d(), "Center"); + this.add(this.a(), "West"); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + private JComponent a() { + JPanel jpanel = new JPanel(new BorderLayout()); + + jpanel.add(new GuiStatsComponent(), "North"); + jpanel.add(this.b(), "Center"); + jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats")); + return jpanel; + } + + private JComponent b() { + PlayerListBox playerlistbox = new PlayerListBox(this.b); + JScrollPane jscrollpane = new JScrollPane(playerlistbox, 22, 30); + + jscrollpane.setBorder(new TitledBorder(new EtchedBorder(), "Players")); + return jscrollpane; + } + + private JComponent d() { + JPanel jpanel = new JPanel(new BorderLayout()); + JTextArea jtextarea = new JTextArea(); + + a.addHandler(new GuiLogOutputHandler(jtextarea)); + JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30); + + jtextarea.setEditable(false); + JTextField jtextfield = new JTextField(); + + jtextfield.addActionListener(new ServerGuiCommandListener(this, jtextfield)); + jtextarea.addFocusListener(new ServerGuiFocusadapter(this)); + jpanel.add(jscrollpane, "Center"); + jpanel.add(jtextfield, "South"); + jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat")); + return jpanel; + } + + public void b(String s) { + a.info(s); + } + + public String c() { + return "CONSOLE"; + } + + static MinecraftServer a(ServerGUI servergui) { + return servergui.b; + } +} diff --git a/net/minecraft/server/ServerGuiCommandListener.java b/net/minecraft/server/ServerGuiCommandListener.java new file mode 100644 index 000000000..4c5c6dc01 --- /dev/null +++ b/net/minecraft/server/ServerGuiCommandListener.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JTextField; + +class ServerGuiCommandListener implements ActionListener { + + final JTextField a; + + final ServerGUI b; + + ServerGuiCommandListener(ServerGUI servergui, JTextField jtextfield) { + this.b = servergui; + this.a = jtextfield; + } + + public void actionPerformed(ActionEvent actionevent) { + String s = this.a.getText().trim(); + + if (s.length() > 0) { + ServerGUI.a(this.b).a(s, (ICommandListener) this.b); + } + + this.a.setText(""); + } +} diff --git a/net/minecraft/server/ServerGuiFocusadapter.java b/net/minecraft/server/ServerGuiFocusadapter.java new file mode 100644 index 000000000..12b3440c0 --- /dev/null +++ b/net/minecraft/server/ServerGuiFocusadapter.java @@ -0,0 +1,15 @@ +package net.minecraft.server; + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; + +class ServerGuiFocusadapter extends FocusAdapter { + + final ServerGUI a; + + ServerGuiFocusadapter(ServerGUI servergui) { + this.a = servergui; + } + + public void focusGained(FocusEvent focusevent) {} +} diff --git a/net/minecraft/server/ServerWindowAdapter.java b/net/minecraft/server/ServerWindowAdapter.java new file mode 100644 index 000000000..3594037f5 --- /dev/null +++ b/net/minecraft/server/ServerWindowAdapter.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +final class ServerWindowAdapter extends WindowAdapter { + + final MinecraftServer a; + + ServerWindowAdapter(MinecraftServer minecraftserver) { + this.a = minecraftserver; + } + + public void windowClosing(WindowEvent windowevent) { + this.a.a(); + + while (!this.a.g) { + try { + Thread.sleep(100L); + } catch (InterruptedException interruptedexception) { + interruptedexception.printStackTrace(); + } + } + + System.exit(0); + } +} diff --git a/net/minecraft/server/SpawnerCreature.java b/net/minecraft/server/SpawnerCreature.java new file mode 100644 index 000000000..2f692c556 --- /dev/null +++ b/net/minecraft/server/SpawnerCreature.java @@ -0,0 +1,135 @@ +package net.minecraft.server; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SpawnerCreature { + + private int a; + private Class b; + private Class[] c; + private Set d = new HashSet(); + + public SpawnerCreature(int i, Class oclass, Class[] aclass) { + this.a = i; + this.b = oclass; + this.c = aclass; + } + + public void a(World world) { + int i = world.a(this.b); + + if (i < this.a) { + for (int j = 0; j < 3; ++j) { + this.a(world, 1, (IProgressUpdate) null); + } + } + } + + protected ChunkPosition a(World world, int i, int j) { + int k = i + world.m.nextInt(16); + int l = world.m.nextInt(128); + int i1 = j + world.m.nextInt(16); + + return new ChunkPosition(k, l, i1); + } + + private int a(World world, int i, IProgressUpdate iprogressupdate) { + this.d.clear(); + + int j; + int k; + int l; + int i1; + + for (j = 0; j < world.k.size(); ++j) { + EntityHuman entityhuman = (EntityHuman) world.k.get(j); + int j1 = MathHelper.b(entityhuman.l / 16.0D); + + k = MathHelper.b(entityhuman.n / 16.0D); + byte b0 = 4; + + for (l = -b0; l <= b0; ++l) { + for (i1 = -b0; i1 <= b0; ++i1) { + this.d.add(new ChunkCoordIntPair(l + j1, i1 + k)); + } + } + } + + j = 0; + Iterator iterator = this.d.iterator(); + + while (iterator.hasNext()) { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); + + if (world.m.nextInt(10) == 0) { + k = world.m.nextInt(this.c.length); + ChunkPosition chunkposition = this.a(world, chunkcoordintpair.a * 16, chunkcoordintpair.b * 16); + + l = chunkposition.a; + i1 = chunkposition.b; + int k1 = chunkposition.c; + + if (world.d(l, i1, k1)) { + return 0; + } + + if (world.c(l, i1, k1) != Material.a) { + return 0; + } + + for (int l1 = 0; l1 < 3; ++l1) { + int i2 = l; + int j2 = i1; + int k2 = k1; + byte b1 = 6; + + for (int l2 = 0; l2 < 2; ++l2) { + i2 += world.m.nextInt(b1) - world.m.nextInt(b1); + j2 += world.m.nextInt(1) - world.m.nextInt(1); + k2 += world.m.nextInt(b1) - world.m.nextInt(b1); + if (world.d(i2, j2 - 1, k2) && !world.d(i2, j2, k2) && !world.c(i2, j2, k2).d() && !world.d(i2, j2 + 1, k2)) { + float f = (float) i2 + 0.5F; + float f1 = (float) j2; + float f2 = (float) k2 + 0.5F; + + if (world.a((double) f, (double) f1, (double) f2, 24.0D) == null) { + float f3 = f - (float) world.n; + float f4 = f1 - (float) world.o; + float f5 = f2 - (float) world.p; + float f6 = f3 * f3 + f4 * f4 + f5 * f5; + + if (f6 >= 576.0F) { + EntityLiving entityliving; + + try { + entityliving = (EntityLiving) this.c[k].getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); + } catch (Exception exception) { + exception.printStackTrace(); + return j; + } + + entityliving.c((double) f, (double) f1, (double) f2, world.m.nextFloat() * 360.0F, 0.0F); + if (entityliving.a()) { + ++j; + world.a((Entity) entityliving); + if (entityliving instanceof EntitySpider && world.m.nextInt(100) == 0) { + EntitySkeleton entityskeleton = new EntitySkeleton(world); + + entityskeleton.c((double) f, (double) f1, (double) f2, entityliving.r, 0.0F); + world.a((Entity) entityskeleton); + entityskeleton.e(entityliving); + } + } + } + } + } + } + } + } + } + + return j; + } +} diff --git a/net/minecraft/server/SpawnerMonsters.java b/net/minecraft/server/SpawnerMonsters.java new file mode 100644 index 000000000..f607ba4c9 --- /dev/null +++ b/net/minecraft/server/SpawnerMonsters.java @@ -0,0 +1,19 @@ +package net.minecraft.server; + +class SpawnerMonsters extends SpawnerCreature { + + final WorldServer a; + + SpawnerMonsters(WorldServer worldserver, int i, Class oclass, Class[] aclass) { + super(i, oclass, aclass); + this.a = worldserver; + } + + protected ChunkPosition a(World world, int i, int j) { + int k = i + world.m.nextInt(16); + int l = world.m.nextInt(world.m.nextInt(120) + 8); + int i1 = j + world.m.nextInt(16); + + return new ChunkPosition(k, l, i1); + } +} diff --git a/net/minecraft/server/StepSound.java b/net/minecraft/server/StepSound.java new file mode 100644 index 000000000..174b460ad --- /dev/null +++ b/net/minecraft/server/StepSound.java @@ -0,0 +1,26 @@ +package net.minecraft.server; + +public class StepSound { + + public final String a; + public final float b; + public final float c; + + public StepSound(String s, float f, float f1) { + this.a = s; + this.b = f; + this.c = f1; + } + + public float a() { + return this.b; + } + + public float b() { + return this.c; + } + + public String c() { + return "step." + this.a; + } +} diff --git a/net/minecraft/server/StepSoundSand.java b/net/minecraft/server/StepSoundSand.java new file mode 100644 index 000000000..a3b7eddf6 --- /dev/null +++ b/net/minecraft/server/StepSoundSand.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +final class StepSoundSand extends StepSound { + + StepSoundSand(String s, float f, float f1) { + super(s, f, f1); + } +} diff --git a/net/minecraft/server/StepSoundStone.java b/net/minecraft/server/StepSoundStone.java new file mode 100644 index 000000000..4fd2eeb19 --- /dev/null +++ b/net/minecraft/server/StepSoundStone.java @@ -0,0 +1,8 @@ +package net.minecraft.server; + +final class StepSoundStone extends StepSound { + + StepSoundStone(String s, float f, float f1) { + super(s, f, f1); + } +} diff --git a/net/minecraft/server/ThreadCommandReader.java b/net/minecraft/server/ThreadCommandReader.java new file mode 100644 index 000000000..e1357e29d --- /dev/null +++ b/net/minecraft/server/ThreadCommandReader.java @@ -0,0 +1,27 @@ +package net.minecraft.server; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class ThreadCommandReader extends Thread { + + final MinecraftServer a; + + public ThreadCommandReader(MinecraftServer minecraftserver) { + this.a = minecraftserver; + } + + public void run() { + BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); + String s = null; + + try { + while (!this.a.g && MinecraftServer.a(this.a) && (s = bufferedreader.readLine()) != null) { + this.a.a(s, (ICommandListener) this.a); + } + } catch (IOException ioexception) { + ioexception.printStackTrace(); + } + } +} diff --git a/net/minecraft/server/ThreadLoginVerifier.java b/net/minecraft/server/ThreadLoginVerifier.java new file mode 100644 index 000000000..b29029680 --- /dev/null +++ b/net/minecraft/server/ThreadLoginVerifier.java @@ -0,0 +1,36 @@ +package net.minecraft.server; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; + +class ThreadLoginVerifier extends Thread { + + final Packet1Login a; + + final NetLoginHandler b; + + ThreadLoginVerifier(NetLoginHandler netloginhandler, Packet1Login packet1login) { + this.b = netloginhandler; + this.a = packet1login; + } + + public void run() { + try { + String s = NetLoginHandler.a(this.b); + URL url = new URL("http://www.minecraft.net/game/checkserver.jsp?user=" + this.a.b + "&serverId=" + s); + BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); + String s1 = bufferedreader.readLine(); + + bufferedreader.close(); + System.out.println("THE REPLY IS " + s1); + if (s1.equals("YES")) { + NetLoginHandler.a(this.b, this.a); + } else { + this.b.b("Failed to verify username!"); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + } +} diff --git a/net/minecraft/server/ThreadMonitorConnection.java b/net/minecraft/server/ThreadMonitorConnection.java new file mode 100644 index 000000000..2a1ab7007 --- /dev/null +++ b/net/minecraft/server/ThreadMonitorConnection.java @@ -0,0 +1,22 @@ +package net.minecraft.server; + +class ThreadMonitorConnection extends Thread { + + final NetworkManager a; + + ThreadMonitorConnection(NetworkManager networkmanager) { + this.a = networkmanager; + } + + public void run() { + try { + Thread.sleep(2000L); + if (NetworkManager.a(this.a)) { + NetworkManager.f(this.a).interrupt(); + this.a.a("Connection closed"); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + } +} diff --git a/net/minecraft/server/ThreadServerApplication.java b/net/minecraft/server/ThreadServerApplication.java new file mode 100644 index 000000000..4e49faee2 --- /dev/null +++ b/net/minecraft/server/ThreadServerApplication.java @@ -0,0 +1,15 @@ +package net.minecraft.server; + +public final class ThreadServerApplication extends Thread { + + final MinecraftServer a; + + public ThreadServerApplication(String s, MinecraftServer minecraftserver) { + super(s); + this.a = minecraftserver; + } + + public void run() { + this.a.run(); + } +} diff --git a/net/minecraft/server/ThreadSleepForever.java b/net/minecraft/server/ThreadSleepForever.java new file mode 100644 index 000000000..1aa96d724 --- /dev/null +++ b/net/minecraft/server/ThreadSleepForever.java @@ -0,0 +1,24 @@ +package net.minecraft.server; + +public class ThreadSleepForever extends Thread { + + final MinecraftServer a; + + public ThreadSleepForever(MinecraftServer minecraftserver) { + this.a = minecraftserver; + this.setDaemon(true); + this.start(); + } + + public void run() { + while (true) { + try { + while (true) { + Thread.sleep(2147483647L); + } + } catch (InterruptedException interruptedexception) { + ; + } + } + } +} diff --git a/net/minecraft/server/TileEntity.java b/net/minecraft/server/TileEntity.java new file mode 100644 index 000000000..cfa69e78e --- /dev/null +++ b/net/minecraft/server/TileEntity.java @@ -0,0 +1,79 @@ +package net.minecraft.server; + +import java.util.HashMap; +import java.util.Map; + +public class TileEntity { + + private static Map e = new HashMap(); + private static Map f = new HashMap(); + public World a; + public int b; + public int c; + public int d; + + public TileEntity() {} + + private static void a(Class oclass, String s) { + if (f.containsKey(s)) { + throw new IllegalArgumentException("Duplicate id: " + s); + } else { + e.put(s, oclass); + f.put(oclass, s); + } + } + + public void a(NBTTagCompound nbttagcompound) { + this.b = nbttagcompound.d("x"); + this.c = nbttagcompound.d("y"); + this.d = nbttagcompound.d("z"); + } + + public void b(NBTTagCompound nbttagcompound) { + String s = (String) f.get(this.getClass()); + + if (s == null) { + throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!"); + } else { + nbttagcompound.a("id", s); + nbttagcompound.a("x", this.b); + nbttagcompound.a("y", this.c); + nbttagcompound.a("z", this.d); + } + } + + public void b() {} + + public static TileEntity c(NBTTagCompound nbttagcompound) { + TileEntity tileentity = null; + + try { + Class oclass = (Class) e.get(nbttagcompound.h("id")); + + if (oclass != null) { + tileentity = (TileEntity) oclass.newInstance(); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + + if (tileentity != null) { + tileentity.a(nbttagcompound); + } else { + System.out.println("Skipping TileEntity with id " + nbttagcompound.h("id")); + } + + return tileentity; + } + + public void c() { + this.a.b(this.b, this.c, this.d, this); + } + + static { + a(TileEntityFurnace.class, "Furnace"); + a(TileEntityChest.class, "Chest"); + a(TileEntitySign.class, "Sign"); + a(TileEntityMobSpawner.class, "MobSpawner"); + } +} diff --git a/net/minecraft/server/TileEntityChest.java b/net/minecraft/server/TileEntityChest.java new file mode 100644 index 000000000..978a0c63d --- /dev/null +++ b/net/minecraft/server/TileEntityChest.java @@ -0,0 +1,62 @@ +package net.minecraft.server; + +public class TileEntityChest extends TileEntity implements IInventory { + + private ItemStack[] e = new ItemStack[36]; + + public TileEntityChest() {} + + public int a() { + return 27; + } + + public ItemStack a(int i) { + return this.e[i]; + } + + public void a(int i, ItemStack itemstack) { + this.e[i] = itemstack; + if (itemstack != null && itemstack.a > this.d()) { + itemstack.a = this.d(); + } + + this.c(); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.k("Items"); + + this.e = new ItemStack[this.a()]; + + for (int i = 0; i < nbttaglist.b(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); + int j = nbttagcompound1.b("Slot") & 255; + + if (j >= 0 && j < this.e.length) { + this.e[j] = new ItemStack(nbttagcompound1); + } + } + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.e.length; ++i) { + if (this.e[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + nbttagcompound1.a("Slot", (byte) i); + this.e[i].a(nbttagcompound1); + nbttaglist.a((NBTBase) nbttagcompound1); + } + } + + nbttagcompound.a("Items", (NBTBase) nbttaglist); + } + + public int d() { + return 64; + } +} diff --git a/net/minecraft/server/TileEntityFurnace.java b/net/minecraft/server/TileEntityFurnace.java new file mode 100644 index 000000000..f5d4bb850 --- /dev/null +++ b/net/minecraft/server/TileEntityFurnace.java @@ -0,0 +1,151 @@ +package net.minecraft.server; + +public class TileEntityFurnace extends TileEntity implements IInventory { + + private ItemStack[] e = new ItemStack[3]; + private int f = 0; + private int g = 0; + private int h = 0; + + public TileEntityFurnace() {} + + public int a() { + return this.e.length; + } + + public ItemStack a(int i) { + return this.e[i]; + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.k("Items"); + + this.e = new ItemStack[this.a()]; + + for (int i = 0; i < nbttaglist.b(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); + byte b0 = nbttagcompound1.b("Slot"); + + if (b0 >= 0 && b0 < this.e.length) { + this.e[b0] = new ItemStack(nbttagcompound1); + } + } + + this.f = nbttagcompound.c("BurnTime"); + this.h = nbttagcompound.c("CookTime"); + this.g = this.a(this.e[1]); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.a("BurnTime", (short) this.f); + nbttagcompound.a("CookTime", (short) this.h); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.e.length; ++i) { + if (this.e[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + nbttagcompound1.a("Slot", (byte) i); + this.e[i].a(nbttagcompound1); + nbttaglist.a((NBTBase) nbttagcompound1); + } + } + + nbttagcompound.a("Items", (NBTBase) nbttaglist); + } + + public int d() { + return 64; + } + + public boolean e() { + return this.f > 0; + } + + public void b() { + boolean flag = this.f > 0; + boolean flag1 = false; + + if (this.f > 0) { + --this.f; + } + + if (!this.a.x) { + if (this.f == 0 && this.g()) { + this.g = this.f = this.a(this.e[1]); + if (this.f > 0) { + flag1 = true; + if (this.e[1] != null) { + --this.e[1].a; + if (this.e[1].a == 0) { + this.e[1] = null; + } + } + } + } + + if (this.e() && this.g()) { + ++this.h; + if (this.h == 200) { + this.h = 0; + this.f(); + flag1 = true; + } + } else { + this.h = 0; + } + + if (flag != this.f > 0) { + flag1 = true; + BlockFurnace.a(this.f > 0, this.a, this.b, this.c, this.d); + } + } + + if (flag1) { + this.c(); + } + } + + private boolean g() { + if (this.e[0] == null) { + return false; + } else { + int i = this.b(this.e[0].a().aS); + + return i < 0 ? false : (this.e[2] == null ? true : (this.e[2].c != i ? false : (this.e[2].a < this.d() && this.e[2].a < this.e[2].b() ? true : this.e[2].a < Item.c[i].a()))); + } + } + + public void f() { + if (this.g()) { + int i = this.b(this.e[0].a().aS); + + if (this.e[2] == null) { + this.e[2] = new ItemStack(i, 1); + } else if (this.e[2].c == i) { + ++this.e[2].a; + } + + --this.e[0].a; + if (this.e[0].a <= 0) { + this.e[0] = null; + } + } + } + + private int b(int i) { + return i == Block.IRON_ORE.bc ? Item.IRON_INGOT.aS : (i == Block.GOLD_ORE.bc ? Item.GOLD_INGOT.aS : (i == Block.DIAMOND_ORE.bc ? Item.DIAMOND.aS : (i == Block.SAND.bc ? Block.GLASS.bc : (i == Item.PORK.aS ? Item.GRILLED_PORK.aS : (i == Block.COBBLESTONE.bc ? Block.STONE.bc : (i == Item.CLAY_BALL.aS ? Item.CLAY_BRICK.aS : -1)))))); + } + + private int a(ItemStack itemstack) { + if (itemstack == null) { + return 0; + } else { + int i = itemstack.a().aS; + + return i < 256 && Block.n[i].bn == Material.c ? 300 : (i == Item.STICK.aS ? 100 : (i == Item.COAL.aS ? 1600 : (i == Item.LAVA_BUCKET.aS ? 20000 : 0))); + } + } +} diff --git a/net/minecraft/server/TileEntityMobSpawner.java b/net/minecraft/server/TileEntityMobSpawner.java new file mode 100644 index 000000000..abd81889f --- /dev/null +++ b/net/minecraft/server/TileEntityMobSpawner.java @@ -0,0 +1,98 @@ +package net.minecraft.server; + +public class TileEntityMobSpawner extends TileEntity { + + public int e = -1; + public String f = "Pig"; + public double g; + public double h = 0.0D; + + public TileEntityMobSpawner() { + this.e = 20; + } + + public boolean a() { + return this.a.a((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D, 16.0D) != null; + } + + public void b() { + this.h = this.g; + if (this.a()) { + double d0 = (double) ((float) this.b + this.a.m.nextFloat()); + double d1 = (double) ((float) this.c + this.a.m.nextFloat()); + double d2 = (double) ((float) this.d + this.a.m.nextFloat()); + + this.a.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.a.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + + for (this.g += (double) (1000.0F / ((float) this.e + 200.0F)); this.g > 360.0D; this.h -= 360.0D) { + this.g -= 360.0D; + } + + if (this.e == -1) { + this.d(); + } + + if (this.e > 0) { + --this.e; + } else { + byte b0 = 4; + + for (int i = 0; i < b0; ++i) { + EntityLiving entityliving = (EntityLiving) ((EntityLiving) EntityTypes.a(this.f, this.a)); + + if (entityliving == null) { + return; + } + + int j = this.a.a(entityliving.getClass(), AxisAlignedBB.b((double) this.b, (double) this.c, (double) this.d, (double) (this.b + 1), (double) (this.c + 1), (double) (this.d + 1)).b(8.0D, 4.0D, 8.0D)).size(); + + if (j >= 6) { + this.d(); + return; + } + + if (entityliving != null) { + double d3 = (double) this.b + (this.a.m.nextDouble() - this.a.m.nextDouble()) * 4.0D; + double d4 = (double) (this.c + this.a.m.nextInt(3) - 1); + double d5 = (double) this.d + (this.a.m.nextDouble() - this.a.m.nextDouble()) * 4.0D; + + entityliving.c(d3, d4, d5, this.a.m.nextFloat() * 360.0F, 0.0F); + if (entityliving.a()) { + this.a.a((Entity) entityliving); + + for (int k = 0; k < 20; ++k) { + d0 = (double) this.b + 0.5D + ((double) this.a.m.nextFloat() - 0.5D) * 2.0D; + d1 = (double) this.c + 0.5D + ((double) this.a.m.nextFloat() - 0.5D) * 2.0D; + d2 = (double) this.d + 0.5D + ((double) this.a.m.nextFloat() - 0.5D) * 2.0D; + this.a.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.a.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + + entityliving.D(); + this.d(); + } + } + } + + super.b(); + } + } + } + + private void d() { + this.e = 200 + this.a.m.nextInt(600); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.f = nbttagcompound.h("EntityId"); + this.e = nbttagcompound.c("Delay"); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.a("EntityId", this.f); + nbttagcompound.a("Delay", (short) this.e); + } +} diff --git a/net/minecraft/server/TileEntitySign.java b/net/minecraft/server/TileEntitySign.java new file mode 100644 index 000000000..720239f6d --- /dev/null +++ b/net/minecraft/server/TileEntitySign.java @@ -0,0 +1,28 @@ +package net.minecraft.server; + +public class TileEntitySign extends TileEntity { + + public String[] e = new String[] { "", "", "", ""}; + public int f = -1; + + public TileEntitySign() {} + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.a("Text1", this.e[0]); + nbttagcompound.a("Text2", this.e[1]); + nbttagcompound.a("Text3", this.e[2]); + nbttagcompound.a("Text4", this.e[3]); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + + for (int i = 0; i < 4; ++i) { + this.e[i] = nbttagcompound.h("Text" + (i + 1)); + if (this.e[i].length() > 15) { + this.e[i] = this.e[i].substring(0, 15); + } + } + } +} diff --git a/net/minecraft/server/Vec3D.java b/net/minecraft/server/Vec3D.java new file mode 100644 index 000000000..d5f6bec5c --- /dev/null +++ b/net/minecraft/server/Vec3D.java @@ -0,0 +1,138 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.List; + +public class Vec3D { + + private static List d = new ArrayList(); + private static int e = 0; + public double a; + public double b; + public double c; + + public static Vec3D a(double d0, double d1, double d2) { + return new Vec3D(d0, d1, d2); + } + + public static void a() { + e = 0; + } + + public static Vec3D b(double d0, double d1, double d2) { + if (e >= d.size()) { + d.add(a(0.0D, 0.0D, 0.0D)); + } + + return ((Vec3D) d.get(e++)).e(d0, d1, d2); + } + + private Vec3D(double d0, double d1, double d2) { + if (d0 == -0.0D) { + d0 = 0.0D; + } + + if (d1 == -0.0D) { + d1 = 0.0D; + } + + if (d2 == -0.0D) { + d2 = 0.0D; + } + + this.a = d0; + this.b = d1; + this.c = d2; + } + + private Vec3D e(double d0, double d1, double d2) { + this.a = d0; + this.b = d1; + this.c = d2; + return this; + } + + public Vec3D b() { + double d0 = (double) MathHelper.a(this.a * this.a + this.b * this.b + this.c * this.c); + + return d0 < 1.0E-4D ? b(0.0D, 0.0D, 0.0D) : b(this.a / d0, this.b / d0, this.c / d0); + } + + public Vec3D c(double d0, double d1, double d2) { + return b(this.a + d0, this.b + d1, this.c + d2); + } + + public double a(Vec3D vec3d) { + double d0 = vec3d.a - this.a; + double d1 = vec3d.b - this.b; + double d2 = vec3d.c - this.c; + + return (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); + } + + public double b(Vec3D vec3d) { + double d0 = vec3d.a - this.a; + double d1 = vec3d.b - this.b; + double d2 = vec3d.c - this.c; + + return d0 * d0 + d1 * d1 + d2 * d2; + } + + public double d(double d0, double d1, double d2) { + double d3 = d0 - this.a; + double d4 = d1 - this.b; + double d5 = d2 - this.c; + + return d3 * d3 + d4 * d4 + d5 * d5; + } + + public double c() { + return (double) MathHelper.a(this.a * this.a + this.b * this.b + this.c * this.c); + } + + public Vec3D a(Vec3D vec3d, double d0) { + double d1 = vec3d.a - this.a; + double d2 = vec3d.b - this.b; + double d3 = vec3d.c - this.c; + + if (d1 * d1 < 1.0000000116860974E-7D) { + return null; + } else { + double d4 = (d0 - this.a) / d1; + + return d4 >= 0.0D && d4 <= 1.0D ? b(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null; + } + } + + public Vec3D b(Vec3D vec3d, double d0) { + double d1 = vec3d.a - this.a; + double d2 = vec3d.b - this.b; + double d3 = vec3d.c - this.c; + + if (d2 * d2 < 1.0000000116860974E-7D) { + return null; + } else { + double d4 = (d0 - this.b) / d2; + + return d4 >= 0.0D && d4 <= 1.0D ? b(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null; + } + } + + public Vec3D c(Vec3D vec3d, double d0) { + double d1 = vec3d.a - this.a; + double d2 = vec3d.b - this.b; + double d3 = vec3d.c - this.c; + + if (d3 * d3 < 1.0000000116860974E-7D) { + return null; + } else { + double d4 = (d0 - this.c) / d3; + + return d4 >= 0.0D && d4 <= 1.0D ? b(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null; + } + } + + public String toString() { + return "(" + this.a + ", " + this.b + ", " + this.c + ")"; + } +} diff --git a/net/minecraft/server/World.java b/net/minecraft/server/World.java new file mode 100644 index 000000000..37737df52 --- /dev/null +++ b/net/minecraft/server/World.java @@ -0,0 +1,1745 @@ +package net.minecraft.server; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.TreeSet; + +public class World implements IBlockAccess { + + private List y; + public List a; + private List z; + private TreeSet A; + private Set B; + public List b; + public long c; + public boolean d; + private long C; + private long D; + private long E; + public int e; + protected int f; + protected int g; + public boolean h; + public static float[] i = new float[16]; + private final long F; + protected int j; + public List k; + public int l; + public Random m; + public int n; + public int o; + public int p; + public boolean q; + protected List r; + private IChunkProvider G; + public File s; + public long t; + private NBTTagCompound H; + public long u; + public final String v; + public boolean w; + private ArrayList I; + private Set J; + private int K; + private List L; + public boolean x; + + public World(File file1, String s) { + this(file1, s, (new Random()).nextLong()); + } + + public World(String s) { + this.y = new ArrayList(); + this.a = new ArrayList(); + this.z = new ArrayList(); + this.A = new TreeSet(); + this.B = new HashSet(); + this.b = new ArrayList(); + this.c = 0L; + this.d = false; + this.C = 8961023L; + this.D = 12638463L; + this.E = 16777215L; + this.e = 0; + this.f = (new Random()).nextInt(); + this.g = 1013904223; + this.h = false; + this.F = System.currentTimeMillis(); + this.j = 40; + this.k = new ArrayList(); + this.m = new Random(); + this.q = false; + this.r = new ArrayList(); + this.t = 0L; + this.u = 0L; + this.I = new ArrayList(); + this.J = new HashSet(); + this.K = this.m.nextInt(12000); + this.L = new ArrayList(); + this.x = false; + this.v = s; + this.G = this.a(this.s); + this.d(); + } + + public World(File file1, String s, long i) { + this.y = new ArrayList(); + this.a = new ArrayList(); + this.z = new ArrayList(); + this.A = new TreeSet(); + this.B = new HashSet(); + this.b = new ArrayList(); + this.c = 0L; + this.d = false; + this.C = 8961023L; + this.D = 12638463L; + this.E = 16777215L; + this.e = 0; + this.f = (new Random()).nextInt(); + this.g = 1013904223; + this.h = false; + this.F = System.currentTimeMillis(); + this.j = 40; + this.k = new ArrayList(); + this.m = new Random(); + this.q = false; + this.r = new ArrayList(); + this.t = 0L; + this.u = 0L; + this.I = new ArrayList(); + this.J = new HashSet(); + this.K = this.m.nextInt(12000); + this.L = new ArrayList(); + this.x = false; + this.v = s; + file1.mkdirs(); + this.s = new File(file1, s); + this.s.mkdirs(); + + File file2; + + try { + file2 = new File(this.s, "session.lock"); + DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file2)); + + try { + dataoutputstream.writeLong(this.F); + } finally { + dataoutputstream.close(); + } + } catch (IOException ioexception) { + throw new RuntimeException("Failed to check session lock, aborting"); + } + + file2 = new File(this.s, "level.dat"); + this.q = !file2.exists(); + if (file2.exists()) { + try { + NBTTagCompound nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file2))); + NBTTagCompound nbttagcompound1 = nbttagcompound.j("Data"); + + this.t = nbttagcompound1.e("RandomSeed"); + this.n = nbttagcompound1.d("SpawnX"); + this.o = nbttagcompound1.d("SpawnY"); + this.p = nbttagcompound1.d("SpawnZ"); + this.c = nbttagcompound1.e("Time"); + this.u = nbttagcompound1.e("SizeOnDisk"); + this.d = nbttagcompound1.l("SnowCovered"); + if (nbttagcompound1.a("Player")) { + this.H = nbttagcompound1.j("Player"); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + } else { + this.d = this.m.nextInt(4) == 0; + } + + boolean flag = false; + + if (this.t == 0L) { + this.t = i; + flag = true; + } + + this.G = this.a(this.s); + if (flag) { + this.w = true; + this.n = 0; + this.o = 64; + + for (this.p = 0; !this.e(this.n, this.p); this.p += this.m.nextInt(64) - this.m.nextInt(64)) { + this.n += this.m.nextInt(64) - this.m.nextInt(64); + } + + this.w = false; + } + + this.d(); + } + + protected IChunkProvider a(File file1) { + return new ChunkProviderLoadOrGenerate(this, new ChunkLoader(file1, true), new ChunkProviderGenerate(this, this.t)); + } + + private boolean e(int i, int j) { + int k = this.f(i, j); + + return k == Block.SAND.bc; + } + + private int f(int i, int j) { + int k; + + for (k = 63; this.a(i, k + 1, j) != 0; ++k) { + ; + } + + return this.a(i, k, j); + } + + public void a(boolean flag, IProgressUpdate iprogressupdate) { + if (this.G.b()) { + if (iprogressupdate != null) { + iprogressupdate.a("Saving level"); + } + + this.h(); + if (iprogressupdate != null) { + iprogressupdate.b("Saving chunks"); + } + + this.G.a(flag, iprogressupdate); + } + } + + private void h() { + this.g(); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + nbttagcompound.a("RandomSeed", this.t); + nbttagcompound.a("SpawnX", this.n); + nbttagcompound.a("SpawnY", this.o); + nbttagcompound.a("SpawnZ", this.p); + nbttagcompound.a("Time", this.c); + nbttagcompound.a("SizeOnDisk", this.u); + nbttagcompound.a("SnowCovered", this.d); + nbttagcompound.a("LastPlayed", System.currentTimeMillis()); + EntityHuman entityhuman = null; + + if (this.k.size() > 0) { + entityhuman = (EntityHuman) this.k.get(0); + } + + NBTTagCompound nbttagcompound1; + + if (entityhuman != null) { + nbttagcompound1 = new NBTTagCompound(); + entityhuman.d(nbttagcompound1); + nbttagcompound.a("Player", nbttagcompound1); + } + + nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.a("Data", (NBTBase) nbttagcompound); + + try { + File file1 = new File(this.s, "level.dat_new"); + File file2 = new File(this.s, "level.dat_old"); + File file3 = new File(this.s, "level.dat"); + + CompressedStreamTools.a(nbttagcompound1, (OutputStream) (new FileOutputStream(file1))); + if (file2.exists()) { + file2.delete(); + } + + file3.renameTo(file2); + if (file3.exists()) { + file3.delete(); + } + + file1.renameTo(file3); + if (file1.exists()) { + file1.delete(); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + public int a(int i, int j, int k) { + return i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000 ? (j < 0 ? 0 : (j >= 128 ? 0 : this.b(i >> 4, k >> 4).a(i & 15, j, k & 15))) : 0; + } + + public boolean e(int i, int j, int k) { + return j >= 0 && j < 128 ? this.g(i >> 4, k >> 4) : false; + } + + public boolean a(int i, int j, int k, int l, int i1, int j1) { + if (i1 >= 0 && j < 128) { + i >>= 4; + j >>= 4; + k >>= 4; + l >>= 4; + i1 >>= 4; + j1 >>= 4; + + for (int k1 = i; k1 <= l; ++k1) { + for (int l1 = k; l1 <= j1; ++l1) { + if (!this.g(k1, l1)) { + return false; + } + } + } + + return true; + } else { + return false; + } + } + + private boolean g(int i, int j) { + return this.G.a(i, j); + } + + public Chunk a(int i, int j) { + return this.b(i >> 4, j >> 4); + } + + public Chunk b(int i, int j) { + return this.G.b(i, j); + } + + public boolean a(int i, int j, int k, int l, int i1) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j < 0) { + return false; + } else if (j >= 128) { + return false; + } else { + Chunk chunk = this.b(i >> 4, k >> 4); + + return chunk.a(i & 15, j, k & 15, l, i1); + } + } else { + return false; + } + } + + public boolean a(int i, int j, int k, int l) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j < 0) { + return false; + } else if (j >= 128) { + return false; + } else { + Chunk chunk = this.b(i >> 4, k >> 4); + + return chunk.a(i & 15, j, k & 15, l); + } + } else { + return false; + } + } + + public Material c(int i, int j, int k) { + int l = this.a(i, j, k); + + return l == 0 ? Material.a : Block.n[l].bn; + } + + public int b(int i, int j, int k) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j < 0) { + return 0; + } else if (j >= 128) { + return 0; + } else { + Chunk chunk = this.b(i >> 4, k >> 4); + + i &= 15; + k &= 15; + return chunk.b(i, j, k); + } + } else { + return 0; + } + } + + public void b(int i, int j, int k, int l) { + this.c(i, j, k, l); + } + + public boolean c(int i, int j, int k, int l) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j < 0) { + return false; + } else if (j >= 128) { + return false; + } else { + Chunk chunk = this.b(i >> 4, k >> 4); + + i &= 15; + k &= 15; + chunk.b(i, j, k, l); + return true; + } + } else { + return false; + } + } + + public boolean d(int i, int j, int k, int l) { + if (this.a(i, j, k, l)) { + this.e(i, j, k, l); + return true; + } else { + return false; + } + } + + public boolean b(int i, int j, int k, int l, int i1) { + if (this.a(i, j, k, l, i1)) { + this.e(i, j, k, l); + return true; + } else { + return false; + } + } + + public void f(int i, int j, int k) { + for (int l = 0; l < this.r.size(); ++l) { + ((IWorldAccess) this.r.get(l)).a(i, j, k); + } + } + + protected void e(int i, int j, int k, int l) { + this.f(i, j, k); + this.g(i, j, k, l); + } + + public void f(int i, int j, int k, int l) { + if (k > l) { + int i1 = l; + + l = k; + k = i1; + } + + this.b(i, k, j, i, l, j); + } + + public void b(int i, int j, int k, int l, int i1, int j1) { + for (int k1 = 0; k1 < this.r.size(); ++k1) { + ((IWorldAccess) this.r.get(k1)).a(i, j, k, l, i1, j1); + } + } + + public void g(int i, int j, int k, int l) { + this.k(i - 1, j, k, l); + this.k(i + 1, j, k, l); + this.k(i, j - 1, k, l); + this.k(i, j + 1, k, l); + this.k(i, j, k - 1, l); + this.k(i, j, k + 1, l); + } + + private void k(int i, int j, int k, int l) { + if (!this.h && !this.x) { + Block block = Block.n[this.a(i, j, k)]; + + if (block != null) { + block.b(this, i, j, k, l); + } + } + } + + public boolean g(int i, int j, int k) { + return this.b(i >> 4, k >> 4).c(i & 15, j, k & 15); + } + + public int h(int i, int j, int k) { + return this.a(i, j, k, true); + } + + public int a(int i, int j, int k, boolean flag) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + int l; + + if (flag) { + l = this.a(i, j, k); + if (l == Block.STEP.bc || l == Block.SOIL.bc) { + int i1 = this.a(i, j + 1, k, false); + int j1 = this.a(i + 1, j, k, false); + int k1 = this.a(i - 1, j, k, false); + int l1 = this.a(i, j, k + 1, false); + int i2 = this.a(i, j, k - 1, false); + + if (j1 > i1) { + i1 = j1; + } + + if (k1 > i1) { + i1 = k1; + } + + if (l1 > i1) { + i1 = l1; + } + + if (i2 > i1) { + i1 = i2; + } + + return i1; + } + } + + if (j < 0) { + return 0; + } else if (j >= 128) { + l = 15 - this.e; + if (l < 0) { + l = 0; + } + + return l; + } else { + Chunk chunk = this.b(i >> 4, k >> 4); + + i &= 15; + k &= 15; + return chunk.c(i, j, k, this.e); + } + } else { + return 15; + } + } + + public boolean i(int i, int j, int k) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j < 0) { + return false; + } else if (j >= 128) { + return true; + } else if (!this.g(i >> 4, k >> 4)) { + return false; + } else { + Chunk chunk = this.b(i >> 4, k >> 4); + + i &= 15; + k &= 15; + return chunk.c(i, j, k); + } + } else { + return false; + } + } + + public int c(int i, int j) { + if (i >= -32000000 && j >= -32000000 && i < 32000000 && j <= 32000000) { + if (!this.g(i >> 4, j >> 4)) { + return 0; + } else { + Chunk chunk = this.b(i >> 4, j >> 4); + + return chunk.b(i & 15, j & 15); + } + } else { + return 0; + } + } + + public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { + if (this.e(i, j, k)) { + if (enumskyblock == EnumSkyBlock.SKY) { + if (this.i(i, j, k)) { + l = 15; + } + } else if (enumskyblock == EnumSkyBlock.BLOCK) { + int i1 = this.a(i, j, k); + + if (Block.t[i1] > l) { + l = Block.t[i1]; + } + } + + if (this.a(enumskyblock, i, j, k) != l) { + this.a(enumskyblock, i, j, k, i, j, k); + } + } + } + + public int a(EnumSkyBlock enumskyblock, int i, int j, int k) { + if (j >= 0 && j < 128 && i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + int l = i >> 4; + int i1 = k >> 4; + + if (!this.g(l, i1)) { + return 0; + } else { + Chunk chunk = this.b(l, i1); + + return chunk.a(enumskyblock, i & 15, j, k & 15); + } + } else { + return enumskyblock.c; + } + } + + public void b(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { + if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j >= 0) { + if (j < 128) { + if (this.g(i >> 4, k >> 4)) { + Chunk chunk = this.b(i >> 4, k >> 4); + + chunk.a(enumskyblock, i & 15, j, k & 15, l); + + for (int i1 = 0; i1 < this.r.size(); ++i1) { + ((IWorldAccess) this.r.get(i1)).a(i, j, k); + } + } + } + } + } + } + + public float j(int i, int j, int k) { + return i[this.h(i, j, k)]; + } + + public boolean a() { + return this.e < 4; + } + + public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { + return this.a(vec3d, vec3d1, false); + } + + public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1, boolean flag) { + if (!Double.isNaN(vec3d.a) && !Double.isNaN(vec3d.b) && !Double.isNaN(vec3d.c)) { + if (!Double.isNaN(vec3d1.a) && !Double.isNaN(vec3d1.b) && !Double.isNaN(vec3d1.c)) { + int i = MathHelper.b(vec3d1.a); + int j = MathHelper.b(vec3d1.b); + int k = MathHelper.b(vec3d1.c); + int l = MathHelper.b(vec3d.a); + int i1 = MathHelper.b(vec3d.b); + int j1 = MathHelper.b(vec3d.c); + int k1 = 20; + + while (k1-- >= 0) { + if (Double.isNaN(vec3d.a) || Double.isNaN(vec3d.b) || Double.isNaN(vec3d.c)) { + return null; + } + + if (l == i && i1 == j && j1 == k) { + return null; + } + + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if (i > l) { + d0 = (double) l + 1.0D; + } + + if (i < l) { + d0 = (double) l + 0.0D; + } + + if (j > i1) { + d1 = (double) i1 + 1.0D; + } + + if (j < i1) { + d1 = (double) i1 + 0.0D; + } + + if (k > j1) { + d2 = (double) j1 + 1.0D; + } + + if (k < j1) { + d2 = (double) j1 + 0.0D; + } + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + double d6 = vec3d1.a - vec3d.a; + double d7 = vec3d1.b - vec3d.b; + double d8 = vec3d1.c - vec3d.c; + + if (d0 != 999.0D) { + d3 = (d0 - vec3d.a) / d6; + } + + if (d1 != 999.0D) { + d4 = (d1 - vec3d.b) / d7; + } + + if (d2 != 999.0D) { + d5 = (d2 - vec3d.c) / d8; + } + + boolean flag1 = false; + byte b0; + + if (d3 < d4 && d3 < d5) { + if (i > l) { + b0 = 4; + } else { + b0 = 5; + } + + vec3d.a = d0; + vec3d.b += d7 * d3; + vec3d.c += d8 * d3; + } else if (d4 < d5) { + if (j > i1) { + b0 = 0; + } else { + b0 = 1; + } + + vec3d.a += d6 * d4; + vec3d.b = d1; + vec3d.c += d8 * d4; + } else { + if (k > j1) { + b0 = 2; + } else { + b0 = 3; + } + + vec3d.a += d6 * d5; + vec3d.b += d7 * d5; + vec3d.c = d2; + } + + Vec3D vec3d2 = Vec3D.b(vec3d.a, vec3d.b, vec3d.c); + + l = (int) (vec3d2.a = (double) MathHelper.b(vec3d.a)); + if (b0 == 5) { + --l; + ++vec3d2.a; + } + + i1 = (int) (vec3d2.b = (double) MathHelper.b(vec3d.b)); + if (b0 == 1) { + --i1; + ++vec3d2.b; + } + + j1 = (int) (vec3d2.c = (double) MathHelper.b(vec3d.c)); + if (b0 == 3) { + --j1; + ++vec3d2.c; + } + + int l1 = this.a(l, i1, j1); + int i2 = this.b(l, i1, j1); + Block block = Block.n[l1]; + + if (l1 > 0 && block.a(i2, flag)) { + MovingObjectPosition movingobjectposition = block.a(this, l, i1, j1, vec3d, vec3d1); + + if (movingobjectposition != null) { + return movingobjectposition; + } + } + } + + return null; + } else { + return null; + } + } else { + return null; + } + } + + public void a(Entity entity, String s, float f, float f1) { + for (int i = 0; i < this.r.size(); ++i) { + ((IWorldAccess) this.r.get(i)).a(s, entity.l, entity.m - (double) entity.C, entity.n, f, f1); + } + } + + public void a(double d0, double d1, double d2, String s, float f, float f1) { + for (int i = 0; i < this.r.size(); ++i) { + ((IWorldAccess) this.r.get(i)).a(s, d0, d1, d2, f, f1); + } + } + + public void a(String s, int i, int j, int k) { + for (int l = 0; l < this.r.size(); ++l) { + ((IWorldAccess) this.r.get(l)).a(s, i, j, k); + } + } + + public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) { + for (int i = 0; i < this.r.size(); ++i) { + ((IWorldAccess) this.r.get(i)).a(s, d0, d1, d2, d3, d4, d5); + } + } + + public boolean a(Entity entity) { + int i = MathHelper.b(entity.l / 16.0D); + int j = MathHelper.b(entity.n / 16.0D); + boolean flag = false; + + if (entity instanceof EntityHuman) { + flag = true; + } + + if (!flag && !this.g(i, j)) { + return false; + } else { + if (entity instanceof EntityHuman) { + this.k.add((EntityHuman) entity); + System.out.println("Player count: " + this.k.size()); + } + + this.b(i, j).a(entity); + this.a.add(entity); + this.b(entity); + return true; + } + } + + protected void b(Entity entity) { + for (int i = 0; i < this.r.size(); ++i) { + ((IWorldAccess) this.r.get(i)).a(entity); + } + } + + protected void c(Entity entity) { + for (int i = 0; i < this.r.size(); ++i) { + ((IWorldAccess) this.r.get(i)).b(entity); + } + } + + public void d(Entity entity) { + entity.j(); + if (entity instanceof EntityHuman) { + this.k.remove((EntityHuman) entity); + System.out.println("Player count: " + this.k.size()); + } + } + + public void a(IWorldAccess iworldaccess) { + this.r.add(iworldaccess); + } + + public List a(Entity entity, AxisAlignedBB axisalignedbb) { + this.I.clear(); + int i = MathHelper.b(axisalignedbb.a); + int j = MathHelper.b(axisalignedbb.d + 1.0D); + int k = MathHelper.b(axisalignedbb.b); + int l = MathHelper.b(axisalignedbb.e + 1.0D); + int i1 = MathHelper.b(axisalignedbb.c); + int j1 = MathHelper.b(axisalignedbb.f + 1.0D); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = i1; l1 < j1; ++l1) { + if (this.e(k1, 64, l1)) { + for (int i2 = k - 1; i2 < l; ++i2) { + Block block = Block.n[this.a(k1, i2, l1)]; + + if (block != null) { + block.a(this, k1, i2, l1, axisalignedbb, this.I); + } + } + } + } + } + + double d0 = 0.25D; + List list = this.b(entity, axisalignedbb.b(d0, d0, d0)); + + for (int j2 = 0; j2 < list.size(); ++j2) { + AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).n(); + + if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { + this.I.add(axisalignedbb1); + } + + axisalignedbb1 = entity.d((Entity) list.get(j2)); + if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { + this.I.add(axisalignedbb1); + } + } + + return this.I; + } + + public int a(float f) { + float f1 = this.b(f); + float f2 = 1.0F - (MathHelper.b(f1 * 3.1415927F * 2.0F) * 2.0F + 0.5F); + + if (f2 < 0.0F) { + f2 = 0.0F; + } + + if (f2 > 1.0F) { + f2 = 1.0F; + } + + return (int) (f2 * 11.0F); + } + + public float b(float f) { + int i = (int) (this.c % 24000L); + float f1 = ((float) i + f) / 24000.0F - 0.25F; + + if (f1 < 0.0F) { + ++f1; + } + + if (f1 > 1.0F) { + --f1; + } + + float f2 = f1; + + f1 = 1.0F - (float) ((Math.cos((double) f1 * 3.141592653589793D) + 1.0D) / 2.0D); + f1 = f2 + (f1 - f2) / 3.0F; + return f1; + } + + public int d(int i, int j) { + Chunk chunk = this.a(i, j); + int k = 127; + + i &= 15; + + for (j &= 15; k > 0; --k) { + int l = chunk.a(i, k, j); + + if (l != 0 && (Block.n[l].bn.c() || Block.n[l].bn.d())) { + return k + 1; + } + } + + return -1; + } + + public void h(int i, int j, int k, int l) { + NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, l); + byte b0 = 8; + + if (this.a(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { + if (l > 0) { + nextticklistentry.a((long) Block.n[l].c() + this.c); + } + + if (!this.B.contains(nextticklistentry)) { + this.B.add(nextticklistentry); + this.A.add(nextticklistentry); + } + } + } + + public void b() { + this.a.removeAll(this.z); + + int i; + Entity entity; + int j; + int k; + + for (i = 0; i < this.z.size(); ++i) { + entity = (Entity) this.z.get(i); + j = entity.aa; + k = entity.ac; + if (entity.Z && this.g(j, k)) { + this.b(j, k).b(entity); + } + } + + for (i = 0; i < this.z.size(); ++i) { + this.c((Entity) this.z.get(i)); + } + + this.z.clear(); + + for (i = 0; i < this.a.size(); ++i) { + entity = (Entity) this.a.get(i); + if (entity.g != null) { + if (!entity.g.B && entity.g.f == entity) { + continue; + } + + entity.g.f = null; + entity.g = null; + } + + if (!entity.B) { + this.e(entity); + } + + if (entity.B) { + j = entity.aa; + k = entity.ac; + if (entity.Z && this.g(j, k)) { + this.b(j, k).b(entity); + } + + this.a.remove(i--); + this.c(entity); + } + } + + for (i = 0; i < this.b.size(); ++i) { + TileEntity tileentity = (TileEntity) this.b.get(i); + + tileentity.b(); + } + } + + protected void e(Entity entity) { + int i = MathHelper.b(entity.l); + int j = MathHelper.b(entity.n); + byte b0 = 16; + + if (this.a(i - b0, 0, j - b0, i + b0, 128, j + b0)) { + entity.J = entity.l; + entity.K = entity.m; + entity.L = entity.n; + entity.t = entity.r; + entity.u = entity.s; + if (entity.g != null) { + entity.v(); + } else { + entity.b_(); + } + + int k = MathHelper.b(entity.l / 16.0D); + int l = MathHelper.b(entity.m / 16.0D); + int i1 = MathHelper.b(entity.n / 16.0D); + + if (!entity.Z || entity.aa != k || entity.ab != l || entity.ac != i1) { + if (entity.Z && this.g(entity.aa, entity.ac)) { + this.b(entity.aa, entity.ac).a(entity, entity.ab); + } + + if (this.g(k, i1)) { + this.b(k, i1).a(entity); + } else { + entity.Z = false; + System.out.println("Removing entity because it\'s not in a chunk!!"); + entity.j(); + } + } + + if (entity.f != null) { + if (!entity.f.B && entity.f.g == entity) { + this.e(entity.f); + } else { + entity.f.g = null; + entity.f = null; + } + } + + if (Double.isNaN(entity.l) || Double.isInfinite(entity.l)) { + entity.l = entity.J; + } + + if (Double.isNaN(entity.m) || Double.isInfinite(entity.m)) { + entity.m = entity.K; + } + + if (Double.isNaN(entity.n) || Double.isInfinite(entity.n)) { + entity.n = entity.L; + } + + if (Double.isNaN((double) entity.s) || Double.isInfinite((double) entity.s)) { + entity.s = entity.u; + } + + if (Double.isNaN((double) entity.r) || Double.isInfinite((double) entity.r)) { + entity.r = entity.t; + } + } + } + + public boolean a(AxisAlignedBB axisalignedbb) { + List list = this.b((Entity) null, axisalignedbb); + + for (int i = 0; i < list.size(); ++i) { + Entity entity = (Entity) list.get(i); + + if (!entity.B && entity.e) { + return false; + } + } + + return true; + } + + public boolean b(AxisAlignedBB axisalignedbb) { + int i = MathHelper.b(axisalignedbb.a); + int j = MathHelper.b(axisalignedbb.d + 1.0D); + int k = MathHelper.b(axisalignedbb.b); + int l = MathHelper.b(axisalignedbb.e + 1.0D); + int i1 = MathHelper.b(axisalignedbb.c); + int j1 = MathHelper.b(axisalignedbb.f + 1.0D); + + if (axisalignedbb.a < 0.0D) { + --i; + } + + if (axisalignedbb.b < 0.0D) { + --k; + } + + if (axisalignedbb.c < 0.0D) { + --i1; + } + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + Block block = Block.n[this.a(k1, l1, i2)]; + + if (block != null && block.bn.d()) { + return true; + } + } + } + } + + return false; + } + + public boolean c(AxisAlignedBB axisalignedbb) { + int i = MathHelper.b(axisalignedbb.a); + int j = MathHelper.b(axisalignedbb.d + 1.0D); + int k = MathHelper.b(axisalignedbb.b); + int l = MathHelper.b(axisalignedbb.e + 1.0D); + int i1 = MathHelper.b(axisalignedbb.c); + int j1 = MathHelper.b(axisalignedbb.f + 1.0D); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + int j2 = this.a(k1, l1, i2); + + if (j2 == Block.FIRE.bc || j2 == Block.LAVA.bc || j2 == Block.STATIONARY_LAVA.bc) { + return true; + } + } + } + } + + return false; + } + + public boolean a(AxisAlignedBB axisalignedbb, Material material, Entity entity) { + int i = MathHelper.b(axisalignedbb.a); + int j = MathHelper.b(axisalignedbb.d + 1.0D); + int k = MathHelper.b(axisalignedbb.b); + int l = MathHelper.b(axisalignedbb.e + 1.0D); + int i1 = MathHelper.b(axisalignedbb.c); + int j1 = MathHelper.b(axisalignedbb.f + 1.0D); + boolean flag = false; + Vec3D vec3d = Vec3D.b(0.0D, 0.0D, 0.0D); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + Block block = Block.n[this.a(k1, l1, i2)]; + + if (block != null && block.bn == material) { + double d0 = (double) ((float) (l1 + 1) - BlockFluids.b(this.b(k1, l1, i2))); + + if ((double) l >= d0) { + flag = true; + block.a(this, k1, l1, i2, entity, vec3d); + } + } + } + } + } + + if (vec3d.c() > 0.0D) { + vec3d = vec3d.b(); + double d1 = 0.0040D; + + entity.o += vec3d.a * d1; + entity.p += vec3d.b * d1; + entity.q += vec3d.c * d1; + } + + return flag; + } + + public boolean a(AxisAlignedBB axisalignedbb, Material material) { + int i = MathHelper.b(axisalignedbb.a); + int j = MathHelper.b(axisalignedbb.d + 1.0D); + int k = MathHelper.b(axisalignedbb.b); + int l = MathHelper.b(axisalignedbb.e + 1.0D); + int i1 = MathHelper.b(axisalignedbb.c); + int j1 = MathHelper.b(axisalignedbb.f + 1.0D); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + Block block = Block.n[this.a(k1, l1, i2)]; + + if (block != null && block.bn == material) { + return true; + } + } + } + } + + return false; + } + + public boolean b(AxisAlignedBB axisalignedbb, Material material) { + int i = MathHelper.b(axisalignedbb.a); + int j = MathHelper.b(axisalignedbb.d + 1.0D); + int k = MathHelper.b(axisalignedbb.b); + int l = MathHelper.b(axisalignedbb.e + 1.0D); + int i1 = MathHelper.b(axisalignedbb.c); + int j1 = MathHelper.b(axisalignedbb.f + 1.0D); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + Block block = Block.n[this.a(k1, l1, i2)]; + + if (block != null && block.bn == material) { + int j2 = this.b(k1, l1, i2); + double d0 = (double) (l1 + 1); + + if (j2 < 8) { + d0 = (double) (l1 + 1) - (double) j2 / 8.0D; + } + + if (d0 >= axisalignedbb.b) { + return true; + } + } + } + } + } + + return false; + } + + public void a(Entity entity, double d0, double d1, double d2, float f) { + (new Explosion()).a(this, entity, d0, d1, d2, f); + } + + public float a(Vec3D vec3d, AxisAlignedBB axisalignedbb) { + double d0 = 1.0D / ((axisalignedbb.d - axisalignedbb.a) * 2.0D + 1.0D); + double d1 = 1.0D / ((axisalignedbb.e - axisalignedbb.b) * 2.0D + 1.0D); + double d2 = 1.0D / ((axisalignedbb.f - axisalignedbb.c) * 2.0D + 1.0D); + int i = 0; + int j = 0; + + for (float f = 0.0F; f <= 1.0F; f = (float) ((double) f + d0)) { + for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float) ((double) f1 + d1)) { + for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float) ((double) f2 + d2)) { + double d3 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) f; + double d4 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) f1; + double d5 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) f2; + + if (this.a(Vec3D.b(d3, d4, d5), vec3d) == null) { + ++i; + } + + ++j; + } + } + } + + return (float) i / (float) j; + } + + public TileEntity k(int i, int j, int k) { + Chunk chunk = this.b(i >> 4, k >> 4); + + return chunk != null ? chunk.d(i & 15, j, k & 15) : null; + } + + public void a(int i, int j, int k, TileEntity tileentity) { + Chunk chunk = this.b(i >> 4, k >> 4); + + if (chunk != null) { + chunk.a(i & 15, j, k & 15, tileentity); + } + } + + public void l(int i, int j, int k) { + Chunk chunk = this.b(i >> 4, k >> 4); + + if (chunk != null) { + chunk.e(i & 15, j, k & 15); + } + } + + public boolean d(int i, int j, int k) { + Block block = Block.n[this.a(i, j, k)]; + + return block == null ? false : block.b(); + } + + public boolean c() { + int i = 1000; + + while (this.y.size() > 0) { + --i; + if (i <= 0) { + return true; + } + + ((MetadataChunkBlock) this.y.remove(this.y.size() - 1)).a(this); + } + + return false; + } + + public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1) { + this.a(enumskyblock, i, j, k, l, i1, j1, true); + } + + public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1, boolean flag) { + int k1 = (l + i) / 2; + int l1 = (j1 + k) / 2; + + if (this.e(k1, 64, l1)) { + int i2 = this.y.size(); + + if (flag) { + int j2 = 4; + + if (j2 > i2) { + j2 = i2; + } + + for (int k2 = 0; k2 < j2; ++k2) { + MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.y.get(this.y.size() - k2 - 1); + + if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) { + return; + } + } + } + + this.y.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1)); + if (this.y.size() > 100000) { + while (this.y.size() > '\uc350') { + this.c(); + } + } + } + } + + public void d() { + int i = this.a(1.0F); + + if (i != this.e) { + this.e = i; + } + } + + public void e() { + this.G.a(); + int i = this.a(1.0F); + + if (i != this.e) { + this.e = i; + + for (int j = 0; j < this.r.size(); ++j) { + ((IWorldAccess) this.r.get(j)).a(); + } + } + + ++this.c; + if (this.c % (long) this.j == 0L) { + this.a(false, (IProgressUpdate) null); + } + + this.a(false); + this.f(); + } + + protected void f() { + this.J.clear(); + + int i; + int j; + int k; + int l; + + for (int i1 = 0; i1 < this.k.size(); ++i1) { + EntityHuman entityhuman = (EntityHuman) this.k.get(i1); + + i = MathHelper.b(entityhuman.l / 16.0D); + j = MathHelper.b(entityhuman.n / 16.0D); + byte b0 = 9; + + for (k = -b0; k <= b0; ++k) { + for (l = -b0; l <= b0; ++l) { + this.J.add(new ChunkCoordIntPair(k + i, l + j)); + } + } + } + + if (this.K > 0) { + --this.K; + } + + Iterator iterator = this.J.iterator(); + + while (iterator.hasNext()) { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); + + i = chunkcoordintpair.a * 16; + j = chunkcoordintpair.b * 16; + Chunk chunk = this.b(chunkcoordintpair.a, chunkcoordintpair.b); + int j1; + int k1; + int l1; + + if (this.K == 0) { + this.f = this.f * 3 + this.g; + k = this.f >> 2; + l = k & 15; + j1 = k >> 8 & 15; + k1 = k >> 16 & 127; + l1 = chunk.a(l, k1, j1); + l += i; + j1 += j; + if (l1 == 0 && this.h(l, k1, j1) <= this.m.nextInt(8) && this.a(EnumSkyBlock.SKY, l, k1, j1) <= 0) { + EntityHuman entityhuman1 = this.a((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, 8.0D); + + if (entityhuman1 != null && entityhuman1.d((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D) > 4.0D) { + this.a((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.m.nextFloat() * 0.2F); + this.K = this.m.nextInt(12000) + 6000; + } + } + } + + if (this.d && this.m.nextInt(4) == 0) { + this.f = this.f * 3 + this.g; + k = this.f >> 2; + l = k & 15; + j1 = k >> 8 & 15; + k1 = this.d(l + i, j1 + j); + if (k1 >= 0 && k1 < 128 && chunk.a(EnumSkyBlock.BLOCK, l, k1, j1) < 10) { + l1 = chunk.a(l, k1 - 1, j1); + if (chunk.a(l, k1, j1) == 0 && Block.SNOW.a(this, l + i, k1, j1 + j)) { + this.d(l + i, k1, j1 + j, Block.SNOW.bc); + } + + if (l1 == Block.STATIONARY_WATER.bc && chunk.b(l, k1 - 1, j1) == 0) { + this.d(l + i, k1 - 1, j1 + j, Block.ICE.bc); + } + } + } + + for (k = 0; k < 80; ++k) { + this.f = this.f * 3 + this.g; + l = this.f >> 2; + j1 = l & 15; + k1 = l >> 8 & 15; + l1 = l >> 16 & 127; + byte b1 = chunk.b[j1 << 11 | k1 << 7 | l1]; + + if (Block.o[b1]) { + Block.n[b1].a(this, j1 + i, l1, k1 + j, this.m); + } + } + } + } + + public boolean a(boolean flag) { + int i = this.A.size(); + + if (i != this.B.size()) { + throw new IllegalStateException("TickNextTick list out of synch"); + } else { + if (i > 1000) { + i = 1000; + } + + for (int j = 0; j < i; ++j) { + NextTickListEntry nextticklistentry = (NextTickListEntry) this.A.first(); + + if (!flag && nextticklistentry.e > this.c) { + break; + } + + this.A.remove(nextticklistentry); + this.B.remove(nextticklistentry); + byte b0 = 8; + + if (this.a(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { + int k = this.a(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); + + if (k == nextticklistentry.d && k > 0) { + Block.n[k].a(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.m); + } + } + } + + return this.A.size() != 0; + } + } + + public List b(Entity entity, AxisAlignedBB axisalignedbb) { + this.L.clear(); + int i = MathHelper.b((axisalignedbb.a - 2.0D) / 16.0D); + int j = MathHelper.b((axisalignedbb.d + 2.0D) / 16.0D); + int k = MathHelper.b((axisalignedbb.c - 2.0D) / 16.0D); + int l = MathHelper.b((axisalignedbb.f + 2.0D) / 16.0D); + + for (int i1 = i; i1 <= j; ++i1) { + for (int j1 = k; j1 <= l; ++j1) { + if (this.g(i1, j1)) { + this.b(i1, j1).a(entity, axisalignedbb, this.L); + } + } + } + + return this.L; + } + + public List a(Class oclass, AxisAlignedBB axisalignedbb) { + int i = MathHelper.b((axisalignedbb.a - 2.0D) / 16.0D); + int j = MathHelper.b((axisalignedbb.d + 2.0D) / 16.0D); + int k = MathHelper.b((axisalignedbb.c - 2.0D) / 16.0D); + int l = MathHelper.b((axisalignedbb.f + 2.0D) / 16.0D); + ArrayList arraylist = new ArrayList(); + + for (int i1 = i; i1 <= j; ++i1) { + for (int j1 = k; j1 <= l; ++j1) { + if (this.g(i1, j1)) { + this.b(i1, j1).a(oclass, axisalignedbb, arraylist); + } + } + } + + return arraylist; + } + + public void b(int i, int j, int k, TileEntity tileentity) { + if (this.e(i, j, k)) { + this.a(i, k).e(); + } + + for (int l = 0; l < this.r.size(); ++l) { + ((IWorldAccess) this.r.get(l)).a(i, j, k, tileentity); + } + } + + public int a(Class oclass) { + int i = 0; + + for (int j = 0; j < this.a.size(); ++j) { + Entity entity = (Entity) this.a.get(j); + + if (oclass.isAssignableFrom(entity.getClass())) { + ++i; + } + } + + return i; + } + + public void a(List list) { + this.a.addAll(list); + + for (int i = 0; i < list.size(); ++i) { + this.b((Entity) list.get(i)); + } + } + + public void b(List list) { + this.z.addAll(list); + } + + public boolean a(int i, int j, int k, int l, boolean flag) { + int i1 = this.a(j, k, l); + Block block = Block.n[i1]; + Block block1 = Block.n[i]; + AxisAlignedBB axisalignedbb = block1.d(this, j, k, l); + + if (flag) { + axisalignedbb = null; + } + + return axisalignedbb != null && !this.a(axisalignedbb) ? false : (block != Block.WATER && block != Block.STATIONARY_WATER && block != Block.LAVA && block != Block.STATIONARY_LAVA && block != Block.FIRE && block != Block.SNOW ? i > 0 && block == null && block1.a(this, j, k, l) : true); + } + + public PathEntity a(Entity entity, Entity entity1, float f) { + int i = MathHelper.b(entity.l); + int j = MathHelper.b(entity.m); + int k = MathHelper.b(entity.n); + int l = (int) (f + 16.0F); + int i1 = i - l; + int j1 = j - l; + int k1 = k - l; + int l1 = i + l; + int i2 = j + l; + int j2 = k + l; + ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2); + + return (new Pathfinder(chunkcache)).a(entity, entity1, f); + } + + public PathEntity a(Entity entity, int i, int j, int k, float f) { + int l = MathHelper.b(entity.l); + int i1 = MathHelper.b(entity.m); + int j1 = MathHelper.b(entity.n); + int k1 = (int) (f + 8.0F); + int l1 = l - k1; + int i2 = i1 - k1; + int j2 = j1 - k1; + int k2 = l + k1; + int l2 = i1 + k1; + int i3 = j1 + k1; + ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3); + + return (new Pathfinder(chunkcache)).a(entity, i, j, k, f); + } + + public boolean i(int i, int j, int k, int l) { + int i1 = this.a(i, j, k); + + return i1 == 0 ? false : Block.n[i1].d(this, i, j, k, l); + } + + public boolean m(int i, int j, int k) { + return this.i(i, j - 1, k, 0) ? true : (this.i(i, j + 1, k, 1) ? true : (this.i(i, j, k - 1, 2) ? true : (this.i(i, j, k + 1, 3) ? true : (this.i(i - 1, j, k, 4) ? true : this.i(i + 1, j, k, 5))))); + } + + public boolean j(int i, int j, int k, int l) { + if (this.d(i, j, k)) { + return this.m(i, j, k); + } else { + int i1 = this.a(i, j, k); + + return i1 == 0 ? false : Block.n[i1].b((IBlockAccess) this, i, j, k, l); + } + } + + public boolean n(int i, int j, int k) { + return this.j(i, j - 1, k, 0) ? true : (this.j(i, j + 1, k, 1) ? true : (this.j(i, j, k - 1, 2) ? true : (this.j(i, j, k + 1, 3) ? true : (this.j(i - 1, j, k, 4) ? true : this.j(i + 1, j, k, 5))))); + } + + public EntityHuman a(Entity entity, double d0) { + return this.a(entity.l, entity.m, entity.n, d0); + } + + public EntityHuman a(double d0, double d1, double d2, double d3) { + double d4 = -1.0D; + EntityHuman entityhuman = null; + + for (int i = 0; i < this.k.size(); ++i) { + EntityHuman entityhuman1 = (EntityHuman) this.k.get(i); + double d5 = entityhuman1.d(d0, d1, d2); + + if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { + d4 = d5; + entityhuman = entityhuman1; + } + } + + return entityhuman; + } + + public byte[] c(int i, int j, int k, int l, int i1, int j1) { + byte[] abyte = new byte[l * i1 * j1 * 5 / 2]; + int k1 = i >> 4; + int l1 = k >> 4; + int i2 = i + l - 1 >> 4; + int j2 = k + j1 - 1 >> 4; + int k2 = 0; + int l2 = j; + int i3 = j + i1; + + if (j < 0) { + l2 = 0; + } + + if (i3 > 128) { + i3 = 128; + } + + for (int j3 = k1; j3 <= i2; ++j3) { + int k3 = i - j3 * 16; + int l3 = i + l - j3 * 16; + + if (k3 < 0) { + k3 = 0; + } + + if (l3 > 16) { + l3 = 16; + } + + for (int i4 = l1; i4 <= j2; ++i4) { + int j4 = k - i4 * 16; + int k4 = k + j1 - i4 * 16; + + if (j4 < 0) { + j4 = 0; + } + + if (k4 > 16) { + k4 = 16; + } + + k2 = this.b(j3, i4).a(abyte, k3, l2, j4, l3, i3, k4, k2); + } + } + + return abyte; + } + + public void g() { + try { + File file1 = new File(this.s, "session.lock"); + DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1)); + + try { + if (datainputstream.readLong() != this.F) { + throw new MinecraftException("The save is being accessed from another location, aborting"); + } + } finally { + datainputstream.close(); + } + } catch (IOException ioexception) { + throw new MinecraftException("Failed to check session lock, aborting"); + } + } + + static { + float f = 0.05F; + + for (int i = 0; i <= 15; ++i) { + float f1 = 1.0F - (float) i / 15.0F; + + i[i] = (1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f; + } + } +} diff --git a/net/minecraft/server/WorldGenBigTree.java b/net/minecraft/server/WorldGenBigTree.java new file mode 100644 index 000000000..9f21332e9 --- /dev/null +++ b/net/minecraft/server/WorldGenBigTree.java @@ -0,0 +1,357 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenBigTree extends WorldGenerator { + + static final byte[] a = new byte[] { (byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1}; + Random b = new Random(); + World c; + int[] d = new int[] { 0, 0, 0}; + int e = 0; + int f; + double g = 0.618D; + double h = 1.0D; + double i = 0.381D; + double j = 1.0D; + double k = 1.0D; + int l = 1; + int m = 12; + int n = 4; + int[][] o; + + public WorldGenBigTree() {} + + void a() { + this.f = (int) ((double) this.e * this.g); + if (this.f >= this.e) { + this.f = this.e - 1; + } + + int i = (int) (1.382D + Math.pow(this.k * (double) this.e / 13.0D, 2.0D)); + + if (i < 1) { + i = 1; + } + + int[][] aint = new int[i * this.e][4]; + int j = this.d[1] + this.e - this.n; + int k = 1; + int l = this.d[1] + this.f; + int i1 = j - this.d[1]; + + aint[0][0] = this.d[0]; + aint[0][1] = j; + aint[0][2] = this.d[2]; + aint[0][3] = l; + --j; + + while (i1 >= 0) { + int j1 = 0; + float f = this.a(i1); + + if (f < 0.0F) { + --j; + --i1; + } else { + for (double d0 = 0.5D; j1 < i; ++j1) { + double d1 = this.j * (double) f * ((double) this.b.nextFloat() + 0.328D); + double d2 = (double) this.b.nextFloat() * 2.0D * 3.14159D; + int k1 = (int) (d1 * Math.sin(d2) + (double) this.d[0] + d0); + int l1 = (int) (d1 * Math.cos(d2) + (double) this.d[2] + d0); + int[] aint1 = new int[] { k1, j, l1}; + int[] aint2 = new int[] { k1, j + this.n, l1}; + + if (this.a(aint1, aint2) == -1) { + int[] aint3 = new int[] { this.d[0], this.d[1], this.d[2]}; + double d3 = Math.sqrt(Math.pow((double) Math.abs(this.d[0] - aint1[0]), 2.0D) + Math.pow((double) Math.abs(this.d[2] - aint1[2]), 2.0D)); + double d4 = d3 * this.i; + + if ((double) aint1[1] - d4 > (double) l) { + aint3[1] = l; + } else { + aint3[1] = (int) ((double) aint1[1] - d4); + } + + if (this.a(aint3, aint1) == -1) { + aint[k][0] = k1; + aint[k][1] = j; + aint[k][2] = l1; + aint[k][3] = aint3[1]; + ++k; + } + } + } + + --j; + --i1; + } + } + + this.o = new int[k][4]; + System.arraycopy(aint, 0, this.o, 0, k); + } + + void a(int i, int j, int k, float f, byte b0, int l) { + int i1 = (int) ((double) f + 0.618D); + byte b1 = a[b0]; + byte b2 = a[b0 + 3]; + int[] aint = new int[] { i, j, k}; + int[] aint1 = new int[] { 0, 0, 0}; + int j1 = -i1; + int k1 = -i1; + + for (aint1[b0] = aint[b0]; j1 <= i1; ++j1) { + aint1[b1] = aint[b1] + j1; + k1 = -i1; + + while (k1 <= i1) { + double d0 = Math.sqrt(Math.pow((double) Math.abs(j1) + 0.5D, 2.0D) + Math.pow((double) Math.abs(k1) + 0.5D, 2.0D)); + + if (d0 > (double) f) { + ++k1; + } else { + aint1[b2] = aint[b2] + k1; + int l1 = this.c.a(aint1[0], aint1[1], aint1[2]); + + if (l1 != 0 && l1 != 18) { + ++k1; + } else { + this.c.a(aint1[0], aint1[1], aint1[2], l); + ++k1; + } + } + } + } + } + + float a(int i) { + if ((double) i < (double) ((float) this.e) * 0.3D) { + return -1.618F; + } else { + float f = (float) this.e / 2.0F; + float f1 = (float) this.e / 2.0F - (float) i; + float f2; + + if (f1 == 0.0F) { + f2 = f; + } else if (Math.abs(f1) >= f) { + f2 = 0.0F; + } else { + f2 = (float) Math.sqrt(Math.pow((double) Math.abs(f), 2.0D) - Math.pow((double) Math.abs(f1), 2.0D)); + } + + f2 *= 0.5F; + return f2; + } + } + + float b(int i) { + return i >= 0 && i < this.n ? (i != 0 && i != this.n - 1 ? 3.0F : 2.0F) : -1.0F; + } + + void a(int i, int j, int k) { + int l = j; + + for (int i1 = j + this.n; l < i1; ++l) { + float f = this.b(l - j); + + this.a(i, l, k, f, (byte) 1, 18); + } + } + + void a(int[] aint, int[] aint1, int i) { + int[] aint2 = new int[] { 0, 0, 0}; + byte b0 = 0; + + byte b1; + + for (b1 = 0; b0 < 3; ++b0) { + aint2[b0] = aint1[b0] - aint[b0]; + if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) { + b1 = b0; + } + } + + if (aint2[b1] != 0) { + byte b2 = a[b1]; + byte b3 = a[b1 + 3]; + byte b4; + + if (aint2[b1] > 0) { + b4 = 1; + } else { + b4 = -1; + } + + double d0 = (double) aint2[b2] / (double) aint2[b1]; + double d1 = (double) aint2[b3] / (double) aint2[b1]; + int[] aint3 = new int[] { 0, 0, 0}; + int j = 0; + + for (int k = aint2[b1] + b4; j != k; j += b4) { + aint3[b1] = MathHelper.b((double) (aint[b1] + j) + 0.5D); + aint3[b2] = MathHelper.b((double) aint[b2] + (double) j * d0 + 0.5D); + aint3[b3] = MathHelper.b((double) aint[b3] + (double) j * d1 + 0.5D); + this.c.a(aint3[0], aint3[1], aint3[2], i); + } + } + } + + void b() { + int i = 0; + + for (int j = this.o.length; i < j; ++i) { + int k = this.o[i][0]; + int l = this.o[i][1]; + int i1 = this.o[i][2]; + + this.a(k, l, i1); + } + } + + boolean c(int i) { + return (double) i >= (double) this.e * 0.2D; + } + + void c() { + int i = this.d[0]; + int j = this.d[1]; + int k = this.d[1] + this.f; + int l = this.d[2]; + int[] aint = new int[] { i, j, l}; + int[] aint1 = new int[] { i, k, l}; + + this.a(aint, aint1, 17); + if (this.l == 2) { + ++aint[0]; + ++aint1[0]; + this.a(aint, aint1, 17); + ++aint[2]; + ++aint1[2]; + this.a(aint, aint1, 17); + aint[0] += -1; + aint1[0] += -1; + this.a(aint, aint1, 17); + } + } + + void d() { + int i = 0; + int j = this.o.length; + + for (int[] aint = new int[] { this.d[0], this.d[1], this.d[2]}; i < j; ++i) { + int[] aint1 = this.o[i]; + int[] aint2 = new int[] { aint1[0], aint1[1], aint1[2]}; + + aint[1] = aint1[3]; + int k = aint[1] - this.d[1]; + + if (this.c(k)) { + this.a(aint, aint2, 17); + } + } + } + + int a(int[] aint, int[] aint1) { + int[] aint2 = new int[] { 0, 0, 0}; + byte b0 = 0; + + byte b1; + + for (b1 = 0; b0 < 3; ++b0) { + aint2[b0] = aint1[b0] - aint[b0]; + if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) { + b1 = b0; + } + } + + if (aint2[b1] == 0) { + return -1; + } else { + byte b2 = a[b1]; + byte b3 = a[b1 + 3]; + byte b4; + + if (aint2[b1] > 0) { + b4 = 1; + } else { + b4 = -1; + } + + double d0 = (double) aint2[b2] / (double) aint2[b1]; + double d1 = (double) aint2[b3] / (double) aint2[b1]; + int[] aint3 = new int[] { 0, 0, 0}; + int i = 0; + + int j; + + for (j = aint2[b1] + b4; i != j; i += b4) { + aint3[b1] = aint[b1] + i; + aint3[b2] = (int) ((double) aint[b2] + (double) i * d0); + aint3[b3] = (int) ((double) aint[b3] + (double) i * d1); + int k = this.c.a(aint3[0], aint3[1], aint3[2]); + + if (k != 0 && k != 18) { + break; + } + } + + return i == j ? -1 : Math.abs(i); + } + } + + boolean e() { + int[] aint = new int[] { this.d[0], this.d[1], this.d[2]}; + int[] aint1 = new int[] { this.d[0], this.d[1] + this.e - 1, this.d[2]}; + int i = this.c.a(this.d[0], this.d[1] - 1, this.d[2]); + + if (i != 2 && i != 3) { + return false; + } else { + int j = this.a(aint, aint1); + + if (j == -1) { + return true; + } else if (j < 6) { + return false; + } else { + this.e = j; + return true; + } + } + } + + public void a(double d0, double d1, double d2) { + this.m = (int) (d0 * 12.0D); + if (d0 > 0.5D) { + this.n = 5; + } + + this.j = d1; + this.k = d2; + } + + public boolean a(World world, Random random, int i, int j, int k) { + this.c = world; + long l = random.nextLong(); + + this.b.setSeed(l); + this.d[0] = i; + this.d[1] = j; + this.d[2] = k; + if (this.e == 0) { + this.e = 5 + this.b.nextInt(this.m); + } + + if (!this.e()) { + return false; + } else { + this.a(); + this.b(); + this.c(); + this.d(); + return true; + } + } +} diff --git a/net/minecraft/server/WorldGenCactus.java b/net/minecraft/server/WorldGenCactus.java new file mode 100644 index 000000000..6f30eed5a --- /dev/null +++ b/net/minecraft/server/WorldGenCactus.java @@ -0,0 +1,28 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenCactus extends WorldGenerator { + + public WorldGenCactus() {} + + public boolean a(World world, Random random, int i, int j, int k) { + for (int l = 0; l < 10; ++l) { + int i1 = i + random.nextInt(8) - random.nextInt(8); + int j1 = j + random.nextInt(4) - random.nextInt(4); + int k1 = k + random.nextInt(8) - random.nextInt(8); + + if (world.a(i1, j1, k1) == 0) { + int l1 = 1 + random.nextInt(random.nextInt(3) + 1); + + for (int i2 = 0; i2 < l1; ++i2) { + if (Block.CACTUS.f(world, i1, j1 + i2, k1)) { + world.a(i1, j1 + i2, k1, Block.CACTUS.bc); + } + } + } + } + + return true; + } +} diff --git a/net/minecraft/server/WorldGenClay.java b/net/minecraft/server/WorldGenClay.java new file mode 100644 index 000000000..5cb908e9f --- /dev/null +++ b/net/minecraft/server/WorldGenClay.java @@ -0,0 +1,57 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenClay extends WorldGenerator { + + private int a; + private int b; + + public WorldGenClay(int i) { + this.a = Block.CLAY.bc; + this.b = i; + } + + public boolean a(World world, Random random, int i, int j, int k) { + if (world.c(i, j, k) != Material.f) { + return false; + } else { + float f = random.nextFloat() * 3.1415927F; + double d0 = (double) ((float) (i + 8) + MathHelper.a(f) * (float) this.b / 8.0F); + double d1 = (double) ((float) (i + 8) - MathHelper.a(f) * (float) this.b / 8.0F); + double d2 = (double) ((float) (k + 8) + MathHelper.b(f) * (float) this.b / 8.0F); + double d3 = (double) ((float) (k + 8) - MathHelper.b(f) * (float) this.b / 8.0F); + double d4 = (double) (j + random.nextInt(3) + 2); + double d5 = (double) (j + random.nextInt(3) + 2); + + for (int l = 0; l <= this.b; ++l) { + double d6 = d0 + (d1 - d0) * (double) l / (double) this.b; + double d7 = d4 + (d5 - d4) * (double) l / (double) this.b; + double d8 = d2 + (d3 - d2) * (double) l / (double) this.b; + double d9 = random.nextDouble() * (double) this.b / 16.0D; + double d10 = (double) (MathHelper.a((float) l * 3.1415927F / (float) this.b) + 1.0F) * d9 + 1.0D; + double d11 = (double) (MathHelper.a((float) l * 3.1415927F / (float) this.b) + 1.0F) * d9 + 1.0D; + + for (int i1 = (int) (d6 - d10 / 2.0D); i1 <= (int) (d6 + d10 / 2.0D); ++i1) { + for (int j1 = (int) (d7 - d11 / 2.0D); j1 <= (int) (d7 + d11 / 2.0D); ++j1) { + for (int k1 = (int) (d8 - d10 / 2.0D); k1 <= (int) (d8 + d10 / 2.0D); ++k1) { + double d12 = ((double) i1 + 0.5D - d6) / (d10 / 2.0D); + double d13 = ((double) j1 + 0.5D - d7) / (d11 / 2.0D); + double d14 = ((double) k1 + 0.5D - d8) / (d10 / 2.0D); + + if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D) { + int l1 = world.a(i1, j1, k1); + + if (l1 == Block.SAND.bc) { + world.a(i1, j1, k1, this.a); + } + } + } + } + } + } + + return true; + } + } +} diff --git a/net/minecraft/server/WorldGenDungeons.java b/net/minecraft/server/WorldGenDungeons.java new file mode 100644 index 000000000..3fb3274a6 --- /dev/null +++ b/net/minecraft/server/WorldGenDungeons.java @@ -0,0 +1,134 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenDungeons extends WorldGenerator { + + public WorldGenDungeons() {} + + public boolean a(World world, Random random, int i, int j, int k) { + byte b0 = 3; + int l = random.nextInt(2) + 2; + int i1 = random.nextInt(2) + 2; + int j1 = 0; + + int k1; + int l1; + int i2; + + for (k1 = i - l - 1; k1 <= i + l + 1; ++k1) { + for (l1 = j - 1; l1 <= j + b0 + 1; ++l1) { + for (i2 = k - i1 - 1; i2 <= k + i1 + 1; ++i2) { + Material material = world.c(k1, l1, i2); + + if (l1 == j - 1 && !material.a()) { + return false; + } + + if (l1 == j + b0 + 1 && !material.a()) { + return false; + } + + if ((k1 == i - l - 1 || k1 == i + l + 1 || i2 == k - i1 - 1 || i2 == k + i1 + 1) && l1 == j && world.a(k1, l1, i2) == 0 && world.a(k1, l1 + 1, i2) == 0) { + ++j1; + } + } + } + } + + if (j1 >= 1 && j1 <= 5) { + for (k1 = i - l - 1; k1 <= i + l + 1; ++k1) { + for (l1 = j + b0; l1 >= j - 1; --l1) { + for (i2 = k - i1 - 1; i2 <= k + i1 + 1; ++i2) { + if (k1 != i - l - 1 && l1 != j - 1 && i2 != k - i1 - 1 && k1 != i + l + 1 && l1 != j + b0 + 1 && i2 != k + i1 + 1) { + world.d(k1, l1, i2, 0); + } else if (l1 >= 0 && !world.c(k1, l1 - 1, i2).a()) { + world.d(k1, l1, i2, 0); + } else if (world.c(k1, l1, i2).a()) { + if (l1 == j - 1 && random.nextInt(4) != 0) { + world.d(k1, l1, i2, Block.MOSSY_COBBLESTONE.bc); + } else { + world.d(k1, l1, i2, Block.COBBLESTONE.bc); + } + } + } + } + } + + k1 = 0; + + while (k1 < 2) { + l1 = 0; + + while (true) { + if (l1 < 3) { + label204: { + i2 = i + random.nextInt(l * 2 + 1) - l; + int j2 = k + random.nextInt(i1 * 2 + 1) - i1; + + if (world.a(i2, j, j2) == 0) { + int k2 = 0; + + if (world.c(i2 - 1, j, j2).a()) { + ++k2; + } + + if (world.c(i2 + 1, j, j2).a()) { + ++k2; + } + + if (world.c(i2, j, j2 - 1).a()) { + ++k2; + } + + if (world.c(i2, j, j2 + 1).a()) { + ++k2; + } + + if (k2 == 1) { + world.d(i2, j, j2, Block.CHEST.bc); + TileEntityChest tileentitychest = (TileEntityChest) world.k(i2, j, j2); + + for (int l2 = 0; l2 < 8; ++l2) { + ItemStack itemstack = this.a(random); + + if (itemstack != null) { + tileentitychest.a(random.nextInt(tileentitychest.a()), itemstack); + } + } + break label204; + } + } + + ++l1; + continue; + } + } + + ++k1; + break; + } + } + + world.d(i, j, k, Block.MOB_SPAWNER.bc); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world.k(i, j, k); + + tileentitymobspawner.f = this.b(random); + return true; + } else { + return false; + } + } + + private ItemStack a(Random random) { + int i = random.nextInt(11); + + return i == 0 ? new ItemStack(Item.SADDLE) : (i == 1 ? new ItemStack(Item.IRON_INGOT, random.nextInt(4) + 1) : (i == 2 ? new ItemStack(Item.BREAD) : (i == 3 ? new ItemStack(Item.WHEAT, random.nextInt(4) + 1) : (i == 4 ? new ItemStack(Item.SULPHUR, random.nextInt(4) + 1) : (i == 5 ? new ItemStack(Item.STRING, random.nextInt(4) + 1) : (i == 6 ? new ItemStack(Item.BUCKET) : (i == 7 && random.nextInt(100) == 0 ? new ItemStack(Item.GOLDEN_APPLE) : (i == 8 && random.nextInt(2) == 0 ? new ItemStack(Item.REDSTONE, random.nextInt(4) + 1) : (i == 9 && random.nextInt(10) == 0 ? new ItemStack(Item.c[Item.GOLD_RECORD.aS + random.nextInt(2)]) : null))))))))); + } + + private String b(Random random) { + int i = random.nextInt(4); + + return i == 0 ? "Skeleton" : (i == 1 ? "Zombie" : (i == 2 ? "Zombie" : (i == 3 ? "Spider" : ""))); + } +} diff --git a/net/minecraft/server/WorldGenFlowers.java b/net/minecraft/server/WorldGenFlowers.java new file mode 100644 index 000000000..2c0182aa2 --- /dev/null +++ b/net/minecraft/server/WorldGenFlowers.java @@ -0,0 +1,26 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenFlowers extends WorldGenerator { + + private int a; + + public WorldGenFlowers(int i) { + this.a = i; + } + + public boolean a(World world, Random random, int i, int j, int k) { + for (int l = 0; l < 64; ++l) { + int i1 = i + random.nextInt(8) - random.nextInt(8); + int j1 = j + random.nextInt(4) - random.nextInt(4); + int k1 = k + random.nextInt(8) - random.nextInt(8); + + if (world.a(i1, j1, k1) == 0 && ((BlockFlower) Block.n[this.a]).f(world, i1, j1, k1)) { + world.a(i1, j1, k1, this.a); + } + } + + return true; + } +} diff --git a/net/minecraft/server/WorldGenLiquids.java b/net/minecraft/server/WorldGenLiquids.java new file mode 100644 index 000000000..1fd3d9973 --- /dev/null +++ b/net/minecraft/server/WorldGenLiquids.java @@ -0,0 +1,64 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenLiquids extends WorldGenerator { + + private int a; + + public WorldGenLiquids(int i) { + this.a = i; + } + + public boolean a(World world, Random random, int i, int j, int k) { + if (world.a(i, j + 1, k) != Block.STONE.bc) { + return false; + } else if (world.a(i, j - 1, k) != Block.STONE.bc) { + return false; + } else if (world.a(i, j, k) != 0 && world.a(i, j, k) != Block.STONE.bc) { + return false; + } else { + int l = 0; + + if (world.a(i - 1, j, k) == Block.STONE.bc) { + ++l; + } + + if (world.a(i + 1, j, k) == Block.STONE.bc) { + ++l; + } + + if (world.a(i, j, k - 1) == Block.STONE.bc) { + ++l; + } + + if (world.a(i, j, k + 1) == Block.STONE.bc) { + ++l; + } + + int i1 = 0; + + if (world.a(i - 1, j, k) == 0) { + ++i1; + } + + if (world.a(i + 1, j, k) == 0) { + ++i1; + } + + if (world.a(i, j, k - 1) == 0) { + ++i1; + } + + if (world.a(i, j, k + 1) == 0) { + ++i1; + } + + if (l == 3 && i1 == 1) { + world.d(i, j, k, this.a); + } + + return true; + } + } +} diff --git a/net/minecraft/server/WorldGenMinable.java b/net/minecraft/server/WorldGenMinable.java new file mode 100644 index 000000000..7f89b941e --- /dev/null +++ b/net/minecraft/server/WorldGenMinable.java @@ -0,0 +1,49 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenMinable extends WorldGenerator { + + private int a; + private int b; + + public WorldGenMinable(int i, int j) { + this.a = i; + this.b = j; + } + + public boolean a(World world, Random random, int i, int j, int k) { + float f = random.nextFloat() * 3.1415927F; + double d0 = (double) ((float) (i + 8) + MathHelper.a(f) * (float) this.b / 8.0F); + double d1 = (double) ((float) (i + 8) - MathHelper.a(f) * (float) this.b / 8.0F); + double d2 = (double) ((float) (k + 8) + MathHelper.b(f) * (float) this.b / 8.0F); + double d3 = (double) ((float) (k + 8) - MathHelper.b(f) * (float) this.b / 8.0F); + double d4 = (double) (j + random.nextInt(3) + 2); + double d5 = (double) (j + random.nextInt(3) + 2); + + for (int l = 0; l <= this.b; ++l) { + double d6 = d0 + (d1 - d0) * (double) l / (double) this.b; + double d7 = d4 + (d5 - d4) * (double) l / (double) this.b; + double d8 = d2 + (d3 - d2) * (double) l / (double) this.b; + double d9 = random.nextDouble() * (double) this.b / 16.0D; + double d10 = (double) (MathHelper.a((float) l * 3.1415927F / (float) this.b) + 1.0F) * d9 + 1.0D; + double d11 = (double) (MathHelper.a((float) l * 3.1415927F / (float) this.b) + 1.0F) * d9 + 1.0D; + + for (int i1 = (int) (d6 - d10 / 2.0D); i1 <= (int) (d6 + d10 / 2.0D); ++i1) { + for (int j1 = (int) (d7 - d11 / 2.0D); j1 <= (int) (d7 + d11 / 2.0D); ++j1) { + for (int k1 = (int) (d8 - d10 / 2.0D); k1 <= (int) (d8 + d10 / 2.0D); ++k1) { + double d12 = ((double) i1 + 0.5D - d6) / (d10 / 2.0D); + double d13 = ((double) j1 + 0.5D - d7) / (d11 / 2.0D); + double d14 = ((double) k1 + 0.5D - d8) / (d10 / 2.0D); + + if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.a(i1, j1, k1) == Block.STONE.bc) { + world.a(i1, j1, k1, this.a); + } + } + } + } + } + + return true; + } +} diff --git a/net/minecraft/server/WorldGenReed.java b/net/minecraft/server/WorldGenReed.java new file mode 100644 index 000000000..bfab85196 --- /dev/null +++ b/net/minecraft/server/WorldGenReed.java @@ -0,0 +1,28 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenReed extends WorldGenerator { + + public WorldGenReed() {} + + public boolean a(World world, Random random, int i, int j, int k) { + for (int l = 0; l < 20; ++l) { + int i1 = i + random.nextInt(4) - random.nextInt(4); + int j1 = j; + int k1 = k + random.nextInt(4) - random.nextInt(4); + + if (world.a(i1, j, k1) == 0 && (world.c(i1 - 1, j - 1, k1) == Material.f || world.c(i1 + 1, j - 1, k1) == Material.f || world.c(i1, j - 1, k1 - 1) == Material.f || world.c(i1, j - 1, k1 + 1) == Material.f)) { + int l1 = 2 + random.nextInt(random.nextInt(3) + 1); + + for (int i2 = 0; i2 < l1; ++i2) { + if (Block.SUGAR_CANE_BLOCK.f(world, i1, j1 + i2, k1)) { + world.a(i1, j1 + i2, k1, Block.SUGAR_CANE_BLOCK.bc); + } + } + } + } + + return true; + } +} diff --git a/net/minecraft/server/WorldGenTrees.java b/net/minecraft/server/WorldGenTrees.java new file mode 100644 index 000000000..5ffb20a78 --- /dev/null +++ b/net/minecraft/server/WorldGenTrees.java @@ -0,0 +1,86 @@ +package net.minecraft.server; + +import java.util.Random; + +public class WorldGenTrees extends WorldGenerator { + + public WorldGenTrees() {} + + public boolean a(World world, Random random, int i, int j, int k) { + int l = random.nextInt(3) + 4; + boolean flag = true; + + if (j >= 1 && j + l + 1 <= 128) { + int i1; + int j1; + int k1; + int l1; + + for (i1 = j; i1 <= j + 1 + l; ++i1) { + byte b0 = 1; + + if (i1 == j) { + b0 = 0; + } + + if (i1 >= j + 1 + l - 2) { + b0 = 2; + } + + for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { + for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { + if (i1 >= 0 && i1 < 128) { + l1 = world.a(j1, i1, k1); + if (l1 != 0 && l1 != Block.LEAVES.bc) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + i1 = world.a(i, j - 1, k); + if ((i1 == Block.GRASS.bc || i1 == Block.DIRT.bc) && j < 128 - l - 1) { + world.a(i, j - 1, k, Block.DIRT.bc); + + int i2; + + for (i2 = j - 3 + l; i2 <= j + l; ++i2) { + j1 = i2 - (j + l); + k1 = 1 - j1 / 2; + + for (l1 = i - k1; l1 <= i + k1; ++l1) { + int j2 = l1 - i; + + for (int k2 = k - k1; k2 <= k + k1; ++k2) { + int l2 = k2 - k; + + if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.p[world.a(l1, i2, k2)]) { + world.a(l1, i2, k2, Block.LEAVES.bc); + } + } + } + } + + for (i2 = 0; i2 < l; ++i2) { + j1 = world.a(i, j + i2, k); + if (j1 == 0 || j1 == Block.LEAVES.bc) { + world.a(i, j + i2, k, Block.LOG.bc); + } + } + + return true; + } else { + return false; + } + } + } else { + return false; + } + } +} diff --git a/net/minecraft/server/WorldGenerator.java b/net/minecraft/server/WorldGenerator.java new file mode 100644 index 000000000..7d6590803 --- /dev/null +++ b/net/minecraft/server/WorldGenerator.java @@ -0,0 +1,12 @@ +package net.minecraft.server; + +import java.util.Random; + +public abstract class WorldGenerator { + + public WorldGenerator() {} + + public abstract boolean a(World world, Random random, int i, int j, int k); + + public void a(double d0, double d1, double d2) {} +} diff --git a/net/minecraft/server/WorldManager.java b/net/minecraft/server/WorldManager.java new file mode 100644 index 000000000..d9f2680d1 --- /dev/null +++ b/net/minecraft/server/WorldManager.java @@ -0,0 +1,36 @@ +package net.minecraft.server; + +public class WorldManager implements IWorldAccess { + + private MinecraftServer a; + + public WorldManager(MinecraftServer minecraftserver) { + this.a = minecraftserver; + } + + public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {} + + public void a(Entity entity) { + this.a.k.a(entity); + } + + public void b(Entity entity) { + this.a.k.b(entity); + } + + public void a(String s, double d0, double d1, double d2, float f, float f1) {} + + public void a(int i, int j, int k, int l, int i1, int j1) {} + + public void a() {} + + public void a(int i, int j, int k) { + this.a.f.a(i, j, k); + } + + public void a(String s, int i, int j, int k) {} + + public void a(int i, int j, int k, TileEntity tileentity) { + this.a.f.a(i, j, k, tileentity); + } +} diff --git a/net/minecraft/server/WorldServer.java b/net/minecraft/server/WorldServer.java new file mode 100644 index 000000000..e0fce55fa --- /dev/null +++ b/net/minecraft/server/WorldServer.java @@ -0,0 +1,48 @@ +package net.minecraft.server; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class WorldServer extends World { + + public ChunkProviderServer y; + public boolean z = false; + public boolean A; + private boolean B; + private SpawnerCreature C = new SpawnerMonsters(this, 200, IMonster.class, new Class[] { EntityZombie.class, EntitySkeleton.class, EntityCreeper.class, EntitySpider.class, EntitySlime.class}); + private SpawnerCreature D = new SpawnerCreature(15, EntityAnimal.class, new Class[] { EntitySheep.class, EntityPig.class, EntityCow.class, EntityChicken.class}); + + public WorldServer(File file1, String s, boolean flag) { + super(file1, s); + this.B = flag; + } + + public void e() { + super.e(); + if (this.B) { + this.C.a(this); + } + + this.D.a(this); + } + + protected IChunkProvider a(File file1) { + this.y = new ChunkProviderServer(this, new ChunkLoader(file1, true), new ChunkProviderGenerate(this, this.t)); + return this.y; + } + + public List d(int i, int j, int k, int l, int i1, int j1) { + ArrayList arraylist = new ArrayList(); + + for (int k1 = 0; k1 < this.b.size(); ++k1) { + TileEntity tileentity = (TileEntity) this.b.get(k1); + + if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) { + arraylist.add(tileentity); + } + } + + return arraylist; + } +} diff --git a/null b/null new file mode 100644 index 000000000..e69de29bb