Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
SPIGOT-2871: Improve BlockStates + BlockStateMeta
Dieser Commit ist enthalten in:
Ursprung
4d99feddd0
Commit
b6ad714e85
@ -1,13 +1,12 @@
|
|||||||
--- a/net/minecraft/server/ContainerEnchantTable.java
|
--- a/net/minecraft/server/ContainerEnchantTable.java
|
||||||
+++ b/net/minecraft/server/ContainerEnchantTable.java
|
+++ b/net/minecraft/server/ContainerEnchantTable.java
|
||||||
@@ -3,9 +3,22 @@
|
@@ -3,6 +3,17 @@
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import java.util.Map;
|
+import java.util.Map;
|
||||||
+import org.bukkit.Location;
|
+import org.bukkit.Location;
|
||||||
+
|
|
||||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
|
||||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
@ -18,21 +17,18 @@
|
|||||||
+
|
+
|
||||||
public class ContainerEnchantTable extends Container {
|
public class ContainerEnchantTable extends Container {
|
||||||
|
|
||||||
- public IInventory enchantSlots = new InventorySubcontainer("Enchant", true, 2) {
|
public IInventory enchantSlots = new InventorySubcontainer("Enchant", true, 2) {
|
||||||
+ // CraftBukkit - make type specific (changed from IInventory)
|
@@ -14,6 +25,13 @@
|
||||||
+ public InventorySubcontainer enchantSlots = new InventorySubcontainer("Enchant", true, 2) {
|
|
||||||
public int getMaxStackSize() {
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
@@ -14,6 +27,11 @@
|
|
||||||
super.update();
|
super.update();
|
||||||
ContainerEnchantTable.this.a((IInventory) this);
|
ContainerEnchantTable.this.a((IInventory) this);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
|
+ // CraftBukkit start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Location getLocation() {
|
+ public Location getLocation() {
|
||||||
+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
|
+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
|
||||||
+ }
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
};
|
};
|
||||||
public World world;
|
public World world;
|
||||||
private final BlockPosition position;
|
private final BlockPosition position;
|
||||||
|
11
nms-patches/ItemReed.patch
Normale Datei
11
nms-patches/ItemReed.patch
Normale Datei
@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/server/ItemReed.java
|
||||||
|
+++ b/net/minecraft/server/ItemReed.java
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
public class ItemReed extends Item {
|
||||||
|
|
||||||
|
- private final Block a;
|
||||||
|
+ public final Block a; // PAIL: private->public
|
||||||
|
|
||||||
|
public ItemReed(Block block) {
|
||||||
|
this.a = block;
|
@ -323,6 +323,16 @@ public class CraftBlock implements Block {
|
|||||||
case RED_SHULKER_BOX:
|
case RED_SHULKER_BOX:
|
||||||
case BLACK_SHULKER_BOX:
|
case BLACK_SHULKER_BOX:
|
||||||
return new CraftShulkerBox(this);
|
return new CraftShulkerBox(this);
|
||||||
|
case ENCHANTMENT_TABLE:
|
||||||
|
return new CraftEnchantingTable(this);
|
||||||
|
case ENDER_CHEST:
|
||||||
|
return new CraftEnderChest(this);
|
||||||
|
case DAYLIGHT_DETECTOR:
|
||||||
|
case DAYLIGHT_DETECTOR_INVERTED:
|
||||||
|
return new CraftDaylightDetector(this);
|
||||||
|
case REDSTONE_COMPARATOR_OFF:
|
||||||
|
case REDSTONE_COMPARATOR_ON:
|
||||||
|
return new CraftComparator(this);
|
||||||
default:
|
default:
|
||||||
return new CraftBlockState(this);
|
return new CraftBlockState(this);
|
||||||
}
|
}
|
||||||
|
33
src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java
Normale Datei
33
src/main/java/org/bukkit/craftbukkit/block/CraftComparator.java
Normale Datei
@ -0,0 +1,33 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
|
import net.minecraft.server.TileEntityComparator;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.EnderChest;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
|
public class CraftComparator extends CraftBlockState implements EnderChest {
|
||||||
|
|
||||||
|
private final CraftWorld world;
|
||||||
|
private final TileEntityComparator comparator;
|
||||||
|
|
||||||
|
public CraftComparator(final Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
world = (CraftWorld) block.getWorld();
|
||||||
|
comparator = (TileEntityComparator) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftComparator(final Material material, final TileEntityComparator te) {
|
||||||
|
super(material);
|
||||||
|
|
||||||
|
comparator = te;
|
||||||
|
world = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity() {
|
||||||
|
return comparator;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.server.ChestLock;
|
import net.minecraft.server.ChestLock;
|
||||||
import net.minecraft.server.TileEntity;
|
import net.minecraft.server.ITileInventory;
|
||||||
import net.minecraft.server.TileEntityContainer;
|
import net.minecraft.server.TileEntityContainer;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -10,7 +10,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
|||||||
|
|
||||||
public class CraftContainer extends CraftBlockState implements Lockable {
|
public class CraftContainer extends CraftBlockState implements Lockable {
|
||||||
|
|
||||||
private final TileEntityContainer container;
|
private final ITileInventory container;
|
||||||
|
|
||||||
public CraftContainer(Block block) {
|
public CraftContainer(Block block) {
|
||||||
super(block);
|
super(block);
|
||||||
@ -18,10 +18,10 @@ public class CraftContainer extends CraftBlockState implements Lockable {
|
|||||||
container = (TileEntityContainer) ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
|
container = (TileEntityContainer) ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftContainer(final Material material, TileEntity tileEntity) {
|
public CraftContainer(final Material material, ITileInventory tileEntity) {
|
||||||
super(material);
|
super(material);
|
||||||
|
|
||||||
container = (TileEntityContainer) tileEntity;
|
container = tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
|
import net.minecraft.server.TileEntityLightDetector;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.EnderChest;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
|
public class CraftDaylightDetector extends CraftBlockState implements EnderChest {
|
||||||
|
|
||||||
|
private final CraftWorld world;
|
||||||
|
private final TileEntityLightDetector detector;
|
||||||
|
|
||||||
|
public CraftDaylightDetector(final Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
world = (CraftWorld) block.getWorld();
|
||||||
|
detector = (TileEntityLightDetector) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftDaylightDetector(final Material material, final TileEntityLightDetector te) {
|
||||||
|
super(material);
|
||||||
|
|
||||||
|
detector = te;
|
||||||
|
world = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity() {
|
||||||
|
return detector;
|
||||||
|
}
|
||||||
|
}
|
43
src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java
Normale Datei
43
src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java
Normale Datei
@ -0,0 +1,43 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
|
import net.minecraft.server.TileEntityEnchantTable;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.block.EnchantingTable;
|
||||||
|
|
||||||
|
public class CraftEnchantingTable extends CraftBlockState implements EnchantingTable {
|
||||||
|
|
||||||
|
private final CraftWorld world;
|
||||||
|
private final TileEntityEnchantTable enchant;
|
||||||
|
|
||||||
|
public CraftEnchantingTable(final Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
world = (CraftWorld) block.getWorld();
|
||||||
|
enchant = (TileEntityEnchantTable) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftEnchantingTable(final Material material, final TileEntityEnchantTable te) {
|
||||||
|
super(material);
|
||||||
|
|
||||||
|
enchant = te;
|
||||||
|
world = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity() {
|
||||||
|
return enchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCustomName() {
|
||||||
|
return enchant.hasCustomName() ? enchant.getName() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCustomName(String name) {
|
||||||
|
enchant.a(name); // PAIL: setCustomName
|
||||||
|
}
|
||||||
|
}
|
33
src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
Normale Datei
33
src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
Normale Datei
@ -0,0 +1,33 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
|
import net.minecraft.server.TileEntityEnderChest;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.EnderChest;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
|
public class CraftEnderChest extends CraftBlockState implements EnderChest {
|
||||||
|
|
||||||
|
private final CraftWorld world;
|
||||||
|
private final TileEntityEnderChest chest;
|
||||||
|
|
||||||
|
public CraftEnderChest(final Block block) {
|
||||||
|
super(block);
|
||||||
|
|
||||||
|
world = (CraftWorld) block.getWorld();
|
||||||
|
chest = (TileEntityEnderChest) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftEnderChest(final Material material, final TileEntityEnderChest te) {
|
||||||
|
super(material);
|
||||||
|
|
||||||
|
chest = te;
|
||||||
|
world = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity() {
|
||||||
|
return chest;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.server.ItemStack;
|
import net.minecraft.server.ItemStack;
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
import net.minecraft.server.TileEntityFlowerPot;
|
import net.minecraft.server.TileEntityFlowerPot;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -26,6 +27,11 @@ public class CraftFlowerPot extends CraftBlockState implements FlowerPot {
|
|||||||
this.pot = pot;
|
this.pot = pot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity() {
|
||||||
|
return pot;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialData getContents() {
|
public MaterialData getContents() {
|
||||||
return (pot.d() == null) ? null : CraftMagicNumbers.getMaterial(pot.getItem()).getNewData((byte) pot.getData()); // PAIL: rename
|
return (pot.d() == null) ? null : CraftMagicNumbers.getMaterial(pot.getItem()).getNewData((byte) pot.getData()); // PAIL: rename
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.server.TileEntity;
|
|
||||||
import net.minecraft.server.TileEntityLootable;
|
import net.minecraft.server.TileEntityLootable;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Nameable;
|
import org.bukkit.Nameable;
|
||||||
@ -17,10 +16,10 @@ public class CraftLootable extends CraftContainer implements Nameable {
|
|||||||
te = (TileEntityLootable) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
|
te = (TileEntityLootable) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftLootable(Material material, TileEntity tileEntity) {
|
public CraftLootable(Material material, TileEntityLootable tileEntity) {
|
||||||
super(material, tileEntity);
|
super(material, tileEntity);
|
||||||
|
|
||||||
te = (TileEntityLootable) tileEntity;
|
te = tileEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.server.TileEntity;
|
||||||
import net.minecraft.server.TileEntityStructure;
|
import net.minecraft.server.TileEntityStructure;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -20,4 +21,9 @@ public class CraftStructureBlock extends CraftBlockState {
|
|||||||
|
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity() {
|
||||||
|
return structure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package org.bukkit.craftbukkit.inventory;
|
package org.bukkit.craftbukkit.inventory;
|
||||||
|
|
||||||
|
import net.minecraft.server.IInventory;
|
||||||
import org.bukkit.inventory.EnchantingInventory;
|
import org.bukkit.inventory.EnchantingInventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import net.minecraft.server.InventorySubcontainer;
|
|
||||||
|
|
||||||
public class CraftInventoryEnchanting extends CraftInventory implements EnchantingInventory {
|
public class CraftInventoryEnchanting extends CraftInventory implements EnchantingInventory {
|
||||||
public CraftInventoryEnchanting(InventorySubcontainer inventory) {
|
public CraftInventoryEnchanting(IInventory inventory) {
|
||||||
super(inventory);
|
super(inventory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +19,6 @@ public class CraftInventoryEnchanting extends CraftInventory implements Enchanti
|
|||||||
return getItem(0);
|
return getItem(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public InventorySubcontainer getInventory() {
|
|
||||||
return (InventorySubcontainer)inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSecondary(ItemStack item) {
|
public void setSecondary(ItemStack item) {
|
||||||
setItem(1, item);
|
setItem(1, item);
|
||||||
|
@ -130,6 +130,7 @@ public final class CraftItemFactory implements ItemFactory {
|
|||||||
case GREEN_SHULKER_BOX:
|
case GREEN_SHULKER_BOX:
|
||||||
case RED_SHULKER_BOX:
|
case RED_SHULKER_BOX:
|
||||||
case BLACK_SHULKER_BOX:
|
case BLACK_SHULKER_BOX:
|
||||||
|
case ENDER_CHEST:
|
||||||
return new CraftMetaBlockState(meta, material);
|
return new CraftMetaBlockState(meta, material);
|
||||||
default:
|
default:
|
||||||
return new CraftMetaItem(meta);
|
return new CraftMetaItem(meta);
|
||||||
|
@ -387,6 +387,7 @@ public final class CraftItemStack extends ItemStack {
|
|||||||
case GREEN_SHULKER_BOX:
|
case GREEN_SHULKER_BOX:
|
||||||
case RED_SHULKER_BOX:
|
case RED_SHULKER_BOX:
|
||||||
case BLACK_SHULKER_BOX:
|
case BLACK_SHULKER_BOX:
|
||||||
|
case ENDER_CHEST:
|
||||||
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
|
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
|
||||||
default:
|
default:
|
||||||
return new CraftMetaItem(item.getTag());
|
return new CraftMetaItem(item.getTag());
|
||||||
|
@ -12,12 +12,16 @@ import net.minecraft.server.TileEntityBeacon;
|
|||||||
import net.minecraft.server.TileEntityBrewingStand;
|
import net.minecraft.server.TileEntityBrewingStand;
|
||||||
import net.minecraft.server.TileEntityChest;
|
import net.minecraft.server.TileEntityChest;
|
||||||
import net.minecraft.server.TileEntityCommand;
|
import net.minecraft.server.TileEntityCommand;
|
||||||
|
import net.minecraft.server.TileEntityComparator;
|
||||||
import net.minecraft.server.TileEntityDispenser;
|
import net.minecraft.server.TileEntityDispenser;
|
||||||
import net.minecraft.server.TileEntityDropper;
|
import net.minecraft.server.TileEntityDropper;
|
||||||
|
import net.minecraft.server.TileEntityEnchantTable;
|
||||||
import net.minecraft.server.TileEntityEndGateway;
|
import net.minecraft.server.TileEntityEndGateway;
|
||||||
|
import net.minecraft.server.TileEntityEnderChest;
|
||||||
import net.minecraft.server.TileEntityFlowerPot;
|
import net.minecraft.server.TileEntityFlowerPot;
|
||||||
import net.minecraft.server.TileEntityFurnace;
|
import net.minecraft.server.TileEntityFurnace;
|
||||||
import net.minecraft.server.TileEntityHopper;
|
import net.minecraft.server.TileEntityHopper;
|
||||||
|
import net.minecraft.server.TileEntityLightDetector;
|
||||||
import net.minecraft.server.TileEntityMobSpawner;
|
import net.minecraft.server.TileEntityMobSpawner;
|
||||||
import net.minecraft.server.TileEntityNote;
|
import net.minecraft.server.TileEntityNote;
|
||||||
import net.minecraft.server.TileEntityShulkerBox;
|
import net.minecraft.server.TileEntityShulkerBox;
|
||||||
@ -34,10 +38,14 @@ import org.bukkit.craftbukkit.block.CraftBlockState;
|
|||||||
import org.bukkit.craftbukkit.block.CraftBrewingStand;
|
import org.bukkit.craftbukkit.block.CraftBrewingStand;
|
||||||
import org.bukkit.craftbukkit.block.CraftChest;
|
import org.bukkit.craftbukkit.block.CraftChest;
|
||||||
import org.bukkit.craftbukkit.block.CraftCommandBlock;
|
import org.bukkit.craftbukkit.block.CraftCommandBlock;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftComparator;
|
||||||
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftDaylightDetector;
|
||||||
import org.bukkit.craftbukkit.block.CraftDispenser;
|
import org.bukkit.craftbukkit.block.CraftDispenser;
|
||||||
import org.bukkit.craftbukkit.block.CraftDropper;
|
import org.bukkit.craftbukkit.block.CraftDropper;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftEnchantingTable;
|
||||||
import org.bukkit.craftbukkit.block.CraftEndGateway;
|
import org.bukkit.craftbukkit.block.CraftEndGateway;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftEnderChest;
|
||||||
import org.bukkit.craftbukkit.block.CraftFlowerPot;
|
import org.bukkit.craftbukkit.block.CraftFlowerPot;
|
||||||
import org.bukkit.craftbukkit.block.CraftFurnace;
|
import org.bukkit.craftbukkit.block.CraftFurnace;
|
||||||
import org.bukkit.craftbukkit.block.CraftHopper;
|
import org.bukkit.craftbukkit.block.CraftHopper;
|
||||||
@ -199,6 +207,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
case GREEN_SHULKER_BOX:
|
case GREEN_SHULKER_BOX:
|
||||||
case RED_SHULKER_BOX:
|
case RED_SHULKER_BOX:
|
||||||
case BLACK_SHULKER_BOX:
|
case BLACK_SHULKER_BOX:
|
||||||
|
case ENDER_CHEST:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -293,7 +302,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
te = new BlockJukeBox.TileEntityRecordPlayer();
|
te = new BlockJukeBox.TileEntityRecordPlayer();
|
||||||
}
|
}
|
||||||
return new CraftJukebox(material, (BlockJukeBox.TileEntityRecordPlayer) te);
|
return new CraftJukebox(material, (BlockJukeBox.TileEntityRecordPlayer) te);
|
||||||
case BREWING_STAND:
|
case BREWING_STAND_ITEM:
|
||||||
if (te == null) {
|
if (te == null) {
|
||||||
te = new TileEntityBrewingStand();
|
te = new TileEntityBrewingStand();
|
||||||
}
|
}
|
||||||
@ -353,6 +362,27 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
te = new TileEntityShulkerBox();
|
te = new TileEntityShulkerBox();
|
||||||
}
|
}
|
||||||
return new CraftShulkerBox(material, (TileEntityShulkerBox) te);
|
return new CraftShulkerBox(material, (TileEntityShulkerBox) te);
|
||||||
|
case ENCHANTMENT_TABLE:
|
||||||
|
if (te == null) {
|
||||||
|
te = new TileEntityEnchantTable();
|
||||||
|
}
|
||||||
|
return new CraftEnchantingTable(material, (TileEntityEnchantTable) te);
|
||||||
|
case ENDER_CHEST:
|
||||||
|
if (te == null){
|
||||||
|
te = new TileEntityEnderChest();
|
||||||
|
}
|
||||||
|
return new CraftEnderChest(material, (TileEntityEnderChest) te);
|
||||||
|
case DAYLIGHT_DETECTOR:
|
||||||
|
case DAYLIGHT_DETECTOR_INVERTED:
|
||||||
|
if (te == null){
|
||||||
|
te = new TileEntityLightDetector();
|
||||||
|
}
|
||||||
|
return new CraftDaylightDetector(material, (TileEntityLightDetector) te);
|
||||||
|
case REDSTONE_COMPARATOR:
|
||||||
|
if (te == null){
|
||||||
|
te = new TileEntityComparator();
|
||||||
|
}
|
||||||
|
return new CraftComparator(material, (TileEntityComparator) te);
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Missing blockState for " + material);
|
throw new IllegalStateException("Missing blockState for " + material);
|
||||||
}
|
}
|
||||||
@ -362,7 +392,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
public void setBlockState(BlockState blockState) {
|
public void setBlockState(BlockState blockState) {
|
||||||
Validate.notNull(blockState, "blockState must not be null");
|
Validate.notNull(blockState, "blockState must not be null");
|
||||||
TileEntity te = ((CraftBlockState) blockState).getTileEntity();
|
TileEntity te = ((CraftBlockState) blockState).getTileEntity();
|
||||||
Validate.notNull(te, "Invalid blockState");
|
Validate.notNull(te, "Invalid tile for " + blockState);
|
||||||
|
|
||||||
boolean valid;
|
boolean valid;
|
||||||
switch (material) {
|
switch (material) {
|
||||||
@ -400,7 +430,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
case JUKEBOX:
|
case JUKEBOX:
|
||||||
valid = te instanceof BlockJukeBox.TileEntityRecordPlayer;
|
valid = te instanceof BlockJukeBox.TileEntityRecordPlayer;
|
||||||
break;
|
break;
|
||||||
case BREWING_STAND:
|
case BREWING_STAND_ITEM:
|
||||||
valid = te instanceof TileEntityBrewingStand;
|
valid = te instanceof TileEntityBrewingStand;
|
||||||
break;
|
break;
|
||||||
case SKULL:
|
case SKULL:
|
||||||
@ -444,6 +474,19 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
case BLACK_SHULKER_BOX:
|
case BLACK_SHULKER_BOX:
|
||||||
valid = te instanceof TileEntityShulkerBox;
|
valid = te instanceof TileEntityShulkerBox;
|
||||||
break;
|
break;
|
||||||
|
case ENCHANTMENT_TABLE:
|
||||||
|
valid = te instanceof TileEntityEnchantTable;
|
||||||
|
break;
|
||||||
|
case ENDER_CHEST:
|
||||||
|
valid = te instanceof TileEntityEnderChest;
|
||||||
|
break;
|
||||||
|
case DAYLIGHT_DETECTOR:
|
||||||
|
case DAYLIGHT_DETECTOR_INVERTED:
|
||||||
|
valid = te instanceof TileEntityLightDetector;
|
||||||
|
break;
|
||||||
|
case REDSTONE_COMPARATOR:
|
||||||
|
valid = te instanceof TileEntityComparator;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
valid = false;
|
valid = false;
|
||||||
break;
|
break;
|
||||||
|
@ -5,6 +5,11 @@ import static org.hamcrest.Matchers.*;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.minecraft.server.Block;
|
||||||
|
import net.minecraft.server.ITileEntity;
|
||||||
|
import net.minecraft.server.Item;
|
||||||
|
import net.minecraft.server.ItemBlock;
|
||||||
|
import net.minecraft.server.ItemReed;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -21,6 +26,7 @@ import org.bukkit.craftbukkit.inventory.ItemStackTest.CraftWrapper;
|
|||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.BannerMeta;
|
import org.bukkit.inventory.meta.BannerMeta;
|
||||||
|
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.bukkit.inventory.meta.FireworkEffectMeta;
|
import org.bukkit.inventory.meta.FireworkEffectMeta;
|
||||||
@ -127,6 +133,38 @@ public class ItemMetaTest extends AbstractTestingBase {
|
|||||||
assertThat(bukkit, is((ItemStack) craft));
|
assertThat(bukkit, is((ItemStack) craft));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlockStateMeta() {
|
||||||
|
for (Item item : (Iterable<Item>) Item.REGISTRY) {
|
||||||
|
Block block = null;
|
||||||
|
|
||||||
|
if (item instanceof ItemBlock) {
|
||||||
|
block = ((ItemBlock) item).getBlock();
|
||||||
|
} else if (item instanceof ItemReed) {
|
||||||
|
block = ((ItemReed) item).a;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block != null) {
|
||||||
|
if (block instanceof ITileEntity) {
|
||||||
|
ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block));
|
||||||
|
|
||||||
|
// Command blocks aren't unit testable atm
|
||||||
|
if (stack.getType() == Material.AIR || stack.getType() == Material.COMMAND || stack.getType() == Material.COMMAND_CHAIN || stack.getType() == Material.COMMAND_REPEATING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemMeta meta = stack.getItemMeta();
|
||||||
|
assertTrue(stack + " has meta of type " + meta + " expected BlockStateMeta", meta instanceof BlockStateMeta);
|
||||||
|
|
||||||
|
BlockStateMeta blockState = (BlockStateMeta) meta;
|
||||||
|
assertNotNull(stack + " has null block state", blockState.getBlockState());
|
||||||
|
|
||||||
|
blockState.setBlockState(blockState.getBlockState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEachExtraData() {
|
public void testEachExtraData() {
|
||||||
final List<StackProvider> providers = Arrays.asList(
|
final List<StackProvider> providers = Arrays.asList(
|
||||||
@ -209,7 +247,7 @@ public class ItemMetaTest extends AbstractTestingBase {
|
|||||||
return cleanStack;
|
return cleanStack;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new StackProvider(Material.BANNER) {
|
new StackProvider(Material.BANNER) {
|
||||||
@Override ItemStack operate(ItemStack cleanStack) {
|
@Override ItemStack operate(ItemStack cleanStack) {
|
||||||
final BannerMeta meta = (BannerMeta) cleanStack.getItemMeta();
|
final BannerMeta meta = (BannerMeta) cleanStack.getItemMeta();
|
||||||
meta.setBaseColor(DyeColor.CYAN);
|
meta.setBaseColor(DyeColor.CYAN);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren