geforkt von Mirrors/Paper
789bc79280
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: c9a46ebf #653: Add World#spawn with randomizeData parameter e49c2e3a Damageable should extend ItemMeta 01ff04f4 SPIGOT-5880, SPIGOT-5567: New ChunkGenerator API ca5b4b1a SPIGOT-6697: Deprecate generateTree with BlockChangeDelegate as it does not handle tiles CraftBukkit Changes: 7c8bbcbe SPIGOT-6716: Preserve the order of stored enchantments of enchanted books. 18027d02 #914: Add World#spawn with randomizeData parameter 3cad0316 SPIGOT-6714: Don't fire PlayerBucketEvent when empty 8c6d60cf Fix server crash with BlockPopulator when entities are at a negative chunk border 4f6bcc84 SPIGOT-5880, SPIGOT-5567: New ChunkGenerator API 78d5b35b SPIGOT-6697: Restore generateTree with BlockChangeDelegate behaviour 15792f0d Rebuild patch c949675e SPIGOT-6713: Cancelling EntityTransformEvent Causes Deceased Slimes To Not Despawn a955f15c Fix issues with new ChunkGenerator API a0a37f41 SPIGOT-6630: Replacing an enchantment on an item creates a conflict error Spigot Changes: b166a49b Rebuild patches 3c1fc60a SPIGOT-6693: Composters only take in one item at custom hopper speeds
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 78f3e00715a5d3a60c341461a7cd4fa52e2492f0..2413ed16de148ea63667dca7ab3ee89fb714cf84 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -241,4 +241,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 597b8d4c79714484e7c8be6e4f90294a96259e4e..5ef6d6cafbd39cf15189bc65cc4dea1f99ef37a0 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -161,6 +161,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;
|
|
@@ -614,6 +615,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.getPlayerTeam(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 b2638a7dbe2ead274e9e2e337babe41c90179f8b..a9ab9bba799a95351cdb829b84163a564b41e0a8 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -87,6 +87,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;
|
|
@@ -149,6 +150,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);
|
|
@@ -385,6 +387,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.getPlayerTeam(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());
|
|
}
|
|
|
|
@@ -504,6 +513,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();
|
|
@@ -1126,6 +1145,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
|