more work

all server patches done (almost)
This commit is contained in:
Lulu13022002 2023-09-22 18:59:52 +02:00
parent 0925b4af6f
commit fdf4e8726b
53 changed files with 30 additions and 30 deletions

View File

@ -57,14 +57,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.entries = buf.readList((buf2) -> { this.entries = buf.readList((buf2) -> {
@@ -0,0 +0,0 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke @@ -0,0 +0,0 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke
public static record Entry(UUID profileId, GameProfile profile, boolean listed, int latency, GameType gameMode, @Nullable Component displayName, @Nullable RemoteChatSession.Data chatSession) { public static record Entry(UUID profileId, @Nullable GameProfile profile, boolean listed, int latency, GameType gameMode, @Nullable Component displayName, @Nullable RemoteChatSession.Data chatSession) {
Entry(ServerPlayer player) { Entry(ServerPlayer player) {
- this(player.getUUID(), player.getGameProfile(), true, player.latency, player.gameMode.getGameModeForPlayer(), player.getTabListDisplayName(), Optionull.map(player.getChatSession(), RemoteChatSession::asData)); - this(player.getUUID(), player.getGameProfile(), true, player.connection.latency(), player.gameMode.getGameModeForPlayer(), player.getTabListDisplayName(), Optionull.map(player.getChatSession(), RemoteChatSession::asData));
+ // Paper start - add listed + // Paper start - add listed
+ this(player, true); + this(player, true);
+ } + }
+ Entry(ServerPlayer player, boolean listed) { + Entry(ServerPlayer player, boolean listed) {
+ this(player.getUUID(), player.getGameProfile(), listed, player.latency, player.gameMode.getGameModeForPlayer(), player.getTabListDisplayName(), Optionull.map(player.getChatSession(), RemoteChatSession::asData)); + this(player.getUUID(), player.getGameProfile(), listed, player.connection.latency(), player.gameMode.getGameModeForPlayer(), player.getTabListDisplayName(), Optionull.map(player.getChatSession(), RemoteChatSession::asData));
+ // Paper end - add listed + // Paper end - add listed
+ } + }
+ // Paper start + // Paper start

View File

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- 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 extends ServerCommonPacketListenerImpl
this.disconnect("Invalid hotbar selection (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause this.disconnect("Invalid hotbar selection (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
return; return;
} }

View File

@ -231,7 +231,7 @@ diff --git a/src/main/java/net/minecraft/world/inventory/ResultContainer.java b/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/inventory/ResultContainer.java --- a/src/main/java/net/minecraft/world/inventory/ResultContainer.java
+++ b/src/main/java/net/minecraft/world/inventory/ResultContainer.java +++ b/src/main/java/net/minecraft/world/inventory/ResultContainer.java
@@ -0,0 +0,0 @@ public class ResultContainer implements Container, RecipeHolder { @@ -0,0 +0,0 @@ public class ResultContainer implements Container, RecipeCraftingHolder {
} }
public org.bukkit.inventory.InventoryHolder getOwner() { public org.bukkit.inventory.InventoryHolder getOwner() {
@ -245,7 +245,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// Don't need a transaction; the InventoryCrafting keeps track of it for us // Don't need a transaction; the InventoryCrafting keeps track of it for us
@@ -0,0 +0,0 @@ public class ResultContainer implements Container, RecipeHolder { @@ -0,0 +0,0 @@ public class ResultContainer implements Container, RecipeCraftingHolder {
return null; return null;
} }
// CraftBukkit end // CraftBukkit end

View File

@ -10,9 +10,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double d1 = vec3d_dx * vec3d_dx + vec3d_dz * vec3d_dz; // Paper double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z;
double d2 = d0 * d0; double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player); boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
+ // Paper start - check Y + // Paper start - check Y
+ if (flag && level.paperConfig().entities.trackingRangeY.enabled) { + if (flag && level.paperConfig().entities.trackingRangeY.enabled) {
+ double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1); + double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);

View File

@ -14,7 +14,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- 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 extends ServerCommonPacketListenerImpl
ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {

View File

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- 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 extends ServerCommonPacketListenerImpl
double d0 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX(this.player.getX())); final double toX = d0; // Paper - OBFHELPER double d0 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX(this.player.getX())); final double toX = d0; // Paper - OBFHELPER
double d1 = ServerGamePacketListenerImpl.clampVertical(packet.getY(this.player.getY())); final double toY = d1; double d1 = ServerGamePacketListenerImpl.clampVertical(packet.getY(this.player.getY())); final double toY = d1;
double d2 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ(this.player.getZ())); final double toZ = d2; // Paper - OBFHELPER double d2 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ(this.player.getZ())); final double toZ = d2; // Paper - OBFHELPER
@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.player.isPassenger()) { if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
} }
// Paper start - Prevent moving into unloaded chunks // Paper start - Prevent moving into unloaded chunks
if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) { if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) {
@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// Paper end // Paper end
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
// CraftBukkit end // CraftBukkit end
@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
boolean flag2 = false; boolean flag2 = false;
if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// Paper start - optimise out extra getCubes // Paper start - optimise out extra getCubes
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (didCollide || !axisalignedbb.equals(newBox)) { if (didCollide || !axisalignedbb.equals(newBox)) {
// note: only call after setLocation, or else getBoundingBox is wrong // note: only call after setLocation, or else getBoundingBox is wrong
teleportBack = this.hasNewCollision(worldserver, this.player, axisalignedbb, newBox); teleportBack = this.hasNewCollision(worldserver, this.player, axisalignedbb, newBox);
@ -83,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} // else: no collision at all detected, why do we care? } // else: no collision at all detected, why do we care?
} }
if (!this.player.noPhysics && !this.player.isSleeping() && teleportBack) { // Paper end - optimise out extra getCubes if (!this.player.noPhysics && !this.player.isSleeping() && teleportBack) { // Paper end - optimise out extra getCubes
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
} }
} }

View File

@ -27,12 +27,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!world.isClientSide) { if (!world.isClientSide) {
ServerPlayer entityplayer = (ServerPlayer) player; ServerPlayer entityplayer = (ServerPlayer) player;
ItemStack itemstack = ItemStack.EMPTY; ItemStack itemstack = ItemStack.EMPTY;
- Optional<CraftingRecipe> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingInventory, world); - Optional<RecipeHolder<CraftingRecipe>> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingInventory, world);
+ final Recipe<?> currentRecipe = craftingInventory.getCurrentRecipe(); // Paper - check last recipe used first + final RecipeHolder<?> currentRecipe = craftingInventory.getCurrentRecipe(); // Paper - check last recipe used first
+ Optional<CraftingRecipe> optional = currentRecipe == null ? world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingInventory, world) : world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingInventory, world, currentRecipe.getId()).map(com.mojang.datafixers.util.Pair::getSecond); // Paper - check last recipe used first + Optional<RecipeHolder<CraftingRecipe>> optional = currentRecipe == null ? world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingInventory, world) : world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftingInventory, world, currentRecipe.id()).map(com.mojang.datafixers.util.Pair::getSecond); // Paper - check last recipe used first
if (optional.isPresent()) { if (optional.isPresent()) {
CraftingRecipe recipecrafting = (CraftingRecipe) optional.get(); RecipeHolder<CraftingRecipe> recipeholder = (RecipeHolder) optional.get();
diff --git a/src/main/java/net/minecraft/world/inventory/ResultSlot.java b/src/main/java/net/minecraft/world/inventory/ResultSlot.java diff --git a/src/main/java/net/minecraft/world/inventory/ResultSlot.java b/src/main/java/net/minecraft/world/inventory/ResultSlot.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/inventory/ResultSlot.java --- a/src/main/java/net/minecraft/world/inventory/ResultSlot.java
@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void onTake(Player player, ItemStack stack) { public void onTake(Player player, ItemStack stack) {
this.checkTakeAchievements(stack); this.checkTakeAchievements(stack);
- NonNullList<ItemStack> nonNullList = player.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, this.craftSlots, player.level()); - NonNullList<ItemStack> nonNullList = player.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, this.craftSlots, player.level());
+ NonNullList<ItemStack> nonNullList = player.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, this.craftSlots, player.level(), this.craftSlots.getCurrentRecipe() != null ? this.craftSlots.getCurrentRecipe().getId() : null); // Paper - check last recipe used first + NonNullList<ItemStack> nonNullList = player.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, this.craftSlots, player.level(), this.craftSlots.getCurrentRecipe() != null ? this.craftSlots.getCurrentRecipe().id() : null); // Paper - check last recipe used first
for(int i = 0; i < nonNullList.size(); ++i) { for(int i = 0; i < nonNullList.size(); ++i) {
ItemStack itemStack = this.craftSlots.getItem(i); ItemStack itemStack = this.craftSlots.getItem(i);
@ -51,33 +51,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java --- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java +++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { @@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
T t0 = map.get(id); // CraftBukkit - decompile error RecipeHolder<T> recipeholder = (RecipeHolder) map.get(id);
if (t0 != null && t0.matches(inventory, world)) { if (recipeholder != null && recipeholder.value().matches(inventory, world)) {
+ inventory.setCurrentRecipe(t0); // Paper + inventory.setCurrentRecipe(recipeholder); // Paper
return Optional.of(Pair.of(id, t0)); return Optional.of(Pair.of(id, recipeholder));
} }
} }
+ inventory.setCurrentRecipe(null); // Paper - clear before it might be set again + inventory.setCurrentRecipe(null); // Paper - clear before it might be set again
return map.entrySet().stream().filter((entry) -> { return map.entrySet().stream().filter((entry) -> {
return ((Recipe) entry.getValue()).matches(inventory, world); return ((RecipeHolder) entry.getValue()).value().matches(inventory, world);
}).findFirst().map((entry) -> { }).findFirst().map((entry) -> {
+ inventory.setCurrentRecipe(entry.getValue()); // Paper + inventory.setCurrentRecipe(entry.getValue()); // Paper
return Pair.of((ResourceLocation) entry.getKey(), entry.getValue()); // CraftBukkit - decompile error return Pair.of((ResourceLocation) entry.getKey(), (RecipeHolder) entry.getValue());
}); });
} }
@@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { @@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
} }
public <C extends Container, T extends Recipe<C>> NonNullList<ItemStack> getRemainingItemsFor(RecipeType<T> type, C inventory, Level world) { public <C extends Container, T extends Recipe<C>> NonNullList<ItemStack> getRemainingItemsFor(RecipeType<T> type, C inventory, Level world) {
- Optional<T> optional = this.getRecipeFor(type, inventory, world); - Optional<RecipeHolder<T>> optional = this.getRecipeFor(type, inventory, world);
+ // Paper start - check last recipe used first + // Paper start - check last recipe used first
+ return this.getRemainingItemsFor(type, inventory, world, null); + return this.getRemainingItemsFor(type, inventory, world, null);
+ } + }
+ public <C extends Container, T extends Recipe<C>> NonNullList<ItemStack> getRemainingItemsFor(RecipeType<T> type, C inventory, Level world, @Nullable ResourceLocation firstToCheck) { + public <C extends Container, T extends Recipe<C>> NonNullList<ItemStack> getRemainingItemsFor(RecipeType<T> type, C inventory, Level world, @Nullable ResourceLocation firstToCheck) {
+ Optional<T> optional = firstToCheck == null ? this.getRecipeFor(type, inventory, world) : this.getRecipeFor(type, inventory, world, firstToCheck).map(Pair::getSecond); + Optional<RecipeHolder<T>> optional = firstToCheck == null ? this.getRecipeFor(type, inventory, world) : this.getRecipeFor(type, inventory, world, firstToCheck).map(Pair::getSecond);
+ // Paper end + // Paper end
if (optional.isPresent()) { if (optional.isPresent()) {
return ((Recipe) optional.get()).getRemainingItems(inventory); return ((RecipeHolder) optional.get()).value().getRemainingItems(inventory);

View File

@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT))); this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT)));
} else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT))); this.setProfile(new CraftGameProfile(null, tag.getString(SKULL_OWNER.NBT)));
} }
+ } catch (Exception ignored) {} // Paper + } catch (Exception ignored) {} // Paper