13
0
geforkt von Mirrors/Paper

Imported from mc-dev:

- TileEntity
- Container
- ContainerFurnace
- ContainerDispenser
- ContainerChest
- ContainerEnchantTableSubcontainer
- ContainerEnchantTableInventory
- ContainerBrewingStand
Dieser Commit ist enthalten in:
Celtic Minstrel 2012-02-25 23:56:31 -05:00 committet von EvilSeph
Ursprung d20091e64c
Commit 10e593649c
8 geänderte Dateien mit 856 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,306 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public abstract class Container {
public List d = new ArrayList();
public List e = new ArrayList();
public int windowId = 0;
private short a = 0;
protected List listeners = new ArrayList();
private Set b = new HashSet();
public Container() {}
protected void a(Slot slot) {
slot.c = this.e.size();
this.e.add(slot);
this.d.add(null);
}
public void a(ICrafting icrafting) {
if (this.listeners.contains(icrafting)) {
throw new IllegalArgumentException("Listener already listening");
} else {
this.listeners.add(icrafting);
icrafting.a(this, this.b());
this.a();
}
}
public List b() {
ArrayList arraylist = new ArrayList();
for (int i = 0; i < this.e.size(); ++i) {
arraylist.add(((Slot) this.e.get(i)).getItem());
}
return arraylist;
}
public void a() {
for (int i = 0; i < this.e.size(); ++i) {
ItemStack itemstack = ((Slot) this.e.get(i)).getItem();
ItemStack itemstack1 = (ItemStack) this.d.get(i);
if (!ItemStack.matches(itemstack1, itemstack)) {
itemstack1 = itemstack == null ? null : itemstack.cloneItemStack();
this.d.set(i, itemstack1);
for (int j = 0; j < this.listeners.size(); ++j) {
((ICrafting) this.listeners.get(j)).a(this, i, itemstack1);
}
}
}
}
public boolean a(EntityHuman entityhuman, int i) {
return false;
}
public Slot a(IInventory iinventory, int i) {
for (int j = 0; j < this.e.size(); ++j) {
Slot slot = (Slot) this.e.get(j);
if (slot.a(iinventory, i)) {
return slot;
}
}
return null;
}
public Slot b(int i) {
return (Slot) this.e.get(i);
}
public ItemStack a(int i) {
Slot slot = (Slot) this.e.get(i);
return slot != null ? slot.getItem() : null;
}
public ItemStack a(int i, int j, boolean flag, EntityHuman entityhuman) {
ItemStack itemstack = null;
if (j > 1) {
return null;
} else {
if (j == 0 || j == 1) {
PlayerInventory playerinventory = entityhuman.inventory;
if (i == -999) {
if (playerinventory.l() != null && i == -999) {
if (j == 0) {
entityhuman.b(playerinventory.l());
playerinventory.b((ItemStack) null);
}
if (j == 1) {
entityhuman.b(playerinventory.l().a(1));
if (playerinventory.l().count == 0) {
playerinventory.b((ItemStack) null);
}
}
}
} else if (flag) {
ItemStack itemstack1 = this.a(i);
if (itemstack1 != null) {
int k = itemstack1.id;
itemstack = itemstack1.cloneItemStack();
Slot slot = (Slot) this.e.get(i);
if (slot != null && slot.getItem() != null && slot.getItem().id == k) {
this.b(i, j, flag, entityhuman);
}
}
} else {
if (i < 0) {
return null;
}
Slot slot1 = (Slot) this.e.get(i);
if (slot1 != null) {
slot1.d();
ItemStack itemstack2 = slot1.getItem();
ItemStack itemstack3 = playerinventory.l();
if (itemstack2 != null) {
itemstack = itemstack2.cloneItemStack();
}
int l;
if (itemstack2 == null) {
if (itemstack3 != null && slot1.isAllowed(itemstack3)) {
l = j == 0 ? itemstack3.count : 1;
if (l > slot1.a()) {
l = slot1.a();
}
slot1.c(itemstack3.a(l));
if (itemstack3.count == 0) {
playerinventory.b((ItemStack) null);
}
}
} else if (itemstack3 == null) {
l = j == 0 ? itemstack2.count : (itemstack2.count + 1) / 2;
ItemStack itemstack4 = slot1.a(l);
playerinventory.b(itemstack4);
if (itemstack2.count == 0) {
slot1.c((ItemStack) null);
}
slot1.b(playerinventory.l());
} else if (slot1.isAllowed(itemstack3)) {
if (itemstack2.id == itemstack3.id && (!itemstack2.usesData() || itemstack2.getData() == itemstack3.getData()) && ItemStack.equals(itemstack2, itemstack3)) {
l = j == 0 ? itemstack3.count : 1;
if (l > slot1.a() - itemstack2.count) {
l = slot1.a() - itemstack2.count;
}
if (l > itemstack3.getMaxStackSize() - itemstack2.count) {
l = itemstack3.getMaxStackSize() - itemstack2.count;
}
itemstack3.a(l);
if (itemstack3.count == 0) {
playerinventory.b((ItemStack) null);
}
itemstack2.count += l;
} else if (itemstack3.count <= slot1.a()) {
slot1.c(itemstack3);
playerinventory.b(itemstack2);
}
} else if (itemstack2.id == itemstack3.id && itemstack3.getMaxStackSize() > 1 && (!itemstack2.usesData() || itemstack2.getData() == itemstack3.getData()) && ItemStack.equals(itemstack2, itemstack3)) {
l = itemstack2.count;
if (l > 0 && l + itemstack3.count <= itemstack3.getMaxStackSize()) {
itemstack3.count += l;
itemstack2.a(l);
if (itemstack2.count == 0) {
slot1.c((ItemStack) null);
}
slot1.b(playerinventory.l());
}
}
}
}
}
return itemstack;
}
}
protected void b(int i, int j, boolean flag, EntityHuman entityhuman) {
this.a(i, j, flag, entityhuman);
}
public void a(EntityHuman entityhuman) {
PlayerInventory playerinventory = entityhuman.inventory;
if (playerinventory.l() != null) {
entityhuman.b(playerinventory.l());
playerinventory.b((ItemStack) null);
}
}
public void a(IInventory iinventory) {
this.a();
}
public void a(int i, ItemStack itemstack) {
this.b(i).c(itemstack);
}
public boolean c(EntityHuman entityhuman) {
return !this.b.contains(entityhuman);
}
public void a(EntityHuman entityhuman, boolean flag) {
if (flag) {
this.b.remove(entityhuman);
} else {
this.b.add(entityhuman);
}
}
public abstract boolean b(EntityHuman entityhuman);
protected boolean a(ItemStack itemstack, int i, int j, boolean flag) {
boolean flag1 = false;
int k = i;
if (flag) {
k = j - 1;
}
Slot slot;
ItemStack itemstack1;
if (itemstack.isStackable()) {
while (itemstack.count > 0 && (!flag && k < j || flag && k >= i)) {
slot = (Slot) this.e.get(k);
itemstack1 = slot.getItem();
if (itemstack1 != null && itemstack1.id == itemstack.id && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1)) {
int l = itemstack1.count + itemstack.count;
if (l <= itemstack.getMaxStackSize()) {
itemstack.count = 0;
itemstack1.count = l;
slot.d();
flag1 = true;
} else if (itemstack1.count < itemstack.getMaxStackSize()) {
itemstack.count -= itemstack.getMaxStackSize() - itemstack1.count;
itemstack1.count = itemstack.getMaxStackSize();
slot.d();
flag1 = true;
}
}
if (flag) {
--k;
} else {
++k;
}
}
}
if (itemstack.count > 0) {
if (flag) {
k = j - 1;
} else {
k = i;
}
while (!flag && k < j || flag && k >= i) {
slot = (Slot) this.e.get(k);
itemstack1 = slot.getItem();
if (itemstack1 == null) {
slot.c(itemstack.cloneItemStack());
slot.d();
itemstack.count = 0;
flag1 = true;
break;
}
if (flag) {
--k;
} else {
++k;
}
}
}
return flag1;
}
}

Datei anzeigen

@ -0,0 +1,90 @@
package net.minecraft.server;
public class ContainerBrewingStand extends Container {
private TileEntityBrewingStand a;
private int b = 0;
public ContainerBrewingStand(PlayerInventory playerinventory, TileEntityBrewingStand tileentitybrewingstand) {
this.a = tileentitybrewingstand;
this.a(new SlotPotionBottle(this, playerinventory.d, tileentitybrewingstand, 0, 56, 46));
this.a(new SlotPotionBottle(this, playerinventory.d, tileentitybrewingstand, 1, 79, 53));
this.a(new SlotPotionBottle(this, playerinventory.d, tileentitybrewingstand, 2, 102, 46));
this.a(new SlotBrewing(this, tileentitybrewingstand, 3, 79, 17));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.a(new Slot(playerinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
}
public void a(ICrafting icrafting) {
super.a(icrafting);
icrafting.a(this, 0, this.a.h());
}
public void a() {
super.a();
for (int i = 0; i < this.listeners.size(); ++i) {
ICrafting icrafting = (ICrafting) this.listeners.get(i);
if (this.b != this.a.h()) {
icrafting.a(this, 0, this.a.h());
}
}
this.b = this.a.h();
}
public boolean b(EntityHuman entityhuman) {
return this.a.a(entityhuman);
}
public ItemStack a(int i) {
ItemStack itemstack = null;
Slot slot = (Slot) this.e.get(i);
if (slot != null && slot.c()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if ((i < 0 || i > 2) && i != 3) {
if (i >= 4 && i < 31) {
if (!this.a(itemstack1, 31, 40, false)) {
return null;
}
} else if (i >= 31 && i < 40) {
if (!this.a(itemstack1, 4, 31, false)) {
return null;
}
} else if (!this.a(itemstack1, 4, 40, false)) {
return null;
}
} else if (!this.a(itemstack1, 4, 40, true)) {
return null;
}
if (itemstack1.count == 0) {
slot.c((ItemStack) null);
} else {
slot.d();
}
if (itemstack1.count == itemstack.count) {
return null;
}
slot.b(itemstack1);
}
return itemstack;
}
}

Datei anzeigen

@ -0,0 +1,68 @@
package net.minecraft.server;
public class ContainerChest extends Container {
private IInventory a;
private int b;
public ContainerChest(IInventory iinventory, IInventory iinventory1) {
this.a = iinventory1;
this.b = iinventory1.getSize() / 9;
iinventory1.f();
int i = (this.b - 4) * 18;
int j;
int k;
for (j = 0; j < this.b; ++j) {
for (k = 0; k < 9; ++k) {
this.a(new Slot(iinventory1, k + j * 9, 8 + k * 18, 18 + j * 18));
}
}
for (j = 0; j < 3; ++j) {
for (k = 0; k < 9; ++k) {
this.a(new Slot(iinventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i));
}
}
for (j = 0; j < 9; ++j) {
this.a(new Slot(iinventory, j, 8 + j * 18, 161 + i));
}
}
public boolean b(EntityHuman entityhuman) {
return this.a.a(entityhuman);
}
public ItemStack a(int i) {
ItemStack itemstack = null;
Slot slot = (Slot) this.e.get(i);
if (slot != null && slot.c()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if (i < this.b * 9) {
if (!this.a(itemstack1, this.b * 9, this.e.size(), true)) {
return null;
}
} else if (!this.a(itemstack1, 0, this.b * 9, false)) {
return null;
}
if (itemstack1.count == 0) {
slot.c((ItemStack) null);
} else {
slot.d();
}
}
return itemstack;
}
public void a(EntityHuman entityhuman) {
super.a(entityhuman);
this.a.g();
}
}

Datei anzeigen

@ -0,0 +1,65 @@
package net.minecraft.server;
public class ContainerDispenser extends Container {
private TileEntityDispenser a;
public ContainerDispenser(IInventory iinventory, TileEntityDispenser tileentitydispenser) {
this.a = tileentitydispenser;
int i;
int j;
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
this.a(new Slot(tileentitydispenser, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
for (i = 0; i < 3; ++i) {
for (j = 0; j < 9; ++j) {
this.a(new Slot(iinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.a(new Slot(iinventory, i, 8 + i * 18, 142));
}
}
public boolean b(EntityHuman entityhuman) {
return this.a.a(entityhuman);
}
public ItemStack a(int i) {
ItemStack itemstack = null;
Slot slot = (Slot) this.e.get(i);
if (slot != null && slot.c()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if (i < 9) {
if (!this.a(itemstack1, 9, 45, true)) {
return null;
}
} else if (!this.a(itemstack1, 0, 9, false)) {
return null;
}
if (itemstack1.count == 0) {
slot.c((ItemStack) null);
} else {
slot.d();
}
if (itemstack1.count == itemstack.count) {
return null;
}
slot.b(itemstack1);
}
return itemstack;
}
}

Datei anzeigen

@ -0,0 +1,20 @@
package net.minecraft.server;
class ContainerEnchantTableInventory extends ContainerEnchantTableSubcontainer {
final ContainerEnchantTable a;
ContainerEnchantTableInventory(ContainerEnchantTable containerenchanttable, String s, int i) {
super(s, i);
this.a = containerenchanttable;
}
public int getMaxStackSize() {
return 1;
}
public void update() {
super.update();
this.a.a((IInventory) this);
}
}

Datei anzeigen

@ -0,0 +1,81 @@
package net.minecraft.server;
import java.util.List;
public class ContainerEnchantTableSubcontainer implements IInventory {
private String a;
private int b;
private ItemStack[] c;
private List d;
public ContainerEnchantTableSubcontainer(String s, int i) {
this.a = s;
this.b = i;
this.c = new ItemStack[i];
}
public ItemStack getItem(int i) {
return this.c[i];
}
public ItemStack splitStack(int i, int j) {
if (this.c[i] != null) {
ItemStack itemstack;
if (this.c[i].count <= j) {
itemstack = this.c[i];
this.c[i] = null;
this.update();
return itemstack;
} else {
itemstack = this.c[i].a(j);
if (this.c[i].count == 0) {
this.c[i] = null;
}
this.update();
return itemstack;
}
} else {
return null;
}
}
public void setItem(int i, ItemStack itemstack) {
this.c[i] = itemstack;
if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.getMaxStackSize();
}
this.update();
}
public int getSize() {
return this.b;
}
public String getName() {
return this.a;
}
public int getMaxStackSize() {
return 64;
}
public void update() {
if (this.d != null) {
for (int i = 0; i < this.d.size(); ++i) {
((IInventoryListener) this.d.get(i)).a(this);
}
}
}
public boolean a(EntityHuman entityhuman) {
return true;
}
public void f() {}
public void g() {}
}

Datei anzeigen

@ -0,0 +1,103 @@
package net.minecraft.server;
public class ContainerFurnace extends Container {
private TileEntityFurnace a;
private int b = 0;
private int c = 0;
private int h = 0;
public ContainerFurnace(PlayerInventory playerinventory, TileEntityFurnace tileentityfurnace) {
this.a = tileentityfurnace;
this.a(new Slot(tileentityfurnace, 0, 56, 17));
this.a(new Slot(tileentityfurnace, 1, 56, 53));
this.a(new SlotResult2(playerinventory.d, tileentityfurnace, 2, 116, 35));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.a(new Slot(playerinventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
}
public void a(ICrafting icrafting) {
super.a(icrafting);
icrafting.a(this, 0, this.a.cookTime);
icrafting.a(this, 1, this.a.burnTime);
icrafting.a(this, 2, this.a.ticksForCurrentFuel);
}
public void a() {
super.a();
for (int i = 0; i < this.listeners.size(); ++i) {
ICrafting icrafting = (ICrafting) this.listeners.get(i);
if (this.b != this.a.cookTime) {
icrafting.a(this, 0, this.a.cookTime);
}
if (this.c != this.a.burnTime) {
icrafting.a(this, 1, this.a.burnTime);
}
if (this.h != this.a.ticksForCurrentFuel) {
icrafting.a(this, 2, this.a.ticksForCurrentFuel);
}
}
this.b = this.a.cookTime;
this.c = this.a.burnTime;
this.h = this.a.ticksForCurrentFuel;
}
public boolean b(EntityHuman entityhuman) {
return this.a.a(entityhuman);
}
public ItemStack a(int i) {
ItemStack itemstack = null;
Slot slot = (Slot) this.e.get(i);
if (slot != null && slot.c()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if (i == 2) {
if (!this.a(itemstack1, 3, 39, true)) {
return null;
}
} else if (i >= 3 && i < 30) {
if (!this.a(itemstack1, 30, 39, false)) {
return null;
}
} else if (i >= 30 && i < 39) {
if (!this.a(itemstack1, 3, 30, false)) {
return null;
}
} else if (!this.a(itemstack1, 3, 39, false)) {
return null;
}
if (itemstack1.count == 0) {
slot.c((ItemStack) null);
} else {
slot.d();
}
if (itemstack1.count == itemstack.count) {
return null;
}
slot.b(itemstack1);
}
return itemstack;
}
}

Datei anzeigen

@ -0,0 +1,123 @@
package net.minecraft.server;
import java.util.HashMap;
import java.util.Map;
public class TileEntity {
private static Map a = new HashMap();
private static Map b = new HashMap();
public World world;
public int x;
public int y;
public int z;
protected boolean o;
public int p = -1;
public Block q;
public TileEntity() {}
private static void a(Class oclass, String s) {
if (b.containsKey(s)) {
throw new IllegalArgumentException("Duplicate id: " + s);
} else {
a.put(s, oclass);
b.put(oclass, s);
}
}
public void a(NBTTagCompound nbttagcompound) {
this.x = nbttagcompound.getInt("x");
this.y = nbttagcompound.getInt("y");
this.z = nbttagcompound.getInt("z");
}
public void b(NBTTagCompound nbttagcompound) {
String s = (String) b.get(this.getClass());
if (s == null) {
throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!");
} else {
nbttagcompound.setString("id", s);
nbttagcompound.setInt("x", this.x);
nbttagcompound.setInt("y", this.y);
nbttagcompound.setInt("z", this.z);
}
}
public void l_() {}
public static TileEntity c(NBTTagCompound nbttagcompound) {
TileEntity tileentity = null;
try {
Class oclass = (Class) a.get(nbttagcompound.getString("id"));
if (oclass != null) {
tileentity = (TileEntity) oclass.newInstance();
}
} catch (Exception exception) {
exception.printStackTrace();
}
if (tileentity != null) {
tileentity.a(nbttagcompound);
} else {
System.out.println("Skipping TileEntity with id " + nbttagcompound.getString("id"));
}
return tileentity;
}
public int j() {
if (this.p == -1) {
this.p = this.world.getData(this.x, this.y, this.z);
}
return this.p;
}
public void update() {
if (this.world != null) {
this.p = this.world.getData(this.x, this.y, this.z);
this.world.b(this.x, this.y, this.z, this);
}
}
public Packet k() {
return null;
}
public boolean l() {
return this.o;
}
public void i() {
this.o = true;
}
public void m() {
this.o = false;
}
public void b(int i, int j) {}
public void d() {
this.q = null;
this.p = -1;
}
static {
a(TileEntityFurnace.class, "Furnace");
a(TileEntityChest.class, "Chest");
a(TileEntityRecordPlayer.class, "RecordPlayer");
a(TileEntityDispenser.class, "Trap");
a(TileEntitySign.class, "Sign");
a(TileEntityMobSpawner.class, "MobSpawner");
a(TileEntityNote.class, "Music");
a(TileEntityPiston.class, "Piston");
a(TileEntityBrewingStand.class, "Cauldron");
a(TileEntityEnchantTable.class, "EnchantTable");
a(TileEntityEnderPortal.class, "Airportal");
}
}