Work on compile errors

This commit is contained in:
Bjarne Koll 2024-10-25 12:30:19 +02:00
parent a040040900
commit f37c1be91e
16 changed files with 60 additions and 39 deletions

View file

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
BlockState iblockdata = this.getBlockStateIfLoaded(blockposition); BlockState iblockdata = this.getBlockStateIfLoaded(blockposition);
if (iblockdata == null) { if (iblockdata == null) {
@@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor {
return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); return BlockHitResult.miss(raytrace1.getTo(), Direction.getApproximateNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
} }
// Paper end - Prevent raytrace from loading chunks // Paper end - Prevent raytrace from loading chunks
- if (iblockdata.isAir()) return null; // Paper - Perf: optimise air cases - if (iblockdata.isAir()) return null; // Paper - Perf: optimise air cases

View file

@ -13,11 +13,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityitem.setDefaultPickUpDelay(); entityitem.setDefaultPickUpDelay();
+ // Paper start - Call EntityDropItemEvent + // Paper start - Call EntityDropItemEvent
+ return this.spawnAtLocation(entityitem); + return this.spawnAtLocation(world, entityitem);
+ } + }
+ } + }
+ @Nullable + @Nullable
+ public ItemEntity spawnAtLocation(ItemEntity entityitem) { + public ItemEntity spawnAtLocation(ServerLevel world, ItemEntity entityitem) {
+ { + {
+ // Paper end - Call EntityDropItemEvent + // Paper end - Call EntityDropItemEvent
// CraftBukkit start // CraftBukkit start

View file

@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java --- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java +++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor {
return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); return BlockHitResult.miss(raytrace1.getTo(), Direction.getApproximateNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
} }
// Paper end - Prevent raytrace from loading chunks // Paper end - Prevent raytrace from loading chunks
- FluidState fluid = this.getFluidState(blockposition); - FluidState fluid = this.getFluidState(blockposition);

View file

@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return; + return;
+ } + }
+ +
+ int i = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); + int i = worldserver.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
+ if (i <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { + if (i <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) {
+ return; + return;
+ } + }

View file

@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - Fix item duplication and teleport issues + // Paper start - Fix item duplication and teleport issues
+ if (!this.isAlive() || !this.valid) { + if (!this.isAlive() || !this.valid) {
+ LOGGER.warn("Illegal Entity Teleport " + this + " to " + teleportTarget.newLevel() + ":" + teleportTarget.pos(), new Throwable()); + LOGGER.warn("Illegal Entity Teleport " + this + " to " + teleportTarget.newLevel() + ":" + teleportTarget.position(), new Throwable());
+ return null; + return null;
+ } + }
+ // Paper end - Fix item duplication and teleport issues + // Paper end - Fix item duplication and teleport issues

View file

@ -21,22 +21,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - Call missing map initialize event and set id + // Paper start - Call missing map initialize event and set id
+ final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage();
+ +
+ final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id.key()); + final Optional<net.minecraft.world.level.saveddata.SavedData> cacheEntry = storage.cache.get(id.key());
+ if (existing == null && !storage.cache.containsKey(id.key())) { + if (cacheEntry == null) { // Cache did not contain, try to load and may init
+ final MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id.key()); + final MapItemSavedData worldmap = storage.get(MapItemSavedData.factory(), id.key()); // get populates the cache
+ storage.cache.put(id.key(), worldmap); + if (worldmap != null) { // map was read, init it and return
+ if (worldmap != null) {
+ worldmap.id = id; + worldmap.id = id;
+ new MapInitializeEvent(worldmap.mapView).callEvent(); + new MapInitializeEvent(worldmap.mapView).callEvent();
+ return worldmap; + return worldmap;
+ } + }
+ } else if (existing instanceof MapItemSavedData mapItemSavedData) { +
+ mapItemSavedData.id = id; + return null; // Map does not exist, reading failed.
} }
- return worldmap; - return worldmap;
- // CraftBukkit end - // CraftBukkit end
+ +
+ return existing instanceof MapItemSavedData data ? data : null; + // Cache entry exists, update it with the id ref and return.
+ if (cacheEntry.orElse(null) instanceof final MapItemSavedData mapItemSavedData) {
+ mapItemSavedData.id = id;
+ return mapItemSavedData;
+ }
+
+ return null;
+ // Paper end - Call missing map initialize event and set id + // Paper end - Call missing map initialize event and set id
} }

View file

@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper start - remove player from map on drop + // Paper start - remove player from map on drop
+ if (itemstack.getItem() == Items.FILLED_MAP) { + if (itemstack.getItem() == net.minecraft.world.item.Items.FILLED_MAP) {
+ net.minecraft.world.level.saveddata.maps.MapItemSavedData worldmap = net.minecraft.world.item.MapItem.getSavedData(itemstack, this.level()); + net.minecraft.world.level.saveddata.maps.MapItemSavedData worldmap = net.minecraft.world.item.MapItem.getSavedData(itemstack, this.level());
+ if (worldmap != null) { + if (worldmap != null) {
+ worldmap.tickCarriedBy(this, itemstack); + worldmap.tickCarriedBy(this, itemstack);

View file

@ -4991,7 +4991,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public void scheduleOnMain(Runnable runnable) { + public void scheduleOnMain(Runnable runnable) {
+ // postToMainThread does not work the same as older versions of mc + // postToMainThread does not work the same as older versions of mc
+ // This method is actually used to create a TickTask, which can then be posted onto main + // This method is actually used to create a TickTask, which can then be posted onto main
+ this.tell(this.wrapRunnable(runnable)); + this.schedule(this.wrapRunnable(runnable));
+ } + }
+ // Paper end + // Paper end

View file

@ -162,23 +162,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }; + };
+ } + }
+ +
+ public static net.minecraft.world.entity.RelativeMovement toNmsRelativeFlag(io.papermc.paper.entity.TeleportFlag.Relative apiFlag) { + public static net.minecraft.world.entity.Relative toNmsRelativeFlag(io.papermc.paper.entity.TeleportFlag.Relative apiFlag) {
+ return switch (apiFlag) { + return switch (apiFlag) {
+ case X -> net.minecraft.world.entity.RelativeMovement.X; + case X -> net.minecraft.world.entity.Relative.X;
+ case Y -> net.minecraft.world.entity.RelativeMovement.Y; + case Y -> net.minecraft.world.entity.Relative.Y;
+ case Z -> net.minecraft.world.entity.RelativeMovement.Z; + case Z -> net.minecraft.world.entity.Relative.Z;
+ case PITCH -> net.minecraft.world.entity.RelativeMovement.X_ROT; + case PITCH -> net.minecraft.world.entity.Relative.X_ROT;
+ case YAW -> net.minecraft.world.entity.RelativeMovement.Y_ROT; + case YAW -> net.minecraft.world.entity.Relative.Y_ROT;
+ }; + };
+ } + }
+ +
+ public static io.papermc.paper.entity.TeleportFlag.Relative toApiRelativeFlag(net.minecraft.world.entity.RelativeMovement nmsFlag) { + public static io.papermc.paper.entity.TeleportFlag.Relative toApiRelativeFlag(net.minecraft.world.entity.Relative nmsFlag) {
+ return switch (nmsFlag) { + return switch (nmsFlag) {
+ case X -> io.papermc.paper.entity.TeleportFlag.Relative.X; + case X -> io.papermc.paper.entity.TeleportFlag.Relative.X;
+ case Y -> io.papermc.paper.entity.TeleportFlag.Relative.Y; + case Y -> io.papermc.paper.entity.TeleportFlag.Relative.Y;
+ case Z -> io.papermc.paper.entity.TeleportFlag.Relative.Z; + case Z -> io.papermc.paper.entity.TeleportFlag.Relative.Z;
+ case X_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.PITCH; + case X_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.PITCH;
+ case Y_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.YAW; + case Y_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.YAW;
+ default -> throw new RuntimeException("not yet"); // TODO figure out what to do with new flags
+ }; + };
+ } + }
+ +
@ -258,7 +259,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (fromWorld == toWorld) { if (fromWorld == toWorld) {
- entity.connection.teleport(to); - entity.connection.teleport(to);
+ // Paper start - Teleport API + // Paper start - Teleport API
+ final Set<net.minecraft.world.entity.RelativeMovement> nms = java.util.EnumSet.noneOf(net.minecraft.world.entity.RelativeMovement.class); + final Set<net.minecraft.world.entity.Relative> nms = java.util.EnumSet.noneOf(net.minecraft.world.entity.Relative.class);
+ for (final io.papermc.paper.entity.TeleportFlag.Relative bukkit : relativeArguments) { + for (final io.papermc.paper.entity.TeleportFlag.Relative bukkit : relativeArguments) {
+ nms.add(toNmsRelativeFlag(bukkit)); + nms.add(toNmsRelativeFlag(bukkit));
+ } + }

View file

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, this.overworld().getRandomSequences(), org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider); - world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, this.overworld().getRandomSequences(), org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ // Paper start - option to use the dimension_type to check if spawners should be added. I imagine mojang will add some datapack-y way of managing this in the future. + // Paper start - option to use the dimension_type to check if spawners should be added. I imagine mojang will add some datapack-y way of managing this in the future.
+ final List<CustomSpawner> spawners; + final List<CustomSpawner> spawners;
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.useDimensionTypeForCustomSpawners && this.registryAccess().registryOrThrow(Registries.DIMENSION_TYPE).getResourceKey(worlddimension.type().value()).orElseThrow() == net.minecraft.world.level.dimension.BuiltinDimensionTypes.OVERWORLD) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.useDimensionTypeForCustomSpawners && this.registryAccess().lookupOrThrow(Registries.DIMENSION_TYPE).getResourceKey(worlddimension.type().value()).orElseThrow() == net.minecraft.world.level.dimension.BuiltinDimensionTypes.OVERWORLD) {
+ spawners = list; + spawners = list;
+ } else { + } else {
+ spawners = Collections.emptyList(); + spawners = Collections.emptyList();

View file

@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // copied the last function parameter (listed below) + // copied the last function parameter (listed below)
+ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); + Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());
+ +
+ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); + return BlockHitResult.miss(raytrace1.getTo(), Direction.getApproximateNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
+ } + }
+ // Paper end - Prevent raytrace from loading chunks + // Paper end - Prevent raytrace from loading chunks
FluidState fluid = this.getFluidState(blockposition); FluidState fluid = this.getFluidState(blockposition);

View file

@ -73,6 +73,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private ContextKeySet paramSet; private ContextKeySet paramSet;
private Optional<ResourceLocation> randomSequence; private Optional<ResourceLocation> randomSequence;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
@@ -0,0 +0,0 @@ public abstract class CraftBoat extends CraftVehicle implements Boat {
throw new EnumConstantNotPresentException(Type.class, boatType.toString());
}
- public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.Boat.EnumStatus enumStatus) {
+ public static Status boatStatusFromNms(net.minecraft.world.entity.vehicle.AbstractBoat.Status enumStatus) { // Paper - remap fixes
return switch (enumStatus) {
default -> throw new EnumConstantNotPresentException(Status.class, enumStatus.name());
case IN_AIR -> Status.IN_AIR;
diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/DyeColorsTest.java --- a/src/test/java/org/bukkit/DyeColorsTest.java

View file

@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
} }
if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false if (this.shouldDropLoot() && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false
// SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0); this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0);
- this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag); - this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag);
@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- entityitem.setDefaultPickUpDelay(); - entityitem.setDefaultPickUpDelay();
+ entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer) + entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer)
// Paper start - Call EntityDropItemEvent // Paper start - Call EntityDropItemEvent
return this.spawnAtLocation(entityitem); return this.spawnAtLocation(world, entityitem);
} }
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -1076,14 +1076,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
this.level.timings.doChunkUnload.startTiming(); // Spigot this.level.timings.doChunkUnload.startTiming(); // Spigot
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
gameprofilerfiller.pop();
this.clearCache();
}
+ if (this.level.getServer().tickRateManager().runsNormally()) this.level.timings.chunkTicks.startTiming(); // Paper
private void tickChunks() {
long i = this.level.getGameTime();
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk = playerchunk.getTickingChunk(); LevelChunk chunk = playerchunk.getTickingChunk();

View file

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
} }
+ if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false + if (this.shouldDropLoot() && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false
// SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0); this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0);
this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag); this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag);

View file

@ -8,14 +8,24 @@ diff --git a/src/main/java/net/minecraft/world/level/block/LightBlock.java b/src
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/LightBlock.java --- a/src/main/java/net/minecraft/world/level/block/LightBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LightBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LightBlock.java
@@ -0,0 +0,0 @@ import java.util.function.ToIntFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.component.DataComponents;
+import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
+import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
@@ -0,0 +0,0 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock { @@ -0,0 +0,0 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock {
builder.add(LEVEL, WATERLOGGED); builder.add(LEVEL, WATERLOGGED);
} }
+ // Paper start - prevent unintended light block manipulation + // Paper start - prevent unintended light block manipulation
+ @Override + @Override
+ protected net.minecraft.world.ItemInteractionResult useItemOn(final ItemStack stack, final BlockState state, final Level world, final BlockPos pos, final Player player, final net.minecraft.world.InteractionHand hand, final BlockHitResult hit) { + protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
+ if (player.getItemInHand(hand).getItem() != Items.LIGHT || !player.mayInteract(world, pos) || !player.mayUseItemAt(pos, hit.getDirection(), player.getItemInHand(hand))) { return net.minecraft.world.ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION; } // Paper - Prevent unintended light block manipulation + if (player.getItemInHand(hand).getItem() != Items.LIGHT || (world instanceof final ServerLevel serverLevel && !player.mayInteract(serverLevel, pos)) || !player.mayUseItemAt(pos, hit.getDirection(), player.getItemInHand(hand))) { return net.minecraft.world.InteractionResult.PASS; } // Paper - Prevent unintended light block manipulation
+ return super.useItemOn(stack, state, world, pos, player, hand, hit); + return super.useItemOn(stack, state, world, pos, player, hand, hit);
+ } + }
+ // Paper end - prevent unintended light block manipulation + // Paper end - prevent unintended light block manipulation