Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -1,7 +0,0 @@
--- a/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java
+++ b/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java
@@ -1,3 +1,4 @@
+// keep
package net.minecraft.world.level.levelgen;
import com.google.common.annotations.VisibleForTesting;

View File

@@ -1,22 +0,0 @@
--- a/net/minecraft/world/level/levelgen/ChunkProviderFlat.java
+++ b/net/minecraft/world/level/levelgen/ChunkProviderFlat.java
@@ -34,10 +34,16 @@
private final GeneratorSettingsFlat settings;
public ChunkProviderFlat(GeneratorSettingsFlat generatorsettingsflat) {
- WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome());
+ // CraftBukkit start
+ // WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome());
- Objects.requireNonNull(generatorsettingsflat);
- super(worldchunkmanagerhell, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings));
+ // Objects.requireNonNull(generatorsettingsflat);
+ this(generatorsettingsflat, new WorldChunkManagerHell(generatorsettingsflat.getBiome()));
+ }
+
+ public ChunkProviderFlat(GeneratorSettingsFlat generatorsettingsflat, net.minecraft.world.level.biome.WorldChunkManager worldchunkmanager) {
+ super(worldchunkmanager, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings));
+ // CraftBukkit end
this.settings = generatorsettingsflat;
}

View File

@@ -0,0 +1,26 @@
--- a/net/minecraft/world/level/levelgen/FlatLevelSource.java
+++ b/net/minecraft/world/level/levelgen/FlatLevelSource.java
@@ -34,13 +34,19 @@
private final FlatLevelGeneratorSettings settings;
public FlatLevelSource(FlatLevelGeneratorSettings config) {
- FixedBiomeSource worldchunkmanagerhell = new FixedBiomeSource(config.getBiome());
+ // CraftBukkit start
+ // WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome());
- Objects.requireNonNull(config);
- super(worldchunkmanagerhell, Util.memoize(config::adjustGenerationSettings));
- this.settings = config;
+ // Objects.requireNonNull(generatorsettingsflat);
+ this(config, new FixedBiomeSource(config.getBiome()));
}
+ public FlatLevelSource(FlatLevelGeneratorSettings generatorsettingsflat, net.minecraft.world.level.biome.BiomeSource worldchunkmanager) {
+ super(worldchunkmanager, Util.memoize(generatorsettingsflat::adjustGenerationSettings));
+ // CraftBukkit end
+ this.settings = generatorsettingsflat;
+ }
+
@Override
public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> structureSetRegistry, RandomState noiseConfig, long seed) {
Stream<Holder<StructureSet>> stream = (Stream) this.settings.structureOverrides().map(HolderSet::stream).orElseGet(() -> {

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java
+++ b/net/minecraft/world/level/levelgen/MobSpawnerPatrol.java
@@ -116,7 +116,7 @@
entitymonsterpatrolling.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
entitymonsterpatrolling.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(blockposition), EntitySpawnReason.PATROL, (GroupDataEntity) null);
- worldserver.addFreshEntityWithPassengers(entitymonsterpatrolling);
+ worldserver.addFreshEntityWithPassengers(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit
return true;
} else {
return false;

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
+++ b/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
@@ -74,7 +74,7 @@
if (entityphantom != null) {
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
groupdataentity = entityphantom.finalizeSpawn(worldserver, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity);
- worldserver.addFreshEntityWithPassengers(entityphantom);
+ worldserver.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
++i;
}
}

View File

@@ -0,0 +1,7 @@
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
@@ -1,3 +1,4 @@
+// keep
package net.minecraft.world.level.levelgen;
import com.google.common.annotations.VisibleForTesting;

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/levelgen/PatrolSpawner.java
+++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java
@@ -116,7 +116,7 @@
entitymonsterpatrolling.setPos((double) pos.getX(), (double) pos.getY(), (double) pos.getZ());
entitymonsterpatrolling.finalizeSpawn(world, world.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, (SpawnGroupData) null);
- world.addFreshEntityWithPassengers(entitymonsterpatrolling);
+ world.addFreshEntityWithPassengers(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit
return true;
} else {
return false;

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java
+++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java
@@ -74,7 +74,7 @@
if (entityphantom != null) {
entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity);
- world.addFreshEntityWithPassengers(entityphantom);
+ world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
++i;
}
}

View File

@@ -1,45 +1,48 @@
--- a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
+++ b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
@@ -8,6 +8,12 @@
@@ -7,6 +7,11 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.feature.configurations.WorldGenFeatureEmptyConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.block.BlockState;
+import org.bukkit.event.world.PortalCreateEvent;
+// CraftBukkit end
+
public class EndPlatformFeature extends WorldGenerator<WorldGenFeatureEmptyConfiguration> {
public EndPlatformFeature(Codec<WorldGenFeatureEmptyConfiguration> codec) {
@@ -21,6 +27,13 @@
public class EndPlatformFeature extends Feature<NoneFeatureConfiguration> {
@@ -21,24 +26,51 @@
}
public static void createEndPlatform(WorldAccess worldaccess, BlockPosition blockposition, boolean flag) {
+ createEndPlatform(worldaccess, blockposition, flag, null);
public static void createEndPlatform(ServerLevelAccessor world, BlockPos pos, boolean breakBlocks) {
- BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
+ EndPlatformFeature.createEndPlatform(world, pos, breakBlocks, null);
+ // CraftBukkit start
+ }
+
+ public static void createEndPlatform(WorldAccess worldaccess, BlockPosition blockposition, boolean flag, Entity entity) {
+ public static void createEndPlatform(ServerLevelAccessor worldaccess, BlockPos blockposition, boolean flag, Entity entity) {
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldaccess);
+ // CraftBukkit end
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
+ BlockPos.MutableBlockPos blockposition_mutableblockposition = blockposition.mutable();
+
for (int i = -2; i <= 2; ++i) {
@@ -29,16 +42,36 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i);
for (int j = -2; j <= 2; ++j) {
for (int k = -1; k < 3; ++k) {
- BlockPos.MutableBlockPos blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(pos).move(j, k, i);
+ BlockPos.MutableBlockPos blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(j, k, i);
Block block = k == -1 ? Blocks.OBSIDIAN : Blocks.AIR;
- if (!worldaccess.getBlockState(blockposition_mutableblockposition1).is(block)) {
- if (!world.getBlockState(blockposition_mutableblockposition1).is(block)) {
- if (breakBlocks) {
- world.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null);
+ // CraftBukkit start
+ if (!blockList.getBlockState(blockposition_mutableblockposition1).is(block)) {
if (flag) {
- worldaccess.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null);
+ if (flag) {
+ blockList.destroyBlock(blockposition_mutableblockposition1, true, (Entity) null);
}
- worldaccess.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3);
- world.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3);
+ blockList.setBlock(blockposition_mutableblockposition1, block.defaultBlockState(), 3);
+ // CraftBukkit end
}
@@ -51,7 +54,7 @@
+ if (entity != null) {
+ org.bukkit.World bworld = worldaccess.getLevel().getWorld();
+ PortalCreateEvent portalEvent = new PortalCreateEvent((List<BlockState>) (List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
+
+ worldaccess.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent);
+ if (portalEvent.isCancelled()) {
+ return;
@@ -64,6 +67,6 @@
+ }
+ blockList.updateList();
+ // CraftBukkit end
+
}
}

View File

@@ -0,0 +1,32 @@
--- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java
+++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java
@@ -18,7 +18,7 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.datafix.DataFixTypes;
import net.minecraft.world.level.ChunkPos;
-import net.minecraft.world.level.Level;
+import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.storage.DimensionDataStorage;
public class LegacyStructureDataHandler {
@@ -233,16 +233,16 @@
}
}
- public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey<Level> world, @Nullable DimensionDataStorage persistentStateManager) {
- if (world == Level.OVERWORLD) {
+ public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey<LevelStem> world, @Nullable DimensionDataStorage persistentStateManager) { // CraftBukkit
+ if (world == LevelStem.OVERWORLD) { // CraftBukkit
return new LegacyStructureDataHandler(persistentStateManager, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"));
} else {
ImmutableList immutablelist;
- if (world == Level.NETHER) {
+ if (world == LevelStem.NETHER) { // CraftBukkit
immutablelist = ImmutableList.of("Fortress");
return new LegacyStructureDataHandler(persistentStateManager, immutablelist, immutablelist);
- } else if (world == Level.END) {
+ } else if (world == LevelStem.END) { // CraftBukkit
immutablelist = ImmutableList.of("EndCity");
return new LegacyStructureDataHandler(persistentStateManager, immutablelist, immutablelist);
} else {

View File

@@ -1,34 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.java
+++ b/net/minecraft/world/level/levelgen/structure/PersistentStructureLegacy.java
@@ -21,6 +21,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.storage.WorldPersistentData;
+// CraftBukkit start
+import net.minecraft.world.level.dimension.WorldDimension;
+// CraftBukkit end
+
public class PersistentStructureLegacy {
private static final Map<String, String> CURRENT_TO_LEGACY_MAP = (Map) SystemUtils.make(Maps.newHashMap(), (hashmap) -> {
@@ -233,16 +237,16 @@
}
}
- public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<World> resourcekey, @Nullable WorldPersistentData worldpersistentdata) {
- if (resourcekey == World.OVERWORLD) {
+ public static PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<WorldDimension> resourcekey, @Nullable WorldPersistentData worldpersistentdata) { // CraftBukkit
+ if (resourcekey == WorldDimension.OVERWORLD) { // CraftBukkit
return new PersistentStructureLegacy(worldpersistentdata, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument"));
} else {
ImmutableList immutablelist;
- if (resourcekey == World.NETHER) {
+ if (resourcekey == WorldDimension.NETHER) { // CraftBukkit
immutablelist = ImmutableList.of("Fortress");
return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist);
- } else if (resourcekey == World.END) {
+ } else if (resourcekey == WorldDimension.END) { // CraftBukkit
immutablelist = ImmutableList.of("EndCity");
return new PersistentStructureLegacy(worldpersistentdata, immutablelist, immutablelist);
} else {

View File

@@ -0,0 +1,164 @@
--- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java
+++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java
@@ -29,8 +29,6 @@
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.ChestBlockEntity;
-import net.minecraft.world.level.block.entity.DispenserBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
@@ -51,7 +49,7 @@
private Rotation rotation;
protected int genDepth;
private final StructurePieceType type;
- private static final Set<Block> SHAPE_CHECK_BLOCKS = ImmutableSet.builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.PALE_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build();
+ public static final Set<Block> SHAPE_CHECK_BLOCKS = ImmutableSet.<Block>builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.PALE_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build(); // CraftBukkit - decompile error / PAIL private -> public
protected StructurePiece(StructurePieceType type, int length, BoundingBox boundingBox) {
this.type = type;
@@ -80,13 +78,11 @@
CompoundTag nbttagcompound = new CompoundTag();
nbttagcompound.putString("id", BuiltInRegistries.STRUCTURE_PIECE.getKey(this.getType()).toString());
- DataResult dataresult = BoundingBox.CODEC.encodeStart(NbtOps.INSTANCE, this.boundingBox);
- Logger logger = StructurePiece.LOGGER;
-
- Objects.requireNonNull(logger);
- dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> {
- nbttagcompound.put("BB", nbtbase);
+ // CraftBukkit start - decompile error
+ BoundingBox.CODEC.encodeStart(NbtOps.INSTANCE, this.boundingBox).resultOrPartial(Objects.requireNonNull(StructurePiece.LOGGER)::error).ifPresent((nbtbase) -> {
+ nbttagcompound.put("BB", nbtbase);
});
+ // CraftBukkit end
Direction enumdirection = this.getOrientation();
nbttagcompound.putInt("O", enumdirection == null ? -1 : enumdirection.get2DDataValue());
@@ -186,6 +182,11 @@
}
world.setBlock(blockposition_mutableblockposition, block, 2);
+ // CraftBukkit start - fluid handling is already done if we have a transformer generator access
+ if (world instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess) {
+ return;
+ }
+ // CraftBukkit end
FluidState fluid = world.getFluidState(blockposition_mutableblockposition);
if (!fluid.isEmpty()) {
@@ -195,10 +196,42 @@
if (StructurePiece.SHAPE_CHECK_BLOCKS.contains(block.getBlock())) {
world.getChunk(blockposition_mutableblockposition).markPosForPostprocessing(blockposition_mutableblockposition);
}
+
+ }
+ }
+ }
+
+ // CraftBukkit start
+ protected boolean placeCraftBlockEntity(ServerLevelAccessor worldAccess, BlockPos position, org.bukkit.craftbukkit.block.CraftBlockEntityState<?> craftBlockEntityState, int i) {
+ if (worldAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ return transformerAccess.setCraftBlock(position, craftBlockEntityState, i);
+ }
+ boolean result = worldAccess.setBlock(position, craftBlockEntityState.getHandle(), i);
+ BlockEntity tileEntity = worldAccess.getBlockEntity(position);
+ if (tileEntity != null) {
+ tileEntity.loadWithComponents(craftBlockEntityState.getSnapshotNBT(), worldAccess.registryAccess());
+ }
+ return result;
+ }
+ protected void placeCraftSpawner(ServerLevelAccessor worldAccess, BlockPos position, org.bukkit.entity.EntityType entityType, int i) {
+ // This method is used in structures that are generated by code and place spawners as they set the entity after the block was placed making it impossible for plugins to access that information
+ org.bukkit.craftbukkit.block.CraftCreatureSpawner spawner = (org.bukkit.craftbukkit.block.CraftCreatureSpawner) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldAccess, position, Blocks.SPAWNER.defaultBlockState(), null);
+ spawner.setSpawnedType(entityType);
+ this.placeCraftBlockEntity(worldAccess, position, spawner, i);
+ }
+
+ protected void setCraftLootTable(ServerLevelAccessor worldAccess, BlockPos position, RandomSource randomSource, ResourceKey<LootTable> loottableKey) {
+ // This method is used in structures that use data markers to a loot table to loot containers as otherwise plugins won't have access to that information.
+ net.minecraft.world.level.block.entity.BlockEntity tileEntity = worldAccess.getBlockEntity(position);
+ if (tileEntity instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity tileEntityLootable) {
+ tileEntityLootable.setLootTable(loottableKey, randomSource.nextLong());
+ if (worldAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ transformerAccess.setCraftBlock(position, (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldAccess, position, tileEntity.getBlockState(), tileEntityLootable.saveWithFullMetadata(worldAccess.registryAccess())), 3);
}
}
}
+ // CraftBukkit end
protected boolean canBeReplaced(LevelReader world, int x, int y, int z, BoundingBox box) {
return true;
@@ -393,12 +426,20 @@
block = StructurePiece.reorient(world, pos, Blocks.CHEST.defaultBlockState());
}
- world.setBlock(pos, block, 2);
- BlockEntity tileentity = world.getBlockEntity(pos);
+ // CraftBukkit start
+ /*
+ worldaccess.setBlock(blockposition, iblockdata, 2);
+ TileEntity tileentity = worldaccess.getBlockEntity(blockposition);
- if (tileentity instanceof ChestBlockEntity) {
- ((ChestBlockEntity) tileentity).setLootTable(lootTable, random.nextLong());
+ if (tileentity instanceof TileEntityChest) {
+ ((TileEntityChest) tileentity).setLootTable(resourcekey, randomsource.nextLong());
}
+ */
+ org.bukkit.craftbukkit.block.CraftChest chestState = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, pos, block, null);
+ chestState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(lootTable));
+ chestState.setSeed(random.nextLong());
+ this.placeCraftBlockEntity(world, pos, chestState, 2);
+ // CraftBukkit end
return true;
} else {
@@ -410,13 +451,32 @@
BlockPos.MutableBlockPos blockposition_mutableblockposition = this.getWorldPos(x, y, z);
if (boundingBox.isInside(blockposition_mutableblockposition) && !world.getBlockState(blockposition_mutableblockposition).is(Blocks.DISPENSER)) {
- this.placeBlock(world, (BlockState) Blocks.DISPENSER.defaultBlockState().setValue(DispenserBlock.FACING, facing), x, y, z, boundingBox);
- BlockEntity tileentity = world.getBlockEntity(blockposition_mutableblockposition);
+ // CraftBukkit start
+ /*
+ this.placeBlock(generatoraccessseed, (IBlockData) Blocks.DISPENSER.defaultBlockState().setValue(BlockDispenser.FACING, enumdirection), i, j, k, structureboundingbox);
+ TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
- if (tileentity instanceof DispenserBlockEntity) {
- ((DispenserBlockEntity) tileentity).setLootTable(lootTable, random.nextLong());
+ if (tileentity instanceof TileEntityDispenser) {
+ ((TileEntityDispenser) tileentity).setLootTable(resourcekey, randomsource.nextLong());
}
+ */
+ if (!this.canBeReplaced(world, x, y, z, boundingBox)) {
+ return true;
+ }
+ BlockState iblockdata = Blocks.DISPENSER.defaultBlockState().setValue(DispenserBlock.FACING, facing);
+ if (this.mirror != Mirror.NONE) {
+ iblockdata = iblockdata.mirror(this.mirror);
+ }
+ if (this.rotation != Rotation.NONE) {
+ iblockdata = iblockdata.rotate(this.rotation);
+ }
+ org.bukkit.craftbukkit.block.CraftDispenser dispenserState = (org.bukkit.craftbukkit.block.CraftDispenser) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, blockposition_mutableblockposition, iblockdata, null);
+ dispenserState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(lootTable));
+ dispenserState.setSeed(random.nextLong());
+ this.placeCraftBlockEntity(world, blockposition_mutableblockposition, dispenserState, 2);
+ // CraftBukkit end
+
return true;
} else {
return false;
@@ -428,7 +488,7 @@
}
public static BoundingBox createBoundingBox(Stream<StructurePiece> pieces) {
- Stream stream1 = pieces.map(StructurePiece::getBoundingBox);
+ Stream<BoundingBox> stream1 = pieces.map(StructurePiece::getBoundingBox); // CraftBukkit - decompile error
Objects.requireNonNull(stream1);
return (BoundingBox) BoundingBox.encapsulatingBoxes(stream1::iterator).orElseThrow(() -> {

View File

@@ -1,142 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java
+++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java
@@ -51,7 +51,7 @@
private EnumBlockRotation rotation;
protected int genDepth;
private final WorldGenFeatureStructurePieceType type;
- private static final Set<Block> SHAPE_CHECK_BLOCKS = ImmutableSet.builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.PALE_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build();
+ public static final Set<Block> SHAPE_CHECK_BLOCKS = ImmutableSet.<Block>builder().add(Blocks.NETHER_BRICK_FENCE).add(Blocks.TORCH).add(Blocks.WALL_TORCH).add(Blocks.OAK_FENCE).add(Blocks.SPRUCE_FENCE).add(Blocks.DARK_OAK_FENCE).add(Blocks.PALE_OAK_FENCE).add(Blocks.ACACIA_FENCE).add(Blocks.BIRCH_FENCE).add(Blocks.JUNGLE_FENCE).add(Blocks.LADDER).add(Blocks.IRON_BARS).build(); // CraftBukkit - decompile error / PAIL private -> public
protected StructurePiece(WorldGenFeatureStructurePieceType worldgenfeaturestructurepiecetype, int i, StructureBoundingBox structureboundingbox) {
this.type = worldgenfeaturestructurepiecetype;
@@ -80,13 +80,11 @@
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.putString("id", BuiltInRegistries.STRUCTURE_PIECE.getKey(this.getType()).toString());
- DataResult dataresult = StructureBoundingBox.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.boundingBox);
- Logger logger = StructurePiece.LOGGER;
-
- Objects.requireNonNull(logger);
- dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> {
- nbttagcompound.put("BB", nbtbase);
+ // CraftBukkit start - decompile error
+ StructureBoundingBox.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.boundingBox).resultOrPartial(Objects.requireNonNull(StructurePiece.LOGGER)::error).ifPresent((nbtbase) -> {
+ nbttagcompound.put("BB", nbtbase);
});
+ // CraftBukkit end
EnumDirection enumdirection = this.getOrientation();
nbttagcompound.putInt("O", enumdirection == null ? -1 : enumdirection.get2DDataValue());
@@ -186,6 +184,11 @@
}
generatoraccessseed.setBlock(blockposition_mutableblockposition, iblockdata, 2);
+ // CraftBukkit start - fluid handling is already done if we have a transformer generator access
+ if (generatoraccessseed instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess) {
+ return;
+ }
+ // CraftBukkit end
Fluid fluid = generatoraccessseed.getFluidState(blockposition_mutableblockposition);
if (!fluid.isEmpty()) {
@@ -200,6 +203,38 @@
}
}
+ // CraftBukkit start
+ protected boolean placeCraftBlockEntity(WorldAccess worldAccess, BlockPosition position, org.bukkit.craftbukkit.block.CraftBlockEntityState<?> craftBlockEntityState, int i) {
+ if (worldAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ return transformerAccess.setCraftBlock(position, craftBlockEntityState, i);
+ }
+ boolean result = worldAccess.setBlock(position, craftBlockEntityState.getHandle(), i);
+ TileEntity tileEntity = worldAccess.getBlockEntity(position);
+ if (tileEntity != null) {
+ tileEntity.loadWithComponents(craftBlockEntityState.getSnapshotNBT(), worldAccess.registryAccess());
+ }
+ return result;
+ }
+
+ protected void placeCraftSpawner(WorldAccess worldAccess, BlockPosition position, org.bukkit.entity.EntityType entityType, int i) {
+ // This method is used in structures that are generated by code and place spawners as they set the entity after the block was placed making it impossible for plugins to access that information
+ org.bukkit.craftbukkit.block.CraftCreatureSpawner spawner = (org.bukkit.craftbukkit.block.CraftCreatureSpawner) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldAccess, position, Blocks.SPAWNER.defaultBlockState(), null);
+ spawner.setSpawnedType(entityType);
+ placeCraftBlockEntity(worldAccess, position, spawner, i);
+ }
+
+ protected void setCraftLootTable(WorldAccess worldAccess, BlockPosition position, RandomSource randomSource, ResourceKey<LootTable> loottableKey) {
+ // This method is used in structures that use data markers to a loot table to loot containers as otherwise plugins won't have access to that information.
+ net.minecraft.world.level.block.entity.TileEntity tileEntity = worldAccess.getBlockEntity(position);
+ if (tileEntity instanceof net.minecraft.world.level.block.entity.TileEntityLootable tileEntityLootable) {
+ tileEntityLootable.setLootTable(loottableKey, randomSource.nextLong());
+ if (worldAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ transformerAccess.setCraftBlock(position, (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldAccess, position, tileEntity.getBlockState(), tileEntityLootable.saveWithFullMetadata(worldAccess.registryAccess())), 3);
+ }
+ }
+ }
+ // CraftBukkit end
+
protected boolean canBeReplaced(IWorldReader iworldreader, int i, int j, int k, StructureBoundingBox structureboundingbox) {
return true;
}
@@ -393,12 +428,20 @@
iblockdata = reorient(worldaccess, blockposition, Blocks.CHEST.defaultBlockState());
}
+ // CraftBukkit start
+ /*
worldaccess.setBlock(blockposition, iblockdata, 2);
TileEntity tileentity = worldaccess.getBlockEntity(blockposition);
if (tileentity instanceof TileEntityChest) {
((TileEntityChest) tileentity).setLootTable(resourcekey, randomsource.nextLong());
}
+ */
+ org.bukkit.craftbukkit.block.CraftChest chestState = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldaccess, blockposition, iblockdata, null);
+ chestState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(resourcekey));
+ chestState.setSeed(randomsource.nextLong());
+ placeCraftBlockEntity(worldaccess, blockposition, chestState, 2);
+ // CraftBukkit end
return true;
} else {
@@ -410,12 +453,31 @@
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = this.getWorldPos(i, j, k);
if (structureboundingbox.isInside(blockposition_mutableblockposition) && !generatoraccessseed.getBlockState(blockposition_mutableblockposition).is(Blocks.DISPENSER)) {
+ // CraftBukkit start
+ /*
this.placeBlock(generatoraccessseed, (IBlockData) Blocks.DISPENSER.defaultBlockState().setValue(BlockDispenser.FACING, enumdirection), i, j, k, structureboundingbox);
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
if (tileentity instanceof TileEntityDispenser) {
((TileEntityDispenser) tileentity).setLootTable(resourcekey, randomsource.nextLong());
}
+ */
+ if (!this.canBeReplaced(generatoraccessseed, i, j, k, structureboundingbox)) {
+ return true;
+ }
+ IBlockData iblockdata = Blocks.DISPENSER.defaultBlockState().setValue(BlockDispenser.FACING, enumdirection);
+ if (this.mirror != EnumBlockMirror.NONE) {
+ iblockdata = iblockdata.mirror(this.mirror);
+ }
+ if (this.rotation != EnumBlockRotation.NONE) {
+ iblockdata = iblockdata.rotate(this.rotation);
+ }
+
+ org.bukkit.craftbukkit.block.CraftDispenser dispenserState = (org.bukkit.craftbukkit.block.CraftDispenser) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(generatoraccessseed, blockposition_mutableblockposition, iblockdata, null);
+ dispenserState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(resourcekey));
+ dispenserState.setSeed(randomsource.nextLong());
+ placeCraftBlockEntity(generatoraccessseed, blockposition_mutableblockposition, dispenserState, 2);
+ // CraftBukkit end
return true;
} else {
@@ -428,7 +490,7 @@
}
public static StructureBoundingBox createBoundingBox(Stream<StructurePiece> stream) {
- Stream stream1 = stream.map(StructurePiece::getBoundingBox);
+ Stream<StructureBoundingBox> stream1 = stream.map(StructurePiece::getBoundingBox); // CraftBukkit - decompile error
Objects.requireNonNull(stream1);
return (StructureBoundingBox) StructureBoundingBox.encapsulatingBoxes(stream1::iterator).orElseThrow(() -> {

View File

@@ -0,0 +1,59 @@
--- a/net/minecraft/world/level/levelgen/structure/StructureStart.java
+++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java
@@ -32,6 +32,12 @@
@Nullable
private volatile BoundingBox cachedBoundingBox;
+ // CraftBukkit start
+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
+ public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(StructureStart.DATA_TYPE_REGISTRY);
+ public org.bukkit.event.world.AsyncStructureGenerateEvent.Cause generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.WORLD_GENERATION;
+ // CraftBukkit end
+
public StructureStart(Structure structure, ChunkPos pos, int references, PiecesContainer children) {
this.structure = structure;
this.chunkPos = pos;
@@ -91,15 +97,29 @@
BoundingBox structureboundingbox1 = ((StructurePiece) list.get(0)).boundingBox;
BlockPos blockposition = structureboundingbox1.getCenter();
BlockPos blockposition1 = new BlockPos(blockposition.getX(), structureboundingbox1.minY(), blockposition.getZ());
+ // CraftBukkit start
+ /*
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
StructurePiece structurepiece = (StructurePiece) iterator.next();
- if (structurepiece.getBoundingBox().intersects(chunkBox)) {
- structurepiece.postProcess(world, structureAccessor, chunkGenerator, random, chunkBox, chunkPos, blockposition1);
+ if (structurepiece.getBoundingBox().intersects(structureboundingbox)) {
+ structurepiece.postProcess(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, blockposition1);
}
}
+ */
+ List<StructurePiece> pieces = list.stream().filter(piece -> piece.getBoundingBox().intersects(chunkBox)).toList();
+ if (!pieces.isEmpty()) {
+ org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess = new org.bukkit.craftbukkit.util.TransformerGeneratorAccess();
+ transformerAccess.setHandle(world);
+ transformerAccess.setStructureTransformer(new org.bukkit.craftbukkit.util.CraftStructureTransformer(this.generationEventCause, world, structureAccessor, this.structure, chunkBox, chunkPos));
+ for (StructurePiece piece : pieces) {
+ piece.postProcess(transformerAccess, structureAccessor, chunkGenerator, random, chunkBox, chunkPos, blockposition1);
+ }
+ transformerAccess.getStructureTransformer().discard();
+ }
+ // CraftBukkit end
this.structure.afterPlace(world, structureAccessor, chunkGenerator, random, chunkBox, chunkPos, this.pieceContainer);
}
@@ -107,6 +127,11 @@
public CompoundTag createTag(StructurePieceSerializationContext context, ChunkPos chunkPos) {
CompoundTag nbttagcompound = new CompoundTag();
+ // CraftBukkit start - store persistent data in nbt
+ if (!this.persistentDataContainer.isEmpty()) {
+ nbttagcompound.put("StructureBukkitValues", this.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
if (this.isValid()) {
nbttagcompound.putString("id", context.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.structure).toString());

View File

@@ -1,55 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/StructureStart.java
+++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java
@@ -32,6 +32,12 @@
@Nullable
private volatile StructureBoundingBox cachedBoundingBox;
+ // CraftBukkit start
+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
+ public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(DATA_TYPE_REGISTRY);
+ public org.bukkit.event.world.AsyncStructureGenerateEvent.Cause generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.WORLD_GENERATION;
+ // CraftBukkit end
+
public StructureStart(Structure structure, ChunkCoordIntPair chunkcoordintpair, int i, PiecesContainer piecescontainer) {
this.structure = structure;
this.chunkPos = chunkcoordintpair;
@@ -91,6 +97,8 @@
StructureBoundingBox structureboundingbox1 = ((StructurePiece) list.get(0)).boundingBox;
BlockPosition blockposition = structureboundingbox1.getCenter();
BlockPosition blockposition1 = new BlockPosition(blockposition.getX(), structureboundingbox1.minY(), blockposition.getZ());
+ // CraftBukkit start
+ /*
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
@@ -100,6 +108,18 @@
structurepiece.postProcess(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, blockposition1);
}
}
+ */
+ List<StructurePiece> pieces = list.stream().filter(piece -> piece.getBoundingBox().intersects(structureboundingbox)).toList();
+ if (!pieces.isEmpty()) {
+ org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess = new org.bukkit.craftbukkit.util.TransformerGeneratorAccess();
+ transformerAccess.setHandle(generatoraccessseed);
+ transformerAccess.setStructureTransformer(new org.bukkit.craftbukkit.util.CraftStructureTransformer(generationEventCause, generatoraccessseed, structuremanager, structure, structureboundingbox, chunkcoordintpair));
+ for (StructurePiece piece : pieces) {
+ piece.postProcess(transformerAccess, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, blockposition1);
+ }
+ transformerAccess.getStructureTransformer().discard();
+ }
+ // CraftBukkit end
this.structure.afterPlace(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, this.pieceContainer);
}
@@ -107,6 +127,11 @@
public NBTTagCompound createTag(StructurePieceSerializationContext structurepieceserializationcontext, ChunkCoordIntPair chunkcoordintpair) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
+ // CraftBukkit start - store persistent data in nbt
+ if (!persistentDataContainer.isEmpty()) {
+ nbttagcompound.put("StructureBukkitValues", persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
if (this.isValid()) {
nbttagcompound.putString("id", structurepieceserializationcontext.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(this.structure).toString());

View File

@@ -0,0 +1,18 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
@@ -68,6 +68,15 @@
private static void placeSuspiciousSand(BoundingBox box, WorldGenLevel world, BlockPos pos) {
if (box.isInside(pos)) {
+ // CraftBukkit start
+ if (world instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ org.bukkit.craftbukkit.block.CraftBrushableBlock brushableState = (org.bukkit.craftbukkit.block.CraftBrushableBlock) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, pos, Blocks.SUSPICIOUS_SAND.defaultBlockState(), null);
+ brushableState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY));
+ brushableState.setSeed(pos.asLong());
+ transformerAccess.setCraftBlock(pos, brushableState, 2);
+ return;
+ }
+ // CraftBukkit end
world.setBlock(pos, Blocks.SUSPICIOUS_SAND.defaultBlockState(), 2);
world.getBlockEntity(pos, BlockEntityType.BRUSHABLE_BLOCK).ifPresent((brushableblockentity) -> {
brushableblockentity.setLootTable(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY, pos.asLong());

View File

@@ -1,18 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java
@@ -68,6 +68,15 @@
private static void placeSuspiciousSand(StructureBoundingBox structureboundingbox, GeneratorAccessSeed generatoraccessseed, BlockPosition blockposition) {
if (structureboundingbox.isInside(blockposition)) {
+ // CraftBukkit start
+ if (generatoraccessseed instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ org.bukkit.craftbukkit.block.CraftBrushableBlock brushableState = (org.bukkit.craftbukkit.block.CraftBrushableBlock) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(generatoraccessseed, blockposition, Blocks.SUSPICIOUS_SAND.defaultBlockState(), null);
+ brushableState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(LootTables.DESERT_PYRAMID_ARCHAEOLOGY));
+ brushableState.setSeed(blockposition.asLong());
+ transformerAccess.setCraftBlock(blockposition, brushableState, 2);
+ return;
+ }
+ // CraftBukkit end
generatoraccessseed.setBlock(blockposition, Blocks.SUSPICIOUS_SAND.defaultBlockState(), 2);
generatoraccessseed.getBlockEntity(blockposition, TileEntityTypes.BRUSHABLE_BLOCK).ifPresent((brushableblockentity) -> {
brushableblockentity.setLootTable(LootTables.DESERT_PYRAMID_ARCHAEOLOGY, blockposition.asLong());

View File

@@ -0,0 +1,16 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java
@@ -285,7 +285,12 @@
BlockPos blockposition1 = pos.below();
if (boundingBox.isInside(blockposition1)) {
- RandomizableContainer.setBlockEntityLootTable(world, random, blockposition1, BuiltInLootTables.END_CITY_TREASURE);
+ // CraftBukkit start - ensure block transformation
+ /*
+ RandomizableContainer.setBlockEntityLootTable(worldaccess, randomsource, blockposition1, LootTables.END_CITY_TREASURE);
+ */
+ this.setCraftLootTable(world, blockposition1, random, BuiltInLootTables.END_CITY_TREASURE);
+ // CraftBukkit end
}
} else if (boundingBox.isInside(pos) && Level.isInSpawnableBounds(pos)) {
if (metadata.startsWith("Sentry")) {

View File

@@ -1,15 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityPieces.java
@@ -285,7 +285,12 @@
BlockPosition blockposition1 = blockposition.below();
if (structureboundingbox.isInside(blockposition1)) {
+ // CraftBukkit start - ensure block transformation
+ /*
RandomizableContainer.setBlockEntityLootTable(worldaccess, randomsource, blockposition1, LootTables.END_CITY_TREASURE);
+ */
+ setCraftLootTable(worldaccess, blockposition1, randomsource, LootTables.END_CITY_TREASURE);
+ // CraftBukkit end
}
} else if (structureboundingbox.isInside(blockposition) && World.isInSpawnableBounds(blockposition)) {
if (s.startsWith("Sentry")) {

View File

@@ -0,0 +1,31 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java
@@ -14,8 +14,6 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
@@ -86,11 +84,16 @@
protected void handleDataMarker(String metadata, BlockPos pos, ServerLevelAccessor world, RandomSource random, BoundingBox boundingBox) {
if ("chest".equals(metadata)) {
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
- BlockEntity tileentity = world.getBlockEntity(pos.below());
+ // CraftBukkit start - ensure block transformation
+ /*
+ TileEntity tileentity = worldaccess.getBlockEntity(blockposition.below());
- if (tileentity instanceof ChestBlockEntity) {
- ((ChestBlockEntity) tileentity).setLootTable(BuiltInLootTables.IGLOO_CHEST, random.nextLong());
+ if (tileentity instanceof TileEntityChest) {
+ ((TileEntityChest) tileentity).setLootTable(LootTables.IGLOO_CHEST, randomsource.nextLong());
}
+ */
+ this.setCraftLootTable(world, pos.below(), random, BuiltInLootTables.IGLOO_CHEST);
+ // CraftBukkit end
}
}

View File

@@ -1,19 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java
@@ -86,11 +86,16 @@
protected void handleDataMarker(String s, BlockPosition blockposition, WorldAccess worldaccess, RandomSource randomsource, StructureBoundingBox structureboundingbox) {
if ("chest".equals(s)) {
worldaccess.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3);
+ // CraftBukkit start - ensure block transformation
+ /*
TileEntity tileentity = worldaccess.getBlockEntity(blockposition.below());
if (tileentity instanceof TileEntityChest) {
((TileEntityChest) tileentity).setLootTable(LootTables.IGLOO_CHEST, randomsource.nextLong());
}
+ */
+ setCraftLootTable(worldaccess, blockposition.below(), randomsource, LootTables.IGLOO_CHEST);
+ // CraftBukkit end
}
}

View File

@@ -0,0 +1,68 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java
@@ -12,6 +12,7 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
+import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BiomeTags;
import net.minecraft.util.RandomSource;
@@ -30,8 +31,6 @@
import net.minecraft.world.level.block.FenceBlock;
import net.minecraft.world.level.block.RailBlock;
import net.minecraft.world.level.block.WallTorchBlock;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.level.chunk.ChunkGenerator;
@@ -520,14 +519,19 @@
if (chunkBox.isInside(blockposition_mutableblockposition) && this.isInterior(world, 1, 0, l, chunkBox)) {
this.hasPlacedSpider = true;
- world.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
- BlockEntity tileentity = world.getBlockEntity(blockposition_mutableblockposition);
-
- if (tileentity instanceof SpawnerBlockEntity) {
- SpawnerBlockEntity tileentitymobspawner = (SpawnerBlockEntity) tileentity;
+ // CraftBukkit start
+ /*
+ generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
+ TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
- tileentitymobspawner.setEntityId(EntityType.CAVE_SPIDER, random);
+ if (tileentity instanceof TileEntityMobSpawner) {
+ TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) tileentity;
+
+ tileentitymobspawner.setEntityId(EntityTypes.CAVE_SPIDER, randomsource);
}
+ */
+ this.placeCraftSpawner(world, blockposition_mutableblockposition, org.bukkit.entity.EntityType.CAVE_SPIDER, 2);
+ // CraftBukkit end
}
}
}
@@ -819,11 +823,11 @@
public MineShaftRoom(CompoundTag nbt) {
super(StructurePieceType.MINE_SHAFT_ROOM, nbt);
- DataResult dataresult = BoundingBox.CODEC.listOf().parse(NbtOps.INSTANCE, nbt.getList("Entrances", 11));
+ DataResult<List<BoundingBox>> dataresult = BoundingBox.CODEC.listOf().parse(NbtOps.INSTANCE, nbt.getList("Entrances", 11)); // CraftBukkit - decompile error
Logger logger = MineshaftPieces.LOGGER;
Objects.requireNonNull(logger);
- Optional optional = dataresult.resultOrPartial(logger::error);
+ Optional<List<BoundingBox>> optional = dataresult.resultOrPartial(logger::error); // CraftBukkit - decompile error
List list = this.childEntranceBoxes;
Objects.requireNonNull(this.childEntranceBoxes);
@@ -929,7 +933,7 @@
@Override
protected void addAdditionalSaveData(StructurePieceSerializationContext context, CompoundTag nbt) {
super.addAdditionalSaveData(context, nbt);
- DataResult dataresult = BoundingBox.CODEC.listOf().encodeStart(NbtOps.INSTANCE, this.childEntranceBoxes);
+ DataResult<Tag> dataresult = BoundingBox.CODEC.listOf().encodeStart(NbtOps.INSTANCE, this.childEntranceBoxes); // CraftBukkit - decompile error
Logger logger = MineshaftPieces.LOGGER;
Objects.requireNonNull(logger);

View File

@@ -1,55 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java
@@ -44,6 +44,10 @@
import net.minecraft.world.level.storage.loot.LootTables;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.nbt.NBTBase;
+// CraftBukkit end
+
public class MineshaftPieces {
static final Logger LOGGER = LogUtils.getLogger();
@@ -520,6 +524,8 @@
if (structureboundingbox.isInside(blockposition_mutableblockposition) && this.isInterior(generatoraccessseed, 1, 0, l, structureboundingbox)) {
this.hasPlacedSpider = true;
+ // CraftBukkit start
+ /*
generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
@@ -528,6 +534,9 @@
tileentitymobspawner.setEntityId(EntityTypes.CAVE_SPIDER, randomsource);
}
+ */
+ placeCraftSpawner(generatoraccessseed, blockposition_mutableblockposition, org.bukkit.entity.EntityType.CAVE_SPIDER, 2);
+ // CraftBukkit end
}
}
}
@@ -819,11 +828,11 @@
public d(NBTTagCompound nbttagcompound) {
super(WorldGenFeatureStructurePieceType.MINE_SHAFT_ROOM, nbttagcompound);
- DataResult dataresult = StructureBoundingBox.CODEC.listOf().parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getList("Entrances", 11));
+ DataResult<List<StructureBoundingBox>> dataresult = StructureBoundingBox.CODEC.listOf().parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getList("Entrances", 11)); // CraftBukkit - decompile error
Logger logger = MineshaftPieces.LOGGER;
Objects.requireNonNull(logger);
- Optional optional = dataresult.resultOrPartial(logger::error);
+ Optional<List<StructureBoundingBox>> optional = dataresult.resultOrPartial(logger::error); // CraftBukkit - decompile error
List list = this.childEntranceBoxes;
Objects.requireNonNull(this.childEntranceBoxes);
@@ -929,7 +938,7 @@
@Override
protected void addAdditionalSaveData(StructurePieceSerializationContext structurepieceserializationcontext, NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(structurepieceserializationcontext, nbttagcompound);
- DataResult dataresult = StructureBoundingBox.CODEC.listOf().encodeStart(DynamicOpsNBT.INSTANCE, this.childEntranceBoxes);
+ DataResult<NBTBase> dataresult = StructureBoundingBox.CODEC.listOf().encodeStart(DynamicOpsNBT.INSTANCE, this.childEntranceBoxes); // CraftBukkit - decompile error
Logger logger = MineshaftPieces.LOGGER;
Objects.requireNonNull(logger);

View File

@@ -0,0 +1,45 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java
@@ -8,15 +8,12 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.RandomSource;
-import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FenceBlock;
import net.minecraft.world.level.block.StairBlock;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
@@ -428,14 +425,19 @@
if (chunkBox.isInside(blockposition_mutableblockposition)) {
this.hasPlacedSpawner = true;
- world.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
- BlockEntity tileentity = world.getBlockEntity(blockposition_mutableblockposition);
-
- if (tileentity instanceof SpawnerBlockEntity) {
- SpawnerBlockEntity tileentitymobspawner = (SpawnerBlockEntity) tileentity;
-
- tileentitymobspawner.setEntityId(EntityType.BLAZE, random);
+ // CraftBukkit start
+ /*
+ generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
+ TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
+
+ if (tileentity instanceof TileEntityMobSpawner) {
+ TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) tileentity;
+
+ tileentitymobspawner.setEntityId(EntityTypes.BLAZE, randomsource);
}
+ */
+ this.placeCraftSpawner(world, blockposition_mutableblockposition, org.bukkit.entity.EntityType.BLAZE, 2);
+ // CraftBukkit end
}
}

View File

@@ -1,21 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java
@@ -428,6 +428,8 @@
if (structureboundingbox.isInside(blockposition_mutableblockposition)) {
this.hasPlacedSpawner = true;
+ // CraftBukkit start
+ /*
generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
@@ -436,6 +438,9 @@
tileentitymobspawner.setEntityId(EntityTypes.BLAZE, randomsource);
}
+ */
+ placeCraftSpawner(generatoraccessseed, blockposition_mutableblockposition, org.bukkit.entity.EntityType.BLAZE, 2);
+ // CraftBukkit end
}
}

View File

@@ -0,0 +1,37 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java
@@ -27,8 +27,6 @@
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
@@ -200,12 +198,20 @@
@Override
protected void handleDataMarker(String metadata, BlockPos pos, ServerLevelAccessor world, RandomSource random, BoundingBox boundingBox) {
if ("chest".equals(metadata)) {
- world.setBlock(pos, (BlockState) Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, world.getFluidState(pos).is(FluidTags.WATER)), 2);
- BlockEntity tileentity = world.getBlockEntity(pos);
-
- if (tileentity instanceof ChestBlockEntity) {
- ((ChestBlockEntity) tileentity).setLootTable(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong());
+ // CraftBukkit start - transform block to ensure loot table is accessible
+ /*
+ worldaccess.setBlock(blockposition, (IBlockData) Blocks.CHEST.defaultBlockState().setValue(BlockChest.WATERLOGGED, worldaccess.getFluidState(blockposition).is(TagsFluid.WATER)), 2);
+ TileEntity tileentity = worldaccess.getBlockEntity(blockposition);
+
+ if (tileentity instanceof TileEntityChest) {
+ ((TileEntityChest) tileentity).setLootTable(this.isLarge ? LootTables.UNDERWATER_RUIN_BIG : LootTables.UNDERWATER_RUIN_SMALL, randomsource.nextLong());
}
+ */
+ org.bukkit.craftbukkit.block.CraftChest craftChest = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, world.getFluidState(pos).is(FluidTags.WATER)), null);
+ craftChest.setSeed(random.nextLong());
+ craftChest.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL));
+ this.placeCraftBlockEntity(world, pos, craftChest, 2);
+ // CraftBukkit end
} else if ("drowned".equals(metadata)) {
Drowned entitydrowned = (Drowned) EntityType.DROWNED.create(world.getLevel(), EntitySpawnReason.STRUCTURE);

View File

@@ -1,23 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java
@@ -200,12 +200,20 @@
@Override
protected void handleDataMarker(String s, BlockPosition blockposition, WorldAccess worldaccess, RandomSource randomsource, StructureBoundingBox structureboundingbox) {
if ("chest".equals(s)) {
+ // CraftBukkit start - transform block to ensure loot table is accessible
+ /*
worldaccess.setBlock(blockposition, (IBlockData) Blocks.CHEST.defaultBlockState().setValue(BlockChest.WATERLOGGED, worldaccess.getFluidState(blockposition).is(TagsFluid.WATER)), 2);
TileEntity tileentity = worldaccess.getBlockEntity(blockposition);
if (tileentity instanceof TileEntityChest) {
((TileEntityChest) tileentity).setLootTable(this.isLarge ? LootTables.UNDERWATER_RUIN_BIG : LootTables.UNDERWATER_RUIN_SMALL, randomsource.nextLong());
}
+ */
+ org.bukkit.craftbukkit.block.CraftChest craftChest = (org.bukkit.craftbukkit.block.CraftChest) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldaccess, blockposition, Blocks.CHEST.defaultBlockState().setValue(BlockChest.WATERLOGGED, worldaccess.getFluidState(blockposition).is(TagsFluid.WATER)), null);
+ craftChest.setSeed(randomsource.nextLong());
+ craftChest.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(this.isLarge ? LootTables.UNDERWATER_RUIN_BIG : LootTables.UNDERWATER_RUIN_SMALL));
+ placeCraftBlockEntity(worldaccess, blockposition, craftChest, 2);
+ // CraftBukkit end
} else if ("drowned".equals(s)) {
EntityDrowned entitydrowned = (EntityDrowned) EntityTypes.DROWNED.create(worldaccess.getLevel(), EntitySpawnReason.STRUCTURE);

View File

@@ -1,14 +1,15 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java
@@ -79,7 +79,12 @@
ResourceKey<LootTable> resourcekey = (ResourceKey) ShipwreckPieces.MARKERS_TO_LOOT.get(s);
ResourceKey<LootTable> resourcekey = (ResourceKey) ShipwreckPieces.MARKERS_TO_LOOT.get(metadata);
if (resourcekey != null) {
- RandomizableContainer.setBlockEntityLootTable(world, random, pos.below(), resourcekey);
+ // CraftBukkit start - ensure block transformation
+ /*
RandomizableContainer.setBlockEntityLootTable(worldaccess, randomsource, blockposition.below(), resourcekey);
+ RandomizableContainer.setBlockEntityLootTable(worldaccess, randomsource, blockposition.below(), resourcekey);
+ */
+ setCraftLootTable(worldaccess, blockposition.below(), randomsource, resourcekey);
+ this.setCraftLootTable(world, pos.below(), random, resourcekey);
+ // CraftBukkit end
}

View File

@@ -0,0 +1,55 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java
@@ -8,7 +8,6 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.RandomSource;
-import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.WorldGenLevel;
@@ -22,8 +21,6 @@
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.StairBlock;
import net.minecraft.world.level.block.WallTorchBlock;
-import net.minecraft.world.level.block.entity.BlockEntity;
-import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.SlabType;
@@ -53,7 +50,7 @@
public boolean doPlace(int chainLength) {
return super.doPlace(chainLength) && chainLength > 5;
}
- }};
+ } }; // CraftBukkit - fix decompile styling
private static List<StrongholdPieces.PieceWeight> currentPieces;
static Class<? extends StrongholdPieces.StrongholdPiece> imposedPiece;
private static int totalWeight;
@@ -1136,14 +1133,19 @@
if (chunkBox.isInside(blockposition_mutableblockposition)) {
this.hasPlacedSpawner = true;
- world.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
- BlockEntity tileentity = world.getBlockEntity(blockposition_mutableblockposition);
-
- if (tileentity instanceof SpawnerBlockEntity) {
- SpawnerBlockEntity tileentitymobspawner = (SpawnerBlockEntity) tileentity;
-
- tileentitymobspawner.setEntityId(EntityType.SILVERFISH, random);
+ // CraftBukkit start
+ /*
+ generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
+ TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
+
+ if (tileentity instanceof TileEntityMobSpawner) {
+ TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) tileentity;
+
+ tileentitymobspawner.setEntityId(EntityTypes.SILVERFISH, randomsource);
}
+ */
+ this.placeCraftSpawner(world, blockposition_mutableblockposition, org.bukkit.entity.EntityType.SILVERFISH, 2);
+ // CraftBukkit end
}
}

View File

@@ -1,30 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java
@@ -53,7 +53,7 @@
public boolean doPlace(int i) {
return super.doPlace(i) && i > 5;
}
- }};
+ } }; // CraftBukkit - fix decompile styling
private static List<StrongholdPieces.f> currentPieces;
static Class<? extends StrongholdPieces.p> imposedPiece;
private static int totalWeight;
@@ -1136,6 +1136,8 @@
if (structureboundingbox.isInside(blockposition_mutableblockposition)) {
this.hasPlacedSpawner = true;
+ // CraftBukkit start
+ /*
generatoraccessseed.setBlock(blockposition_mutableblockposition, Blocks.SPAWNER.defaultBlockState(), 2);
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition_mutableblockposition);
@@ -1144,6 +1146,9 @@
tileentitymobspawner.setEntityId(EntityTypes.SILVERFISH, randomsource);
}
+ */
+ placeCraftSpawner(generatoraccessseed, blockposition_mutableblockposition, org.bukkit.entity.EntityType.SILVERFISH, 2);
+ // CraftBukkit end
}
}

View File

@@ -3,18 +3,18 @@
@@ -100,7 +100,7 @@
entitywitch.setPersistenceRequired();
entitywitch.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F);
entitywitch.finalizeSpawn(generatoraccessseed, generatoraccessseed.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null);
- generatoraccessseed.addFreshEntityWithPassengers(entitywitch);
+ generatoraccessseed.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
entitywitch.finalizeSpawn(world, world.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (SpawnGroupData) null);
- world.addFreshEntityWithPassengers(entitywitch);
+ world.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
}
}
}
@@ -121,7 +121,7 @@
entitycat.setPersistenceRequired();
entitycat.moveTo((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D, 0.0F, 0.0F);
entitycat.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (GroupDataEntity) null);
- worldaccess.addFreshEntityWithPassengers(entitycat);
+ worldaccess.addFreshEntityWithPassengers(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
entitycat.finalizeSpawn(world, world.getCurrentDifficultyAt(blockposition_mutableblockposition), EntitySpawnReason.STRUCTURE, (SpawnGroupData) null);
- world.addFreshEntityWithPassengers(entitycat);
+ world.addFreshEntityWithPassengers(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
}
}
}

View File

@@ -1,147 +0,0 @@
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
@@ -56,6 +56,12 @@
import net.minecraft.world.phys.shapes.VoxelShapeBitSet;
import net.minecraft.world.phys.shapes.VoxelShapeDiscrete;
+// CraftBukkit start
+import net.minecraft.nbt.NBTBase;
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
+// CraftBukkit end
+
public class DefinedStructure {
public static final String PALETTE_TAG = "palette";
@@ -74,6 +80,11 @@
private BaseBlockPosition size;
private String author;
+ // CraftBukkit start - data containers
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
+ public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
+ // CraftBukkit end
+
public DefinedStructure() {
this.size = BaseBlockPosition.ZERO;
this.author = "?";
@@ -147,7 +158,7 @@
}
private static List<DefinedStructure.BlockInfo> buildInfoList(List<DefinedStructure.BlockInfo> list, List<DefinedStructure.BlockInfo> list1, List<DefinedStructure.BlockInfo> list2) {
- Comparator<DefinedStructure.BlockInfo> comparator = Comparator.comparingInt((definedstructure_blockinfo) -> {
+ Comparator<DefinedStructure.BlockInfo> comparator = Comparator.<DefinedStructure.BlockInfo>comparingInt((definedstructure_blockinfo) -> { // CraftBukkit - decompile error
return definedstructure_blockinfo.pos.getY();
}).thenComparingInt((definedstructure_blockinfo) -> {
return definedstructure_blockinfo.pos.getX();
@@ -253,6 +264,19 @@
if (this.palettes.isEmpty()) {
return false;
} else {
+ // CraftBukkit start
+ // We only want the TransformerGeneratorAccess at certain locations because in here are many "block update" calls that shouldn't be transformed
+ WorldAccess wrappedAccess = worldaccess;
+ org.bukkit.craftbukkit.util.CraftStructureTransformer structureTransformer = null;
+ if (wrappedAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ worldaccess = transformerAccess.getHandle();
+ structureTransformer = transformerAccess.getStructureTransformer();
+ // The structureTransformer is not needed if we can not transform blocks therefore we can save a little bit of performance doing this
+ if (structureTransformer != null && !structureTransformer.canTransformBlocks()) {
+ structureTransformer = null;
+ }
+ }
+ // CraftBukkit end
List<DefinedStructure.BlockInfo> list = definedstructureinfo.getRandomPalette(this.palettes, blockposition).blocks();
if ((!list.isEmpty() || !definedstructureinfo.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 && this.size.getY() >= 1 && this.size.getZ() >= 1) {
@@ -284,6 +308,20 @@
Clearable.tryClear(tileentity);
worldaccess.setBlock(blockposition2, Blocks.BARRIER.defaultBlockState(), 20);
}
+ // CraftBukkit start
+ if (structureTransformer != null) {
+ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldaccess, blockposition2, iblockdata, null);
+ if (definedstructure_blockinfo.nbt != null && craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState<?> entityState) {
+ entityState.loadData(definedstructure_blockinfo.nbt);
+ if (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftLootable<?> craftLootable) {
+ craftLootable.setSeed(randomsource.nextLong());
+ }
+ }
+ craftBlockState = structureTransformer.transformCraftState(craftBlockState);
+ iblockdata = craftBlockState.getHandle();
+ definedstructure_blockinfo = new DefinedStructure.BlockInfo(blockposition2, iblockdata, (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState<?> craftBlockEntityState ? craftBlockEntityState.getSnapshotNBT() : null));
+ }
+ // CraftBukkit end
if (worldaccess.setBlock(blockposition2, iblockdata, i)) {
j = Math.min(j, blockposition2.getX());
@@ -296,7 +334,7 @@
if (definedstructure_blockinfo.nbt != null) {
tileentity = worldaccess.getBlockEntity(blockposition2);
if (tileentity != null) {
- if (tileentity instanceof RandomizableContainer) {
+ if (structureTransformer == null && tileentity instanceof RandomizableContainer) { // CraftBukkit - only process if don't have a transformer access (Was already set above) - SPIGOT-7520: Use structureTransformer as check, so that it is the same as above
definedstructure_blockinfo.nbt.putLong("LootTableSeed", randomsource.nextLong());
}
@@ -401,7 +439,7 @@
}
if (!definedstructureinfo.isIgnoreEntities()) {
- this.placeEntities(worldaccess, blockposition, definedstructureinfo.getMirror(), definedstructureinfo.getRotation(), definedstructureinfo.getRotationPivot(), structureboundingbox, definedstructureinfo.shouldFinalizeEntities());
+ this.placeEntities(wrappedAccess, blockposition, definedstructureinfo.getMirror(), definedstructureinfo.getRotation(), definedstructureinfo.getRotationPivot(), structureboundingbox, definedstructureinfo.shouldFinalizeEntities()); // CraftBukkit
}
return true;
@@ -503,11 +541,13 @@
}
private static Optional<Entity> createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) {
- try {
+ // CraftBukkit start
+ // try {
return EntityTypes.create(nbttagcompound, worldaccess.getLevel(), EntitySpawnReason.STRUCTURE);
- } catch (Exception exception) {
- return Optional.empty();
- }
+ // } catch (Exception exception) {
+ // return Optional.empty();
+ // }
+ // CraftBukkit end
}
public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) {
@@ -721,6 +761,11 @@
nbttagcompound.put("entities", nbttaglist3);
nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ()));
+ // CraftBukkit start - PDC
+ if (!this.persistentDataContainer.isEmpty()) {
+ nbttagcompound.put("BukkitValues", this.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
return GameProfileSerializer.addCurrentDataVersion(nbttagcompound);
}
@@ -760,6 +805,12 @@
}
}
+ // CraftBukkit start - PDC
+ NBTBase base = nbttagcompound.get("BukkitValues");
+ if (base instanceof NBTTagCompound) {
+ this.persistentDataContainer.putAll((NBTTagCompound) base);
+ }
+ // CraftBukkit end
}
private void loadPalette(HolderGetter<Block> holdergetter, NBTTagList nbttaglist, NBTTagList nbttaglist1) {
@@ -924,7 +975,7 @@
public IBlockData stateFor(int i) {
IBlockData iblockdata = (IBlockData) this.ids.byId(i);
- return iblockdata == null ? DefinedStructure.c.DEFAULT_BLOCK_STATE : iblockdata;
+ return iblockdata == null ? DEFAULT_BLOCK_STATE : iblockdata; // CraftBukkit - decompile error
}
public Iterator<IBlockData> iterator() {

View File

@@ -1,12 +1,12 @@
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
@@ -22,7 +22,7 @@
private LiquidSettings liquidSettings;
@Nullable
private RandomSource random;
- private int palette;
+ public int palette = -1; // CraftBukkit - Set initial value so we know if the palette has been set forcefully
private final List<DefinedStructureProcessor> processors;
private final List<StructureProcessor> processors;
private boolean knownShape;
private boolean finalizeEntities;
@@ -149,6 +149,13 @@
@@ -18,8 +18,8 @@
+ if (this.palette >= i) {
+ throw new IllegalArgumentException("Palette index out of bounds. Got " + this.palette + " where there are only " + i + " palettes available.");
+ }
+ return list.get(this.palette);
+ return infoLists.get(this.palette);
+ // CraftBukkit end
} else {
return (DefinedStructure.b) list.get(this.getRandom(blockposition).nextInt(i));
return (StructureTemplate.Palette) infoLists.get(this.getRandom(pos).nextInt(i));
}

View File

@@ -0,0 +1,152 @@
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java
@@ -25,6 +25,7 @@
import net.minecraft.nbt.IntTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
+import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Clearable;
@@ -55,6 +56,9 @@
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape;
import net.minecraft.world.phys.shapes.DiscreteVoxelShape;
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
+// CraftBukkit end
public class StructureTemplate {
@@ -73,6 +77,11 @@
public final List<StructureTemplate.StructureEntityInfo> entityInfoList = Lists.newArrayList();
private Vec3i size;
private String author;
+
+ // CraftBukkit start - data containers
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
+ public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY);
+ // CraftBukkit end
public StructureTemplate() {
this.size = Vec3i.ZERO;
@@ -147,7 +156,7 @@
}
private static List<StructureTemplate.StructureBlockInfo> buildInfoList(List<StructureTemplate.StructureBlockInfo> fullBlocks, List<StructureTemplate.StructureBlockInfo> blocksWithNbt, List<StructureTemplate.StructureBlockInfo> otherBlocks) {
- Comparator<StructureTemplate.StructureBlockInfo> comparator = Comparator.comparingInt((definedstructure_blockinfo) -> {
+ Comparator<StructureTemplate.StructureBlockInfo> comparator = Comparator.<StructureTemplate.StructureBlockInfo>comparingInt((definedstructure_blockinfo) -> { // CraftBukkit - decompile error
return definedstructure_blockinfo.pos.getY();
}).thenComparingInt((definedstructure_blockinfo) -> {
return definedstructure_blockinfo.pos.getX();
@@ -253,6 +262,19 @@
if (this.palettes.isEmpty()) {
return false;
} else {
+ // CraftBukkit start
+ // We only want the TransformerGeneratorAccess at certain locations because in here are many "block update" calls that shouldn't be transformed
+ ServerLevelAccessor wrappedAccess = world;
+ org.bukkit.craftbukkit.util.CraftStructureTransformer structureTransformer = null;
+ if (wrappedAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) {
+ world = transformerAccess.getHandle();
+ structureTransformer = transformerAccess.getStructureTransformer();
+ // The structureTransformer is not needed if we can not transform blocks therefore we can save a little bit of performance doing this
+ if (structureTransformer != null && !structureTransformer.canTransformBlocks()) {
+ structureTransformer = null;
+ }
+ }
+ // CraftBukkit end
List<StructureTemplate.StructureBlockInfo> list = placementData.getRandomPalette(this.palettes, pos).blocks();
if ((!list.isEmpty() || !placementData.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 && this.size.getY() >= 1 && this.size.getZ() >= 1) {
@@ -284,6 +306,20 @@
Clearable.tryClear(tileentity);
world.setBlock(blockposition2, Blocks.BARRIER.defaultBlockState(), 20);
}
+ // CraftBukkit start
+ if (structureTransformer != null) {
+ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, blockposition2, iblockdata, null);
+ if (definedstructure_blockinfo.nbt != null && craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState<?> entityState) {
+ entityState.loadData(definedstructure_blockinfo.nbt);
+ if (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftLootable<?> craftLootable) {
+ craftLootable.setSeed(random.nextLong());
+ }
+ }
+ craftBlockState = structureTransformer.transformCraftState(craftBlockState);
+ iblockdata = craftBlockState.getHandle();
+ definedstructure_blockinfo = new StructureTemplate.StructureBlockInfo(blockposition2, iblockdata, (craftBlockState instanceof org.bukkit.craftbukkit.block.CraftBlockEntityState<?> craftBlockEntityState ? craftBlockEntityState.getSnapshotNBT() : null));
+ }
+ // CraftBukkit end
if (world.setBlock(blockposition2, iblockdata, flags)) {
j = Math.min(j, blockposition2.getX());
@@ -296,7 +332,7 @@
if (definedstructure_blockinfo.nbt != null) {
tileentity = world.getBlockEntity(blockposition2);
if (tileentity != null) {
- if (tileentity instanceof RandomizableContainer) {
+ if (structureTransformer == null && tileentity instanceof RandomizableContainer) { // CraftBukkit - only process if don't have a transformer access (Was already set above) - SPIGOT-7520: Use structureTransformer as check, so that it is the same as above
definedstructure_blockinfo.nbt.putLong("LootTableSeed", random.nextLong());
}
@@ -401,7 +437,7 @@
}
if (!placementData.isIgnoreEntities()) {
- this.placeEntities(world, pos, placementData.getMirror(), placementData.getRotation(), placementData.getRotationPivot(), structureboundingbox, placementData.shouldFinalizeEntities());
+ this.placeEntities(wrappedAccess, pos, placementData.getMirror(), placementData.getRotation(), placementData.getRotationPivot(), structureboundingbox, placementData.shouldFinalizeEntities()); // CraftBukkit
}
return true;
@@ -503,11 +539,13 @@
}
private static Optional<Entity> createEntityIgnoreException(ServerLevelAccessor world, CompoundTag nbt) {
- try {
+ // CraftBukkit start
+ // try {
return EntityType.create(nbt, world.getLevel(), EntitySpawnReason.STRUCTURE);
- } catch (Exception exception) {
- return Optional.empty();
- }
+ // } catch (Exception exception) {
+ // return Optional.empty();
+ // }
+ // CraftBukkit end
}
public Vec3i getSize(Rotation rotation) {
@@ -721,6 +759,11 @@
nbt.put("entities", nbttaglist3);
nbt.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ()));
+ // CraftBukkit start - PDC
+ if (!this.persistentDataContainer.isEmpty()) {
+ nbt.put("BukkitValues", this.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
return NbtUtils.addCurrentDataVersion(nbt);
}
@@ -760,6 +803,12 @@
}
}
+ // CraftBukkit start - PDC
+ Tag base = nbt.get("BukkitValues");
+ if (base instanceof CompoundTag) {
+ this.persistentDataContainer.putAll((CompoundTag) base);
+ }
+ // CraftBukkit end
}
private void loadPalette(HolderGetter<Block> blockLookup, ListTag palette, ListTag blocks) {
@@ -924,7 +973,7 @@
public BlockState stateFor(int id) {
BlockState iblockdata = (BlockState) this.ids.byId(id);
- return iblockdata == null ? StructureTemplate.SimplePalette.DEFAULT_BLOCK_STATE : iblockdata;
+ return iblockdata == null ? SimplePalette.DEFAULT_BLOCK_STATE : iblockdata; // CraftBukkit - decompile error
}
public Iterator<BlockState> iterator() {