summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/net/minecraft/server/TileEntityMobSpawner.java108
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java11
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftChest.java40
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java40
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java56
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java49
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java31
7 files changed, 335 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java
new file mode 100644
index 00000000..d185b661
--- /dev/null
+++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java
@@ -0,0 +1,108 @@
+package net.minecraft.server;
+
+import java.util.List;
+import java.util.Random;
+
+public class TileEntityMobSpawner extends TileEntity {
+
+ public int e;
+ public String h; // CraftBukkit -> public
+ public double f;
+ public double g;
+
+ public TileEntityMobSpawner() {
+ e = -1;
+ g = 0.0D;
+ h = "Pig";
+ e = 20;
+ }
+
+ public void a(String s) {
+ h = s;
+ }
+
+ public boolean a() {
+ return a.a((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D, 16D) != null;
+ }
+
+ public void f() {
+ g = f;
+ if (!a()) {
+ return;
+ }
+ double d = (float) b + a.l.nextFloat();
+ double d2 = (float) c + a.l.nextFloat();
+ double d4 = (float) this.d + a.l.nextFloat();
+
+ a.a("smoke", d, d2, d4, 0.0D, 0.0D, 0.0D);
+ a.a("flame", d, d2, d4, 0.0D, 0.0D, 0.0D);
+ for (f += 1000F / ((float) e + 200F); f > 360D;) {
+ f -= 360D;
+ g -= 360D;
+ }
+
+ if (e == -1) {
+ b();
+ }
+ if (e > 0) {
+ e--;
+ return;
+ }
+ byte byte0 = 4;
+
+ for (int i = 0; i < byte0; i++) {
+ EntityLiving entityliving = (EntityLiving) EntityList.a(h, a);
+
+ if (entityliving == null) {
+ return;
+ }
+ int j = a.a(((entityliving)).getClass(), AxisAlignedBB.b(b, c, this.d, b + 1, c + 1, this.d + 1).b(8D, 4D, 8D)).size();
+
+ if (j >= 6) {
+ b();
+ return;
+ }
+ if (entityliving == null) {
+ continue;
+ }
+ double d6 = (double) b + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
+ double d7 = (c + a.l.nextInt(3)) - 1;
+ double d8 = (double) this.d + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
+
+ entityliving.c(d6, d7, d8, a.l.nextFloat() * 360F, 0.0F);
+ if (!entityliving.b()) {
+ continue;
+ }
+ a.a(((Entity) (entityliving)));
+ for (int k = 0; k < 20; k++) {
+ double d1 = (double) b + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
+ double d3 = (double) c + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
+ double d5 = (double) this.d + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
+
+ a.a("smoke", d1, d3, d5, 0.0D, 0.0D, 0.0D);
+ a.a("flame", d1, d3, d5, 0.0D, 0.0D, 0.0D);
+ }
+
+ entityliving.R();
+ b();
+ }
+
+ super.f();
+ }
+
+ private void b() {
+ e = 200 + a.l.nextInt(600);
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
+ h = nbttagcompound.h("EntityId");
+ e = ((int) (nbttagcompound.c("Delay")));
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ super.b(nbttagcompound);
+ nbttagcompound.a("EntityId", h);
+ nbttagcompound.a("Delay", (short) e);
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 1ee32257..4c000896 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -288,6 +288,17 @@ public class CraftBlock implements Block {
case SIGN_POST:
case WALL_SIGN:
return new CraftSign(this);
+ case CHEST:
+ return new CraftChest(this);
+ case BURNING_FURNACE:
+ case FURNACE:
+ return new CraftFurnace(this);
+ case DISPENSER:
+ return new CraftDispenser(this);
+ case MOB_SPAWNER:
+ return new CraftMobSpawner(this);
+ case NOTE_BLOCK:
+ return new CraftNoteBlock(this);
default:
return new CraftBlockState(this);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
new file mode 100644
index 00000000..e16c4181
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
@@ -0,0 +1,40 @@
+package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.TileEntityChest;
+import org.bukkit.block.Block;
+import org.bukkit.block.Chest;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.inventory.Inventory;
+
+/**
+ * Represents a chest.
+ *
+ * @author sk89q
+ */
+public class CraftChest extends CraftBlockState implements Chest {
+ private final CraftWorld world;
+ private final TileEntityChest chest;
+
+ public CraftChest(final Block block) {
+ super(block);
+
+ world = (CraftWorld)block.getWorld();
+ chest = (TileEntityChest)world.getTileEntityAt(getX(), getY(), getZ());
+ }
+
+ public Inventory getInventory() {
+ return new CraftInventory(chest);
+ }
+
+ @Override
+ public boolean update(boolean force) {
+ boolean result = super.update(force);
+
+ if (result) {
+ chest.d();
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java b/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java
new file mode 100644
index 00000000..6c512140
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java
@@ -0,0 +1,40 @@
+package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.TileEntityDispenser;
+import org.bukkit.block.Block;
+import org.bukkit.block.Dispenser;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.inventory.Inventory;
+
+/**
+ * Represents a dispenser.
+ *
+ * @author sk89q
+ */
+public class CraftDispenser extends CraftBlockState implements Dispenser {
+ private final CraftWorld world;
+ private final TileEntityDispenser dispenser;
+
+ public CraftDispenser(final Block block) {
+ super(block);
+
+ world = (CraftWorld)block.getWorld();
+ dispenser = (TileEntityDispenser)world.getTileEntityAt(getX(), getY(), getZ());
+ }
+
+ public Inventory getInventory() {
+ return new CraftInventory(dispenser);
+ }
+
+ @Override
+ public boolean update(boolean force) {
+ boolean result = super.update(force);
+
+ if (result) {
+ dispenser.d();
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
new file mode 100644
index 00000000..fd6e927b
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
@@ -0,0 +1,56 @@
+package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.TileEntityFurnace;
+import org.bukkit.block.Block;
+import org.bukkit.block.Furnace;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.inventory.Inventory;
+
+/**
+ * Represents a furnace.
+ *
+ * @author sk89q
+ */
+public class CraftFurnace extends CraftBlockState implements Furnace {
+ private final CraftWorld world;
+ private final TileEntityFurnace furnace;
+
+ public CraftFurnace(final Block block) {
+ super(block);
+
+ world = (CraftWorld)block.getWorld();
+ furnace = (TileEntityFurnace)world.getTileEntityAt(getX(), getY(), getZ());
+ }
+
+ public Inventory getInventory() {
+ return new CraftInventory(furnace);
+ }
+
+ @Override
+ public boolean update(boolean force) {
+ boolean result = super.update(force);
+
+ if (result) {
+ furnace.d();
+ }
+
+ return result;
+ }
+
+ public short getBurnTime() {
+ return (short)furnace.e;
+ }
+
+ public void setBurnTime(short burnTime) {
+ furnace.e = burnTime;
+ }
+
+ public short getCookTime() {
+ return (short)furnace.g;
+ }
+
+ public void setCookTime(short cookTime) {
+ furnace.g = cookTime;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java
new file mode 100644
index 00000000..9cc283ec
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java
@@ -0,0 +1,49 @@
+package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.TileEntityMobSpawner;
+import org.bukkit.block.Block;
+import org.bukkit.block.MobSpawner;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.entity.MobType;
+
+public class CraftMobSpawner extends CraftBlockState implements MobSpawner {
+ private final CraftWorld world;
+ private final TileEntityMobSpawner spawner;
+
+ public CraftMobSpawner(final Block block) {
+ super(block);
+
+ world = (CraftWorld)block.getWorld();
+ spawner = (TileEntityMobSpawner)world.getTileEntityAt(getX(), getY(), getZ());
+ }
+
+ public MobType getMobType() {
+ return MobType.fromName(spawner.h);
+ }
+
+ public void setMobType(MobType mobType) {
+ spawner.h = mobType.getName();
+ }
+
+ public String getMobTypeId() {
+ return spawner.h;
+ }
+
+ public void setMobTypeId(String mobType) {
+ // Verify input
+ MobType type = MobType.fromName(mobType);
+ if (type == null) {
+ return;
+ }
+ spawner.h = type.getName();
+
+ }
+
+ public int getDelay() {
+ return spawner.e;
+ }
+
+ public void setDelay(int delay) {
+ spawner.e = delay;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java
new file mode 100644
index 00000000..9927730b
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java
@@ -0,0 +1,31 @@
+package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.TileEntityNote;
+import org.bukkit.block.Block;
+import org.bukkit.block.NoteBlock;
+import org.bukkit.craftbukkit.CraftWorld;
+
+/**
+ * Represents a note block.
+ *
+ * @author sk89q
+ */
+public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
+ private final CraftWorld world;
+ private final TileEntityNote note;
+
+ public CraftNoteBlock(final Block block) {
+ super(block);
+
+ world = (CraftWorld)block.getWorld();
+ note = (TileEntityNote)world.getTileEntityAt(getX(), getY(), getZ());
+ }
+
+ public byte getNote() {
+ return note.e;
+ }
+
+ public void setNote(byte n) {
+ note.e = n;
+ }
+}