and yet again, more patches
This commit is contained in:
parent
4664528315
commit
2e347b629d
36 changed files with 106 additions and 123 deletions
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 7 Jul 2021 16:19:41 -0700
|
||||
Subject: [PATCH] Fixes kick event leave message not being sent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index d66c9c09ae3874dd53ef298f94a0e5c6177f2b35..43cd0b67f31d0340893672c9bf5a00467d9cdb54 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -456,7 +456,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), (future) -> {
|
||||
this.connection.disconnect(ichatbasecomponent);
|
||||
});
|
||||
- this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
|
||||
+ this.onDisconnect(ichatbasecomponent, event.leaveMessage()); // CraftBukkit - fire quit instantly // Paper - use kick event leave message
|
||||
this.connection.setReadOnly();
|
||||
MinecraftServer minecraftserver = this.server;
|
||||
Connection networkmanager = this.connection;
|
||||
@@ -1877,6 +1877,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
@Override
|
||||
public void onDisconnect(Component reason) {
|
||||
+ // Paper start
|
||||
+ this.onDisconnect(reason, null);
|
||||
+ }
|
||||
+ public void onDisconnect(Component reason, @Nullable net.kyori.adventure.text.Component quitMessage) {
|
||||
+ // Paper end
|
||||
// CraftBukkit start - Rarely it would send a disconnect line twice
|
||||
if (this.processedDisconnect) {
|
||||
return;
|
||||
@@ -1893,7 +1898,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
this.player.disconnect();
|
||||
// Paper start - Adventure
|
||||
- net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().remove(this.player);
|
||||
+ quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used
|
||||
if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
|
||||
this.server.getPlayerList().broadcastMessage(PaperAdventure.asVanilla(quitMessage), ChatType.SYSTEM, Util.NIL_UUID);
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index de8a14e86b337954fd0f730c1096758e1db409aa..963d40bf7cf7c12a22472f3a5b7080daf1c90e7b 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -585,6 +585,11 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // Paper - return Component
|
||||
+ // Paper start
|
||||
+ return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())));
|
||||
+ }
|
||||
+ public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
|
||||
+ // Paper end
|
||||
ServerLevel worldserver = entityplayer.getLevel();
|
||||
|
||||
entityplayer.awardStat(Stats.LEAVE_GAME);
|
||||
@@ -595,7 +600,7 @@ public abstract class PlayerList {
|
||||
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
|
||||
}
|
||||
|
||||
- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())), entityplayer.quitReason); // Paper - quit reason
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), leaveMessage, entityplayer.quitReason); // Paper - quit reason
|
||||
if (entityplayer.didPlayerJoinEvent) this.cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit
|
||||
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 2 Dec 2020 21:03:02 -0800
|
||||
Subject: [PATCH] Add config for mobs immune to default effects
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 3af1cfc75af23edd3cbfbf202427856761b42ce7..c58b18cd75eca14ce61d59c6beffa34337917ddd 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -667,6 +667,21 @@ public class PaperWorldConfig {
|
||||
log("Hopper Ignore Occluding Blocks: " + (hoppersIgnoreOccludingBlocks ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
+ public boolean undeadImmuneToCertainEffects = true;
|
||||
+ public boolean spidersImmuneToPoisonEffect = true;
|
||||
+ public boolean witherImmuneToWitherEffect = true;
|
||||
+ public boolean witherSkeletonImmuneToWitherEffect = true;
|
||||
+ private void mobEffectChanges() {
|
||||
+ undeadImmuneToCertainEffects = getBoolean("mob-effects.undead-immune-to-certain-effects", undeadImmuneToCertainEffects);
|
||||
+ log("Undead immune to harmful effects: " + undeadImmuneToCertainEffects);
|
||||
+ spidersImmuneToPoisonEffect = getBoolean("mob-effects.spiders-immune-to-poison-effect", spidersImmuneToPoisonEffect);
|
||||
+ log("Spiders immune to poison effect: " + spidersImmuneToPoisonEffect);
|
||||
+ witherImmuneToWitherEffect = getBoolean("mob-effects.immune-to-wither-effect.wither", witherImmuneToWitherEffect);
|
||||
+ log("Wither immune to wither effect: " + witherImmuneToWitherEffect);
|
||||
+ witherSkeletonImmuneToWitherEffect = getBoolean("mob-effects.immune-to-wither-effect.wither-skeleton", witherSkeletonImmuneToWitherEffect);
|
||||
+ log("Wither skeleton immune to wither effect: " + witherSkeletonImmuneToWitherEffect);
|
||||
+ }
|
||||
+
|
||||
public boolean nerfNetherPortalPigmen = false;
|
||||
private void nerfNetherPortalPigmen() {
|
||||
nerfNetherPortalPigmen = getBoolean("game-mechanics.nerf-pigmen-from-nether-portals", nerfNetherPortalPigmen);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4c0c2bc9fae878304eab1c18b5ef0cae1b780cfd..bec2507294e266dc16f810d0deb7b790dd0a6df0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1128,7 +1128,7 @@ public abstract class LivingEntity extends Entity {
|
||||
if (this.getMobType() == MobType.UNDEAD) {
|
||||
MobEffect mobeffectlist = effect.getEffect();
|
||||
|
||||
- if (mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) {
|
||||
+ if ((mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) && this.level.paperConfig.undeadImmuneToCertainEffects) { // Paper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index 3657b7021d8b505653fadbdfbd515c112cd11177..ede0ced64d74d71547d1b8bb6853c5aacc1b486a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -613,7 +613,7 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig.witherImmuneToWitherEffect ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
|
||||
private class WitherDoNothingGoal extends Goal {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
index a3cb44914ef7d8636e743baa361a1a09ceeb2207..05b6c07c0705c7d8741c77baa87982e8e278dc97 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
@@ -133,7 +133,7 @@ public class Spider extends Monster {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.POISON && this.level.paperConfig.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
index c727bbf7de71213fba410625c4a7ad90315b608a..6acc46c3a6fe7648d2cc4d0aaef063633c74c20d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
@@ -122,6 +122,6 @@ public class WitherSkeleton extends AbstractSkeleton {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig.witherSkeletonImmuneToWitherEffect ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: sulu5890 <sulu@sulu.me>
|
||||
Date: Sun, 11 Jul 2021 19:34:03 -0500
|
||||
Subject: [PATCH] Fix incorrect message for outdated client
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index e0cd786f130e34b3401d40663e1548fc0076f74a..451ca1a1d84227274fd59fc5d46654a441561710 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -81,7 +81,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
if (packet.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
Component chatmessage; // Paper - Fix hex colors not working in some kick messages
|
||||
|
||||
- if (packet.getProtocolVersion() < 754) {
|
||||
+ if (packet.getProtocolVersion() < SharedConstants.getCurrentVersion().getProtocolVersion()) { // Paper - Fix incorrect message for outdated clients
|
||||
chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
||||
} else {
|
||||
chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: thamid-gamer <60953955+thamid-gamer@users.noreply.github.com>
|
||||
Date: Fri, 16 Jul 2021 16:00:17 -0400
|
||||
Subject: [PATCH] Fix MerchantOffer BuyB-Only AssertionError
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
||||
index e0f1857dc100bc4d68e5e308b984e5eeaef976b5..12354b2fd411c57fd14dfca92cd2f1522fa6f050 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
||||
@@ -231,6 +231,7 @@ public class MerchantOffer {
|
||||
if (!this.satisfiedBy(firstBuyStack, secondBuyStack)) {
|
||||
return false;
|
||||
} else {
|
||||
+ if (!this.getCostA().isEmpty()) // Paper
|
||||
firstBuyStack.shrink(this.getCostA().getCount());
|
||||
if (!this.getCostB().isEmpty()) {
|
||||
secondBuyStack.shrink(this.getCostB().getCount());
|
|
@ -0,0 +1,39 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <max@themoep.de>
|
||||
Date: Sun, 20 Jun 2021 16:35:42 +0100
|
||||
Subject: [PATCH] Don't apply cramming damage to players
|
||||
|
||||
It does not make a lot of sense to damage players if they get crammed,
|
||||
especially as the usecase of teleporting lots of players to the same
|
||||
location isn't too uncommon and killing all those players isn't
|
||||
really what one would expect to happen.
|
||||
|
||||
For those who really want it a config option is provided.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index c58b18cd75eca14ce61d59c6beffa34337917ddd..f21bd06d7f0531e8ae0412377757a147e9db4e85 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -823,4 +823,9 @@ public class PaperWorldConfig {
|
||||
private void showSignClickCommandFailureMessagesToPlayer() {
|
||||
showSignClickCommandFailureMessagesToPlayer = getBoolean("show-sign-click-command-failure-msgs-to-player", showSignClickCommandFailureMessagesToPlayer);
|
||||
}
|
||||
+
|
||||
+ public boolean allowPlayerCrammingDamage = false;
|
||||
+ private void playerCrammingDamage() {
|
||||
+ allowPlayerCrammingDamage = getBoolean("allow-player-cramming-damage", allowPlayerCrammingDamage);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index d3984faa2566e61eeb6c77b327f3ea951c8c8179..fbd1baca8455e1971f36370c2e90661202d8371f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1417,7 +1417,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource damageSource) {
|
||||
- return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || this.getAbilities().invulnerable && damageSource == DamageSource.WITHER;
|
||||
+ return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || this.getAbilities().invulnerable && damageSource == DamageSource.WITHER || !level.paperConfig.allowPlayerCrammingDamage && damageSource == DamageSource.CRAMMING; // Paper - disable player cramming
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,215 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <max@themoep.de>
|
||||
Date: Mon, 28 Jun 2021 22:38:29 +0100
|
||||
Subject: [PATCH] Rate options and timings for sensors and behaviors
|
||||
|
||||
This adds config options to specify the tick rate for sensors
|
||||
and behaviors of different entity types as well as timings
|
||||
for those in order to be able to have some metrics as to which
|
||||
ones might need tweaking.
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
index b47b7dce26805badd422c1867733ff4bfd00e9f4..b27021a42cbed3f0648a8d0903d00d03922ae221 100644
|
||||
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
@@ -113,6 +113,14 @@ public final class MinecraftTimings {
|
||||
return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType + " - " + type, tickEntityTimer);
|
||||
}
|
||||
|
||||
+ public static Timing getBehaviorTimings(String type) {
|
||||
+ return Timings.ofSafe("## Behavior - " + type);
|
||||
+ }
|
||||
+
|
||||
+ public static Timing getSensorTimings(String type, int rate) {
|
||||
+ return Timings.ofSafe("## Sensor - " + type + " (Default rate: " + rate + ")");
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Get a named timer for the specified tile entity type to track type specific timings.
|
||||
* @param entity
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index f21bd06d7f0531e8ae0412377757a147e9db4e85..1f8f7735fbbb86583bd3ac1313e7e6adcfcb16d3 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -7,13 +7,18 @@ import it.unimi.dsi.fastutil.objects.Reference2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import java.util.HashMap;
|
||||
+import java.util.Locale;
|
||||
import java.util.Map;
|
||||
+
|
||||
+import com.google.common.collect.HashBasedTable;
|
||||
+import com.google.common.collect.Table;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.monster.Vindicator;
|
||||
import net.minecraft.world.entity.monster.Zombie;
|
||||
import net.minecraft.world.level.NaturalSpawner;
|
||||
import org.bukkit.Bukkit;
|
||||
+import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.spigotmc.SpigotWorldConfig;
|
||||
|
||||
@@ -828,4 +833,57 @@ public class PaperWorldConfig {
|
||||
private void playerCrammingDamage() {
|
||||
allowPlayerCrammingDamage = getBoolean("allow-player-cramming-damage", allowPlayerCrammingDamage);
|
||||
}
|
||||
+
|
||||
+ private Table<String, String, Integer> sensorTickRates;
|
||||
+ private Table<String, String, Integer> behaviorTickRates;
|
||||
+ private void tickRates() {
|
||||
+ config.addDefault("world-settings.default.tick-rates.sensor.villager.secondarypoisensor", 40);
|
||||
+ config.addDefault("world-settings.default.tick-rates.behavior.villager.validatenearbypoi", -1); // Example
|
||||
+ log("Tick rates:");
|
||||
+ sensorTickRates = loadTickRates("sensor");
|
||||
+ behaviorTickRates = loadTickRates("behavior");
|
||||
+ }
|
||||
+
|
||||
+ private Table<String, String, Integer> loadTickRates(String type) {
|
||||
+ log(" " + type + ":");
|
||||
+ Table<String, String, Integer> table = HashBasedTable.create();
|
||||
+
|
||||
+ ConfigurationSection typeSection = config.getConfigurationSection("world-settings." + worldName + ".tick-rates." + type);
|
||||
+ if (typeSection == null) {
|
||||
+ typeSection = config.getConfigurationSection("world-settings.default.tick-rates." + type);
|
||||
+ }
|
||||
+ if (typeSection != null) {
|
||||
+ for (String entity : typeSection.getKeys(false)) {
|
||||
+ ConfigurationSection entitySection = typeSection.getConfigurationSection(entity);
|
||||
+ if (entitySection != null) {
|
||||
+ log(" " + entity + ":");
|
||||
+ for (String typeName : entitySection.getKeys(false)) {
|
||||
+ if (entitySection.isInt(typeName)) {
|
||||
+ int tickRate = entitySection.getInt(typeName);
|
||||
+ table.put(entity.toLowerCase(Locale.ROOT), typeName.toLowerCase(Locale.ROOT), tickRate);
|
||||
+ log(" " + typeName + ": " + tickRate);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (table.isEmpty()) {
|
||||
+ log(" None configured");
|
||||
+ }
|
||||
+ return table;
|
||||
+ }
|
||||
+
|
||||
+ public int getBehaviorTickRate(String typeName, String entityType, int def) {
|
||||
+ return getIntOrDefault(behaviorTickRates, typeName, entityType, def);
|
||||
+ }
|
||||
+
|
||||
+ public int getSensorTickRate(String typeName, String entityType, int def) {
|
||||
+ return getIntOrDefault(sensorTickRates, typeName, entityType, def);
|
||||
+ }
|
||||
+
|
||||
+ private int getIntOrDefault(Table<String, String, Integer> table, String rowKey, String columnKey, int def) {
|
||||
+ Integer rate = table.get(columnKey, rowKey);
|
||||
+ return rate != null && rate > -1 ? rate : def;
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
index b1212e162ba938b3abe0df747a633ba9cbbe57c8..c24ff2ef1054523e58892c2b35080cffb6ab744a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
@@ -14,6 +14,10 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
private long endTimestamp;
|
||||
private final int minDuration;
|
||||
private final int maxDuration;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ private final String configKey;
|
||||
+ private final co.aikar.timings.Timing timing;
|
||||
+ // Paper end
|
||||
|
||||
public Behavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState) {
|
||||
this(requiredMemoryState, 60);
|
||||
@@ -27,6 +31,15 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
this.minDuration = minRunTime;
|
||||
this.maxDuration = maxRunTime;
|
||||
this.entryCondition = requiredMemoryState;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName());
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public Behavior.Status getStatus() {
|
||||
@@ -34,11 +47,19 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
}
|
||||
|
||||
public final boolean tryStart(ServerLevel world, E entity, long time) {
|
||||
+ // Paper start - behavior tick rate
|
||||
+ int tickRate = world.paperConfig.getBehaviorTickRate(this.configKey, entity.getType().id, -1);
|
||||
+ if (tickRate > -1 && time < this.endTimestamp + tickRate) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.hasRequiredMemories(entity) && this.checkExtraStartConditions(world, entity)) {
|
||||
this.status = Behavior.Status.RUNNING;
|
||||
int i = this.minDuration + world.getRandom().nextInt(this.maxDuration + 1 - this.minDuration);
|
||||
this.endTimestamp = time + (long)i;
|
||||
+ this.timing.startTiming(); // Paper - behavior timings
|
||||
this.start(world, entity, time);
|
||||
+ this.timing.stopTiming(); // Paper - behavior timings
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -49,11 +70,13 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
}
|
||||
|
||||
public final void tickOrStop(ServerLevel world, E entity, long time) {
|
||||
+ this.timing.startTiming(); // Paper - behavior timings
|
||||
if (!this.timedOut(time) && this.canStillUse(world, entity, time)) {
|
||||
this.tick(world, entity, time);
|
||||
} else {
|
||||
this.doStop(world, entity, time);
|
||||
}
|
||||
+ this.timing.stopTiming(); // Paper - behavior timings
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
index c940a910a435b20297eca493c7b27fd69be54e86..f3b8e253a5bfc3f68121dbe656ae7e2ac0f0eb1c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
@@ -19,8 +19,21 @@ public abstract class Sensor<E extends LivingEntity> {
|
||||
private static final TargetingConditions ATTACK_TARGET_CONDITIONS_IGNORE_INVISIBILITY_AND_LINE_OF_SIGHT = TargetingConditions.forCombat().range(16.0D).ignoreLineOfSight().ignoreInvisibilityTesting();
|
||||
private final int scanRate;
|
||||
private long timeToTick;
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ private final String configKey;
|
||||
+ private final co.aikar.timings.Timing timing;
|
||||
+ // Paper end
|
||||
|
||||
public Sensor(int senseInterval) {
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName());
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey, senseInterval);
|
||||
+ // Paper end
|
||||
this.scanRate = senseInterval;
|
||||
this.timeToTick = (long)RANDOM.nextInt(senseInterval);
|
||||
}
|
||||
@@ -31,8 +44,12 @@ public abstract class Sensor<E extends LivingEntity> {
|
||||
|
||||
public final void tick(ServerLevel world, E entity) {
|
||||
if (--this.timeToTick <= 0L) {
|
||||
- this.timeToTick = (long)this.scanRate;
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ this.timeToTick = world.paperConfig.getSensorTickRate(this.configKey, entity.getType().id, this.scanRate);
|
||||
+ this.timing.startTiming();
|
||||
+ // Paper end
|
||||
this.doTick(world, entity);
|
||||
+ this.timing.stopTiming(); // Paper - sensor timings
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 20 Jul 2021 21:25:35 -0700
|
||||
Subject: [PATCH] Add a bunch of missing forceDrop toggles
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 68da2530db8b0fcdba957ee90c185324a010919f..4a027c802ffa80f69cf2bc68f737a842fbfb0596 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1489,7 +1489,9 @@ public abstract class Mob extends LivingEntity {
|
||||
}
|
||||
|
||||
if (this.tickCount > 100) {
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.spawnAtLocation((ItemLike) Items.LEAD);
|
||||
+ this.forceDrops = false; // Paper
|
||||
this.leashInfoTag = null;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
index e47f3092b6bd6b86b577de705db1a575d0952348..490212cfe4e5cea7219eaf4304e14bfac0e6472d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
@@ -100,7 +100,9 @@ public class WorkAtComposter extends WorkAtPoi {
|
||||
ItemStack itemstack = inventorysubcontainer.addItem(new ItemStack(Items.BREAD, j));
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ entity.forceDrops = true; // Paper
|
||||
entity.spawnAtLocation(itemstack, 0.5F);
|
||||
+ entity.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
index 29372c8a0c54e4bae518e09846f0e9caba263896..f9be50049325a1139d67ccf590caeeceadb2fd23 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
@@ -522,7 +522,9 @@ public class Panda extends Animal {
|
||||
}
|
||||
|
||||
if (!this.level.isClientSide() && this.random.nextInt(700) == 0 && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.spawnAtLocation((ItemLike) Items.SLIME_BALL);
|
||||
+ this.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
index f7c23377e41870c558a49a08552d109b7b9cbc33..8a2c2b4bd603aae37055abd058feb7ee759078ce 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -305,7 +305,9 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
@Override
|
||||
protected void finishConversion(ServerLevel world) {
|
||||
PiglinAi.cancelAdmiring(this);
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.inventory.removeAllItems().forEach(this::spawnAtLocation);
|
||||
+ this.forceDrops = false; // Paper
|
||||
super.finishConversion(world);
|
||||
}
|
||||
|
39
patches/server/0690-Stinger-API.patch
Normal file
39
patches/server/0690-Stinger-API.patch
Normal file
|
@ -0,0 +1,39 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Tue, 22 Jun 2021 23:15:44 -0400
|
||||
Subject: [PATCH] Stinger API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index ca176b9331345e343c19a02b6ba2ea886d20962d..c022751e3b45469cc0ad6732e2d6ff08918bafa4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -321,7 +321,28 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0");
|
||||
this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count);
|
||||
}
|
||||
+ // Paper Start - Bee Stinger API
|
||||
+ @Override
|
||||
+ public int getBeeStingerCooldown() {
|
||||
+ return getHandle().removeStingerTime;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBeeStingerCooldown(int ticks) {
|
||||
+ getHandle().removeStingerTime = ticks;
|
||||
+ }
|
||||
|
||||
+ @Override
|
||||
+ public int getBeeStingersInBody() {
|
||||
+ return getHandle().getStingerCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBeeStingersInBody(int count) {
|
||||
+ Preconditions.checkArgument(count >= 0, "New bee stinger amount must be >= 0");
|
||||
+ getHandle().setStingerCount(count);
|
||||
+ }
|
||||
+ // Paper End - Bee Stinger API
|
||||
@Override
|
||||
public void damage(double amount) {
|
||||
this.damage(amount, null);
|
|
@ -0,0 +1,31 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 1 Aug 2021 09:49:06 +0100
|
||||
Subject: [PATCH] Fix incosistency issue with empty map items in CB
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
index 602e6bc05c053baf821c11c30b24538320b9ac61..7baf8039c5cf2bd68ba79d4a095ed4b58a847081 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
@@ -71,7 +71,7 @@ public class MapItem extends ComplexItem {
|
||||
public static Integer getMapId(ItemStack stack) {
|
||||
CompoundTag nbttagcompound = stack.getTag();
|
||||
|
||||
- return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
|
||||
+ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null; // CraftBukkit - make new maps for no tag // Paper - don't return invalid ID
|
||||
}
|
||||
|
||||
public static int createNewSavedData(Level world, int x, int z, int scale, boolean showIcons, boolean unlimitedTracking, ResourceKey<Level> dimension) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
index 96ab7d53f4e089c7666872f9fd0f09283259a726..8e634ccb91b58000412c572903e57d30ddb2caba 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
@@ -144,6 +144,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
|
||||
|
||||
@Override
|
||||
public int getMapId() {
|
||||
+ Preconditions.checkState(this.hasMapView(), "Item does not have map associated - check hasMapView() first!"); // Paper - more friendly message
|
||||
return this.mapId;
|
||||
}
|
||||
|
126
patches/server/0692-Add-System.out-err-catcher.patch
Normal file
126
patches/server/0692-Add-System.out-err-catcher.patch
Normal file
|
@ -0,0 +1,126 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: underscore11code <minecrafter11mrt@gmail.com>
|
||||
Date: Fri, 23 Jul 2021 23:01:42 -0700
|
||||
Subject: [PATCH] Add System.out/err catcher
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/SysoutCatcher.java b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..76d0d00cd6742991e3f3ec827a75ee87d856b6c9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
|
||||
@@ -0,0 +1,94 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.plugin.java.JavaPlugin;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.OutputStream;
|
||||
+import java.io.PrintStream;
|
||||
+import java.util.Objects;
|
||||
+import java.util.concurrent.ConcurrentHashMap;
|
||||
+import java.util.concurrent.ConcurrentMap;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public final class SysoutCatcher {
|
||||
+ private static final boolean SUPPRESS_NAGS = Boolean.getBoolean("io.papermc.paper.suppress.sout.nags");
|
||||
+ // Nanoseconds between nag at most; if interval is caught first, this is reset.
|
||||
+ // <= 0 for disabling.
|
||||
+ private static final long NAG_TIMEOUT = TimeUnit.MILLISECONDS.toNanos(
|
||||
+ Long.getLong("io.papermc.paper.sout.nags.timeout", TimeUnit.MINUTES.toMillis(5L)));
|
||||
+ // Count since last nag; if timeout is first, this is reset.
|
||||
+ // <= 0 for disabling.
|
||||
+ private static final long NAG_INTERVAL = Long.getLong("io.papermc.paper.sout.nags.interval", 200L);
|
||||
+
|
||||
+ // We don't particularly care about how correct this is at any given moment; let's do it on a best attempt basis.
|
||||
+ // The records are also pretty small, so let's just go for a size of 64 to start...
|
||||
+ //
|
||||
+ // Content: Plugin name => nag object
|
||||
+ // Why plugin name?: This doesn't store a reference to the plugin; keeps the reload ability.
|
||||
+ // Why not clean on reload?: Effort.
|
||||
+ private final ConcurrentMap<String, PluginNag> nagRecords = new ConcurrentHashMap<>(64);
|
||||
+
|
||||
+ public SysoutCatcher() {
|
||||
+ System.setOut(new WrappedOutStream(System.out, Level.INFO, "[STDOUT] "));
|
||||
+ System.setErr(new WrappedOutStream(System.err, Level.SEVERE, "[STDERR] "));
|
||||
+ }
|
||||
+
|
||||
+ private final class WrappedOutStream extends PrintStream {
|
||||
+ private static final StackWalker STACK_WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
|
||||
+ private final Level level;
|
||||
+ private final String prefix;
|
||||
+
|
||||
+ public WrappedOutStream(@NotNull final OutputStream out, final Level level, final String prefix) {
|
||||
+ super(out);
|
||||
+ this.level = level;
|
||||
+ this.prefix = prefix;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void println(@Nullable final String line) {
|
||||
+ final Class<?> clazz = STACK_WALKER.getCallerClass();
|
||||
+ try {
|
||||
+ final JavaPlugin plugin = JavaPlugin.getProvidingPlugin(clazz);
|
||||
+
|
||||
+ // Instead of just printing the message, send it to the plugin's logger
|
||||
+ plugin.getLogger().log(this.level, this.prefix + line);
|
||||
+
|
||||
+ if (SysoutCatcher.SUPPRESS_NAGS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (SysoutCatcher.NAG_INTERVAL > 0 || SysoutCatcher.NAG_TIMEOUT > 0) {
|
||||
+ final PluginNag nagRecord = SysoutCatcher.this.nagRecords.computeIfAbsent(plugin.getName(), k -> new PluginNag());
|
||||
+ final boolean hasTimePassed = SysoutCatcher.NAG_TIMEOUT > 0
|
||||
+ && (nagRecord.lastNagTimestamp == Long.MIN_VALUE
|
||||
+ || nagRecord.lastNagTimestamp + SysoutCatcher.NAG_TIMEOUT <= System.nanoTime());
|
||||
+ final boolean hasMessagesPassed = SysoutCatcher.NAG_INTERVAL > 0
|
||||
+ && (nagRecord.messagesSinceNag == Long.MIN_VALUE
|
||||
+ || ++nagRecord.messagesSinceNag >= SysoutCatcher.NAG_INTERVAL);
|
||||
+ if (!hasMessagesPassed && !hasTimePassed) {
|
||||
+ return;
|
||||
+ }
|
||||
+ nagRecord.lastNagTimestamp = System.nanoTime();
|
||||
+ nagRecord.messagesSinceNag = 0;
|
||||
+ }
|
||||
+ Bukkit.getLogger().warning(
|
||||
+ String.format("Nag author(s): '%s' of '%s' about their usage of System.out/err.print. "
|
||||
+ + "Please use your plugin's logger instead (JavaPlugin#getLogger).",
|
||||
+ plugin.getDescription().getAuthors(),
|
||||
+ plugin.getName())
|
||||
+ );
|
||||
+ } catch (final IllegalArgumentException | IllegalStateException e) {
|
||||
+ // If anything happens, the calling class doesn't exist, there is no JavaPlugin that "owns" the calling class, etc
|
||||
+ // Just print out normally, with some added information
|
||||
+ Bukkit.getLogger().log(this.level, String.format("%s[%s] %s", this.prefix, clazz.getName(), line));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static class PluginNag {
|
||||
+ private long lastNagTimestamp = Long.MIN_VALUE;
|
||||
+ private long messagesSinceNag = Long.MIN_VALUE;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 9f69e1874caa087778e1de637c93719b43ac5a23..6b53310b37a502a677459bf2b777a2c450fb6482 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -18,6 +18,7 @@ import com.mojang.serialization.Lifecycle;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
+import io.papermc.paper.logging.SysoutCatcher;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
@@ -294,6 +295,7 @@ public final class CraftServer implements Server {
|
||||
public int reloadCount;
|
||||
private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
|
||||
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||
+ private final SysoutCatcher sysoutCatcher = new SysoutCatcher(); // Paper
|
||||
|
||||
static {
|
||||
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
|
24
patches/server/0693-Fix-test-not-bootstrapping.patch
Normal file
24
patches/server/0693-Fix-test-not-bootstrapping.patch
Normal file
|
@ -0,0 +1,24 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Mon, 2 Aug 2021 08:52:21 +0200
|
||||
Subject: [PATCH] Fix test not bootstrapping
|
||||
|
||||
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
|
||||
diff --git a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
index 19777eaca02640f220626940f5384563777dd74a..9873addca9e7a2a7eaa30a1c1cd332260ca07b35 100644
|
||||
--- a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
+++ b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
@@ -5,10 +5,11 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
-public class EnchantmentTargetTest {
|
||||
+public class EnchantmentTargetTest extends AbstractTestingBase { // Paper
|
||||
|
||||
@Test
|
||||
public void test() {
|
|
@ -0,0 +1,246 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SirYwell <hannesgreule@outlook.de>
|
||||
Date: Sat, 10 Jul 2021 11:12:30 +0200
|
||||
Subject: [PATCH] Rewrite LogEvents to contain the source jars in stack traces
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java b/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6ffd1befe64c6c3036c22e05ed1c44808d64bd28
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java
|
||||
@@ -0,0 +1,130 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.Marker;
|
||||
+import org.apache.logging.log4j.ThreadContext;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
|
||||
+import org.apache.logging.log4j.core.time.Instant;
|
||||
+import org.apache.logging.log4j.message.Message;
|
||||
+import org.apache.logging.log4j.util.ReadOnlyStringMap;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+
|
||||
+public class DelegateLogEvent implements LogEvent {
|
||||
+ private final LogEvent original;
|
||||
+
|
||||
+ protected DelegateLogEvent(LogEvent original) {
|
||||
+ this.original = original;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public LogEvent toImmutable() {
|
||||
+ return this.original.toImmutable();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Map<String, String> getContextMap() {
|
||||
+ return this.original.getContextMap();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ReadOnlyStringMap getContextData() {
|
||||
+ return this.original.getContextData();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThreadContext.ContextStack getContextStack() {
|
||||
+ return this.original.getContextStack();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getLoggerFqcn() {
|
||||
+ return this.original.getLoggerFqcn();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Level getLevel() {
|
||||
+ return this.original.getLevel();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getLoggerName() {
|
||||
+ return this.original.getLoggerName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Marker getMarker() {
|
||||
+ return this.original.getMarker();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Message getMessage() {
|
||||
+ return this.original.getMessage();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getTimeMillis() {
|
||||
+ return this.original.getTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Instant getInstant() {
|
||||
+ return this.original.getInstant();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public StackTraceElement getSource() {
|
||||
+ return this.original.getSource();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getThreadName() {
|
||||
+ return this.original.getThreadName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getThreadId() {
|
||||
+ return this.original.getThreadId();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getThreadPriority() {
|
||||
+ return this.original.getThreadPriority();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Throwable getThrown() {
|
||||
+ return this.original.getThrown();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThrowableProxy getThrownProxy() {
|
||||
+ return this.original.getThrownProxy();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEndOfBatch() {
|
||||
+ return this.original.isEndOfBatch();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isIncludeLocation() {
|
||||
+ return this.original.isIncludeLocation();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEndOfBatch(boolean endOfBatch) {
|
||||
+ this.original.setEndOfBatch(endOfBatch);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setIncludeLocation(boolean locationRequired) {
|
||||
+ this.original.setIncludeLocation(locationRequired);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getNanoTime() {
|
||||
+ return this.original.getNanoTime();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java b/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..558427c65b4051923f73d15d85ee519be005060a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java
|
||||
@@ -0,0 +1,48 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.impl.ExtendedClassInfo;
|
||||
+import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
|
||||
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
|
||||
+
|
||||
+public class ExtraClassInfoLogEvent extends DelegateLogEvent {
|
||||
+
|
||||
+ private boolean fixed;
|
||||
+
|
||||
+ public ExtraClassInfoLogEvent(LogEvent original) {
|
||||
+ super(original);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThrowableProxy getThrownProxy() {
|
||||
+ if (fixed) {
|
||||
+ return super.getThrownProxy();
|
||||
+ }
|
||||
+ rewriteStackTrace(super.getThrownProxy());
|
||||
+ fixed = true;
|
||||
+ return super.getThrownProxy();
|
||||
+ }
|
||||
+
|
||||
+ private void rewriteStackTrace(ThrowableProxy throwable) {
|
||||
+ ExtendedStackTraceElement[] stackTrace = throwable.getExtendedStackTrace();
|
||||
+ for (int i = 0; i < stackTrace.length; i++) {
|
||||
+ ExtendedClassInfo classInfo = stackTrace[i].getExtraClassInfo();
|
||||
+ if (classInfo.getLocation().equals("?")) {
|
||||
+ StackTraceElement element = stackTrace[i].getStackTraceElement();
|
||||
+ String classLoaderName = element.getClassLoaderName();
|
||||
+ if (classLoaderName != null) {
|
||||
+ stackTrace[i] = new ExtendedStackTraceElement(element,
|
||||
+ new ExtendedClassInfo(classInfo.getExact(), classLoaderName, "?"));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (throwable.getCauseProxy() != null) {
|
||||
+ rewriteStackTrace(throwable.getCauseProxy());
|
||||
+ }
|
||||
+ if (throwable.getSuppressedProxies() != null) {
|
||||
+ for (ThrowableProxy proxy : throwable.getSuppressedProxies()) {
|
||||
+ rewriteStackTrace(proxy);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java b/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..34734bb969a1a74c7a4f9c17d40ebf007ad5d701
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java
|
||||
@@ -0,0 +1,29 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.core.Core;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy;
|
||||
+import org.apache.logging.log4j.core.config.plugins.Plugin;
|
||||
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+@Plugin(
|
||||
+ name = "ExtraClassInfoRewritePolicy",
|
||||
+ category = Core.CATEGORY_NAME,
|
||||
+ elementType = "rewritePolicy",
|
||||
+ printObject = true
|
||||
+)
|
||||
+public final class ExtraClassInfoRewritePolicy implements RewritePolicy {
|
||||
+ @Override
|
||||
+ public LogEvent rewrite(LogEvent source) {
|
||||
+ if (source.getThrown() != null) {
|
||||
+ return new ExtraClassInfoLogEvent(source);
|
||||
+ }
|
||||
+ return source;
|
||||
+ }
|
||||
+
|
||||
+ @PluginFactory
|
||||
+ public static @NotNull ExtraClassInfoRewritePolicy createPolicy() {
|
||||
+ return new ExtraClassInfoRewritePolicy();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
||||
index 2e421eaac80cf251b32e0bb504dd54a73edf4986..74ccc67e3c12dc5182602fb691ef3ddeb5b53280 100644
|
||||
--- a/src/main/resources/log4j2.xml
|
||||
+++ b/src/main/resources/log4j2.xml
|
||||
@@ -34,6 +34,10 @@
|
||||
</Async>
|
||||
<Rewrite name="rewrite">
|
||||
<StacktraceDeobfuscatingRewritePolicy />
|
||||
+ <AppenderRef ref="rewrite2"/>
|
||||
+ </Rewrite>
|
||||
+ <Rewrite name="rewrite2">
|
||||
+ <ExtraClassInfoRewritePolicy />
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="TerminalConsole" level="info"/>
|
||||
<AppenderRef ref="ServerGuiConsole" level="info"/>
|
70
patches/server/0695-Improve-boat-collision-performance.patch
Normal file
70
patches/server/0695-Improve-boat-collision-performance.patch
Normal file
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
||||
Subject: [PATCH] Improve boat collision performance
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||
index b9775bc4e601fe1be8e514222e56ae782a897395..6288ffdaad147a10f25cce00c13820903b4cc7d7 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -78,6 +78,7 @@ public class Util {
|
||||
}).findFirst().orElseThrow(() -> {
|
||||
return new IllegalStateException("No jar file system provider found");
|
||||
});
|
||||
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper
|
||||
private static Consumer<String> thePauser = (string) -> {
|
||||
};
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index bec2507294e266dc16f810d0deb7b790dd0a6df0..3f9e3415db6cfee317da695793d295660ef29b18 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1316,7 +1316,7 @@ public abstract class LivingEntity extends Entity {
|
||||
if (!source.isProjectile()) {
|
||||
Entity entity = source.getDirectEntity();
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper
|
||||
this.blockUsingShield((LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
@@ -1425,11 +1425,12 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
if (entity1 != null) {
|
||||
- double d0 = entity1.getX() - this.getX();
|
||||
+ final boolean far = entity1.distanceToSqr(this) > (200.0 * 200.0); // Paper
|
||||
+ double d0 = far ? (Math.random() - Math.random()) : entity1.getX() - this.getX(); // Paper
|
||||
|
||||
double d1;
|
||||
|
||||
- for (d1 = entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
|
||||
+ for (d1 = far ? Math.random() - Math.random() : entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { // Paper
|
||||
d0 = (Math.random() - Math.random()) * 0.01D;
|
||||
}
|
||||
|
||||
@@ -2085,7 +2086,7 @@ public abstract class LivingEntity extends Entity {
|
||||
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
Entity entity = damagesource.getDirectEntity();
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper
|
||||
this.blockUsingShield((LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index c3d111204601270b57389e1f85456a9e2ada4629..b967177cb10041f96831322c311579e409050e88 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -687,8 +687,8 @@ public class Boat extends Entity {
|
||||
this.invFriction = 0.05F;
|
||||
if (this.oldStatus == Boat.Status.IN_AIR && this.status != Boat.Status.IN_AIR && this.status != Boat.Status.ON_LAND) {
|
||||
this.waterLevel = this.getY(1.0D);
|
||||
- this.setPos(this.getX(), (double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D, this.getZ());
|
||||
- this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
||||
+ this.move(MoverType.SELF, new Vec3(0.0, ((double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D) - this.getY(), 0.0)); // Paper
|
||||
+ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); // Paper
|
||||
this.lastYd = 0.0D;
|
||||
this.status = Boat.Status.IN_WATER;
|
||||
} else {
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Noah van der Aa <ndvdaa@gmail.com>
|
||||
Date: Sat, 24 Jul 2021 16:54:11 +0200
|
||||
Subject: [PATCH] Prevent AFK kick while watching end credits.
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 43cd0b67f31d0340893672c9bf5a00467d9cdb54..7b6cf326dfab9bd0b13dfc330d143d2efeea9aa1 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -388,7 +388,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
--this.dropSpamTickCount;
|
||||
}
|
||||
|
||||
- if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) {
|
||||
+ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60) && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits.
|
||||
this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
this.disconnect(new TranslatableComponent("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Professor Bloodstone <git@bloodstone.dev>
|
||||
Date: Fri, 23 Jul 2021 02:32:04 +0200
|
||||
Subject: [PATCH] Allow skipping writing of comments to server.properties
|
||||
|
||||
Makes less git noise, as it won't update the date every single time
|
||||
|
||||
Use -DPaper.skipServerPropertiesComments=true flag to disable writing it
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||
index 71767307062e99262afb994016720e1f1555b820..b285e8f6172154af1aa942ab164d73bc885c5fa4 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.minecraft.server.dedicated;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
+
|
||||
+import java.io.BufferedOutputStream; // Paper
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -18,11 +20,13 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import joptsimple.OptionSet; // CraftBukkit
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
+import org.jetbrains.annotations.NotNull; // Paper
|
||||
|
||||
public abstract class Settings<T extends Settings<T>> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public final Properties properties;
|
||||
+ private static final boolean skipComments = Boolean.getBoolean("Paper.skipServerPropertiesComments"); // Paper - allow skipping server.properties comments
|
||||
// CraftBukkit start
|
||||
private OptionSet options = null;
|
||||
|
||||
@@ -79,9 +83,47 @@ public abstract class Settings<T extends Settings<T>> {
|
||||
}
|
||||
// CraftBukkit end
|
||||
OutputStream outputstream = Files.newOutputStream(path);
|
||||
+ // Paper start - disable writing comments to properties file
|
||||
+ BufferedOutputStream bufferedOutputStream = !skipComments ? new BufferedOutputStream(outputstream) : new BufferedOutputStream(outputstream) {
|
||||
+ private boolean isRightAfterNewline = true; // If last written char was newline
|
||||
+ private boolean isComment = false; // Are we writing comment currently?
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull byte[] b) throws IOException {
|
||||
+ this.write(b, 0, b.length);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@NotNull byte[] bbuf, int off, int len) throws IOException {
|
||||
+ int latest_offset = off; // The latest offset, updated when comment ends
|
||||
+ for (int index = off; index < off + len; ++index ) {
|
||||
+ byte c = bbuf[index];
|
||||
+ boolean isNewline = (c == '\n' || c == '\r');
|
||||
+ if (isNewline && isComment) {
|
||||
+ // Comment has ended
|
||||
+ isComment = false;
|
||||
+ latest_offset = index+1;
|
||||
+ }
|
||||
+ if (c == '#' && isRightAfterNewline) {
|
||||
+ isComment = true;
|
||||
+ if (index != latest_offset) {
|
||||
+ // We got some non-comment data earlier
|
||||
+ super.write(bbuf, latest_offset, index-latest_offset);
|
||||
+ }
|
||||
+ }
|
||||
+ isRightAfterNewline = isNewline; // Store for next iteration
|
||||
+
|
||||
+ }
|
||||
+ if (latest_offset < off+len && !isComment) {
|
||||
+ // We have some unwritten data, that isn't part of a comment
|
||||
+ super.write(bbuf, latest_offset, (off + len) - latest_offset);
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+ // Paper end
|
||||
|
||||
try {
|
||||
- this.properties.store(outputstream, "Minecraft server properties");
|
||||
+ this.properties.store(bufferedOutputStream, "Minecraft server properties"); // Paper - use bufferedOutputStream
|
||||
} catch (Throwable throwable) {
|
||||
if (outputstream != null) {
|
||||
try {
|
110
patches/server/0698-Add-PlayerSetSpawnEvent.patch
Normal file
110
patches/server/0698-Add-PlayerSetSpawnEvent.patch
Normal file
|
@ -0,0 +1,110 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 19 May 2021 18:59:10 -0700
|
||||
Subject: [PATCH] Add PlayerSetSpawnEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
index e95f2222814e104bf9194a96385737dffe2cb2b5..249ab7357aa19d87179fa4c3ae89d9d37f32fbfb 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
@@ -33,7 +33,7 @@ public class SetSpawnCommand {
|
||||
ResourceKey<Level> resourceKey = source.getLevel().dimension();
|
||||
|
||||
for(ServerPlayer serverPlayer : targets) {
|
||||
- serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false);
|
||||
+ serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND); // Paper - PlayerSetSpawnEvent
|
||||
}
|
||||
|
||||
String string = resourceKey.location().toString();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index fbd1baca8455e1971f36370c2e90661202d8371f..a6ec320bdca4a1c6e23461cd10a6f7bed681f243 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1258,7 +1258,7 @@ public class ServerPlayer extends Player {
|
||||
} else if (this.bedBlocked(blockposition, enumdirection)) {
|
||||
return Either.left(Player.BedSleepingProblem.OBSTRUCTED);
|
||||
} else {
|
||||
- this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true);
|
||||
+ this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - PlayerSetSpawnEvent
|
||||
if (this.level.isDay()) {
|
||||
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -2086,12 +2086,33 @@ public class ServerPlayer extends Player {
|
||||
return this.respawnForced;
|
||||
}
|
||||
|
||||
+ @Deprecated // Paper
|
||||
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
|
||||
+ // Paper start
|
||||
+ this.setRespawnPosition(dimension, pos, angle, forced, sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+ public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) {
|
||||
+ Location spawnLoc = null;
|
||||
+ boolean willNotify = false;
|
||||
if (pos != null) {
|
||||
boolean flag2 = pos.equals(this.respawnPosition) && dimension.equals(this.respawnDimension);
|
||||
+ spawnLoc = net.minecraft.server.MCUtil.toLocation(this.getServer().getLevel(dimension), pos);
|
||||
+ spawnLoc.setYaw(angle);
|
||||
+ willNotify = sendMessage && !flag2;
|
||||
+ }
|
||||
+ com.destroystokyo.paper.event.player.PlayerSetSpawnEvent event = new com.destroystokyo.paper.event.player.PlayerSetSpawnEvent(this.getBukkitEntity(), cause, spawnLoc, forced, willNotify, willNotify ? net.kyori.adventure.text.Component.translatable("block.minecraft.set_spawn") : null);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (event.getLocation() != null) {
|
||||
+ dimension = event.getLocation().getWorld() != null ? ((CraftWorld) event.getLocation().getWorld()).getHandle().dimension() : dimension;
|
||||
+ pos = net.minecraft.server.MCUtil.toBlockPosition(event.getLocation());
|
||||
+ angle = (float) event.getLocation().getYaw();
|
||||
+ forced = event.isForced();
|
||||
+ // Paper end
|
||||
|
||||
- if (sendMessage && !flag2) {
|
||||
- this.sendMessage(new TranslatableComponent("block.minecraft.set_spawn"), Util.NIL_UUID);
|
||||
+ if (event.willNotifyPlayer() && event.getNotification() != null) { // Paper
|
||||
+ this.sendMessage(PaperAdventure.asVanilla(event.getNotification()), Util.NIL_UUID); // Paper
|
||||
}
|
||||
|
||||
this.respawnPosition = pos;
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 963d40bf7cf7c12a22472f3a5b7080daf1c90e7b..dca3b995c02507e5df299abe60f518480ce56d21 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -889,7 +889,7 @@ public abstract class PlayerList {
|
||||
f1 = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
|
||||
- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false);
|
||||
+ entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // Paper - PlayerSetSpawnEvent
|
||||
flag2 = !flag && flag3;
|
||||
isBedSpawn = true;
|
||||
location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
index d620f559cdd1bd0e161a99123ef6c6f64e3302df..07e893f1859abe3c2a765694c21309d60346ca82 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
@@ -73,7 +73,7 @@ public class RespawnAnchorBlock extends Block {
|
||||
if (!world.isClientSide) {
|
||||
ServerPlayer serverPlayer = (ServerPlayer)player;
|
||||
if (serverPlayer.getRespawnDimension() != world.dimension() || !pos.equals(serverPlayer.getRespawnPosition())) {
|
||||
- serverPlayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true);
|
||||
+ serverPlayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR); // Paper - PlayerSetSpawnEvent
|
||||
world.playSound((Player)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index b5df4beaefe68b13e402b6f71d67ca5ddd47c6f4..9b136a877ff07262b1694c6cad43da756602384e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1077,9 +1077,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@Override
|
||||
public void setBedSpawnLocation(Location location, boolean override) {
|
||||
if (location == null) {
|
||||
- this.getHandle().setRespawnPosition(null, null, 0.0F, override, false);
|
||||
+ this.getHandle().setRespawnPosition(null, null, 0.0F, override, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLUGIN); // Paper - PlayerSetSpawnEvent
|
||||
} else {
|
||||
- this.getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false);
|
||||
+ this.getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false); // Paper - PlayerSetSpawnEvent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 7 Jul 2021 16:30:17 -0700
|
||||
Subject: [PATCH] Make hoppers respect inventory max stack size
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index b63fcebac4d51f0d01914c76712f896e6d117f90..71a644a3de1565f7c60b35553df017882f3be860 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -588,17 +588,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
+ ItemStack leftover = ItemStack.EMPTY; // Paper
|
||||
if (!stack.isEmpty() && stack.getCount() > to.getMaxStackSize()) {
|
||||
+ leftover = stack; // Paper
|
||||
stack = stack.split(to.getMaxStackSize());
|
||||
}
|
||||
// Spigot end
|
||||
IGNORE_TILE_UPDATES = true; // Paper
|
||||
to.setItem(slot, stack);
|
||||
IGNORE_TILE_UPDATES = false; // Paper
|
||||
- stack = ItemStack.EMPTY;
|
||||
+ stack = leftover; // Paper
|
||||
flag = true;
|
||||
} else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) {
|
||||
- int j = stack.getMaxStackSize() - itemstack1.getCount();
|
||||
+ int j = Math.min(stack.getMaxStackSize(), to.getMaxStackSize()) - itemstack1.getCount(); // Paper
|
||||
int k = Math.min(stack.getCount(), j);
|
||||
|
||||
stack.shrink(k);
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Sun, 8 Aug 2021 00:52:54 -0400
|
||||
Subject: [PATCH] Optimize entity tracker passenger checks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index f6b6ac1ab31c364646151866c54c9e46dee12516..75d0c2532c26eab044256cf6373ba7909dfe6395 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -73,7 +73,7 @@ public class ServerEntity {
|
||||
this.trackedPlayers = trackedPlayers;
|
||||
// CraftBukkit end
|
||||
this.ap = Vec3.ZERO;
|
||||
- this.lastPassengers = Collections.emptyList();
|
||||
+ this.lastPassengers = com.google.common.collect.ImmutableList.of(); // Paper - optimize passenger checks
|
||||
this.level = worldserver;
|
||||
this.broadcast = consumer;
|
||||
this.entity = entity;
|
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 2 Dec 2020 03:07:58 -0800
|
||||
Subject: [PATCH] Config option for Piglins guarding chests
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 1f8f7735fbbb86583bd3ac1313e7e6adcfcb16d3..569b108b22cfa21d9368b7f7e1bf785ae7dd15fa 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -78,6 +78,11 @@ public class PaperWorldConfig {
|
||||
zombiesTargetTurtleEggs = getBoolean("zombies-target-turtle-eggs", zombiesTargetTurtleEggs);
|
||||
}
|
||||
|
||||
+ public boolean piglinsGuardChests = true;
|
||||
+ private void piglinsGuardChests() {
|
||||
+ piglinsGuardChests = getBoolean("piglins-guard-chests", piglinsGuardChests);
|
||||
+ }
|
||||
+
|
||||
public boolean useEigencraftRedstone = false;
|
||||
private void useEigencraftRedstone() {
|
||||
useEigencraftRedstone = this.getBoolean("use-faster-eigencraft-redstone", false);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
index 08d17a26bf8a7f3757f4f5b2df4592edbdde9f2e..f362e007aece208036a37d9bda8bb481a78eeaff 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
@@ -464,6 +464,7 @@ public class PiglinAi {
|
||||
}
|
||||
|
||||
public static void angerNearbyPiglins(Player player, boolean blockOpen) {
|
||||
+ if (!player.level.paperConfig.piglinsGuardChests) return; // Paper
|
||||
List<Piglin> list = player.level.getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0D));
|
||||
|
||||
list.stream().filter(PiglinAi::isIdle).filter((entitypiglin) -> {
|
65
patches/server/0702-Added-EntityDamageItemEvent.patch
Normal file
65
patches/server/0702-Added-EntityDamageItemEvent.patch
Normal file
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 22 Dec 2020 13:52:48 -0800
|
||||
Subject: [PATCH] Added EntityDamageItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index c5286b3751c58df1b70d9ac01b0497b83c0f917a..8f2f516b1f473ce18a07e9f130b49b795dd6b46e 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -527,7 +527,7 @@ public final class ItemStack {
|
||||
return this.getItem().getMaxDamage();
|
||||
}
|
||||
|
||||
- public boolean hurt(int amount, Random random, @Nullable ServerPlayer player) {
|
||||
+ public boolean hurt(int amount, Random random, @Nullable LivingEntity player) { // Paper - allow any living entity instead of only ServerPlayers
|
||||
if (!this.isDamageableItem()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -545,8 +545,8 @@ public final class ItemStack {
|
||||
|
||||
amount -= k;
|
||||
// CraftBukkit start
|
||||
- if (player != null) {
|
||||
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount);
|
||||
+ if (player instanceof ServerPlayer serverPlayer) { // Paper
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper
|
||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (amount != event.getDamage() || event.isCancelled()) {
|
||||
@@ -557,6 +557,14 @@ public final class ItemStack {
|
||||
}
|
||||
|
||||
amount = event.getDamage();
|
||||
+ // Paper start - EntityDamageItemEvent
|
||||
+ } else if (player != null) {
|
||||
+ io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ amount = event.getDamage();
|
||||
+ // Paper end
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (amount <= 0) {
|
||||
@@ -564,8 +572,8 @@ public final class ItemStack {
|
||||
}
|
||||
}
|
||||
|
||||
- if (player != null && amount != 0) {
|
||||
- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(player, this, this.getDamageValue() + amount);
|
||||
+ if (player instanceof ServerPlayer serverPlayer && amount != 0) { // Paper
|
||||
+ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, this.getDamageValue() + amount); // Paper
|
||||
}
|
||||
|
||||
j = this.getDamageValue() + amount;
|
||||
@@ -577,7 +585,7 @@ public final class ItemStack {
|
||||
public <T extends LivingEntity> void hurtAndBreak(int amount, T entity, Consumer<T> breakCallback) {
|
||||
if (!entity.level.isClientSide && (!(entity instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) entity).getAbilities().instabuild)) {
|
||||
if (this.isDamageableItem()) {
|
||||
- if (this.hurt(amount, entity.getRandom(), entity instanceof ServerPlayer ? (ServerPlayer) entity : null)) {
|
||||
+ if (this.hurt(amount, entity.getRandom(), entity /*instanceof ServerPlayer ? (ServerPlayer) entity : null*/)) { // Paper - pass LivingEntity for EntityItemDamageEvent
|
||||
breakCallback.accept(entity);
|
||||
Item item = this.getItem();
|
||||
// CraftBukkit start - Check for item breaking
|
|
@ -0,0 +1,52 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 9 Aug 2021 00:38:37 -0400
|
||||
Subject: [PATCH] Optimize indirect passenger iteration
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 9abbde2f0e8076c9986bc805abd2e71ba4a0af04..aeae0eb6260fa88c55eb8add7e5df3198fe3d465 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3458,26 +3458,41 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
|
||||
private Stream<Entity> getIndirectPassengersStream() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(); } // Paper
|
||||
return this.passengers.stream().flatMap(Entity::getSelfAndPassengers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entity> getSelfAndPassengers() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(this); } // Paper
|
||||
return Stream.concat(Stream.of(this), this.getIndirectPassengersStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entity> getPassengersAndSelf() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(this); } // Paper
|
||||
return Stream.concat(this.passengers.stream().flatMap(Entity::getPassengersAndSelf), Stream.of(this));
|
||||
}
|
||||
|
||||
public Iterable<Entity> getIndirectPassengers() {
|
||||
+ // Paper start - rewrite this method
|
||||
+ if (this.passengers.isEmpty()) { return ImmutableList.of(); }
|
||||
+ ImmutableList.Builder<Entity> indirectPassengers = ImmutableList.builder();
|
||||
+ for (Entity passenger : this.passengers) {
|
||||
+ indirectPassengers.add(passenger);
|
||||
+ indirectPassengers.addAll(passenger.getIndirectPassengers());
|
||||
+ }
|
||||
+ return indirectPassengers.build();
|
||||
+ }
|
||||
+ private Iterable<Entity> getIndirectPassengers_old() {
|
||||
+ // Paper end
|
||||
return () -> {
|
||||
return this.getIndirectPassengersStream().iterator();
|
||||
};
|
||||
}
|
||||
|
||||
public boolean hasExactlyOnePlayerPassenger() {
|
||||
+ if (this.passengers.isEmpty()) { return false; } // Paper
|
||||
return this.getIndirectPassengersStream().filter((entity) -> {
|
||||
return entity instanceof Player;
|
||||
}).count() == 1L;
|
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Thu, 12 Aug 2021 21:15:38 -0700
|
||||
Subject: [PATCH] Fix block drops position losing precision millions of blocks
|
||||
out
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index a37213bce34f45898f56a22196b0d5ef1470e812..76b3d78f4c866a11bd7798af6b330340d898d7d9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -342,9 +342,11 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
|
||||
public static void popResource(Level world, BlockPos pos, ItemStack stack) {
|
||||
float f = EntityType.ITEM.getHeight() / 2.0F;
|
||||
- double d0 = (double) ((float) pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
- double d1 = (double) ((float) pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - (double) f;
|
||||
- double d2 = (double) ((float) pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
+ // Paper start - don't convert potentially massive numbers to floats
|
||||
+ double d0 = pos.getX() + 0.5D + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
+ double d1 = pos.getY() + 0.5D + Mth.nextDouble(world.random, -0.25D, 0.25D) - (double) f;
|
||||
+ double d2 = pos.getZ() + 0.5D + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
+ // Paper end
|
||||
|
||||
Block.popResource(world, () -> {
|
||||
return new ItemEntity(world, d0, d1, d2, stack);
|
||||
@@ -357,9 +359,11 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
int k = direction.getStepZ();
|
||||
float f = EntityType.ITEM.getWidth() / 2.0F;
|
||||
float f1 = EntityType.ITEM.getHeight() / 2.0F;
|
||||
- double d0 = (double) ((float) pos.getX() + 0.5F) + (i == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) i * (0.5F + f)));
|
||||
- double d1 = (double) ((float) pos.getY() + 0.5F) + (j == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) j * (0.5F + f1))) - (double) f1;
|
||||
- double d2 = (double) ((float) pos.getZ() + 0.5F) + (k == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) k * (0.5F + f)));
|
||||
+ // Paper start - don't convert potentially massive numbers to floats
|
||||
+ double d0 = pos.getX() + 0.5D + (i == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) i * (0.5F + f)));
|
||||
+ double d1 = pos.getY() + 0.5D + (j == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) j * (0.5F + f1))) - (double) f1;
|
||||
+ double d2 = pos.getZ() + 0.5D + (k == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) k * (0.5F + f)));
|
||||
+ // Paper end
|
||||
double d3 = i == 0 ? Mth.nextDouble(world.random, -0.1D, 0.1D) : (double) i * 0.1D;
|
||||
double d4 = j == 0 ? Mth.nextDouble(world.random, 0.0D, 0.1D) : (double) j * 0.1D + 0.1D;
|
||||
double d5 = k == 0 ? Mth.nextDouble(world.random, -0.1D, 0.1D) : (double) k * 0.1D;
|
|
@ -0,0 +1,35 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
|
||||
Date: Fri, 13 Aug 2021 01:14:38 +0200
|
||||
Subject: [PATCH] Configurable item frame map cursor update interval
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 569b108b22cfa21d9368b7f7e1bf785ae7dd15fa..7eacd9265a8d4cee6e3c3608ab08603a3b6e5a15 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -819,6 +819,11 @@ public class PaperWorldConfig {
|
||||
mapItemFrameCursorLimit = getInt("map-item-frame-cursor-limit", mapItemFrameCursorLimit);
|
||||
}
|
||||
|
||||
+ public int mapItemFrameCursorUpdateInterval = 10;
|
||||
+ private void itemFrameCursorUpdateInterval() {
|
||||
+ mapItemFrameCursorUpdateInterval = getInt("map-item-frame-cursor-update-interval", mapItemFrameCursorUpdateInterval);
|
||||
+ }
|
||||
+
|
||||
public boolean fixItemsMergingThroughWalls;
|
||||
private void fixItemsMergingThroughWalls() {
|
||||
fixItemsMergingThroughWalls = getBoolean("fix-items-merging-through-walls", fixItemsMergingThroughWalls);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 75d0c2532c26eab044256cf6373ba7909dfe6395..94704a258ce7183aeb0ccec0b9106e40efd08821 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -98,7 +98,7 @@ public class ServerEntity {
|
||||
ItemFrame entityitemframe = (ItemFrame) this.entity;
|
||||
ItemStack itemstack = entityitemframe.getItem();
|
||||
|
||||
- if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
|
||||
+ if (this.level.paperConfig.mapItemFrameCursorUpdateInterval > 0 && this.tickCount % this.level.paperConfig.mapItemFrameCursorUpdateInterval == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks // Paper - Make item frame map cursor update interval configurable
|
||||
Integer integer = MapItem.getMapId(itemstack);
|
||||
MapItemSavedData worldmap = MapItem.getSavedData(integer, this.level);
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 21:25:31 -0800
|
||||
Subject: [PATCH] Make EntityUnleashEvent cancellable
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 4a027c802ffa80f69cf2bc68f737a842fbfb0596..697c2663c4deeb8f2ad603c979ab0884ac027930 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1463,7 +1463,7 @@ public abstract class Mob extends LivingEntity {
|
||||
if (flag1 && this.isLeashed()) {
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, true);
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return flag1; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
index 5f256c1ac5d49e19cfccf174dd55506313c493e0..744a99151ceecc85349861a99f6cb65e04c41b73 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
@@ -51,7 +51,7 @@ public abstract class PathfinderMob extends Mob {
|
||||
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public abstract class PathfinderMob extends Mob {
|
||||
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) return;
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
20
patches/server/0707-Clear-bucket-NBT-after-dispense.patch
Normal file
20
patches/server/0707-Clear-bucket-NBT-after-dispense.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 13 Aug 2021 15:00:06 -0700
|
||||
Subject: [PATCH] Clear bucket NBT after dispense
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
index 89921ffeae7cc715aa18cbf8687e7c8e612e5612..59db245fe11384282af84ec1d5be08ab0e9484ca 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
@@ -634,8 +634,7 @@ public interface DispenseItemBehavior {
|
||||
Item item = Items.BUCKET;
|
||||
stack.shrink(1);
|
||||
if (stack.isEmpty()) {
|
||||
- stack.setItem(Items.BUCKET);
|
||||
- stack.setCount(1);
|
||||
+ stack = new ItemStack(item); // Paper - clear tag
|
||||
} else if (((DispenserBlockEntity) pointer.getEntity()).addItem(new ItemStack(item)) < 0) {
|
||||
this.defaultDispenseItemBehavior.dispense(pointer, new ItemStack(item));
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 18 Aug 2021 12:02:02 -0500
|
||||
Subject: [PATCH] Set AsyncAppender dispatch thread to be a daemon thread
|
||||
|
||||
This diff will be included in the not yet released Log4j 2.14.2. When Log4j 2.14.2 is released this patch should be dropped in favor of bumping Log4j.
|
||||
|
||||
diff --git a/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppenderEventDispatcher.java b/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppenderEventDispatcher.java
|
||||
index a01f68db840b6e953fa6908ad10cd25744be6471..d406c3d38059b1e4012ca5ebd938b8a6f8ce152f 100644
|
||||
--- a/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppenderEventDispatcher.java
|
||||
+++ b/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppenderEventDispatcher.java
|
||||
@@ -50,6 +50,7 @@ class AsyncAppenderEventDispatcher extends Log4jThread {
|
||||
final List<AppenderControl> appenders,
|
||||
final BlockingQueue<LogEvent> queue) {
|
||||
super("AsyncAppenderEventDispatcher-" + THREAD_COUNTER.incrementAndGet() + "-" + name);
|
||||
+ this.setDaemon(true); // Paper - Backport change from not yet released Log4j 2.14.2
|
||||
this.errorAppender = errorAppender;
|
||||
this.appenders = appenders;
|
||||
this.queue = queue;
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Noah van der Aa <ndvdaa@gmail.com>
|
||||
Date: Wed, 18 Aug 2021 23:01:55 +0200
|
||||
Subject: [PATCH] Respect despawn rate in item merge check
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 7897b3324bc8d5a33cd3cd144b9fae9ffdc9241e..0ac107d7a360a5812a43488c611498d12546eed9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -261,7 +261,7 @@ public class ItemEntity extends Entity {
|
||||
private boolean isMergable() {
|
||||
ItemStack itemstack = this.getItem();
|
||||
|
||||
- return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < 6000 && itemstack.getCount() < itemstack.getMaxStackSize();
|
||||
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.getDespawnRate() && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - respect despawn rate in pickup check.
|
||||
}
|
||||
|
||||
private void tryToMerge(ItemEntity other) {
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Madeline Miller <mnmiller1@me.com>
|
||||
Date: Sun, 22 Aug 2021 22:17:18 +1000
|
||||
Subject: [PATCH] Move BlockPistonRetractEvent to fix duplication
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
index da9ae487799e58b196ebf219a62020d0c28adc70..c7d23fcaa5702f0e8bbf616c86b16ab1b3400dbb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
@@ -146,14 +146,14 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
- //if (!this.sticky) { // Paper - Prevents empty sticky pistons from firing retract - history behind is odd
|
||||
- org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
||||
- BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
|
||||
- world.getCraftServer().getPluginManager().callEvent(event);
|
||||
-
|
||||
- if (event.isCancelled()) {
|
||||
- return;
|
||||
- }
|
||||
+ //if (!this.sticky) { // Paper - Prevents empty sticky pistons from firing retract - history behind is odd - Move further down
|
||||
+ // org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
||||
+ // BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
|
||||
+ // world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ // if (event.isCancelled()) {
|
||||
+ // return;
|
||||
+ // }
|
||||
//} // Paper
|
||||
// PAIL: checkME - what happened to setTypeAndData?
|
||||
// CraftBukkit end
|
||||
@@ -236,6 +236,15 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
|
||||
BlockState iblockdata1 = (BlockState) ((BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(MovingPistonBlock.FACING, enumdirection)).setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT);
|
||||
|
||||
+ // Paper - Move empty piston retract call to fix duplication
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
||||
+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ } // Paper
|
||||
+
|
||||
world.setBlock(pos, iblockdata1, 20);
|
||||
world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, iblockdata1, (BlockState) this.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.from3DDataValue(data & 7)), enumdirection, false, true)); // Paper - diff on change
|
||||
world.blockUpdated(pos, iblockdata1.getBlock());
|
|
@ -0,0 +1,54 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sat, 21 Aug 2021 12:13:53 -0700
|
||||
Subject: [PATCH] Change EnderEye target without changing other things
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
index ab0493b975206b15095175149086cf1a6663995d..909de00db8c94ade82231e76ccd6c884cefed70b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
@@ -75,6 +75,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
}
|
||||
|
||||
public void signalTo(BlockPos pos) {
|
||||
+ // Paper start
|
||||
+ this.signalTo(pos, true);
|
||||
+ }
|
||||
+ public void signalTo(BlockPos pos, boolean update) {
|
||||
+ // Paper end
|
||||
double d0 = (double) pos.getX();
|
||||
int i = pos.getY();
|
||||
double d1 = (double) pos.getZ();
|
||||
@@ -92,8 +97,10 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
this.tz = d1;
|
||||
}
|
||||
|
||||
+ if (update) { // Paper
|
||||
this.life = 0;
|
||||
this.surviveAfterDeath = this.random.nextInt(5) > 0;
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
index 705dcae8f881cbdf5ff468f945b9269f9eae0e58..13c1188639e00cd96e00b179c4e353582bf66e64 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
@@ -38,8 +38,15 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
|
||||
|
||||
@Override
|
||||
public void setTargetLocation(Location location) {
|
||||
+ // Paper start
|
||||
+ this.setTargetLocation(location, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setTargetLocation(Location location, boolean update) {
|
||||
+ // Paper end
|
||||
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
|
||||
- this.getHandle().signalTo(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
+ this.getHandle().signalTo(new BlockPos(location.getX(), location.getY(), location.getZ()), update); // Paper
|
||||
}
|
||||
|
||||
@Override
|
Loading…
Add table
Add a link
Reference in a new issue