Initial commit
build-and-test / build (push) Has been cancelled
Java-Compatibility / build (17) (push) Has been cancelled
Java-Compatibility / build (21) (push) Has been cancelled
Release Workflow / build-and-release (push) Has been cancelled

This commit is contained in:
2026-09-20 01:56:07 +01:00
commit 82192a4802
943 changed files with 92762 additions and 0 deletions
@@ -0,0 +1,60 @@
package net.minecraft.server;
public class Achievement extends Statistic {
public final int a;
public final int b;
public final Achievement c;
private final String l;
public final ItemStack d;
private boolean m;
public Achievement(int i, String s, int j, int k, Item item, Achievement achievement) {
this(i, s, j, k, new ItemStack(item), achievement);
}
public Achievement(int i, String s, int j, int k, Block block, Achievement achievement) {
this(i, s, j, k, new ItemStack(block), achievement);
}
public Achievement(int i, String s, int j, int k, ItemStack itemstack, Achievement achievement) {
super(5242880 + i, StatisticCollector.a("achievement." + s));
this.d = itemstack;
this.l = StatisticCollector.a("achievement." + s + ".desc");
this.a = j;
this.b = k;
if (j < AchievementList.a) {
AchievementList.a = j;
}
if (k < AchievementList.b) {
AchievementList.b = k;
}
if (j > AchievementList.c) {
AchievementList.c = j;
}
if (k > AchievementList.d) {
AchievementList.d = k;
}
this.c = achievement;
}
public Achievement a() {
this.g = true;
return this;
}
public Achievement b() {
this.m = true;
return this;
}
public Achievement c() {
super.d();
AchievementList.e.add(this);
return this;
}
}
@@ -0,0 +1,37 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.List;
public class AchievementList {
public static int a;
public static int b;
public static int c;
public static int d;
public static List e = new ArrayList();
public static Achievement f = (new Achievement(0, "openInventory", 0, 0, Item.BOOK, (Achievement) null)).a().c();
public static Achievement g = (new Achievement(1, "mineWood", 2, 1, Block.LOG, f)).c();
public static Achievement h = (new Achievement(2, "buildWorkBench", 4, -1, Block.WORKBENCH, g)).c();
public static Achievement i = (new Achievement(3, "buildPickaxe", 4, 2, Item.WOOD_PICKAXE, h)).c();
public static Achievement j = (new Achievement(4, "buildFurnace", 3, 4, Block.BURNING_FURNACE, i)).c();
public static Achievement k = (new Achievement(5, "acquireIron", 1, 4, Item.IRON_INGOT, j)).c();
public static Achievement l = (new Achievement(6, "buildHoe", 2, -3, Item.WOOD_HOE, h)).c();
public static Achievement m = (new Achievement(7, "makeBread", -1, -3, Item.BREAD, l)).c();
public static Achievement n = (new Achievement(8, "bakeCake", 0, -5, Item.CAKE, l)).c();
public static Achievement o = (new Achievement(9, "buildBetterPickaxe", 6, 2, Item.STONE_PICKAXE, i)).c();
public static Achievement p = (new Achievement(10, "cookFish", 2, 6, Item.COOKED_FISH, j)).c();
public static Achievement q = (new Achievement(11, "onARail", 2, 3, Block.RAILS, k)).b().c();
public static Achievement r = (new Achievement(12, "buildSword", 6, -1, Item.WOOD_SWORD, h)).c();
public static Achievement s = (new Achievement(13, "killEnemy", 8, -1, Item.BONE, r)).c();
public static Achievement t = (new Achievement(14, "killCow", 7, -3, Item.LEATHER, r)).c();
public static Achievement u = (new Achievement(15, "flyPig", 8, -4, Item.SADDLE, t)).b().c();
public AchievementList() {}
public static void a() {}
static {
System.out.println(e.size() + " achievements");
}
}
@@ -0,0 +1,35 @@
package net.minecraft.server;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class AchievementMap {
public static AchievementMap a = new AchievementMap();
private Map b = new HashMap();
private AchievementMap() {
try {
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(AchievementMap.class.getResourceAsStream("/achievement/map.txt")));
String s;
while ((s = bufferedreader.readLine()) != null) {
String[] astring = s.split(",");
int i = Integer.parseInt(astring[0]);
this.b.put(Integer.valueOf(i), astring[1]);
}
bufferedreader.close();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public static String a(int i) {
return (String) a.b.get(Integer.valueOf(i));
}
}
@@ -0,0 +1,334 @@
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 boolean a(Vec3D vec3d) {
return vec3d.a > this.a && vec3d.a < this.d ? (vec3d.b > this.b && vec3d.b < this.e ? vec3d.c > this.c && vec3d.c < this.f : false) : false;
}
public AxisAlignedBB shrink(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 clone() {
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.b(vec3d2)) {
vec3d2 = null;
}
if (!this.b(vec3d3)) {
vec3d3 = null;
}
if (!this.c(vec3d4)) {
vec3d4 = null;
}
if (!this.c(vec3d5)) {
vec3d5 = null;
}
if (!this.d(vec3d6)) {
vec3d6 = null;
}
if (!this.d(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 b(Vec3D vec3d) {
return vec3d == null ? false : vec3d.b >= this.b && vec3d.b <= this.e && 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.c >= this.c && vec3d.c <= this.f;
}
private boolean d(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;
}
public String toString() {
return "box[" + this.a + ", " + this.b + ", " + this.c + " -> " + this.d + ", " + this.e + ", " + this.f + "]";
}
}
@@ -0,0 +1,10 @@
package net.minecraft.server;
public class BedBlockTextures {
public static final int[] a = new int[] { 3, 4, 2, 5};
public static final int[] b = new int[] { 2, 3, 0, 1};
public static final int[][] c = new int[][] { { 1, 0, 3, 2, 5, 4}, { 1, 0, 5, 4, 2, 3}, { 1, 0, 2, 3, 4, 5}, { 1, 0, 4, 5, 3, 2}};
public BedBlockTextures() {}
}
@@ -0,0 +1,121 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BiomeBase {
public static final BiomeBase RAINFOREST = (new BiomeRainforest()).b(588342).a("Rainforest").a(2094168);
public static final BiomeBase SWAMPLAND = (new BiomeSwamp()).b(522674).a("Swampland").a(9154376);
public static final BiomeBase SEASONAL_FOREST = (new BiomeBase()).b(10215459).a("Seasonal Forest");
public static final BiomeBase FOREST = (new BiomeForest()).b(353825).a("Forest").a(5159473);
public static final BiomeBase SAVANNA = (new BiomeDesert()).b(14278691).a("Savanna");
public static final BiomeBase SHRUBLAND = (new BiomeBase()).b(10595616).a("Shrubland");
public static final BiomeBase TAIGA = (new BiomeTaiga()).b(3060051).a("Taiga").b().a(8107825);
public static final BiomeBase DESERT = (new BiomeDesert()).b(16421912).a("Desert").e();
public static final BiomeBase PLAINS = (new BiomeDesert()).b(16767248).a("Plains");
public static final BiomeBase ICE_DESERT = (new BiomeDesert()).b(16772499).a("Ice Desert").b().e().a(12899129);
public static final BiomeBase TUNDRA = (new BiomeBase()).b(5762041).a("Tundra").b().a(12899129);
public static final BiomeBase HELL = (new BiomeHell()).b(16711680).a("Hell").e();
public static final BiomeBase SKY = (new BiomeSky()).b(8421631).a("Sky").e();
public String n;
public int o;
public byte p;
public byte q;
public int r;
protected List s;
protected List t;
protected List u;
private boolean v;
private boolean w;
private static BiomeBase[] x = new BiomeBase[4096];
protected BiomeBase() {
this.p = (byte) Block.GRASS.id;
this.q = (byte) Block.DIRT.id;
this.r = 5169201;
this.s = new ArrayList();
this.t = new ArrayList();
this.u = new ArrayList();
this.w = true;
this.s.add(new BiomeMeta(EntitySpider.class, 10));
this.s.add(new BiomeMeta(EntityZombie.class, 10));
this.s.add(new BiomeMeta(EntitySkeleton.class, 10));
this.s.add(new BiomeMeta(EntityCreeper.class, 10));
this.s.add(new BiomeMeta(EntitySlime.class, 10));
this.t.add(new BiomeMeta(EntitySheep.class, 12));
this.t.add(new BiomeMeta(EntityPig.class, 10));
this.t.add(new BiomeMeta(EntityChicken.class, 10));
this.t.add(new BiomeMeta(EntityCow.class, 8));
this.u.add(new BiomeMeta(EntitySquid.class, 10));
}
private BiomeBase e() {
this.w = false;
return this;
}
public static void a() {
for (int i = 0; i < 64; ++i) {
for (int j = 0; j < 64; ++j) {
x[i + j * 64] = a((float) i / 63.0F, (float) j / 63.0F);
}
}
DESERT.p = DESERT.q = (byte) Block.SAND.id;
ICE_DESERT.p = ICE_DESERT.q = (byte) Block.SAND.id;
}
public WorldGenerator a(Random random) {
return (WorldGenerator) (random.nextInt(10) == 0 ? new WorldGenBigTree() : new WorldGenTrees());
}
protected BiomeBase b() {
this.v = true;
return this;
}
protected BiomeBase a(String s) {
this.n = s;
return this;
}
protected BiomeBase a(int i) {
this.r = i;
return this;
}
protected BiomeBase b(int i) {
this.o = i;
return this;
}
public static BiomeBase a(double d0, double d1) {
int i = (int) (d0 * 63.0D);
int j = (int) (d1 * 63.0D);
return x[i + j * 64];
}
public static BiomeBase a(float f, float f1) {
f1 *= f;
return f < 0.1F ? TUNDRA : (f1 < 0.2F ? (f < 0.5F ? TUNDRA : (f < 0.95F ? SAVANNA : DESERT)) : (f1 > 0.5F && f < 0.7F ? SWAMPLAND : (f < 0.5F ? TAIGA : (f < 0.97F ? (f1 < 0.35F ? SHRUBLAND : FOREST) : (f1 < 0.45F ? PLAINS : (f1 < 0.9F ? SEASONAL_FOREST : RAINFOREST))))));
}
public List a(EnumCreatureType enumcreaturetype) {
return enumcreaturetype == EnumCreatureType.MONSTER ? this.s : (enumcreaturetype == EnumCreatureType.CREATURE ? this.t : (enumcreaturetype == EnumCreatureType.WATER_CREATURE ? this.u : null));
}
public boolean c() {
return this.v;
}
public boolean d() {
return this.v ? false : this.w;
}
static {
a();
}
}
@@ -0,0 +1,6 @@
package net.minecraft.server;
public class BiomeDesert extends BiomeBase {
public BiomeDesert() {}
}
@@ -0,0 +1,14 @@
package net.minecraft.server;
import java.util.Random;
public class BiomeForest extends BiomeBase {
public BiomeForest() {
this.t.add(new BiomeMeta(EntityWolf.class, 2));
}
public WorldGenerator a(Random random) {
return (WorldGenerator) (random.nextInt(5) == 0 ? new WorldGenForest() : (random.nextInt(3) == 0 ? new WorldGenBigTree() : new WorldGenTrees()));
}
}
@@ -0,0 +1,12 @@
package net.minecraft.server;
public class BiomeHell extends BiomeBase {
public BiomeHell() {
this.s.clear();
this.t.clear();
this.u.clear();
this.s.add(new BiomeMeta(EntityGhast.class, 10));
this.s.add(new BiomeMeta(EntityPigZombie.class, 10));
}
}
@@ -0,0 +1,12 @@
package net.minecraft.server;
public class BiomeMeta {
public Class a;
public int b;
public BiomeMeta(Class oclass, int i) {
this.a = oclass;
this.b = i;
}
}
@@ -0,0 +1,12 @@
package net.minecraft.server;
import java.util.Random;
public class BiomeRainforest extends BiomeBase {
public BiomeRainforest() {}
public WorldGenerator a(Random random) {
return (WorldGenerator) (random.nextInt(3) == 0 ? new WorldGenBigTree() : new WorldGenTrees());
}
}
@@ -0,0 +1,11 @@
package net.minecraft.server;
public class BiomeSky extends BiomeBase {
public BiomeSky() {
this.s.clear();
this.t.clear();
this.u.clear();
this.t.add(new BiomeMeta(EntityChicken.class, 10));
}
}
@@ -0,0 +1,6 @@
package net.minecraft.server;
public class BiomeSwamp extends BiomeBase {
public BiomeSwamp() {}
}
@@ -0,0 +1,14 @@
package net.minecraft.server;
import java.util.Random;
public class BiomeTaiga extends BiomeBase {
public BiomeTaiga() {
this.t.add(new BiomeMeta(EntityWolf.class, 2));
}
public WorldGenerator a(Random random) {
return (WorldGenerator) (random.nextInt(3) == 0 ? new WorldGenTaiga1() : new WorldGenTaiga2());
}
}
@@ -0,0 +1,555 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class Block {
public static final StepSound d = new StepSound("stone", 1.0F, 1.0F);
public static final StepSound e = new StepSound("wood", 1.0F, 1.0F);
public static final StepSound f = new StepSound("gravel", 1.0F, 1.0F);
public static final StepSound g = new StepSound("grass", 1.0F, 1.0F);
public static final StepSound h = new StepSound("stone", 1.0F, 1.0F);
public static final StepSound i = new StepSound("stone", 1.0F, 1.5F);
public static final StepSound j = new StepSoundStone("stone", 1.0F, 1.0F);
public static final StepSound k = new StepSound("cloth", 1.0F, 1.0F);
public static final StepSound l = new StepSoundSand("sand", 1.0F, 1.0F);
public static final Block[] byId = new Block[256];
public static final boolean[] n = new boolean[256];
public static final boolean[] o = new boolean[256];
public static final boolean[] isTileEntity = new boolean[256];
public static final int[] q = new int[256];
public static final boolean[] r = new boolean[256];
public static final int[] s = new int[256];
public static final boolean[] t = new boolean[256];
public static final Block STONE = (new BlockStone(1, 1)).c(1.5F).b(10.0F).a(h).a("stone");
public static final BlockGrass GRASS = (BlockGrass) (new BlockGrass(2)).c(0.6F).a(g).a("grass");
public static final Block DIRT = (new BlockDirt(3, 2)).c(0.5F).a(f).a("dirt");
public static final Block COBBLESTONE = (new Block(4, 16, Material.STONE)).c(2.0F).b(10.0F).a(h).a("stonebrick");
public static final Block WOOD = (new Block(5, 4, Material.WOOD)).c(2.0F).b(5.0F).a(e).a("wood").g();
public static final Block SAPLING = (new BlockSapling(6, 15)).c(0.0F).a(g).a("sapling").g();
public static final Block BEDROCK = (new Block(7, 17, Material.STONE)).i().b(6000000.0F).a(h).a("bedrock").n();
public static final Block WATER = (new BlockFlowing(8, Material.WATER)).c(100.0F).f(3).a("water").n().g();
public static final Block STATIONARY_WATER = (new BlockStationary(9, Material.WATER)).c(100.0F).f(3).a("water").n().g();
public static final Block LAVA = (new BlockFlowing(10, Material.LAVA)).c(0.0F).a(1.0F).f(255).a("lava").n().g();
public static final Block STATIONARY_LAVA = (new BlockStationary(11, Material.LAVA)).c(100.0F).a(1.0F).f(255).a("lava").n().g();
public static final Block SAND = (new BlockSand(12, 18)).c(0.5F).a(l).a("sand");
public static final Block GRAVEL = (new BlockGravel(13, 19)).c(0.6F).a(f).a("gravel");
public static final Block GOLD_ORE = (new BlockOre(14, 32)).c(3.0F).b(5.0F).a(h).a("oreGold");
public static final Block IRON_ORE = (new BlockOre(15, 33)).c(3.0F).b(5.0F).a(h).a("oreIron");
public static final Block COAL_ORE = (new BlockOre(16, 34)).c(3.0F).b(5.0F).a(h).a("oreCoal");
public static final Block LOG = (new BlockLog(17)).c(2.0F).a(e).a("log").g();
public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).f(1).a(g).a("leaves").n().g();
public static final Block SPONGE = (new BlockSponge(19)).c(0.6F).a(g).a("sponge");
public static final Block GLASS = (new BlockGlass(20, 49, Material.SHATTERABLE, false)).c(0.3F).a(j).a("glass");
public static final Block LAPIS_ORE = (new BlockOre(21, 160)).c(3.0F).b(5.0F).a(h).a("oreLapis");
public static final Block LAPIS_BLOCK = (new Block(22, 144, Material.STONE)).c(3.0F).b(5.0F).a(h).a("blockLapis");
public static final Block DISPENSER = (new BlockDispenser(23)).c(3.5F).a(h).a("dispenser").g();
public static final Block SANDSTONE = (new BlockSandStone(24)).a(h).c(0.8F).a("sandStone");
public static final Block NOTE_BLOCK = (new BlockNote(25)).c(0.8F).a("musicBlock").g();
public static final Block BED = (new BlockBed(26)).c(0.2F).a("bed").n().g();
public static final Block GOLDEN_RAIL = (new BlockMinecartTrack(27, 179, true)).c(0.7F).a(i).a("goldenRail").g();
public static final Block DETECTOR_RAIL = (new BlockMinecartDetector(28, 195)).c(0.7F).a(i).a("detectorRail").g();
public static final Block PISTON_STICKY = (new BlockPiston(29, 106, true)).a("pistonStickyBase").g();
public static final Block WEB = (new BlockWeb(30, 11)).f(1).c(4.0F).a("web");
public static final BlockLongGrass LONG_GRASS = (BlockLongGrass) (new BlockLongGrass(31, 39)).c(0.0F).a(g).a("tallgrass");
public static final BlockDeadBush DEAD_BUSH = (BlockDeadBush) (new BlockDeadBush(32, 55)).c(0.0F).a(g).a("deadbush");
public static final Block PISTON = (new BlockPiston(33, 107, false)).a("pistonBase").g();
public static final BlockPistonExtension PISTON_EXTENSION = (BlockPistonExtension) (new BlockPistonExtension(34, 107)).g();
public static final Block WOOL = (new BlockCloth()).c(0.8F).a(k).a("cloth").g();
public static final BlockPistonMoving PISTON_MOVING = new BlockPistonMoving(36);
public static final BlockFlower YELLOW_FLOWER = (BlockFlower) (new BlockFlower(37, 13)).c(0.0F).a(g).a("flower");
public static final BlockFlower RED_ROSE = (BlockFlower) (new BlockFlower(38, 12)).c(0.0F).a(g).a("rose");
public static final BlockFlower BROWN_MUSHROOM = (BlockFlower) (new BlockMushroom(39, 29)).c(0.0F).a(g).a(0.125F).a("mushroom");
public static final BlockFlower RED_MUSHROOM = (BlockFlower) (new BlockMushroom(40, 28)).c(0.0F).a(g).a("mushroom");
public static final Block GOLD_BLOCK = (new BlockOreBlock(41, 23)).c(3.0F).b(10.0F).a(i).a("blockGold");
public static final Block IRON_BLOCK = (new BlockOreBlock(42, 22)).c(5.0F).b(10.0F).a(i).a("blockIron");
public static final Block DOUBLE_STEP = (new BlockStep(43, true)).c(2.0F).b(10.0F).a(h).a("stoneSlab");
public static final Block STEP = (new BlockStep(44, false)).c(2.0F).b(10.0F).a(h).a("stoneSlab");
public static final Block BRICK = (new Block(45, 7, Material.STONE)).c(2.0F).b(10.0F).a(h).a("brick");
public static final Block TNT = (new BlockTNT(46, 8)).c(0.0F).a(g).a("tnt");
public static final Block BOOKSHELF = (new BlockBookshelf(47, 35)).c(1.5F).a(e).a("bookshelf");
public static final Block MOSSY_COBBLESTONE = (new Block(48, 36, Material.STONE)).c(2.0F).b(10.0F).a(h).a("stoneMoss");
public static final Block OBSIDIAN = (new BlockObsidian(49, 37)).c(10.0F).b(2000.0F).a(h).a("obsidian");
public static final Block TORCH = (new BlockTorch(50, 80)).c(0.0F).a(0.9375F).a(e).a("torch").g();
public static final BlockFire FIRE = (BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(e).a("fire").n().g();
public static final Block MOB_SPAWNER = (new BlockMobSpawner(52, 65)).c(5.0F).a(i).a("mobSpawner").n();
public static final Block WOOD_STAIRS = (new BlockStairs(53, WOOD)).a("stairsWood").g();
public static final Block CHEST = (new BlockChest(54)).c(2.5F).a(e).a("chest").g();
public static final Block REDSTONE_WIRE = (new BlockRedstoneWire(55, 164)).c(0.0F).a(d).a("redstoneDust").n().g();
public static final Block DIAMOND_ORE = (new BlockOre(56, 50)).c(3.0F).b(5.0F).a(h).a("oreDiamond");
public static final Block DIAMOND_BLOCK = (new BlockOreBlock(57, 24)).c(5.0F).b(10.0F).a(i).a("blockDiamond");
public static final Block WORKBENCH = (new BlockWorkbench(58)).c(2.5F).a(e).a("workbench");
public static final Block CROPS = (new BlockCrops(59, 88)).c(0.0F).a(g).a("crops").n().g();
public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(f).a("farmland");
public static final Block FURNACE = (new BlockFurnace(61, false)).c(3.5F).a(h).a("furnace").g();
public static final Block BURNING_FURNACE = (new BlockFurnace(62, true)).c(3.5F).a(h).a(0.875F).a("furnace").g();
public static final Block SIGN_POST = (new BlockSign(63, TileEntitySign.class, true)).c(1.0F).a(e).a("sign").n().g();
public static final Block WOODEN_DOOR = (new BlockDoor(64, Material.WOOD)).c(3.0F).a(e).a("doorWood").n().g();
public static final Block LADDER = (new BlockLadder(65, 83)).c(0.4F).a(e).a("ladder").g();
public static final Block RAILS = (new BlockMinecartTrack(66, 128, false)).c(0.7F).a(i).a("rail").g();
public static final Block COBBLESTONE_STAIRS = (new BlockStairs(67, COBBLESTONE)).a("stairsStone").g();
public static final Block WALL_SIGN = (new BlockSign(68, TileEntitySign.class, false)).c(1.0F).a(e).a("sign").n().g();
public static final Block LEVER = (new BlockLever(69, 96)).c(0.5F).a(e).a("lever").g();
public static final Block STONE_PLATE = (new BlockPressurePlate(70, STONE.textureId, EnumMobType.MOBS, Material.STONE)).c(0.5F).a(h).a("pressurePlate").g();
public static final Block IRON_DOOR_BLOCK = (new BlockDoor(71, Material.ORE)).c(5.0F).a(i).a("doorIron").n().g();
public static final Block WOOD_PLATE = (new BlockPressurePlate(72, WOOD.textureId, EnumMobType.EVERYTHING, Material.WOOD)).c(0.5F).a(e).a("pressurePlate").g();
public static final Block REDSTONE_ORE = (new BlockRedstoneOre(73, 51, false)).c(3.0F).b(5.0F).a(h).a("oreRedstone").g();
public static final Block GLOWING_REDSTONE_ORE = (new BlockRedstoneOre(74, 51, true)).a(0.625F).c(3.0F).b(5.0F).a(h).a("oreRedstone").g();
public static final Block REDSTONE_TORCH_OFF = (new BlockRedstoneTorch(75, 115, false)).c(0.0F).a(e).a("notGate").g();
public static final Block REDSTONE_TORCH_ON = (new BlockRedstoneTorch(76, 99, true)).c(0.0F).a(0.5F).a(e).a("notGate").g();
public static final Block STONE_BUTTON = (new BlockButton(77, STONE.textureId)).c(0.5F).a(h).a("button").g();
public static final Block SNOW = (new BlockSnow(78, 66)).c(0.1F).a(k).a("snow");
public static final Block ICE = (new BlockIce(79, 67)).c(0.5F).f(3).a(j).a("ice");
public static final Block SNOW_BLOCK = (new BlockSnowBlock(80, 66)).c(0.2F).a(k).a("snow");
public static final Block CACTUS = (new BlockCactus(81, 70)).c(0.4F).a(k).a("cactus");
public static final Block CLAY = (new BlockClay(82, 72)).c(0.6F).a(f).a("clay");
public static final Block SUGAR_CANE_BLOCK = (new BlockReed(83, 73)).c(0.0F).a(g).a("reeds").n();
public static final Block JUKEBOX = (new BlockJukeBox(84, 74)).c(2.0F).b(10.0F).a(h).a("jukebox").g();
public static final Block FENCE = (new BlockFence(85, 4)).c(2.0F).b(5.0F).a(e).a("fence").g();
public static final Block PUMPKIN = (new BlockPumpkin(86, 102, false)).c(1.0F).a(e).a("pumpkin").g();
public static final Block NETHERRACK = (new BlockBloodStone(87, 103)).c(0.4F).a(h).a("hellrock");
public static final Block SOUL_SAND = (new BlockSlowSand(88, 104)).c(0.5F).a(l).a("hellsand");
public static final Block GLOWSTONE = (new BlockLightStone(89, 105, Material.STONE)).c(0.3F).a(j).a(1.0F).a("lightgem");
public static final BlockPortal PORTAL = (BlockPortal) (new BlockPortal(90, 14)).c(-1.0F).a(j).a(0.75F).a("portal");
public static final Block JACK_O_LANTERN = (new BlockPumpkin(91, 102, true)).c(1.0F).a(e).a(1.0F).a("litpumpkin").g();
public static final Block CAKE_BLOCK = (new BlockCake(92, 121)).c(0.5F).a(k).a("cake").n().g();
public static final Block DIODE_OFF = (new BlockDiode(93, false)).c(0.0F).a(e).a("diode").n().g();
public static final Block DIODE_ON = (new BlockDiode(94, true)).c(0.0F).a(0.625F).a(e).a("diode").n().g();
public static final Block LOCKED_CHEST = (new BlockLockedChest(95)).c(0.0F).a(1.0F).a(e).a("lockedchest").a(true).g();
public static final Block TRAP_DOOR = (new BlockTrapdoor(96, Material.WOOD)).c(3.0F).a(e).a("trapdoor").n().g();
public static final List<Integer> leafDecayBlacklist = Arrays.asList(PoseidonConfig.getInstance().getTreeBlacklistIDs());
public int textureId;
public final int id;
protected float strength;
protected float durability;
protected boolean bq;
protected boolean br;
public double minX;
public double minY;
public double minZ;
public double maxX;
public double maxY;
public double maxZ;
public StepSound stepSound;
public float bz;
public final Material material;
public float frictionFactor;
private String name;
protected Block(int i, Material material) {
this.bq = true;
this.br = true;
this.stepSound = d;
this.bz = 1.0F;
this.frictionFactor = 0.6F;
if (byId[i] != null) {
throw new IllegalArgumentException("Slot " + i + " is already occupied by " + byId[i] + " when adding " + this);
} else {
this.material = material;
byId[i] = this;
this.id = i;
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
o[i] = this.a();
q[i] = this.a() ? 255 : 0;
r[i] = !material.blocksLight();
isTileEntity[i] = false;
}
}
protected Block g() {
t[this.id] = true;
return this;
}
protected void h() {
}
protected Block(int i, int j, Material material) {
this(i, material);
this.textureId = j;
}
protected Block a(StepSound stepsound) {
this.stepSound = stepsound;
return this;
}
protected Block f(int i) {
q[this.id] = i;
return this;
}
protected Block a(float f) {
s[this.id] = (int) (15.0F * f);
return this;
}
protected Block b(float f) {
this.durability = f * 3.0F;
return this;
}
public boolean b() {
return true;
}
protected Block c(float f) {
this.strength = f;
if (this.durability < f * 5.0F) {
this.durability = f * 5.0F;
}
return this;
}
protected Block i() {
this.c(-1.0F);
return this;
}
public float j() {
return this.strength;
}
protected Block a(boolean flag) {
n[this.id] = flag;
return this;
}
public void a(float f, float f1, float f2, float f3, float f4, float f5) {
this.minX = (double) f;
this.minY = (double) f1;
this.minZ = (double) f2;
this.maxX = (double) f3;
this.maxY = (double) f4;
this.maxZ = (double) f5;
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return iblockaccess.getMaterial(i, j, k).isBuildable();
}
public int a(int i, int j) {
return this.a(i);
}
public int a(int i) {
return this.textureId;
}
public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) {
AxisAlignedBB axisalignedbb1 = this.e(world, i, j, k);
if (axisalignedbb1 != null && axisalignedbb.a(axisalignedbb1)) {
arraylist.add(axisalignedbb1);
}
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return AxisAlignedBB.b((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) j + this.maxY, (double) k + this.maxZ);
}
public boolean a() {
return true;
}
public boolean a(int i, boolean flag) {
return this.k_();
}
public boolean k_() {
return true;
}
public void a(World world, int i, int j, int k, Random random) {
}
public void postBreak(World world, int i, int j, int k, int l) {
}
public void doPhysics(World world, int i, int j, int k, int l) {
}
public int c() {
return 10;
}
public void c(World world, int i, int j, int k) {
}
public void remove(World world, int i, int j, int k) {
}
public int a(Random random) {
return 1;
}
public int a(int i, Random random) {
return this.id;
}
public float getDamage(EntityHuman entityhuman) {
return this.strength < 0.0F ? 0.0F : (!entityhuman.b(this) ? 1.0F / this.strength / 100.0F : entityhuman.a(this) / this.strength / 30.0F);
}
public final void g(World world, int i, int j, int k, int l) {
this.dropNaturally(world, i, j, k, l, 1.0F);
}
public void dropNaturally(World world, int i, int j, int k, int l, float f) {
if (!world.isStatic) {
int i1 = this.a(world.random);
for (int j1 = 0; j1 < i1; ++j1) {
// CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions
if (world.random.nextFloat() < f) {
int k1 = this.a(l, world.random);
if (k1 > 0) {
this.a(world, i, j, k, new ItemStack(k1, 1, this.a_(l)));
}
}
}
}
}
protected void a(World world, int i, int j, int k, ItemStack itemstack) {
if (!world.isStatic) {
float f = 0.7F;
double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, itemstack);
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
}
}
protected int a_(int i) {
return 0;
}
public float a(Entity entity) {
return this.durability / 5.0F;
}
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
this.a(world, i, j, k);
vec3d = vec3d.add((double) (-i), (double) (-j), (double) (-k));
vec3d1 = vec3d1.add((double) (-i), (double) (-j), (double) (-k));
Vec3D vec3d2 = vec3d.a(vec3d1, this.minX);
Vec3D vec3d3 = vec3d.a(vec3d1, this.maxX);
Vec3D vec3d4 = vec3d.b(vec3d1, this.minY);
Vec3D vec3d5 = vec3d.b(vec3d1, this.maxY);
Vec3D vec3d6 = vec3d.c(vec3d1, this.minZ);
Vec3D vec3d7 = vec3d.c(vec3d1, this.maxZ);
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.add((double) i, (double) j, (double) k));
}
}
private boolean a(Vec3D vec3d) {
return vec3d == null ? false : vec3d.b >= this.minY && vec3d.b <= this.maxY && vec3d.c >= this.minZ && vec3d.c <= this.maxZ;
}
private boolean b(Vec3D vec3d) {
return vec3d == null ? false : vec3d.a >= this.minX && vec3d.a <= this.maxX && vec3d.c >= this.minZ && vec3d.c <= this.maxZ;
}
private boolean c(Vec3D vec3d) {
return vec3d == null ? false : vec3d.a >= this.minX && vec3d.a <= this.maxX && vec3d.b >= this.minY && vec3d.b <= this.maxY;
}
public void d(World world, int i, int j, int k) {
}
public boolean canPlace(World world, int i, int j, int k, int l) {
return this.canPlace(world, i, j, k);
}
public boolean canPlace(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k);
return l == 0 || byId[l].material.isReplacable();
}
public boolean interact(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 postPlace(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 a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return false;
}
public boolean isPowerSource() {
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 void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
entityhuman.a(StatisticList.C[this.id], 1);
this.g(world, i, j, k, l);
}
public boolean f(World world, int i, int j, int k) {
return true;
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
}
public Block a(String s) {
this.name = "tile." + s;
return this;
}
public String k() {
return StatisticCollector.a(this.l() + ".name");
}
public String l() {
return this.name;
}
public void a(World world, int i, int j, int k, int l, int i1) {
}
public boolean m() {
return this.br;
}
protected Block n() {
this.br = false;
return this;
}
public int e() {
return this.material.j();
}
static {
Item.byId[WOOL.id] = (new ItemCloth(WOOL.id - 256)).a("cloth");
Item.byId[LOG.id] = (new ItemLog(LOG.id - 256)).a("log");
Item.byId[STEP.id] = (new ItemStep(STEP.id - 256)).a("stoneSlab");
Item.byId[SAPLING.id] = (new ItemSapling(SAPLING.id - 256)).a("sapling");
Item.byId[LEAVES.id] = (new ItemLeaves(LEAVES.id - 256)).a("leaves");
Item.byId[PISTON.id] = new ItemPiston(PISTON.id - 256);
Item.byId[PISTON_STICKY.id] = new ItemPiston(PISTON_STICKY.id - 256);
for (int i = 0; i < 256; ++i) {
if (byId[i] != null && Item.byId[i] == null) {
Item.byId[i] = new ItemBlock(i - 256);
byId[i].h();
}
}
r[0] = true;
StatisticList.b();
}
}
@@ -0,0 +1,201 @@
package net.minecraft.server;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.Iterator;
import java.util.Random;
public class BlockBed extends Block {
public static final int[][] a = new int[][] { { 0, 1}, { -1, 0}, { 0, -1}, { 1, 0}};
public BlockBed(int i) {
super(i, 134, Material.CLOTH);
this.o();
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
int l = world.getData(i, j, k);
if (!d(l)) {
int i1 = c(l);
i += a[i1][0];
k += a[i1][1];
if (world.getTypeId(i, j, k) != this.id) {
return true;
}
l = world.getData(i, j, k);
}
if (!world.worldProvider.d()) {
double d0 = (double) i + 0.5D;
double d1 = (double) j + 0.5D;
double d2 = (double) k + 0.5D;
world.setTypeId(i, j, k, 0);
int j1 = c(l);
i += a[j1][0];
k += a[j1][1];
if (world.getTypeId(i, j, k) == this.id) {
world.setTypeId(i, j, k, 0);
d0 = (d0 + (double) i + 0.5D) / 2.0D;
d1 = (d1 + (double) j + 0.5D) / 2.0D;
d2 = (d2 + (double) k + 0.5D) / 2.0D;
}
world.createExplosion((Entity) null, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), 5.0F, true, EntityDamageEvent.DamageCause.BED_EXPLOSION); //Project poseidon
return true;
} else {
if (e(l)) {
EntityHuman entityhuman1 = null;
Iterator iterator = world.players.iterator();
while (iterator.hasNext()) {
EntityHuman entityhuman2 = (EntityHuman) iterator.next();
if (entityhuman2.isSleeping()) {
ChunkCoordinates chunkcoordinates = entityhuman2.A;
if (chunkcoordinates.x == i && chunkcoordinates.y == j && chunkcoordinates.z == k) {
entityhuman1 = entityhuman2;
}
}
}
if (entityhuman1 != null) {
entityhuman.a("tile.bed.occupied");
return true;
}
a(world, i, j, k, false);
}
EnumBedError enumbederror = entityhuman.a(i, j, k);
if (enumbederror == EnumBedError.OK) {
a(world, i, j, k, true);
return true;
} else {
if (enumbederror == EnumBedError.NOT_POSSIBLE_NOW) {
entityhuman.a("tile.bed.noSleep");
}
return true;
}
}
}
}
public int a(int i, int j) {
if (i == 0) {
return Block.WOOD.textureId;
} else {
int k = c(j);
int l = BedBlockTextures.c[k][i];
return d(j) ? (l == 2 ? this.textureId + 2 + 16 : (l != 5 && l != 4 ? this.textureId + 1 : this.textureId + 1 + 16)) : (l == 3 ? this.textureId - 1 + 16 : (l != 5 && l != 4 ? this.textureId : this.textureId + 16));
}
}
public boolean b() {
return false;
}
public boolean a() {
return false;
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
this.o();
}
public void doPhysics(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
int j1 = c(i1);
if (d(i1)) {
if (world.getTypeId(i - a[j1][0], j, k - a[j1][1]) != this.id) {
world.setTypeId(i, j, k, 0);
}
} else if (world.getTypeId(i + a[j1][0], j, k + a[j1][1]) != this.id) {
world.setTypeId(i, j, k, 0);
if (!world.isStatic) {
this.g(world, i, j, k, i1);
}
}
}
public int a(int i, Random random) {
return d(i) ? 0 : Item.BED.id;
}
private void o() {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
}
public static int c(int i) {
return i & 3;
}
public static boolean d(int i) {
return (i & 8) != 0;
}
public static boolean e(int i) {
return (i & 4) != 0;
}
public static void a(World world, int i, int j, int k, boolean flag) {
int l = world.getData(i, j, k);
if (flag) {
l |= 4;
} else {
l &= -5;
}
world.setData(i, j, k, l);
}
public static ChunkCoordinates f(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
int j1 = c(i1);
for (int k1 = 0; k1 <= 1; ++k1) {
int l1 = i - a[j1][0] * k1 - 1;
int i2 = k - a[j1][1] * k1 - 1;
int j2 = l1 + 2;
int k2 = i2 + 2;
for (int l2 = l1; l2 <= j2; ++l2) {
for (int i3 = i2; i3 <= k2; ++i3) {
if (world.e(l2, j - 1, i3) && world.isEmpty(l2, j, i3) && world.isEmpty(l2, j + 1, i3)) {
if (l <= 0) {
return new ChunkCoordinates(l2, j, i3);
}
--l;
}
}
}
}
return null;
}
public void dropNaturally(World world, int i, int j, int k, int l, float f) {
if (!d(l)) {
super.dropNaturally(world, i, j, k, l, f);
}
}
public int e() {
return 1;
}
}
@@ -0,0 +1,22 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockBloodStone extends Block {
public BlockBloodStone(int i, int j) {
super(i, j, Material.STONE);
}
// CraftBukkit start
public void doPhysics(World world, int i, int j, int k, int l) {
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
int power = block.getBlockPower();
BlockRedstoneEvent event = new BlockRedstoneEvent(block, power, power);
world.getServer().getPluginManager().callEvent(event);
}
}
// CraftBukkit end
}
@@ -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.WOOD);
}
public int a(int i) {
return i <= 1 ? 4 : this.textureId;
}
public int a(Random random) {
return 0;
}
}
@@ -0,0 +1,15 @@
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 a() {
return false;
}
}
@@ -0,0 +1,248 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
import java.util.Random;
public class BlockButton extends Block {
protected BlockButton(int i, int j) {
super(i, j, Material.ORIENTABLE);
this.a(true);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public int c() {
return 20;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k, int l) {
return l == 2 && world.e(i, j, k + 1) ? true : (l == 3 && world.e(i, j, k - 1) ? true : (l == 4 && world.e(i + 1, j, k) ? true : l == 5 && world.e(i - 1, j, k)));
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i - 1, j, k) ? true : (world.e(i + 1, j, k) ? true : (world.e(i, j, k - 1) ? true : world.e(i, j, k + 1)));
}
public void postPlace(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
int j1 = i1 & 8;
i1 &= 7;
if (l == 2 && world.e(i, j, k + 1)) {
i1 = 4;
} else if (l == 3 && world.e(i, j, k - 1)) {
i1 = 3;
} else if (l == 4 && world.e(i + 1, j, k)) {
i1 = 2;
} else if (l == 5 && world.e(i - 1, j, k)) {
i1 = 1;
} else {
i1 = this.g(world, i, j, k);
}
world.setData(i, j, k, i1 + j1);
}
private int g(World world, int i, int j, int k) {
return world.e(i - 1, j, k) ? 1 : (world.e(i + 1, j, k) ? 2 : (world.e(i, j, k - 1) ? 3 : (world.e(i, j, k + 1) ? 4 : 1)));
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (this.h(world, i, j, k)) {
int i1 = world.getData(i, j, k) & 7;
boolean flag = false;
if (!world.e(i - 1, j, k) && i1 == 1) {
flag = true;
}
if (!world.e(i + 1, j, k) && i1 == 2) {
flag = true;
}
if (!world.e(i, j, k - 1) && i1 == 3) {
flag = true;
}
if (!world.e(i, j, k + 1) && i1 == 4) {
flag = true;
}
if (flag) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
}
private boolean h(World world, int i, int j, int k) {
if (!this.canPlace(world, i, j, k)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
return false;
} else {
return true;
}
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(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.interact(world, i, j, k, entityhuman);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
int l = world.getData(i, j, k);
int i1 = l & 7;
int j1 = 8 - (l & 8);
if (j1 == 0) {
return true;
} else {
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
world.getServer().getPluginManager().callEvent(eventRedstone);
if ((eventRedstone.getNewCurrent() > 0) != (j1 == 8)) {
return true;
}
// CraftBukkit end
world.setData(i, j, k, i1 + j1);
world.b(i, j, k, i, j, k);
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
world.applyPhysics(i, j, k, this.id);
if (i1 == 1) {
world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) {
world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) {
world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) {
world.applyPhysics(i, j, k + 1, this.id);
} else {
world.applyPhysics(i, j - 1, k, this.id);
}
world.c(i, j, k, this.id, this.c());
return true;
}
}
public void remove(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
if ((l & 8) > 0) {
world.applyPhysics(i, j, k, this.id);
int i1 = l & 7;
if (i1 == 1) {
world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) {
world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) {
world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) {
world.applyPhysics(i, j, k + 1, this.id);
} else {
world.applyPhysics(i, j - 1, k, this.id);
}
}
super.remove(world, i, j, k);
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return (iblockaccess.getData(i, j, k) & 8) > 0;
}
public boolean d(World world, int i, int j, int k, int l) {
int i1 = world.getData(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 isPowerSource() {
return true;
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
int l = world.getData(i, j, k);
if ((l & 8) != 0) {
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 1, 0);
world.getServer().getPluginManager().callEvent(eventRedstone);
if (eventRedstone.getNewCurrent() > 0) return;
// CraftBukkit end
world.setData(i, j, k, l & 7);
world.applyPhysics(i, j, k, this.id);
int i1 = l & 7;
if (i1 == 1) {
world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) {
world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) {
world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) {
world.applyPhysics(i, j, k + 1, this.id);
} else {
world.applyPhysics(i, j - 1, k, this.id);
}
world.makeSound((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);
}
}
}
}
@@ -0,0 +1,103 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.Random;
// CraftBukkit end
public class BlockCactus extends Block {
protected BlockCactus(int i, int j) {
super(i, j, Material.CACTUS);
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 AxisAlignedBB e(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.textureId - 1 : (i == 0 ? this.textureId + 1 : this.textureId);
}
public boolean b() {
return false;
}
public boolean a() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return !super.canPlace(world, i, j, k) ? false : this.f(world, i, j, k);
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!this.f(world, i, j, k)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
public boolean f(World world, int i, int j, int k) {
if (world.getMaterial(i - 1, j, k).isBuildable()) {
return false;
} else if (world.getMaterial(i + 1, j, k).isBuildable()) {
return false;
} else if (world.getMaterial(i, j, k - 1).isBuildable()) {
return false;
} else if (world.getMaterial(i, j, k + 1).isBuildable()) {
return false;
} else {
int l = world.getTypeId(i, j - 1, k);
return l == Block.CACTUS.id || l == Block.SAND.id;
}
}
public void a(World world, int i, int j, int k, Entity entity) {
// CraftBukkit start - ENTITY_DAMAGEBY_BLOCK event
if (entity instanceof EntityLiving) {
org.bukkit.block.Block damager = world.getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, EntityDamageEvent.DamageCause.CONTACT, 1);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
entity.damageEntity((Entity) null, event.getDamage());
}
return;
}
// CraftBukkit end
entity.damageEntity((Entity) null, 1);
}
}
@@ -0,0 +1,91 @@
package net.minecraft.server;
import java.util.Random;
public class BlockCake extends Block {
protected BlockCake(int i, int j) {
super(i, j, Material.CAKE);
this.a(true);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(i, j, k);
float f = 0.0625F;
float f1 = (float) (1 + l * 2) / 16.0F;
float f2 = 0.5F;
this.a(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
float f = 0.0625F;
float f1 = (float) (1 + l * 2) / 16.0F;
float f2 = 0.5F;
return AxisAlignedBB.b((double) ((float) i + f1), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) j + f2 - f), (double) ((float) (k + 1) - f));
}
public int a(int i, int j) {
return i == 1 ? this.textureId : (i == 0 ? this.textureId + 3 : (j > 0 && i == 4 ? this.textureId + 2 : this.textureId + 1));
}
public int a(int i) {
return i == 1 ? this.textureId : (i == 0 ? this.textureId + 3 : this.textureId + 1);
}
public boolean b() {
return false;
}
public boolean a() {
return false;
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
this.c(world, i, j, k, entityhuman);
return true;
}
public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
this.c(world, i, j, k, entityhuman);
}
private void c(World world, int i, int j, int k, EntityHuman entityhuman) {
if (entityhuman.health < 20) {
entityhuman.b(3);
int l = world.getData(i, j, k) + 1;
if (l >= 6) {
world.setTypeId(i, j, k, 0);
} else {
world.setData(i, j, k, l);
world.i(i, j, k);
}
}
}
public boolean canPlace(World world, int i, int j, int k) {
return !super.canPlace(world, i, j, k) ? false : this.f(world, i, j, k);
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!this.f(world, i, j, k)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
public boolean f(World world, int i, int j, int k) {
return world.getMaterial(i, j - 1, k).isBuildable();
}
public int a(Random random) {
return 0;
}
public int a(int i, Random random) {
return 0;
}
}
@@ -0,0 +1,120 @@
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.WOOD);
this.textureId = 26;
}
public int a(int i) {
return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId - 1 : (i == 3 ? this.textureId + 1 : this.textureId));
}
public boolean canPlace(World world, int i, int j, int k) {
int l = 0;
if (world.getTypeId(i - 1, j, k) == this.id) {
++l;
}
if (world.getTypeId(i + 1, j, k) == this.id) {
++l;
}
if (world.getTypeId(i, j, k - 1) == this.id) {
++l;
}
if (world.getTypeId(i, j, k + 1) == this.id) {
++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.getTypeId(i, j, k) != this.id ? false : (world.getTypeId(i - 1, j, k) == this.id ? true : (world.getTypeId(i + 1, j, k) == this.id ? true : (world.getTypeId(i, j, k - 1) == this.id ? true : world.getTypeId(i, j, k + 1) == this.id)));
}
public void remove(World world, int i, int j, int k) {
TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(i, j, k);
for (int l = 0; l < tileentitychest.getSize(); ++l) {
ItemStack itemstack = tileentitychest.getItem(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.count > 0) {
int i1 = this.a.nextInt(21) + 10;
if (i1 > itemstack.count) {
i1 = itemstack.count;
}
itemstack.count -= i1;
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData()));
float f3 = 0.05F;
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
world.addEntity(entityitem);
}
tileentitychest.setItem(l, null);
}
}
super.remove(world, i, j, k);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
Object object = (TileEntityChest) world.getTileEntity(i, j, k);
if (world.e(i, j + 1, k)) {
return true;
} else if (world.getTypeId(i - 1, j, k) == this.id && world.e(i - 1, j + 1, k)) {
return true;
} else if (world.getTypeId(i + 1, j, k) == this.id && world.e(i + 1, j + 1, k)) {
return true;
} else if (world.getTypeId(i, j, k - 1) == this.id && world.e(i, j + 1, k - 1)) {
return true;
} else if (world.getTypeId(i, j, k + 1) == this.id && world.e(i, j + 1, k + 1)) {
return true;
} else {
if (world.getTypeId(i - 1, j, k) == this.id) {
object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i - 1, j, k), (IInventory) object);
}
if (world.getTypeId(i + 1, j, k) == this.id) {
object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i + 1, j, k));
}
if (world.getTypeId(i, j, k - 1) == this.id) {
object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i, j, k - 1), (IInventory) object);
}
if (world.getTypeId(i, j, k + 1) == this.id) {
object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i, j, k + 1));
}
if (world.isStatic) {
return true;
} else {
entityhuman.a((IInventory) object);
return true;
}
}
}
protected TileEntity a_() {
return new TileEntityChest();
}
}
@@ -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.CLAY);
}
public int a(int i, Random random) {
return Item.CLAY_BALL.id;
}
public int a(Random random) {
return 4;
}
}
@@ -0,0 +1,29 @@
package net.minecraft.server;
public class BlockCloth extends Block {
public BlockCloth() {
super(35, 64, Material.CLOTH);
}
public int a(int i, int j) {
if (j == 0) {
return this.textureId;
} else {
j = ~(j & 15);
return 113 + ((j & 8) >> 3) + (j & 7) * 16;
}
}
protected int a_(int i) {
return i;
}
public static int c(int i) {
return ~i & 15;
}
public static int d(int i) {
return ~i & 15;
}
}
@@ -0,0 +1,26 @@
package net.minecraft.server;
public abstract class BlockContainer extends Block {
protected BlockContainer(int i, Material material) {
super(i, material);
isTileEntity[i] = true;
}
protected BlockContainer(int i, int j, Material material) {
super(i, j, material);
isTileEntity[i] = true;
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
world.setTileEntity(i, j, k, this.a_());
}
public void remove(World world, int i, int j, int k) {
super.remove(world, i, j, k);
world.o(i, j, k);
}
protected abstract TileEntity a_();
}
@@ -0,0 +1,114 @@
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 c(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.h(world, i, j, k);
if (random.nextInt((int) (100.0F / f)) == 0) {
++l;
world.setData(i, j, k, l);
}
}
}
}
public void d_(World world, int i, int j, int k) {
world.setData(i, j, k, 7);
}
private float h(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 void dropNaturally(World world, int i, int j, int k, int l, float f) {
super.dropNaturally(world, i, j, k, l, f);
if (!world.isStatic) {
for (int i1 = 0; i1 < 3; ++i1) {
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 a(int i, Random random) {
return i == 7 ? Item.WHEAT.id : -1;
}
public int a(Random random) {
return 1;
}
}
@@ -0,0 +1,25 @@
package net.minecraft.server;
import java.util.Random;
public class BlockDeadBush extends BlockFlower {
protected BlockDeadBush(int i, int j) {
super(i, j);
float f = 0.4F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
}
protected boolean c(int i) {
return i == Block.SAND.id;
}
public int a(int i, int j) {
return this.textureId;
}
public int a(int i, Random random) {
return -1;
}
}
@@ -0,0 +1,145 @@
package net.minecraft.server;
import java.util.Random;
public class BlockDiode extends Block {
public static final double[] a = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D};
private static final int[] b = new int[] { 1, 2, 3, 4};
private final boolean c;
protected BlockDiode(int i, boolean flag) {
super(i, 6, Material.ORIENTABLE);
this.c = flag;
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return !world.e(i, j - 1, k) ? false : super.canPlace(world, i, j, k);
}
public boolean f(World world, int i, int j, int k) {
return !world.e(i, j - 1, k) ? false : super.f(world, i, j, k);
}
public void a(World world, int i, int j, int k, Random random) {
int l = world.getData(i, j, k);
boolean flag = this.f(world, i, j, k, l);
if (this.c && !flag) {
world.setTypeIdAndData(i, j, k, Block.DIODE_OFF.id, l);
} else if (!this.c) {
world.setTypeIdAndData(i, j, k, Block.DIODE_ON.id, l);
if (!flag) {
int i1 = (l & 12) >> 2;
world.c(i, j, k, Block.DIODE_ON.id, b[i1] * 2);
}
}
}
public int a(int i, int j) {
return i == 0 ? (this.c ? 99 : 115) : (i == 1 ? (this.c ? 147 : 131) : 5);
}
public int a(int i) {
return this.a(i, 0);
}
public boolean d(World world, int i, int j, int k, int l) {
return this.a(world, i, j, k, l);
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
if (!this.c) {
return false;
} else {
int i1 = iblockaccess.getData(i, j, k) & 3;
return i1 == 0 && l == 3 ? true : (i1 == 1 && l == 4 ? true : (i1 == 2 && l == 2 ? true : i1 == 3 && l == 5));
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!this.f(world, i, j, k)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
} else {
int i1 = world.getData(i, j, k);
boolean flag = this.f(world, i, j, k, i1);
int j1 = (i1 & 12) >> 2;
if (this.c && !flag) {
world.c(i, j, k, this.id, b[j1] * 2);
} else if (!this.c && flag) {
world.c(i, j, k, this.id, b[j1] * 2);
}
}
}
private boolean f(World world, int i, int j, int k, int l) {
int i1 = l & 3;
switch (i1) {
case 0:
return world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) || world.getTypeId(i, j, k + 1) == Block.REDSTONE_WIRE.id && world.getData(i, j, k + 1) > 0;
case 1:
return world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) || world.getTypeId(i - 1, j, k) == Block.REDSTONE_WIRE.id && world.getData(i - 1, j, k) > 0;
case 2:
return world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) || world.getTypeId(i, j, k - 1) == Block.REDSTONE_WIRE.id && world.getData(i, j, k - 1) > 0;
case 3:
return world.isBlockFaceIndirectlyPowered(i + 1, j, k, 5) || world.getTypeId(i + 1, j, k) == Block.REDSTONE_WIRE.id && world.getData(i + 1, j, k) > 0;
default:
return false;
}
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
int l = world.getData(i, j, k);
int i1 = (l & 12) >> 2;
i1 = i1 + 1 << 2 & 12;
world.setData(i, j, k, i1 | l & 3);
return true;
}
public boolean isPowerSource() {
return false;
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
world.setData(i, j, k, l);
boolean flag = this.f(world, i, j, k, l);
if (flag) {
world.c(i, j, k, this.id, 1);
}
}
public void c(World world, int i, int j, int k) {
world.applyPhysics(i + 1, j, k, this.id);
world.applyPhysics(i - 1, j, k, this.id);
world.applyPhysics(i, j, k + 1, this.id);
world.applyPhysics(i, j, k - 1, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.applyPhysics(i, j + 1, k, this.id);
}
public boolean a() {
return false;
}
public int a(int i, Random random) {
return Item.DIODE.id;
}
}
@@ -0,0 +1,8 @@
package net.minecraft.server;
public class BlockDirt extends Block {
protected BlockDirt(int i, int j) {
super(i, j, Material.EARTH);
}
}
@@ -0,0 +1,249 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.util.Vector;
import java.util.Random;
// CraftBukkit start
// CraftBukkit end
public class BlockDispenser extends BlockContainer {
private Random a = new Random();
protected BlockDispenser(int i) {
super(i, Material.STONE);
this.textureId = 45;
}
public int c() {
return 4;
}
public int a(int i, Random random) {
return Block.DISPENSER.id;
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
this.g(world, i, j, k);
}
private void g(World world, int i, int j, int k) {
if (!world.isStatic) {
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);
byte b0 = 3;
if (Block.o[l] && !Block.o[i1]) {
b0 = 3;
}
if (Block.o[i1] && !Block.o[l]) {
b0 = 2;
}
if (Block.o[j1] && !Block.o[k1]) {
b0 = 5;
}
if (Block.o[k1] && !Block.o[j1]) {
b0 = 4;
}
world.setData(i, j, k, b0);
}
}
public int a(int i) {
return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId + 1 : this.textureId));
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);
entityhuman.a(tileentitydispenser);
return true;
}
}
// CraftBukkit - private -> public
public void dispense(World world, int i, int j, int k, Random random) {
int l = world.getData(i, j, k);
byte b0 = 0;
byte b1 = 0;
if (l == 3) {
b1 = 1;
} else if (l == 2) {
b1 = -1;
} else if (l == 5) {
b0 = 1;
} else {
b0 = -1;
}
TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);
// CraftBukkit start
int dispenseSlot = tileentitydispenser.findDispenseSlot();
ItemStack itemstack = null;
if (dispenseSlot > -1) {
itemstack = tileentitydispenser.getContents()[dispenseSlot];
// Copy item stack, because we want it to have 1 item
itemstack = new ItemStack(itemstack.id, 1, itemstack.damage);
}
// CraftBukkit end
double d0 = (double) i + (double) b0 * 0.6D + 0.5D;
double d1 = (double) j + 0.5D;
double d2 = (double) k + (double) b1 * 0.6D + 0.5D;
if (itemstack == null) {
world.e(1001, i, j, k, 0);
} else {
// CraftBukkit start
double d3 = random.nextDouble() * 0.1D + 0.2D;
double motX = (double) b0 * d3;
double motY = 0.20000000298023224D;
double motZ = (double) b1 * d3;
motX += random.nextGaussian() * 0.007499999832361937D * 6.0D;
motY += random.nextGaussian() * 0.007499999832361937D * 6.0D;
motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D;
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone();
BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ));
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// Actually remove the item
tileentitydispenser.splitStack(dispenseSlot, 1);
motX = event.getVelocity().getX();
motY = event.getVelocity().getY();
motZ = event.getVelocity().getZ();
itemstack = new ItemStack(event.getItem().getTypeId(), event.getItem().getAmount(), event.getItem().getDurability());
// CraftBukkit end
if (itemstack.id == Item.ARROW.id) {
EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2);
entityarrow.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
entityarrow.fromPlayer = true;
world.addEntity(entityarrow);
world.e(1002, i, j, k, 0);
} else if (itemstack.id == Item.EGG.id) {
EntityEgg entityegg = new EntityEgg(world, d0, d1, d2);
entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
world.addEntity(entityegg);
world.e(1002, i, j, k, 0);
} else if (itemstack.id == Item.SNOW_BALL.id) {
EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2);
entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
world.addEntity(entitysnowball);
world.e(1002, i, j, k, 0);
} else {
EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
// CraftBukkit start
// double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up
entityitem.motX = motX;
entityitem.motY = motY;
entityitem.motZ = motZ;
// CraftBukkit end
world.addEntity(entityitem);
world.e(1000, i, j, k, 0);
}
world.e(2000, i, j, k, b0 + 1 + (b1 + 1) * 3);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (l > 0 && Block.byId[l].isPowerSource()) {
boolean flag = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k);
if (flag) {
world.c(i, j, k, this.id, this.c());
}
}
}
public void a(World world, int i, int j, int k, Random random) {
if (world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k)) {
this.dispense(world, i, j, k, random);
}
}
protected TileEntity a_() {
return new TileEntityDispenser();
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) {
world.setData(i, j, k, 2);
}
if (l == 1) {
world.setData(i, j, k, 5);
}
if (l == 2) {
world.setData(i, j, k, 3);
}
if (l == 3) {
world.setData(i, j, k, 4);
}
}
public void remove(World world, int i, int j, int k) {
TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);
for (int l = 0; l < tileentitydispenser.getSize(); ++l) {
ItemStack itemstack = tileentitydispenser.getItem(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.count > 0) {
int i1 = this.a.nextInt(21) + 10;
if (i1 > itemstack.count) {
i1 = itemstack.count;
}
itemstack.count -= i1;
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData()));
float f3 = 0.05F;
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
world.addEntity(entityitem);
}
tileentitydispenser.setItem(l, null);
}
}
super.remove(world, i, j, k);
}
}
@@ -0,0 +1,211 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
import java.util.Random;
public class BlockDoor extends Block {
protected BlockDoor(int i, Material material) {
super(i, material);
this.textureId = 97;
if (material == Material.ORE) {
++this.textureId;
}
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 int a(int i, int j) {
if (i != 0 && i != 1) {
int k = this.d(j);
if ((k == 0 || k == 2) ^ i <= 3) {
return this.textureId;
} else {
int l = k / 2 + (i & 1 ^ k);
l += (j & 4) / 4;
int i1 = this.textureId - (j & 8) * 2;
if ((l & 1) != 0) {
i1 = -i1;
}
return i1;
}
} else {
return this.textureId;
}
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public AxisAlignedBB e(World world, int i, int j, int k) {
this.a(world, i, j, k);
return super.e(world, i, j, k);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
this.c(this.d(iblockaccess.getData(i, j, k)));
}
public void c(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.interact(world, i, j, k, entityhuman);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (this.material == Material.ORE) {
return true;
} else {
int l = world.getData(i, j, k);
if ((l & 8) != 0) {
if (world.getTypeId(i, j - 1, k) == this.id) {
this.interact(world, i, j - 1, k, entityhuman);
}
return true;
} else {
if (world.getTypeId(i, j + 1, k) == this.id) {
world.setData(i, j + 1, k, (l ^ 4) + 8);
}
world.setData(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k);
world.a(entityhuman, 1003, i, j, k, 0);
return true;
}
}
}
public void setDoor(World world, int i, int j, int k, boolean flag) {
int l = world.getData(i, j, k);
if ((l & 8) != 0) {
if (world.getTypeId(i, j - 1, k) == this.id) {
this.setDoor(world, i, j - 1, k, flag);
}
} else {
boolean flag1 = (world.getData(i, j, k) & 4) > 0;
if (flag1 != flag) {
if (world.getTypeId(i, j + 1, k) == this.id) {
world.setData(i, j + 1, k, (l ^ 4) + 8);
}
world.setData(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k);
world.a((EntityHuman) null, 1003, i, j, k, 0);
}
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
if ((i1 & 8) != 0) {
if (world.getTypeId(i, j - 1, k) != this.id) {
world.setTypeId(i, j, k, 0);
}
if (l > 0 && Block.byId[l].isPowerSource()) {
this.doPhysics(world, i, j - 1, k, l);
}
} else {
boolean flag = false;
if (world.getTypeId(i, j + 1, k) != this.id) {
world.setTypeId(i, j, k, 0);
flag = true;
}
if (!world.e(i, j - 1, k)) {
world.setTypeId(i, j, k, 0);
flag = true;
if (world.getTypeId(i, j + 1, k) == this.id) {
world.setTypeId(i, j + 1, k, 0);
}
}
if (flag) {
if (!world.isStatic) {
this.g(world, i, j, k, i1);
}
} else if (l > 0 && Block.byId[l].isPowerSource()) {
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
org.bukkit.block.Block blockTop = bworld.getBlockAt(i, j + 1, k);
int power = block.getBlockPower();
int powerTop = blockTop.getBlockPower();
if (powerTop > power) power = powerTop;
int oldPower = (world.getData(i, j, k) & 4) > 0 ? 15 : 0;
if (oldPower == 0 ^ power == 0) {
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, oldPower, power);
world.getServer().getPluginManager().callEvent(eventRedstone);
this.setDoor(world, i, j, k, eventRedstone.getNewCurrent() > 0);
}
// CraftBukkit end
}
}
}
public int a(int i, Random random) {
return (i & 8) != 0 ? 0 : (this.material == Material.ORE ? Item.IRON_DOOR.id : Item.WOOD_DOOR.id);
}
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
this.a(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 canPlace(World world, int i, int j, int k) {
return j >= 127 ? false : world.e(i, j - 1, k) && super.canPlace(world, i, j, k) && super.canPlace(world, i, j + 1, k);
}
public static boolean e(int i) {
return (i & 4) != 0;
}
public int e() {
return 1;
}
}
@@ -0,0 +1,70 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
public class BlockFence extends Block {
private boolean modernFencingBounding = false;
public BlockFence(int i, int j) {
super(i, j, Material.WOOD);
modernFencingBounding = (boolean) PoseidonConfig.getInstance().getConfigOption("world-settings.use-modern-fence-bounding-boxes", false);
}
public boolean canPlace(World world, int i, int j, int k) {
return world.getTypeId(i, j - 1, k) == this.id ? true : (!world.getMaterial(i, j - 1, k).isBuildable() ? false : super.canPlace(world, i, j, k));
}
public AxisAlignedBB e(World world, int i, int j, int k) {
if(!modernFencingBounding) {
return AxisAlignedBB.b((double) i, (double) j, (double) k, (double) (i + 1), (double) ((float) j + 1.5F), (double) (k + 1));
}
boolean flag = this.b(world, i, j, k - 1);
boolean flag1 = this.b(world, i, j, k + 1);
boolean flag2 = this.b(world, i - 1, j, k);
boolean flag3 = this.b(world, i + 1, j, k);
float f = 0.375F;
float f1 = 0.625F;
float f2 = 0.375F;
float f3 = 0.625F;
if (flag) {
f2 = 0.0F;
}
if (flag1) {
f3 = 1.0F;
}
if (flag2) {
f = 0.0F;
}
if (flag3) {
f1 = 1.0F;
}
return AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f2), (double) ((float) i + f1), (double) ((float) j + 1.5F), (double) ((float) k + f3));
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getTypeId(i, j, k);
if (l != this.id) {
Block block = Block.byId[l];
return block != null && block.material.h() && block.b() ? block.material != Material.PUMPKIN : false;
} else {
return true;
}
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
}
@@ -0,0 +1,242 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.material.MaterialData;
import java.util.Random;
// CraftBukkit start
// CraftBukkit end
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.FIRE);
this.a(true);
}
public void h() {
this.a(Block.WOOD.id, 5, 20);
this.a(Block.FENCE.id, 5, 20);
this.a(Block.WOOD_STAIRS.id, 5, 20);
this.a(Block.LOG.id, 5, 5);
this.a(Block.LEAVES.id, 30, 60);
this.a(Block.BOOKSHELF.id, 30, 20);
this.a(Block.TNT.id, 15, 100);
this.a(Block.LONG_GRASS.id, 60, 100);
this.a(Block.WOOL.id, 30, 60);
}
private void a(int i, int j, int k) {
this.a[i] = j;
this.b[i] = k;
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public int a(Random random) {
return 0;
}
public int c() {
return 40;
}
public void a(World world, int i, int j, int k, Random random) {
boolean flag = world.getTypeId(i, j - 1, k) == Block.NETHERRACK.id;
if (!this.canPlace(world, i, j, k)) {
world.setTypeId(i, j, k, 0);
}
if (!flag && world.v() && (world.s(i, j, k) || world.s(i - 1, j, k) || world.s(i + 1, j, k) || world.s(i, j, k - 1) || world.s(i, j, k + 1))) {
world.setTypeId(i, j, k, 0);
} else {
int l = world.getData(i, j, k);
if (l < 15) {
world.setRawData(i, j, k, l + random.nextInt(3) / 2);
}
world.c(i, j, k, this.id, this.c());
if (!flag && !this.g(world, i, j, k)) {
if (!world.e(i, j - 1, k) || l > 3) {
world.setTypeId(i, j, k, 0);
}
} else if (!flag && !this.b(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
world.setTypeId(i, j, k, 0);
} else {
this.a(world, i + 1, j, k, 300, random, l);
this.a(world, i - 1, j, k, 300, random, l);
this.a(world, i, j - 1, k, 250, random, l);
this.a(world, i, j + 1, k, 250, random, l);
this.a(world, i, j, k - 1, 300, random, l);
this.a(world, i, j, k + 1, 300, random, l);
// CraftBukkit start - Call to stop spread of fire.
org.bukkit.Server server = world.getServer();
org.bukkit.World bworld = world.getWorld();
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
org.bukkit.block.Block fromBlock = bworld.getBlockAt(i, j, k);
// CraftBukkit end
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) {
int j2 = (i2 + 40) / (l + 30);
if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.v() || !world.s(i1, k1, j1)) && !world.s(i1 - 1, k1, k) && !world.s(i1 + 1, k1, j1) && !world.s(i1, k1, j1 - 1) && !world.s(i1, k1, j1 + 1)) {
int k2 = l + random.nextInt(5) / 4;
if (k2 > 15) {
k2 = 15;
}
// CraftBukkit start - Call to stop spread of fire.
org.bukkit.block.Block block = bworld.getBlockAt(i1, k1, j1);
if (block.getTypeId() != Block.FIRE.id) {
BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState();
blockState.setTypeId(this.id);
blockState.setData(new MaterialData(this.id, (byte) k2));
BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), fromBlock, blockState);
server.getPluginManager().callEvent(spreadEvent);
if (!spreadEvent.isCancelled()) {
blockState.update(true);
}
}
// CraftBukkit end
}
}
}
}
}
}
}
}
}
private void a(World world, int i, int j, int k, int l, Random random, int i1) {
int j1 = this.b[world.getTypeId(i, j, k)];
if (random.nextInt(l) < j1) {
boolean flag = world.getTypeId(i, j, k) == Block.TNT.id;
// CraftBukkit start
org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(i, j, k);
BlockBurnEvent event = new BlockBurnEvent(theBlock);
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// CraftBukkit end
if (random.nextInt(i1 + 10) < 5 && !world.s(i, j, k)) {
int k1 = i1 + random.nextInt(5) / 4;
if (k1 > 15) {
k1 = 15;
}
world.setTypeIdAndData(i, j, k, this.id, k1);
} else {
world.setTypeId(i, j, k, 0);
}
if (flag) {
Block.TNT.postBreak(world, i, j, k, 1);
}
}
}
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.isEmpty(i, j, k)) {
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 k_() {
return false;
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
return this.a[iblockaccess.getTypeId(i, j, k)] > 0;
}
public int f(World world, int i, int j, int k, int l) {
int i1 = this.a[world.getTypeId(i, j, k)];
return i1 > l ? i1 : l;
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i, j - 1, k) || this.g(world, i, j, k);
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.e(i, j - 1, k) && !this.g(world, i, j, k)) {
world.setTypeId(i, j, k, 0);
}
}
public void c(World world, int i, int j, int k) {
if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.a_(world, i, j, k)) {
if (!world.e(i, j - 1, k) && !this.g(world, i, j, k)) {
world.setTypeId(i, j, k, 0);
} else {
world.c(i, j, k, this.id, this.c());
}
}
}
}
@@ -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.PLANT);
this.textureId = 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 canPlace(World world, int i, int j, int k) {
return super.canPlace(world, i, j, k) && this.c(world.getTypeId(i, j - 1, k));
}
protected boolean c(int i) {
return i == Block.GRASS.id || i == Block.DIRT.id || i == Block.SOIL.id;
}
public void doPhysics(World world, int i, int j, int k, int l) {
super.doPhysics(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.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
public boolean f(World world, int i, int j, int k) {
return (world.k(i, j, k) >= 8 || world.isChunkLoaded(i, j, k)) && this.c(world.getTypeId(i, j - 1, k));
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
}
@@ -0,0 +1,308 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
import org.bukkit.block.BlockFace;
import org.bukkit.event.block.BlockFromToEvent;
import java.util.Random;
// CraftBukkit start
// CraftBukkit end
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 l = world.getData(i, j, k);
world.setRawTypeIdAndData(i, j, k, this.id + 1, l);
world.b(i, j, k, i, j, k);
world.notify(i, j, k);
}
public void a(World world, int i, int j, int k, Random random) {
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
org.bukkit.Server server = world.getServer();
org.bukkit.block.Block source = bworld == null ? null : bworld.getBlockAt(i, j, k);
// CraftBukkit end
int l = this.g(world, i, j, k);
byte b0 = 1;
if (this.material == Material.LAVA && !world.worldProvider.d) {
b0 = 2;
}
boolean flag = true;
int i1;
if (l > 0) {
byte b1 = -100;
this.a = 0;
int j1 = this.f(world, i - 1, j, k, b1);
j1 = this.f(world, i + 1, j, k, j1);
j1 = this.f(world, i, j, k - 1, j1);
j1 = this.f(world, i, j, k + 1, j1);
i1 = j1 + b0;
if (i1 >= 8 || j1 < 0) {
i1 = -1;
}
if (this.g(world, i, j + 1, k) >= 0) {
int k1 = this.g(world, i, j + 1, k);
if (k1 >= 8) {
i1 = k1;
} else {
i1 = k1 + 8;
}
}
if (this.a >= 2 && this.material == Material.WATER) {
if (world.getMaterial(i, j - 1, k).isBuildable()) {
i1 = 0;
} else if (world.getMaterial(i, j - 1, k) == this.material && world.getData(i, j, k) == 0) {
i1 = 0;
}
}
if (this.material == Material.LAVA && l < 8 && i1 < 8 && i1 > l && random.nextInt(4) != 0) {
// Poseidon start - Fix flowing lava not disappearing
boolean fixFlowingLava = PoseidonConfig.getInstance().getConfigBoolean("world.settings.flowing-lava-fix.enabled", true);
if (!fixFlowingLava) {
i1 = l;
}
// Poseidon end
flag = false;
}
if (i1 != l) {
l = i1;
if (i1 < 0) {
world.setTypeId(i, j, k, 0);
} else {
world.setData(i, j, k, i1);
world.c(i, j, k, this.id, this.c());
world.applyPhysics(i, j, k, this.id);
}
} else if (flag) {
this.i(world, i, j, k);
}
} else {
this.i(world, i, j, k);
}
if (this.l(world, i, j - 1, k)) {
// CraftBukkit start - send "down" to the server
BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
if (server != null) {
server.getPluginManager().callEvent(event);
}
if (!event.isCancelled()) {
if (l >= 8) {
world.setTypeIdAndData(i, j - 1, k, this.id, l);
} else {
world.setTypeIdAndData(i, j - 1, k, this.id, l + 8);
}
}
// CraftBukkit end
} else if (l >= 0 && (l == 0 || this.k(world, i, j - 1, k))) {
boolean[] aboolean = this.j(world, i, j, k);
i1 = l + b0;
if (l >= 8) {
i1 = 1;
}
if (i1 >= 8) {
return;
}
// CraftBukkit start - all four cardinal directions. Do not change the order!
BlockFace[] faces = new BlockFace[] { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST };
int index = 0;
for (BlockFace currentFace: faces) {
if (aboolean[index]) {
BlockFromToEvent event = new BlockFromToEvent(source, currentFace);
if (server != null) {
server.getPluginManager().callEvent(event);
}
if (!event.isCancelled()) {
this.flow(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), i1);
}
}
index++;
}
// CraftBukkit end
}
}
private void flow(World world, int i, int j, int k, int l) {
if (this.l(world, i, j, k)) {
int i1 = world.getTypeId(i, j, k);
if (i1 > 0) {
if (this.material == Material.LAVA) {
this.h(world, i, j, k);
} else {
Block.byId[i1].g(world, i, j, k, world.getData(i, j, k));
}
}
world.setTypeIdAndData(i, j, k, this.id, l);
}
}
private int b(World world, int i, int j, int k, int l, int i1) {
int j1 = 1000;
for (int k1 = 0; k1 < 4; ++k1) {
if ((k1 != 0 || i1 != 1) && (k1 != 1 || i1 != 0) && (k1 != 2 || i1 != 3) && (k1 != 3 || i1 != 2)) {
int l1 = i;
int i2 = k;
if (k1 == 0) {
l1 = i - 1;
}
if (k1 == 1) {
++l1;
}
if (k1 == 2) {
i2 = k - 1;
}
if (k1 == 3) {
++i2;
}
if (!this.k(world, l1, j, i2) && (world.getMaterial(l1, j, i2) != this.material || world.getData(l1, j, i2) != 0)) {
if (!this.k(world, l1, j - 1, i2)) {
return l;
}
if (l < 4) {
int j2 = this.b(world, l1, j, i2, l + 1, k1);
if (j2 < j1) {
j1 = j2;
}
}
}
}
}
return j1;
}
private boolean[] j(World world, int i, int j, int k) {
int l;
int i1;
for (l = 0; l < 4; ++l) {
this.c[l] = 1000;
i1 = i;
int j1 = k;
if (l == 0) {
i1 = i - 1;
}
if (l == 1) {
++i1;
}
if (l == 2) {
j1 = k - 1;
}
if (l == 3) {
++j1;
}
if (!this.k(world, i1, j, j1) && (world.getMaterial(i1, j, j1) != this.material || world.getData(i1, j, j1) != 0)) {
if (!this.k(world, i1, j - 1, j1)) {
this.c[l] = 0;
} else {
this.c[l] = this.b(world, i1, j, j1, 1, l);
}
}
}
l = this.c[0];
for (i1 = 1; i1 < 4; ++i1) {
if (this.c[i1] < l) {
l = this.c[i1];
}
}
for (i1 = 0; i1 < 4; ++i1) {
this.b[i1] = this.c[i1] == l;
}
return this.b;
}
private boolean k(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k);
if (l != Block.WOODEN_DOOR.id && l != Block.IRON_DOOR_BLOCK.id && l != Block.SIGN_POST.id && l != Block.LADDER.id && l != Block.SUGAR_CANE_BLOCK.id) {
if (l == 0) {
return false;
} else {
Material material = Block.byId[l].material;
return material.isSolid();
}
} else {
return true;
}
}
protected int f(World world, int i, int j, int k, int l) {
int i1 = this.g(world, i, j, k);
if (i1 < 0) {
return l;
} else {
if (i1 == 0) {
++this.a;
}
if (i1 >= 8) {
i1 = 0;
}
return l >= 0 && i1 >= l ? l : i1;
}
}
private boolean l(World world, int i, int j, int k) {
Material material = world.getMaterial(i, j, k);
return material == this.material ? false : (material == Material.LAVA ? false : !this.k(world, i, j, k));
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
if (world.getTypeId(i, j, k) == this.id) {
world.c(i, j, k, this.id, this.c());
}
}
}
@@ -0,0 +1,234 @@
package net.minecraft.server;
import java.util.Random;
public abstract class BlockFluids extends Block {
protected BlockFluids(int i, Material material) {
super(i, (material == Material.LAVA ? 14 : 12) * 16 + 13, material);
float f = 0.0F;
float f1 = 0.0F;
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 c(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.textureId + 1 : this.textureId;
}
protected int g(World world, int i, int j, int k) {
return world.getMaterial(i, j, k) != this.material ? -1 : world.getData(i, j, k);
}
protected int b(IBlockAccess iblockaccess, int i, int j, int k) {
if (iblockaccess.getMaterial(i, j, k) != this.material) {
return -1;
} else {
int l = iblockaccess.getData(i, j, k);
if (l >= 8) {
l = 0;
}
return l;
}
}
public boolean b() {
return false;
}
public boolean a() {
return false;
}
public boolean a(int i, boolean flag) {
return flag && i == 0;
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
Material material = iblockaccess.getMaterial(i, j, k);
return material == this.material ? false : (material == Material.ICE ? false : (l == 1 ? true : super.b(iblockaccess, i, j, k, l)));
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
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.create(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.getMaterial(j1, j, k1).isSolid()) {
l1 = this.b(iblockaccess, j1, j - 1, k1);
if (l1 >= 0) {
i2 = l1 - (l - 8);
vec3d = vec3d.add((double) ((j1 - i) * i2), (double) ((j - j) * i2), (double) ((k1 - k) * i2));
}
}
} else if (l1 >= 0) {
i2 = l1 - l;
vec3d = vec3d.add((double) ((j1 - i) * i2), (double) ((j - j) * i2), (double) ((k1 - k) * i2));
}
}
if (iblockaccess.getData(i, j, k) >= 8) {
boolean flag = false;
if (flag || this.b(iblockaccess, i, j, k - 1, 2)) {
flag = true;
}
if (flag || this.b(iblockaccess, i, j, k + 1, 3)) {
flag = true;
}
if (flag || this.b(iblockaccess, i - 1, j, k, 4)) {
flag = true;
}
if (flag || this.b(iblockaccess, i + 1, j, k, 5)) {
flag = true;
}
if (flag || this.b(iblockaccess, i, j + 1, k - 1, 2)) {
flag = true;
}
if (flag || this.b(iblockaccess, i, j + 1, k + 1, 3)) {
flag = true;
}
if (flag || this.b(iblockaccess, i - 1, j + 1, k, 4)) {
flag = true;
}
if (flag || this.b(iblockaccess, i + 1, j + 1, k, 5)) {
flag = true;
}
if (flag) {
vec3d = vec3d.b().add(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((IBlockAccess) world, i, j, k);
vec3d.a += vec3d1.a;
vec3d.b += vec3d1.b;
vec3d.c += vec3d1.c;
}
public int c() {
return this.material == Material.WATER ? 5 : (this.material == Material.LAVA ? 30 : 0);
}
public void a(World world, int i, int j, int k, Random random) {
super.a(world, i, j, k, random);
}
public void c(World world, int i, int j, int k) {
this.i(world, i, j, k);
}
public void doPhysics(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.getTypeId(i, j, k) == this.id) {
if (this.material == Material.LAVA) {
boolean flag = false;
if (flag || world.getMaterial(i, j, k - 1) == Material.WATER) {
flag = true;
}
if (flag || world.getMaterial(i, j, k + 1) == Material.WATER) {
flag = true;
}
if (flag || world.getMaterial(i - 1, j, k) == Material.WATER) {
flag = true;
}
if (flag || world.getMaterial(i + 1, j, k) == Material.WATER) {
flag = true;
}
if (flag || world.getMaterial(i, j + 1, k) == Material.WATER) {
flag = true;
}
if (flag) {
int l = world.getData(i, j, k);
if (l == 0) {
world.setTypeId(i, j, k, Block.OBSIDIAN.id);
} else if (l <= 4) {
world.setTypeId(i, j, k, Block.COBBLESTONE.id);
}
this.h(world, i, j, k);
}
}
}
}
protected void h(World world, int i, int j, int k) {
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.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);
}
}
}
@@ -0,0 +1,147 @@
package net.minecraft.server;
import java.util.Random;
public class BlockFurnace extends BlockContainer {
private Random a = new Random();
private final boolean b;
private static boolean c = false;
protected BlockFurnace(int i, boolean flag) {
super(i, Material.STONE);
this.b = flag;
this.textureId = 45;
}
public int a(int i, Random random) {
return Block.FURNACE.id;
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
this.g(world, i, j, k);
}
private void g(World world, int i, int j, int k) {
if (!world.isStatic) {
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);
byte b0 = 3;
if (Block.o[l] && !Block.o[i1]) {
b0 = 3;
}
if (Block.o[i1] && !Block.o[l]) {
b0 = 2;
}
if (Block.o[j1] && !Block.o[k1]) {
b0 = 5;
}
if (Block.o[k1] && !Block.o[j1]) {
b0 = 4;
}
world.setData(i, j, k, b0);
}
}
public int a(int i) {
return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId));
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(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.getData(i, j, k);
TileEntity tileentity = world.getTileEntity(i, j, k);
if (tileentity == null) return; // CraftBukkit
c = true;
if (flag) {
world.setTypeId(i, j, k, Block.BURNING_FURNACE.id);
} else {
world.setTypeId(i, j, k, Block.FURNACE.id);
}
c = false;
world.setData(i, j, k, l);
tileentity.j();
world.setTileEntity(i, j, k, tileentity);
}
protected TileEntity a_() {
return new TileEntityFurnace();
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) {
world.setData(i, j, k, 2);
}
if (l == 1) {
world.setData(i, j, k, 5);
}
if (l == 2) {
world.setData(i, j, k, 3);
}
if (l == 3) {
world.setData(i, j, k, 4);
}
}
public void remove(World world, int i, int j, int k) {
if (!c) {
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
if (tileentityfurnace == null) return; // CraftBukkit
for (int l = 0; l < tileentityfurnace.getSize(); ++l) {
ItemStack itemstack = tileentityfurnace.getItem(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.count > 0) {
int i1 = this.a.nextInt(21) + 10;
if (i1 > itemstack.count) {
i1 = itemstack.count;
}
itemstack.count -= i1;
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData()));
float f3 = 0.05F;
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
world.addEntity(entityitem);
}
tileentityfurnace.setItem(l, null);
}
}
}
super.remove(world, i, j, k);
}
}
@@ -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;
}
}
@@ -0,0 +1,64 @@
package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.BlockFadeEvent;
//CraftBukkit end
public class BlockGrass extends Block {
protected BlockGrass(int i) {
super(i, Material.GRASS);
this.textureId = 3;
this.a(true);
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
if (world.getLightLevel(i, j + 1, k) < 4 && Block.q[world.getTypeId(i, j + 1, k)] > 2) {
if (random.nextInt(4) != 0) {
return;
}
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.BlockState blockState = bworld.getBlockAt(i, j, k).getState();
blockState.setTypeId(Block.DIRT.id);
BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
} else if (world.getLightLevel(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;
int k1 = world.getTypeId(l, i1 + 1, j1);
if (world.getTypeId(l, i1, j1) == Block.DIRT.id && world.getLightLevel(l, i1 + 1, j1) >= 4 && Block.q[k1] <= 2) {
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.BlockState blockState = bworld.getBlockAt(l, i1, j1).getState();
blockState.setTypeId(this.id);
BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
}
}
}
}
public int a(int i, Random random) {
return Block.DIRT.a(0, random);
}
}
@@ -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.id : this.id;
}
}
@@ -0,0 +1,44 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import java.util.Random;
public class BlockIce extends BlockBreakable {
public BlockIce(int i, int j) {
super(i, j, Material.ICE, false);
this.frictionFactor = 0.98F;
this.a(true);
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
super.a(world, entityhuman, i, j, k, l);
Material material = world.getMaterial(i, j - 1, k);
if (material.isSolid() || material.isLiquid()) {
world.setTypeId(i, j, k, Block.WATER.id);
}
}
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.q[this.id]) {
// CraftBukkit start
if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), Block.STATIONARY_WATER.id).isCancelled()) {
return;
}
// CraftBukkit end
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, Block.STATIONARY_WATER.id);
}
}
public int e() {
return 0;
}
}
@@ -0,0 +1,70 @@
package net.minecraft.server;
public class BlockJukeBox extends BlockContainer {
protected BlockJukeBox(int i, int j) {
super(i, j, Material.WOOD);
}
public int a(int i) {
return this.textureId + (i == 1 ? 1 : 0);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.getData(i, j, k) == 0) {
return false;
} else {
this.b_(world, i, j, k);
return true;
}
}
public void f(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
TileEntityRecordPlayer tileentityrecordplayer = (TileEntityRecordPlayer) world.getTileEntity(i, j, k);
tileentityrecordplayer.a = l;
tileentityrecordplayer.update();
world.setData(i, j, k, 1);
}
}
public void b_(World world, int i, int j, int k) {
if (!world.isStatic) {
TileEntityRecordPlayer tileentityrecordplayer = (TileEntityRecordPlayer) world.getTileEntity(i, j, k);
if (tileentityrecordplayer == null) return; // CraftBukkit
int l = tileentityrecordplayer.a;
if (l != 0) {
world.e(1005, i, j, k, 0);
world.a((String) null, i, j, k);
tileentityrecordplayer.a = 0;
tileentityrecordplayer.update();
world.setData(i, j, k, 0);
float f = 0.7F;
double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(l, 1, 0));
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
}
}
}
public void remove(World world, int i, int j, int k) {
this.b_(world, i, j, k);
super.remove(world, i, j, k);
}
public void dropNaturally(World world, int i, int j, int k, int l, float f) {
if (!world.isStatic) {
super.dropNaturally(world, i, j, k, l, f);
}
}
protected TileEntity a_() {
return new TileEntityRecordPlayer();
}
}
@@ -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.ORIENTABLE);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
int l = world.getData(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.e(world, i, j, k);
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i - 1, j, k) ? true : (world.e(i + 1, j, k) ? true : (world.e(i, j, k - 1) ? true : world.e(i, j, k + 1)));
}
public void postPlace(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
if ((i1 == 0 || l == 2) && world.e(i, j, k + 1)) {
i1 = 2;
}
if ((i1 == 0 || l == 3) && world.e(i, j, k - 1)) {
i1 = 3;
}
if ((i1 == 0 || l == 4) && world.e(i + 1, j, k)) {
i1 = 4;
}
if ((i1 == 0 || l == 5) && world.e(i - 1, j, k)) {
i1 = 5;
}
world.setData(i, j, k, i1);
}
public void doPhysics(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
boolean flag = false;
if (i1 == 2 && world.e(i, j, k + 1)) {
flag = true;
}
if (i1 == 3 && world.e(i, j, k - 1)) {
flag = true;
}
if (i1 == 4 && world.e(i + 1, j, k)) {
flag = true;
}
if (i1 == 5 && world.e(i - 1, j, k)) {
flag = true;
}
if (!flag) {
this.g(world, i, j, k, i1);
world.setTypeId(i, j, k, 0);
}
super.doPhysics(world, i, j, k, l);
}
public int a(Random random) {
return 1;
}
}
@@ -0,0 +1,165 @@
package net.minecraft.server;
import org.bukkit.event.block.LeavesDecayEvent;
import java.util.Random;
public class BlockLeaves extends BlockLeavesBase {
private int c;
int[] a;
protected BlockLeaves(int i, int j) {
super(i, j, Material.LEAVES, false);
this.c = j;
this.a(true);
}
public void remove(World world, int i, int j, int k) {
byte b0 = 1;
int l = b0 + 1;
if (world.a(i - l, j - l, k - l, i + l, j + l, k + l)) {
for (int i1 = -b0; i1 <= b0; ++i1) {
for (int j1 = -b0; j1 <= b0; ++j1) {
for (int k1 = -b0; k1 <= b0; ++k1) {
int l1 = world.getTypeId(i + i1, j + j1, k + k1);
if (l1 == Block.LEAVES.id) {
int i2 = world.getData(i + i1, j + j1, k + k1);
world.setRawData(i + i1, j + j1, k + k1, i2 | 8);
}
}
}
}
}
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
int l = world.getData(i, j, k);
if ((l & 8) != 0) {
byte b0 = 4;
int i1 = b0 + 1;
byte b1 = 32;
int j1 = b1 * b1;
int k1 = b1 / 2;
if (this.a == null) {
this.a = new int[b1 * b1 * b1];
}
int l1;
if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
int i2;
int j2;
int k2;
for (l1 = -b0; l1 <= b0; ++l1) {
for (i2 = -b0; i2 <= b0; ++i2) {
for (j2 = -b0; j2 <= b0; ++j2) {
k2 = world.getTypeId(i + l1, j + i2, k + j2);
if (k2 == Block.LOG.id) {
this.a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
} else if (k2 == Block.LEAVES.id) {
this.a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
} else {
this.a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
}
}
}
}
for (l1 = 1; l1 <= 4; ++l1) {
for (i2 = -b0; i2 <= b0; ++i2) {
for (j2 = -b0; j2 <= b0; ++j2) {
for (k2 = -b0; k2 <= b0; ++k2) {
if (this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) {
if (this.a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
this.a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (this.a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
this.a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (this.a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) {
this.a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
}
if (this.a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) {
this.a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
}
if (this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) {
this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
}
if (this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) {
this.a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
}
}
}
}
}
}
}
l1 = this.a[k1 * j1 + k1 * b1 + k1];
if (l1 >= 0) {
world.setRawData(i, j, k, l & -9);
} else {
this.g(world, i, j, k);
}
}
}
}
private void g(World world, int i, int j, int k) {
// CraftBukkit start
LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(i, j, k));
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) return;
// CraftBukkit end
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(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.id;
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.G() != null && entityhuman.G().id == Item.SHEARS.id) {
entityhuman.a(StatisticList.C[this.id], 1);
this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3));
} else {
super.a(world, entityhuman, i, j, k, l);
}
}
protected int a_(int i) {
return i & 3;
}
public boolean a() {
return !this.b;
}
public int a(int i, int j) {
return (j & 3) == 1 ? this.textureId + 80 : this.textureId;
}
public void b(World world, int i, int j, int k, Entity entity) {
super.b(world, i, j, k, entity);
}
}
@@ -0,0 +1,15 @@
package net.minecraft.server;
public class BlockLeavesBase extends Block {
protected boolean b;
protected BlockLeavesBase(int i, int j, Material material, boolean flag) {
super(i, j, material);
this.b = flag;
}
public boolean a() {
return false;
}
}
@@ -0,0 +1,216 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockLever extends Block {
protected BlockLever(int i, int j) {
super(i, j, Material.ORIENTABLE);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k, int l) {
return l == 1 && world.e(i, j - 1, k) ? true : (l == 2 && world.e(i, j, k + 1) ? true : (l == 3 && world.e(i, j, k - 1) ? true : (l == 4 && world.e(i + 1, j, k) ? true : l == 5 && world.e(i - 1, j, k))));
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i - 1, j, k) ? true : (world.e(i + 1, j, k) ? true : (world.e(i, j, k - 1) ? true : (world.e(i, j, k + 1) ? true : world.e(i, j - 1, k))));
}
public void postPlace(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
int j1 = i1 & 8;
i1 &= 7;
i1 = -1;
if (l == 1 && world.e(i, j - 1, k)) {
i1 = 5 + world.random.nextInt(2);
}
if (l == 2 && world.e(i, j, k + 1)) {
i1 = 4;
}
if (l == 3 && world.e(i, j, k - 1)) {
i1 = 3;
}
if (l == 4 && world.e(i + 1, j, k)) {
i1 = 2;
}
if (l == 5 && world.e(i - 1, j, k)) {
i1 = 1;
}
if (i1 == -1) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
} else {
world.setData(i, j, k, i1 + j1);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (this.g(world, i, j, k)) {
int i1 = world.getData(i, j, k) & 7;
boolean flag = false;
if (!world.e(i - 1, j, k) && i1 == 1) {
flag = true;
}
if (!world.e(i + 1, j, k) && i1 == 2) {
flag = true;
}
if (!world.e(i, j, k - 1) && i1 == 3) {
flag = true;
}
if (!world.e(i, j, k + 1) && i1 == 4) {
flag = true;
}
if (!world.e(i, j - 1, k) && i1 == 5) {
flag = true;
}
if (!world.e(i, j - 1, k) && i1 == 6) {
flag = true;
}
if (flag) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
}
private boolean g(World world, int i, int j, int k) {
if (!this.canPlace(world, i, j, k)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
return false;
} else {
return true;
}
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(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.interact(world, i, j, k, entityhuman);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
int l = world.getData(i, j, k);
int i1 = l & 7;
int j1 = 8 - (l & 8);
// CraftBukkit start - Interact Lever
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
world.getServer().getPluginManager().callEvent(eventRedstone);
if ((eventRedstone.getNewCurrent() > 0) != (j1 == 8)) {
return true;
}
// CraftBukkit end
world.setData(i, j, k, i1 + j1);
world.b(i, j, k, i, j, k);
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 > 0 ? 0.6F : 0.5F);
world.applyPhysics(i, j, k, this.id);
if (i1 == 1) {
world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) {
world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) {
world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) {
world.applyPhysics(i, j, k + 1, this.id);
} else {
world.applyPhysics(i, j - 1, k, this.id);
}
return true;
}
}
public void remove(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
if ((l & 8) > 0) {
world.applyPhysics(i, j, k, this.id);
int i1 = l & 7;
if (i1 == 1) {
world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) {
world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) {
world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) {
world.applyPhysics(i, j, k + 1, this.id);
} else {
world.applyPhysics(i, j - 1, k, this.id);
}
}
super.remove(world, i, j, k);
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return (iblockaccess.getData(i, j, k) & 8) > 0;
}
public boolean d(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k);
if ((i1 & 8) == 0) {
return false;
} else {
int j1 = i1 & 7;
return j1 == 6 && l == 1 ? true : (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 isPowerSource() {
return true;
}
}
@@ -0,0 +1,18 @@
package net.minecraft.server;
import java.util.Random;
public class BlockLightStone extends Block {
public BlockLightStone(int i, int j, Material material) {
super(i, j, material);
}
public int a(Random random) {
return 2 + random.nextInt(3);
}
public int a(int i, Random random) {
return Item.GLOWSTONE_DUST.id;
}
}
@@ -0,0 +1,23 @@
package net.minecraft.server;
import java.util.Random;
public class BlockLockedChest extends Block {
protected BlockLockedChest(int i) {
super(i, Material.WOOD);
this.textureId = 26;
}
public int a(int i) {
return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId - 1 : (i == 3 ? this.textureId + 1 : this.textureId));
}
public boolean canPlace(World world, int i, int j, int k) {
return true;
}
public void a(World world, int i, int j, int k, Random random) {
world.setTypeId(i, j, k, 0);
}
}
@@ -0,0 +1,54 @@
package net.minecraft.server;
import java.util.Random;
public class BlockLog extends Block {
protected BlockLog(int i) {
super(i, Material.WOOD);
this.textureId = 20;
}
public int a(Random random) {
return 1;
}
public int a(int i, Random random) {
return Block.LOG.id;
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
super.a(world, entityhuman, i, j, k, l);
}
public void remove(World world, int i, int j, int k) {
byte b0 = 4;
int l = b0 + 1;
if (world.a(i - l, j - l, k - l, i + l, j + l, k + l)) {
for (int i1 = -b0; i1 <= b0; ++i1) {
for (int j1 = -b0; j1 <= b0; ++j1) {
for (int k1 = -b0; k1 <= b0; ++k1) {
int l1 = world.getTypeId(i + i1, j + j1, k + k1);
if (l1 == Block.LEAVES.id) {
int i2 = world.getData(i + i1, j + j1, k + k1);
if ((i2 & 8) == 0) {
world.setRawData(i + i1, j + j1, k + k1, i2 | 8);
}
}
}
}
}
}
}
public int a(int i, int j) {
return i == 1 ? 21 : (i == 0 ? 21 : (j == 1 ? 116 : (j == 2 ? 117 : 20)));
}
protected int a_(int i) {
return i;
}
}
@@ -0,0 +1,21 @@
package net.minecraft.server;
import java.util.Random;
public class BlockLongGrass extends BlockFlower {
protected BlockLongGrass(int i, int j) {
super(i, j);
float f = 0.4F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
}
public int a(int i, int j) {
return j == 1 ? this.textureId : (j == 2 ? this.textureId + 16 + 1 : (j == 0 ? this.textureId + 16 : this.textureId));
}
public int a(int i, Random random) {
return random.nextInt(8) == 0 ? Item.SEEDS.id : -1;
}
}
@@ -0,0 +1,90 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
import java.util.List;
import java.util.Random;
public class BlockMinecartDetector extends BlockMinecartTrack {
public BlockMinecartDetector(int i, int j) {
super(i, j, true);
this.a(true);
}
public int c() {
return 20;
}
public boolean isPowerSource() {
return true;
}
public void a(World world, int i, int j, int k, Entity entity) {
if (!world.isStatic) {
int l = world.getData(i, j, k);
if ((l & 8) == 0) {
this.f(world, i, j, k, l);
}
}
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
int l = world.getData(i, j, k);
if ((l & 8) != 0) {
this.f(world, i, j, k, l);
}
}
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return (iblockaccess.getData(i, j, k) & 8) != 0;
}
public boolean d(World world, int i, int j, int k, int l) {
return (world.getData(i, j, k) & 8) == 0 ? false : l == 1;
}
private void f(World world, int i, int j, int k, int l) {
boolean flag = (l & 8) != 0;
boolean flag1 = false;
float f = 0.125F;
List list = world.a(EntityMinecart.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;
}
// CraftBukkit start
if (flag != flag1) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 1 : 0, flag1 ? 1 : 0);
world.getServer().getPluginManager().callEvent(eventRedstone);
flag1 = eventRedstone.getNewCurrent() > 0;
}
// CraftBukkit end
if (flag1 && !flag) {
world.setData(i, j, k, l | 8);
world.applyPhysics(i, j, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k);
}
if (!flag1 && flag) {
world.setData(i, j, k, l & 7);
world.applyPhysics(i, j, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k);
}
if (flag1) {
world.c(i, j, k, this.id, this.c());
}
}
}
@@ -0,0 +1,258 @@
package net.minecraft.server;
import java.util.Random;
public class BlockMinecartTrack extends Block {
private final boolean a;
public static final boolean g(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k);
return l == Block.RAILS.id || l == Block.GOLDEN_RAIL.id || l == Block.DETECTOR_RAIL.id;
}
public static final boolean c(int i) {
return i == Block.RAILS.id || i == Block.GOLDEN_RAIL.id || i == Block.DETECTOR_RAIL.id;
}
protected BlockMinecartTrack(int i, int j, boolean flag) {
super(i, j, Material.ORIENTABLE);
this.a = flag;
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean f() {
return this.a;
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
this.a(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.getData(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(int i, int j) {
if (this.a) {
if (this.id == Block.GOLDEN_RAIL.id && (j & 8) == 0) {
return this.textureId - 16;
}
} else if (j >= 6) {
return this.textureId - 16;
}
return this.textureId;
}
public boolean b() {
return false;
}
public int a(Random random) {
return 1;
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i, j - 1, k);
}
public void c(World world, int i, int j, int k) {
if (!world.isStatic) {
this.a(world, i, j, k, true);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
int i1 = world.getData(i, j, k);
int j1 = i1;
if (this.a) {
j1 = i1 & 7;
}
boolean flag = false;
if (!world.e(i, j - 1, k)) {
flag = true;
}
if (j1 == 2 && !world.e(i + 1, j, k)) {
flag = true;
}
if (j1 == 3 && !world.e(i - 1, j, k)) {
flag = true;
}
if (j1 == 4 && !world.e(i, j, k - 1)) {
flag = true;
}
if (j1 == 5 && !world.e(i, j, k + 1)) {
flag = true;
}
if (flag) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
} else if (this.id == Block.GOLDEN_RAIL.id) {
boolean flag1 = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k);
flag1 = flag1 || this.a(world, i, j, k, i1, true, 0) || this.a(world, i, j, k, i1, false, 0);
boolean flag2 = false;
if (flag1 && (i1 & 8) == 0) {
world.setData(i, j, k, j1 | 8);
flag2 = true;
} else if (!flag1 && (i1 & 8) != 0) {
world.setData(i, j, k, j1);
flag2 = true;
}
if (flag2) {
world.applyPhysics(i, j - 1, k, this.id);
if (j1 == 2 || j1 == 3 || j1 == 4 || j1 == 5) {
world.applyPhysics(i, j + 1, k, this.id);
}
}
} else if (l > 0 && Block.byId[l].isPowerSource() && !this.a && MinecartTrackLogic.a(new MinecartTrackLogic(this, world, i, j, k)) == 3) {
this.a(world, i, j, k, false);
}
}
}
private void a(World world, int i, int j, int k, boolean flag) {
if (!world.isStatic) {
(new MinecartTrackLogic(this, world, i, j, k)).a(world.isBlockIndirectlyPowered(i, j, k), flag);
}
}
private boolean a(World world, int i, int j, int k, int l, boolean flag, int i1) {
if (i1 >= 8) {
return false;
} else {
int j1 = l & 7;
boolean flag1 = true;
switch (j1) {
case 0:
if (flag) {
++k;
} else {
--k;
}
break;
case 1:
if (flag) {
--i;
} else {
++i;
}
break;
case 2:
if (flag) {
--i;
} else {
++i;
++j;
flag1 = false;
}
j1 = 1;
break;
case 3:
if (flag) {
--i;
++j;
flag1 = false;
} else {
++i;
}
j1 = 1;
break;
case 4:
if (flag) {
++k;
} else {
--k;
++j;
flag1 = false;
}
j1 = 0;
break;
case 5:
if (flag) {
++k;
++j;
flag1 = false;
} else {
--k;
}
j1 = 0;
}
return this.a(world, i, j, k, flag, i1, j1) ? true : flag1 && this.a(world, i, j - 1, k, flag, i1, j1);
}
}
private boolean a(World world, int i, int j, int k, boolean flag, int l, int i1) {
int j1 = world.getTypeId(i, j, k);
if (j1 == Block.GOLDEN_RAIL.id) {
int k1 = world.getData(i, j, k);
int l1 = k1 & 7;
if (i1 == 1 && (l1 == 0 || l1 == 4 || l1 == 5)) {
return false;
}
if (i1 == 0 && (l1 == 1 || l1 == 2 || l1 == 3)) {
return false;
}
if ((k1 & 8) != 0) {
if (!world.isBlockIndirectlyPowered(i, j, k) && !world.isBlockIndirectlyPowered(i, j + 1, k)) {
return this.a(world, i, j, k, k1, flag, l + 1);
}
return true;
}
}
return false;
}
public int e() {
return 0;
}
static boolean a(BlockMinecartTrack blockminecarttrack) {
return blockminecarttrack.a;
}
}
@@ -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.STONE);
}
protected TileEntity a_() {
return new TileEntityMobSpawner();
}
public int a(int i, Random random) {
return 0;
}
public int a(Random random) {
return 0;
}
public boolean a() {
return false;
}
}
@@ -0,0 +1,52 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockSpreadEvent;
import java.util.Random;
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);
this.a(true);
}
public void a(World world, int i, int j, int k, Random random) {
if (random.nextInt(100) == 0) {
int l = i + random.nextInt(3) - 1;
int i1 = j + random.nextInt(2) - random.nextInt(2);
int j1 = k + random.nextInt(3) - 1;
if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
int k1 = i + (random.nextInt(3) - 1);
k1 = k + (random.nextInt(3) - 1);
if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.BlockState blockState = bworld.getBlockAt(l, i1, j1).getState();
blockState.setTypeId(this.id);
BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
}
}
}
}
protected boolean c(int i) {
return Block.o[i];
}
public boolean f(World world, int i, int j, int k) {
return j >= 0 && j < 128 ? world.k(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)) : false;
}
}
@@ -0,0 +1,75 @@
package net.minecraft.server;
public class BlockNote extends BlockContainer {
public BlockNote(int i) {
super(i, 74, Material.WOOD);
}
public int a(int i) {
return this.textureId;
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (l > 0 && Block.byId[l].isPowerSource()) {
boolean flag = world.isBlockPowered(i, j, k);
TileEntityNote tileentitynote = (TileEntityNote) world.getTileEntity(i, j, k);
if (tileentitynote.b != flag) {
if (flag) {
tileentitynote.play(world, i, j, k);
}
tileentitynote.b = flag;
}
}
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
TileEntityNote tileentitynote = (TileEntityNote) world.getTileEntity(i, j, k);
tileentitynote.a();
tileentitynote.play(world, i, j, k);
return true;
}
}
public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
if (!world.isStatic) {
TileEntityNote tileentitynote = (TileEntityNote) world.getTileEntity(i, j, k);
tileentitynote.play(world, i, j, k);
}
}
protected TileEntity a_() {
return new TileEntityNote();
}
public void a(World world, int i, int j, int k, int l, int i1) {
float f = (float) Math.pow(2.0D, (double) (i1 - 12) / 12.0D);
String s = "harp";
if (l == 1) {
s = "bd";
}
if (l == 2) {
s = "snare";
}
if (l == 3) {
s = "hat";
}
if (l == 4) {
s = "bassattack";
}
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "note." + s, 3.0F, f);
world.a("note", (double) i + 0.5D, (double) j + 1.2D, (double) k + 0.5D, (double) i1 / 24.0D, 0.0D, 0.0D);
}
}
@@ -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.id;
}
}
@@ -0,0 +1,22 @@
package net.minecraft.server;
import java.util.Random;
public class BlockOre extends Block {
public BlockOre(int i, int j) {
super(i, j, Material.STONE);
}
public int a(int i, Random random) {
return this.id == Block.COAL_ORE.id ? Item.COAL.id : (this.id == Block.DIAMOND_ORE.id ? Item.DIAMOND.id : (this.id == Block.LAPIS_ORE.id ? Item.INK_SACK.id : this.id));
}
public int a(Random random) {
return this.id == Block.LAPIS_ORE.id ? 4 + random.nextInt(5) : 1;
}
protected int a_(int i) {
return this.id == Block.LAPIS_ORE.id ? 4 : 0;
}
}
@@ -0,0 +1,13 @@
package net.minecraft.server;
public class BlockOreBlock extends Block {
public BlockOreBlock(int i, int j) {
super(i, Material.ORE);
this.textureId = j;
}
public int a(int i) {
return this.textureId;
}
}
@@ -0,0 +1,374 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import java.util.ArrayList;
// CraftBukkit start
// CraftBukkit end
public class BlockPiston extends Block {
private boolean a;
private boolean b;
public BlockPiston(int i, int j, boolean flag) {
super(i, j, Material.PISTON);
this.a = flag;
this.a(h);
this.c(0.5F);
}
public int a(int i, int j) {
int k = c(j);
return k > 5 ? this.textureId : (i == k ? (!d(j) && this.minX <= 0.0D && this.minY <= 0.0D && this.minZ <= 0.0D && this.maxX >= 1.0D && this.maxY >= 1.0D && this.maxZ >= 1.0D ? this.textureId : 110) : (i == PistonBlockTextures.a[k] ? 109 : 108));
}
public boolean a() {
return false;
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
return false;
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = c(world, i, j, k, (EntityHuman) entityliving);
world.setData(i, j, k, l);
if (!world.isStatic) {
this.g(world, i, j, k);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic && !this.b) {
this.g(world, i, j, k);
}
}
public void c(World world, int i, int j, int k) {
if (!world.isStatic && world.getTileEntity(i, j, k) == null) {
this.g(world, i, j, k);
}
}
private void g(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
int i1 = c(l);
boolean flag = this.f(world, i, j, k, i1);
if (l != 7) {
if (flag && !d(l)) {
// CraftBukkit start
int length;
try {
length = h(world, i, j, k, i1);
} catch (RuntimeException exception) {
System.out.println("[Poseidon] A piston crash attempt occurred at " + i + " " + j + " " + k + " in " + world.getWorld().getName());
return;
}
if (length >= 0) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
BlockPistonExtendEvent event = new BlockPistonExtendEvent(block, length);
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// CraftBukkit end
world.setRawData(i, j, k, i1 | 8);
world.playNote(i, j, k, 0, i1);
}
} else if (!flag && d(l)) {
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
BlockPistonRetractEvent event = new BlockPistonRetractEvent(block);
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// CraftBukkit end
world.setRawData(i, j, k, i1);
world.playNote(i, j, k, 1, i1);
}
}
}
private boolean f(World world, int i, int j, int k, int l) {
return l != 0 && world.isBlockFaceIndirectlyPowered(i, j - 1, k, 0) ? true : (l != 1 && world.isBlockFaceIndirectlyPowered(i, j + 1, k, 1) ? true : (l != 2 && world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) ? true : (l != 3 && world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) ? true : (l != 5 && world.isBlockFaceIndirectlyPowered(i + 1, j, k, 5) ? true : (l != 4 && world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) ? true : (world.isBlockFaceIndirectlyPowered(i, j, k, 0) ? true : (world.isBlockFaceIndirectlyPowered(i, j + 2, k, 1) ? true : (world.isBlockFaceIndirectlyPowered(i, j + 1, k - 1, 2) ? true : (world.isBlockFaceIndirectlyPowered(i, j + 1, k + 1, 3) ? true : (world.isBlockFaceIndirectlyPowered(i - 1, j + 1, k, 4) ? true : world.isBlockFaceIndirectlyPowered(i + 1, j + 1, k, 5)))))))))));
}
public void a(World world, int i, int j, int k, int l, int i1) {
this.b = true;
if (l == 0) {
if (this.i(world, i, j, k, i1)) {
world.setData(i, j, k, i1 | 8);
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "tile.piston.out", 0.5F, world.random.nextFloat() * 0.25F + 0.6F);
}
} else if (l == 1) {
TileEntity tileentity = world.getTileEntity(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1]);
if (tileentity != null && tileentity instanceof TileEntityPiston) {
((TileEntityPiston) tileentity).k();
}
world.setRawTypeIdAndData(i, j, k, Block.PISTON_MOVING.id, i1);
world.setTileEntity(i, j, k, BlockPistonMoving.a(this.id, i1, i1, false, true));
if (this.a) {
int j1 = i + PistonBlockTextures.b[i1] * 2;
int k1 = j + PistonBlockTextures.c[i1] * 2;
int l1 = k + PistonBlockTextures.d[i1] * 2;
int i2 = world.getTypeId(j1, k1, l1);
int j2 = world.getData(j1, k1, l1);
boolean flag = false;
if (i2 == Block.PISTON_MOVING.id) {
TileEntity tileentity1 = world.getTileEntity(j1, k1, l1);
if (tileentity1 != null && tileentity1 instanceof TileEntityPiston) {
TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity1;
if (tileentitypiston.d() == i1 && tileentitypiston.c()) {
tileentitypiston.k();
i2 = tileentitypiston.a();
j2 = tileentitypiston.e();
flag = true;
}
}
}
if (!flag && i2 > 0 && a(i2, world, j1, k1, l1, false) && (Block.byId[i2].e() == 0 || i2 == Block.PISTON.id || i2 == Block.PISTON_STICKY.id)) {
this.b = false;
world.setTypeId(j1, k1, l1, 0);
this.b = true;
i += PistonBlockTextures.b[i1];
j += PistonBlockTextures.c[i1];
k += PistonBlockTextures.d[i1];
world.setRawTypeIdAndData(i, j, k, Block.PISTON_MOVING.id, j2);
world.setTileEntity(i, j, k, BlockPistonMoving.a(i2, j2, i1, false, false));
} else if (!flag) {
this.b = false;
world.setTypeId(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1], 0);
this.b = true;
}
} else {
this.b = false;
world.setTypeId(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1], 0);
this.b = true;
}
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "tile.piston.in", 0.5F, world.random.nextFloat() * 0.15F + 0.6F);
}
this.b = false;
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(i, j, k);
if (d(l)) {
switch (c(l)) {
case 0:
this.a(0.0F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case 1:
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
break;
case 2:
this.a(0.0F, 0.0F, 0.25F, 1.0F, 1.0F, 1.0F);
break;
case 3:
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.75F);
break;
case 4:
this.a(0.25F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case 5:
this.a(0.0F, 0.0F, 0.0F, 0.75F, 1.0F, 1.0F);
}
} else {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
}
public boolean b() {
return false;
}
public static int c(int i) {
return i & 7;
}
public static boolean d(int i) {
return (i & 8) != 0;
}
private static int c(World world, int i, int j, int k, EntityHuman entityhuman) {
if (MathHelper.abs((float) entityhuman.locX - (float) i) < 2.0F && MathHelper.abs((float) entityhuman.locZ - (float) k) < 2.0F) {
double d0 = entityhuman.locY + 1.82D - (double) entityhuman.height;
if (d0 - (double) j > 2.0D) {
return 1;
}
if ((double) j - d0 > 0.0D) {
return 0;
}
}
int l = MathHelper.floor((double) (entityhuman.yaw * 4.0F / 360.0F) + 0.5D) & 3;
return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
}
private static boolean a(int i, World world, int j, int k, int l, boolean flag) {
if (i == Block.OBSIDIAN.id) {
return false;
} else if ((i == Block.FURNACE.id || i == Block.BURNING_FURNACE.id) && PoseidonConfig.getInstance().getBoolean("world.settings.block-pistons-pushing-furnaces.enabled", true)) {
// System.out.println("Blocking a piston from being pushed.");
return false;
} else {
if (i != Block.PISTON.id && i != Block.PISTON_STICKY.id) {
if (Block.byId[i].j() == -1.0F) {
return false;
}
if (Block.byId[i].e() == 2) {
return false;
}
if (!flag && Block.byId[i].e() == 1) {
return false;
}
} else if (d(world.getData(j, k, l))) {
return false;
}
TileEntity tileentity = world.getTileEntity(j, k, l);
return tileentity == null;
}
}
// CraftBukkkit boolean -> int
private static int h(World world, int i, int j, int k, int l) {
int i1 = i + PistonBlockTextures.b[l];
int j1 = j + PistonBlockTextures.c[l];
int k1 = k + PistonBlockTextures.d[l];
int l1 = 0;
while (true) {
if (l1 < 13) {
if (j1 <= 0 || j1 >= 127) {
return -1; // CraftBukkit
}
int i2 = world.getTypeId(i1, j1, k1);
if (i2 != 0) {
if (!a(i2, world, i1, j1, k1, true)) {
return -1; // CraftBukkit
}
if (Block.byId[i2].e() != 1) {
if (l1 == 12) {
return -1; // CraftBukkit
}
i1 += PistonBlockTextures.b[l];
j1 += PistonBlockTextures.c[l];
k1 += PistonBlockTextures.d[l];
++l1;
continue;
}
}
}
return l1; // CraftBukkit
}
}
private boolean i(World world, int i, int j, int k, int l) {
int i1 = i + PistonBlockTextures.b[l];
int j1 = j + PistonBlockTextures.c[l];
int k1 = k + PistonBlockTextures.d[l];
int l1 = 0;
while (true) {
int i2;
if (l1 < 13) {
if (j1 <= 0 || j1 >= 127) {
return false;
}
i2 = world.getTypeId(i1, j1, k1);
if (i2 != 0) {
if (!a(i2, world, i1, j1, k1, true)) {
return false;
}
if (Block.byId[i2].e() != 1) {
if (l1 == 12) {
return false;
}
i1 += PistonBlockTextures.b[l];
j1 += PistonBlockTextures.c[l];
k1 += PistonBlockTextures.d[l];
++l1;
continue;
}
Block.byId[i2].g(world, i1, j1, k1, world.getData(i1, j1, k1));
if (PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.other-fixes.enabled", true)) {
world.setRawTypeId(i1, j1, k1, 0);
} else {
world.setTypeId(i1, j1, k1, 0);
}
}
}
while (i1 != i || j1 != j || k1 != k) {
l1 = i1 - PistonBlockTextures.b[l];
i2 = j1 - PistonBlockTextures.c[l];
int j2 = k1 - PistonBlockTextures.d[l];
int k2 = world.getTypeId(l1, i2, j2);
int l2 = world.getData(l1, i2, j2);
if (k2 == this.id && l1 == i && i2 == j && j2 == k) {
world.setRawTypeIdAndData(i1, j1, k1, Block.PISTON_MOVING.id, l | (this.a ? 8 : 0));
world.setTileEntity(i1, j1, k1, BlockPistonMoving.a(Block.PISTON_EXTENSION.id, l | (this.a ? 8 : 0), l, true, false));
} else {
world.setRawTypeIdAndData(i1, j1, k1, Block.PISTON_MOVING.id, l2);
world.setTileEntity(i1, j1, k1, BlockPistonMoving.a(k2, l2, l, true, false));
}
i1 = l1;
j1 = i2;
k1 = j2;
}
return true;
}
}
}
@@ -0,0 +1,155 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.Random;
public class BlockPistonExtension extends Block {
private int a = -1;
public BlockPistonExtension(int i, int j) {
super(i, j, Material.PISTON);
this.a(h);
this.c(0.5F);
}
public void remove(World world, int i, int j, int k) {
super.remove(world, i, j, k);
int l = world.getData(i, j, k);
if (l < 0 || l == 6 || l == 7 || l > 13) return; // CraftBukkit - fixed a piston AIOOBE issue.
int i1 = PistonBlockTextures.a[b(l)];
i += PistonBlockTextures.b[i1];
j += PistonBlockTextures.c[i1];
k += PistonBlockTextures.d[i1];
int j1 = world.getTypeId(i, j, k);
if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) {
l = world.getData(i, j, k);
if (BlockPiston.d(l)) {
Block.byId[j1].g(world, i, j, k, l);
world.setTypeId(i, j, k, 0);
}
}
}
public int a(int i, int j) {
int k = b(j);
return i == k ? (this.a >= 0 ? this.a : ((j & 8) != 0 ? this.textureId - 1 : this.textureId)) : (i == PistonBlockTextures.a[k] ? 107 : 108);
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return false;
}
public boolean canPlace(World world, int i, int j, int k, int l) {
return false;
}
public int a(Random random) {
return 0;
}
public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) {
int l = world.getData(i, j, k);
switch (b(l)) {
case 0:
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
this.a(0.375F, 0.25F, 0.375F, 0.625F, 1.0F, 0.625F);
super.a(world, i, j, k, axisalignedbb, arraylist);
break;
case 1:
this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
this.a(0.375F, 0.0F, 0.375F, 0.625F, 0.75F, 0.625F);
super.a(world, i, j, k, axisalignedbb, arraylist);
break;
case 2:
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F);
super.a(world, i, j, k, axisalignedbb, arraylist);
this.a(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
break;
case 3:
this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
this.a(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F);
super.a(world, i, j, k, axisalignedbb, arraylist);
break;
case 4:
this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
this.a(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
break;
case 5:
this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.a(world, i, j, k, axisalignedbb, arraylist);
this.a(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F);
super.a(world, i, j, k, axisalignedbb, arraylist);
}
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(i, j, k);
switch (b(l)) {
case 0:
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
break;
case 1:
this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case 2:
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F);
break;
case 3:
this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F);
break;
case 4:
this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F);
break;
case 5:
this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
int i1 = b(world.getData(i, j, k));
if (i1 > 5 || i1 < 0) return; // CraftBukkit - fixed a piston AIOOBE issue.
int j1 = world.getTypeId(i - PistonBlockTextures.b[i1], j - PistonBlockTextures.c[i1], k - PistonBlockTextures.d[i1]);
if (j1 != Block.PISTON.id && j1 != Block.PISTON_STICKY.id) {
world.setTypeId(i, j, k, 0);
} else {
Block.byId[j1].doPhysics(world, i - PistonBlockTextures.b[i1], j - PistonBlockTextures.c[i1], k - PistonBlockTextures.d[i1], l);
}
}
public static int b(int i) {
return i & 7;
}
}
@@ -0,0 +1,146 @@
package net.minecraft.server;
import java.util.Random;
public class BlockPistonMoving extends BlockContainer {
public BlockPistonMoving(int i) {
super(i, Material.PISTON);
this.c(-1.0F);
}
protected TileEntity a_() {
return null;
}
public void c(World world, int i, int j, int k) {}
public void remove(World world, int i, int j, int k) {
TileEntity tileentity = world.getTileEntity(i, j, k);
if (tileentity != null && tileentity instanceof TileEntityPiston) {
((TileEntityPiston) tileentity).k();
} else {
super.remove(world, i, j, k);
}
}
public boolean canPlace(World world, int i, int j, int k) {
return false;
}
public boolean canPlace(World world, int i, int j, int k, int l) {
return false;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (!world.isStatic && world.getTileEntity(i, j, k) == null) {
world.setTypeId(i, j, k, 0);
return true;
} else {
return false;
}
}
public int a(int i, Random random) {
return 0;
}
public void dropNaturally(World world, int i, int j, int k, int l, float f) {
if (!world.isStatic) {
TileEntityPiston tileentitypiston = this.b(world, i, j, k);
if (tileentitypiston != null) {
Block.byId[tileentitypiston.a()].g(world, i, j, k, tileentitypiston.e());
}
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic && world.getTileEntity(i, j, k) == null) {
;
}
}
public static TileEntity a(int i, int j, int k, boolean flag, boolean flag1) {
return new TileEntityPiston(i, j, k, flag, flag1);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
TileEntityPiston tileentitypiston = this.b(world, i, j, k);
if (tileentitypiston == null) {
return null;
} else {
float f = tileentitypiston.a(0.0F);
if (tileentitypiston.c()) {
f = 1.0F - f;
}
return this.a(world, i, j, k, tileentitypiston.a(), f, tileentitypiston.d());
}
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
TileEntityPiston tileentitypiston = this.b(iblockaccess, i, j, k);
if (tileentitypiston != null) {
Block block = Block.byId[tileentitypiston.a()];
if (block == null || block == this) {
return;
}
block.a(iblockaccess, i, j, k);
float f = tileentitypiston.a(0.0F);
if (tileentitypiston.c()) {
f = 1.0F - f;
}
int l = tileentitypiston.d();
this.minX = block.minX - (double) ((float) PistonBlockTextures.b[l] * f);
this.minY = block.minY - (double) ((float) PistonBlockTextures.c[l] * f);
this.minZ = block.minZ - (double) ((float) PistonBlockTextures.d[l] * f);
this.maxX = block.maxX - (double) ((float) PistonBlockTextures.b[l] * f);
this.maxY = block.maxY - (double) ((float) PistonBlockTextures.c[l] * f);
this.maxZ = block.maxZ - (double) ((float) PistonBlockTextures.d[l] * f);
}
}
public AxisAlignedBB a(World world, int i, int j, int k, int l, float f, int i1) {
if (l != 0 && l != this.id) {
AxisAlignedBB axisalignedbb = Block.byId[l].e(world, i, j, k);
if (axisalignedbb == null) {
return null;
} else {
axisalignedbb.a -= (double) ((float) PistonBlockTextures.b[i1] * f);
axisalignedbb.d -= (double) ((float) PistonBlockTextures.b[i1] * f);
axisalignedbb.b -= (double) ((float) PistonBlockTextures.c[i1] * f);
axisalignedbb.e -= (double) ((float) PistonBlockTextures.c[i1] * f);
axisalignedbb.c -= (double) ((float) PistonBlockTextures.d[i1] * f);
axisalignedbb.f -= (double) ((float) PistonBlockTextures.d[i1] * f);
return axisalignedbb;
}
} else {
return null;
}
}
private TileEntityPiston b(IBlockAccess iblockaccess, int i, int j, int k) {
TileEntity tileentity = iblockaccess.getTileEntity(i, j, k);
return tileentity != null && tileentity instanceof TileEntityPiston ? (TileEntityPiston) tileentity : null;
}
}
@@ -0,0 +1,173 @@
package net.minecraft.server;
import org.bukkit.event.entity.EntityPortalEnterEvent;
import org.bukkit.event.world.PortalCreateEvent;
import java.util.Random;
// CraftBukkit start
// CraftBukkit end
public class BlockPortal extends BlockBreakable {
public BlockPortal(int i, int j) {
super(i, j, Material.PORTAL, false);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
float f;
float f1;
if (iblockaccess.getTypeId(i - 1, j, k) != this.id && iblockaccess.getTypeId(i + 1, j, k) != this.id) {
f = 0.125F;
f1 = 0.5F;
this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1);
} else {
f = 0.5F;
f1 = 0.125F;
this.a(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1);
}
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean a_(World world, int i, int j, int k) {
byte b0 = 0;
byte b1 = 0;
if (world.getTypeId(i - 1, j, k) == Block.OBSIDIAN.id || world.getTypeId(i + 1, j, k) == Block.OBSIDIAN.id) {
b0 = 1;
}
if (world.getTypeId(i, j, k - 1) == Block.OBSIDIAN.id || world.getTypeId(i, j, k + 1) == Block.OBSIDIAN.id) {
b1 = 1;
}
if (b0 == b1) {
return false;
} else {
// CraftBukkit start
java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>();
org.bukkit.World bworld = world.getWorld();
// CraftBukkit end
if (world.getTypeId(i - b0, j, k - b1) == 0) {
i -= b0;
k -= b1;
}
int l;
int i1;
for (l = -1; l <= 2; ++l) {
for (i1 = -1; i1 <= 3; ++i1) {
boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3;
if (l != -1 && l != 2 || i1 != -1 && i1 != 3) {
int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l);
if (flag) {
if (j1 != Block.OBSIDIAN.id) {
return false;
} else {
blocks.add(bworld.getBlockAt(i + b0 * l, j + i1, k + b1 * l)); // CraftBukkit
}
} else if (j1 != 0 && j1 != Block.FIRE.id) {
return false;
}
}
}
}
// CraftBukkit start
for (l = 0; l < 2; ++l) {
for (i1 = 0; i1 < 3; ++i1) {
blocks.add(bworld.getBlockAt(i + b0 * l, j + i1, k + b1 * l));
}
}
PortalCreateEvent event = new PortalCreateEvent(blocks, bworld);
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
world.suppressPhysics = true;
for (l = 0; l < 2; ++l) {
for (i1 = 0; i1 < 3; ++i1) {
world.setTypeId(i + b0 * l, j + i1, k + b1 * l, Block.PORTAL.id);
}
}
world.suppressPhysics = false;
return true;
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
byte b0 = 0;
byte b1 = 1;
if (world.getTypeId(i - 1, j, k) == this.id || world.getTypeId(i + 1, j, k) == this.id) {
b0 = 1;
b1 = 0;
}
int i1;
for (i1 = j; world.getTypeId(i, i1 - 1, k) == this.id; --i1) {
;
}
if (world.getTypeId(i, i1 - 1, k) != Block.OBSIDIAN.id) {
world.setTypeId(i, j, k, 0);
} else {
int j1;
for (j1 = 1; j1 < 4 && world.getTypeId(i, i1 + j1, k) == this.id; ++j1) {
;
}
if (j1 == 3 && world.getTypeId(i, i1 + j1, k) == Block.OBSIDIAN.id) {
boolean flag = world.getTypeId(i - 1, j, k) == this.id || world.getTypeId(i + 1, j, k) == this.id;
boolean flag1 = world.getTypeId(i, j, k - 1) == this.id || world.getTypeId(i, j, k + 1) == this.id;
if (flag && flag1) {
world.setTypeId(i, j, k, 0);
} else if ((world.getTypeId(i + b0, j, k + b1) != Block.OBSIDIAN.id || world.getTypeId(i - b0, j, k - b1) != this.id) && (world.getTypeId(i - b0, j, k - b1) != Block.OBSIDIAN.id || world.getTypeId(i + b0, j, k + b1) != this.id)) {
world.setTypeId(i, j, k, 0);
}
} else {
world.setTypeId(i, j, k, 0);
}
}
}
public int a(Random random) {
return 0;
}
public void a(World world, int i, int j, int k, Entity entity) {
if (entity.vehicle == null && entity.passenger == null) {
// CraftBukkit start - Entity in portal
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), i, j, k));
world.getServer().getPluginManager().callEvent(event);
// CraftBukkit end
entity.P();
}
}
}
@@ -0,0 +1,189 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import java.util.List;
import java.util.Random;
// CraftBukkit start
// CraftBukkit end
public class BlockPressurePlate extends Block {
private EnumMobType a;
protected BlockPressurePlate(int i, int j, EnumMobType enummobtype, Material material) {
super(i, j, material);
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 e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i, j - 1, k);
}
public void c(World world, int i, int j, int k) {}
public void doPhysics(World world, int i, int j, int k, int l) {
boolean flag = false;
if (!world.e(i, j - 1, k)) {
flag = true;
}
if (flag) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
if (world.getData(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.isStatic) {
if (world.getData(i, j, k) != 1) {
this.g(world, i, j, k);
}
}
}
private void g(World world, int i, int j, int k) {
boolean flag = world.getData(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;
}
// CraftBukkit start - Interact Pressure Plate
org.bukkit.World bworld = world.getWorld();
org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
if (flag != flag1) {
if (flag1) {
for (Object object: list) {
if (object != null) {
org.bukkit.event.Cancellable cancellable;
if (object instanceof EntityHuman) {
cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
} else if (object instanceof Entity) {
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
manager.callEvent((EntityInteractEvent) cancellable);
} else {
continue;
}
if (cancellable.isCancelled()) {
return;
}
}
}
}
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
manager.callEvent(eventRedstone);
flag1 = eventRedstone.getNewCurrent() > 0;
}
// CraftBukkit end
if (flag1 && !flag) {
world.setData(i, j, k, 1);
world.applyPhysics(i, j, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k);
world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
}
if (!flag1 && flag) {
world.setData(i, j, k, 0);
world.applyPhysics(i, j, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k);
world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
}
if (flag1) {
world.c(i, j, k, this.id, this.c());
}
}
public void remove(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
if (l > 0) {
world.applyPhysics(i, j, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
}
super.remove(world, i, j, k);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
boolean flag = iblockaccess.getData(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 a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return iblockaccess.getData(i, j, k) > 0;
}
public boolean d(World world, int i, int j, int k, int l) {
return world.getData(i, j, k) == 0 ? false : l == 1;
}
public boolean isPowerSource() {
return true;
}
public int e() {
return 1;
}
}
@@ -0,0 +1,63 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockPumpkin extends Block {
private boolean a;
protected BlockPumpkin(int i, int j, boolean flag) {
super(i, Material.PUMPKIN);
this.textureId = j;
this.a(true);
this.a = flag;
}
public int a(int i, int j) {
if (i == 1) {
return this.textureId;
} else if (i == 0) {
return this.textureId;
} else {
int k = this.textureId + 1 + 16;
if (this.a) {
++k;
}
return j == 2 && i == 2 ? k : (j == 3 && i == 5 ? k : (j == 0 && i == 3 ? k : (j == 1 && i == 4 ? k : this.textureId + 16)));
}
}
public int a(int i) {
return i == 1 ? this.textureId : (i == 0 ? this.textureId : (i == 3 ? this.textureId + 1 + 16 : this.textureId + 16));
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
}
public boolean canPlace(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k);
return (l == 0 || Block.byId[l].material.isReplacable()) && world.e(i, j - 1, k);
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 2.5D) & 3;
world.setData(i, j, k, l);
}
// CraftBukkit start
public void doPhysics(World world, int i, int j, int k, int l) {
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
int power = block.getBlockPower();
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
world.getServer().getPluginManager().callEvent(eventRedstone);
}
}
// CraftBukkit end
}
@@ -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.STONE);
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 interact(World world, int i, int j, int k, EntityHuman entityhuman) {
this.g(world, i, j, k);
return super.interact(world, i, j, k, entityhuman);
}
private void g(World world, int i, int j, int k) {
this.h(world, i, j, k);
if (this.id == Block.REDSTONE_ORE.id) {
world.setTypeId(i, j, k, Block.GLOWING_REDSTONE_ORE.id);
}
}
public void a(World world, int i, int j, int k, Random random) {
if (this.id == Block.GLOWING_REDSTONE_ORE.id) {
world.setTypeId(i, j, k, Block.REDSTONE_ORE.id);
}
}
public int a(int i, Random random) {
return Item.REDSTONE.id;
}
public int a(Random random) {
return 4 + random.nextInt(2);
}
private void h(World world, int i, int j, int k) {
Random random = world.random;
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.p(i, j + 1, k)) {
d2 = (double) (j + 1) + d0;
}
if (l == 1 && !world.p(i, j - 1, k)) {
d2 = (double) (j + 0) - d0;
}
if (l == 2 && !world.p(i, j, k + 1)) {
d3 = (double) (k + 1) + d0;
}
if (l == 3 && !world.p(i, j, k - 1)) {
d3 = (double) (k + 0) - d0;
}
if (l == 4 && !world.p(i + 1, j, k)) {
d1 = (double) (i + 1) + d0;
}
if (l == 5 && !world.p(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);
}
}
}
}
@@ -0,0 +1,162 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BlockRedstoneTorch extends BlockTorch {
private boolean isOn = false;
private static List b = new ArrayList();
public int a(int i, int j) {
return i == 1 ? Block.REDSTONE_WIRE.a(i, j) : super.a(i, j);
}
private boolean a(World world, int i, int j, int k, boolean flag) {
if (flag) {
b.add(new RedstoneUpdateInfo(i, j, k, world.getTime()));
}
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.isOn = flag;
this.a(true);
}
public int c() {
return 2;
}
public void c(World world, int i, int j, int k) {
if (world.getData(i, j, k) == 0) {
super.c(world, i, j, k);
}
if (this.isOn) {
world.applyPhysics(i, j - 1, k, this.id);
world.applyPhysics(i, j + 1, k, this.id);
world.applyPhysics(i - 1, j, k, this.id);
world.applyPhysics(i + 1, j, k, this.id);
world.applyPhysics(i, j, k - 1, this.id);
world.applyPhysics(i, j, k + 1, this.id);
}
}
public void remove(World world, int i, int j, int k) {
if (this.isOn) {
world.applyPhysics(i, j - 1, k, this.id);
world.applyPhysics(i, j + 1, k, this.id);
world.applyPhysics(i - 1, j, k, this.id);
world.applyPhysics(i + 1, j, k, this.id);
world.applyPhysics(i, j, k - 1, this.id);
world.applyPhysics(i, j, k + 1, this.id);
}
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
if (!this.isOn) {
return false;
} else {
int i1 = iblockaccess.getData(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.getData(i, j, k);
return l == 5 && world.isBlockFaceIndirectlyPowered(i, j - 1, k, 0) ? true : (l == 3 && world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) ? true : (l == 4 && world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) ? true : (l == 1 && world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) ? true : l == 2 && world.isBlockFaceIndirectlyPowered(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.getTime() - ((RedstoneUpdateInfo) b.get(0)).d > 100L) {
b.remove(0);
}
// CraftBukkit start
org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
int oldCurrent = this.isOn ? 15 : 0;
BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
// CraftBukkit end
if (this.isOn) {
if (flag) {
// CraftBukkit start
if (oldCurrent != 0) {
event.setNewCurrent(0);
manager.callEvent(event);
if (event.getNewCurrent() != 0) {
return;
}
}
// CraftBukkit end
world.setTypeIdAndData(i, j, k, Block.REDSTONE_TORCH_OFF.id, world.getData(i, j, k));
if (this.a(world, i, j, k, true)) {
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.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)) {
// CraftBukkit start
if (oldCurrent != 15) {
event.setNewCurrent(15);
manager.callEvent(event);
if (event.getNewCurrent() != 15) {
return;
}
}
// CraftBukkit end
world.setTypeIdAndData(i, j, k, Block.REDSTONE_TORCH_ON.id, world.getData(i, j, k));
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
super.doPhysics(world, i, j, k, l);
world.c(i, j, k, this.id, this.c());
}
public boolean d(World world, int i, int j, int k, int l) {
return l == 0 ? this.a(world, i, j, k, l) : false;
}
public int a(int i, Random random) {
return Block.REDSTONE_TORCH_ON.id;
}
public boolean isPowerSource() {
return true;
}
}
@@ -0,0 +1,357 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class BlockRedstoneWire extends Block {
private boolean a = true;
private Set b = new HashSet();
public BlockRedstoneWire(int i, int j) {
super(i, j, Material.ORIENTABLE);
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
}
public int a(int i, int j) {
return this.textureId;
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i, j - 1, k);
}
private void g(World world, int i, int j, int k) {
this.a(world, i, j, k, i, j, k);
ArrayList arraylist = new ArrayList(this.b);
this.b.clear();
for (int l = 0; l < arraylist.size(); ++l) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l);
world.applyPhysics(chunkposition.x, chunkposition.y, chunkposition.z, this.id);
}
}
private void a(World world, int i, int j, int k, int l, int i1, int j1) {
int k1 = world.getData(i, j, k);
int l1 = 0;
this.a = false;
boolean flag = world.isBlockIndirectlyPowered(i, j, k);
this.a = true;
int i2;
int j2;
int k2;
if (flag) {
l1 = 15;
} else {
for (i2 = 0; i2 < 4; ++i2) {
j2 = i;
k2 = k;
if (i2 == 0) {
j2 = i - 1;
}
if (i2 == 1) {
++j2;
}
if (i2 == 2) {
k2 = k - 1;
}
if (i2 == 3) {
++k2;
}
if (j2 != l || j != i1 || k2 != j1) {
l1 = this.getPower(world, j2, j, k2, l1);
}
if (world.e(j2, j, k2) && !world.e(i, j + 1, k)) {
if (j2 != l || j + 1 != i1 || k2 != j1) {
l1 = this.getPower(world, j2, j + 1, k2, l1);
}
} else if (!world.e(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) {
l1 = this.getPower(world, j2, j - 1, k2, l1);
}
}
if (l1 > 0) {
--l1;
} else {
l1 = 0;
}
}
// CraftBukkit start
if (k1 != l1) {
BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(i, j, k), k1, l1);
world.getServer().getPluginManager().callEvent(event);
l1 = event.getNewCurrent();
}
// CraftBukkit end
if (k1 != l1) {
world.suppressPhysics = true;
world.setData(i, j, k, l1);
world.b(i, j, k, i, j, k);
world.suppressPhysics = false;
for (i2 = 0; i2 < 4; ++i2) {
j2 = i;
k2 = k;
int l2 = j - 1;
if (i2 == 0) {
j2 = i - 1;
}
if (i2 == 1) {
++j2;
}
if (i2 == 2) {
k2 = k - 1;
}
if (i2 == 3) {
++k2;
}
if (world.e(j2, j, k2)) {
l2 += 2;
}
boolean flag1 = false;
int i3 = this.getPower(world, j2, j, k2, -1);
l1 = world.getData(i, j, k);
if (l1 > 0) {
--l1;
}
if (i3 >= 0 && i3 != l1) {
this.a(world, j2, j, k2, i, j, k);
}
i3 = this.getPower(world, j2, l2, k2, -1);
l1 = world.getData(i, j, k);
if (l1 > 0) {
--l1;
}
if (i3 >= 0 && i3 != l1) {
this.a(world, j2, l2, k2, i, j, k);
}
}
if (k1 == 0 || l1 == 0) {
this.b.add(new ChunkPosition(i, j, k));
this.b.add(new ChunkPosition(i - 1, j, k));
this.b.add(new ChunkPosition(i + 1, j, k));
this.b.add(new ChunkPosition(i, j - 1, k));
this.b.add(new ChunkPosition(i, j + 1, k));
this.b.add(new ChunkPosition(i, j, k - 1));
this.b.add(new ChunkPosition(i, j, k + 1));
}
}
}
private void h(World world, int i, int j, int k) {
if (world.getTypeId(i, j, k) == this.id) {
world.applyPhysics(i, j, k, this.id);
world.applyPhysics(i - 1, j, k, this.id);
world.applyPhysics(i + 1, j, k, this.id);
world.applyPhysics(i, j, k - 1, this.id);
world.applyPhysics(i, j, k + 1, this.id);
world.applyPhysics(i, j - 1, k, this.id);
world.applyPhysics(i, j + 1, k, this.id);
}
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
if (!world.isStatic) {
this.g(world, i, j, k);
world.applyPhysics(i, j + 1, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
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.e(i - 1, j, k)) {
this.h(world, i - 1, j + 1, k);
} else {
this.h(world, i - 1, j - 1, k);
}
if (world.e(i + 1, j, k)) {
this.h(world, i + 1, j + 1, k);
} else {
this.h(world, i + 1, j - 1, k);
}
if (world.e(i, j, k - 1)) {
this.h(world, i, j + 1, k - 1);
} else {
this.h(world, i, j - 1, k - 1);
}
if (world.e(i, j, k + 1)) {
this.h(world, i, j + 1, k + 1);
} else {
this.h(world, i, j - 1, k + 1);
}
}
}
public void remove(World world, int i, int j, int k) {
super.remove(world, i, j, k);
if (!world.isStatic) {
world.applyPhysics(i, j + 1, k, this.id);
world.applyPhysics(i, j - 1, k, this.id);
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.e(i - 1, j, k)) {
this.h(world, i - 1, j + 1, k);
} else {
this.h(world, i - 1, j - 1, k);
}
if (world.e(i + 1, j, k)) {
this.h(world, i + 1, j + 1, k);
} else {
this.h(world, i + 1, j - 1, k);
}
if (world.e(i, j, k - 1)) {
this.h(world, i, j + 1, k - 1);
} else {
this.h(world, i, j - 1, k - 1);
}
if (world.e(i, j, k + 1)) {
this.h(world, i, j + 1, k + 1);
} else {
this.h(world, i, j - 1, k + 1);
}
}
}
// CraftBukkit - private -> public
public int getPower(World world, int i, int j, int k, int l) {
if (world.getTypeId(i, j, k) != this.id) {
return l;
} else {
int i1 = world.getData(i, j, k);
return i1 > l ? i1 : l;
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
int i1 = world.getData(i, j, k);
boolean flag = this.canPlace(world, i, j, k);
if (!flag) {
this.g(world, i, j, k, i1);
world.setTypeId(i, j, k, 0);
} else {
this.g(world, i, j, k);
}
super.doPhysics(world, i, j, k, l);
}
}
public int a(int i, Random random) {
return Item.REDSTONE.id;
}
public boolean d(World world, int i, int j, int k, int l) {
return !this.a ? false : this.a(world, i, j, k, l);
}
public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
if (!this.a) {
return false;
} else if (iblockaccess.getData(i, j, k) == 0) {
return false;
} else if (l == 1) {
return true;
} else {
boolean flag = c(iblockaccess, i - 1, j, k, 1) || !iblockaccess.e(i - 1, j, k) && c(iblockaccess, i - 1, j - 1, k, -1);
boolean flag1 = c(iblockaccess, i + 1, j, k, 3) || !iblockaccess.e(i + 1, j, k) && c(iblockaccess, i + 1, j - 1, k, -1);
boolean flag2 = c(iblockaccess, i, j, k - 1, 2) || !iblockaccess.e(i, j, k - 1) && c(iblockaccess, i, j - 1, k - 1, -1);
boolean flag3 = c(iblockaccess, i, j, k + 1, 0) || !iblockaccess.e(i, j, k + 1) && c(iblockaccess, i, j - 1, k + 1, -1);
if (!iblockaccess.e(i, j + 1, k)) {
if (iblockaccess.e(i - 1, j, k) && c(iblockaccess, i - 1, j + 1, k, -1)) {
flag = true;
}
if (iblockaccess.e(i + 1, j, k) && c(iblockaccess, i + 1, j + 1, k, -1)) {
flag1 = true;
}
if (iblockaccess.e(i, j, k - 1) && c(iblockaccess, i, j + 1, k - 1, -1)) {
flag2 = true;
}
if (iblockaccess.e(i, j, k + 1) && c(iblockaccess, i, j + 1, k + 1, -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 isPowerSource() {
return this.a;
}
public static boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) {
int i1 = iblockaccess.getTypeId(i, j, k);
if (i1 == Block.REDSTONE_WIRE.id) {
return true;
} else if (i1 == 0) {
return false;
} else if (Block.byId[i1].isPowerSource()) {
return true;
} else if (i1 != Block.DIODE_OFF.id && i1 != Block.DIODE_ON.id) {
return false;
} else {
int j1 = iblockaccess.getData(i, j, k);
return l == BedBlockTextures.b[j1 & 3];
}
}
}
@@ -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.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 ? 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.g(world, i, j, k, world.getData(i, j, k));
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 a(int i, Random random) {
return Item.SUGAR_CANE.id;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
}
@@ -0,0 +1,30 @@
package net.minecraft.server;
public class BlockRegister {
private static byte[] a = new byte[256];
public BlockRegister() {}
public static void a(byte[] abyte) {
for (int i = 0; i < abyte.length; ++i) {
abyte[i] = a[abyte[i] & 255];
}
}
static {
try {
for (int i = 0; i < 256; ++i) {
byte b0 = (byte) i;
if (b0 != 0 && Block.byId[b0 & 255] == null) {
b0 = 0;
}
a[i] = b0;
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
@@ -0,0 +1,69 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
import java.util.Random;
public class BlockSand extends Block {
public static boolean instaFall = false;
public BlockSand(int i, int j) {
super(i, j, Material.SAND);
}
public void c(World world, int i, int j, int k) {
world.c(i, j, k, this.id, this.c());
}
public void doPhysics(World world, int i, int j, int k, int l) {
world.c(i, j, k, this.id, this.c());
}
public void a(World world, int i, int j, int k, Random random) {
this.g(world, i, j, k);
}
private void g(World world, int i, int j, int k) {
if (c_(world, i, j - 1, k) && j >= 0) {
byte b0 = 32;
if (!instaFall && world.a(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
if (PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.sand-gravel-duping-fix.enabled", true)) {
world.setTypeId(i, j, k, 0);
}
EntityFallingSand entityfallingsand = new EntityFallingSand(world, i + 0.5D, j + 0.5D, k + 0.5D, this.id);
world.addEntity(entityfallingsand);
} else {
world.setTypeId(i, j, k, 0);
while (c_(world, i, j - 1, k) && j > 0) {
--j;
}
if (j > 0) {
world.setTypeId(i, j, k, this.id);
}
}
}
}
public int c() {
return 3;
}
public static boolean c_(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k);
if (l == 0) {
return true;
} else if (l == Block.FIRE.id) {
return true;
} else {
Material material = Block.byId[l].material;
return material == Material.WATER ? true : material == Material.LAVA;
}
}
}
@@ -0,0 +1,12 @@
package net.minecraft.server;
public class BlockSandStone extends Block {
public BlockSandStone(int i) {
super(i, 192, Material.STONE);
}
public int a(int i) {
return i == 1 ? this.textureId - 16 : (i == 0 ? this.textureId + 16 : this.textureId);
}
}
@@ -0,0 +1,86 @@
package net.minecraft.server;
import org.bukkit.BlockChangeDelegate;
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) {
if (!world.isStatic) {
super.a(world, i, j, k, random);
if (world.getLightLevel(i, j + 1, k) >= 9 && random.nextInt(30) == 0) {
int l = world.getData(i, j, k);
if ((l & 8) == 0) {
world.setData(i, j, k, l | 8);
} else {
this.b(world, i, j, k, random);
}
}
}
}
public int a(int i, int j) {
j &= 3;
return j == 1 ? 63 : (j == 2 ? 79 : super.a(i, j));
}
public void b(World world, int i, int j, int k, Random random) {
int l = world.getData(i, j, k) & 3;
world.setRawTypeId(i, j, k, 0);
// CraftBukkit start - fixes client updates on recently grown trees
boolean grownTree;
BlockChangeWithNotify delegate = new BlockChangeWithNotify(world);
if (l == 1) {
grownTree = new WorldGenTaiga2().generate(delegate, random, i, j, k);
} else if (l == 2) {
grownTree = new WorldGenForest().generate(delegate, random, i, j, k);
} else {
if (random.nextInt(10) == 0) {
grownTree = new WorldGenBigTree().generate(delegate, random, i, j, k);
} else {
grownTree = new WorldGenTrees().generate(delegate, random, i, j, k);
}
}
if (!grownTree) {
world.setRawTypeIdAndData(i, j, k, this.id, l);
}
// CraftBukkit end
}
protected int a_(int i) {
return i & 3;
}
// CraftBukkit start
private class BlockChangeWithNotify implements BlockChangeDelegate {
World world;
BlockChangeWithNotify(World world) { this.world = world; }
public boolean setRawTypeId(int x, int y, int z, int type) {
return this.world.setTypeId(x, y, z, type);
}
public boolean setRawTypeIdAndData(int x, int y, int z, int type, int data) {
return this.world.setTypeIdAndData(x, y, z, type, data);
}
public int getTypeId(int x, int y, int z) {
return this.world.getTypeId(x, y, z);
}
}
// CraftBukkit end
}
@@ -0,0 +1,120 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
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.WOOD);
this.b = flag;
this.textureId = 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 e(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.getData(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 boolean b() {
return false;
}
public boolean a() {
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.id;
}
public void doPhysics(World world, int i, int j, int k, int l) {
boolean flag = false;
if (this.b) {
if (!world.getMaterial(i, j - 1, k).isBuildable()) {
flag = true;
}
} else {
int i1 = world.getData(i, j, k);
flag = true;
if (i1 == 2 && world.getMaterial(i, j, k + 1).isBuildable()) {
flag = false;
}
if (i1 == 3 && world.getMaterial(i, j, k - 1).isBuildable()) {
flag = false;
}
if (i1 == 4 && world.getMaterial(i + 1, j, k).isBuildable()) {
flag = false;
}
if (i1 == 5 && world.getMaterial(i - 1, j, k).isBuildable()) {
flag = false;
}
}
if (flag) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
super.doPhysics(world, i, j, k, l);
// CraftBukkit start
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
int power = block.getBlockPower();
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
world.getServer().getPluginManager().callEvent(eventRedstone);
}
// CraftBukkit end
}
}
@@ -0,0 +1,19 @@
package net.minecraft.server;
public class BlockSlowSand extends Block {
public BlockSlowSand(int i, int j) {
super(i, j, Material.SAND);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
float f = 0.125F;
return AxisAlignedBB.b((double) i, (double) j, (double) k, (double) (i + 1), (double) ((float) (j + 1) - f), (double) (k + 1));
}
public void a(World world, int i, int j, int k, Entity entity) {
entity.motX *= 0.4D;
entity.motZ *= 0.4D;
}
}
@@ -0,0 +1,90 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import java.util.Random;
public class BlockSnow extends Block {
protected BlockSnow(int i, int j) {
super(i, j, Material.SNOW_LAYER);
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
this.a(true);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
int l = world.getData(i, j, k) & 7;
return l >= 3 ? AxisAlignedBB.b((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + 0.5F), (double) k + this.maxZ) : null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.getData(i, j, k) & 7;
float f = (float) (2 * (1 + l)) / 16.0F;
this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
}
public boolean canPlace(World world, int i, int j, int k) {
int l = world.getTypeId(i, j - 1, k);
return l != 0 && Block.byId[l].a() ? world.getMaterial(i, j - 1, k).isSolid() : false;
}
public void doPhysics(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.canPlace(world, i, j, k)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
return false;
} else {
return true;
}
}
public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
int i1 = Item.SNOW_BALL.id;
float f = 0.7F;
double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d2 = (double) (world.random.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, 1, 0));
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
world.setTypeId(i, j, k, 0);
entityhuman.a(StatisticList.C[this.id], 1);
}
public int a(int i, Random random) {
return Item.SNOW_BALL.id;
}
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) {
// CraftBukkit start
if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), 0).isCancelled()) {
return;
}
// CraftBukkit end
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
}
@@ -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.SNOW_BLOCK);
this.a(true);
}
public int a(int i, Random random) {
return Item.SNOW_BALL.id;
}
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.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
}
@@ -0,0 +1,113 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.entity.EntityInteractEvent;
import java.util.Random;
// CraftBukkit start
// CraftBukkit end
public class BlockSoil extends Block {
protected BlockSoil(int i) {
super(i, Material.EARTH);
this.textureId = 87;
this.a(true);
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
this.f(255);
}
public AxisAlignedBB e(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 a() {
return false;
}
public boolean b() {
return false;
}
public int a(int i, int j) {
return i == 1 && j > 0 ? this.textureId - 1 : (i == 1 ? this.textureId : 2);
}
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.s(i, j + 1, k)) {
int l = world.getData(i, j, k);
if (l > 0) {
world.setData(i, j, k, l - 1);
} else if (!this.g(world, i, j, k)) {
world.setTypeId(i, j, k, Block.DIRT.id);
}
} else {
world.setData(i, j, k, 7);
}
}
}
public void b(World world, int i, int j, int k, Entity entity) {
if (world.random.nextInt(4) == 0) {
// CraftBukkit start - Interact Soil
org.bukkit.event.Cancellable cancellable;
if (entity instanceof EntityHuman) {
cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
} else {
cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k));
world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
}
if (cancellable.isCancelled()) {
return;
}
// CraftBukkit end
world.setTypeId(i, j, k, Block.DIRT.id);
}
}
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.getTypeId(l, j + 1, i1) == Block.CROPS.id) {
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.getMaterial(l, i1, j1) == Material.WATER) {
return true;
}
}
}
}
return false;
}
public void doPhysics(World world, int i, int j, int k, int l) {
super.doPhysics(world, i, j, k, l);
Material material = world.getMaterial(i, j + 1, k);
if (material.isBuildable()) {
world.setTypeId(i, j, k, Block.DIRT.id);
}
}
public int a(int i, Random random) {
return Block.DIRT.a(0, random);
}
}
@@ -0,0 +1,42 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
public class BlockSponge extends Block {
protected BlockSponge(int i) {
super(i, Material.SPONGE);
this.textureId = 48;
}
public void remove(World world, int i, int j, int k) {
byte radius = 2;
if (PoseidonConfig.getInstance().getConfigBoolean("fix.optimize-sponges.enabled", true)) {
this.optimizedRemove(world, i, j, k, radius);
return;
}
for (int x = i - radius; x <= i + radius; ++x) {
for (int y = j - radius; y <= j + radius; ++y) {
for (int z = k - radius; z <= k + radius; ++z) {
world.applyPhysics(x, y, z, world.getTypeId(x, y, z));
}
}
}
}
private void optimizedRemove(World world, int i, int j, int k, byte radius) {
for (int x = i - radius; x <= i + radius; ++x) {
for (int y = j - radius; y <= j + radius; ++y) {
if (y > 127 || y < 0) continue;
for (int z = k - radius; z <= k + radius; ++z) {
int type = world.getTypeId(x, y, z);
if ((type != Block.WATER.id && type != Block.STATIONARY_WATER.id)) continue;
world.applyPhysics(x, y, z, type);
}
}
}
}
}
@@ -0,0 +1,159 @@
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.textureId, block.material);
this.a = block;
this.c(block.strength);
this.b(block.durability / 3.0F);
this.a(block.stepSound);
this.f(255);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return super.e(world, i, j, k);
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) {
int l = world.getData(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, EntityHuman entityhuman) {
this.a.b(world, i, j, k, entityhuman);
}
public void postBreak(World world, int i, int j, int k, int l) {
this.a.postBreak(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, int j) {
return this.a.a(i, j);
}
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 k_() {
return this.a.k_();
}
public boolean a(int i, boolean flag) {
return this.a.a(i, flag);
}
public boolean canPlace(World world, int i, int j, int k) {
return this.a.canPlace(world, i, j, k);
}
public void c(World world, int i, int j, int k) {
this.doPhysics(world, i, j, k, 0);
this.a.c(world, i, j, k);
}
public void remove(World world, int i, int j, int k) {
this.a.remove(world, i, j, k);
}
public void dropNaturally(World world, int i, int j, int k, int l, float f) {
this.a.dropNaturally(world, i, j, k, l, f);
}
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 interact(World world, int i, int j, int k, EntityHuman entityhuman) {
return this.a.interact(world, i, j, k, entityhuman);
}
public void d(World world, int i, int j, int k) {
this.a.d(world, i, j, k);
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) {
world.setData(i, j, k, 2);
}
if (l == 1) {
world.setData(i, j, k, 1);
}
if (l == 2) {
world.setData(i, j, k, 3);
}
if (l == 3) {
world.setData(i, j, k, 0);
}
}
}
@@ -0,0 +1,77 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockIgniteEvent;
import java.util.Random;
public class BlockStationary extends BlockFluids {
protected BlockStationary(int i, Material material) {
super(i, material);
this.a(false);
if (material == Material.LAVA) {
this.a(true);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
super.doPhysics(world, i, j, k, l);
if (world.getTypeId(i, j, k) == this.id) {
this.i(world, i, j, k);
}
}
private void i(World world, int i, int j, int k) {
int l = world.getData(i, j, k);
world.suppressPhysics = true;
world.setRawTypeIdAndData(i, j, k, this.id - 1, l);
world.b(i, j, k, i, j, k);
world.c(i, j, k, this.id - 1, this.c());
world.suppressPhysics = false;
}
public void a(World world, int i, int j, int k, Random random) {
if (this.material == Material.LAVA) {
int l = random.nextInt(3);
// CraftBukkit start - prevent lava putting something on fire.
org.bukkit.World bworld = world.getWorld();
BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
// CraftBukkit end
for (int i1 = 0; i1 < l; ++i1) {
i += random.nextInt(3) - 1;
++j;
k += random.nextInt(3) - 1;
int j1 = world.getTypeId(i, j, k);
if (j1 == 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)) {
// CraftBukkit start - prevent lava putting something on fire.
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
if (block.getTypeId() != Block.FIRE.id) {
BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null);
world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
}
// CraftBukkit end
world.setTypeId(i, j, k, Block.FIRE.id);
return;
}
} else if (Block.byId[j1].material.isSolid()) {
return;
}
}
}
}
private boolean j(World world, int i, int j, int k) {
return world.getMaterial(i, j, k).isBurnable();
}
}
@@ -0,0 +1,64 @@
package net.minecraft.server;
import java.util.Random;
public class BlockStep extends Block {
public static final String[] a = new String[] { "stone", "sand", "wood", "cobble"};
private boolean b;
public BlockStep(int i, boolean flag) {
super(i, 6, Material.STONE);
this.b = flag;
if (!flag) {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
this.f(255);
}
public int a(int i, int j) {
return j == 0 ? (i <= 1 ? 6 : 5) : (j == 1 ? (i == 0 ? 208 : (i == 1 ? 176 : 192)) : (j == 2 ? 4 : (j == 3 ? 16 : 6)));
}
public int a(int i) {
return this.a(i, 0);
}
public boolean a() {
return this.b;
}
public void c(World world, int i, int j, int k) {
if (this != Block.STEP) {
super.c(world, i, j, k);
}
int l = world.getTypeId(i, j - 1, k);
int i1 = world.getData(i, j, k);
int j1 = world.getData(i, j - 1, k);
if (i1 == j1) {
if (l == STEP.id) {
world.setTypeId(i, j, k, 0);
world.setTypeIdAndData(i, j - 1, k, Block.DOUBLE_STEP.id, i1);
}
}
}
public int a(int i, Random random) {
return Block.STEP.id;
}
public int a(Random random) {
return this.b ? 2 : 1;
}
protected int a_(int i) {
return i;
}
public boolean b() {
return this.b;
}
}
@@ -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.STONE);
}
public int a(int i, Random random) {
return Block.COBBLESTONE.id;
}
}
@@ -0,0 +1,65 @@
package net.minecraft.server;
import java.util.Random;
public class BlockTNT extends Block {
public BlockTNT(int i, int j) {
super(i, j, Material.TNT);
}
public int a(int i) {
return i == 0 ? this.textureId + 2 : (i == 1 ? this.textureId + 1 : this.textureId);
}
public void c(World world, int i, int j, int k) {
super.c(world, i, j, k);
if (world.isBlockIndirectlyPowered(i, j, k)) {
this.postBreak(world, i, j, k, 1);
world.setTypeId(i, j, k, 0);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (l > 0 && Block.byId[l].isPowerSource() && world.isBlockIndirectlyPowered(i, j, k)) {
this.postBreak(world, i, j, k, 1);
world.setTypeId(i, j, k, 0);
}
}
public int a(Random random) {
return 0;
}
public void d(World world, int i, int j, int k) {
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
entitytntprimed.fuseTicks = world.random.nextInt(entitytntprimed.fuseTicks / 4) + entitytntprimed.fuseTicks / 8;
world.addEntity(entitytntprimed);
}
public void postBreak(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
if ((l & 1) == 0) {
this.a(world, i, j, k, new ItemStack(Block.TNT.id, 1, 0));
} else {
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
world.addEntity(entitytntprimed);
world.makeSound(entitytntprimed, "random.fuse", 1.0F, 1.0F);
}
}
}
public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
if (entityhuman.G() != null && entityhuman.G().id == Item.FLINT_AND_STEEL.id) {
world.setRawData(i, j, k, 1);
}
super.b(world, i, j, k, entityhuman);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
return super.interact(world, i, j, k, entityhuman);
}
}
@@ -0,0 +1,145 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
import java.util.Random;
public class BlockTorch extends Block {
protected BlockTorch(int i, int j) {
super(i, j, Material.ORIENTABLE);
this.a(true);
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean a() {
return false;
}
public boolean b() {
return false;
}
private boolean g(World world, int i, int j, int k) {
return world.e(i, j, k) || world.getTypeId(i, j, k) == Block.FENCE.id;
}
public boolean canPlace(World world, int i, int j, int k) {
return world.e(i - 1, j, k) ? true : (world.e(i + 1, j, k) ? true : (world.e(i, j, k - 1) ? true : (world.e(i, j, k + 1) ? true : this.g(world, i, j - 1, k))));
}
public void postPlace(World world, int i, int j, int k, int l) {
if (PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.transmutation-fix.enabled", true) && world.getTypeId(i, j, k) != this.id) return;
int i1 = world.getData(i, j, k);
if (l == 1 && this.g(world, i, j - 1, k)) {
i1 = 5;
}
if (l == 2 && world.e(i, j, k + 1)) {
i1 = 4;
}
if (l == 3 && world.e(i, j, k - 1)) {
i1 = 3;
}
if (l == 4 && world.e(i + 1, j, k)) {
i1 = 2;
}
if (l == 5 && world.e(i - 1, j, k)) {
i1 = 1;
}
world.setData(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.getData(i, j, k) == 0) {
this.c(world, i, j, k);
}
}
public void c(World world, int i, int j, int k) {
if (world.e(i - 1, j, k)) {
world.setData(i, j, k, 1);
} else if (world.e(i + 1, j, k)) {
world.setData(i, j, k, 2);
} else if (world.e(i, j, k - 1)) {
world.setData(i, j, k, 3);
} else if (world.e(i, j, k + 1)) {
world.setData(i, j, k, 4);
} else if (this.g(world, i, j - 1, k)) {
world.setData(i, j, k, 5);
}
this.h(world, i, j, k);
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (this.h(world, i, j, k)) {
int i1 = world.getData(i, j, k);
boolean flag = false;
if (!world.e(i - 1, j, k) && i1 == 1) {
flag = true;
}
if (!world.e(i + 1, j, k) && i1 == 2) {
flag = true;
}
if (!world.e(i, j, k - 1) && i1 == 3) {
flag = true;
}
if (!world.e(i, j, k + 1) && i1 == 4) {
flag = true;
}
if (!this.g(world, i, j - 1, k) && i1 == 5) {
flag = true;
}
if (flag) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(i, j, k, 0);
}
}
}
private boolean h(World world, int i, int j, int k) {
if (!this.canPlace(world, i, j, k) && (!PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.other-fixes.enabled") || world.getTypeId(i, j, k) == this.id)) {
this.g(world, i, j, k, world.getData(i, j, k));
world.setTypeId(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.getData(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);
}
}
@@ -0,0 +1,189 @@
package net.minecraft.server;
import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockTrapdoor extends Block {
protected BlockTrapdoor(int i, Material material) {
super(i, material);
this.textureId = 84;
if (material == Material.ORE) {
++this.textureId;
}
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 a() {
return false;
}
public boolean b() {
return false;
}
public AxisAlignedBB e(World world, int i, int j, int k) {
this.a(world, i, j, k);
return super.e(world, i, j, k);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
this.c(iblockaccess.getData(i, j, k));
}
public void c(int i) {
float f = 0.1875F;
this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
if (d(i)) {
if ((i & 3) == 0) {
this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}
if ((i & 3) == 1) {
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}
if ((i & 3) == 2) {
this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
if ((i & 3) == 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.interact(world, i, j, k, entityhuman);
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (this.material == Material.ORE) {
return true;
} else {
int l = world.getData(i, j, k);
world.setData(i, j, k, l ^ 4);
world.a(entityhuman, 1003, i, j, k, 0);
return true;
}
}
public void a(World world, int i, int j, int k, boolean flag) {
int l = world.getData(i, j, k);
boolean flag1 = (l & 4) > 0;
if (flag1 != flag) {
world.setData(i, j, k, l ^ 4);
world.a((EntityHuman) null, 1003, i, j, k, 0);
}
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
int i1 = world.getData(i, j, k);
int j1 = i;
int k1 = k;
if ((i1 & 3) == 0) {
k1 = k + 1;
}
if ((i1 & 3) == 1) {
--k1;
}
if ((i1 & 3) == 2) {
j1 = i + 1;
}
if ((i1 & 3) == 3) {
--j1;
}
if (!world.e(j1, j, k1)) {
world.setTypeId(i, j, k, 0);
this.g(world, i, j, k, i1);
}
// CraftBukkit start
if (l > 0 && Block.byId[l] != null && Block.byId[l].isPowerSource()) {
org.bukkit.World bworld = world.getWorld();
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
int power = block.getBlockPower();
int oldPower = (world.getData(i, j, k) & 4) > 0 ? 15 : 0;
if (oldPower == 0 ^ power == 0) {
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, oldPower, power);
world.getServer().getPluginManager().callEvent(eventRedstone);
this.a(world, i, j, k, eventRedstone.getNewCurrent() > 0);
}
// CraftBukkit end
}
}
}
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
this.a(world, i, j, k);
return super.a(world, i, j, k, vec3d, vec3d1);
}
public void postPlace(World world, int i, int j, int k, int l) {
byte b0 = 0;
if (l == 2) {
b0 = 0;
}
if (l == 3) {
b0 = 1;
}
if (l == 4) {
b0 = 2;
}
if (l == 5) {
b0 = 3;
}
world.setData(i, j, k, b0);
doPhysics(world, i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit
}
public boolean canPlace(World world, int i, int j, int k, int l) {
if (l == 0) {
return false;
} else if (l == 1) {
return false;
} else {
if (l == 2) {
++k;
}
if (l == 3) {
--k;
}
if (l == 4) {
++i;
}
if (l == 5) {
--i;
}
return world.e(i, j, k);
}
}
public static boolean d(int i) {
return (i & 4) != 0;
}
}
@@ -0,0 +1,30 @@
package net.minecraft.server;
import java.util.Random;
public class BlockWeb extends Block {
public BlockWeb(int i, int j) {
super(i, j, Material.WEB);
}
public void a(World world, int i, int j, int k, Entity entity) {
entity.bf = true;
}
public boolean a() {
return false;
}
public AxisAlignedBB e(World world, int i, int j, int k) {
return null;
}
public boolean b() {
return false;
}
public int a(int i, Random random) {
return Item.STRING.id;
}
}
@@ -0,0 +1,22 @@
package net.minecraft.server;
public class BlockWorkbench extends Block {
protected BlockWorkbench(int i) {
super(i, Material.WOOD);
this.textureId = 59;
}
public int a(int i) {
return i == 1 ? this.textureId - 16 : (i == 0 ? Block.WOOD.a(0) : (i != 2 && i != 4 ? this.textureId : this.textureId + 1));
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) {
return true;
} else {
entityhuman.b(i, j, k);
return true;
}
}
}
@@ -0,0 +1,650 @@
package net.minecraft.server;
import com.legacyminecraft.poseidon.PoseidonConfig;
import java.util.*;
public class Chunk {
public static boolean a;
public byte[] b;
public boolean c;
public World world;
public NibbleArray e;
public NibbleArray f;
public NibbleArray g;
public byte[] heightMap;
public int i;
public final int x;
public final int z;
public Map tileEntities;
public List[] entitySlices;
public boolean done;
public boolean o;
public boolean p;
public boolean q;
public long r;
public Chunk(World world, int i, int j) {
this.tileEntities = new HashMap();
this.entitySlices = new List[8];
this.done = false;
this.o = false;
this.q = false;
this.r = 0L;
this.world = world;
this.x = i;
this.z = j;
this.heightMap = new byte[256];
for (int k = 0; k < this.entitySlices.length; ++k) {
this.entitySlices[k] = new ArrayList();
}
// CraftBukkit start
org.bukkit.craftbukkit.CraftWorld cworld = this.world.getWorld();
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
}
public org.bukkit.Chunk bukkitChunk;
// CraftBukkit end
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.x && j == this.z;
}
public int b(int i, int j) {
return this.heightMap[j << 4 | i] & 255;
}
public void a() {}
public void initLighting() {
int i = 127;
int j;
int k;
for (j = 0; j < 16; ++j) {
for (k = 0; k < 16; ++k) {
int l = 127;
int i1;
for (i1 = j << 11 | k << 7; l > 0 && Block.q[this.b[i1 + l - 1] & 255] == 0; --l) {
;
}
this.heightMap[k << 4 | j] = (byte) l;
if (l < i) {
i = l;
}
if (!this.world.worldProvider.e) {
int j1 = 15;
int k1 = 127;
do {
j1 -= Block.q[this.b[i1 + k1] & 255];
if (j1 > 0) {
this.f.a(j, k1, k, j1);
}
--k1;
} while (k1 > 0 && j1 > 0);
}
}
}
this.i = i;
for (j = 0; j < 16; ++j) {
for (k = 0; k < 16; ++k) {
this.c(j, k);
}
}
this.o = true;
}
public void loadNOP() {}
private void c(int i, int j) {
int k = this.b(i, j);
int l = this.x * 16 + i;
int i1 = this.z * 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.world.getHighestBlockYAt(i, j);
if (l > k) {
this.world.a(EnumSkyBlock.SKY, i, k, j, i, l, j);
this.o = true;
} else if (l < k) {
this.world.a(EnumSkyBlock.SKY, i, l, j, i, k, j);
this.o = true;
}
}
private void g(int i, int j, int k) {
int l = this.heightMap[k << 4 | i] & 255;
int i1 = l;
if (j > l) {
i1 = j;
}
for (int j1 = i << 11 | k << 7; i1 > 0 && Block.q[this.b[j1 + i1 - 1] & 255] == 0; --i1) {
;
}
if (i1 != l) {
this.world.g(i, k, i1, l);
this.heightMap[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.heightMap[i2 << 4 | l1] & 255) < k1) {
k1 = this.heightMap[i2 << 4 | l1] & 255;
}
}
}
this.i = k1;
}
k1 = this.x * 16 + i;
l1 = this.z * 16 + k;
if (i1 < l) {
for (i2 = i1; i2 < l; ++i2) {
this.f.a(i, i2, k, 15);
}
} else {
this.world.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.q[this.getTypeId(i, i1, k)];
if (k2 == 0) {
k2 = 1;
}
i2 -= k2;
if (i2 < 0) {
i2 = 0;
}
}
while (i1 > 0 && Block.q[this.getTypeId(i, i1 - 1, k)] == 0) {
--i1;
}
if (i1 != j2) {
this.world.a(EnumSkyBlock.SKY, k1 - 1, i1, l1 - 1, k1 + 1, j2, l1 + 1);
}
this.o = true;
}
}
public int getTypeId(int i, int j, int k) {
return this.b[i << 11 | k << 7 | j] & 255;
}
public boolean a(int i, int j, int k, int l, int i1) {
byte b0 = (byte) l;
int j1 = this.heightMap[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.x * 16 + i;
int i2 = this.z * 16 + k;
this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255);
if (PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.transmutation-fix.enabled", true)) {
this.e.a(i, j, k, i1);
if (k1 != 0 && !this.world.isStatic) {
Block.byId[k1].remove(this.world, l1, j, i2);
}
} else {
if (k1 != 0 && !this.world.isStatic) {
Block.byId[k1].remove(this.world, l1, j, i2);
}
this.e.a(i, j, k, i1);
}
if (!this.world.worldProvider.e) {
if (Block.q[b0 & 255] != 0) {
if (j >= j1) {
this.g(i, j + 1, k);
}
} else if (j == j1 - 1) {
this.g(i, j, k);
}
this.world.a(EnumSkyBlock.SKY, l1, j, i2, l1, j, i2);
}
this.world.a(EnumSkyBlock.BLOCK, l1, j, i2, l1, j, i2);
this.c(i, k);
if (l != 0) {
Block.byId[l].c(this.world, 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.heightMap[k << 4 | i] & 255;
int j1 = this.b[i << 11 | k << 7 | j] & 255;
if (j1 == l) {
return false;
} else {
int k1 = this.x * 16 + i;
int l1 = this.z * 16 + k;
this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255);
if (j1 != 0) {
Block.byId[j1].remove(this.world, k1, j, l1);
}
this.e.a(i, j, k, 0);
if (Block.q[b0 & 255] != 0) {
if (j >= i1) {
this.g(i, j + 1, k);
}
} else if (j == i1 - 1) {
this.g(i, j, k);
}
this.world.a(EnumSkyBlock.SKY, k1, j, l1, k1, j, l1);
this.world.a(EnumSkyBlock.BLOCK, k1, j, l1, k1, j, l1);
this.c(i, k);
if (l != 0 && !this.world.isStatic) {
Block.byId[l].c(this.world, k1, j, l1);
}
this.o = true;
return true;
}
}
public int getData(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) {
this.q = true;
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
if (i != this.x || j != this.z) {
System.out.println("Wrong location! " + entity);
// Thread.dumpStack(); // CraftBukkit
// CraftBukkit
System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z);
}
int k = MathHelper.floor(entity.locY / 16.0D);
if (k < 0) {
k = 0;
}
if (k >= this.entitySlices.length) {
k = this.entitySlices.length - 1;
}
entity.bG = true;
entity.bH = this.x;
entity.bI = k;
entity.bJ = this.z;
this.entitySlices[k].add(entity);
}
public void b(Entity entity) {
this.a(entity, entity.bI);
}
public void a(Entity entity, int i) {
if (i < 0) {
i = 0;
}
if (i >= this.entitySlices.length) {
i = this.entitySlices.length - 1;
}
this.entitySlices[i].remove(entity);
}
public boolean c(int i, int j, int k) {
return j >= (this.heightMap[k << 4 | i] & 255);
}
public TileEntity d(int i, int j, int k) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k);
TileEntity tileentity = (TileEntity) this.tileEntities.get(chunkposition);
if (tileentity == null) {
int l = this.getTypeId(i, j, k);
if (!Block.isTileEntity[l]) {
return null;
}
BlockContainer blockcontainer = (BlockContainer) Block.byId[l];
blockcontainer.c(this.world, this.x * 16 + i, j, this.z * 16 + k);
tileentity = (TileEntity) this.tileEntities.get(chunkposition);
}
if (tileentity != null && tileentity.g()) {
this.tileEntities.remove(chunkposition);
return null;
} else {
return tileentity;
}
}
public void a(TileEntity tileentity) {
int i = tileentity.x - this.x * 16;
int j = tileentity.y;
int k = tileentity.z - this.z * 16;
this.placeTileEntity(i, j, k, tileentity);
if (this.c) {
this.world.c.add(tileentity);
}
}
public void placeTileEntity(int i, int j, int k, TileEntity tileentity) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k);
tileentity.world = this.world;
tileentity.x = this.x * 16 + i;
tileentity.y = j;
tileentity.z = this.z * 16 + k;
if (this.getTypeId(i, j, k) != 0 && Block.byId[this.getTypeId(i, j, k)] instanceof BlockContainer) {
tileentity.j();
this.tileEntities.put(chunkposition, tileentity);
// Poseidon start - Backport of 0021-Remove-invalid-mob-spawner-tile-entities.patch from PaperSpigot
} else if (tileentity instanceof TileEntityMobSpawner && !(Block.byId[this.getTypeId(i, j, k)] instanceof BlockMobSpawner)) {
this.tileEntities.remove(chunkposition);
// Poseidon end
} 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) {
TileEntity tileentity = (TileEntity) this.tileEntities.remove(chunkposition);
if (tileentity != null) {
tileentity.h();
}
}
}
public void addEntities() {
this.c = true;
this.world.a(this.tileEntities.values());
for (int i = 0; i < this.entitySlices.length; ++i) {
this.world.a(this.entitySlices[i]);
}
}
public void removeEntities() {
this.c = false;
Iterator iterator = this.tileEntities.values().iterator();
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();
world.markForRemoval(tileentity); // Craftbukkit
}
for (int i = 0; i < this.entitySlices.length; ++i) {
// CraftBukkit start
java.util.Iterator<Object> iter = this.entitySlices[i].iterator();
while (iter.hasNext()) {
Entity entity = (Entity) iter.next();
int cx = org.bukkit.Location.locToBlock(entity.locX) >> 4;
int cz = org.bukkit.Location.locToBlock(entity.locZ) >> 4;
// Do not pass along players, as doing so can get them stuck outside of time.
// (which for example disables inventory icon updates and prevents block breaking)
if (entity instanceof EntityPlayer && (cx != this.x || cz != this.z)) {
iter.remove();
}
}
// CraftBukkit end
this.world.b(this.entitySlices[i]);
}
}
public void f() {
this.o = true;
}
public void a(Entity entity, AxisAlignedBB axisalignedbb, List list) {
int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
if (i < 0) {
i = 0;
}
if (j >= this.entitySlices.length) {
j = this.entitySlices.length - 1;
}
for (int k = i; k <= j; ++k) {
List list1 = this.entitySlices[k];
for (int l = 0; l < list1.size(); ++l) {
Entity entity1 = (Entity) list1.get(l);
if (entity1 != entity && entity1.boundingBox.a(axisalignedbb)) {
list.add(entity1);
}
}
}
}
public void a(Class oclass, AxisAlignedBB axisalignedbb, List list) {
int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
if (i < 0) {
i = 0;
}
if (j >= this.entitySlices.length) {
j = this.entitySlices.length - 1;
}
for (int k = i; k <= j; ++k) {
List list1 = this.entitySlices[k];
for (int l = 0; l < list1.size(); ++l) {
Entity entity = (Entity) list1.get(l);
if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.a(axisalignedbb)) {
list.add(entity);
}
}
}
}
public boolean a(boolean flag) {
if (this.p) {
return false;
} else {
if (flag) {
if (this.q && this.world.getTime() != this.r) {
return true;
}
} else if (this.q && this.world.getTime() >= this.r + 600L) {
return true;
}
return this.o;
}
}
public int getData(byte[] abyte, int i, int j, int k, int l, int i1, int j1, int k1) {
int l1 = l - i;
int i2 = i1 - j;
int j2 = j1 - k;
if (l1 * i2 * j2 == this.b.length) {
System.arraycopy(this.b, 0, abyte, k1, this.b.length);
k1 += this.b.length;
System.arraycopy(this.e.a, 0, abyte, k1, this.e.a.length);
k1 += this.e.a.length;
System.arraycopy(this.g.a, 0, abyte, k1, this.g.a.length);
k1 += this.g.a.length;
System.arraycopy(this.f.a, 0, abyte, k1, this.f.a.length);
k1 += this.f.a.length;
return k1;
} else {
int k2;
int l2;
int i3;
int j3;
for (k2 = i; k2 < l; ++k2) {
for (l2 = k; l2 < j1; ++l2) {
i3 = k2 << 11 | l2 << 7 | j;
j3 = i1 - j;
System.arraycopy(this.b, i3, abyte, k1, j3);
k1 += j3;
}
}
for (k2 = i; k2 < l; ++k2) {
for (l2 = k; l2 < j1; ++l2) {
i3 = (k2 << 11 | l2 << 7 | j) >> 1;
j3 = (i1 - j) / 2;
System.arraycopy(this.e.a, i3, abyte, k1, j3);
k1 += j3;
}
}
for (k2 = i; k2 < l; ++k2) {
for (l2 = k; l2 < j1; ++l2) {
i3 = (k2 << 11 | l2 << 7 | j) >> 1;
j3 = (i1 - j) / 2;
System.arraycopy(this.g.a, i3, abyte, k1, j3);
k1 += j3;
}
}
for (k2 = i; k2 < l; ++k2) {
for (l2 = k; l2 < j1; ++l2) {
i3 = (k2 << 11 | l2 << 7 | j) >> 1;
j3 = (i1 - j) / 2;
System.arraycopy(this.f.a, i3, abyte, k1, j3);
k1 += j3;
}
}
return k1;
}
}
public Random a(long i) {
return new Random(this.world.getSeed() + (long) (this.x * this.x * 4987142) + (long) (this.x * 5947611) + (long) (this.z * this.z) * 4392871L + (long) (this.z * 389711) ^ i);
}
public boolean isEmpty() {
return false;
}
public void h() {
BlockRegister.a(this.b);
}
}
@@ -0,0 +1,22 @@
package net.minecraft.server;
import java.io.ByteArrayOutputStream;
class ChunkBuffer extends ByteArrayOutputStream {
private int b;
private int c;
final RegionFile a;
public ChunkBuffer(RegionFile regionfile, int i, int j) {
super(8096);
this.a = regionfile;
this.b = i;
this.c = j;
}
public void close() {
this.a.a(this.b, this.c, this.buf, this.count);
}
}
@@ -0,0 +1,76 @@
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.getChunkAt(i2, j2);
}
}
}
public int getTypeId(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;
if (l >= 0 && l < this.c.length && i1 >= 0 && i1 < this.c[l].length) {
Chunk chunk = this.c[l][i1];
return chunk == null ? 0 : chunk.getTypeId(i & 15, j, k & 15);
} else {
return 0;
}
}
}
public TileEntity getTileEntity(int i, int j, int k) {
int l = (i >> 4) - this.a;
int i1 = (k >> 4) - this.b;
return this.c[l][i1].d(i & 15, j, k & 15);
}
public int getData(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].getData(i & 15, j, k & 15);
}
}
public Material getMaterial(int i, int j, int k) {
int l = this.getTypeId(i, j, k);
return l == 0 ? Material.AIR : Block.byId[l].material;
}
public boolean e(int i, int j, int k) {
Block block = Block.byId[this.getTypeId(i, j, k)];
return block == null ? false : block.material.isSolid() && block.b();
}
}
@@ -0,0 +1,26 @@
package net.minecraft.server;
public class ChunkCoordIntPair {
public final int x;
public final int z;
public ChunkCoordIntPair(int i, int j) {
this.x = i;
this.z = j;
}
public static int a(int i, int j) {
return (i < 0 ? Integer.MIN_VALUE : 0) | (i & 32767) << 16 | (j < 0 ? '\u8000' : 0) | j & 32767;
}
public int hashCode() {
return a(this.x, this.z);
}
public boolean equals(Object object) {
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) object;
return chunkcoordintpair.x == this.x && chunkcoordintpair.z == this.z;
}
}
@@ -0,0 +1,49 @@
package net.minecraft.server;
public class ChunkCoordinates implements Comparable {
public int x;
public int y;
public int z;
public ChunkCoordinates() {}
public ChunkCoordinates(int i, int j, int k) {
this.x = i;
this.y = j;
this.z = k;
}
public ChunkCoordinates(ChunkCoordinates chunkcoordinates) {
this.x = chunkcoordinates.x;
this.y = chunkcoordinates.y;
this.z = chunkcoordinates.z;
}
public boolean equals(Object object) {
if (!(object instanceof ChunkCoordinates)) {
return false;
} else {
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) object;
return this.x == chunkcoordinates.x && this.y == chunkcoordinates.y && this.z == chunkcoordinates.z;
}
}
public int hashCode() {
return this.x + this.z << 8 + this.y << 16;
}
public int compareTo(Object o) {
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) o;
return this.y == chunkcoordinates.y ? (this.z == chunkcoordinates.z ? this.x - chunkcoordinates.x : this.z - chunkcoordinates.z) : this.y - chunkcoordinates.y;
}
public double a(int i, int j, int k) {
int l = this.x - i;
int i1 = this.y - j;
int j1 = this.z - k;
return Math.sqrt((double) (l * l + i1 * i1 + j1 * j1));
}
}
@@ -0,0 +1,51 @@
package net.minecraft.server;
import java.io.File;
import java.util.regex.Matcher;
class ChunkFile implements Comparable {
private final File a;
private final int b;
private final int c;
public ChunkFile(File file1) {
this.a = file1;
Matcher matcher = ChunkFilenameFilter.a.matcher(file1.getName());
if (matcher.matches()) {
this.b = Integer.parseInt(matcher.group(1), 36);
this.c = Integer.parseInt(matcher.group(2), 36);
} else {
this.b = 0;
this.c = 0;
}
}
public int compareTo(Object o) {
ChunkFile chunkfile = (ChunkFile) o;
int i = this.b >> 5;
int j = chunkfile.b >> 5;
if (i == j) {
int k = this.c >> 5;
int l = chunkfile.c >> 5;
return k - l;
} else {
return i - j;
}
}
public File a() {
return this.a;
}
public int b() {
return this.b;
}
public int c() {
return this.c;
}
}
@@ -0,0 +1,27 @@
package net.minecraft.server;
import java.io.File;
import java.io.FileFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class ChunkFileFilter implements FileFilter {
public static final Pattern a = Pattern.compile("[0-9a-z]|([0-9a-z][0-9a-z])");
private ChunkFileFilter() {}
public boolean accept(File file1) {
if (file1.isDirectory()) {
Matcher matcher = a.matcher(file1.getName());
return matcher.matches();
} else {
return false;
}
}
ChunkFileFilter(EmptyClass2 emptyclass2) {
this();
}
}
@@ -0,0 +1,23 @@
package net.minecraft.server;
import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class ChunkFilenameFilter implements FilenameFilter {
public static final Pattern a = Pattern.compile("c\\.(-?[0-9a-z]+)\\.(-?[0-9a-z]+)\\.dat");
private ChunkFilenameFilter() {}
public boolean accept(File file1, String s) {
Matcher matcher = a.matcher(s);
return matcher.matches();
}
ChunkFilenameFilter(EmptyClass2 emptyclass2) {
this();
}
}
@@ -0,0 +1,221 @@
package net.minecraft.server;
import java.io.*;
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.hasKey("Level")) {
System.out.println("Chunk file at " + i + "," + j + " is missing level data, skipping");
return null;
}
if (!nbttagcompound.k("Level").hasKey("Blocks")) {
System.out.println("Chunk file at " + i + "," + j + " is missing block data, skipping");
return null;
}
Chunk chunk = a(world, nbttagcompound.k("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.x + ", " + chunk.z + ")");
nbttagcompound.a("xPos", i);
nbttagcompound.a("zPos", j);
chunk = a(world, nbttagcompound.k("Level"));
}
chunk.h();
return chunk;
} catch (Exception exception) {
exception.printStackTrace();
}
}
return null;
}
public void a(World world, Chunk chunk) {
world.k();
File file1 = this.a(chunk.x, chunk.z);
if (file1.exists()) {
WorldData worlddata = world.q();
worlddata.b(worlddata.g() - 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);
a(chunk, world, nbttagcompound1);
CompressedStreamTools.a(nbttagcompound, (OutputStream) fileoutputstream);
fileoutputstream.close();
if (file1.exists()) {
file1.delete();
}
file2.renameTo(file1);
WorldData worlddata1 = world.q();
worlddata1.b(worlddata1.g() + file1.length());
} catch (Exception exception) {
exception.printStackTrace();
}
}
public static void a(Chunk chunk, World world, NBTTagCompound nbttagcompound) {
world.k();
nbttagcompound.a("xPos", chunk.x);
nbttagcompound.a("zPos", chunk.z);
nbttagcompound.setLong("LastUpdate", world.getTime());
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.heightMap);
nbttagcompound.a("TerrainPopulated", chunk.done);
chunk.q = false;
NBTTagList nbttaglist = new NBTTagList();
Iterator iterator;
NBTTagCompound nbttagcompound1;
for (int i = 0; i < chunk.entitySlices.length; ++i) {
iterator = chunk.entitySlices[i].iterator();
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
chunk.q = true;
nbttagcompound1 = new NBTTagCompound();
if (entity.c(nbttagcompound1)) {
nbttaglist.a((NBTBase) nbttagcompound1);
}
}
}
nbttagcompound.a("Entities", (NBTBase) nbttaglist);
NBTTagList nbttaglist1 = new NBTTagList();
iterator = chunk.tileEntities.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.e("xPos");
int j = nbttagcompound.e("zPos");
Chunk chunk = new Chunk(world, i, j);
chunk.b = nbttagcompound.j("Blocks");
chunk.e = new NibbleArray(nbttagcompound.j("Data"));
chunk.f = new NibbleArray(nbttagcompound.j("SkyLight"));
chunk.g = new NibbleArray(nbttagcompound.j("BlockLight"));
chunk.heightMap = nbttagcompound.j("HeightMap");
chunk.done = nbttagcompound.m("TerrainPopulated");
if (!chunk.e.a()) {
chunk.e = new NibbleArray(chunk.b.length);
}
if (chunk.heightMap == null || !chunk.f.a()) {
chunk.heightMap = new byte[256];
chunk.f = new NibbleArray(chunk.b.length);
chunk.initLighting();
}
if (!chunk.g.a()) {
chunk.g = new NibbleArray(chunk.b.length);
chunk.a();
}
NBTTagList nbttaglist = nbttagcompound.l("Entities");
if (nbttaglist != null) {
for (int k = 0; k < nbttaglist.c(); ++k) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(k);
Entity entity = EntityTypes.a(nbttagcompound1, world);
chunk.q = true;
if (entity != null) {
chunk.a(entity);
}
}
}
NBTTagList nbttaglist1 = nbttagcompound.l("TileEntities");
if (nbttaglist1 != null) {
for (int l = 0; l < nbttaglist1.c(); ++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) {}
}
@@ -0,0 +1,28 @@
package net.minecraft.server;
public class ChunkPosition {
public final int x;
public final int y;
public final int z;
public ChunkPosition(int i, int j, int k) {
this.x = i;
this.y = j;
this.z = k;
}
public boolean equals(Object object) {
if (!(object instanceof ChunkPosition)) {
return false;
} else {
ChunkPosition chunkposition = (ChunkPosition) object;
return chunkposition.x == this.x && chunkposition.y == this.y && chunkposition.z == this.z;
}
}
public int hashCode() {
return this.x * 8976890 + this.y * 981131 + this.z;
}
}
@@ -0,0 +1,642 @@
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();
private BiomeBase[] v;
double[] d;
double[] e;
double[] f;
double[] g;
double[] h;
int[][] i = new int[32][32];
private double[] w;
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, BiomeBase[] abiomebase, double[] adouble) {
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) {
double d17 = adouble[(i1 * 4 + i2) * 16 + j1 * 4 + k2];
int l2 = 0;
if (k1 * 8 + l1 < b1) {
if (d17 < 0.5D && k1 * 8 + l1 >= b1 - 1) {
l2 = Block.ICE.id;
} else {
l2 = Block.STATIONARY_WATER.id;
}
}
if (d15 > 0.0D) {
l2 = Block.STONE.id;
}
abyte[j2] = (byte) l2;
j2 += short1;
d15 += d16;
}
d10 += d12;
d11 += d13;
}
d1 += d5;
d2 += d6;
d3 += d7;
d4 += d8;
}
}
}
}
}
public void a(int i, int j, byte[] abyte, BiomeBase[] abiomebase) {
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) (i * 16), 109.0134D, (double) (j * 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) {
BiomeBase biomebase = abiomebase[k + l * 16];
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 = biomebase.p;
byte b2 = biomebase.q;
for (int k1 = 127; k1 >= 0; --k1) {
int l1 = (l * 16 + k) * 128 + k1;
if (k1 <= 0 + this.j.nextInt(5)) {
abyte[l1] = (byte) Block.BEDROCK.id;
} else {
byte b3 = abyte[l1];
if (b3 == 0) {
j1 = -1;
} else if (b3 == Block.STONE.id) {
if (j1 == -1) {
if (i1 <= 0) {
b1 = 0;
b2 = (byte) Block.STONE.id;
} else if (k1 >= b0 - 4 && k1 <= b0 + 1) {
b1 = biomebase.p;
b2 = biomebase.q;
if (flag1) {
b1 = 0;
}
if (flag1) {
b2 = (byte) Block.GRAVEL.id;
}
if (flag) {
b1 = (byte) Block.SAND.id;
}
if (flag) {
b2 = (byte) Block.SAND.id;
}
}
if (k1 < b0 && b1 == 0) {
b1 = (byte) Block.STATIONARY_WATER.id;
}
j1 = i1;
if (k1 >= b0 - 1) {
abyte[l1] = b1;
} else {
abyte[l1] = b2;
}
} else if (j1 > 0) {
--j1;
abyte[l1] = b2;
if (j1 == 0 && b2 == Block.SAND.id) {
j1 = this.j.nextInt(4);
b2 = (byte) Block.SANDSTONE.id;
}
}
}
}
}
}
}
}
public Chunk getChunkAt(int i, int j) {
return this.getOrCreateChunk(i, j);
}
public Chunk getOrCreateChunk(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.v = this.p.getWorldChunkManager().a(this.v, i * 16, j * 16, 16, 16);
double[] adouble = this.p.getWorldChunkManager().temperature;
this.a(i, j, abyte, this.v, adouble);
this.a(i, j, abyte, this.v);
this.u.a(this, this.p, i, j, abyte);
chunk.initLighting();
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;
double[] adouble1 = this.p.getWorldChunkManager().temperature;
double[] adouble2 = this.p.getWorldChunkManager().rain;
this.g = this.a.a(this.g, i, k, l, j1, 1.121D, 1.121D, 0.5D);
this.h = this.b.a(this.h, i, k, l, j1, 200.0D, 200.0D, 0.5D);
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;
int i2 = 16 / l;
for (int j2 = 0; j2 < l; ++j2) {
int k2 = j2 * i2 + i2 / 2;
for (int l2 = 0; l2 < j1; ++l2) {
int i3 = l2 * i2 + i2 / 2;
double d2 = adouble1[k2 * 16 + i3];
double d3 = adouble2[k2 * 16 + i3] * d2;
double d4 = 1.0D - d3;
d4 *= d4;
d4 *= d4;
d4 = 1.0D - d4;
double d5 = (this.g[l1] + 256.0D) / 512.0D;
d5 *= d4;
if (d5 > 1.0D) {
d5 = 1.0D;
}
double d6 = this.h[l1] / 8000.0D;
if (d6 < 0.0D) {
d6 = -d6 * 0.3D;
}
d6 = d6 * 3.0D - 2.0D;
if (d6 < 0.0D) {
d6 /= 2.0D;
if (d6 < -1.0D) {
d6 = -1.0D;
}
d6 /= 1.4D;
d6 /= 2.0D;
d5 = 0.0D;
} else {
if (d6 > 1.0D) {
d6 = 1.0D;
}
d6 /= 8.0D;
}
if (d5 < 0.0D) {
d5 = 0.0D;
}
d5 += 0.5D;
d6 = d6 * (double) i1 / 16.0D;
double d7 = (double) i1 / 2.0D + d6 * 4.0D;
++l1;
for (int j3 = 0; j3 < i1; ++j3) {
double d8 = 0.0D;
double d9 = ((double) j3 - d7) * 12.0D / d5;
if (d9 < 0.0D) {
d9 *= 4.0D;
}
double d10 = this.e[k1] / 512.0D;
double d11 = this.f[k1] / 512.0D;
double d12 = (this.d[k1] / 10.0D + 1.0D) / 2.0D;
if (d12 < 0.0D) {
d8 = d10;
} else if (d12 > 1.0D) {
d8 = d11;
} else {
d8 = d10 + (d11 - d10) * d12;
}
d8 -= d9;
if (j3 > i1 - 4) {
double d13 = (double) ((float) (j3 - (i1 - 4)) / 3.0F);
d8 = d8 * (1.0D - d13) + -10.0D * d13;
}
adouble[k1] = d8;
++k1;
}
}
}
return adouble;
}
public boolean isChunkLoaded(int i, int j) {
return true;
}
public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) {
BlockSand.instaFall = true;
int k = i * 16;
int l = j * 16;
BiomeBase biomebase = this.p.getWorldChunkManager().getBiome(k + 16, l + 16);
this.j.setSeed(this.p.getSeed());
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.getSeed());
double d0 = 0.25D;
int k1;
int l1;
int i2;
if (this.j.nextInt(4) == 0) {
k1 = k + this.j.nextInt(16) + 8;
l1 = this.j.nextInt(128);
i2 = l + this.j.nextInt(16) + 8;
(new WorldGenLakes(Block.STATIONARY_WATER.id)).a(this.p, this.j, k1, l1, i2);
}
if (this.j.nextInt(8) == 0) {
k1 = k + this.j.nextInt(16) + 8;
l1 = this.j.nextInt(this.j.nextInt(120) + 8);
i2 = l + this.j.nextInt(16) + 8;
if (l1 < 64 || this.j.nextInt(10) == 0) {
(new WorldGenLakes(Block.STATIONARY_LAVA.id)).a(this.p, this.j, k1, l1, 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.id, 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.id, 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.id, 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.id, 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.id, 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.id, 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.id, 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) + this.j.nextInt(16);
j2 = l + this.j.nextInt(16);
(new WorldGenMinable(Block.LAPIS_ORE.id, 6)).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);
l1 = 0;
if (this.j.nextInt(10) == 0) {
++l1;
}
if (biomebase == BiomeBase.FOREST) {
l1 += k1 + 5;
}
if (biomebase == BiomeBase.RAINFOREST) {
l1 += k1 + 5;
}
if (biomebase == BiomeBase.SEASONAL_FOREST) {
l1 += k1 + 2;
}
if (biomebase == BiomeBase.TAIGA) {
l1 += k1 + 5;
}
if (biomebase == BiomeBase.DESERT) {
l1 -= 20;
}
if (biomebase == BiomeBase.TUNDRA) {
l1 -= 20;
}
if (biomebase == BiomeBase.PLAINS) {
l1 -= 20;
}
int k2;
for (i2 = 0; i2 < l1; ++i2) {
j2 = k + this.j.nextInt(16) + 8;
k2 = l + this.j.nextInt(16) + 8;
WorldGenerator worldgenerator = biomebase.a(this.j);
worldgenerator.a(1.0D, 1.0D, 1.0D);
worldgenerator.a(this.p, this.j, j2, this.p.getHighestBlockYAt(j2, k2), k2);
}
byte b0 = 0;
if (biomebase == BiomeBase.FOREST) {
b0 = 2;
}
if (biomebase == BiomeBase.SEASONAL_FOREST) {
b0 = 4;
}
if (biomebase == BiomeBase.TAIGA) {
b0 = 2;
}
if (biomebase == BiomeBase.PLAINS) {
b0 = 3;
}
int l2;
int i3;
for (j2 = 0; j2 < b0; ++j2) {
k2 = k + this.j.nextInt(16) + 8;
i3 = this.j.nextInt(128);
l2 = l + this.j.nextInt(16) + 8;
(new WorldGenFlowers(Block.YELLOW_FLOWER.id)).a(this.p, this.j, k2, i3, l2);
}
byte b1 = 0;
if (biomebase == BiomeBase.FOREST) {
b1 = 2;
}
if (biomebase == BiomeBase.RAINFOREST) {
b1 = 10;
}
if (biomebase == BiomeBase.SEASONAL_FOREST) {
b1 = 2;
}
if (biomebase == BiomeBase.TAIGA) {
b1 = 1;
}
if (biomebase == BiomeBase.PLAINS) {
b1 = 10;
}
int j3;
int k3;
for (k2 = 0; k2 < b1; ++k2) {
byte b2 = 1;
if (biomebase == BiomeBase.RAINFOREST && this.j.nextInt(3) != 0) {
b2 = 2;
}
l2 = k + this.j.nextInt(16) + 8;
k3 = this.j.nextInt(128);
j3 = l + this.j.nextInt(16) + 8;
(new WorldGenGrass(Block.LONG_GRASS.id, b2)).a(this.p, this.j, l2, k3, j3);
}
b1 = 0;
if (biomebase == BiomeBase.DESERT) {
b1 = 2;
}
for (k2 = 0; k2 < b1; ++k2) {
i3 = k + this.j.nextInt(16) + 8;
l2 = this.j.nextInt(128);
k3 = l + this.j.nextInt(16) + 8;
(new WorldGenDeadBush(Block.DEAD_BUSH.id)).a(this.p, this.j, i3, l2, k3);
}
if (this.j.nextInt(2) == 0) {
k2 = k + this.j.nextInt(16) + 8;
i3 = this.j.nextInt(128);
l2 = l + this.j.nextInt(16) + 8;
(new WorldGenFlowers(Block.RED_ROSE.id)).a(this.p, this.j, k2, i3, l2);
}
if (this.j.nextInt(4) == 0) {
k2 = k + this.j.nextInt(16) + 8;
i3 = this.j.nextInt(128);
l2 = l + this.j.nextInt(16) + 8;
(new WorldGenFlowers(Block.BROWN_MUSHROOM.id)).a(this.p, this.j, k2, i3, l2);
}
if (this.j.nextInt(8) == 0) {
k2 = k + this.j.nextInt(16) + 8;
i3 = this.j.nextInt(128);
l2 = l + this.j.nextInt(16) + 8;
(new WorldGenFlowers(Block.RED_MUSHROOM.id)).a(this.p, this.j, k2, i3, l2);
}
for (k2 = 0; k2 < 10; ++k2) {
i3 = k + this.j.nextInt(16) + 8;
l2 = this.j.nextInt(128);
k3 = l + this.j.nextInt(16) + 8;
(new WorldGenReed()).a(this.p, this.j, i3, l2, k3);
}
if (this.j.nextInt(32) == 0) {
k2 = k + this.j.nextInt(16) + 8;
i3 = this.j.nextInt(128);
l2 = l + this.j.nextInt(16) + 8;
(new WorldGenPumpkin()).a(this.p, this.j, k2, i3, l2);
}
k2 = 0;
if (biomebase == BiomeBase.DESERT) {
k2 += 10;
}
for (i3 = 0; i3 < k2; ++i3) {
l2 = k + this.j.nextInt(16) + 8;
k3 = this.j.nextInt(128);
j3 = l + this.j.nextInt(16) + 8;
(new WorldGenCactus()).a(this.p, this.j, l2, k3, j3);
}
for (i3 = 0; i3 < 50; ++i3) {
l2 = k + this.j.nextInt(16) + 8;
k3 = this.j.nextInt(this.j.nextInt(120) + 8);
j3 = l + this.j.nextInt(16) + 8;
(new WorldGenLiquids(Block.WATER.id)).a(this.p, this.j, l2, k3, j3);
}
for (i3 = 0; i3 < 20; ++i3) {
l2 = k + this.j.nextInt(16) + 8;
k3 = this.j.nextInt(this.j.nextInt(this.j.nextInt(112) + 8) + 8);
j3 = l + this.j.nextInt(16) + 8;
(new WorldGenLiquids(Block.LAVA.id)).a(this.p, this.j, l2, k3, j3);
}
this.w = this.p.getWorldChunkManager().a(this.w, k + 8, l + 8, 16, 16);
for (i3 = k + 8; i3 < k + 8 + 16; ++i3) {
for (l2 = l + 8; l2 < l + 8 + 16; ++l2) {
k3 = i3 - (k + 8);
j3 = l2 - (l + 8);
int l3 = this.p.e(i3, l2);
double d1 = this.w[k3 * 16 + j3] - (double) (l3 - 64) / 64.0D * 0.3D;
if (d1 < 0.5D && l3 > 0 && l3 < 128 && this.p.isEmpty(i3, l3, l2) && this.p.getMaterial(i3, l3 - 1, l2).isSolid() && this.p.getMaterial(i3, l3 - 1, l2) != Material.ICE) {
this.p.setTypeId(i3, l3, l2, Block.SNOW.id);
}
}
}
BlockSand.instaFall = false;
}
public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) {
return true;
}
public boolean unloadChunks() {
return false;
}
public boolean canSave() {
return true;
}
}
@@ -0,0 +1,387 @@
package net.minecraft.server;
import java.util.Random;
public class ChunkProviderHell implements IChunkProvider {
private Random h;
private NoiseGeneratorOctaves i;
private NoiseGeneratorOctaves j;
private NoiseGeneratorOctaves k;
private NoiseGeneratorOctaves l;
private NoiseGeneratorOctaves m;
public NoiseGeneratorOctaves a;
public NoiseGeneratorOctaves b;
private World n;
private double[] o;
private double[] p = new double[256];
private double[] q = new double[256];
private double[] r = new double[256];
private MapGenBase s = new MapGenCavesHell();
double[] c;
double[] d;
double[] e;
double[] f;
double[] g;
public ChunkProviderHell(World world, long i) {
this.n = world;
this.h = new Random(i);
this.i = new NoiseGeneratorOctaves(this.h, 16);
this.j = new NoiseGeneratorOctaves(this.h, 16);
this.k = new NoiseGeneratorOctaves(this.h, 8);
this.l = new NoiseGeneratorOctaves(this.h, 4);
this.m = new NoiseGeneratorOctaves(this.h, 4);
this.a = new NoiseGeneratorOctaves(this.h, 10);
this.b = new NoiseGeneratorOctaves(this.h, 16);
}
public void a(int i, int j, byte[] abyte) {
byte b0 = 4;
byte b1 = 32;
int k = b0 + 1;
byte b2 = 17;
int l = b0 + 1;
this.o = this.a(this.o, 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.o[((i1 + 0) * l + j1 + 0) * b2 + k1 + 0];
double d2 = this.o[((i1 + 0) * l + j1 + 1) * b2 + k1 + 0];
double d3 = this.o[((i1 + 1) * l + j1 + 0) * b2 + k1 + 0];
double d4 = this.o[((i1 + 1) * l + j1 + 1) * b2 + k1 + 0];
double d5 = (this.o[((i1 + 0) * l + j1 + 0) * b2 + k1 + 1] - d1) * d0;
double d6 = (this.o[((i1 + 0) * l + j1 + 1) * b2 + k1 + 1] - d2) * d0;
double d7 = (this.o[((i1 + 1) * l + j1 + 0) * b2 + k1 + 1] - d3) * d0;
double d8 = (this.o[((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) {
l2 = Block.STATIONARY_LAVA.id;
}
if (d15 > 0.0D) {
l2 = Block.NETHERRACK.id;
}
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.p = this.l.a(this.p, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0, d0, 1.0D);
this.q = this.l.a(this.q, (double) (i * 16), 109.0134D, (double) (j * 16), 16, 1, 16, d0, 1.0D, d0);
this.r = this.m.a(this.r, (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.p[k + l * 16] + this.h.nextDouble() * 0.2D > 0.0D;
boolean flag1 = this.q[k + l * 16] + this.h.nextDouble() * 0.2D > 0.0D;
int i1 = (int) (this.r[k + l * 16] / 3.0D + 3.0D + this.h.nextDouble() * 0.25D);
int j1 = -1;
byte b1 = (byte) Block.NETHERRACK.id;
byte b2 = (byte) Block.NETHERRACK.id;
for (int k1 = 127; k1 >= 0; --k1) {
int l1 = (l * 16 + k) * 128 + k1;
if (k1 >= 127 - this.h.nextInt(5)) {
abyte[l1] = (byte) Block.BEDROCK.id;
} else if (k1 <= 0 + this.h.nextInt(5)) {
abyte[l1] = (byte) Block.BEDROCK.id;
} else {
byte b3 = abyte[l1];
if (b3 == 0) {
j1 = -1;
} else if (b3 == Block.NETHERRACK.id) {
if (j1 == -1) {
if (i1 <= 0) {
b1 = 0;
b2 = (byte) Block.NETHERRACK.id;
} else if (k1 >= b0 - 4 && k1 <= b0 + 1) {
b1 = (byte) Block.NETHERRACK.id;
b2 = (byte) Block.NETHERRACK.id;
if (flag1) {
b1 = (byte) Block.GRAVEL.id;
}
if (flag1) {
b2 = (byte) Block.NETHERRACK.id;
}
if (flag) {
b1 = (byte) Block.SOUL_SAND.id;
}
if (flag) {
b2 = (byte) Block.SOUL_SAND.id;
}
}
if (k1 < b0 && b1 == 0) {
b1 = (byte) Block.STATIONARY_LAVA.id;
}
j1 = i1;
if (k1 >= b0 - 1) {
abyte[l1] = b1;
} else {
abyte[l1] = b2;
}
} else if (j1 > 0) {
--j1;
abyte[l1] = b2;
}
}
}
}
}
}
}
public Chunk getChunkAt(int i, int j) {
return this.getOrCreateChunk(i, j);
}
public Chunk getOrCreateChunk(int i, int j) {
this.h.setSeed((long) i * 341873128712L + (long) j * 132897987541L);
byte[] abyte = new byte['\u8000'];
this.a(i, j, abyte);
this.b(i, j, abyte);
this.s.a(this, this.n, i, j, abyte);
Chunk chunk = new Chunk(this.n, abyte, i, j);
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 = 2053.236D;
this.f = this.a.a(this.f, (double) i, (double) j, (double) k, l, 1, j1, 1.0D, 0.0D, 1.0D);
this.g = this.b.a(this.g, (double) i, (double) j, (double) k, l, 1, j1, 100.0D, 0.0D, 100.0D);
this.c = this.k.a(this.c, (double) i, (double) j, (double) k, l, i1, j1, d0 / 80.0D, d1 / 60.0D, d0 / 80.0D);
this.d = this.i.a(this.d, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0);
this.e = this.j.a(this.e, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0);
int k1 = 0;
int l1 = 0;
double[] adouble1 = new double[i1];
int i2;
for (i2 = 0; i2 < i1; ++i2) {
adouble1[i2] = Math.cos((double) i2 * 3.141592653589793D * 6.0D / (double) i1) * 2.0D;
double d2 = (double) i2;
if (i2 > i1 / 2) {
d2 = (double) (i1 - 1 - i2);
}
if (d2 < 4.0D) {
d2 = 4.0D - d2;
adouble1[i2] -= d2 * d2 * d2 * 10.0D;
}
}
for (i2 = 0; i2 < l; ++i2) {
for (int j2 = 0; j2 < j1; ++j2) {
double d3 = (this.f[l1] + 256.0D) / 512.0D;
if (d3 > 1.0D) {
d3 = 1.0D;
}
double d4 = 0.0D;
double d5 = this.g[l1] / 8000.0D;
if (d5 < 0.0D) {
d5 = -d5;
}
d5 = d5 * 3.0D - 3.0D;
if (d5 < 0.0D) {
d5 /= 2.0D;
if (d5 < -1.0D) {
d5 = -1.0D;
}
d5 /= 1.4D;
d5 /= 2.0D;
d3 = 0.0D;
} else {
if (d5 > 1.0D) {
d5 = 1.0D;
}
d5 /= 6.0D;
}
d3 += 0.5D;
d5 = d5 * (double) i1 / 16.0D;
++l1;
for (int k2 = 0; k2 < i1; ++k2) {
double d6 = 0.0D;
double d7 = adouble1[k2];
double d8 = this.d[k1] / 512.0D;
double d9 = this.e[k1] / 512.0D;
double d10 = (this.c[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 < d4) {
d11 = (d4 - (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 isChunkLoaded(int i, int j) {
return true;
}
public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) {
BlockSand.instaFall = true;
int k = i * 16;
int l = j * 16;
int i1;
int j1;
int k1;
int l1;
for (i1 = 0; i1 < 8; ++i1) {
j1 = k + this.h.nextInt(16) + 8;
k1 = this.h.nextInt(120) + 4;
l1 = l + this.h.nextInt(16) + 8;
(new WorldGenHellLava(Block.LAVA.id)).a(this.n, this.h, j1, k1, l1);
}
i1 = this.h.nextInt(this.h.nextInt(10) + 1) + 1;
int i2;
for (j1 = 0; j1 < i1; ++j1) {
k1 = k + this.h.nextInt(16) + 8;
l1 = this.h.nextInt(120) + 4;
i2 = l + this.h.nextInt(16) + 8;
(new WorldGenFire()).a(this.n, this.h, k1, l1, i2);
}
i1 = this.h.nextInt(this.h.nextInt(10) + 1);
for (j1 = 0; j1 < i1; ++j1) {
k1 = k + this.h.nextInt(16) + 8;
l1 = this.h.nextInt(120) + 4;
i2 = l + this.h.nextInt(16) + 8;
(new WorldGenLightStone2()).a(this.n, this.h, k1, l1, i2);
}
for (j1 = 0; j1 < 10; ++j1) {
k1 = k + this.h.nextInt(16) + 8;
l1 = this.h.nextInt(128);
i2 = l + this.h.nextInt(16) + 8;
(new WorldGenLightStone1()).a(this.n, this.h, k1, l1, i2);
}
if (this.h.nextInt(1) == 0) {
j1 = k + this.h.nextInt(16) + 8;
k1 = this.h.nextInt(128);
l1 = l + this.h.nextInt(16) + 8;
(new WorldGenFlowers(Block.BROWN_MUSHROOM.id)).a(this.n, this.h, j1, k1, l1);
}
if (this.h.nextInt(1) == 0) {
j1 = k + this.h.nextInt(16) + 8;
k1 = this.h.nextInt(128);
l1 = l + this.h.nextInt(16) + 8;
(new WorldGenFlowers(Block.RED_MUSHROOM.id)).a(this.n, this.h, j1, k1, l1);
}
BlockSand.instaFall = false;
}
public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) {
return true;
}
public boolean unloadChunks() {
return false;
}
public boolean canSave() {
return true;
}
}

Some files were not shown because too many files have changed in this diff Show More