Patches maybe done?

This commit is contained in:
Cryptite
2023-04-25 08:36:54 -05:00
parent 3241691aea
commit 87ec6b249e
8 changed files with 437 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:16:51 -0500
Subject: [PATCH] Add Force Crit to PlayerPreAttackEntityEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java
index d49999ea597ef247bbf2298e6bf5600bfe003c3e..4ed53b14f94154043e3043f4fef540b45b2b272d 100644
--- a/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java
+++ b/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java
@@ -26,6 +26,7 @@ public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellab
private final Entity attacked;
private boolean cancelled;
private final boolean willAttack;
+ private boolean forceCrit; // Slice
public PrePlayerAttackEntityEvent(@NotNull Player who, @NotNull Entity attacked, boolean willAttack) {
super(who);
@@ -55,6 +56,16 @@ public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellab
return this.willAttack;
}
+ // Slice start
+ public boolean isForceCrit() {
+ return forceCrit;
+ }
+
+ public void setForceCrit(boolean forceCrit) {
+ this.forceCrit = forceCrit;
+ }
+ // Slice end
+
@NotNull
@Override
public HandlerList getHandlers() {

View File

@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:17:39 -0500
Subject: [PATCH] Add Preventing KB Bonus to PlayerPreAttackEntityEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java
index 4ed53b14f94154043e3043f4fef540b45b2b272d..608df52360df66390fce3070e52e4ecd4cd5fb64 100644
--- a/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java
+++ b/src/main/java/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.java
@@ -27,6 +27,7 @@ public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellab
private boolean cancelled;
private final boolean willAttack;
private boolean forceCrit; // Slice
+ private boolean preventKnockbackBonus; // Slice
public PrePlayerAttackEntityEvent(@NotNull Player who, @NotNull Entity attacked, boolean willAttack) {
super(who);
@@ -64,6 +65,15 @@ public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellab
public void setForceCrit(boolean forceCrit) {
this.forceCrit = forceCrit;
}
+
+ public boolean isPreventKnockbackBonus() {
+ return preventKnockbackBonus;
+ }
+
+ public void setPreventKnockbackBonus(boolean preventKnockbackBonus) {
+ this.preventKnockbackBonus = preventKnockbackBonus;
+ }
+
// Slice end
@NotNull

View File

@@ -0,0 +1,66 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:25:26 -0500
Subject: [PATCH] PlayerLoadStatsEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..80b67d390152b114ad385f7eb6af5ef975b7ca20
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java
@@ -0,0 +1,54 @@
+package com.destroystokyo.paper.event.player;
+
+import com.google.gson.JsonObject;
+import org.bukkit.Bukkit;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.UUID;
+
+/**
+ * Calls an event in which player stats can be provided. If null, will load from disk, otherwise will use provided data
+ */
+public class PlayerLoadStatsEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ private final UUID playerId;
+ private JsonObject statistics;
+
+ public PlayerLoadStatsEvent(@NotNull UUID playerId) {
+ super(!Bukkit.isPrimaryThread());
+ this.playerId = playerId;
+ }
+
+ /**
+ * Gets the player's unique ID.
+ *
+ * @return The unique ID
+ */
+ @NotNull
+ public UUID getUniqueId() {
+ return playerId;
+ }
+
+ @Nullable
+ public JsonObject getStatistics() {
+ return statistics;
+ }
+
+ public void setStatistics(@NotNull JsonObject statistics) {
+ this.statistics = statistics;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -0,0 +1,146 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:15:23 -0500
Subject: [PATCH] PlayerLoadStatsEvent
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index a5828dd3cc747eb720b7c53f0d59f01a6d1fdd7c..e0bd18ac70a93d41762fb23e7442d06355384d59 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1456,7 +1456,7 @@ public abstract class PlayerList {
}
}
- serverstatisticmanager = new ServerStatsCounter(this.server, file1);
+ serverstatisticmanager = new ServerStatsCounter(this.server, file1, uuid); // Slice
// this.stats.put(uuid, serverstatisticmanager); // CraftBukkit
}
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
index 8afd9b785fb8734255e3ea926b8375bb9cae60be..5a0ccc7e08ecba5dc62c02195c5f87c22ea6d122 100644
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
@@ -45,7 +45,7 @@ public class ServerStatsCounter extends StatsCounter {
private final File file;
private final Set<Stat<?>> dirty = Sets.newHashSet();
- public ServerStatsCounter(MinecraftServer server, File file) {
+ public ServerStatsCounter(MinecraftServer server, File file, java.util.UUID uuid) { // Slice
this.server = server;
this.file = file;
// Spigot start
@@ -55,7 +55,14 @@ public class ServerStatsCounter extends StatsCounter {
this.stats.put( wrapper, entry.getValue().intValue() );
}
// Spigot end
- if (file.isFile()) {
+
+ // Slice start - If event supplies stats, use it. Otherwise just load from disk as usual
+ com.destroystokyo.paper.event.player.PlayerLoadStatsEvent event = new com.destroystokyo.paper.event.player.PlayerLoadStatsEvent(uuid);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ JsonObject providedStats = event.getStatistics();
+ if (providedStats != null) {
+ readStats(server.getFixerUpper(), fromJson(providedStats));
+ } else if (file.isFile()) { // Slice end
try {
this.parseLocal(server.getFixerUpper(), FileUtils.readFileToString(file));
} catch (IOException ioexception) {
@@ -103,46 +110,8 @@ public class ServerStatsCounter extends StatsCounter {
if (!jsonelement.isJsonNull()) {
CompoundTag nbttagcompound = ServerStatsCounter.fromJson(jsonelement.getAsJsonObject());
-
- nbttagcompound = DataFixTypes.STATS.updateToCurrentVersion(dataFixer, nbttagcompound, NbtUtils.getDataVersion(nbttagcompound, 1343));
- if (!nbttagcompound.contains("stats", 10)) {
- break label48;
- }
-
- CompoundTag nbttagcompound1 = nbttagcompound.getCompound("stats");
- Iterator iterator = nbttagcompound1.getAllKeys().iterator();
-
- while (true) {
- if (!iterator.hasNext()) {
- break label48;
- }
-
- String s1 = (String) iterator.next();
-
- if (nbttagcompound1.contains(s1, 10)) {
- Util.ifElse(BuiltInRegistries.STAT_TYPE.getOptional(new ResourceLocation(s1)), (statisticwrapper) -> {
- CompoundTag nbttagcompound2 = nbttagcompound1.getCompound(s1);
- Iterator iterator1 = nbttagcompound2.getAllKeys().iterator();
-
- while (iterator1.hasNext()) {
- String s2 = (String) iterator1.next();
-
- if (nbttagcompound2.contains(s2, 99)) {
- Util.ifElse(this.getStat(statisticwrapper, s2), (statistic) -> {
- this.stats.put(statistic, nbttagcompound2.getInt(s2));
- }, () -> {
- ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2);
- });
- } else {
- ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2});
- }
- }
-
- }, () -> {
- ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1);
- });
- }
- }
+ readStats(dataFixer, nbttagcompound);
+ break label48;
}
ServerStatsCounter.LOGGER.error("Unable to parse Stat data from {}", this.file);
@@ -167,6 +136,48 @@ public class ServerStatsCounter extends StatsCounter {
}
+ private void readStats(DataFixer dataFixer, CompoundTag nbttagcompound) {
+ nbttagcompound = DataFixTypes.STATS.updateToCurrentVersion(dataFixer, nbttagcompound, NbtUtils.getDataVersion(nbttagcompound, 1343));
+ if (!nbttagcompound.contains("stats", 10)) {
+ return;
+ }
+
+ CompoundTag nbttagcompound1 = nbttagcompound.getCompound("stats");
+ Iterator iterator = nbttagcompound1.getAllKeys().iterator();
+
+ while (true) {
+ if (!iterator.hasNext()) {
+ return;
+ }
+
+ String s1 = (String) iterator.next();
+
+ if (nbttagcompound1.contains(s1, 10)) {
+ Util.ifElse(BuiltInRegistries.STAT_TYPE.getOptional(new ResourceLocation(s1)), (statisticwrapper) -> {
+ CompoundTag nbttagcompound2 = nbttagcompound1.getCompound(s1);
+ Iterator iterator1 = nbttagcompound2.getAllKeys().iterator();
+
+ while (iterator1.hasNext()) {
+ String s2 = (String) iterator1.next();
+
+ if (nbttagcompound2.contains(s2, 99)) {
+ Util.ifElse(this.getStat(statisticwrapper, s2), (statistic) -> {
+ this.stats.put(statistic, nbttagcompound2.getInt(s2));
+ }, () -> {
+ ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2);
+ });
+ } else {
+ ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2});
+ }
+ }
+
+ }, () -> {
+ ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1);
+ });
+ }
+ }
+ }
+
private <T> Optional<Stat<T>> getStat(StatType<T> type, String id) {
// CraftBukkit - decompile error start
Optional<ResourceLocation> optional = Optional.ofNullable(ResourceLocation.tryParse(id));

View File

@@ -0,0 +1,52 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:16:50 -0500
Subject: [PATCH] Add Force Crit to PlayerPreAttackEntityEvent
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index a144f9a911297891645f704c361e1d8ba0e28a69..a3f47872173eb9798b263c419e87b0adedcc4e25 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1276,10 +1276,11 @@ public abstract class Player extends LivingEntity {
flag1 = true;
}
- boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; // Paper - Add critical damage API - conflict on change
+ boolean forceCrit = playerAttackEntityEvent.isForceCrit();
+ boolean flag2 = forceCrit || (flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity); // Paper - Add critical damage API - conflict on change // Slice
flag2 = flag2 && !level.paperConfig().entities.behavior.disablePlayerCrits; // Paper
- flag2 = flag2 && !this.isSprinting();
+ flag2 = forceCrit || (flag2 && !this.isSprinting()); // Slice
if (flag2) {
f *= 1.5F;
}
@@ -2394,27 +2395,6 @@ public abstract class Player extends LivingEntity {
this.lastDeathLocation = lastDeathPos;
}
- @Override
- public float getHurtDir() {
- return this.hurtDir;
- }
-
- @Override
- public void animateHurt(float yaw) {
- super.animateHurt(yaw);
- this.hurtDir = yaw;
- }
-
- @Override
- public boolean canSprint() {
- return true;
- }
-
- @Override
- protected float getFlyingSpeed() {
- return this.abilities.flying && !this.isPassenger() ? (this.isSprinting() ? this.abilities.getFlyingSpeed() * 2.0F : this.abilities.getFlyingSpeed()) : (this.isSprinting() ? 0.025999999F : 0.02F);
- }
-
public static enum BedSleepingProblem {
NOT_POSSIBLE_HERE, NOT_POSSIBLE_NOW(Component.translatable("block.minecraft.bed.no_sleep")), TOO_FAR_AWAY(Component.translatable("block.minecraft.bed.too_far_away")), OBSTRUCTED(Component.translatable("block.minecraft.bed.obstructed")), OTHER_PROBLEM, NOT_SAFE(Component.translatable("block.minecraft.bed.not_safe"));

View File

@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:17:39 -0500
Subject: [PATCH] Add Preventing KB Bonus to PlayerPreAttackEntityEvent
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index a3f47872173eb9798b263c419e87b0adedcc4e25..28125492ceed99b244c5e177edb6739a9c2d68d9 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1268,7 +1268,11 @@ public abstract class Player extends LivingEntity {
boolean flag = f2 > 0.9F;
boolean flag1 = false;
byte b0 = 0;
- int i = b0 + EnchantmentHelper.getKnockbackBonus(this);
+ int i = b0; // Slice start
+ if (!playerAttackEntityEvent.isPreventKnockbackBonus()) {
+ i += EnchantmentHelper.getKnockbackBonus(this);
+ }
+ // Slice end
if (this.isSprinting() && flag) {
sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility

View File

@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:20:19 -0500
Subject: [PATCH] Player specific target chunk send rate
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
index 5b32567bcf532994a31f184743cf42f4ea0113a4..cf2656a4290bbf57d8a911eee4b94af4dea44637 100644
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
@@ -386,8 +386,8 @@ public final class PlayerChunkLoader {
return (int)Math.ceil(Math.min(config * MinecraftServer.getServer().getPlayerCount(), max <= 1.0 ? Double.MAX_VALUE : max));
}
- protected long getTargetSendPerPlayerAddend() {
- return GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate <= 1.0 ? 0L : (long)Math.round(1.0e9 / GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate);
+ protected long getTargetSendPerPlayerAddend(ServerPlayer player) { // Slice
+ return player.targetChunkSendRate <= 1.0 ? 0L : (long)Math.round(1.0e9 / player.targetChunkSendRate); // Slice
}
protected long getMaxSendAddend() {
@@ -541,7 +541,6 @@ public final class PlayerChunkLoader {
}
final int maxSends = this.getMaxConcurrentChunkSends();
- final long nextPlayerDeadline = this.getTargetSendPerPlayerAddend() + time;
for (;;) {
if (this.chunkSendQueue.isEmpty()) {
break;
@@ -574,7 +573,7 @@ public final class PlayerChunkLoader {
throw new IllegalStateException();
}
- data.nextChunkSendTarget = nextPlayerDeadline;
+ data.nextChunkSendTarget = this.getTargetSendPerPlayerAddend(data.player) + time; // Slice
this.chunkSendWaitQueue.add(data);
synchronized (this.sendingChunkCounts) {
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 4b28d3c0c973e0c33cb7e0063021556f8d3976d4..cc69ec55f0aaac0abda5be7cf2d707b7448627f6 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -276,6 +276,7 @@ public class ServerPlayer extends Player {
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event
public boolean smoothWorldTeleport; // Slice
+ public double targetChunkSendRate = io.papermc.paper.configuration.GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate; // Slice
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);

View File

@@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 25 Apr 2023 08:21:03 -0500
Subject: [PATCH] noEntityCollisions for Entity
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
index a87f6380b2c387fb0cdd40d5087b5c93492e3c88..cd35c2136a638c07fed683a2f92e70aa57bcfa8e 100644
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -809,7 +809,7 @@ public final class CollisionUtil {
public static boolean getEntityHardCollisions(final CollisionGetter getter, final Entity entity, AABB aabb,
final List<AABB> into, final boolean checkOnly, final Predicate<Entity> predicate) {
- if (isEmpty(aabb) || !(getter instanceof EntityGetter entityGetter)) {
+ if ((entity != null && entity.noEntityCollisions) || isEmpty(aabb) || !(getter instanceof EntityGetter entityGetter)) { // Slice
return false;
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 40af077f7a8115142ecc07f486246fdbc70f15f4..6e23c18003f582d0e0c963ca69393b0eb2d8fcbe 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -434,6 +434,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
* Overriding this field will cause memory leaks.
*/
private final boolean hardCollides;
+ public boolean noEntityCollisions; // Slice
private static final java.util.Map<Class<? extends Entity>, Boolean> cachedOverrides = java.util.Collections.synchronizedMap(new java.util.WeakHashMap<>());
{