More more more more work

This commit is contained in:
Nassim Jahnke
2023-06-07 21:37:42 +02:00
parent dae8787b45
commit 9ffb4e1b63
40 changed files with 39 additions and 41 deletions

View File

@@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
boolean flag = d8 > 0.0D; boolean flag = d7 > 0.0D;
if (this.player.isOnGround() && !packet.isOnGround() && flag) { if (this.player.onGround() && !packet.isOnGround() && flag) {
- this.player.jumpFromGround(); - this.player.jumpFromGround();
+ // Paper start - Add player jump event + // Paper start - Add player jump event
+ Player player = this.getCraftPlayer(); + Player player = this.getCraftPlayer();

View File

@@ -29,18 +29,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end + // Paper end
@Override @Override
public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) {
- PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
+ // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async + // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // Paper - run this async
// CraftBukkit start // CraftBukkit start
if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
- this.disconnect(Component.translatable("disconnect.spam")); - this.disconnect(Component.translatable("disconnect.spam"));
+ server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]))); // Paper + server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]))); // Paper
return; return;
} }
// Paper start
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
// Paper end
// CraftBukkit end // CraftBukkit end
+ // Paper start - async tab completion + // Paper start - async tab completion
+ TAB_COMPLETE_EXECUTOR.execute(() -> { + TAB_COMPLETE_EXECUTOR.execute(() -> {

View File

@@ -575,10 +575,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.papermc.paper.math.Position; import io.papermc.paper.math.Position;
import com.google.gson.JsonArray; import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
@@ -0,0 +0,0 @@ import net.minecraft.world.level.Level; @@ -0,0 +0,0 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.Level;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
+import com.mojang.authlib.GameProfile; +import com.mojang.authlib.GameProfile;
import org.bukkit.Location; import org.bukkit.Location;

View File

@@ -64,9 +64,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} private int tickCount;
} private boolean handlingFault;
// Paper end - add pending task queue public String hostname = ""; // CraftBukkit - add field
+ // Paper start - NetworkClient implementation + // Paper start - NetworkClient implementation
+ public int protocolVersion; + public int protocolVersion;
+ public java.net.InetSocketAddress virtualHost; + public java.net.InetSocketAddress virtualHost;

View File

@@ -29,14 +29,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }*/ // Paper + }*/ // Paper
// CraftBukkit end // CraftBukkit end
Bootstrap.isBootstrapped = true; Bootstrap.isBootstrapped = true;
if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { Instant instant = Instant.now();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java --- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -0,0 +0,0 @@ public class Main { @@ -0,0 +0,0 @@ public class Main {
Calendar deadline = Calendar.getInstance(); Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -21); deadline.add(Calendar.DAY_OF_YEAR, -3);
if (buildDate.before(deadline.getTime())) { if (buildDate.before(deadline.getTime())) {
- System.err.println("*** Error, this build is outdated ***"); - System.err.println("*** Error, this build is outdated ***");
+ // Paper start - This is some stupid bullshit + // Paper start - This is some stupid bullshit

View File

@@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ExperienceOrb extends Entity { @@ -0,0 +0,0 @@ public class ExperienceOrb extends Entity {
@Override @Override
public void playerTouch(Player player) { public void playerTouch(Player player) {
if (!this.level.isClientSide) { if (!this.level().isClientSide) {
- if (player.takeXpDelay == 0) { - if (player.takeXpDelay == 0) {
+ if (player.takeXpDelay == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper + if (player.takeXpDelay == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper
player.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(player, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; player.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(player, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2;

View File

@@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
int i = b0 + EnchantmentHelper.getKnockbackBonus(this); int i = b0 + EnchantmentHelper.getKnockbackBonus(this);
if (this.isSprinting() && flag) { if (this.isSprinting() && flag) {
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F);
+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
++i; ++i;
flag1 = true; flag1 = true;
@@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F);
+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
this.sweepAttack(); this.sweepAttack();
} }
@@ -31,26 +31,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
if (flag2) { if (flag2) {
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F);
+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
this.crit(target); this.crit(target);
} }
if (!flag2 && !flag3) { if (!flag2 && !flag3) {
if (flag) { if (flag) {
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F); - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F);
+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
} else { } else {
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F); - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F);
+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
} }
} }
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
this.causeFoodExhaustion(level.spigotConfig.combatExhaustion, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value this.causeFoodExhaustion(this.level().spigotConfig.combatExhaustion, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent // Spigot - Change to use configurable value
} else { } else {
- this.level.playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F);
+ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
if (flag4) { if (flag4) {
target.clearFire(); target.clearFire();

View File

@@ -29,23 +29,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return entity; + return entity;
+ } + }
+ // Paper - maintain old signature + // Paper - maintain old signature
private boolean spawnEntityFromShoulder(CompoundTag nbttagcompound) { // CraftBukkit void->boolean +
- if (!this.level.isClientSide && !nbttagcompound.isEmpty()) { private boolean respawnEntityOnShoulder(CompoundTag nbttagcompound) { // CraftBukkit void->boolean
+ return spawnEntityFromShoulder0(nbttagcompound) != null; - if (!this.level().isClientSide && !nbttagcompound.isEmpty()) {
+ return this.spawnEntityFromShoulder0(nbttagcompound) != null;
+ } + }
+ +
+ // Paper - return entity + // Paper - return entity
+ private Entity spawnEntityFromShoulder0(@Nullable CompoundTag nbttagcompound) { + private Entity respawnEntityOnShoulder0(CompoundTag nbttagcompound) { // CraftBukkit void->boolean
+ if (!this.level.isClientSide && nbttagcompound != null && !nbttagcompound.isEmpty()) { + if (!this.level().isClientSide && nbttagcompound != null && !nbttagcompound.isEmpty()) {
return EntityType.create(nbttagcompound, this.level).map((entity) -> { // CraftBukkit return EntityType.create(nbttagcompound, this.level()).map((entity) -> { // CraftBukkit
if (entity instanceof TamableAnimal) { if (entity instanceof TamableAnimal) {
((TamableAnimal) entity).setOwnerUUID(this.uuid); ((TamableAnimal) entity).setOwnerUUID(this.uuid);
} }
entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ()); entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ());
- return ((ServerLevel) this.level).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit - return ((ServerLevel) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
- }).orElse(true); // CraftBukkit - }).orElse(true); // CraftBukkit
+ boolean addedToWorld = ((ServerLevel) this.level).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit + boolean addedToWorld = ((ServerLevel) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
+ return addedToWorld ? entity : null; + return addedToWorld ? entity : null;
+ }).orElse(null); // CraftBukkit // Paper - true -> null + }).orElse(null); // CraftBukkit // Paper - true -> null
} }

View File

@@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround() && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity;
+ flag2 = flag2 && !level.paperConfig().entities.behavior.disablePlayerCrits; // Paper + flag2 = flag2 && !level.paperConfig().entities.behavior.disablePlayerCrits; // Paper
flag2 = flag2 && !this.isSprinting(); flag2 = flag2 && !this.isSprinting();

View File

@@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
public void handleKeepAlive(ServerboundKeepAlivePacket packet) { public void handleKeepAlive(ServerboundKeepAlivePacket packet) {
- PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit
+ //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread + //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread
if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) {
int i = (int) (Util.getMillis() - this.keepAliveTime); int i = (int) (Util.getMillis() - this.keepAliveTime);

View File

@@ -42,15 +42,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.server.getProfiler().push("keepAlive"); this.server.getProfiler().push("keepAlive");
- long i = Util.getMillis(); - long i = Util.getMillis();
+ // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings -
+ // This should effectively place the keepalive handling back to "as it was" before 1.12.2
+ long currentTime = Util.getMillis();
+ long elapsedTime = currentTime - this.keepAliveTime;
- if (i - this.keepAliveTime >= 25000L) { // CraftBukkit - if (i - this.keepAliveTime >= 25000L) { // CraftBukkit
- if (this.keepAlivePending) { - if (this.keepAlivePending) {
- this.disconnect(Component.translatable("disconnect.timeout")); - this.disconnect(Component.translatable("disconnect.timeout"));
- } else { - } else {
+ // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings
+ // This should effectively place the keepalive handling back to "as it was" before 1.12.2
+ long currentTime = Util.getMillis();
+ long elapsedTime = currentTime - this.keepAliveTime;
+
+ if (this.keepAlivePending) { + if (this.keepAlivePending) {
+ if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected + if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
+ ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info + ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info