13
0
geforkt von Mirrors/Paper

Make CraftMinecartHopper work as InventoryHolder. Adds BUKKIT-3796

Dieser Commit ist enthalten in:
Michael Limiero 2013-03-17 15:50:34 -04:00 committet von Travis Watkins
Ursprung 93fd33e218
Commit 2642fbdf7e
3 geänderte Dateien mit 19 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ import java.util.Set;
import net.minecraft.server.Container; import net.minecraft.server.Container;
import net.minecraft.server.EntityHuman; import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityMinecartHopper;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.Packet100OpenWindow; import net.minecraft.server.Packet100OpenWindow;
import net.minecraft.server.Packet101CloseWindow; import net.minecraft.server.Packet101CloseWindow;
@ -221,6 +222,8 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
case HOPPER: case HOPPER:
if (craftinv.getInventory() instanceof TileEntityHopper) { if (craftinv.getInventory() instanceof TileEntityHopper) {
getHandle().openHopper((TileEntityHopper) craftinv.getInventory()); getHandle().openHopper((TileEntityHopper) craftinv.getInventory());
} else if (craftinv.getInventory() instanceof EntityMinecartHopper) {
getHandle().openMinecartHopper((EntityMinecartHopper) craftinv.getInventory());
} }
break; break;
case CREATIVE: case CREATIVE:

Datei anzeigen

@ -3,20 +3,29 @@ package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityMinecartHopper; import net.minecraft.server.EntityMinecartHopper;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.minecart.HopperMinecart; import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.inventory.Inventory;
final class CraftMinecartHopper extends CraftMinecart implements HopperMinecart { final class CraftMinecartHopper extends CraftMinecart implements HopperMinecart {
private final CraftInventory inventory;
CraftMinecartHopper(CraftServer server, EntityMinecartHopper entity) { CraftMinecartHopper(CraftServer server, EntityMinecartHopper entity) {
super(server, entity); super(server, entity);
inventory = new CraftInventory(entity);
} }
@Override @Override
public String toString() { public String toString() {
return "CraftMinecartHopper"; return "CraftMinecartHopper{" + "inventory=" + inventory + '}';
} }
public EntityType getType() { public EntityType getType() {
return EntityType.MINECART_HOPPER; return EntityType.MINECART_HOPPER;
} }
public Inventory getInventory() {
return inventory;
}
} }

Datei anzeigen

@ -6,6 +6,7 @@ import java.util.ListIterator;
import net.minecraft.server.ContainerAnvilInventory; import net.minecraft.server.ContainerAnvilInventory;
import net.minecraft.server.ContainerEnchantTableInventory; import net.minecraft.server.ContainerEnchantTableInventory;
import net.minecraft.server.IHopper;
import net.minecraft.server.IInventory; import net.minecraft.server.IInventory;
import net.minecraft.server.InventoryCrafting; import net.minecraft.server.InventoryCrafting;
import net.minecraft.server.InventoryEnderChest; import net.minecraft.server.InventoryEnderChest;
@ -15,7 +16,6 @@ import net.minecraft.server.TileEntityBeacon;
import net.minecraft.server.TileEntityBrewingStand; import net.minecraft.server.TileEntityBrewingStand;
import net.minecraft.server.TileEntityDispenser; import net.minecraft.server.TileEntityDispenser;
import net.minecraft.server.TileEntityFurnace; import net.minecraft.server.TileEntityFurnace;
import net.minecraft.server.TileEntityHopper;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
@ -445,7 +445,7 @@ public class CraftInventory implements Inventory {
return InventoryType.BEACON; return InventoryType.BEACON;
} else if (inventory instanceof ContainerAnvilInventory) { } else if (inventory instanceof ContainerAnvilInventory) {
return InventoryType.ANVIL; return InventoryType.ANVIL;
} else if (inventory instanceof TileEntityHopper) { } else if (inventory instanceof IHopper) {
return InventoryType.HOPPER; return InventoryType.HOPPER;
} else { } else {
return InventoryType.CHEST; return InventoryType.CHEST;