Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 13:00:06 +01:00
Implement Hopper block state and inventory methods. Adds BUKKIT-3749
Dieser Commit ist enthalten in:
Ursprung
6f68fc4ba4
Commit
d802168cd5
@ -249,6 +249,8 @@ public class CraftBlock implements Block {
|
|||||||
return new CraftFurnace(this);
|
return new CraftFurnace(this);
|
||||||
case DISPENSER:
|
case DISPENSER:
|
||||||
return new CraftDispenser(this);
|
return new CraftDispenser(this);
|
||||||
|
case HOPPER:
|
||||||
|
return new CraftHopper(this);
|
||||||
case MOB_SPAWNER:
|
case MOB_SPAWNER:
|
||||||
return new CraftCreatureSpawner(this);
|
return new CraftCreatureSpawner(this);
|
||||||
case NOTE_BLOCK:
|
case NOTE_BLOCK:
|
||||||
|
35
src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
Normale Datei
35
src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
Normale Datei
@ -0,0 +1,35 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntityHopper;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Hopper;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
public class CraftHopper extends CraftBlockState implements Hopper {
|
||||||
|
private final CraftWorld world;
|
||||||
|
private final TileEntityHopper hopper;
|
||||||
|
|
||||||
|
public CraftHopper(final Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
world = (CraftWorld) block.getWorld();
|
||||||
|
hopper = (TileEntityHopper) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory getInventory() {
|
||||||
|
return new CraftInventory(hopper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(boolean force) {
|
||||||
|
boolean result = super.update(force);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
hopper.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import net.minecraft.server.Packet101CloseWindow;
|
|||||||
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.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -217,6 +218,11 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||||||
case ENCHANTING:
|
case ENCHANTING:
|
||||||
openCustomInventory(inventory, player, 4);
|
openCustomInventory(inventory, player, 4);
|
||||||
break;
|
break;
|
||||||
|
case HOPPER:
|
||||||
|
if (craftinv.getInventory() instanceof TileEntityHopper) {
|
||||||
|
getHandle().openHopper((TileEntityHopper)craftinv.getInventory());
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CREATIVE:
|
case CREATIVE:
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
throw new IllegalArgumentException("Can't open a " + type + " inventory!");
|
throw new IllegalArgumentException("Can't open a " + type + " inventory!");
|
||||||
|
@ -15,6 +15,7 @@ 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;
|
||||||
@ -444,6 +445,8 @@ 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) {
|
||||||
|
return InventoryType.HOPPER;
|
||||||
} else {
|
} else {
|
||||||
return InventoryType.CHEST;
|
return InventoryType.CHEST;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren