Initial 26.2 port

This commit is contained in:
granny
2026-06-03 16:22:25 -07:00
parent bb69e15257
commit 1638c22046
144 changed files with 1133 additions and 830 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -104,6 +_,13 @@
@@ -107,6 +_,13 @@
JvmProfiler.INSTANCE.start(Environment.SERVER);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -320,6 +_,7 @@
@@ -318,6 +_,7 @@
public joptsimple.OptionSet options;
public org.bukkit.command.ConsoleCommandSender console;
public static int currentTick; // Paper - improve tick loop
@@ -8,7 +8,7 @@
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod;
// Paper - don't store the vanilla dispatcher
@@ -336,6 +_,8 @@
@@ -334,6 +_,8 @@
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
@@ -17,7 +17,7 @@
// Paper start - improve tick loop
public final ca.spottedleaf.moonrise.common.time.TickData tickTimes1s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(1L));
public final ca.spottedleaf.moonrise.common.time.TickData tickTimes5s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(5L));
@@ -420,6 +_,7 @@
@@ -418,6 +_,7 @@
public double[] computeTPS() {
final long interval = this.tickRateManager().nanosecondsPerTick();
return new double[] {
@@ -25,7 +25,7 @@
getTPS(this.tickTimes1m, interval),
getTPS(this.tickTimes5m, interval),
getTPS(this.tickTimes15m, interval)
@@ -1047,6 +_,15 @@
@@ -955,6 +_,15 @@
LOGGER.info("Stopping server");
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
@@ -41,7 +41,7 @@
// CraftBukkit start
if (this.server != null) {
this.server.spark.disable(); // Paper - spark
@@ -1141,6 +_,8 @@
@@ -1044,6 +_,8 @@
this.safeShutdown(wait, false);
}
public void safeShutdown(final boolean wait, final boolean isRestarting) {
@@ -50,7 +50,7 @@
this.isRestarting = isRestarting;
this.hasLoggedStop = true; // Paper - Debugging
if (this.isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread("Server stopped"); // Paper - Debugging
@@ -1322,11 +_,21 @@
@@ -1210,11 +_,21 @@
}
// Paper end - Add onboarding message for initial server start
// Paper start - Improve outdated version checking
@@ -73,7 +73,7 @@
while (this.running) {
final long tickStart = System.nanoTime(); // Paper - improve tick loop
long thisTickNanos; // Paper - improve tick loop - diff on change, expect this to be tick interval
@@ -1340,9 +_,11 @@
@@ -1228,9 +_,11 @@
final long ticksBehind = Math.max(1L, this.tickSchedule.getPeriodsAhead(thisTickNanos, tickStart));
final long catchup = (long)Math.max(
1,
@@ -86,7 +86,7 @@
// adjust ticksBehind so that it is not greater-than catchup
if (ticksBehind - catchup > 0L) {
final long difference = ticksBehind - catchup;
@@ -1973,7 +_,7 @@
@@ -1853,7 +_,7 @@
}
public String getServerModName() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PlayerAdvancements.java
+++ b/net/minecraft/server/PlayerAdvancements.java
@@ -148,6 +_,7 @@
@@ -146,6 +_,7 @@
AdvancementHolder advancement = manager.get(id);
if (advancement == null) {
if (!id.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) return; // CraftBukkit
@@ -8,7 +8,7 @@
LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", id, this.playerSavePath);
} else {
this.startProgress(advancement, progress);
@@ -195,6 +_,7 @@
@@ -193,6 +_,7 @@
holder.value().display().ifPresent(display -> {
// Paper start - Add Adventure message to PlayerAdvancementDoneEvent
if (event.message() != null && this.player.level().getGameRules().get(GameRules.SHOW_ADVANCEMENT_MESSAGES)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -211,6 +_,7 @@
@@ -172,6 +_,7 @@
public void run() {
if (!org.bukkit.craftbukkit.Main.useConsole) return; // CraftBukkit
// Paper start - Use TerminalConsoleAppender
@@ -8,7 +8,7 @@
new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start();
/*
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
@@ -289,6 +_,15 @@
@@ -250,6 +_,15 @@
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
@@ -24,7 +24,7 @@
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
// this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading
@@ -331,6 +_,30 @@
@@ -292,6 +_,30 @@
if (true) throw new IllegalStateException("Failed to bind to port", e); // Paper - Propagate failed to bind to port error
return false;
}
@@ -55,7 +55,7 @@
// CraftBukkit start
this.server.loadPlugins();
@@ -406,6 +_,9 @@
@@ -366,6 +_,9 @@
MinecraftServerStatistics.registerJmxMonitoring(this);
LOGGER.info("JMX monitoring enabled");
}

View File

@@ -1,135 +0,0 @@
--- a/net/minecraft/server/gui/MinecraftServerGui.java
+++ b/net/minecraft/server/gui/MinecraftServerGui.java
@@ -39,6 +_,11 @@
private Thread logAppenderThread;
private final Collection<Runnable> finalizers = Lists.newArrayList();
private final AtomicBoolean isClosing = new AtomicBoolean();
+ // Purpur start - GUI Improvements
+ private final CommandHistory history = new CommandHistory();
+ private String currentCommand = "";
+ private int historyIndex = 0;
+ // Purpur end - GUI Improvements
public static MinecraftServerGui showFrameFor(final DedicatedServer server) {
try {
@@ -46,7 +_,7 @@
} catch (Exception var3) {
}
- final JFrame frame = new JFrame("Minecraft server");
+ final JFrame frame = new JFrame("Purpur Minecraft server"); // Purpur - Improve GUI
final MinecraftServerGui gui = new MinecraftServerGui(server);
frame.setDefaultCloseOperation(2);
frame.add(gui);
@@ -54,7 +_,7 @@
frame.setLocationRelativeTo(null);
frame.setVisible(true);
// Paper start - Improve ServerGUI
- frame.setName("Minecraft server");
+ frame.setName("Purpur Minecraft server"); // Purpur - Improve GUI
try {
frame.setIconImage(javax.imageio.ImageIO.read(java.util.Objects.requireNonNull(MinecraftServerGui.class.getClassLoader().getResourceAsStream("logo.png"))));
} catch (java.io.IOException ignore) {
@@ -64,7 +_,7 @@
@Override
public void windowClosing(final WindowEvent event) {
if (!gui.isClosing.getAndSet(true)) {
- frame.setTitle("Minecraft server - shutting down!");
+ frame.setTitle("Purpur Minecraft server - shutting down!"); // Purpur - Improve GUI
server.halt(true);
gui.runFinalizers();
}
@@ -112,7 +_,7 @@
private JComponent buildChatPanel() {
JPanel panel = new JPanel(new BorderLayout());
- JTextArea chatArea = new JTextArea();
+ org.purpurmc.purpur.gui.JColorTextPane chatArea = new org.purpurmc.purpur.gui.JColorTextPane(); // Purpur - GUI Improvements
JScrollPane scrollPane = new JScrollPane(chatArea, 22, 30);
chatArea.setEditable(false);
chatArea.setFont(MONOSPACED);
@@ -121,10 +_,43 @@
String text = chatField.getText().trim();
if (!text.isEmpty()) {
this.server.handleConsoleInput(text, this.server.createCommandSourceStack());
+ // Purpur start - GUI Improvements
+ history.add(text);
+ historyIndex = -1;
+ // Purpur end - GUI Improvements
}
chatField.setText("");
});
+ // Purpur start - GUI Improvements
+ chatField.getInputMap().put(javax.swing.KeyStroke.getKeyStroke("UP"), "up");
+ chatField.getInputMap().put(javax.swing.KeyStroke.getKeyStroke("DOWN"), "down");
+ chatField.getActionMap().put("up", new javax.swing.AbstractAction() {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
+ if (historyIndex < 0) {
+ currentCommand = chatField.getText();
+ }
+ if (historyIndex < history.size() - 1) {
+ chatField.setText(history.get(++historyIndex));
+ }
+ }
+ });
+ chatField.getActionMap().put("down", new javax.swing.AbstractAction() {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
+ if (historyIndex >= 0) {
+ if (historyIndex == 0) {
+ --historyIndex;
+ chatField.setText(currentCommand);
+ } else {
+ --historyIndex;
+ chatField.setText(history.get(historyIndex));
+ }
+ }
+ }
+ });
+ // Purpur end - GUI Improvements
chatArea.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(final FocusEvent arg0) {
@@ -159,7 +_,7 @@
}
private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\e\\[[\\d;]*[^\\d;]"); // CraftBukkit // Paper
- public void print(final JTextArea console, final JScrollPane scrollPane, final String line) {
+ public void print(final org.purpurmc.purpur.gui.JColorTextPane console, final JScrollPane scrollPane, final String line) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> this.print(console, scrollPane, line));
} else {
@@ -170,16 +_,29 @@
shouldScroll = scrollBar.getValue() + scrollBar.getSize().getHeight() + MONOSPACED.getSize() * 4 > scrollBar.getMaximum();
}
- try {
+ /*try { // Purpur - GUI Improvements
document.insertString(document.getLength(), MinecraftServerGui.ANSI.matcher(line).replaceAll(""), null); // CraftBukkit
} catch (BadLocationException var8) {
- }
+ }*/ // Purpur - GUI Improvements
+ console.append(line); // Purpur - GUI Improvements
if (shouldScroll) {
scrollBar.setValue(Integer.MAX_VALUE);
}
}
}
+
+ // Purpur start - GUI Improvements
+ public static class CommandHistory extends java.util.LinkedList<String> {
+ @Override
+ public boolean add(String command) {
+ if (size() > 1000) {
+ remove();
+ }
+ return super.offerFirst(command);
+ }
+ }
+ // Purpur end - GUI Improvements
// Paper start - Add onboarding message for initial server start
private JComponent buildOnboardingPanel() {

View File

@@ -1,181 +0,0 @@
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -219,6 +_,8 @@
private final StructureManager structureManager;
private final StructureCheck structureCheck;
private final boolean tickTime;
+ private double preciseTime; // Purpur - Configurable daylight cycle
+ private boolean forceTime; // Purpur - Configurable daylight cycle
private final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this);
// CraftBukkit start
@@ -643,8 +_,25 @@
// CraftBukkit end
this.tickTime = tickTime;
this.server = server;
- this.customSpawners = customSpawners;
+ this.customSpawners = new ArrayList<>(); // Purpur - Allow toggling special MobSpawners per world
this.serverLevelData = levelData;
+ // Purpur start - Allow toggling special MobSpawners per world
+ if (purpurConfig.phantomSpawning) {
+ this.customSpawners.add(new net.minecraft.world.level.levelgen.PhantomSpawner());
+ }
+ if (purpurConfig.patrolSpawning) {
+ this.customSpawners.add(new net.minecraft.world.level.levelgen.PatrolSpawner());
+ }
+ if (purpurConfig.catSpawning) {
+ this.customSpawners.add(new net.minecraft.world.entity.npc.CatSpawner());
+ }
+ if (purpurConfig.villageSiegeSpawning) {
+ this.customSpawners.add(new net.minecraft.world.entity.ai.village.VillageSiege());
+ }
+ if (purpurConfig.villagerTraderSpawning) {
+ this.customSpawners.add(new net.minecraft.world.entity.npc.wanderingtrader.WanderingTraderSpawner(savedDataStorage));
+ }
+ // Purpur end - Allow toggling special MobSpawners per world
ChunkGenerator generator = levelStem.generator();
// CraftBukkit start
// Paper start - per-world time
@@ -738,6 +_,7 @@
this.chunkDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.ChunkDataController((ServerLevel)(Object)this, this.chunkTaskScheduler);
// Paper end - rewrite chunk system
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
+ this.preciseTime = this.serverLevelData.getGameTime(); // Purpur - Configurable daylight cycle
}
// Paper start
@@ -794,7 +_,7 @@
}
int percentage = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE);
- if (this.sleepStatus.areEnoughSleeping(percentage) && this.sleepStatus.areEnoughDeepSleeping(percentage, this.players)) {
+ if (this.purpurConfig.playersSkipNight && this.sleepStatus.areEnoughSleeping(percentage) && this.sleepStatus.areEnoughDeepSleeping(percentage, this.players)) { // Purpur - Config for skipping night
Optional<Holder<WorldClock>> defaultClock = this.dimensionType().defaultClock();
org.bukkit.event.world.ClockTimeSkipEvent event = null; // Paper - per-world time
if (this.getGameRules().get(GameRules.ADVANCE_TIME) && defaultClock.isPresent()) {
@@ -1036,9 +_,18 @@
&& this.random.nextDouble() < difficulty.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01) // Paper - Configurable spawn chances for skeleton horses
&& !this.getBlockState(pos.below()).is(BlockTags.LIGHTNING_RODS);
if (isTrap) {
+ // Purpur start - Special mobs naturally spawn
+ net.minecraft.world.entity.animal.equine.AbstractHorse skeletonHorse;
+ if (purpurConfig.zombieHorseSpawnChance > 0D && random.nextDouble() <= purpurConfig.zombieHorseSpawnChance) {
+ skeletonHorse = EntityType.ZOMBIE_HORSE.create(this, EntitySpawnReason.EVENT);
+ } else {
+ skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
+ if (skeletonHorse != null) ((SkeletonHorse) skeletonHorse).setTrap(true);
+ }
+ // Purpur end - Special mobs naturally spawn
SkeletonHorse horse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
if (horse != null) {
- horse.setTrap(true);
+ //horse.setTrap(true); // Purpur - Special mobs naturally spawn - moved up
horse.setAge(0);
horse.setPos(pos.getX(), pos.getY(), pos.getZ());
this.addFreshEntity(horse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
@@ -1073,9 +_,35 @@
if (state.is(Blocks.SNOW)) {
int currentLayers = state.getValue(SnowLayerBlock.LAYERS);
if (currentLayers < Math.min(maxHeight, 8)) {
+ // Purpur start - Smooth snow accumulation
+ boolean canSnow = true;
+ // Ensure snow doesn't get more than N layers taller than its neighbors
+ // We only need to check blocks that are taller than the minimum step height
+ if (org.purpurmc.purpur.PurpurConfig.smoothSnowAccumulationStep > 0 && currentLayers >= org.purpurmc.purpur.PurpurConfig.smoothSnowAccumulationStep) {
+ int layersValueMin = currentLayers - org.purpurmc.purpur.PurpurConfig.smoothSnowAccumulationStep;
+ for (Direction direction : Direction.Plane.HORIZONTAL) {
+ BlockPos blockPosNeighbor = topPos.relative(direction);
+ BlockState blockStateNeighbor = this.getBlockState(blockPosNeighbor);
+ if (blockStateNeighbor.is(Blocks.SNOW)) {
+ // Special check for snow layers, if neighbors are too short, don't accumulate
+ int layersValueNeighbor = blockStateNeighbor.getValue(SnowLayerBlock.LAYERS);
+ if (layersValueNeighbor <= layersValueMin) {
+ canSnow = false;
+ break;
+ }
+ } else if (!Block.isFaceFull(blockStateNeighbor.getCollisionShape(this, blockPosNeighbor), direction.getOpposite())) {
+ // Since our layer is tall enough already, if we have a non-full neighbor block, don't accumulate
+ canSnow = false;
+ break;
+ }
+ }
+ }
+ if (canSnow) {
+ // Purpur end - Smooth snow accumulation
BlockState newState = state.setValue(SnowLayerBlock.LAYERS, currentLayers + 1);
Block.pushEntitiesUp(state, newState, this, topPos);
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, topPos, newState, Block.UPDATE_ALL, null); // CraftBukkit
+ } // Purpur - Smooth snow accumulation
}
} else {
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, topPos, Blocks.SNOW.defaultBlockState(), Block.UPDATE_ALL, null); // CraftBukkit
@@ -1096,7 +_,7 @@
p -> p.is(PoiTypes.LIGHTNING_ROD),
lightningRodPos -> lightningRodPos.getY() == this.getHeight(Heightmap.Types.WORLD_SURFACE, lightningRodPos.getX(), lightningRodPos.getZ()) - 1,
center,
- 128,
+ org.purpurmc.purpur.PurpurConfig.lightningRodRange, // Purpur - Make lightning rod range configurable
PoiManager.Occupancy.ANY
);
return nearbyLightningRod.map(blockPos -> blockPos.above(1));
@@ -1144,8 +_,26 @@
int percentage = this.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE);
Component message;
if (this.sleepStatus.areEnoughSleeping(percentage)) {
+ // Purpur start - Customizable sleeping actionbar messages
+ if (org.purpurmc.purpur.PurpurConfig.sleepSkippingNight.isBlank()) {
+ return;
+ }
+ if (!org.purpurmc.purpur.PurpurConfig.sleepSkippingNight.equalsIgnoreCase("default")) {
+ message = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.sleepSkippingNight));
+ } else
+ // Purpur end - Customizable sleeping actionbar messages
message = Component.translatable("sleep.skipping_night");
} else {
+ // Purpur start - Customizable sleeping actionbar messages
+ if (org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent.isBlank()) {
+ return;
+ }
+ if (!org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent.equalsIgnoreCase("default")) {
+ message = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent,
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.parsed("count", Integer.toString(this.sleepStatus.amountSleeping())),
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.parsed("total", Integer.toString(this.sleepStatus.sleepersNeeded(percentage)))));
+ } else
+ // Purpur end - Customizable sleeping actionbar messages
message = Component.translatable("sleep.players_sleeping", this.sleepStatus.amountSleeping(), this.sleepStatus.sleepersNeeded(percentage));
}
@@ -1311,6 +_,7 @@
public void resetWeatherCycle() {
WeatherData weatherData = this.getWeatherData();
// CraftBukkit start
+ if (this.purpurConfig.rainStopsAfterSleep) // Purpur - Option for if rain and thunder should stop on sleep
weatherData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - Add cause to Weather/ThunderChangeEvents
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
// Not that everyone ever manages to get the whole server to sleep at the same time....
@@ -1318,6 +_,7 @@
weatherData.setRainTime(0);
}
// CraftBukkit end
+ if (this.purpurConfig.thunderStopsAfterSleep) // Purpur - Option for if rain and thunder should stop on sleep
weatherData.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - Add cause to Weather/ThunderChangeEvents
// CraftBukkit start
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
@@ -1989,7 +_,7 @@
Explosion.BlockInteraction blockInteraction = switch (interactionType) {
case NONE -> Explosion.BlockInteraction.KEEP;
case BLOCK -> this.getDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY);
- case MOB -> this.getGameRules().get(GameRules.MOB_GRIEFING)
+ case MOB -> ((source instanceof net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball) ? this.getGameRules().get(GameRules.MOB_GRIEFING, this.purpurConfig.fireballsMobGriefingOverride) : this.getGameRules().get(GameRules.MOB_GRIEFING)) // Purpur - Add mobGriefing override to everything affected
? this.getDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY)
: Explosion.BlockInteraction.KEEP;
case TNT -> this.getDestroyType(GameRules.TNT_EXPLOSION_DROP_DECAY);
@@ -2914,7 +_,7 @@
// Spigot start
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
// Paper start - Fix merchant inventory not closing on entity removal
- if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) {
+ if (!entity.level().purpurConfig.playerVoidTrading && entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { // Purpur - Allow void trading
merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED);
}
// Paper end - Fix merchant inventory not closing on entity removal

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -435,6 +_,9 @@
@@ -436,6 +_,9 @@
public boolean isRealPlayer; // Paper
public com.destroystokyo.paper.event.entity.@Nullable PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
public org.bukkit.event.player.PlayerQuitEvent.@Nullable QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
@@ -8,9 +8,9 @@
+ private boolean compassBar = false; // Purpur - Add compass command
+ private boolean ramBar = false; // Purpur - Implement rambar commands
// Paper start - rewrite chunk system
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
@@ -508,6 +_,9 @@
public ServerPlayer(final MinecraftServer server, final ServerLevel level, final GameProfile gameProfile, final ClientInformation clientInformation) {
super(level, gameProfile);
@@ -480,6 +_,9 @@
this.respawnConfig = input.read("respawn", ServerPlayer.RespawnConfig.CODEC).orElse(null);
this.spawnExtraParticlesOnFall = input.getBooleanOr("spawn_extra_particles_on_fall", false);
this.raidOmenPosition = input.read("raid_omen_position", BlockPos.CODEC).orElse(null);
@@ -20,7 +20,7 @@
// Paper start - Expand PlayerGameModeChangeEvent
this.loadGameTypes(input);
}
@@ -549,6 +_,9 @@
@@ -522,6 +_,9 @@
output.store("ShoulderEntityRight", CompoundTag.CODEC, this.getShoulderEntityRight());
}
this.getBukkitEntity().setExtraData(output); // CraftBukkit
@@ -30,7 +30,7 @@
}
private void saveParentVehicle(final ValueOutput playerOutput) {
@@ -1179,6 +_,7 @@
@@ -1158,6 +_,7 @@
// Paper - moved up to sendClientboundPlayerCombatKillPacket()
sendClientboundPlayerCombatKillPacket(event.getShowDeathMessages(), deathScreenMessage); // Paper - Expand PlayerDeathEvent
Team team = this.getTeam();
@@ -38,7 +38,7 @@
if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) {
this.server.getPlayerList().broadcastSystemMessage(deathMessage, false);
} else if (team.getDeathMessageVisibility() == Team.Visibility.HIDE_FOR_OTHER_TEAMS) {
@@ -1288,6 +_,13 @@
@@ -1267,6 +_,13 @@
return false;
}
@@ -52,7 +52,7 @@
Entity entity = source.getEntity();
if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false.
!(entity instanceof Player player && !this.canHarmPlayer(player))
@@ -1529,7 +_,7 @@
@@ -1508,7 +_,7 @@
}
if (newLevel.dimension() == lastDimension) {
@@ -61,7 +61,7 @@
this.connection.resetPosition();
transition.postTeleportTransition().onTransition(this);
return this;
@@ -1552,6 +_,7 @@
@@ -1531,6 +_,7 @@
profiler.pop();
profiler.push("placing");
@@ -69,7 +69,7 @@
this.setServerLevel(newLevel);
this.connection.internalTeleport(PositionMoveRotation.of(transition), transition.relatives()); // CraftBukkit - use internal teleport without event
this.connection.resetPosition();
@@ -1664,7 +_,7 @@
@@ -1643,7 +_,7 @@
new AABB(bedCenter.x() - 8.0, bedCenter.y() - 5.0, bedCenter.z() - 8.0, bedCenter.x() + 8.0, bedCenter.y() + 5.0, bedCenter.z() + 8.0),
monster -> monster.isPreventingPlayerRest(this.level(), this)
);
@@ -78,7 +78,7 @@
return Either.left(Player.BedSleepingProblem.NOT_SAFE);
}
}
@@ -1700,7 +_,17 @@
@@ -1679,7 +_,17 @@
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
});
if (!this.level().canSleepThroughNights()) {
@@ -97,7 +97,7 @@
}
this.level().updateSleepingPlayerList();
@@ -1794,6 +_,7 @@
@@ -1774,6 +_,7 @@
@Override
public void openTextEdit(final SignBlockEntity sign, final boolean isFrontText) {
@@ -105,7 +105,7 @@
this.connection.send(new ClientboundBlockUpdatePacket(this.level(), sign.getBlockPos()));
this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), isFrontText));
}
@@ -2138,6 +_,26 @@
@@ -2118,6 +_,26 @@
this.lastSentExp = -1; // CraftBukkit - Added to reset
}
@@ -132,7 +132,7 @@
@Override
public void completeUsingItem() {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
@@ -2373,6 +_,20 @@
@@ -2355,6 +_,20 @@
);
}
@@ -153,7 +153,7 @@
@Override
public void sendSystemMessage(final Component message) {
this.sendSystemMessage(message, false);
@@ -2524,7 +_,67 @@
@@ -2506,7 +_,67 @@
public void resetLastActionTime() {
this.lastActionTime = Util.getMillis();
@@ -222,7 +222,7 @@
public ServerStatsCounter getStats() {
return this.stats;
@@ -3149,4 +_,65 @@
@@ -3131,4 +_,65 @@
return (org.bukkit.craftbukkit.entity.CraftPlayer) super.getBukkitEntity();
}
// CraftBukkit end

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/server/level/WorldGenRegion.java
+++ b/net/minecraft/server/level/WorldGenRegion.java
@@ -292,6 +_,7 @@
return true;
} else {
@@ -297,6 +_,7 @@
int chunkX = SectionPos.blockToSectionCoord(pos.getX());
int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
// Paper start - Buffer OOB setBlock calls
+ if (!org.purpurmc.purpur.PurpurConfig.loggerSuppressSetBlockFarChunk) // Purpur - Logger settings (suppressing pointless logs)
if (!hasSetFarWarned) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -354,6 +_,20 @@
@@ -357,6 +_,20 @@
}
// Paper end - configuration phase API
@@ -21,7 +21,7 @@
@Override
public void tick() {
if (this.ackBlockChangesUpTo > -1) {
@@ -371,6 +_,12 @@
@@ -375,6 +_,12 @@
&& this.server.playerIdleTimeout() > 0
&& Util.getMillis() - this.player.getLastActionTime() > TimeUnit.MINUTES.toMillis(this.server.playerIdleTimeout())
&& !this.player.wonGame) {
@@ -34,7 +34,7 @@
this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
}
}
@@ -692,6 +_,8 @@
@@ -685,6 +_,8 @@
this.lastYaw = to.getYaw();
this.lastPitch = to.getPitch();
@@ -43,7 +43,7 @@
Location oldTo = to.clone();
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
this.cserver.getPluginManager().callEvent(event);
@@ -771,6 +_,7 @@
@@ -741,6 +_,7 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
if (packet.getId() == this.awaitingTeleport) {
if (this.awaitingPositionFromClient == null) {
@@ -51,7 +51,7 @@
this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
return;
}
@@ -1339,6 +_,10 @@
@@ -1312,6 +_,10 @@
final int maxBookPageSize = pageMax.intValue();
final double multiplier = Math.clamp(io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier, 0.3D, 1D);
long byteAllowed = maxBookPageSize;
@@ -62,7 +62,7 @@
for (final String page : pageList) {
final int byteLength = page.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
byteTotal += byteLength;
@@ -1363,7 +_,8 @@
@@ -1336,7 +_,8 @@
}
if (byteTotal > byteAllowed) {
@@ -72,7 +72,7 @@
this.disconnectAsync(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - add proper async disconnect
return;
}
@@ -1382,31 +_,45 @@
@@ -1355,31 +_,45 @@
Optional<String> title = packet.title();
title.ifPresent(contents::add);
contents.addAll(packet.pages());
@@ -122,7 +122,7 @@
writtenBook.set(
DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getPlainTextName(), 0, pages, true)
);
@@ -1419,6 +_,16 @@
@@ -1392,6 +_,16 @@
return this.player.isTextFilteringEnabled() ? Filterable.passThrough(text.filteredOrEmpty()) : Filterable.from(text);
}
@@ -139,7 +139,7 @@
@Override
public void handleEntityTagQuery(final ServerboundEntityTagQueryPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
@@ -1458,7 +_,15 @@
@@ -1431,7 +_,15 @@
@Override
public void handleMovePlayer(final ServerboundMovePlayerPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
@@ -156,7 +156,7 @@
this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause
} else {
ServerLevel level = this.player.level();
@@ -1643,7 +_,7 @@
@@ -1615,7 +_,7 @@
movedWrongly = true;
if (event.getLogWarning())
// Paper end
@@ -165,7 +165,7 @@
} // Paper
}
@@ -1708,6 +_,8 @@
@@ -1670,6 +_,8 @@
this.lastYaw = to.getYaw();
this.lastPitch = to.getPitch();
@@ -174,7 +174,7 @@
Location oldTo = to.clone();
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
this.cserver.getPluginManager().callEvent(event);
@@ -1763,6 +_,13 @@
@@ -1725,6 +_,13 @@
this.player.tryResetCurrentImpulseContext();
}
@@ -188,7 +188,7 @@
this.player.checkMovementStatistics(this.player.getX() - startX, this.player.getY() - startY, this.player.getZ() - startZ);
this.lastGoodX = this.player.getX();
this.lastGoodY = this.player.getY();
@@ -1783,6 +_,17 @@
@@ -1745,6 +_,17 @@
}
}
@@ -206,7 +206,7 @@
private boolean shouldCheckPlayerMovement(final boolean isFallFlying) {
if (this.isSingleplayerOwner()) {
return false;
@@ -2229,6 +_,7 @@
@@ -2158,6 +_,7 @@
boolean cancelled;
if (hitResult == null || hitResult.getType() != HitResult.Type.BLOCK) {
@@ -214,7 +214,7 @@
org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemStack, hand);
cancelled = event.useItemInHand() == Event.Result.DENY;
} else {
@@ -2863,6 +_,7 @@
@@ -2801,6 +_,7 @@
ItemStack mainHandItem = this.player.getMainHandItem();
if (this.player.isWithinAttackRange(mainHandItem, targetBounds, io.papermc.paper.configuration.GlobalConfiguration.get().misc.clientInteractionLeniencyDistance.or(3.0))) { // Paper - configurable lenience
if (!mainHandItem.has(DataComponents.PIERCING_WEAPON)) {
@@ -222,7 +222,7 @@
if (target instanceof ItemEntity
|| target instanceof ExperienceOrb
|| target == this.player
@@ -3644,7 +_,7 @@
@@ -3584,7 +_,7 @@
@Override
public void handleChangeGameMode(final ServerboundChangeGameModePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -284,7 +_,7 @@
@@ -286,7 +_,7 @@
ServerLoginPacketListenerImpl.LOGGER.warn("Failed to verify username but will let them in anyway!");
ServerLoginPacketListenerImpl.this.startClientVerification(ServerLoginPacketListenerImpl.this.createOfflineProfile(name)); // Spigot
} else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -312,6 +_,7 @@
@@ -313,6 +_,7 @@
scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam);
}
// Paper end - Configurable player collision
@@ -8,7 +8,7 @@
// CraftBukkit start - moved down
LOGGER.info(
"{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", // Paper - add world identifier
@@ -432,6 +_,7 @@
@@ -433,6 +_,7 @@
}
public net.kyori.adventure.text.@Nullable Component remove(final ServerPlayer player, final net.kyori.adventure.text.Component leaveMessage) {
// Paper end - Fix kick event leave message not being sent
@@ -16,7 +16,7 @@
ServerLevel level = player.level();
player.awardStat(Stats.LEAVE_GAME);
// CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
@@ -768,6 +_,20 @@
@@ -769,6 +_,20 @@
}
}
@@ -37,7 +37,7 @@
public void broadcastAll(final Packet<?> packet, final ResourceKey<Level> dimension) {
for (ServerPlayer player : this.players) {
if (player.level().dimension() == dimension) {
@@ -861,6 +_,7 @@
@@ -862,6 +_,7 @@
case ADMINS -> EntityEvent.PERMISSION_LEVEL_ADMINS;
case OWNERS -> EntityEvent.PERMISSION_LEVEL_OWNERS;
};
@@ -45,7 +45,7 @@
player.connection.send(new ClientboundEntityEventPacket(player, eventId));
}
@@ -872,7 +_,7 @@
@@ -873,7 +_,7 @@
// Paper start - whitelist verify event / login event
public LoginResult canBypassFullServerLogin(final NameAndId nameAndId, final LoginResult currentResult) {