Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
0fa2a949ae
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 8503c3c9 #621: Add HumanEntity#getItemInUse and Material#getSlipperiness 248deb09 #622: Add methods to check if item is the breed item for an entity 2ce691d8 Clarify Player#breakBlock only works for blocks in the same world 5dcdd48e SPIGOT-6514: Small Dripleaf block data is missing half property cc9610b7 #619: Add Player#breakBlock() 862bc475 Fix bad merge of SPIGOT-6502 fix 989bb0c1 Downgrade SnakeYAML due to issues with comments parsing 1dff62ae Fix inverted visual fire docs CraftBukkit Changes: 40caacc8 SPIGOT-6526: World entities are not populated when plugin onEnable is called c9a92ad0 SPIGOT-6536: Marker position not set on spawn 20d3e57c #855: Add HumanEntity#getItemInUse and Material#getSlipperiness d9c69b44 SPIGOT-6529: Fix BundleMeta#setItems 8bd43be5 SPIGOT-6535: PlayerGameModeChangeEvent event incorrectly reports old gamemode 4ece3ff3 #856: Add methods to check if item is the breed item for an entity dd4bec5f Add additional validation to Player#breakBlock bc835ae6 SPIGOT-6532: Fix Entity#setGlowing 384e116e Restore 1.16.5 behaviour of InventoryDragEvent being called even when a single item is 'dragged' to its own slot b42e708c Fix new map colors rendering as transparent cfe7fecf SPIGOT-6524: Inventory desync when InventoryClickEvent is cancelled eeae1b19 SPIGOT-6522: ItemStack on cursor is always AIR 7490724d Fix missing PlayerEditBookEvent 06875f76 SPIGOT-6513: Placing ItemStack in Inventory causes InventoryAction.NOTHING 27835bde SPIGOT-6519: Fix end gateway teleports 4ac634ad SPIGOT-6515: "Un-waterlogging" throws UnsupportedOperationException in some cases da425fa2 SPIGOT-6518: Anvils falling onto dripstone can sometimes crash server 50530da9 SPIGOT-6514: Small Dripleaf block data is missing half property 6fdecf20 #853: Implement Player#breakBlock() 4db9c49f SPIGOT-6510: Bukkit#createMap throws NullPointerException 89e2b127 SPIGOT-6517: Spider jockey crash on dripstone cbf2f678 SPIGOT-6508: Rename conflicted getServer 74575d48 SPIGOT-6506: Fix crash with custom inventories a3df386f Fix NPE with Entity.getNearbyEntities d747f8ed Fix NPE with World.getNearbyEntities 4d2c7800 Fix second usage of worldGenSettings just in case 5182f923 SPIGOT-6504: Fix generating fresh worlds Spigot Changes: 66f9d3c1 Rebuild patches 191e4971 Rebuild patches a09c0bb6 Restore Spigot experience merging
132 Zeilen
7.5 KiB
Diff
132 Zeilen
7.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 13 Apr 2016 02:10:49 -0400
|
|
Subject: [PATCH] Configurable Player Collision
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
index 439dcc6effdc91830d2b7ede9063982998b37120..504efea7b6f50a0d17f4f353781953dfb18bdeca 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -232,4 +232,9 @@ public class PaperConfig {
|
|
private static void regionFileCacheSize() {
|
|
regionFileCacheSize = Math.max(getInt("settings.region-file-cache-size", 256), 4);
|
|
}
|
|
+
|
|
+ public static boolean enablePlayerCollisions = true;
|
|
+ private static void enablePlayerCollisions() {
|
|
+ enablePlayerCollisions = getBoolean("settings.enable-player-collisions", true);
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
|
index 8885220e4813b34627b42523834bbec995d8950d..4c9660176e783999301565790b8cf6f47b0d02a2 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
|
@@ -193,7 +193,7 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi
|
|
buf.writeComponent(this.displayName);
|
|
buf.writeByte(this.options);
|
|
buf.writeUtf(this.nametagVisibility);
|
|
- buf.writeUtf(this.collisionRule);
|
|
+ buf.writeUtf(!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions ? "never" : this.collisionRule); // Paper
|
|
buf.writeEnum(this.color);
|
|
buf.writeComponent(this.playerPrefix);
|
|
buf.writeComponent(this.playerSuffix);
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 9e936078b388459bed7da3c6edfd0e65f3b1b1bf..15e26dbc38e23c5284246ef55d038eb011759ee2 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -163,6 +163,7 @@ import net.minecraft.world.level.storage.loot.LootTables;
|
|
import net.minecraft.world.level.storage.loot.PredicateManager;
|
|
import net.minecraft.world.phys.Vec2;
|
|
import net.minecraft.world.phys.Vec3;
|
|
+import net.minecraft.world.scores.PlayerTeam; // Paper
|
|
import org.apache.commons.lang3.Validate;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
@@ -603,6 +604,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
|
|
}
|
|
|
|
+ // Paper start - Handle collideRule team for player collision toggle
|
|
+ final ServerScoreboard scoreboard = this.getScoreboard();
|
|
+ final java.util.Collection<String> toRemove = scoreboard.getPlayerTeams().stream().filter(team -> team.getName().startsWith("collideRule_")).map(PlayerTeam::getName).collect(java.util.stream.Collectors.toList());
|
|
+ for (String teamName : toRemove) {
|
|
+ scoreboard.removePlayerTeam(scoreboard.getPlayersTeam(teamName)); // Clean up after ourselves
|
|
+ }
|
|
+
|
|
+ if (!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions) {
|
|
+ this.getPlayerList().collideRuleTeamName = org.apache.commons.lang3.StringUtils.left("collideRule_" + java.util.concurrent.ThreadLocalRandom.current().nextInt(), 16);
|
|
+ PlayerTeam collideTeam = scoreboard.addPlayerTeam(this.getPlayerList().collideRuleTeamName);
|
|
+ collideTeam.setSeeFriendlyInvisibles(false); // Because we want to mimic them not being on a team at all
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
|
this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
|
|
this.connection.acceptConnections();
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index ce72102870075fffd8be6f32230ceae269ea4f9c..b9c4428bc9653e81ed046bda94e248218c1fa9c9 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -85,6 +85,7 @@ import net.minecraft.world.level.storage.PlayerDataStorage;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import net.minecraft.world.scores.Objective;
|
|
import net.minecraft.world.scores.PlayerTeam;
|
|
+import net.minecraft.world.scores.Scoreboard; // Paper
|
|
import net.minecraft.world.scores.Team;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
@@ -146,6 +147,7 @@ public abstract class PlayerList {
|
|
// CraftBukkit start
|
|
private CraftServer cserver;
|
|
private final Map<String,ServerPlayer> playersByName = new java.util.HashMap<>();
|
|
+ public @Nullable String collideRuleTeamName; // Paper - Team name used for collideRule
|
|
|
|
public PlayerList(MinecraftServer server, RegistryAccess.RegistryHolder registryManager, PlayerDataStorage saveHandler, int maxPlayers) {
|
|
this.cserver = server.server = new CraftServer((DedicatedServer) server, this);
|
|
@@ -377,6 +379,13 @@ public abstract class PlayerList {
|
|
|
|
player.initInventoryMenu();
|
|
// CraftBukkit - Moved from above, added world
|
|
+ // Paper start - Add to collideRule team if needed
|
|
+ final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard();
|
|
+ final PlayerTeam collideRuleTeam = scoreboard.getPlayersTeam(this.collideRuleTeamName);
|
|
+ if (this.collideRuleTeamName != null && collideRuleTeam != null && player.getTeam() == null) {
|
|
+ scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam);
|
|
+ }
|
|
+ // Paper end
|
|
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
|
}
|
|
|
|
@@ -496,6 +505,16 @@ public abstract class PlayerList {
|
|
entityplayer.doTick(); // SPIGOT-924
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - Remove from collideRule team if needed
|
|
+ if (this.collideRuleTeamName != null) {
|
|
+ final Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard();
|
|
+ final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName);
|
|
+ if (entityplayer.getTeam() == team && team != null) {
|
|
+ scoreBoard.removePlayerFromTeam(entityplayer.getScoreboardName(), team);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
this.save(entityplayer);
|
|
if (entityplayer.isPassenger()) {
|
|
Entity entity = entityplayer.getRootVehicle();
|
|
@@ -1118,6 +1137,13 @@ public abstract class PlayerList {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - Remove collideRule team if it exists
|
|
+ if (this.collideRuleTeamName != null) {
|
|
+ final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard();
|
|
+ final PlayerTeam team = scoreboard.getPlayersTeam(this.collideRuleTeamName);
|
|
+ if (team != null) scoreboard.removePlayerTeam(team);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
// CraftBukkit start
|