diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java new file mode 100644 index 0000000000..818d2efd9e --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockCrops.java @@ -0,0 +1,120 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockCrops extends BlockFlower { + + protected BlockCrops(int i, int j) { + super(i, j); + this.textureId = 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 d(int i) { + return i == Block.SOIL.id; + } + + public void a(World world, int i, int j, int k, Random random) { + super.a(world, i, j, k, random); + if (world.getLightLevel(i, j + 1, k) >= 9) { + int l = world.getData(i, j, k); + + if (l < 7) { + float f = this.i(world, i, j, k); + + if (random.nextInt((int) (25.0F / f) + 1) == 0) { + ++l; + world.setData(i, j, k, l); + } + } + } + } + + public void g(World world, int i, int j, int k) { + world.setData(i, j, k, 7); + } + + private float i(World world, int i, int j, int k) { + float f = 1.0F; + int l = world.getTypeId(i, j, k - 1); + int i1 = world.getTypeId(i, j, k + 1); + int j1 = world.getTypeId(i - 1, j, k); + int k1 = world.getTypeId(i + 1, j, k); + int l1 = world.getTypeId(i - 1, j, k - 1); + int i2 = world.getTypeId(i + 1, j, k - 1); + int j2 = world.getTypeId(i + 1, j, k + 1); + int k2 = world.getTypeId(i - 1, j, k + 1); + boolean flag = j1 == this.id || k1 == this.id; + boolean flag1 = l == this.id || i1 == this.id; + boolean flag2 = l1 == this.id || i2 == this.id || j2 == this.id || k2 == this.id; + + for (int l2 = i - 1; l2 <= i + 1; ++l2) { + for (int i3 = k - 1; i3 <= k + 1; ++i3) { + int j3 = world.getTypeId(l2, j - 1, i3); + float f1 = 0.0F; + + if (j3 == Block.SOIL.id) { + f1 = 1.0F; + if (world.getData(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(int i, int j) { + if (j < 0) { + j = 7; + } + + return this.textureId + j; + } + + public int c() { + return 6; + } + + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { + super.dropNaturally(world, i, j, k, l, f, 0); + if (!world.isStatic) { + int j1 = 3 + i1; + + for (int k1 = 0; k1 < j1; ++k1) { + if (world.random.nextInt(15) <= l) { + float f1 = 0.7F; + float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; + float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; + float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; + EntityItem entityitem = new EntityItem(world, (double) ((float) i + f2), (double) ((float) j + f3), (double) ((float) k + f4), new ItemStack(Item.SEEDS)); + + entityitem.pickupDelay = 10; + world.addEntity(entityitem); + } + } + } + } + + public int getDropType(int i, Random random, int j) { + return i == 7 ? Item.WHEAT.id : -1; + } + + public int a(Random random) { + return 1; + } +} diff --git a/src/main/java/net/minecraft/server/BlockNetherWart.java b/src/main/java/net/minecraft/server/BlockNetherWart.java new file mode 100644 index 0000000000..f496853420 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockNetherWart.java @@ -0,0 +1,70 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockNetherWart extends BlockFlower { + + protected BlockNetherWart(int i) { + super(i, 226); + 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 d(int i) { + return i == Block.SOUL_SAND.id; + } + + public void a(World world, int i, int j, int k, Random random) { + int l = world.getData(i, j, k); + + if (l < 3) { + WorldChunkManager worldchunkmanager = world.getWorldChunkManager(); + + if (worldchunkmanager != null) { + BiomeBase biomebase = worldchunkmanager.getBiome(i, k); + + if (biomebase instanceof BiomeHell && random.nextInt(15) == 0) { + ++l; + world.setData(i, j, k, l); + } + } + } + + super.a(world, i, j, k, random); + } + + public int a(int i, int j) { + return j >= 3 ? this.textureId + 2 : (j > 0 ? this.textureId + 1 : this.textureId); + } + + public int c() { + return 6; + } + + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { + if (!world.isStatic) { + int j1 = 1; + + if (l >= 3) { + j1 = 2 + world.random.nextInt(3); + if (i1 > 0) { + j1 += world.random.nextInt(i1 + 1); + } + } + + for (int k1 = 0; k1 < j1; ++k1) { + this.a(world, i, j, k, new ItemStack(Item.NETHER_STALK)); + } + } + } + + public int getDropType(int i, Random random, int j) { + return 0; + } + + public int a(Random random) { + return 0; + } +} diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java new file mode 100644 index 0000000000..21afe6a332 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockReed.java @@ -0,0 +1,77 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockReed extends Block { + + protected BlockReed(int i, int j) { + super(i, Material.PLANT); + this.textureId = 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.isEmpty(i, j + 1, k)) { + int l; + + for (l = 1; world.getTypeId(i, j - l, k) == this.id; ++l) { + ; + } + + if (l < 3) { + int i1 = world.getData(i, j, k); + + if (i1 == 15) { + world.setTypeId(i, j + 1, k, this.id); + world.setData(i, j, k, 0); + } else { + world.setData(i, j, k, i1 + 1); + } + } + } + } + + public boolean canPlace(World world, int i, int j, int k) { + int l = world.getTypeId(i, j - 1, k); + + return l == this.id ? true : (l != Block.GRASS.id && l != Block.DIRT.id && l != Block.SAND.id ? false : (world.getMaterial(i - 1, j - 1, k) == Material.WATER ? true : (world.getMaterial(i + 1, j - 1, k) == Material.WATER ? true : (world.getMaterial(i, j - 1, k - 1) == Material.WATER ? true : world.getMaterial(i, j - 1, k + 1) == Material.WATER)))); + } + + public void doPhysics(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.b(world, i, j, k, world.getData(i, j, k), 0); + world.setTypeId(i, j, k, 0); + } + } + + public boolean f(World world, int i, int j, int k) { + return this.canPlace(world, i, j, k); + } + + public AxisAlignedBB e(World world, int i, int j, int k) { + return null; + } + + public int getDropType(int i, Random random, int j) { + return Item.SUGAR_CANE.id; + } + + public boolean a() { + return false; + } + + public boolean b() { + return false; + } + + public int c() { + return 1; + } +} diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java new file mode 100644 index 0000000000..388077778f --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockStem.java @@ -0,0 +1,185 @@ +package net.minecraft.server; + +import java.util.Random; + +public class BlockStem extends BlockFlower { + + private Block a; + + protected BlockStem(int i, Block block) { + super(i, 111); + this.a = block; + this.a(true); + float f = 0.125F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + } + + protected boolean d(int i) { + return i == Block.SOIL.id; + } + + public void a(World world, int i, int j, int k, Random random) { + super.a(world, i, j, k, random); + if (world.getLightLevel(i, j + 1, k) >= 9) { + float f = this.i(world, i, j, k); + + if (random.nextInt((int) (25.0F / f) + 1) == 0) { + int l = world.getData(i, j, k); + + if (l < 7) { + ++l; + world.setData(i, j, k, l); + } else { + if (world.getTypeId(i - 1, j, k) == this.a.id) { + return; + } + + if (world.getTypeId(i + 1, j, k) == this.a.id) { + return; + } + + if (world.getTypeId(i, j, k - 1) == this.a.id) { + return; + } + + if (world.getTypeId(i, j, k + 1) == this.a.id) { + return; + } + + int i1 = random.nextInt(4); + int j1 = i; + int k1 = k; + + if (i1 == 0) { + j1 = i - 1; + } + + if (i1 == 1) { + ++j1; + } + + if (i1 == 2) { + k1 = k - 1; + } + + if (i1 == 3) { + ++k1; + } + + int l1 = world.getTypeId(j1, j - 1, k1); + + if (world.getTypeId(j1, j, k1) == 0 && (l1 == Block.SOIL.id || l1 == Block.DIRT.id || l1 == Block.GRASS.id)) { + world.setTypeId(j1, j, k1, this.a.id); + } + } + } + } + } + + public void g(World world, int i, int j, int k) { + world.setData(i, j, k, 7); + } + + private float i(World world, int i, int j, int k) { + float f = 1.0F; + int l = world.getTypeId(i, j, k - 1); + int i1 = world.getTypeId(i, j, k + 1); + int j1 = world.getTypeId(i - 1, j, k); + int k1 = world.getTypeId(i + 1, j, k); + int l1 = world.getTypeId(i - 1, j, k - 1); + int i2 = world.getTypeId(i + 1, j, k - 1); + int j2 = world.getTypeId(i + 1, j, k + 1); + int k2 = world.getTypeId(i - 1, j, k + 1); + boolean flag = j1 == this.id || k1 == this.id; + boolean flag1 = l == this.id || i1 == this.id; + boolean flag2 = l1 == this.id || i2 == this.id || j2 == this.id || k2 == this.id; + + for (int l2 = i - 1; l2 <= i + 1; ++l2) { + for (int i3 = k - 1; i3 <= k + 1; ++i3) { + int j3 = world.getTypeId(l2, j - 1, i3); + float f1 = 0.0F; + + if (j3 == Block.SOIL.id) { + f1 = 1.0F; + if (world.getData(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(int i, int j) { + return this.textureId; + } + + public void f() { + float f = 0.125F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + } + + public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { + this.maxY = (double) ((float) (iblockaccess.getData(i, j, k) * 2 + 2) / 16.0F); + float f = 0.125F; + + this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float) this.maxY, 0.5F + f); + } + + public int c() { + return 19; + } + + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { + super.dropNaturally(world, i, j, k, l, f, i1); + if (!world.isStatic) { + Item item = null; + + if (this.a == Block.PUMPKIN) { + item = Item.PUMPKIN_SEEDS; + } + + if (this.a == Block.MELON) { + item = Item.MELON_SEEDS; + } + + for (int j1 = 0; j1 < 3; ++j1) { + if (world.random.nextInt(15) <= l) { + float f1 = 0.7F; + float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; + float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; + float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; + EntityItem entityitem = new EntityItem(world, (double) ((float) i + f2), (double) ((float) j + f3), (double) ((float) k + f4), new ItemStack(item)); + + entityitem.pickupDelay = 10; + world.addEntity(entityitem); + } + } + } + } + + public int getDropType(int i, Random random, int j) { + if (i == 7) { + ; + } + + return -1; + } + + public int a(Random random) { + return 1; + } +}