mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 17:21:37 +01:00
#877: Improve and simplify CraftBlockState
By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
65625f410c
commit
f27c8f74f8
@ -21,7 +21,7 @@
|
|||||||
+ // CraftBukkit start - special case for handling block placement with water lilies and snow buckets
|
+ // CraftBukkit start - special case for handling block placement with water lilies and snow buckets
|
||||||
+ org.bukkit.block.BlockState blockstate = null;
|
+ org.bukkit.block.BlockState blockstate = null;
|
||||||
+ if (this instanceof ItemWaterLily || this instanceof SolidBucketItem) {
|
+ if (this instanceof ItemWaterLily || this instanceof SolidBucketItem) {
|
||||||
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(blockactioncontext1.getWorld(), blockactioncontext1.getClickPosition());
|
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockactioncontext1.getWorld(), blockactioncontext1.getClickPosition());
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
--- a/net/minecraft/world/level/block/BlockConcretePowder.java
|
--- a/net/minecraft/world/level/block/BlockConcretePowder.java
|
||||||
+++ b/net/minecraft/world/level/block/BlockConcretePowder.java
|
+++ b/net/minecraft/world/level/block/BlockConcretePowder.java
|
||||||
@@ -13,6 +13,11 @@
|
@@ -13,6 +13,12 @@
|
||||||
import net.minecraft.world.level.block.state.BlockBase;
|
import net.minecraft.world.level.block.state.BlockBase;
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
|
+import org.bukkit.craftbukkit.block.CraftBlockStates;
|
||||||
+import org.bukkit.event.block.BlockFormEvent;
|
+import org.bukkit.event.block.BlockFormEvent;
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public class BlockConcretePowder extends BlockFalling {
|
public class BlockConcretePowder extends BlockFalling {
|
||||||
|
|
||||||
private final IBlockData concrete;
|
private final IBlockData concrete;
|
||||||
@@ -25,7 +30,7 @@
|
@@ -25,7 +31,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
|
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
|
||||||
if (canHarden(world, blockposition, iblockdata1)) {
|
if (canHarden(world, blockposition, iblockdata1)) {
|
||||||
@ -21,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,7 +41,24 @@
|
@@ -36,7 +42,24 @@
|
||||||
BlockPosition blockposition = blockactioncontext.getClickPosition();
|
BlockPosition blockposition = blockactioncontext.getClickPosition();
|
||||||
IBlockData iblockdata = world.getType(blockposition);
|
IBlockData iblockdata = world.getType(blockposition);
|
||||||
|
|
||||||
@ -32,7 +33,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ // TODO: An event factory call for methods like this
|
+ // TODO: An event factory call for methods like this
|
||||||
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition);
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
|
||||||
+ blockState.setData(this.concrete);
|
+ blockState.setData(this.concrete);
|
||||||
+
|
+
|
||||||
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
||||||
@ -47,7 +48,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
|
private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
|
||||||
@@ -72,7 +94,25 @@
|
@@ -72,7 +95,25 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
||||||
@ -58,7 +59,7 @@
|
|||||||
+ if (!(generatoraccess instanceof World)) {
|
+ if (!(generatoraccess instanceof World)) {
|
||||||
+ return this.concrete;
|
+ return this.concrete;
|
||||||
+ }
|
+ }
|
||||||
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition);
|
||||||
+ blockState.setData(this.concrete);
|
+ blockState.setData(this.concrete);
|
||||||
+
|
+
|
||||||
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
--- a/net/minecraft/world/level/block/BlockFire.java
|
--- a/net/minecraft/world/level/block/BlockFire.java
|
||||||
+++ b/net/minecraft/world/level/block/BlockFire.java
|
+++ b/net/minecraft/world/level/block/BlockFire.java
|
||||||
@@ -28,6 +28,13 @@
|
@@ -28,6 +28,14 @@
|
||||||
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
|
+import org.bukkit.craftbukkit.block.CraftBlockStates;
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
+import org.bukkit.event.block.BlockBurnEvent;
|
+import org.bukkit.event.block.BlockBurnEvent;
|
||||||
+import org.bukkit.event.block.BlockFadeEvent;
|
+import org.bukkit.event.block.BlockFadeEvent;
|
||||||
@ -14,7 +15,7 @@
|
|||||||
public class BlockFire extends BlockFireAbstract {
|
public class BlockFire extends BlockFireAbstract {
|
||||||
|
|
||||||
public static final int MAX_AGE = 15;
|
public static final int MAX_AGE = 15;
|
||||||
@@ -93,7 +100,24 @@
|
@@ -93,7 +101,24 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
||||||
@ -25,7 +26,7 @@
|
|||||||
+ if (!(generatoraccess instanceof World)) {
|
+ if (!(generatoraccess instanceof World)) {
|
||||||
+ return Blocks.AIR.getBlockData();
|
+ return Blocks.AIR.getBlockData();
|
||||||
+ }
|
+ }
|
||||||
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
|
+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition);
|
||||||
+ blockState.setData(Blocks.AIR.getBlockData());
|
+ blockState.setData(Blocks.AIR.getBlockData());
|
||||||
+
|
+
|
||||||
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
||||||
@ -40,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,7 +166,7 @@
|
@@ -142,7 +167,7 @@
|
||||||
worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random));
|
worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random));
|
||||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
|
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
|
||||||
if (!iblockdata.canPlace(worldserver, blockposition)) {
|
if (!iblockdata.canPlace(worldserver, blockposition)) {
|
||||||
@ -49,7 +50,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
IBlockData iblockdata1 = worldserver.getType(blockposition.down());
|
IBlockData iblockdata1 = worldserver.getType(blockposition.down());
|
||||||
@@ -150,7 +174,7 @@
|
@@ -150,7 +175,7 @@
|
||||||
int i = (Integer) iblockdata.get(BlockFire.AGE);
|
int i = (Integer) iblockdata.get(BlockFire.AGE);
|
||||||
|
|
||||||
if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
|
if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
|
||||||
@ -58,7 +59,7 @@
|
|||||||
} else {
|
} else {
|
||||||
int j = Math.min(15, i + random.nextInt(3) / 2);
|
int j = Math.min(15, i + random.nextInt(3) / 2);
|
||||||
|
|
||||||
@@ -164,14 +188,14 @@
|
@@ -164,14 +189,14 @@
|
||||||
BlockPosition blockposition1 = blockposition.down();
|
BlockPosition blockposition1 = blockposition.down();
|
||||||
|
|
||||||
if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) {
|
if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) {
|
||||||
@ -75,7 +76,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,12 +203,14 @@
|
@@ -179,12 +204,14 @@
|
||||||
boolean flag1 = worldserver.u(blockposition);
|
boolean flag1 = worldserver.u(blockposition);
|
||||||
int k = flag1 ? -50 : 0;
|
int k = flag1 ? -50 : 0;
|
||||||
|
|
||||||
@ -96,7 +97,7 @@
|
|||||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
||||||
|
|
||||||
for (int l = -1; l <= 1; ++l) {
|
for (int l = -1; l <= 1; ++l) {
|
||||||
@@ -210,7 +236,15 @@
|
@@ -210,7 +237,15 @@
|
||||||
if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) {
|
if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) {
|
||||||
int j2 = Math.min(15, i + random.nextInt(5) / 4);
|
int j2 = Math.min(15, i + random.nextInt(5) / 4);
|
||||||
|
|
||||||
@ -113,7 +114,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,12 +268,24 @@
|
@@ -234,12 +269,24 @@
|
||||||
return iblockdata.b(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.get(BlockProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(iblockdata.getBlock());
|
return iblockdata.b(BlockProperties.WATERLOGGED) && (Boolean) iblockdata.get(BlockProperties.WATERLOGGED) ? 0 : this.flameOdds.getInt(iblockdata.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||||
+++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
+++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||||
@@ -17,6 +17,11 @@
|
@@ -17,6 +17,12 @@
|
||||||
import net.minecraft.world.level.material.FluidType;
|
import net.minecraft.world.level.material.FluidType;
|
||||||
import net.minecraft.world.level.material.FluidTypes;
|
import net.minecraft.world.level.material.FluidTypes;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
|
+import org.bukkit.craftbukkit.block.CraftBlockStates;
|
||||||
+import org.bukkit.event.block.CauldronLevelChangeEvent;
|
+import org.bukkit.event.block.CauldronLevelChangeEvent;
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public class LayeredCauldronBlock extends AbstractCauldronBlock {
|
public class LayeredCauldronBlock extends AbstractCauldronBlock {
|
||||||
|
|
||||||
public static final int MIN_FILL_LEVEL = 1;
|
public static final int MIN_FILL_LEVEL = 1;
|
||||||
@@ -56,10 +61,14 @@
|
@@ -56,10 +62,14 @@
|
||||||
@Override
|
@Override
|
||||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||||
if (!world.isClientSide && entity.isBurning() && this.a(iblockdata, blockposition, entity)) {
|
if (!world.isClientSide && entity.isBurning() && this.a(iblockdata, blockposition, entity)) {
|
||||||
@ -29,7 +30,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -69,15 +78,38 @@
|
@@ -69,15 +79,38 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void e(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
public static void e(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||||
@ -46,7 +47,7 @@
|
|||||||
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public static boolean changeLevel(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
|
+ public static boolean changeLevel(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
|
||||||
+ CraftBlockState newState = CraftBlockState.getBlockState(world, blockposition);
|
+ CraftBlockState newState = CraftBlockStates.getBlockState(world, blockposition);
|
||||||
+ newState.setData(newBlock);
|
+ newState.setData(newBlock);
|
||||||
+
|
+
|
||||||
+ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
|
+ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
|
||||||
@ -70,7 +71,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +126,11 @@
|
@@ -94,7 +127,11 @@
|
||||||
@Override
|
@Override
|
||||||
protected void a(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) {
|
protected void a(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) {
|
||||||
if (!this.c(iblockdata)) {
|
if (!this.c(iblockdata)) {
|
||||||
|
@ -9,9 +9,8 @@ import net.minecraft.world.item.EnumColor;
|
|||||||
import net.minecraft.world.level.block.BlockBannerAbstract;
|
import net.minecraft.world.level.block.BlockBannerAbstract;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBanner;
|
import net.minecraft.world.level.block.entity.TileEntityBanner;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Banner;
|
import org.bukkit.block.Banner;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.banner.Pattern;
|
import org.bukkit.block.banner.Pattern;
|
||||||
import org.bukkit.block.banner.PatternType;
|
import org.bukkit.block.banner.PatternType;
|
||||||
|
|
||||||
@ -20,12 +19,8 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
|
|||||||
private DyeColor base;
|
private DyeColor base;
|
||||||
private List<Pattern> patterns;
|
private List<Pattern> patterns;
|
||||||
|
|
||||||
public CraftBanner(final Block block) {
|
public CraftBanner(World world, TileEntityBanner tileEntity) {
|
||||||
super(block, TileEntityBanner.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBanner(final Material material, final TileEntityBanner te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,20 +4,15 @@ import net.minecraft.sounds.SoundEffects;
|
|||||||
import net.minecraft.world.level.block.BlockBarrel;
|
import net.minecraft.world.level.block.BlockBarrel;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBarrel;
|
import net.minecraft.world.level.block.entity.TileEntityBarrel;
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Barrel;
|
import org.bukkit.block.Barrel;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barrel {
|
public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barrel {
|
||||||
|
|
||||||
public CraftBarrel(Block block) {
|
public CraftBarrel(World world, TileEntityBarrel tileEntity) {
|
||||||
super(block, TileEntityBarrel.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBarrel(Material material, TileEntityBarrel te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,9 +8,8 @@ import net.minecraft.world.effect.MobEffectList;
|
|||||||
import net.minecraft.world.entity.player.EntityHuman;
|
import net.minecraft.world.entity.player.EntityHuman;
|
||||||
import net.minecraft.world.level.block.entity.TileEntity;
|
import net.minecraft.world.level.block.entity.TileEntity;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBeacon;
|
import net.minecraft.world.level.block.entity.TileEntityBeacon;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Beacon;
|
import org.bukkit.block.Beacon;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@ -18,12 +17,8 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> implements Beacon {
|
public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> implements Beacon {
|
||||||
|
|
||||||
public CraftBeacon(final Block block) {
|
public CraftBeacon(World world, TileEntityBeacon tileEntity) {
|
||||||
super(block, TileEntityBeacon.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBeacon(final Material material, final TileEntityBeacon te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,18 +2,13 @@ package org.bukkit.craftbukkit.block;
|
|||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBed;
|
import net.minecraft.world.level.block.entity.TileEntityBed;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Bed;
|
import org.bukkit.block.Bed;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Bed {
|
public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Bed {
|
||||||
|
|
||||||
public CraftBed(Block block) {
|
public CraftBed(World world, TileEntityBed tileEntity) {
|
||||||
super(block, TileEntityBed.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBed(Material material, TileEntityBed te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,20 +8,15 @@ import net.minecraft.world.entity.Entity;
|
|||||||
import net.minecraft.world.level.block.entity.TileEntityBeehive;
|
import net.minecraft.world.level.block.entity.TileEntityBeehive;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBeehive.ReleaseStatus;
|
import net.minecraft.world.level.block.entity.TileEntityBeehive.ReleaseStatus;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Beehive;
|
import org.bukkit.block.Beehive;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftBee;
|
import org.bukkit.craftbukkit.entity.CraftBee;
|
||||||
import org.bukkit.entity.Bee;
|
import org.bukkit.entity.Bee;
|
||||||
|
|
||||||
public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> implements Beehive {
|
public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> implements Beehive {
|
||||||
|
|
||||||
public CraftBeehive(final Block block) {
|
public CraftBeehive(World world, TileEntityBeehive tileEntity) {
|
||||||
super(block, TileEntityBeehive.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBeehive(final Material material, final TileEntityBeehive te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBell;
|
import net.minecraft.world.level.block.entity.TileEntityBell;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Bell;
|
import org.bukkit.block.Bell;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
public class CraftBell extends CraftBlockEntityState<TileEntityBell> implements Bell {
|
public class CraftBell extends CraftBlockEntityState<TileEntityBell> implements Bell {
|
||||||
|
|
||||||
public CraftBell(Block block) {
|
public CraftBell(World world, TileEntityBell tileEntity) {
|
||||||
super(block, TileEntityBell.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBell(Material material, TileEntityBell te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
|
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlastFurnace;
|
import org.bukkit.block.BlastFurnace;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
public class CraftBlastFurnace extends CraftFurnace<TileEntityBlastFurnace> implements BlastFurnace {
|
public class CraftBlastFurnace extends CraftFurnace<TileEntityBlastFurnace> implements BlastFurnace {
|
||||||
|
|
||||||
public CraftBlastFurnace(Block block) {
|
public CraftBlastFurnace(World world, TileEntityBlastFurnace tileEntity) {
|
||||||
super(block, TileEntityBlastFurnace.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBlastFurnace(Material material, TileEntityBlastFurnace te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import net.minecraft.world.level.RayTrace;
|
|||||||
import net.minecraft.world.level.biome.BiomeBase;
|
import net.minecraft.world.level.biome.BiomeBase;
|
||||||
import net.minecraft.world.level.block.BlockRedstoneWire;
|
import net.minecraft.world.level.block.BlockRedstoneWire;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.TileEntity;
|
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
import net.minecraft.world.phys.AxisAlignedBB;
|
import net.minecraft.world.phys.AxisAlignedBB;
|
||||||
import net.minecraft.world.phys.MovingObjectPosition;
|
import net.minecraft.world.phys.MovingObjectPosition;
|
||||||
@ -318,174 +317,7 @@ public class CraftBlock implements Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getState() {
|
public BlockState getState() {
|
||||||
Material material = getType();
|
return CraftBlockStates.getBlockState(this);
|
||||||
|
|
||||||
switch (material) {
|
|
||||||
case ACACIA_SIGN:
|
|
||||||
case ACACIA_WALL_SIGN:
|
|
||||||
case BIRCH_SIGN:
|
|
||||||
case BIRCH_WALL_SIGN:
|
|
||||||
case CRIMSON_SIGN:
|
|
||||||
case CRIMSON_WALL_SIGN:
|
|
||||||
case DARK_OAK_SIGN:
|
|
||||||
case DARK_OAK_WALL_SIGN:
|
|
||||||
case JUNGLE_SIGN:
|
|
||||||
case JUNGLE_WALL_SIGN:
|
|
||||||
case OAK_SIGN:
|
|
||||||
case OAK_WALL_SIGN:
|
|
||||||
case SPRUCE_SIGN:
|
|
||||||
case SPRUCE_WALL_SIGN:
|
|
||||||
case WARPED_SIGN:
|
|
||||||
case WARPED_WALL_SIGN:
|
|
||||||
return new CraftSign(this);
|
|
||||||
case CHEST:
|
|
||||||
case TRAPPED_CHEST:
|
|
||||||
return new CraftChest(this);
|
|
||||||
case FURNACE:
|
|
||||||
return new CraftFurnaceFurnace(this);
|
|
||||||
case DISPENSER:
|
|
||||||
return new CraftDispenser(this);
|
|
||||||
case DROPPER:
|
|
||||||
return new CraftDropper(this);
|
|
||||||
case END_GATEWAY:
|
|
||||||
return new CraftEndGateway(this);
|
|
||||||
case HOPPER:
|
|
||||||
return new CraftHopper(this);
|
|
||||||
case SPAWNER:
|
|
||||||
return new CraftCreatureSpawner(this);
|
|
||||||
case JUKEBOX:
|
|
||||||
return new CraftJukebox(this);
|
|
||||||
case BREWING_STAND:
|
|
||||||
return new CraftBrewingStand(this);
|
|
||||||
case CREEPER_HEAD:
|
|
||||||
case CREEPER_WALL_HEAD:
|
|
||||||
case DRAGON_HEAD:
|
|
||||||
case DRAGON_WALL_HEAD:
|
|
||||||
case PLAYER_HEAD:
|
|
||||||
case PLAYER_WALL_HEAD:
|
|
||||||
case SKELETON_SKULL:
|
|
||||||
case SKELETON_WALL_SKULL:
|
|
||||||
case WITHER_SKELETON_SKULL:
|
|
||||||
case WITHER_SKELETON_WALL_SKULL:
|
|
||||||
case ZOMBIE_HEAD:
|
|
||||||
case ZOMBIE_WALL_HEAD:
|
|
||||||
return new CraftSkull(this);
|
|
||||||
case COMMAND_BLOCK:
|
|
||||||
case CHAIN_COMMAND_BLOCK:
|
|
||||||
case REPEATING_COMMAND_BLOCK:
|
|
||||||
return new CraftCommandBlock(this);
|
|
||||||
case BEACON:
|
|
||||||
return new CraftBeacon(this);
|
|
||||||
case BLACK_BANNER:
|
|
||||||
case BLACK_WALL_BANNER:
|
|
||||||
case BLUE_BANNER:
|
|
||||||
case BLUE_WALL_BANNER:
|
|
||||||
case BROWN_BANNER:
|
|
||||||
case BROWN_WALL_BANNER:
|
|
||||||
case CYAN_BANNER:
|
|
||||||
case CYAN_WALL_BANNER:
|
|
||||||
case GRAY_BANNER:
|
|
||||||
case GRAY_WALL_BANNER:
|
|
||||||
case GREEN_BANNER:
|
|
||||||
case GREEN_WALL_BANNER:
|
|
||||||
case LIGHT_BLUE_BANNER:
|
|
||||||
case LIGHT_BLUE_WALL_BANNER:
|
|
||||||
case LIGHT_GRAY_BANNER:
|
|
||||||
case LIGHT_GRAY_WALL_BANNER:
|
|
||||||
case LIME_BANNER:
|
|
||||||
case LIME_WALL_BANNER:
|
|
||||||
case MAGENTA_BANNER:
|
|
||||||
case MAGENTA_WALL_BANNER:
|
|
||||||
case ORANGE_BANNER:
|
|
||||||
case ORANGE_WALL_BANNER:
|
|
||||||
case PINK_BANNER:
|
|
||||||
case PINK_WALL_BANNER:
|
|
||||||
case PURPLE_BANNER:
|
|
||||||
case PURPLE_WALL_BANNER:
|
|
||||||
case RED_BANNER:
|
|
||||||
case RED_WALL_BANNER:
|
|
||||||
case WHITE_BANNER:
|
|
||||||
case WHITE_WALL_BANNER:
|
|
||||||
case YELLOW_BANNER:
|
|
||||||
case YELLOW_WALL_BANNER:
|
|
||||||
return new CraftBanner(this);
|
|
||||||
case STRUCTURE_BLOCK:
|
|
||||||
return new CraftStructureBlock(this);
|
|
||||||
case SHULKER_BOX:
|
|
||||||
case WHITE_SHULKER_BOX:
|
|
||||||
case ORANGE_SHULKER_BOX:
|
|
||||||
case MAGENTA_SHULKER_BOX:
|
|
||||||
case LIGHT_BLUE_SHULKER_BOX:
|
|
||||||
case YELLOW_SHULKER_BOX:
|
|
||||||
case LIME_SHULKER_BOX:
|
|
||||||
case PINK_SHULKER_BOX:
|
|
||||||
case GRAY_SHULKER_BOX:
|
|
||||||
case LIGHT_GRAY_SHULKER_BOX:
|
|
||||||
case CYAN_SHULKER_BOX:
|
|
||||||
case PURPLE_SHULKER_BOX:
|
|
||||||
case BLUE_SHULKER_BOX:
|
|
||||||
case BROWN_SHULKER_BOX:
|
|
||||||
case GREEN_SHULKER_BOX:
|
|
||||||
case RED_SHULKER_BOX:
|
|
||||||
case BLACK_SHULKER_BOX:
|
|
||||||
return new CraftShulkerBox(this);
|
|
||||||
case ENCHANTING_TABLE:
|
|
||||||
return new CraftEnchantingTable(this);
|
|
||||||
case ENDER_CHEST:
|
|
||||||
return new CraftEnderChest(this);
|
|
||||||
case DAYLIGHT_DETECTOR:
|
|
||||||
return new CraftDaylightDetector(this);
|
|
||||||
case COMPARATOR:
|
|
||||||
return new CraftComparator(this);
|
|
||||||
case BLACK_BED:
|
|
||||||
case BLUE_BED:
|
|
||||||
case BROWN_BED:
|
|
||||||
case CYAN_BED:
|
|
||||||
case GRAY_BED:
|
|
||||||
case GREEN_BED:
|
|
||||||
case LIGHT_BLUE_BED:
|
|
||||||
case LIGHT_GRAY_BED:
|
|
||||||
case LIME_BED:
|
|
||||||
case MAGENTA_BED:
|
|
||||||
case ORANGE_BED:
|
|
||||||
case PINK_BED:
|
|
||||||
case PURPLE_BED:
|
|
||||||
case RED_BED:
|
|
||||||
case WHITE_BED:
|
|
||||||
case YELLOW_BED:
|
|
||||||
return new CraftBed(this);
|
|
||||||
case CONDUIT:
|
|
||||||
return new CraftConduit(this);
|
|
||||||
case BARREL:
|
|
||||||
return new CraftBarrel(this);
|
|
||||||
case BELL:
|
|
||||||
return new CraftBell(this);
|
|
||||||
case BLAST_FURNACE:
|
|
||||||
return new CraftBlastFurnace(this);
|
|
||||||
case CAMPFIRE:
|
|
||||||
case SOUL_CAMPFIRE:
|
|
||||||
return new CraftCampfire(this);
|
|
||||||
case JIGSAW:
|
|
||||||
return new CraftJigsaw(this);
|
|
||||||
case LECTERN:
|
|
||||||
return new CraftLectern(this);
|
|
||||||
case SMOKER:
|
|
||||||
return new CraftSmoker(this);
|
|
||||||
case BEEHIVE:
|
|
||||||
case BEE_NEST:
|
|
||||||
return new CraftBeehive(this);
|
|
||||||
case SCULK_SENSOR:
|
|
||||||
return new CraftSculkSensor(this);
|
|
||||||
default:
|
|
||||||
TileEntity tileEntity = world.getTileEntity(position);
|
|
||||||
if (tileEntity != null) {
|
|
||||||
// block with unhandled TileEntity:
|
|
||||||
return new CraftBlockEntityState<TileEntity>(this, (Class<TileEntity>) tileEntity.getClass());
|
|
||||||
} else {
|
|
||||||
// Block without TileEntity:
|
|
||||||
return new CraftBlockState(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,39 +1,19 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import net.minecraft.core.BlockPosition;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.level.block.entity.TileEntity;
|
import net.minecraft.world.level.block.entity.TileEntity;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
|
||||||
public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
|
public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
|
||||||
|
|
||||||
private final Class<T> tileEntityClass;
|
|
||||||
private final T tileEntity;
|
private final T tileEntity;
|
||||||
private final T snapshot;
|
private final T snapshot;
|
||||||
|
|
||||||
public CraftBlockEntityState(Block block, Class<T> tileEntityClass) {
|
public CraftBlockEntityState(World world, T tileEntity) {
|
||||||
super(block);
|
super(world, tileEntity.getPosition(), tileEntity.getBlock());
|
||||||
|
|
||||||
this.tileEntityClass = tileEntityClass;
|
|
||||||
|
|
||||||
// get tile entity from block:
|
|
||||||
this.tileEntity = tileEntityClass.cast(getWorldHandle().getTileEntity(this.getPosition()));
|
|
||||||
Preconditions.checkState(this.tileEntity != null, "Tile is null, asynchronous access? %s", block);
|
|
||||||
|
|
||||||
// copy tile entity data:
|
|
||||||
this.snapshot = this.createSnapshot(tileEntity);
|
|
||||||
this.load(snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBlockEntityState(Material material, T tileEntity) {
|
|
||||||
super(material);
|
|
||||||
|
|
||||||
this.tileEntityClass = (Class<T>) tileEntity.getClass();
|
|
||||||
this.tileEntity = tileEntity;
|
this.tileEntity = tileEntity;
|
||||||
|
|
||||||
// copy tile entity data:
|
// copy tile entity data:
|
||||||
@ -58,7 +38,6 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
|||||||
|
|
||||||
// copies the TileEntity-specific data, retains the position
|
// copies the TileEntity-specific data, retains the position
|
||||||
private void copyData(T from, T to) {
|
private void copyData(T from, T to) {
|
||||||
BlockPosition pos = to.getPosition();
|
|
||||||
NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound());
|
NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound());
|
||||||
to.load(nbtTagCompound);
|
to.load(nbtTagCompound);
|
||||||
}
|
}
|
||||||
@ -103,7 +82,7 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isApplicable(TileEntity tileEntity) {
|
protected boolean isApplicable(TileEntity tileEntity) {
|
||||||
return tileEntityClass.isInstance(tileEntity);
|
return this.tileEntity.getClass() == tileEntity.getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,7 +93,7 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
|
|||||||
TileEntity tile = getTileEntityFromWorld();
|
TileEntity tile = getTileEntityFromWorld();
|
||||||
|
|
||||||
if (isApplicable(tile)) {
|
if (isApplicable(tile)) {
|
||||||
applyTo(tileEntityClass.cast(tile));
|
applyTo((T) tile);
|
||||||
tile.update();
|
tile.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.block;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.core.BlockPosition;
|
import net.minecraft.core.BlockPosition;
|
||||||
import net.minecraft.world.level.GeneratorAccess;
|
import net.minecraft.world.level.GeneratorAccess;
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
@ -22,39 +23,30 @@ import org.bukkit.metadata.MetadataValue;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class CraftBlockState implements BlockState {
|
public class CraftBlockState implements BlockState {
|
||||||
|
|
||||||
protected final CraftWorld world;
|
protected final CraftWorld world;
|
||||||
private final BlockPosition position;
|
private final BlockPosition position;
|
||||||
protected IBlockData data;
|
protected IBlockData data;
|
||||||
protected int flag;
|
protected int flag;
|
||||||
private WeakReference<GeneratorAccess> weakWorld;
|
private WeakReference<GeneratorAccess> weakWorld;
|
||||||
|
|
||||||
public CraftBlockState(final Block block) {
|
protected CraftBlockState(final Block block) {
|
||||||
this.world = (CraftWorld) block.getWorld();
|
this(block.getWorld(), ((CraftBlock) block).getPosition(), ((CraftBlock) block).getNMS());
|
||||||
this.position = ((CraftBlock) block).getPosition();
|
|
||||||
this.data = ((CraftBlock) block).getNMS();
|
|
||||||
this.flag = 3;
|
this.flag = 3;
|
||||||
|
|
||||||
setWorldHandle(((CraftBlock) block).getHandle());
|
setWorldHandle(((CraftBlock) block).getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftBlockState(final Block block, int flag) {
|
protected CraftBlockState(final Block block, int flag) {
|
||||||
this(block);
|
this(block);
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftBlockState(Material material) {
|
// world can be null for non-placed BlockStates.
|
||||||
world = null;
|
protected CraftBlockState(@Nullable World world, BlockPosition blockPosition, IBlockData blockData) {
|
||||||
data = CraftMagicNumbers.getBlock(material).getBlockData();
|
this.world = (CraftWorld) world;
|
||||||
position = BlockPosition.ZERO;
|
position = blockPosition;
|
||||||
this.weakWorld = null;
|
data = blockData;
|
||||||
}
|
|
||||||
|
|
||||||
public static CraftBlockState getBlockState(GeneratorAccess world, net.minecraft.core.BlockPosition pos) {
|
|
||||||
return new CraftBlockState(CraftBlock.at(world, pos));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CraftBlockState getBlockState(GeneratorAccess world, net.minecraft.core.BlockPosition pos, int flag) {
|
|
||||||
return new CraftBlockState(CraftBlock.at(world, pos), flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorldHandle(GeneratorAccess generatorAccess) {
|
public void setWorldHandle(GeneratorAccess generatorAccess) {
|
||||||
|
@ -0,0 +1,385 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.core.BlockPosition;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.level.GeneratorAccess;
|
||||||
|
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBanner;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBarrel;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBeacon;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBed;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBeehive;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBell;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityBrewingStand;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityCampfire;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityChest;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityCommand;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityComparator;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityConduit;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityDispenser;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityDropper;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityEnchantTable;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityEndGateway;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityEnderPortal;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityFurnaceFurnace;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityHopper;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityJigsaw;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityLectern;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityLightDetector;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityShulkerBox;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntitySign;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntitySkull;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntitySmoker;
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityStructure;
|
||||||
|
import net.minecraft.world.level.block.piston.TileEntityPiston;
|
||||||
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
|
||||||
|
public final class CraftBlockStates {
|
||||||
|
|
||||||
|
private abstract static class BlockStateFactory<B extends CraftBlockState> {
|
||||||
|
|
||||||
|
public final Class<B> blockStateType;
|
||||||
|
|
||||||
|
public BlockStateFactory(Class<B> blockStateType) {
|
||||||
|
this.blockStateType = blockStateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The given world can be null for unplaced BlockStates.
|
||||||
|
// If the world is not null and the given block data is a tile entity, the given tile entity is expected to not be null.
|
||||||
|
// Otherwise, the given tile entity may or may not be null.
|
||||||
|
// If the given tile entity is not null, its position and block data are expected to match the given block position and block data.
|
||||||
|
// In some situations, such as during chunk generation, the tile entity's world may be null, even if the given world is not null.
|
||||||
|
// If the tile entity's world is not null, it is expected to match the given world.
|
||||||
|
public abstract B createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BlockEntityStateFactory<T extends TileEntity, B extends CraftBlockEntityState<T>> extends BlockStateFactory<B> {
|
||||||
|
|
||||||
|
private final BiFunction<World, T, B> blockStateConstructor;
|
||||||
|
private final BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor;
|
||||||
|
|
||||||
|
protected BlockEntityStateFactory(Class<B> blockStateType, BiFunction<World, T, B> blockStateConstructor, BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor) {
|
||||||
|
super(blockStateType);
|
||||||
|
this.blockStateConstructor = blockStateConstructor;
|
||||||
|
this.tileEntityConstructor = tileEntityConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final B createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
|
||||||
|
if (world != null) {
|
||||||
|
Preconditions.checkState(tileEntity != null, "Tile is null, asynchronous access? %s", CraftBlock.at(((CraftWorld) world).getHandle(), blockPosition));
|
||||||
|
} else if (tileEntity == null) {
|
||||||
|
tileEntity = this.createTileEntity(blockPosition, blockData);
|
||||||
|
}
|
||||||
|
return this.createBlockState(world, (T) tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private T createTileEntity(BlockPosition blockPosition, IBlockData blockData) {
|
||||||
|
return tileEntityConstructor.apply(blockPosition, blockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private B createBlockState(World world, T tileEntity) {
|
||||||
|
return blockStateConstructor.apply(world, tileEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Material, BlockStateFactory<?>> FACTORIES = new HashMap<>();
|
||||||
|
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
|
||||||
|
@Override
|
||||||
|
public CraftBlockState createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
|
||||||
|
Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
|
||||||
|
return new CraftBlockState(world, blockPosition, blockData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static {
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.ACACIA_SIGN,
|
||||||
|
Material.ACACIA_WALL_SIGN,
|
||||||
|
Material.BIRCH_SIGN,
|
||||||
|
Material.BIRCH_WALL_SIGN,
|
||||||
|
Material.CRIMSON_SIGN,
|
||||||
|
Material.CRIMSON_WALL_SIGN,
|
||||||
|
Material.DARK_OAK_SIGN,
|
||||||
|
Material.DARK_OAK_WALL_SIGN,
|
||||||
|
Material.JUNGLE_SIGN,
|
||||||
|
Material.JUNGLE_WALL_SIGN,
|
||||||
|
Material.OAK_SIGN,
|
||||||
|
Material.OAK_WALL_SIGN,
|
||||||
|
Material.SPRUCE_SIGN,
|
||||||
|
Material.SPRUCE_WALL_SIGN,
|
||||||
|
Material.WARPED_SIGN,
|
||||||
|
Material.WARPED_WALL_SIGN
|
||||||
|
), CraftSign.class, CraftSign::new, TileEntitySign::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.CREEPER_HEAD,
|
||||||
|
Material.CREEPER_WALL_HEAD,
|
||||||
|
Material.DRAGON_HEAD,
|
||||||
|
Material.DRAGON_WALL_HEAD,
|
||||||
|
Material.PLAYER_HEAD,
|
||||||
|
Material.PLAYER_WALL_HEAD,
|
||||||
|
Material.SKELETON_SKULL,
|
||||||
|
Material.SKELETON_WALL_SKULL,
|
||||||
|
Material.WITHER_SKELETON_SKULL,
|
||||||
|
Material.WITHER_SKELETON_WALL_SKULL,
|
||||||
|
Material.ZOMBIE_HEAD,
|
||||||
|
Material.ZOMBIE_WALL_HEAD
|
||||||
|
), CraftSkull.class, CraftSkull::new, TileEntitySkull::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.COMMAND_BLOCK,
|
||||||
|
Material.REPEATING_COMMAND_BLOCK,
|
||||||
|
Material.CHAIN_COMMAND_BLOCK
|
||||||
|
), CraftCommandBlock.class, CraftCommandBlock::new, TileEntityCommand::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.BLACK_BANNER,
|
||||||
|
Material.BLACK_WALL_BANNER,
|
||||||
|
Material.BLUE_BANNER,
|
||||||
|
Material.BLUE_WALL_BANNER,
|
||||||
|
Material.BROWN_BANNER,
|
||||||
|
Material.BROWN_WALL_BANNER,
|
||||||
|
Material.CYAN_BANNER,
|
||||||
|
Material.CYAN_WALL_BANNER,
|
||||||
|
Material.GRAY_BANNER,
|
||||||
|
Material.GRAY_WALL_BANNER,
|
||||||
|
Material.GREEN_BANNER,
|
||||||
|
Material.GREEN_WALL_BANNER,
|
||||||
|
Material.LIGHT_BLUE_BANNER,
|
||||||
|
Material.LIGHT_BLUE_WALL_BANNER,
|
||||||
|
Material.LIGHT_GRAY_BANNER,
|
||||||
|
Material.LIGHT_GRAY_WALL_BANNER,
|
||||||
|
Material.LIME_BANNER,
|
||||||
|
Material.LIME_WALL_BANNER,
|
||||||
|
Material.MAGENTA_BANNER,
|
||||||
|
Material.MAGENTA_WALL_BANNER,
|
||||||
|
Material.ORANGE_BANNER,
|
||||||
|
Material.ORANGE_WALL_BANNER,
|
||||||
|
Material.PINK_BANNER,
|
||||||
|
Material.PINK_WALL_BANNER,
|
||||||
|
Material.PURPLE_BANNER,
|
||||||
|
Material.PURPLE_WALL_BANNER,
|
||||||
|
Material.RED_BANNER,
|
||||||
|
Material.RED_WALL_BANNER,
|
||||||
|
Material.WHITE_BANNER,
|
||||||
|
Material.WHITE_WALL_BANNER,
|
||||||
|
Material.YELLOW_BANNER,
|
||||||
|
Material.YELLOW_WALL_BANNER
|
||||||
|
), CraftBanner.class, CraftBanner::new, TileEntityBanner::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.SHULKER_BOX,
|
||||||
|
Material.WHITE_SHULKER_BOX,
|
||||||
|
Material.ORANGE_SHULKER_BOX,
|
||||||
|
Material.MAGENTA_SHULKER_BOX,
|
||||||
|
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||||
|
Material.YELLOW_SHULKER_BOX,
|
||||||
|
Material.LIME_SHULKER_BOX,
|
||||||
|
Material.PINK_SHULKER_BOX,
|
||||||
|
Material.GRAY_SHULKER_BOX,
|
||||||
|
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||||
|
Material.CYAN_SHULKER_BOX,
|
||||||
|
Material.PURPLE_SHULKER_BOX,
|
||||||
|
Material.BLUE_SHULKER_BOX,
|
||||||
|
Material.BROWN_SHULKER_BOX,
|
||||||
|
Material.GREEN_SHULKER_BOX,
|
||||||
|
Material.RED_SHULKER_BOX,
|
||||||
|
Material.BLACK_SHULKER_BOX
|
||||||
|
), CraftShulkerBox.class, CraftShulkerBox::new, TileEntityShulkerBox::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.BLACK_BED,
|
||||||
|
Material.BLUE_BED,
|
||||||
|
Material.BROWN_BED,
|
||||||
|
Material.CYAN_BED,
|
||||||
|
Material.GRAY_BED,
|
||||||
|
Material.GREEN_BED,
|
||||||
|
Material.LIGHT_BLUE_BED,
|
||||||
|
Material.LIGHT_GRAY_BED,
|
||||||
|
Material.LIME_BED,
|
||||||
|
Material.MAGENTA_BED,
|
||||||
|
Material.ORANGE_BED,
|
||||||
|
Material.PINK_BED,
|
||||||
|
Material.PURPLE_BED,
|
||||||
|
Material.RED_BED,
|
||||||
|
Material.WHITE_BED,
|
||||||
|
Material.YELLOW_BED
|
||||||
|
), CraftBed.class, CraftBed::new, TileEntityBed::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.BEEHIVE,
|
||||||
|
Material.BEE_NEST
|
||||||
|
), CraftBeehive.class, CraftBeehive::new, TileEntityBeehive::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.CAMPFIRE,
|
||||||
|
Material.SOUL_CAMPFIRE
|
||||||
|
), CraftCampfire.class, CraftCampfire::new, TileEntityCampfire::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(
|
||||||
|
Arrays.asList(
|
||||||
|
Material.CHEST,
|
||||||
|
Material.TRAPPED_CHEST
|
||||||
|
), CraftChest.class, CraftChest::new, TileEntityChest::new
|
||||||
|
);
|
||||||
|
|
||||||
|
register(Material.BARREL, CraftBarrel.class, CraftBarrel::new, TileEntityBarrel::new);
|
||||||
|
register(Material.BEACON, CraftBeacon.class, CraftBeacon::new, TileEntityBeacon::new);
|
||||||
|
register(Material.BELL, CraftBell.class, CraftBell::new, TileEntityBell::new);
|
||||||
|
register(Material.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new, TileEntityBlastFurnace::new);
|
||||||
|
register(Material.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new, TileEntityBrewingStand::new);
|
||||||
|
register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, TileEntityComparator::new);
|
||||||
|
register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, TileEntityConduit::new);
|
||||||
|
register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, TileEntityLightDetector::new);
|
||||||
|
register(Material.DISPENSER, CraftDispenser.class, CraftDispenser::new, TileEntityDispenser::new);
|
||||||
|
register(Material.DROPPER, CraftDropper.class, CraftDropper::new, TileEntityDropper::new);
|
||||||
|
register(Material.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new, TileEntityEnchantTable::new);
|
||||||
|
register(Material.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new, TileEntityEnderChest::new);
|
||||||
|
register(Material.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new, TileEntityEndGateway::new);
|
||||||
|
register(Material.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new, TileEntityEnderPortal::new);
|
||||||
|
register(Material.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new, TileEntityFurnaceFurnace::new);
|
||||||
|
register(Material.HOPPER, CraftHopper.class, CraftHopper::new, TileEntityHopper::new);
|
||||||
|
register(Material.JIGSAW, CraftJigsaw.class, CraftJigsaw::new, TileEntityJigsaw::new);
|
||||||
|
register(Material.JUKEBOX, CraftJukebox.class, CraftJukebox::new, TileEntityJukeBox::new);
|
||||||
|
register(Material.LECTERN, CraftLectern.class, CraftLectern::new, TileEntityLectern::new);
|
||||||
|
register(Material.MOVING_PISTON, CraftMovingPiston.class, CraftMovingPiston::new, TileEntityPiston::new);
|
||||||
|
register(Material.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new, SculkSensorBlockEntity::new);
|
||||||
|
register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, TileEntitySmoker::new);
|
||||||
|
register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, TileEntityMobSpawner::new);
|
||||||
|
register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, TileEntityStructure::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void register(Material blockType, BlockStateFactory<?> factory) {
|
||||||
|
FACTORIES.put(blockType, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T extends TileEntity, B extends CraftBlockEntityState<T>> void register(
|
||||||
|
Material blockType,
|
||||||
|
Class<B> blockStateType,
|
||||||
|
BiFunction<World, T, B> blockStateConstructor,
|
||||||
|
BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor
|
||||||
|
) {
|
||||||
|
register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T extends TileEntity, B extends CraftBlockEntityState<T>> void register(
|
||||||
|
List<Material> blockTypes,
|
||||||
|
Class<B> blockStateType,
|
||||||
|
BiFunction<World, T, B> blockStateConstructor,
|
||||||
|
BiFunction<BlockPosition, IBlockData, T> tileEntityConstructor
|
||||||
|
) {
|
||||||
|
BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, tileEntityConstructor);
|
||||||
|
for (Material blockType : blockTypes) {
|
||||||
|
register(blockType, factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlockStateFactory<?> getFactory(Material material) {
|
||||||
|
return FACTORIES.getOrDefault(material, DEFAULT_FACTORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class<? extends CraftBlockState> getBlockStateType(Material material) {
|
||||||
|
Preconditions.checkNotNull(material, "material is null");
|
||||||
|
return getFactory(material).blockStateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockState getBlockState(Block block) {
|
||||||
|
Preconditions.checkNotNull(block, "block is null");
|
||||||
|
CraftBlock craftBlock = (CraftBlock) block;
|
||||||
|
CraftWorld world = (CraftWorld) block.getWorld();
|
||||||
|
BlockPosition blockPosition = craftBlock.getPosition();
|
||||||
|
IBlockData blockData = craftBlock.getNMS();
|
||||||
|
TileEntity tileEntity = craftBlock.getHandle().getTileEntity(blockPosition);
|
||||||
|
CraftBlockState blockState = getBlockState(world, blockPosition, blockData, tileEntity);
|
||||||
|
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
|
||||||
|
return blockState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockState getBlockState(Material material, @Nullable NBTTagCompound blockEntityTag) {
|
||||||
|
return getBlockState(BlockPosition.ZERO, material, blockEntityTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockState getBlockState(BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) {
|
||||||
|
Preconditions.checkNotNull(material, "material is null");
|
||||||
|
IBlockData blockData = CraftMagicNumbers.getBlock(material).getBlockData();
|
||||||
|
return getBlockState(blockPosition, blockData, blockEntityTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockState getBlockState(IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) {
|
||||||
|
return getBlockState(BlockPosition.ZERO, blockData, blockEntityTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockState getBlockState(BlockPosition blockPosition, IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) {
|
||||||
|
Preconditions.checkNotNull(blockPosition, "blockPosition is null");
|
||||||
|
Preconditions.checkNotNull(blockData, "blockData is null");
|
||||||
|
TileEntity tileEntity = (blockEntityTag == null) ? null : TileEntity.create(blockPosition, blockData, blockEntityTag);
|
||||||
|
return getBlockState(null, blockPosition, blockData, tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// See BlockStateFactory#createBlockState(World, BlockPosition, IBlockData, TileEntity)
|
||||||
|
private static CraftBlockState getBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
|
||||||
|
Material material = CraftMagicNumbers.getMaterial(blockData.getBlock());
|
||||||
|
BlockStateFactory<?> factory;
|
||||||
|
// For some types of TileEntity blocks (eg. moving pistons), Minecraft may in some situations (eg. when using Block#setType or the
|
||||||
|
// setBlock command) not create a corresponding TileEntity in the world. We return a normal BlockState in this case.
|
||||||
|
if (world != null && tileEntity == null && isTileEntityOptional(material)) {
|
||||||
|
factory = DEFAULT_FACTORY;
|
||||||
|
} else {
|
||||||
|
factory = getFactory(material);
|
||||||
|
}
|
||||||
|
return factory.createBlockState(world, blockPosition, blockData, tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isTileEntityOptional(Material material) {
|
||||||
|
return material == Material.MOVING_PISTON;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This ignores tile entity data.
|
||||||
|
public static CraftBlockState getBlockState(GeneratorAccess world, BlockPosition pos) {
|
||||||
|
return new CraftBlockState(CraftBlock.at(world, pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This ignores tile entity data.
|
||||||
|
public static CraftBlockState getBlockState(GeneratorAccess world, BlockPosition pos, int flag) {
|
||||||
|
return new CraftBlockState(CraftBlock.at(world, pos), flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CraftBlockStates() {
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,15 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBrewingStand;
|
import net.minecraft.world.level.block.entity.TileEntityBrewingStand;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
|
|
||||||
public class CraftBrewingStand extends CraftContainer<TileEntityBrewingStand> implements BrewingStand {
|
public class CraftBrewingStand extends CraftContainer<TileEntityBrewingStand> implements BrewingStand {
|
||||||
|
|
||||||
public CraftBrewingStand(Block block) {
|
public CraftBrewingStand(World world, TileEntityBrewingStand tileEntity) {
|
||||||
super(block, TileEntityBrewingStand.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftBrewingStand(final Material material, final TileEntityBrewingStand te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityCampfire;
|
import net.minecraft.world.level.block.entity.TileEntityCampfire;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Campfire;
|
import org.bukkit.block.Campfire;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CraftCampfire extends CraftBlockEntityState<TileEntityCampfire> implements Campfire {
|
public class CraftCampfire extends CraftBlockEntityState<TileEntityCampfire> implements Campfire {
|
||||||
|
|
||||||
public CraftCampfire(Block block) {
|
public CraftCampfire(World world, TileEntityCampfire tileEntity) {
|
||||||
super(block, TileEntityCampfire.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftCampfire(Material material, TileEntityCampfire te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Blocks;
|
|||||||
import net.minecraft.world.level.block.entity.TileEntityChest;
|
import net.minecraft.world.level.block.entity.TileEntityChest;
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
@ -17,12 +17,8 @@ import org.bukkit.inventory.Inventory;
|
|||||||
|
|
||||||
public class CraftChest extends CraftLootable<TileEntityChest> implements Chest {
|
public class CraftChest extends CraftLootable<TileEntityChest> implements Chest {
|
||||||
|
|
||||||
public CraftChest(final Block block) {
|
public CraftChest(World world, TileEntityChest tileEntity) {
|
||||||
super(block, TileEntityChest.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftChest(final Material material, final TileEntityChest te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityCommand;
|
import net.minecraft.world.level.block.entity.TileEntityCommand;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.CommandBlock;
|
import org.bukkit.block.CommandBlock;
|
||||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
|
|
||||||
public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand> implements CommandBlock {
|
public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand> implements CommandBlock {
|
||||||
|
|
||||||
public CraftCommandBlock(Block block) {
|
public CraftCommandBlock(World world, TileEntityCommand tileEntity) {
|
||||||
super(block, TileEntityCommand.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftCommandBlock(final Material material, final TileEntityCommand te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityComparator;
|
import net.minecraft.world.level.block.entity.TileEntityComparator;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Comparator;
|
import org.bukkit.block.Comparator;
|
||||||
|
|
||||||
public class CraftComparator extends CraftBlockEntityState<TileEntityComparator> implements Comparator {
|
public class CraftComparator extends CraftBlockEntityState<TileEntityComparator> implements Comparator {
|
||||||
|
|
||||||
public CraftComparator(final Block block) {
|
public CraftComparator(World world, TileEntityComparator tileEntity) {
|
||||||
super(block, TileEntityComparator.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftComparator(final Material material, final TileEntityComparator te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityConduit;
|
import net.minecraft.world.level.block.entity.TileEntityConduit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Conduit;
|
import org.bukkit.block.Conduit;
|
||||||
|
|
||||||
public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> implements Conduit {
|
public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> implements Conduit {
|
||||||
|
|
||||||
public CraftConduit(Block block) {
|
public CraftConduit(World world, TileEntityConduit tileEntity) {
|
||||||
super(block, TileEntityConduit.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftConduit(Material material, TileEntityConduit te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,14 @@ package org.bukkit.craftbukkit.block;
|
|||||||
|
|
||||||
import net.minecraft.world.ChestLock;
|
import net.minecraft.world.ChestLock;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityContainer;
|
import net.minecraft.world.level.block.entity.TileEntityContainer;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Container;
|
import org.bukkit.block.Container;
|
||||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
|
|
||||||
public abstract class CraftContainer<T extends TileEntityContainer> extends CraftBlockEntityState<T> implements Container {
|
public abstract class CraftContainer<T extends TileEntityContainer> extends CraftBlockEntityState<T> implements Container {
|
||||||
|
|
||||||
public CraftContainer(Block block, Class<T> tileEntityClass) {
|
public CraftContainer(World world, T tileEntity) {
|
||||||
super(block, tileEntityClass);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftContainer(final Material material, T tileEntity) {
|
|
||||||
super(material, tileEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,19 +5,14 @@ import net.minecraft.core.BlockPosition;
|
|||||||
import net.minecraft.resources.MinecraftKey;
|
import net.minecraft.resources.MinecraftKey;
|
||||||
import net.minecraft.world.entity.EntityTypes;
|
import net.minecraft.world.entity.EntityTypes;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpawner> implements CreatureSpawner {
|
public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpawner> implements CreatureSpawner {
|
||||||
|
|
||||||
public CraftCreatureSpawner(final Block block) {
|
public CraftCreatureSpawner(World world, TileEntityMobSpawner tileEntity) {
|
||||||
super(block, TileEntityMobSpawner.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftCreatureSpawner(final Material material, TileEntityMobSpawner te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityLightDetector;
|
import net.minecraft.world.level.block.entity.TileEntityLightDetector;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.DaylightDetector;
|
import org.bukkit.block.DaylightDetector;
|
||||||
|
|
||||||
public class CraftDaylightDetector extends CraftBlockEntityState<TileEntityLightDetector> implements DaylightDetector {
|
public class CraftDaylightDetector extends CraftBlockEntityState<TileEntityLightDetector> implements DaylightDetector {
|
||||||
|
|
||||||
public CraftDaylightDetector(final Block block) {
|
public CraftDaylightDetector(World world, TileEntityLightDetector tileEntity) {
|
||||||
super(block, TileEntityLightDetector.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftDaylightDetector(final Material material, final TileEntityLightDetector te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import net.minecraft.world.level.block.BlockDispenser;
|
|||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityDispenser;
|
import net.minecraft.world.level.block.entity.TileEntityDispenser;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Dispenser;
|
import org.bukkit.block.Dispenser;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
@ -15,12 +16,8 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
|||||||
|
|
||||||
public class CraftDispenser extends CraftLootable<TileEntityDispenser> implements Dispenser {
|
public class CraftDispenser extends CraftLootable<TileEntityDispenser> implements Dispenser {
|
||||||
|
|
||||||
public CraftDispenser(final Block block) {
|
public CraftDispenser(World world, TileEntityDispenser tileEntity) {
|
||||||
super(block, TileEntityDispenser.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftDispenser(final Material material, final TileEntityDispenser te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,6 +5,7 @@ import net.minecraft.world.level.block.BlockDropper;
|
|||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityDropper;
|
import net.minecraft.world.level.block.entity.TileEntityDropper;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Dropper;
|
import org.bukkit.block.Dropper;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
@ -13,12 +14,8 @@ import org.bukkit.inventory.Inventory;
|
|||||||
|
|
||||||
public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dropper {
|
public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dropper {
|
||||||
|
|
||||||
public CraftDropper(final Block block) {
|
public CraftDropper(World world, TileEntityDropper tileEntity) {
|
||||||
super(block, TileEntityDropper.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftDropper(final Material material, TileEntityDropper te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityEnchantTable;
|
import net.minecraft.world.level.block.entity.TileEntityEnchantTable;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.EnchantingTable;
|
import org.bukkit.block.EnchantingTable;
|
||||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
|
|
||||||
public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchantTable> implements EnchantingTable {
|
public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchantTable> implements EnchantingTable {
|
||||||
|
|
||||||
public CraftEnchantingTable(final Block block) {
|
public CraftEnchantingTable(World world, TileEntityEnchantTable tileEntity) {
|
||||||
super(block, TileEntityEnchantTable.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftEnchantingTable(final Material material, final TileEntityEnchantTable te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,18 +4,13 @@ import java.util.Objects;
|
|||||||
import net.minecraft.core.BlockPosition;
|
import net.minecraft.core.BlockPosition;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityEndGateway;
|
import net.minecraft.world.level.block.entity.TileEntityEndGateway;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.EndGateway;
|
import org.bukkit.block.EndGateway;
|
||||||
|
|
||||||
public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway> implements EndGateway {
|
public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway> implements EndGateway {
|
||||||
|
|
||||||
public CraftEndGateway(Block block) {
|
public CraftEndGateway(World world, TileEntityEndGateway tileEntity) {
|
||||||
super(block, TileEntityEndGateway.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftEndGateway(final Material material, TileEntityEndGateway te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.entity.TileEntityEnderPortal;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public class CraftEndPortal extends CraftBlockEntityState<TileEntityEnderPortal> {
|
||||||
|
|
||||||
|
public CraftEndPortal(World world, TileEntityEnderPortal tileEntity) {
|
||||||
|
super(world, tileEntity);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.EnderChest;
|
import org.bukkit.block.EnderChest;
|
||||||
|
|
||||||
public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest> implements EnderChest {
|
public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest> implements EnderChest {
|
||||||
|
|
||||||
public CraftEnderChest(final Block block) {
|
public CraftEnderChest(World world, TileEntityEnderChest tileEntity) {
|
||||||
super(block, TileEntityEnderChest.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftEnderChest(final Material material, final TileEntityEnderChest te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,15 @@ package org.bukkit.craftbukkit.block;
|
|||||||
|
|
||||||
import net.minecraft.world.level.block.BlockFurnace;
|
import net.minecraft.world.level.block.BlockFurnace;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityFurnace;
|
import net.minecraft.world.level.block.entity.TileEntityFurnace;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
|
||||||
import org.bukkit.inventory.FurnaceInventory;
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
|
|
||||||
public abstract class CraftFurnace<T extends TileEntityFurnace> extends CraftContainer<T> implements Furnace {
|
public abstract class CraftFurnace<T extends TileEntityFurnace> extends CraftContainer<T> implements Furnace {
|
||||||
|
|
||||||
public CraftFurnace(Block block, Class<T> tileEntityClass) {
|
public CraftFurnace(World world, T tileEntity) {
|
||||||
super(block, tileEntityClass);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftFurnace(final Material material, final T te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityFurnaceFurnace;
|
import net.minecraft.world.level.block.entity.TileEntityFurnaceFurnace;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
public class CraftFurnaceFurnace extends CraftFurnace<TileEntityFurnaceFurnace> {
|
public class CraftFurnaceFurnace extends CraftFurnace<TileEntityFurnaceFurnace> {
|
||||||
|
|
||||||
public CraftFurnaceFurnace(Block block) {
|
public CraftFurnaceFurnace(World world, TileEntityFurnaceFurnace tileEntity) {
|
||||||
super(block, TileEntityFurnaceFurnace.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftFurnaceFurnace(Material material, TileEntityFurnaceFurnace te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityHopper;
|
import net.minecraft.world.level.block.entity.TileEntityHopper;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Hopper;
|
import org.bukkit.block.Hopper;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
public class CraftHopper extends CraftLootable<TileEntityHopper> implements Hopper {
|
public class CraftHopper extends CraftLootable<TileEntityHopper> implements Hopper {
|
||||||
|
|
||||||
public CraftHopper(final Block block) {
|
public CraftHopper(World world, TileEntityHopper tileEntity) {
|
||||||
super(block, TileEntityHopper.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftHopper(final Material material, final TileEntityHopper te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityJigsaw;
|
import net.minecraft.world.level.block.entity.TileEntityJigsaw;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Jigsaw;
|
import org.bukkit.block.Jigsaw;
|
||||||
|
|
||||||
public class CraftJigsaw extends CraftBlockEntityState<TileEntityJigsaw> implements Jigsaw {
|
public class CraftJigsaw extends CraftBlockEntityState<TileEntityJigsaw> implements Jigsaw {
|
||||||
|
|
||||||
public CraftJigsaw(Block block) {
|
public CraftJigsaw(World world, TileEntityJigsaw tileEntity) {
|
||||||
super(block, TileEntityJigsaw.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftJigsaw(Material material, TileEntityJigsaw te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import net.minecraft.world.level.block.entity.TileEntity;
|
|||||||
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
|
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Jukebox;
|
import org.bukkit.block.Jukebox;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
@ -16,12 +16,8 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|||||||
|
|
||||||
public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> implements Jukebox {
|
public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> implements Jukebox {
|
||||||
|
|
||||||
public CraftJukebox(final Block block) {
|
public CraftJukebox(World world, TileEntityJukeBox tileEntity) {
|
||||||
super(block, TileEntityJukeBox.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftJukebox(final Material material, TileEntityJukeBox te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,19 +3,15 @@ package org.bukkit.craftbukkit.block;
|
|||||||
import net.minecraft.world.level.block.BlockLectern;
|
import net.minecraft.world.level.block.BlockLectern;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityLectern;
|
import net.minecraft.world.level.block.entity.TileEntityLectern;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Lectern;
|
import org.bukkit.block.Lectern;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryLectern;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryLectern;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> implements Lectern {
|
public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> implements Lectern {
|
||||||
|
|
||||||
public CraftLectern(Block block) {
|
public CraftLectern(World world, TileEntityLectern tileEntity) {
|
||||||
super(block, TileEntityLectern.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftLectern(Material material, TileEntityLectern te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,21 +3,16 @@ package org.bukkit.craftbukkit.block;
|
|||||||
import net.minecraft.resources.MinecraftKey;
|
import net.minecraft.resources.MinecraftKey;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityLootable;
|
import net.minecraft.world.level.block.entity.TileEntityLootable;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Nameable;
|
import org.bukkit.Nameable;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
import org.bukkit.loot.LootTable;
|
import org.bukkit.loot.LootTable;
|
||||||
import org.bukkit.loot.Lootable;
|
import org.bukkit.loot.Lootable;
|
||||||
|
|
||||||
public abstract class CraftLootable<T extends TileEntityLootable> extends CraftContainer<T> implements Nameable, Lootable {
|
public abstract class CraftLootable<T extends TileEntityLootable> extends CraftContainer<T> implements Nameable, Lootable {
|
||||||
|
|
||||||
public CraftLootable(Block block, Class<T> tileEntityClass) {
|
public CraftLootable(World world, T tileEntity) {
|
||||||
super(block, tileEntityClass);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftLootable(Material material, T tileEntity) {
|
|
||||||
super(material, tileEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.piston.TileEntityPiston;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public class CraftMovingPiston extends CraftBlockEntityState<TileEntityPiston> {
|
||||||
|
|
||||||
|
public CraftMovingPiston(World world, TileEntityPiston tileEntity) {
|
||||||
|
super(world, tileEntity);
|
||||||
|
}
|
||||||
|
}
|
@ -2,18 +2,13 @@ package org.bukkit.craftbukkit.block;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
|
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.SculkSensor;
|
import org.bukkit.block.SculkSensor;
|
||||||
|
|
||||||
public class CraftSculkSensor extends CraftBlockEntityState<SculkSensorBlockEntity> implements SculkSensor {
|
public class CraftSculkSensor extends CraftBlockEntityState<SculkSensorBlockEntity> implements SculkSensor {
|
||||||
|
|
||||||
public CraftSculkSensor(final Block block) {
|
public CraftSculkSensor(World world, SculkSensorBlockEntity tileEntity) {
|
||||||
super(block, SculkSensorBlockEntity.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftSculkSensor(final Material material, final SculkSensorBlockEntity te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,12 +3,10 @@ package org.bukkit.craftbukkit.block;
|
|||||||
import net.minecraft.sounds.SoundCategory;
|
import net.minecraft.sounds.SoundCategory;
|
||||||
import net.minecraft.sounds.SoundEffects;
|
import net.minecraft.sounds.SoundEffects;
|
||||||
import net.minecraft.world.item.EnumColor;
|
import net.minecraft.world.item.EnumColor;
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import net.minecraft.world.level.block.BlockShulkerBox;
|
import net.minecraft.world.level.block.BlockShulkerBox;
|
||||||
import net.minecraft.world.level.block.entity.TileEntityShulkerBox;
|
import net.minecraft.world.level.block.entity.TileEntityShulkerBox;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.ShulkerBox;
|
import org.bukkit.block.ShulkerBox;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
@ -16,12 +14,8 @@ import org.bukkit.inventory.Inventory;
|
|||||||
|
|
||||||
public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> implements ShulkerBox {
|
public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> implements ShulkerBox {
|
||||||
|
|
||||||
public CraftShulkerBox(final Block block) {
|
public CraftShulkerBox(World world, TileEntityShulkerBox tileEntity) {
|
||||||
super(block, TileEntityShulkerBox.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftShulkerBox(final Material material, final TileEntityShulkerBox te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,7 +43,7 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
|
|||||||
public void open() {
|
public void open() {
|
||||||
requirePlaced();
|
requirePlaced();
|
||||||
if (!getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
if (!getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
||||||
World world = getTileEntity().getWorld();
|
net.minecraft.world.level.World world = getTileEntity().getWorld();
|
||||||
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 1);
|
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 1);
|
||||||
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||||
}
|
}
|
||||||
@ -60,7 +54,7 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
|
|||||||
public void close() {
|
public void close() {
|
||||||
requirePlaced();
|
requirePlaced();
|
||||||
if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
|
||||||
World world = getTileEntity().getWorld();
|
net.minecraft.world.level.World world = getTileEntity().getWorld();
|
||||||
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 0);
|
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 0);
|
||||||
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,7 @@ import net.minecraft.network.chat.IChatBaseComponent;
|
|||||||
import net.minecraft.world.item.EnumColor;
|
import net.minecraft.world.item.EnumColor;
|
||||||
import net.minecraft.world.level.block.entity.TileEntitySign;
|
import net.minecraft.world.level.block.entity.TileEntitySign;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
|
|
||||||
@ -16,12 +15,8 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
|
|||||||
private String[] originalLines = null;
|
private String[] originalLines = null;
|
||||||
private String[] lines = null;
|
private String[] lines = null;
|
||||||
|
|
||||||
public CraftSign(final Block block) {
|
public CraftSign(World world, TileEntitySign tileEntity) {
|
||||||
super(block, TileEntitySign.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftSign(final Material material, final TileEntitySign te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,10 +5,9 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.level.block.entity.TileEntitySkull;
|
import net.minecraft.world.level.block.entity.TileEntitySkull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.SkullType;
|
import org.bukkit.SkullType;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -21,12 +20,8 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
|
|||||||
private static final int MAX_OWNER_LENGTH = 16;
|
private static final int MAX_OWNER_LENGTH = 16;
|
||||||
private GameProfile profile;
|
private GameProfile profile;
|
||||||
|
|
||||||
public CraftSkull(final Block block) {
|
public CraftSkull(World world, TileEntitySkull tileEntity) {
|
||||||
super(block, TileEntitySkull.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftSkull(final Material material, final TileEntitySkull te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.block;
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntitySmoker;
|
import net.minecraft.world.level.block.entity.TileEntitySmoker;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Smoker;
|
import org.bukkit.block.Smoker;
|
||||||
|
|
||||||
public class CraftSmoker extends CraftFurnace<TileEntitySmoker> implements Smoker {
|
public class CraftSmoker extends CraftFurnace<TileEntitySmoker> implements Smoker {
|
||||||
|
|
||||||
public CraftSmoker(Block block) {
|
public CraftSmoker(World world, TileEntitySmoker tileEntity) {
|
||||||
super(block, TileEntitySmoker.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftSmoker(Material material, TileEntitySmoker te) {
|
|
||||||
super(material, te);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@ import net.minecraft.world.level.block.EnumBlockRotation;
|
|||||||
import net.minecraft.world.level.block.entity.TileEntityStructure;
|
import net.minecraft.world.level.block.entity.TileEntityStructure;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockPropertyStructureMode;
|
import net.minecraft.world.level.block.state.properties.BlockPropertyStructureMode;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Structure;
|
import org.bukkit.block.Structure;
|
||||||
import org.bukkit.block.structure.Mirror;
|
import org.bukkit.block.structure.Mirror;
|
||||||
import org.bukkit.block.structure.StructureRotation;
|
import org.bukkit.block.structure.StructureRotation;
|
||||||
@ -21,12 +20,8 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
|
|||||||
|
|
||||||
private static final int MAX_SIZE = 48;
|
private static final int MAX_SIZE = 48;
|
||||||
|
|
||||||
public CraftStructureBlock(Block block) {
|
public CraftStructureBlock(World world, TileEntityStructure tileEntity) {
|
||||||
super(block, TileEntityStructure.class);
|
super(world, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public CraftStructureBlock(Material material, TileEntityStructure structure) {
|
|
||||||
super(material, structure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,6 +84,7 @@ import org.bukkit.craftbukkit.CraftStatistic;
|
|||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftBlockStates;
|
||||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||||
@ -734,7 +735,7 @@ public class CraftEventFactory {
|
|||||||
* BlockFadeEvent
|
* BlockFadeEvent
|
||||||
*/
|
*/
|
||||||
public static BlockFadeEvent callBlockFadeEvent(GeneratorAccess world, BlockPosition pos, IBlockData newBlock) {
|
public static BlockFadeEvent callBlockFadeEvent(GeneratorAccess world, BlockPosition pos, IBlockData newBlock) {
|
||||||
CraftBlockState state = CraftBlockState.getBlockState(world, pos);
|
CraftBlockState state = CraftBlockStates.getBlockState(world, pos);
|
||||||
state.setData(newBlock);
|
state.setData(newBlock);
|
||||||
|
|
||||||
BlockFadeEvent event = new BlockFadeEvent(state.getBlock(), state);
|
BlockFadeEvent event = new BlockFadeEvent(state.getBlock(), state);
|
||||||
@ -743,7 +744,7 @@ public class CraftEventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleMoistureChangeEvent(World world, BlockPosition pos, IBlockData newBlock, int flag) {
|
public static boolean handleMoistureChangeEvent(World world, BlockPosition pos, IBlockData newBlock, int flag) {
|
||||||
CraftBlockState state = CraftBlockState.getBlockState(world, pos, flag);
|
CraftBlockState state = CraftBlockStates.getBlockState(world, pos, flag);
|
||||||
state.setData(newBlock);
|
state.setData(newBlock);
|
||||||
|
|
||||||
MoistureChangeEvent event = new MoistureChangeEvent(state.getBlock(), state);
|
MoistureChangeEvent event = new MoistureChangeEvent(state.getBlock(), state);
|
||||||
@ -766,7 +767,7 @@ public class CraftEventFactory {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftBlockState state = CraftBlockState.getBlockState(world, target, flag);
|
CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag);
|
||||||
state.setData(block);
|
state.setData(block);
|
||||||
|
|
||||||
BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, source), state);
|
BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, source), state);
|
||||||
@ -1532,7 +1533,7 @@ public class CraftEventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block, int flag, @Nullable Entity entity) {
|
public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block, int flag, @Nullable Entity entity) {
|
||||||
CraftBlockState blockState = CraftBlockState.getBlockState(world, pos, flag);
|
CraftBlockState blockState = CraftBlockStates.getBlockState(world, pos, flag);
|
||||||
blockState.setData(block);
|
blockState.setData(block);
|
||||||
|
|
||||||
BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState);
|
BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState);
|
||||||
|
@ -3,75 +3,15 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.minecraft.core.BlockPosition;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.item.EnumColor;
|
|
||||||
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBanner;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBarrel;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBeacon;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBeehive;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBell;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityBrewingStand;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityCampfire;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityChest;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityCommand;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityComparator;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityDispenser;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityDropper;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityEnchantTable;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityEndGateway;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityFurnaceFurnace;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityHopper;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityJigsaw;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityJukeBox;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityLectern;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityLightDetector;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityShulkerBox;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntitySign;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntitySkull;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntitySmoker;
|
|
||||||
import net.minecraft.world.level.block.entity.TileEntityStructure;
|
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||||
import org.bukkit.craftbukkit.block.CraftBanner;
|
import org.bukkit.craftbukkit.block.CraftBanner;
|
||||||
import org.bukkit.craftbukkit.block.CraftBarrel;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBeacon;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBeehive;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBell;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBlastFurnace;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBlockEntityState;
|
import org.bukkit.craftbukkit.block.CraftBlockEntityState;
|
||||||
import org.bukkit.craftbukkit.block.CraftBrewingStand;
|
import org.bukkit.craftbukkit.block.CraftBlockStates;
|
||||||
import org.bukkit.craftbukkit.block.CraftCampfire;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftChest;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftCommandBlock;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftComparator;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftDaylightDetector;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftDispenser;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftDropper;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftEnchantingTable;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftEndGateway;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftEnderChest;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftFurnaceFurnace;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftHopper;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftJigsaw;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftJukebox;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftLectern;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftSculkSensor;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftShulkerBox;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftSign;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftSkull;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftSmoker;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftStructureBlock;
|
|
||||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey;
|
import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
@ -305,422 +245,18 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockPosition blockposition = BlockPosition.ZERO;
|
|
||||||
IBlockData iblockdata = CraftMagicNumbers.getBlock(stateMaterial).getBlockData();
|
|
||||||
TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(blockposition, iblockdata, blockEntityTag);
|
|
||||||
|
|
||||||
switch (material) {
|
// This is expected to always return a CraftBlockEntityState for the passed material:
|
||||||
case ACACIA_SIGN:
|
return CraftBlockStates.getBlockState(stateMaterial, blockEntityTag);
|
||||||
case ACACIA_WALL_SIGN:
|
|
||||||
case BIRCH_SIGN:
|
|
||||||
case BIRCH_WALL_SIGN:
|
|
||||||
case CRIMSON_SIGN:
|
|
||||||
case CRIMSON_WALL_SIGN:
|
|
||||||
case DARK_OAK_SIGN:
|
|
||||||
case DARK_OAK_WALL_SIGN:
|
|
||||||
case JUNGLE_SIGN:
|
|
||||||
case JUNGLE_WALL_SIGN:
|
|
||||||
case OAK_SIGN:
|
|
||||||
case OAK_WALL_SIGN:
|
|
||||||
case SPRUCE_SIGN:
|
|
||||||
case SPRUCE_WALL_SIGN:
|
|
||||||
case WARPED_SIGN:
|
|
||||||
case WARPED_WALL_SIGN:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntitySign(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftSign(material, (TileEntitySign) te);
|
|
||||||
case CHEST:
|
|
||||||
case TRAPPED_CHEST:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityChest(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftChest(material, (TileEntityChest) te);
|
|
||||||
case FURNACE:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityFurnaceFurnace(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftFurnaceFurnace(material, (TileEntityFurnaceFurnace) te);
|
|
||||||
case DISPENSER:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityDispenser(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftDispenser(material, (TileEntityDispenser) te);
|
|
||||||
case DROPPER:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityDropper(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftDropper(material, (TileEntityDropper) te);
|
|
||||||
case END_GATEWAY:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityEndGateway(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftEndGateway(material, (TileEntityEndGateway) te);
|
|
||||||
case HOPPER:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityHopper(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftHopper(material, (TileEntityHopper) te);
|
|
||||||
case SPAWNER:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityMobSpawner(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftCreatureSpawner(material, (TileEntityMobSpawner) te);
|
|
||||||
case JUKEBOX:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityJukeBox(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftJukebox(material, (TileEntityJukeBox) te);
|
|
||||||
case BREWING_STAND:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBrewingStand(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBrewingStand(material, (TileEntityBrewingStand) te);
|
|
||||||
case CREEPER_HEAD:
|
|
||||||
case CREEPER_WALL_HEAD:
|
|
||||||
case DRAGON_HEAD:
|
|
||||||
case DRAGON_WALL_HEAD:
|
|
||||||
case PLAYER_HEAD:
|
|
||||||
case PLAYER_WALL_HEAD:
|
|
||||||
case SKELETON_SKULL:
|
|
||||||
case SKELETON_WALL_SKULL:
|
|
||||||
case WITHER_SKELETON_SKULL:
|
|
||||||
case WITHER_SKELETON_WALL_SKULL:
|
|
||||||
case ZOMBIE_HEAD:
|
|
||||||
case ZOMBIE_WALL_HEAD:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntitySkull(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftSkull(material, (TileEntitySkull) te);
|
|
||||||
case COMMAND_BLOCK:
|
|
||||||
case REPEATING_COMMAND_BLOCK:
|
|
||||||
case CHAIN_COMMAND_BLOCK:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityCommand(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftCommandBlock(material, (TileEntityCommand) te);
|
|
||||||
case BEACON:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBeacon(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBeacon(material, (TileEntityBeacon) te);
|
|
||||||
case SHIELD:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBanner(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
((TileEntityBanner) te).baseColor = (blockEntityTag == null) ? EnumColor.WHITE : EnumColor.fromColorIndex(blockEntityTag.getInt(CraftMetaBanner.BASE.NBT));
|
|
||||||
case BLACK_BANNER:
|
|
||||||
case BLACK_WALL_BANNER:
|
|
||||||
case BLUE_BANNER:
|
|
||||||
case BLUE_WALL_BANNER:
|
|
||||||
case BROWN_BANNER:
|
|
||||||
case BROWN_WALL_BANNER:
|
|
||||||
case CYAN_BANNER:
|
|
||||||
case CYAN_WALL_BANNER:
|
|
||||||
case GRAY_BANNER:
|
|
||||||
case GRAY_WALL_BANNER:
|
|
||||||
case GREEN_BANNER:
|
|
||||||
case GREEN_WALL_BANNER:
|
|
||||||
case LIGHT_BLUE_BANNER:
|
|
||||||
case LIGHT_BLUE_WALL_BANNER:
|
|
||||||
case LIGHT_GRAY_BANNER:
|
|
||||||
case LIGHT_GRAY_WALL_BANNER:
|
|
||||||
case LIME_BANNER:
|
|
||||||
case LIME_WALL_BANNER:
|
|
||||||
case MAGENTA_BANNER:
|
|
||||||
case MAGENTA_WALL_BANNER:
|
|
||||||
case ORANGE_BANNER:
|
|
||||||
case ORANGE_WALL_BANNER:
|
|
||||||
case PINK_BANNER:
|
|
||||||
case PINK_WALL_BANNER:
|
|
||||||
case PURPLE_BANNER:
|
|
||||||
case PURPLE_WALL_BANNER:
|
|
||||||
case RED_BANNER:
|
|
||||||
case RED_WALL_BANNER:
|
|
||||||
case WHITE_BANNER:
|
|
||||||
case WHITE_WALL_BANNER:
|
|
||||||
case YELLOW_BANNER:
|
|
||||||
case YELLOW_WALL_BANNER:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBanner(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBanner(material == Material.SHIELD ? shieldToBannerHack(blockEntityTag) : material, (TileEntityBanner) te);
|
|
||||||
case STRUCTURE_BLOCK:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityStructure(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftStructureBlock(material, (TileEntityStructure) te);
|
|
||||||
case SHULKER_BOX:
|
|
||||||
case WHITE_SHULKER_BOX:
|
|
||||||
case ORANGE_SHULKER_BOX:
|
|
||||||
case MAGENTA_SHULKER_BOX:
|
|
||||||
case LIGHT_BLUE_SHULKER_BOX:
|
|
||||||
case YELLOW_SHULKER_BOX:
|
|
||||||
case LIME_SHULKER_BOX:
|
|
||||||
case PINK_SHULKER_BOX:
|
|
||||||
case GRAY_SHULKER_BOX:
|
|
||||||
case LIGHT_GRAY_SHULKER_BOX:
|
|
||||||
case CYAN_SHULKER_BOX:
|
|
||||||
case PURPLE_SHULKER_BOX:
|
|
||||||
case BLUE_SHULKER_BOX:
|
|
||||||
case BROWN_SHULKER_BOX:
|
|
||||||
case GREEN_SHULKER_BOX:
|
|
||||||
case RED_SHULKER_BOX:
|
|
||||||
case BLACK_SHULKER_BOX:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityShulkerBox(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftShulkerBox(material, (TileEntityShulkerBox) te);
|
|
||||||
case ENCHANTING_TABLE:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityEnchantTable(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftEnchantingTable(material, (TileEntityEnchantTable) te);
|
|
||||||
case ENDER_CHEST:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityEnderChest(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftEnderChest(material, (TileEntityEnderChest) te);
|
|
||||||
case DAYLIGHT_DETECTOR:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityLightDetector(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftDaylightDetector(material, (TileEntityLightDetector) te);
|
|
||||||
case COMPARATOR:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityComparator(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftComparator(material, (TileEntityComparator) te);
|
|
||||||
case BARREL:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBarrel(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBarrel(material, (TileEntityBarrel) te);
|
|
||||||
case BELL:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBell(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBell(material, (TileEntityBell) te);
|
|
||||||
case BLAST_FURNACE:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBlastFurnace(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBlastFurnace(material, (TileEntityBlastFurnace) te);
|
|
||||||
case CAMPFIRE:
|
|
||||||
case SOUL_CAMPFIRE:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityCampfire(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftCampfire(material, (TileEntityCampfire) te);
|
|
||||||
case JIGSAW:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityJigsaw(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftJigsaw(material, (TileEntityJigsaw) te);
|
|
||||||
case LECTERN:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityLectern(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftLectern(material, (TileEntityLectern) te);
|
|
||||||
case SMOKER:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntitySmoker(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftSmoker(material, (TileEntitySmoker) te);
|
|
||||||
case BEE_NEST:
|
|
||||||
case BEEHIVE:
|
|
||||||
if (te == null) {
|
|
||||||
te = new TileEntityBeehive(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftBeehive(material, (TileEntityBeehive) te);
|
|
||||||
case SCULK_SENSOR:
|
|
||||||
if (te == null) {
|
|
||||||
te = new SculkSensorBlockEntity(blockposition, iblockdata);
|
|
||||||
}
|
|
||||||
return new CraftSculkSensor(material, (SculkSensorBlockEntity) te);
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Missing blockState for " + material);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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");
|
||||||
|
|
||||||
boolean valid;
|
Material stateMaterial = (material != Material.SHIELD) ? material : shieldToBannerHack(blockEntityTag);
|
||||||
switch (material) {
|
Class<?> blockStateType = CraftBlockStates.getBlockStateType(stateMaterial);
|
||||||
case ACACIA_SIGN:
|
Validate.isTrue(blockStateType == blockState.getClass() && blockState instanceof CraftBlockEntityState, "Invalid blockState for " + material);
|
||||||
case ACACIA_WALL_SIGN:
|
|
||||||
case BIRCH_SIGN:
|
|
||||||
case BIRCH_WALL_SIGN:
|
|
||||||
case CRIMSON_SIGN:
|
|
||||||
case CRIMSON_WALL_SIGN:
|
|
||||||
case DARK_OAK_SIGN:
|
|
||||||
case DARK_OAK_WALL_SIGN:
|
|
||||||
case JUNGLE_SIGN:
|
|
||||||
case JUNGLE_WALL_SIGN:
|
|
||||||
case OAK_SIGN:
|
|
||||||
case OAK_WALL_SIGN:
|
|
||||||
case SPRUCE_SIGN:
|
|
||||||
case SPRUCE_WALL_SIGN:
|
|
||||||
case WARPED_SIGN:
|
|
||||||
case WARPED_WALL_SIGN:
|
|
||||||
valid = blockState instanceof CraftSign;
|
|
||||||
break;
|
|
||||||
case CHEST:
|
|
||||||
case TRAPPED_CHEST:
|
|
||||||
valid = blockState instanceof CraftChest;
|
|
||||||
break;
|
|
||||||
case FURNACE:
|
|
||||||
valid = blockState instanceof CraftFurnaceFurnace;
|
|
||||||
break;
|
|
||||||
case DISPENSER:
|
|
||||||
valid = blockState instanceof CraftDispenser;
|
|
||||||
break;
|
|
||||||
case DROPPER:
|
|
||||||
valid = blockState instanceof CraftDropper;
|
|
||||||
break;
|
|
||||||
case END_GATEWAY:
|
|
||||||
valid = blockState instanceof CraftEndGateway;
|
|
||||||
break;
|
|
||||||
case HOPPER:
|
|
||||||
valid = blockState instanceof CraftHopper;
|
|
||||||
break;
|
|
||||||
case SPAWNER:
|
|
||||||
valid = blockState instanceof CraftCreatureSpawner;
|
|
||||||
break;
|
|
||||||
case JUKEBOX:
|
|
||||||
valid = blockState instanceof CraftJukebox;
|
|
||||||
break;
|
|
||||||
case BREWING_STAND:
|
|
||||||
valid = blockState instanceof CraftBrewingStand;
|
|
||||||
break;
|
|
||||||
case CREEPER_HEAD:
|
|
||||||
case CREEPER_WALL_HEAD:
|
|
||||||
case DRAGON_HEAD:
|
|
||||||
case DRAGON_WALL_HEAD:
|
|
||||||
case PLAYER_HEAD:
|
|
||||||
case PLAYER_WALL_HEAD:
|
|
||||||
case SKELETON_SKULL:
|
|
||||||
case SKELETON_WALL_SKULL:
|
|
||||||
case WITHER_SKELETON_SKULL:
|
|
||||||
case WITHER_SKELETON_WALL_SKULL:
|
|
||||||
case ZOMBIE_HEAD:
|
|
||||||
case ZOMBIE_WALL_HEAD:
|
|
||||||
valid = blockState instanceof CraftSkull;
|
|
||||||
break;
|
|
||||||
case COMMAND_BLOCK:
|
|
||||||
case REPEATING_COMMAND_BLOCK:
|
|
||||||
case CHAIN_COMMAND_BLOCK:
|
|
||||||
valid = blockState instanceof CraftCommandBlock;
|
|
||||||
break;
|
|
||||||
case BEACON:
|
|
||||||
valid = blockState instanceof CraftBeacon;
|
|
||||||
break;
|
|
||||||
case SHIELD:
|
|
||||||
case BLACK_BANNER:
|
|
||||||
case BLACK_WALL_BANNER:
|
|
||||||
case BLUE_BANNER:
|
|
||||||
case BLUE_WALL_BANNER:
|
|
||||||
case BROWN_BANNER:
|
|
||||||
case BROWN_WALL_BANNER:
|
|
||||||
case CYAN_BANNER:
|
|
||||||
case CYAN_WALL_BANNER:
|
|
||||||
case GRAY_BANNER:
|
|
||||||
case GRAY_WALL_BANNER:
|
|
||||||
case GREEN_BANNER:
|
|
||||||
case GREEN_WALL_BANNER:
|
|
||||||
case LIGHT_BLUE_BANNER:
|
|
||||||
case LIGHT_BLUE_WALL_BANNER:
|
|
||||||
case LIGHT_GRAY_BANNER:
|
|
||||||
case LIGHT_GRAY_WALL_BANNER:
|
|
||||||
case LIME_BANNER:
|
|
||||||
case LIME_WALL_BANNER:
|
|
||||||
case MAGENTA_BANNER:
|
|
||||||
case MAGENTA_WALL_BANNER:
|
|
||||||
case ORANGE_BANNER:
|
|
||||||
case ORANGE_WALL_BANNER:
|
|
||||||
case PINK_BANNER:
|
|
||||||
case PINK_WALL_BANNER:
|
|
||||||
case PURPLE_BANNER:
|
|
||||||
case PURPLE_WALL_BANNER:
|
|
||||||
case RED_BANNER:
|
|
||||||
case RED_WALL_BANNER:
|
|
||||||
case WHITE_BANNER:
|
|
||||||
case WHITE_WALL_BANNER:
|
|
||||||
case YELLOW_BANNER:
|
|
||||||
case YELLOW_WALL_BANNER:
|
|
||||||
valid = blockState instanceof CraftBanner;
|
|
||||||
break;
|
|
||||||
case STRUCTURE_BLOCK:
|
|
||||||
valid = blockState instanceof CraftStructureBlock;
|
|
||||||
break;
|
|
||||||
case SHULKER_BOX:
|
|
||||||
case WHITE_SHULKER_BOX:
|
|
||||||
case ORANGE_SHULKER_BOX:
|
|
||||||
case MAGENTA_SHULKER_BOX:
|
|
||||||
case LIGHT_BLUE_SHULKER_BOX:
|
|
||||||
case YELLOW_SHULKER_BOX:
|
|
||||||
case LIME_SHULKER_BOX:
|
|
||||||
case PINK_SHULKER_BOX:
|
|
||||||
case GRAY_SHULKER_BOX:
|
|
||||||
case LIGHT_GRAY_SHULKER_BOX:
|
|
||||||
case CYAN_SHULKER_BOX:
|
|
||||||
case PURPLE_SHULKER_BOX:
|
|
||||||
case BLUE_SHULKER_BOX:
|
|
||||||
case BROWN_SHULKER_BOX:
|
|
||||||
case GREEN_SHULKER_BOX:
|
|
||||||
case RED_SHULKER_BOX:
|
|
||||||
case BLACK_SHULKER_BOX:
|
|
||||||
valid = blockState instanceof CraftShulkerBox;
|
|
||||||
break;
|
|
||||||
case ENCHANTING_TABLE:
|
|
||||||
valid = blockState instanceof CraftEnchantingTable;
|
|
||||||
break;
|
|
||||||
case ENDER_CHEST:
|
|
||||||
valid = blockState instanceof CraftEnderChest;
|
|
||||||
break;
|
|
||||||
case DAYLIGHT_DETECTOR:
|
|
||||||
valid = blockState instanceof CraftDaylightDetector;
|
|
||||||
break;
|
|
||||||
case COMPARATOR:
|
|
||||||
valid = blockState instanceof CraftComparator;
|
|
||||||
break;
|
|
||||||
case BARREL:
|
|
||||||
valid = blockState instanceof CraftBarrel;
|
|
||||||
break;
|
|
||||||
case BELL:
|
|
||||||
valid = blockState instanceof CraftBell;
|
|
||||||
break;
|
|
||||||
case BLAST_FURNACE:
|
|
||||||
valid = blockState instanceof CraftBlastFurnace;
|
|
||||||
break;
|
|
||||||
case CAMPFIRE:
|
|
||||||
case SOUL_CAMPFIRE:
|
|
||||||
valid = blockState instanceof CraftCampfire;
|
|
||||||
break;
|
|
||||||
case JIGSAW:
|
|
||||||
valid = blockState instanceof CraftJigsaw;
|
|
||||||
break;
|
|
||||||
case LECTERN:
|
|
||||||
valid = blockState instanceof CraftLectern;
|
|
||||||
break;
|
|
||||||
case SMOKER:
|
|
||||||
valid = blockState instanceof CraftSmoker;
|
|
||||||
break;
|
|
||||||
case BEEHIVE:
|
|
||||||
case BEE_NEST:
|
|
||||||
valid = blockState instanceof CraftBeehive;
|
|
||||||
break;
|
|
||||||
case SCULK_SENSOR:
|
|
||||||
valid = blockState instanceof CraftSculkSensor;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
valid = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Validate.isTrue(valid, "Invalid blockState for " + material);
|
|
||||||
|
|
||||||
blockEntityTag = ((CraftBlockEntityState) blockState).getSnapshotNBT();
|
blockEntityTag = ((CraftBlockEntityState) blockState).getSnapshotNBT();
|
||||||
// Set shield base
|
// Set shield base
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import net.minecraft.core.IRegistry;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.ITileEntity;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.support.AbstractTestingBase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class BlockStateTest extends AbstractTestingBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTileEntityBlockStates() {
|
||||||
|
for (Block block : IRegistry.BLOCK) {
|
||||||
|
Material material = CraftMagicNumbers.getMaterial(block);
|
||||||
|
Class<?> blockStateType = CraftBlockStates.getBlockStateType(material);
|
||||||
|
boolean isCraftBlockEntityState = CraftBlockEntityState.class.isAssignableFrom(blockStateType);
|
||||||
|
|
||||||
|
if (block instanceof ITileEntity) {
|
||||||
|
assertTrue(material + " has BlockState of type " + blockStateType.getName() + ", but expected subtype of CraftBlockEntityState", isCraftBlockEntityState);
|
||||||
|
} else {
|
||||||
|
assertTrue(material + " has unexpected CraftBlockEntityState subytype " + blockStateType.getName() + " (but is not a tile)", !isCraftBlockEntityState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user