mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Work on compile errors
This commit is contained in:
parent
a040040900
commit
f37c1be91e
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
BlockState iblockdata = this.getBlockStateIfLoaded(blockposition);
|
||||
if (iblockdata == null) {
|
||||
@@ -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
|
||||
- if (iblockdata.isAir()) return null; // Paper - Perf: optimise air cases
|
||||
|
@ -13,11 +13,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
entityitem.setDefaultPickUpDelay();
|
||||
+ // Paper start - Call EntityDropItemEvent
|
||||
+ return this.spawnAtLocation(entityitem);
|
||||
+ return this.spawnAtLocation(world, entityitem);
|
||||
+ }
|
||||
+ }
|
||||
+ @Nullable
|
||||
+ public ItemEntity spawnAtLocation(ItemEntity entityitem) {
|
||||
+ public ItemEntity spawnAtLocation(ServerLevel world, ItemEntity entityitem) {
|
||||
+ {
|
||||
+ // Paper end - Call EntityDropItemEvent
|
||||
// CraftBukkit start
|
||||
|
@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/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 {
|
||||
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
|
||||
- FluidState fluid = this.getFluidState(blockposition);
|
||||
|
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ 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) {
|
||||
+ return;
|
||||
+ }
|
||||
|
@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
+ // Paper start - Fix item duplication and teleport issues
|
||||
+ 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;
|
||||
+ }
|
||||
+ // Paper end - Fix item duplication and teleport issues
|
||||
|
@ -21,22 +21,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - Call missing map initialize event and set id
|
||||
+ final DimensionDataStorage storage = this.getServer().overworld().getDataStorage();
|
||||
+
|
||||
+ final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id.key());
|
||||
+ if (existing == null && !storage.cache.containsKey(id.key())) {
|
||||
+ final MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id.key());
|
||||
+ storage.cache.put(id.key(), worldmap);
|
||||
+ if (worldmap != null) {
|
||||
+ final Optional<net.minecraft.world.level.saveddata.SavedData> cacheEntry = storage.cache.get(id.key());
|
||||
+ if (cacheEntry == null) { // Cache did not contain, try to load and may init
|
||||
+ final MapItemSavedData worldmap = storage.get(MapItemSavedData.factory(), id.key()); // get populates the cache
|
||||
+ if (worldmap != null) { // map was read, init it and return
|
||||
+ worldmap.id = id;
|
||||
+ new MapInitializeEvent(worldmap.mapView).callEvent();
|
||||
+ return worldmap;
|
||||
+ }
|
||||
+ } else if (existing instanceof MapItemSavedData mapItemSavedData) {
|
||||
+ mapItemSavedData.id = id;
|
||||
+
|
||||
+ return null; // Map does not exist, reading failed.
|
||||
}
|
||||
- return worldmap;
|
||||
- // 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
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
+ // 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());
|
||||
+ if (worldmap != null) {
|
||||
+ worldmap.tickCarriedBy(this, itemstack);
|
||||
|
@ -4991,7 +4991,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public void scheduleOnMain(Runnable runnable) {
|
||||
+ // 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.tell(this.wrapRunnable(runnable));
|
||||
+ this.schedule(this.wrapRunnable(runnable));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
|
@ -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) {
|
||||
+ case X -> net.minecraft.world.entity.RelativeMovement.X;
|
||||
+ case Y -> net.minecraft.world.entity.RelativeMovement.Y;
|
||||
+ case Z -> net.minecraft.world.entity.RelativeMovement.Z;
|
||||
+ case PITCH -> net.minecraft.world.entity.RelativeMovement.X_ROT;
|
||||
+ case YAW -> net.minecraft.world.entity.RelativeMovement.Y_ROT;
|
||||
+ case X -> net.minecraft.world.entity.Relative.X;
|
||||
+ case Y -> net.minecraft.world.entity.Relative.Y;
|
||||
+ case Z -> net.minecraft.world.entity.Relative.Z;
|
||||
+ case PITCH -> net.minecraft.world.entity.Relative.X_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) {
|
||||
+ case X -> io.papermc.paper.entity.TeleportFlag.Relative.X;
|
||||
+ case Y -> io.papermc.paper.entity.TeleportFlag.Relative.Y;
|
||||
+ case Z -> io.papermc.paper.entity.TeleportFlag.Relative.Z;
|
||||
+ case X_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.PITCH;
|
||||
+ 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) {
|
||||
- entity.connection.teleport(to);
|
||||
+ // 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) {
|
||||
+ nms.add(toNmsRelativeFlag(bukkit));
|
||||
+ }
|
||||
|
@ -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);
|
||||
+ // 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;
|
||||
+ 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;
|
||||
+ } else {
|
||||
+ spawners = Collections.emptyList();
|
||||
|
@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // copied the last function parameter (listed below)
|
||||
+ 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
|
||||
FluidState fluid = this.getFluidState(blockposition);
|
||||
|
@ -73,6 +73,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private ContextKeySet paramSet;
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/DyeColorsTest.java
|
||||
|
@ -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)
|
||||
this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0);
|
||||
- this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag);
|
||||
@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- entityitem.setDefaultPickUpDelay();
|
||||
+ entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer)
|
||||
// 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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
|
@ -1076,14 +1076,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
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 {
|
||||
LevelChunk chunk = playerchunk.getTickingChunk();
|
||||
|
||||
|
@ -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)
|
||||
this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0);
|
||||
this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag);
|
||||
|
@ -8,14 +8,24 @@ diff --git a/src/main/java/net/minecraft/world/level/block/LightBlock.java b/src
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/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 {
|
||||
builder.add(LEVEL, WATERLOGGED);
|
||||
}
|
||||
|
||||
+ // Paper start - prevent unintended light block manipulation
|
||||
+ @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) {
|
||||
+ 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
|
||||
+ protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
+ 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);
|
||||
+ }
|
||||
+ // Paper end - prevent unintended light block manipulation
|
||||
|
Loading…
Reference in New Issue
Block a user