Fix/improve the last upstream update (#6780)
This commit is contained in:
parent
c1644521c9
commit
a55617d9ce
6 changed files with 216 additions and 141 deletions
|
@ -244,3 +244,6 @@ public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations fromBukkitS
|
||||||
|
|
||||||
# Add methods to find targets for lightning strikes
|
# Add methods to find targets for lightning strikes
|
||||||
public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional;
|
public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional;
|
||||||
|
|
||||||
|
# Improve CraftBlockStates
|
||||||
|
public net.minecraft.world.level.block.entity.BlockEntityType validBlocks
|
||||||
|
|
|
@ -9,8 +9,21 @@ block at the position, not the tile entity. This change prioritizes using the
|
||||||
tile entity type to determine the block state factory and falls back on
|
tile entity type to determine the block state factory and falls back on
|
||||||
the material type of the block at that location.
|
the material type of the block at that location.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||||
|
index 38c4dac82793930777eaf0189c5534234a9162ed..9b4a464fe820effa906af486cf71a74e283ccd4e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||||
|
@@ -232,7 +232,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
|
||||||
|
// Paper end
|
||||||
|
if (this.level == null) return null;
|
||||||
|
org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
|
||||||
|
- if (block.getType() == org.bukkit.Material.AIR) return null;
|
||||||
|
+ // if (block.getType() == org.bukkit.Material.AIR) return null; // Paper - actually get the tile entity if it still exists
|
||||||
|
org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper
|
||||||
|
if (state instanceof InventoryHolder) return (InventoryHolder) state;
|
||||||
|
return null;
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
||||||
index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b86b35fe2 100644
|
index b794e04036df00dd9633b9bd808591f499238387..0356c33bc14bef73a7468d5360ea5cd309d5f623 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
|
||||||
@@ -19,6 +19,7 @@ import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
|
@@ -19,6 +19,7 @@ import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
|
||||||
|
@ -21,7 +34,12 @@ index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b
|
||||||
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
|
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
|
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||||
@@ -110,6 +111,12 @@ public final class CraftBlockStates {
|
@@ -106,183 +107,54 @@ public final class CraftBlockStates {
|
||||||
|
@Override
|
||||||
|
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
|
||||||
|
// When a block is being destroyed, the TileEntity may temporarily still exist while the block's type has already been set to AIR. We ignore the TileEntity in this case.
|
||||||
|
- Preconditions.checkState(tileEntity == null || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
|
||||||
|
+ Preconditions.checkState(tileEntity == null/* || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR*/, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); // Paper - don't ignore the TileEntity while its still valid
|
||||||
return new CraftBlockState(world, blockPosition, blockData);
|
return new CraftBlockState(world, blockPosition, blockData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,72 +51,143 @@ index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
static {
|
static {
|
||||||
register(
|
- register(
|
||||||
@@ -130,7 +137,7 @@ public final class CraftBlockStates {
|
- Arrays.asList(
|
||||||
Material.SPRUCE_WALL_SIGN,
|
- Material.ACACIA_SIGN,
|
||||||
Material.WARPED_SIGN,
|
- Material.ACACIA_WALL_SIGN,
|
||||||
Material.WARPED_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, SignBlockEntity::new
|
- ), CraftSign.class, CraftSign::new, SignBlockEntity::new
|
||||||
+ ), BlockEntityType.SIGN, CraftSign.class, CraftSign::new, SignBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
@@ -147,7 +154,7 @@ public final class CraftBlockStates {
|
- Material.CREEPER_HEAD,
|
||||||
Material.WITHER_SKELETON_WALL_SKULL,
|
- Material.CREEPER_WALL_HEAD,
|
||||||
Material.ZOMBIE_HEAD,
|
- Material.DRAGON_HEAD,
|
||||||
Material.ZOMBIE_WALL_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, SkullBlockEntity::new
|
- ), CraftSkull.class, CraftSkull::new, SkullBlockEntity::new
|
||||||
+ ), BlockEntityType.SKULL, CraftSkull.class, CraftSkull::new, SkullBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
@@ -155,7 +162,7 @@ public final class CraftBlockStates {
|
- Material.COMMAND_BLOCK,
|
||||||
Material.COMMAND_BLOCK,
|
- Material.REPEATING_COMMAND_BLOCK,
|
||||||
Material.REPEATING_COMMAND_BLOCK,
|
- Material.CHAIN_COMMAND_BLOCK
|
||||||
Material.CHAIN_COMMAND_BLOCK
|
|
||||||
- ), CraftCommandBlock.class, CraftCommandBlock::new, CommandBlockEntity::new
|
- ), CraftCommandBlock.class, CraftCommandBlock::new, CommandBlockEntity::new
|
||||||
+ ), BlockEntityType.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new, CommandBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
@@ -192,7 +199,7 @@ public final class CraftBlockStates {
|
- Material.BLACK_BANNER,
|
||||||
Material.WHITE_WALL_BANNER,
|
- Material.BLACK_WALL_BANNER,
|
||||||
Material.YELLOW_BANNER,
|
- Material.BLUE_BANNER,
|
||||||
Material.YELLOW_WALL_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, BannerBlockEntity::new
|
- ), CraftBanner.class, CraftBanner::new, BannerBlockEntity::new
|
||||||
+ ), BlockEntityType.BANNER, CraftBanner.class, CraftBanner::new, BannerBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
@@ -214,7 +221,7 @@ public final class CraftBlockStates {
|
- Material.SHULKER_BOX,
|
||||||
Material.GREEN_SHULKER_BOX,
|
- Material.WHITE_SHULKER_BOX,
|
||||||
Material.RED_SHULKER_BOX,
|
- Material.ORANGE_SHULKER_BOX,
|
||||||
Material.BLACK_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, ShulkerBoxBlockEntity::new
|
- ), CraftShulkerBox.class, CraftShulkerBox::new, ShulkerBoxBlockEntity::new
|
||||||
+ ), BlockEntityType.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new, ShulkerBoxBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
@@ -235,54 +242,51 @@ public final class CraftBlockStates {
|
- Material.BLACK_BED,
|
||||||
Material.RED_BED,
|
- Material.BLUE_BED,
|
||||||
Material.WHITE_BED,
|
- Material.BROWN_BED,
|
||||||
Material.YELLOW_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, BedBlockEntity::new
|
- ), CraftBed.class, CraftBed::new, BedBlockEntity::new
|
||||||
+ ), BlockEntityType.BED, CraftBed.class, CraftBed::new, BedBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
Arrays.asList(
|
- Material.BEEHIVE,
|
||||||
Material.BEEHIVE,
|
- Material.BEE_NEST
|
||||||
Material.BEE_NEST
|
|
||||||
- ), CraftBeehive.class, CraftBeehive::new, BeehiveBlockEntity::new
|
- ), CraftBeehive.class, CraftBeehive::new, BeehiveBlockEntity::new
|
||||||
+ ), BlockEntityType.BEEHIVE, CraftBeehive.class, CraftBeehive::new, BeehiveBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
- register(
|
||||||
register(
|
- Arrays.asList(
|
||||||
Arrays.asList(
|
- Material.CAMPFIRE,
|
||||||
Material.CAMPFIRE,
|
- Material.SOUL_CAMPFIRE
|
||||||
Material.SOUL_CAMPFIRE
|
|
||||||
- ), CraftCampfire.class, CraftCampfire::new, CampfireBlockEntity::new
|
- ), CraftCampfire.class, CraftCampfire::new, CampfireBlockEntity::new
|
||||||
- );
|
- );
|
||||||
-
|
-
|
||||||
|
@ -107,9 +196,8 @@ index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b
|
||||||
- Material.CHEST,
|
- Material.CHEST,
|
||||||
- Material.TRAPPED_CHEST
|
- Material.TRAPPED_CHEST
|
||||||
- ), CraftChest.class, CraftChest::new, ChestBlockEntity::new
|
- ), CraftChest.class, CraftChest::new, ChestBlockEntity::new
|
||||||
+ ), BlockEntityType.CAMPFIRE, CraftCampfire.class, CraftCampfire::new, CampfireBlockEntity::new // Paper
|
- );
|
||||||
);
|
-
|
||||||
|
|
||||||
- register(Material.BARREL, CraftBarrel.class, CraftBarrel::new, BarrelBlockEntity::new);
|
- register(Material.BARREL, CraftBarrel.class, CraftBarrel::new, BarrelBlockEntity::new);
|
||||||
- register(Material.BEACON, CraftBeacon.class, CraftBeacon::new, BeaconBlockEntity::new);
|
- register(Material.BEACON, CraftBeacon.class, CraftBeacon::new, BeaconBlockEntity::new);
|
||||||
- register(Material.BELL, CraftBell.class, CraftBell::new, BellBlockEntity::new);
|
- register(Material.BELL, CraftBell.class, CraftBell::new, BellBlockEntity::new);
|
||||||
|
@ -134,61 +222,75 @@ index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b
|
||||||
- register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, SmokerBlockEntity::new);
|
- register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, SmokerBlockEntity::new);
|
||||||
- register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, SpawnerBlockEntity::new);
|
- register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, SpawnerBlockEntity::new);
|
||||||
- register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, StructureBlockEntity::new);
|
- register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, StructureBlockEntity::new);
|
||||||
+ // Paper start
|
+ // Paper start - simplify
|
||||||
+ register(Material.CHEST, BlockEntityType.CHEST, CraftChest.class, CraftChest::new, ChestBlockEntity::new); // Paper - split up chests due to different block entity types
|
+ register(BlockEntityType.SIGN, CraftSign.class, CraftSign::new);
|
||||||
+ register(Material.TRAPPED_CHEST, BlockEntityType.TRAPPED_CHEST, CraftChest.class, CraftChest::new, net.minecraft.world.level.block.entity.TrappedChestBlockEntity::new); // Paper - split up chests due to different block entity types
|
+ register(BlockEntityType.SKULL, CraftSkull.class, CraftSkull::new);
|
||||||
+ register(Material.BARREL, BlockEntityType.BARREL, CraftBarrel.class, CraftBarrel::new, BarrelBlockEntity::new);
|
+ register(BlockEntityType.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new);
|
||||||
+ register(Material.BEACON, BlockEntityType.BEACON, CraftBeacon.class, CraftBeacon::new, BeaconBlockEntity::new);
|
+ register(BlockEntityType.BANNER, CraftBanner.class, CraftBanner::new);
|
||||||
+ register(Material.BELL, BlockEntityType.BELL, CraftBell.class, CraftBell::new, BellBlockEntity::new);
|
+ register(BlockEntityType.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new);
|
||||||
+ register(Material.BLAST_FURNACE, BlockEntityType.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new, BlastFurnaceBlockEntity::new);
|
+ register(BlockEntityType.BED, CraftBed.class, CraftBed::new);
|
||||||
+ register(Material.BREWING_STAND, BlockEntityType.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new, BrewingStandBlockEntity::new);
|
+ register(BlockEntityType.BEEHIVE, CraftBeehive.class, CraftBeehive::new);
|
||||||
+ register(Material.COMPARATOR, BlockEntityType.COMPARATOR, CraftComparator.class, CraftComparator::new, ComparatorBlockEntity::new);
|
+ register(BlockEntityType.CAMPFIRE, CraftCampfire.class, CraftCampfire::new);
|
||||||
+ register(Material.CONDUIT, BlockEntityType.CONDUIT, CraftConduit.class, CraftConduit::new, ConduitBlockEntity::new);
|
+ register(BlockEntityType.CHEST, CraftChest.class, CraftChest::new); // Paper - split up chests due to different block entity types
|
||||||
+ register(Material.DAYLIGHT_DETECTOR, BlockEntityType.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, DaylightDetectorBlockEntity::new);
|
+ register(BlockEntityType.TRAPPED_CHEST, CraftChest.class, CraftChest::new); // Paper - split up chests due to different block entity types
|
||||||
+ register(Material.DISPENSER, BlockEntityType.DISPENSER, CraftDispenser.class, CraftDispenser::new, DispenserBlockEntity::new);
|
+ register(BlockEntityType.BARREL, CraftBarrel.class, CraftBarrel::new);
|
||||||
+ register(Material.DROPPER, BlockEntityType.DROPPER, CraftDropper.class, CraftDropper::new, DropperBlockEntity::new);
|
+ register(BlockEntityType.BEACON, CraftBeacon.class, CraftBeacon::new);
|
||||||
+ register(Material.ENCHANTING_TABLE, BlockEntityType.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new, EnchantmentTableBlockEntity::new);
|
+ register(BlockEntityType.BELL, CraftBell.class, CraftBell::new);
|
||||||
+ register(Material.ENDER_CHEST, BlockEntityType.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new, EnderChestBlockEntity::new);
|
+ register(BlockEntityType.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new);
|
||||||
+ register(Material.END_GATEWAY, BlockEntityType.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new, TheEndGatewayBlockEntity::new);
|
+ register(BlockEntityType.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new);
|
||||||
+ register(Material.END_PORTAL, BlockEntityType.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new, TheEndPortalBlockEntity::new);
|
+ register(BlockEntityType.COMPARATOR, CraftComparator.class, CraftComparator::new);
|
||||||
+ register(Material.FURNACE, BlockEntityType.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new, FurnaceBlockEntity::new);
|
+ register(BlockEntityType.CONDUIT, CraftConduit.class, CraftConduit::new);
|
||||||
+ register(Material.HOPPER, BlockEntityType.HOPPER, CraftHopper.class, CraftHopper::new, HopperBlockEntity::new);
|
+ register(BlockEntityType.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new);
|
||||||
+ register(Material.JIGSAW, BlockEntityType.JIGSAW, CraftJigsaw.class, CraftJigsaw::new, JigsawBlockEntity::new);
|
+ register(BlockEntityType.DISPENSER, CraftDispenser.class, CraftDispenser::new);
|
||||||
+ register(Material.JUKEBOX, BlockEntityType.JUKEBOX, CraftJukebox.class, CraftJukebox::new, JukeboxBlockEntity::new);
|
+ register(BlockEntityType.DROPPER, CraftDropper.class, CraftDropper::new);
|
||||||
+ register(Material.LECTERN, BlockEntityType.LECTERN, CraftLectern.class, CraftLectern::new, LecternBlockEntity::new);
|
+ register(BlockEntityType.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new);
|
||||||
+ register(Material.MOVING_PISTON, BlockEntityType.PISTON, CraftMovingPiston.class, CraftMovingPiston::new, PistonMovingBlockEntity::new);
|
+ register(BlockEntityType.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new);
|
||||||
+ register(Material.SCULK_SENSOR, BlockEntityType.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new, SculkSensorBlockEntity::new);
|
+ register(BlockEntityType.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new);
|
||||||
+ register(Material.SMOKER, BlockEntityType.SMOKER, CraftSmoker.class, CraftSmoker::new, SmokerBlockEntity::new);
|
+ register(BlockEntityType.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new);
|
||||||
+ register(Material.SPAWNER, BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, SpawnerBlockEntity::new);
|
+ register(BlockEntityType.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new);
|
||||||
+ register(Material.STRUCTURE_BLOCK, BlockEntityType.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, StructureBlockEntity::new);
|
+ register(BlockEntityType.HOPPER, CraftHopper.class, CraftHopper::new);
|
||||||
|
+ register(BlockEntityType.JIGSAW, CraftJigsaw.class, CraftJigsaw::new);
|
||||||
|
+ register(BlockEntityType.JUKEBOX, CraftJukebox.class, CraftJukebox::new);
|
||||||
|
+ register(BlockEntityType.LECTERN, CraftLectern.class, CraftLectern::new);
|
||||||
|
+ register(BlockEntityType.PISTON, CraftMovingPiston.class, CraftMovingPiston::new);
|
||||||
|
+ register(BlockEntityType.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new);
|
||||||
|
+ register(BlockEntityType.SMOKER, CraftSmoker.class, CraftSmoker::new);
|
||||||
|
+ register(BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new);
|
||||||
|
+ register(BlockEntityType.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(Material blockType, BlockStateFactory<?> factory) {
|
private static void register(Material blockType, BlockStateFactory<?> factory) {
|
||||||
@@ -291,15 +295,17 @@ public final class CraftBlockStates {
|
@@ -290,35 +162,45 @@ public final class CraftBlockStates {
|
||||||
|
}
|
||||||
|
|
||||||
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
|
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
|
||||||
Material blockType,
|
- Material blockType,
|
||||||
+ net.minecraft.world.level.block.entity.BlockEntityType<?> blockEntityType, // Paper
|
+ net.minecraft.world.level.block.entity.BlockEntityType<? extends T> blockEntityType, // Paper
|
||||||
Class<B> blockStateType,
|
Class<B> blockStateType,
|
||||||
BiFunction<World, T, B> blockStateConstructor,
|
- BiFunction<World, T, B> blockStateConstructor,
|
||||||
BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
|
- BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
|
||||||
|
+ BiFunction<World, T, B> blockStateConstructor // Paper
|
||||||
) {
|
) {
|
||||||
- CraftBlockStates.register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
|
- CraftBlockStates.register(Collections.singletonList(blockType), blockStateType, blockStateConstructor, tileEntityConstructor);
|
||||||
+ CraftBlockStates.register(Collections.singletonList(blockType), blockEntityType, blockStateType, blockStateConstructor, tileEntityConstructor); // Paper
|
- }
|
||||||
|
-
|
||||||
|
- private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
|
||||||
|
- List<Material> blockTypes,
|
||||||
|
- Class<B> blockStateType,
|
||||||
|
- BiFunction<World, T, B> blockStateConstructor,
|
||||||
|
- BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
|
||||||
|
- ) {
|
||||||
|
- BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, tileEntityConstructor);
|
||||||
|
- for (Material blockType : blockTypes) {
|
||||||
|
- CraftBlockStates.register(blockType, factory);
|
||||||
|
+ // Paper start
|
||||||
|
+ BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, blockEntityType::create);
|
||||||
|
+ for (net.minecraft.world.level.block.Block block : blockEntityType.validBlocks) {
|
||||||
|
+ CraftBlockStates.register(CraftMagicNumbers.getMaterial(block), factory);
|
||||||
}
|
}
|
||||||
|
+ CraftBlockStates.register(blockEntityType, factory);
|
||||||
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
|
+ // Paper end
|
||||||
List<Material> blockTypes,
|
|
||||||
+ net.minecraft.world.level.block.entity.BlockEntityType<?> blockEntityType, // Paper
|
|
||||||
Class<B> blockStateType,
|
|
||||||
BiFunction<World, T, B> blockStateConstructor,
|
|
||||||
BiFunction<BlockPos, net.minecraft.world.level.block.state.BlockState, T> tileEntityConstructor
|
|
||||||
@@ -308,17 +314,35 @@ public final class CraftBlockStates {
|
|
||||||
for (Material blockType : blockTypes) {
|
|
||||||
CraftBlockStates.register(blockType, factory);
|
|
||||||
}
|
|
||||||
+ CraftBlockStates.register(blockEntityType, factory); // Paper
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockStateFactory<?> getFactory(Material material) {
|
private static BlockStateFactory<?> getFactory(Material material) {
|
||||||
|
@ -220,7 +322,7 @@ index b794e04036df00dd9633b9bd808591f499238387..a20505b6badaf2d709bd95fa01d0617b
|
||||||
public static BlockState getBlockState(Block block) {
|
public static BlockState getBlockState(Block block) {
|
||||||
Preconditions.checkNotNull(block, "block is null");
|
Preconditions.checkNotNull(block, "block is null");
|
||||||
CraftBlock craftBlock = (CraftBlock) block;
|
CraftBlock craftBlock = (CraftBlock) block;
|
||||||
@@ -361,7 +385,7 @@ public final class CraftBlockStates {
|
@@ -361,7 +243,7 @@ public final class CraftBlockStates {
|
||||||
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
|
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
|
||||||
factory = CraftBlockStates.DEFAULT_FACTORY;
|
factory = CraftBlockStates.DEFAULT_FACTORY;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
||||||
Date: Thu, 7 Oct 2021 20:49:13 -0700
|
|
||||||
Subject: [PATCH] Fix unplaced block states after new chunk gen API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
|
|
||||||
index e00210950cbf005b0e65aed68dfbb7c281aefd87..b4a10c1ef095faaefbedc2a1fd84aea721a4ba98 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
|
|
||||||
@@ -65,6 +65,7 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
|
||||||
List<Bee> bees = new ArrayList<>();
|
|
||||||
|
|
||||||
if (isPlaced()) {
|
|
||||||
+ Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't release entities during world generation"); // Paper - don't fail if block isnt placed, this method did not use to fail
|
|
||||||
BeehiveBlockEntity beehive = ((BeehiveBlockEntity) this.getTileEntityFromWorld());
|
|
||||||
for (Entity bee : beehive.releaseBees(this.getHandle(), BeeReleaseStatus.BEE_RELEASED, true)) {
|
|
||||||
bees.add((Bee) bee.getBukkitEntity());
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
|
||||||
index 9806697cb7566c5af1df74b7eaa8088d19ee4fdc..ad833481414d3b60bdbcf87727b494ecff84f2c3 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
|
||||||
@@ -42,6 +42,7 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
|
|
||||||
if (!isPlaced() || isWorldGeneration()) {
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
+ Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't get inventory during world generation, use getBlockInventory() instead"); // Paper - move after placed check
|
|
||||||
|
|
||||||
// The logic here is basically identical to the logic in BlockChest.interact
|
|
||||||
CraftWorld world = (CraftWorld) this.getWorld();
|
|
Loading…
Reference in a new issue