more more more more more more more more more more work
This commit is contained in:
parent
4875ee4814
commit
3aa8e7ef3f
32 changed files with 102 additions and 103 deletions
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 16 Jun 2022 14:22:56 -0700
|
||||
Subject: [PATCH] Don't broadcast messages to command blocks
|
||||
|
||||
Previously the broadcast method would update the last output
|
||||
in command blocks, and if called asynchronously, would throw
|
||||
an error
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
index e05eb08a9c229b371887676da510df948b896a85..ceeedbd88c56c08ec8b047c9ca2f14cc581e12ad 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
@@ -172,6 +172,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
||||
@Override
|
||||
public void sendSystemMessage(Component message) {
|
||||
if (this.trackOutput) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper
|
||||
SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT;
|
||||
Date date = new Date();
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 17eaf05dbf0542f7867e92421148cf4edf47bd80..097ceaa948469f6b63362dfa00525cd0fd01d907 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1777,7 +1777,7 @@ public final class CraftServer implements Server {
|
||||
// Paper end
|
||||
Set<CommandSender> recipients = new HashSet<>();
|
||||
for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) {
|
||||
- if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
|
||||
+ if (permissible instanceof CommandSender && !(permissible instanceof org.bukkit.command.BlockCommandSender) && permissible.hasPermission(permission)) { // Paper - don't broadcast to BlockCommandSender (specifically Command Blocks)
|
||||
recipients.add((CommandSender) permissible);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Wed, 15 Jun 2022 21:52:57 -0400
|
||||
Subject: [PATCH] Prevent empty items from being added to world
|
||||
|
||||
The previous solution caused a bunch of bandaid fixes inorder to resolve edge cases where minecraft/the api might spawn items that are air.
|
||||
Just simply prevent them from being added to the world instead.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 0a57c11f1b9811e4fb980268bc561df4290494cf..565b5aca5854876ae640d9d93b3ae24da6e12b70 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1296,6 +1296,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
||||
return false;
|
||||
} else {
|
||||
+ if (entity instanceof net.minecraft.world.entity.item.ItemEntity itemEntity && itemEntity.getItem().isEmpty()) return false; // Paper - Prevent empty items from being added
|
||||
// Paper start - capture all item additions to the world
|
||||
if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) {
|
||||
captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity);
|
||||
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 b8db8750125315b15cc3d3e76ee629a60c4546a1..6b3a17e6717b8c03c5bd674771b29e4becd42c71 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -520,7 +520,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
}
|
||||
|
||||
public void setItem(ItemStack stack) {
|
||||
- com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit
|
||||
+ // com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit // Paper - Remove check
|
||||
this.getEntityData().set(ItemEntity.DATA_ITEM, stack);
|
||||
this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 21 Apr 2022 18:18:02 -0700
|
||||
Subject: [PATCH] Fix CCE for SplashPotion and LingeringPotion spawning
|
||||
|
||||
Remove in 1.19 along with the SplashPotion and
|
||||
LingeringPotion interfaces
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
|
||||
index f1a3ed6670fcb4e40000ed5c4f7042a4ca99175c..04bcb1f26db12556d70e41541a5df0700d20d964 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
|
||||
@@ -13,7 +13,7 @@ import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
-public class CraftThrownPotion extends CraftThrowableProjectile implements ThrownPotion {
|
||||
+public class CraftThrownPotion extends CraftThrowableProjectile implements ThrownPotion, org.bukkit.entity.SplashPotion, org.bukkit.entity.LingeringPotion { // Paper - implement other classes to avoid violating spawn method generic contracts
|
||||
public CraftThrownPotion(CraftServer server, net.minecraft.world.entity.projectile.ThrownPotion entity) {
|
||||
super(server, entity);
|
||||
}
|
26
patches/server/0817-Add-Player-getFishHook.patch
Normal file
26
patches/server/0817-Add-Player-getFishHook.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: u9g <git@u9g.dev>
|
||||
Date: Tue, 14 Jun 2022 19:36:10 -0400
|
||||
Subject: [PATCH] Add Player#getFishHook
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
index 268d0abadb1c6de78f7b2de964808ca7029970a8..beefbb0d04bd995bc8750707487183c3ffc22239 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
@@ -161,6 +161,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
return new Location(worldServer.getWorld(), bed.getX(), bed.getY(), bed.getZ());
|
||||
}
|
||||
// Paper end
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public org.bukkit.entity.FishHook getFishHook() {
|
||||
+ if (getHandle().fishing == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return (org.bukkit.entity.FishHook) getHandle().fishing.getBukkitEntity();
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public boolean sleep(Location location, boolean force) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
|
@ -0,0 +1,29 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 3 Jul 2022 22:31:37 -0700
|
||||
Subject: [PATCH] Do not sync load chunk for dynamic game event listener
|
||||
registration
|
||||
|
||||
These can be called while an entity is being added to the world,
|
||||
and if the entity is being added from a chunk load context the
|
||||
sync load will block indefinitely (because the chunk load context
|
||||
is for completing the chunk to FULL).
|
||||
|
||||
This does raise questions about the current system for these
|
||||
dynamic registrations, as it looks like there is _zero_ logic
|
||||
to account for the case where the chunk is _not_ currently loaded
|
||||
and then later loaded.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java b/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java
|
||||
index e64435c1dfbaf182d2292a1123701033f817ec38..d368ba29fec49a989be1cacd2422599d6d613c29 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java
|
||||
@@ -48,7 +48,7 @@ public class DynamicGameEventListener<T extends GameEventListener> {
|
||||
|
||||
private static void ifChunkExists(LevelReader world, @Nullable SectionPos sectionPos, Consumer<GameEventListenerRegistry> dispatcherConsumer) {
|
||||
if (sectionPos != null) {
|
||||
- ChunkAccess chunkAccess = world.getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.FULL, false);
|
||||
+ ChunkAccess chunkAccess = world.getChunkIfLoadedImmediately(sectionPos.getX(), sectionPos.getZ()); // Paper - can cause sync loads while completing a chunk, resulting in deadlock
|
||||
if (chunkAccess != null) {
|
||||
dispatcherConsumer.accept(chunkAccess.getListenerRegistry(sectionPos.y()));
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 20 Jul 2021 21:35:47 -0700
|
||||
Subject: [PATCH] Add various missing EntityDropItemEvent calls
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index a45f7b96fb3afc9ebe1354d9c61c4a66a67fae69..56060d5d962a1827873d3b2311f30b766c64575f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2559,6 +2559,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe
|
||||
|
||||
entityitem.setDefaultPickUpDelay();
|
||||
+ // Paper start
|
||||
+ return this.spawnAtLocation(entityitem);
|
||||
+ }
|
||||
+ }
|
||||
+ @Nullable
|
||||
+ public ItemEntity spawnAtLocation(ItemEntity entityitem) {
|
||||
+ {
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java
|
||||
index 1c4b8b29faac3dbcfc14a07b24c64650982ece00..8448c5d778998390cf2b683f36e4e18ca7ffdc34 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java
|
||||
@@ -597,7 +597,7 @@ public class Dolphin extends WaterAnimal {
|
||||
float f2 = 0.02F * Dolphin.this.random.nextFloat();
|
||||
|
||||
entityitem.setDeltaMovement((double) (0.3F * -Mth.sin(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.cos(f1) * f2), (double) (0.3F * Mth.sin(Dolphin.this.getXRot() * 0.017453292F) * 1.5F), (double) (0.3F * Mth.cos(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.sin(f1) * f2));
|
||||
- Dolphin.this.level().addFreshEntity(entityitem);
|
||||
+ Dolphin.this.spawnAtLocation(entityitem); // Paper - call EntityDropItemEvent
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
||||
index df06cad9447982ebe57d07c9967cb68c6dd20ca3..9f24fb3ea75b9dcb41f70f6e4b0d6cd5dca57ff6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
||||
@@ -509,14 +509,14 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
|
||||
entityitem.setPickUpDelay(40);
|
||||
entityitem.setThrower(this.getUUID());
|
||||
this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F);
|
||||
- this.level().addFreshEntity(entityitem);
|
||||
+ this.spawnAtLocation(entityitem); // Paper - call EntityDropItemEvent
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItemStack(ItemStack stack) {
|
||||
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), stack);
|
||||
|
||||
- this.level().addFreshEntity(entityitem);
|
||||
+ this.spawnAtLocation(entityitem); // Paper - call EntityDropItemEvent
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
index 3ec2f590dfe9410f1a9d2afb530eebfcce917798..363892e0c26bab89d2abaa44d8736e2fd84d292f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -357,8 +357,7 @@ public class Goat extends Animal {
|
||||
double d2 = (double) Mth.randomBetween(this.random, -0.2F, 0.2F);
|
||||
ItemEntity entityitem = new ItemEntity(this.level(), vec3d.x(), vec3d.y(), vec3d.z(), itemstack, d0, d1, d2);
|
||||
|
||||
- this.level().addFreshEntity(entityitem);
|
||||
- return true;
|
||||
+ return this.spawnAtLocation(entityitem) != null; // Paper - call EntityDropItemEvent by calling spawnAtLocation.
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
index 1d9913cbc7fd0c6e29278b02c38703b52af1245b..36b3945832733b5ad66d25aa3a31335234d2acff 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
@@ -352,8 +352,9 @@ public class Sniffer extends Animal {
|
||||
|
||||
entityitem.setDefaultPickUpDelay();
|
||||
this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null);
|
||||
+ if (this.spawnAtLocation(entityitem) != null) { // Paper - call EntityDropItemEvent
|
||||
this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F);
|
||||
- world.addFreshEntity(entityitem);
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Wed, 6 Jul 2022 05:52:22 +0100
|
||||
Subject: [PATCH] Add some minimal debug information to chat packet errors
|
||||
|
||||
TODO: potentially add some kick leeway
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index aabd4a28cef4a31e0eed34d2e7c490199203bfd5..5d62bf8a1031295ca63289ebbdc11cf0910ccb14 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2134,7 +2134,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
private Optional<LastSeenMessages> tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) {
|
||||
if (!this.updateChatOrder(timestamp)) {
|
||||
- ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}'", this.player.getName().getString(), message);
|
||||
+ ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}': {} > {}", this.player.getName().getString(), message, this.lastChatTimeStamp.get().getEpochSecond(), timestamp.getEpochSecond()); // Paper
|
||||
this.server.scheduleOnMain(() -> { // Paper - push to main
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes
|
||||
}); // Paper - push to main
|
19
patches/server/0821-Fix-Bee-flower-NPE.patch
Normal file
19
patches/server/0821-Fix-Bee-flower-NPE.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 6 Jul 2022 14:59:38 -0700
|
||||
Subject: [PATCH] Fix Bee flower NPE
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index 7c81c6ebe200a029a5944b65827223e81ab08938..e06d5eea4bc81be264a1f5d5fad2d4548c4ae8d2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -803,7 +803,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
++this.pollinatingTicks;
|
||||
if (this.pollinatingTicks > 600) {
|
||||
Bee.this.savedFlowerPos = null;
|
||||
- } else {
|
||||
+ } else if (Bee.this.savedFlowerPos != null) { // Paper - add null check since API can manipulate this
|
||||
Vec3 vec3d = Vec3.atBottomCenterOf(Bee.this.savedFlowerPos).add(0.0D, 0.6000000238418579D, 0.0D);
|
||||
|
||||
if (vec3d.distanceTo(Bee.this.position()) > 1.0D) {
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Doc <nachito94@msn.com>
|
||||
Date: Sun, 17 Jul 2022 11:49:43 -0400
|
||||
Subject: [PATCH] Fix Spigot Config not using commands.spam-exclusions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 5d62bf8a1031295ca63289ebbdc11cf0910ccb14..4428b7310bcce3fd1471e5b89bc4eb9ec16deb4e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2354,7 +2354,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
}
|
||||
// Spigot end
|
||||
// this.chatSpamTickCount += 20;
|
||||
- if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
||||
+ if (counted && this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper - exclude from SpigotConfig.spamExclusions
|
||||
// CraftBukkit end
|
||||
this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - kick event cause
|
||||
}
|
216
patches/server/0823-More-Teleport-API.patch
Normal file
216
patches/server/0823-More-Teleport-API.patch
Normal file
|
@ -0,0 +1,216 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Sun, 5 Sep 2021 12:15:59 -0400
|
||||
Subject: [PATCH] More Teleport API
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.server.network.ServerGamePacketListenerImpl internalTeleport(DDDFFLjava/util/Set;Z)V
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 4428b7310bcce3fd1471e5b89bc4eb9ec16deb4e..57d2bffd55db5f7833121c6781984985689c4188 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1591,11 +1591,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
return false; // CraftBukkit - Return event status
|
||||
}
|
||||
|
||||
- PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause);
|
||||
+ // Paper start - Teleport API
|
||||
+ Set<io.papermc.paper.entity.TeleportFlag.Relative> relativeFlags = java.util.EnumSet.noneOf(io.papermc.paper.entity.TeleportFlag.Relative.class);
|
||||
+ for (RelativeMovement relativeArgument : set) {
|
||||
+ relativeFlags.add(org.bukkit.craftbukkit.entity.CraftPlayer.toApiRelativeFlag(relativeArgument));
|
||||
+ }
|
||||
+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags));
|
||||
+ // Paper end
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled() || !to.equals(event.getTo())) {
|
||||
- set.clear(); // Can't relative teleport
|
||||
+ //set.clear(); // Can't relative teleport // Paper - Teleport API: Now you can!
|
||||
to = event.isCancelled() ? event.getFrom() : event.getTo();
|
||||
d0 = to.getX();
|
||||
d1 = to.getY();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 87c303ff576cd05291d50d5676e86ca93a13b301..b19665fd570c86274caef62dc3e365f0e6a7ca8e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -567,15 +567,36 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location location, TeleportCause cause) {
|
||||
+ // Paper start - Teleport passenger API
|
||||
+ return teleport(location, cause, new io.papermc.paper.entity.TeleportFlag[0]);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean teleport(Location location, TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) {
|
||||
+ // Paper end
|
||||
Preconditions.checkArgument(location != null, "location cannot be null");
|
||||
location.checkFinite();
|
||||
+ // Paper start - Teleport passenger API
|
||||
+ Set<io.papermc.paper.entity.TeleportFlag> flagSet = Set.of(flags);
|
||||
+ boolean dismount = !flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_VEHICLE);
|
||||
+ boolean ignorePassengers = flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS);
|
||||
+ // Don't allow teleporting between worlds while keeping passengers
|
||||
+ if (flagSet.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS) && this.entity.isVehicle() && location.getWorld() != this.getWorld()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Don't allow to teleport between worlds if remaining on vehicle
|
||||
+ if (!dismount && this.entity.isPassenger() && location.getWorld() != this.getWorld()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
- if (this.entity.isVehicle() || this.entity.isRemoved()) {
|
||||
+ if ((!ignorePassengers && this.entity.isVehicle()) || this.entity.isRemoved()) { // Paper - Teleport passenger API
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this entity is riding another entity, we must dismount before teleporting.
|
||||
- this.entity.stopRiding();
|
||||
+ if (dismount) this.entity.stopRiding(); // Paper - Teleport passenger API
|
||||
|
||||
// Let the server handle cross world teleports
|
||||
if (location.getWorld() != null && !location.getWorld().equals(this.getWorld())) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 91d572075ea018e4768f11115723d67b06018bf0..17a4390514b72481de6dc0676eb8130428fabf89 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1170,13 +1170,101 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
- throw new UnsupportedOperationException("Cannot set rotation of players. Consider teleporting instead.");
|
||||
+ // Paper start - Teleport API
|
||||
+ Location targetLocation = this.getEyeLocation();
|
||||
+ targetLocation.setYaw(yaw);
|
||||
+ targetLocation.setPitch(pitch);
|
||||
+
|
||||
+ org.bukkit.util.Vector direction = targetLocation.getDirection();
|
||||
+ direction.multiply(9999999); // We need to move the target block.. FAR out
|
||||
+ targetLocation.add(direction);
|
||||
+ this.lookAt(targetLocation, io.papermc.paper.entity.LookAnchor.EYES);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ // Paper start - Teleport API
|
||||
+ return this.teleport(location, cause, new io.papermc.paper.entity.TeleportFlag[0]);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(@NotNull org.bukkit.entity.Entity entity, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor, @NotNull io.papermc.paper.entity.LookAnchor entityAnchor) {
|
||||
+ this.getHandle().lookAt(toNmsAnchor(playerAnchor), ((CraftEntity) entity).getHandle(), toNmsAnchor(entityAnchor));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(double x, double y, double z, @NotNull io.papermc.paper.entity.LookAnchor playerAnchor) {
|
||||
+ this.getHandle().lookAt(toNmsAnchor(playerAnchor), new Vec3(x, y, z));
|
||||
+ }
|
||||
+
|
||||
+ public static net.minecraft.commands.arguments.EntityAnchorArgument.Anchor toNmsAnchor(io.papermc.paper.entity.LookAnchor nmsAnchor) {
|
||||
+ return switch (nmsAnchor) {
|
||||
+ case EYES -> net.minecraft.commands.arguments.EntityAnchorArgument.Anchor.EYES;
|
||||
+ case FEET -> net.minecraft.commands.arguments.EntityAnchorArgument.Anchor.FEET;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ public static io.papermc.paper.entity.LookAnchor toApiAnchor(net.minecraft.commands.arguments.EntityAnchorArgument.Anchor playerAnchor) {
|
||||
+ return switch (playerAnchor) {
|
||||
+ case EYES -> io.papermc.paper.entity.LookAnchor.EYES;
|
||||
+ case FEET -> io.papermc.paper.entity.LookAnchor.FEET;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ public static net.minecraft.world.entity.RelativeMovement toNmsRelativeFlag(io.papermc.paper.entity.TeleportFlag.Relative apiFlag) {
|
||||
+ return switch (apiFlag) {
|
||||
+ case X -> net.minecraft.world.entity.RelativeMovement.X;
|
||||
+ case Y -> net.minecraft.world.entity.RelativeMovement.Y;
|
||||
+ case Z -> net.minecraft.world.entity.RelativeMovement.Z;
|
||||
+ case PITCH -> net.minecraft.world.entity.RelativeMovement.X_ROT;
|
||||
+ case YAW -> net.minecraft.world.entity.RelativeMovement.Y_ROT;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ public static io.papermc.paper.entity.TeleportFlag.Relative toApiRelativeFlag(net.minecraft.world.entity.RelativeMovement nmsFlag) {
|
||||
+ return switch (nmsFlag) {
|
||||
+ case X -> io.papermc.paper.entity.TeleportFlag.Relative.X;
|
||||
+ case Y -> io.papermc.paper.entity.TeleportFlag.Relative.Y;
|
||||
+ case Z -> io.papermc.paper.entity.TeleportFlag.Relative.Z;
|
||||
+ case X_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.PITCH;
|
||||
+ case Y_ROT -> io.papermc.paper.entity.TeleportFlag.Relative.YAW;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean teleport(Location location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) {
|
||||
+ java.util.Set<net.minecraft.world.entity.RelativeMovement> relativeArguments;
|
||||
+ java.util.Set<io.papermc.paper.entity.TeleportFlag> allFlags;
|
||||
+ if (flags.length == 0) {
|
||||
+ relativeArguments = Set.of();
|
||||
+ allFlags = Set.of();
|
||||
+ } else {
|
||||
+ relativeArguments = java.util.EnumSet.noneOf(net.minecraft.world.entity.RelativeMovement.class);
|
||||
+ allFlags = new HashSet<>();
|
||||
+ for (io.papermc.paper.entity.TeleportFlag flag : flags) {
|
||||
+ if (flag instanceof io.papermc.paper.entity.TeleportFlag.Relative relativeTeleportFlag) {
|
||||
+ relativeArguments.add(toNmsRelativeFlag(relativeTeleportFlag));
|
||||
+ }
|
||||
+ allFlags.add(flag);
|
||||
+ }
|
||||
+ }
|
||||
+ boolean dismount = !allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_VEHICLE);
|
||||
+ boolean ignorePassengers = allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_PASSENGERS);
|
||||
+ // Paper end - Teleport API
|
||||
Preconditions.checkArgument(location != null, "location");
|
||||
Preconditions.checkArgument(location.getWorld() != null, "location.world");
|
||||
+ // Paper start - Teleport passenger API
|
||||
+ // Don't allow teleporting between worlds while keeping passengers
|
||||
+ if (ignorePassengers && entity.isVehicle() && location.getWorld() != this.getWorld()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Don't allow to teleport between worlds if remaining on vehicle
|
||||
+ if (!dismount && entity.isPassenger() && location.getWorld() != this.getWorld()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
location.checkFinite();
|
||||
|
||||
ServerPlayer entity = this.getHandle();
|
||||
@@ -1189,7 +1277,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return false;
|
||||
}
|
||||
|
||||
- if (entity.isVehicle()) {
|
||||
+ if (entity.isVehicle() && !ignorePassengers) { // Paper - Teleport API
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1207,7 +1295,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
// If this player is riding another entity, we must dismount before teleporting.
|
||||
- entity.stopRiding();
|
||||
+ if (dismount) entity.stopRiding(); // Paper - Teleport API
|
||||
|
||||
// SPIGOT-5509: Wakeup, similar to riding
|
||||
if (this.isSleeping()) {
|
||||
@@ -1223,13 +1311,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
ServerLevel toWorld = ((CraftWorld) to.getWorld()).getHandle();
|
||||
|
||||
// Close any foreign inventory
|
||||
- if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) {
|
||||
+ if (this.getHandle().containerMenu != this.getHandle().inventoryMenu && !allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_OPEN_INVENTORY)) { // Paper
|
||||
this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper
|
||||
}
|
||||
|
||||
// Check if the fromWorld and toWorld are the same.
|
||||
if (fromWorld == toWorld) {
|
||||
- entity.connection.teleport(to);
|
||||
+ entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), relativeArguments); // Paper - Teleport API
|
||||
} else {
|
||||
// The respawn reason should never be used if the passed location is non null.
|
||||
server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper
|
32
patches/server/0824-Add-EntityPortalReadyEvent.patch
Normal file
32
patches/server/0824-Add-EntityPortalReadyEvent.patch
Normal file
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 12 May 2021 04:30:42 -0700
|
||||
Subject: [PATCH] Add EntityPortalReadyEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 56060d5d962a1827873d3b2311f30b766c64575f..2a13d5f4cf86b4ae5e5cf2d0602fbcd275b1c080 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2922,6 +2922,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
|
||||
this.level().getProfiler().push("portal");
|
||||
this.portalTime = i;
|
||||
+ // Paper start
|
||||
+ io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER);
|
||||
+ if (!event.callEvent()) {
|
||||
+ this.portalTime = 0;
|
||||
+ } else {
|
||||
+ worldserver1 = event.getTargetWorld() == null ? null : ((CraftWorld) event.getTargetWorld()).getHandle();
|
||||
+ // Paper end
|
||||
this.setPortalCooldown();
|
||||
// CraftBukkit start
|
||||
if (this instanceof ServerPlayer) {
|
||||
@@ -2929,6 +2936,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
} else {
|
||||
this.changeDimension(worldserver1);
|
||||
}
|
||||
+ } // Paper
|
||||
// CraftBukkit end
|
||||
this.level().getProfiler().pop();
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 10 Jul 2022 14:13:22 -0700
|
||||
Subject: [PATCH] Don't use level random in entity constructors
|
||||
|
||||
Paper makes the entity random thread-safe
|
||||
and constructing an entity off the main thread
|
||||
should be supported. Some entities (for whatever
|
||||
reason) use the level's random in some places.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index e06d5eea4bc81be264a1f5d5fad2d4548c4ae8d2..55026e1731e41b4e3e4c6a8fef5d96a32051a556 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -1029,7 +1029,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
BeeGoToHiveGoal() {
|
||||
super();
|
||||
- this.travellingTicks = Bee.this.level().random.nextInt(10);
|
||||
+ this.travellingTicks = Bee.this./* level(). */random.nextInt(10); // Paper - use entity random
|
||||
this.blacklistedTargets = Lists.newArrayList();
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
@@ -1146,7 +1146,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
BeeGoToKnownFlowerGoal() {
|
||||
super();
|
||||
- this.travellingTicks = Bee.this.level().random.nextInt(10);
|
||||
+ this.travellingTicks = Bee.this./* level(). */random.nextInt(10); // Paper - use entity random
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
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 6b3a17e6717b8c03c5bd674771b29e4becd42c71..22d29a2e58c5615dcee04ba68752fb76489c8a28 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -64,7 +64,12 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
}
|
||||
|
||||
public ItemEntity(Level world, double x, double y, double z, ItemStack stack) {
|
||||
- this(world, x, y, z, stack, world.random.nextDouble() * 0.2D - 0.1D, 0.2D, world.random.nextDouble() * 0.2D - 0.1D);
|
||||
+ // Paper start - don't use world random in entity constructor
|
||||
+ this(EntityType.ITEM, world);
|
||||
+ this.setPos(x, y, z);
|
||||
+ this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D);
|
||||
+ this.setItem(stack);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public ItemEntity(Level world, double x, double y, double z, ItemStack stack, double velocityX, double velocityY, double velocityZ) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index 57f9bf73ee14bc8811d0192543caf2b02e890ee0..4ce3e69970dd9eb251d0538a2d233ca30e9e5e47 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -36,7 +36,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
||||
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
|
||||
this(EntityType.TNT, world);
|
||||
this.setPos(x, y, z);
|
||||
- double d3 = world.random.nextDouble() * 6.2831854820251465D;
|
||||
+ double d3 = this.random.nextDouble() * 6.2831854820251465D; // Paper - don't use world random in entity constructor
|
||||
|
||||
this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
|
||||
this.setFuse(80);
|
|
@ -0,0 +1,91 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Sat, 25 Jun 2022 19:45:20 -0400
|
||||
Subject: [PATCH] Send block entities after destroy prediction
|
||||
|
||||
Minecraft's prediction system does not handle block entities, so if we are manually sending block entities during
|
||||
block breaking we need to set it after the prediction is finished. This fixes block entities not showing when cancelling the BlockBreakEvent.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index f968dee743f58fe71935097701866800c0f382a1..73e2948210139e40e234b5e2107f9008f3094964 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -62,6 +62,8 @@ public class ServerPlayerGameMode {
|
||||
private BlockPos delayedDestroyPos;
|
||||
private int delayedTickStart;
|
||||
private int lastSentState;
|
||||
+ public boolean captureSentBlockEntities = false; // Paper
|
||||
+ public boolean capturedBlockEntity = false; // Paper
|
||||
|
||||
public ServerPlayerGameMode(ServerPlayer player) {
|
||||
this.gameModeForPlayer = GameType.DEFAULT_MODE;
|
||||
@@ -188,10 +190,7 @@ public class ServerPlayerGameMode {
|
||||
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
|
||||
this.debugLogging(pos, false, sequence, "may not interact");
|
||||
// Update any tile entity data for this block
|
||||
- BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
- if (tileentity != null) {
|
||||
- this.player.connection.send(tileentity.getUpdatePacket());
|
||||
- }
|
||||
+ capturedBlockEntity = true; // Paper - send block entity after predicting
|
||||
// CraftBukkit end
|
||||
return;
|
||||
}
|
||||
@@ -207,10 +206,7 @@ public class ServerPlayerGameMode {
|
||||
// Paper end
|
||||
this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
||||
// Update any tile entity data for this block
|
||||
- BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
- if (tileentity != null) {
|
||||
- this.player.connection.send(tileentity.getUpdatePacket());
|
||||
- }
|
||||
+ capturedBlockEntity = true; // Paper - send block entity after predicting
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -392,10 +388,12 @@ public class ServerPlayerGameMode {
|
||||
}
|
||||
|
||||
// Update any tile entity data for this block
|
||||
+ if (!captureSentBlockEntities) { // Paper - Toggle this location for capturing as this is used for api
|
||||
BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
if (tileentity != null) {
|
||||
this.player.connection.send(tileentity.getUpdatePacket());
|
||||
}
|
||||
+ } else {capturedBlockEntity = true;} // Paper end
|
||||
return false;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 57d2bffd55db5f7833121c6781984985689c4188..58fdede705e55801c4dff11db1b9d29b2430c19c 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1737,8 +1737,28 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
return;
|
||||
}
|
||||
// Paper end - Don't allow digging in unloaded chunks
|
||||
+ // Paper start - send block entities after prediction
|
||||
+ this.player.gameMode.capturedBlockEntity = false;
|
||||
+ this.player.gameMode.captureSentBlockEntities = true;
|
||||
+ // Paper end - send block entities after prediction
|
||||
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxBuildHeight(), packet.getSequence());
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
+ // Paper start - send block entities after prediction
|
||||
+ this.player.gameMode.captureSentBlockEntities = false;
|
||||
+ // If a block entity was modified speedup the block change ack to avoid the block entity
|
||||
+ // being overriden.
|
||||
+ if (this.player.gameMode.capturedBlockEntity) {
|
||||
+ // manually tick
|
||||
+ this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo));
|
||||
+ this.player.connection.ackBlockChangesUpTo = -1;
|
||||
+
|
||||
+ this.player.gameMode.capturedBlockEntity = false;
|
||||
+ BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - send block entities after prediction
|
||||
return;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid player action");
|
|
@ -0,0 +1,96 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Fri, 29 Jul 2022 12:35:19 -0400
|
||||
Subject: [PATCH] Warn on plugins accessing faraway chunks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 7d39cdfec62884a8ee98af3ca71aa3c9908cc3d8..aa5879aef6e6e517ead13a422fed7674f715c994 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -440,7 +440,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
}
|
||||
|
||||
private static boolean isInWorldBoundsHorizontal(BlockPos pos) {
|
||||
- return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000;
|
||||
+ return pos.getX() >= -30000000 && pos.getZ() >= -30000000 && pos.getX() < 30000000 && pos.getZ() < 30000000; // Dif on change
|
||||
}
|
||||
|
||||
private static boolean isOutsideSpawnableHeight(int y) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 2ec9d65ce7c9947021cf95f0827c3bc1cc2166ab..c7e6e73507ab198224de1b549f7c71887341c6a6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -310,9 +310,24 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
public boolean setSpawnLocation(int x, int y, int z) {
|
||||
return this.setSpawnLocation(x, y, z, 0.0F);
|
||||
}
|
||||
+ // Paper start
|
||||
+ private static void warnUnsafeChunk(String reason, int x, int z) {
|
||||
+ // if any chunk coord is outside of 30 million blocks
|
||||
+ if (x > 1875000 || z > 1875000 || x < -1875000 || z < -1875000) {
|
||||
+ Plugin plugin = io.papermc.paper.util.StackWalkerUtil.getFirstPluginCaller();
|
||||
+ if (plugin != null) {
|
||||
+ plugin.getLogger().warning("Plugin is %s at (%s, %s), this might cause issues.".formatted(reason, x, z));
|
||||
+ }
|
||||
+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) {
|
||||
+ io.papermc.paper.util.TraceUtil.dumpTraceForThread("Dangerous chunk retrieval");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(int x, int z) {
|
||||
+ warnUnsafeChunk("getting a faraway chunk", x, z); // Paper
|
||||
// Paper start - add ticket to hold chunk for a little while longer if plugin accesses it
|
||||
net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
||||
if (chunk == null) {
|
||||
@@ -427,6 +442,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("chunk regenerate"); // Spigot
|
||||
+ warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper
|
||||
// Paper start - implement regenerateChunk method
|
||||
final ServerLevel serverLevel = this.world;
|
||||
final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource();
|
||||
@@ -514,6 +530,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@Override
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
||||
+ warnUnsafeChunk("loading a faraway chunk", x, z); // Paper
|
||||
// Paper start - Optimize this method
|
||||
ChunkPos chunkPos = new ChunkPos(x, z);
|
||||
ChunkAccess immediate = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); // Paper
|
||||
@@ -577,6 +594,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean addPluginChunkTicket(int x, int z, Plugin plugin) {
|
||||
+ warnUnsafeChunk("adding a faraway chunk ticket", x, z); // Paper
|
||||
Preconditions.checkArgument(plugin != null, "null plugin");
|
||||
Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled");
|
||||
|
||||
@@ -658,6 +676,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public void setChunkForceLoaded(int x, int z, boolean forced) {
|
||||
+ warnUnsafeChunk("forceloading a faraway chunk", x, z); // Paper
|
||||
this.getHandle().setChunkForced(x, z, forced);
|
||||
}
|
||||
|
||||
@@ -970,6 +989,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
|
||||
+ warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper
|
||||
// Transient load for this tick
|
||||
return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
|
||||
}
|
||||
@@ -2342,6 +2362,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
// Spigot end
|
||||
// Paper start
|
||||
public java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent) {
|
||||
+ warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
||||
if (immediate != null) {
|
|
@ -0,0 +1,33 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Sat, 30 Jul 2022 11:23:05 -0400
|
||||
Subject: [PATCH] Custom Chat Completion Suggestions API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 17a4390514b72481de6dc0676eb8130428fabf89..ba93dbec8b22809133335e975f64caa85df30c9b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -610,6 +610,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
this.getHandle().getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), level, false);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void addAdditionalChatCompletions(@NotNull Collection<String> completions) {
|
||||
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket(
|
||||
+ net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.ADD,
|
||||
+ new ArrayList<>(completions)
|
||||
+ ));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void removeAdditionalChatCompletions(@NotNull Collection<String> completions) {
|
||||
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket(
|
||||
+ net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.REMOVE,
|
||||
+ new ArrayList<>(completions)
|
||||
+ ));
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
|
@ -0,0 +1,71 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Thu, 21 Jul 2022 12:07:54 -0400
|
||||
Subject: [PATCH] Add and fix missing BlockFadeEvents
|
||||
|
||||
Beyond calling the BlockFadeEvent in more places, this patch also aims
|
||||
to pass the proper replacement state to the event, specifically for
|
||||
potentially waterlogged block states fading.
|
||||
|
||||
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
||||
index 834c5e3fbff3819f3f72e95a1072d9b9e57f25b3..294d22b6b27e96b59c77527efcfefa9410b756e4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
||||
@@ -85,6 +85,11 @@ public class FrogspawnBlock extends Block {
|
||||
}
|
||||
|
||||
private void hatchFrogspawn(ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
+ // Paper start - Call BlockFadeEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.defaultBlockState()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.destroyBlock(world, pos);
|
||||
world.playSound((Player)null, pos, SoundEvents.FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
this.spawnTadpoles(world, pos, random);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java b/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java
|
||||
index f99082c58743e8b73e263655dbebc34e904c45bc..e9358522e526505d5c200e19b193bbcf5ee10826 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ScaffoldingBlock.java
|
||||
@@ -96,7 +96,7 @@ public class ScaffoldingBlock extends Block implements SimpleWaterloggedBlock {
|
||||
int i = ScaffoldingBlock.getDistance(world, pos);
|
||||
BlockState iblockdata1 = (BlockState) ((BlockState) state.setValue(ScaffoldingBlock.DISTANCE, i)).setValue(ScaffoldingBlock.BOTTOM, this.isBottom(world, pos, i));
|
||||
|
||||
- if ((Integer) iblockdata1.getValue(ScaffoldingBlock.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit - BlockFadeEvent
|
||||
+ if ((Integer) iblockdata1.getValue(ScaffoldingBlock.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, iblockdata1.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit - BlockFadeEvent // Paper - fix wrong block state
|
||||
if ((Integer) state.getValue(ScaffoldingBlock.DISTANCE) == 7) {
|
||||
FallingBlockEntity.fall(world, pos, iblockdata1);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
|
||||
index 1e115adfcfee518667559100d04050f5e71c8a23..8aaa3cb2248a02b5ee25251cc837a145edd34341 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
|
||||
@@ -54,12 +54,26 @@ public class SnifferEggBlock extends Block {
|
||||
return this.getHatchLevel(state) == 2;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private void rescheduleTick(ServerLevel world, BlockPos pos) {
|
||||
+ int baseDelay = hatchBoost(world, pos) ? BOOSTED_HATCH_TIME_TICKS : REGULAR_HATCH_TIME_TICKS;
|
||||
+ world.scheduleTick(pos, this, (baseDelay / 3) + world.random.nextInt(RANDOM_HATCH_OFFSET_TICKS));
|
||||
+ // reschedule to avoid being stuck here and behave like the other calls (see #onPlace)
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
if (!this.isReadyToHatch(state)) {
|
||||
world.playSound((Player)null, pos, SoundEvents.SNIFFER_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
||||
world.setBlock(pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2);
|
||||
} else {
|
||||
+ // Paper start - Call BlockFadeEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, state.getFluidState().createLegacyBlock()).isCancelled()) {
|
||||
+ rescheduleTick(world, pos);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
world.playSound((Player)null, pos, SoundEvents.SNIFFER_EGG_HATCH, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
||||
world.destroyBlock(pos, false);
|
||||
Sniffer sniffer = EntityType.SNIFFER.create(world);
|
47
patches/server/0830-Collision-API.patch
Normal file
47
patches/server/0830-Collision-API.patch
Normal file
|
@ -0,0 +1,47 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Wed, 6 Oct 2021 20:10:44 -0400
|
||||
Subject: [PATCH] Collision API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
index 5be114bc70c6fdbcb7d804e7558a5172c4461b96..3b9d7f92f4e47da2d7eb1e9cb9e996ee36b57e4c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
@@ -1020,5 +1020,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
|
||||
return this.getHandle().clip(new net.minecraft.world.level.ClipContext(start, end, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, null)).getType() == net.minecraft.world.phys.HitResult.Type.MISS;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasCollisionsIn(@org.jetbrains.annotations.NotNull org.bukkit.util.BoundingBox boundingBox) {
|
||||
+ net.minecraft.world.phys.AABB aabb = new AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ(), false);
|
||||
+
|
||||
+ return !this.getHandle().noCollision(aabb);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index b19665fd570c86274caef62dc3e365f0e6a7ca8e..ba0c1be4f5303bd6a33fd27f4e8c9910a8325695 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1419,4 +1419,19 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
return getHandle().isInPowderSnow || getHandle().wasInPowderSnow; // depending on the location in the entity "tick" either could be needed.
|
||||
}
|
||||
// Paper end
|
||||
+ // Paper Start - Collision API
|
||||
+ @Override
|
||||
+ public boolean collidesAt(@org.jetbrains.annotations.NotNull Location location) {
|
||||
+ net.minecraft.world.phys.AABB aabb = this.getHandle().getBoundingBoxAt(location.getX(), location.getY(), location.getZ());
|
||||
+
|
||||
+ return !this.getHandle().level().noCollision(this.getHandle(), aabb);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean wouldCollideUsing(@org.jetbrains.annotations.NotNull BoundingBox boundingBox) {
|
||||
+ net.minecraft.world.phys.AABB aabb = new AABB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ(), false);
|
||||
+
|
||||
+ return !this.getHandle().level().noCollision(this.getHandle(), aabb);
|
||||
+ }
|
||||
+ // Paper End - Collision API
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: chickeneer <emcchickeneer@gmail.com>
|
||||
Date: Mon, 1 Aug 2022 20:13:02 -0500
|
||||
Subject: [PATCH] Fix suggest command message for brigadier syntax exceptions
|
||||
|
||||
This is a bug accidentally introduced in upstream CB
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index c704761bd5dae98f7c77780a4f7058b737fdb664..3eec879bf3975636739b2491cc05b8177032d16d 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -348,7 +348,7 @@ public class Commands {
|
||||
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
|
||||
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
|
||||
MutableComponent ichatmutablecomponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((chatmodifier) -> {
|
||||
- return chatmodifier.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, label)); // CraftBukkit
|
||||
+ return chatmodifier.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label)); // CraftBukkit // Paper
|
||||
});
|
||||
|
||||
if (j > 10) {
|
48
patches/server/0832-Block-Ticking-API.patch
Normal file
48
patches/server/0832-Block-Ticking-API.patch
Normal file
|
@ -0,0 +1,48 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Sun, 26 Dec 2021 13:23:46 -0500
|
||||
Subject: [PATCH] Block Ticking API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index df104b1f7753d98318a5cc511c6e0e1c68e5c277..f3ac362b7b65a5273ff5fdad1d8065c5f654a53a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -735,5 +735,21 @@ public class CraftBlock implements Block {
|
||||
public boolean isValidTool(ItemStack itemStack) {
|
||||
return getDrops(itemStack).size() != 0;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void tick() {
|
||||
+ net.minecraft.world.level.block.state.BlockState blockData = this.getNMS();
|
||||
+ net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld();
|
||||
+
|
||||
+ blockData.getBlock().tick(blockData, level, this.position, level.random);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void randomTick() {
|
||||
+ net.minecraft.world.level.block.state.BlockState blockData = this.getNMS();
|
||||
+ net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld();
|
||||
+
|
||||
+ blockData.getBlock().randomTick(blockData, level, this.position, level.random);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
index f4e37764f714419a614a7e40718924788a204d28..86fb50f946ff57d66c561ba0ee6f1116f63479fb 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
@@ -703,4 +703,11 @@ public class CraftBlockData implements BlockData {
|
||||
return speed;
|
||||
}
|
||||
// Paper end - destroy speed API
|
||||
+
|
||||
+ // Paper start - Block tick API
|
||||
+ @Override
|
||||
+ public boolean isRandomlyTicked() {
|
||||
+ return this.state.isRandomlyTicking();
|
||||
+ }
|
||||
+ // Paper end - Block tick API
|
||||
}
|
227
patches/server/0833-Add-Velocity-IP-Forwarding-Support.patch
Normal file
227
patches/server/0833-Add-Velocity-IP-Forwarding-Support.patch
Normal file
|
@ -0,0 +1,227 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 8 Oct 2018 14:36:14 -0400
|
||||
Subject: [PATCH] Add Velocity IP Forwarding Support
|
||||
|
||||
While Velocity supports BungeeCord-style IP forwarding, it is not secure. Users
|
||||
have a lot of problems setting up firewalls or setting up plugins like IPWhitelist.
|
||||
Further, the BungeeCord IP forwarding protocol still retains essentially its original
|
||||
form, when there is brand new support for custom login plugin messages in 1.13.
|
||||
|
||||
Velocity's modern IP forwarding uses an HMAC-SHA256 code to ensure authenticity
|
||||
of messages, is packed into a binary format that is smaller than BungeeCord's
|
||||
forwarding, and is integrated into the Minecraft login process by using the 1.13
|
||||
login plugin message packet.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c4934979b1ed85bfc4f8d9e6f8848b2beaad95c3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java
|
||||
@@ -0,0 +1,75 @@
|
||||
+package com.destroystokyo.paper.proxy;
|
||||
+
|
||||
+import io.papermc.paper.configuration.GlobalConfiguration;
|
||||
+import com.google.common.net.InetAddresses;
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import com.mojang.authlib.properties.Property;
|
||||
+import java.net.InetAddress;
|
||||
+import java.security.InvalidKeyException;
|
||||
+import java.security.MessageDigest;
|
||||
+import java.security.NoSuchAlgorithmException;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+import javax.crypto.Mac;
|
||||
+import javax.crypto.spec.SecretKeySpec;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.world.entity.player.ProfilePublicKey;
|
||||
+
|
||||
+public class VelocityProxy {
|
||||
+ private static final int SUPPORTED_FORWARDING_VERSION = 1;
|
||||
+ public static final int MODERN_FORWARDING_WITH_KEY = 2;
|
||||
+ public static final int MODERN_FORWARDING_WITH_KEY_V2 = 3;
|
||||
+ public static final int MODERN_LAZY_SESSION = 4;
|
||||
+ public static final byte MAX_SUPPORTED_FORWARDING_VERSION = MODERN_LAZY_SESSION;
|
||||
+ public static final ResourceLocation PLAYER_INFO_CHANNEL = new ResourceLocation("velocity", "player_info");
|
||||
+
|
||||
+ public static boolean checkIntegrity(final FriendlyByteBuf buf) {
|
||||
+ final byte[] signature = new byte[32];
|
||||
+ buf.readBytes(signature);
|
||||
+
|
||||
+ final byte[] data = new byte[buf.readableBytes()];
|
||||
+ buf.getBytes(buf.readerIndex(), data);
|
||||
+
|
||||
+ try {
|
||||
+ final Mac mac = Mac.getInstance("HmacSHA256");
|
||||
+ mac.init(new SecretKeySpec(GlobalConfiguration.get().proxies.velocity.secret.getBytes(java.nio.charset.StandardCharsets.UTF_8), "HmacSHA256"));
|
||||
+ final byte[] mySignature = mac.doFinal(data);
|
||||
+ if (!MessageDigest.isEqual(signature, mySignature)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ } catch (final InvalidKeyException | NoSuchAlgorithmException e) {
|
||||
+ throw new AssertionError(e);
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ public static InetAddress readAddress(final FriendlyByteBuf buf) {
|
||||
+ return InetAddresses.forString(buf.readUtf(Short.MAX_VALUE));
|
||||
+ }
|
||||
+
|
||||
+ public static GameProfile createProfile(final FriendlyByteBuf buf) {
|
||||
+ final GameProfile profile = new GameProfile(buf.readUUID(), buf.readUtf(16));
|
||||
+ readProperties(buf, profile);
|
||||
+ return profile;
|
||||
+ }
|
||||
+
|
||||
+ private static void readProperties(final FriendlyByteBuf buf, final GameProfile profile) {
|
||||
+ final int properties = buf.readVarInt();
|
||||
+ for (int i1 = 0; i1 < properties; i1++) {
|
||||
+ final String name = buf.readUtf(Short.MAX_VALUE);
|
||||
+ final String value = buf.readUtf(Short.MAX_VALUE);
|
||||
+ final String signature = buf.readBoolean() ? buf.readUtf(Short.MAX_VALUE) : null;
|
||||
+ profile.getProperties().put(name, new Property(name, value, signature));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static ProfilePublicKey.Data readForwardedKey(FriendlyByteBuf buf) {
|
||||
+ return new ProfilePublicKey.Data(buf);
|
||||
+ }
|
||||
+
|
||||
+ public static UUID readSignerUuidOrElse(FriendlyByteBuf buf, UUID orElse) {
|
||||
+ return buf.readBoolean() ? buf.readUUID() : orElse;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index f1e5798c47ee6c8d8b9d599fa503e8cefe18aa19..c1882185ad93315925ca97a085482197f6ae9f4a 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -274,13 +274,20 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start
|
||||
+ boolean usingProxy = org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled;
|
||||
+ String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord";
|
||||
+ String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/";
|
||||
+ // Paper end
|
||||
if (!this.usesAuthentication()) {
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
// Spigot start
|
||||
- if (org.spigotmc.SpigotConfig.bungee) {
|
||||
- DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.");
|
||||
- DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.");
|
||||
+ // Paper start
|
||||
+ if (usingProxy) {
|
||||
+ DedicatedServer.LOGGER.warn("Whilst this makes it possible to use " + proxyFlavor + ", unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.");
|
||||
+ DedicatedServer.LOGGER.warn("Please see " + proxyLink + " for further information.");
|
||||
+ // Paper end
|
||||
} else {
|
||||
DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index ced150fa9160310408f57e89d115de740097eaf5..5012405cc3dd98c05d271ee4003968717f93f3e9 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -62,6 +62,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
private final String serverId;
|
||||
private ServerPlayer player; // CraftBukkit
|
||||
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
||||
+ private int velocityLoginMessageId = -1; // Paper - Velocity support
|
||||
|
||||
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) {
|
||||
this.state = ServerLoginPacketListenerImpl.State.HELLO;
|
||||
@@ -175,6 +176,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
this.state = ServerLoginPacketListenerImpl.State.KEY;
|
||||
this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge));
|
||||
} else {
|
||||
+ // Paper start - Velocity support
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) {
|
||||
+ this.velocityLoginMessageId = java.util.concurrent.ThreadLocalRandom.current().nextInt();
|
||||
+ net.minecraft.network.FriendlyByteBuf buf = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.buffer());
|
||||
+ buf.writeByte(com.destroystokyo.paper.proxy.VelocityProxy.MAX_SUPPORTED_FORWARDING_VERSION);
|
||||
+ net.minecraft.network.protocol.login.ClientboundCustomQueryPacket packet1 = new net.minecraft.network.protocol.login.ClientboundCustomQueryPacket(this.velocityLoginMessageId, com.destroystokyo.paper.proxy.VelocityProxy.PLAYER_INFO_CHANNEL, buf);
|
||||
+ this.connection.send(packet1);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// Spigot start
|
||||
// Paper start - Cache authenticator threads
|
||||
authenticatorPool.execute(new Runnable() {
|
||||
@@ -318,6 +329,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
public class LoginHandler {
|
||||
|
||||
public void fireEvents(GameProfile gameprofile) throws Exception {
|
||||
+ // Paper start - Velocity support
|
||||
+ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) {
|
||||
+ disconnect("This server requires you to connect with Velocity.");
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
String playerName = gameprofile.getName();
|
||||
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
|
||||
java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.channel.remoteAddress()).getAddress(); // Paper
|
||||
@@ -367,6 +384,47 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
|
||||
@Override
|
||||
public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket packet) {
|
||||
+ // Paper start - Velocity support
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && packet.getTransactionId() == this.velocityLoginMessageId) {
|
||||
+ net.minecraft.network.FriendlyByteBuf buf = packet.getData();
|
||||
+ if (buf == null) {
|
||||
+ this.disconnect("This server requires you to connect with Velocity.");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!com.destroystokyo.paper.proxy.VelocityProxy.checkIntegrity(buf)) {
|
||||
+ this.disconnect("Unable to verify player details");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ int version = buf.readVarInt();
|
||||
+ if (version > com.destroystokyo.paper.proxy.VelocityProxy.MAX_SUPPORTED_FORWARDING_VERSION) {
|
||||
+ throw new IllegalStateException("Unsupported forwarding version " + version + ", wanted upto " + com.destroystokyo.paper.proxy.VelocityProxy.MAX_SUPPORTED_FORWARDING_VERSION);
|
||||
+ }
|
||||
+
|
||||
+ java.net.SocketAddress listening = this.connection.getRemoteAddress();
|
||||
+ int port = 0;
|
||||
+ if (listening instanceof java.net.InetSocketAddress) {
|
||||
+ port = ((java.net.InetSocketAddress) listening).getPort();
|
||||
+ }
|
||||
+ this.connection.address = new java.net.InetSocketAddress(com.destroystokyo.paper.proxy.VelocityProxy.readAddress(buf), port);
|
||||
+
|
||||
+ this.authenticatedProfile = com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf);
|
||||
+
|
||||
+ //TODO Update handling for lazy sessions, might not even have to do anything?
|
||||
+
|
||||
+ // Proceed with login
|
||||
+ authenticatorPool.execute(() -> {
|
||||
+ try {
|
||||
+ new LoginHandler().fireEvents(this.authenticatedProfile);
|
||||
+ } catch (Exception ex) {
|
||||
+ disconnect("Failed to verify username!");
|
||||
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + this.authenticatedProfile.getName(), ex);
|
||||
+ }
|
||||
+ });
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.disconnect(ServerLoginPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 097ceaa948469f6b63362dfa00525cd0fd01d907..615baf99dd8680b97aa1f03d4a961e15bcdd832b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -806,7 +806,7 @@ public final class CraftServer implements Server {
|
||||
@Override
|
||||
public long getConnectionThrottle() {
|
||||
// Spigot Start - Automatically set connection throttle for bungee configurations
|
||||
- if (org.spigotmc.SpigotConfig.bungee) {
|
||||
+ if (org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { // Paper - Velocity support
|
||||
return -1;
|
||||
} else {
|
||||
return this.configuration.getInt("settings.connection-throttle");
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Thu, 11 Aug 2022 14:37:33 +0100
|
||||
Subject: [PATCH] Use thread safe random in ServerLoginPacketListenerImpl
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 5012405cc3dd98c05d271ee4003968717f93f3e9..dc8e2d31cf90d76e64d0b6a4783040df91ae2568 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -50,6 +50,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||
private static final Component DISCONNECT_UNEXPECTED_QUERY = Component.translatable("multiplayer.disconnect.unexpected_query_response");
|
||||
+ private static final RandomSource RANDOM = new org.bukkit.craftbukkit.util.RandomSourceWrapper(new java.util.Random()); // Paper - This is called across threads, make safe
|
||||
private final byte[] challenge;
|
||||
final MinecraftServer server;
|
||||
public final Connection connection;
|
31
patches/server/0835-Add-NamespacedKey-biome-methods.patch
Normal file
31
patches/server/0835-Add-NamespacedKey-biome-methods.patch
Normal file
|
@ -0,0 +1,31 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Josh Roy <10731363+JRoy@users.noreply.github.com>
|
||||
Date: Sun, 14 Aug 2022 12:23:11 -0400
|
||||
Subject: [PATCH] Add NamespacedKey biome methods
|
||||
|
||||
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index e169c16626e967c30c6f9a324a40550adf5476dd..58f2eaf81f24f1548bdc9f46528cb4b94b18de69 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -610,6 +610,19 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
Preconditions.checkArgument(material.isBlock(), material + " is not a block");
|
||||
return getBlock(material).hasCollision;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.NamespacedKey getBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z) {
|
||||
+ org.bukkit.craftbukkit.CraftRegionAccessor cra = (org.bukkit.craftbukkit.CraftRegionAccessor) accessor;
|
||||
+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(cra.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getKey(cra.getHandle().getBiome(new net.minecraft.core.BlockPos(x, y, z)).value()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBiomeKey(org.bukkit.RegionAccessor accessor, int x, int y, int z, org.bukkit.NamespacedKey biomeKey) {
|
||||
+ org.bukkit.craftbukkit.CraftRegionAccessor cra = (org.bukkit.craftbukkit.CraftRegionAccessor) accessor;
|
||||
+ net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeBase = cra.getHandle().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getHolderOrThrow(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.BIOME, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(biomeKey)));
|
||||
+ cra.setBiome(x, y, z, biomeBase);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
|
@ -0,0 +1,67 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= <josemmo@pm.me>
|
||||
Date: Sat, 5 Jun 2021 13:45:15 +0200
|
||||
Subject: [PATCH] Fix plugin loggers on server shutdown
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/log/CustomLogManager.java b/src/main/java/io/papermc/paper/log/CustomLogManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c1d3bac79bb8b4796c013ff4472f75dcd79602dc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/log/CustomLogManager.java
|
||||
@@ -0,0 +1,26 @@
|
||||
+package io.papermc.paper.log;
|
||||
+
|
||||
+import java.util.logging.LogManager;
|
||||
+
|
||||
+public class CustomLogManager extends LogManager {
|
||||
+ private static CustomLogManager instance;
|
||||
+
|
||||
+ public CustomLogManager() {
|
||||
+ instance = this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void reset() {
|
||||
+ // Ignore calls to this method
|
||||
+ }
|
||||
+
|
||||
+ private void superReset() {
|
||||
+ super.reset();
|
||||
+ }
|
||||
+
|
||||
+ public static void forceReset() {
|
||||
+ if (instance != null) {
|
||||
+ instance.superReset();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index ff70a2d03ffb85b64829e15bfdfd7a2f35dc9323..bf9e396505c5004b0fb640837b41a4885bcab08e 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -998,6 +998,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
||||
} catch (Exception e) {
|
||||
}
|
||||
+ io.papermc.paper.log.CustomLogManager.forceReset(); // Paper - Reset loggers after shutdown
|
||||
this.onServerExit();
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 224be855fd16b37c8766c3c07b81905d50d5518d..6f816ec287f35dca6e196f86d016a2c28617bab6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -18,6 +18,12 @@ public class Main {
|
||||
public static boolean useJline = true;
|
||||
public static boolean useConsole = true;
|
||||
|
||||
+ // Paper start - Hijack log manager to ensure logging on shutdown
|
||||
+ static {
|
||||
+ System.setProperty("java.util.logging.manager", "io.papermc.paper.log.CustomLogManager");
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static void main(String[] args) {
|
||||
// Paper start
|
||||
final String warnWhenLegacyFormattingDetected = String.join(".", "net", "kyori", "adventure", "text", "warnWhenLegacyFormattingDetected");
|
|
@ -0,0 +1,74 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MWHunter <s0521458@student.rockvalleycollege.edu>
|
||||
Date: Wed, 24 Aug 2022 09:54:11 -0400
|
||||
Subject: [PATCH] Stop large look changes from crashing the server
|
||||
|
||||
Co-authored-by: Jaren Knodel <Jaren@Knodel.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index a3fc80627627a4ad991ec8e674ac528fd69580df..c3b9d590497bf96fd0df4c00f863ab64ec91115e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3062,37 +3062,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("rangeChecks");
|
||||
|
||||
- while (this.getYRot() - this.yRotO < -180.0F) {
|
||||
- this.yRotO -= 360.0F;
|
||||
- }
|
||||
-
|
||||
- while (this.getYRot() - this.yRotO >= 180.0F) {
|
||||
- this.yRotO += 360.0F;
|
||||
- }
|
||||
+ // Paper start - stop large pitch and yaw changes from crashing the server
|
||||
+ this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
|
||||
|
||||
- while (this.yBodyRot - this.yBodyRotO < -180.0F) {
|
||||
- this.yBodyRotO -= 360.0F;
|
||||
- }
|
||||
+ this.yBodyRotO += Math.round((this.yBodyRot - this.yBodyRotO) / 360.0F) * 360.0F;
|
||||
|
||||
- while (this.yBodyRot - this.yBodyRotO >= 180.0F) {
|
||||
- this.yBodyRotO += 360.0F;
|
||||
- }
|
||||
-
|
||||
- while (this.getXRot() - this.xRotO < -180.0F) {
|
||||
- this.xRotO -= 360.0F;
|
||||
- }
|
||||
+ this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F;
|
||||
|
||||
- while (this.getXRot() - this.xRotO >= 180.0F) {
|
||||
- this.xRotO += 360.0F;
|
||||
- }
|
||||
-
|
||||
- while (this.yHeadRot - this.yHeadRotO < -180.0F) {
|
||||
- this.yHeadRotO -= 360.0F;
|
||||
- }
|
||||
-
|
||||
- while (this.yHeadRot - this.yHeadRotO >= 180.0F) {
|
||||
- this.yHeadRotO += 360.0F;
|
||||
- }
|
||||
+ this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
|
||||
+ // Paper end
|
||||
|
||||
this.level().getProfiler().pop();
|
||||
this.animStep += f2;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index 24b549cb21926a02d736f0bbb991006b9453068d..6d7ac0c8c171834fa8da94f158258a4774d80ec4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -251,13 +251,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
}
|
||||
|
||||
protected static float lerpRotation(float prevRot, float newRot) {
|
||||
- while (newRot - prevRot < -180.0F) {
|
||||
- prevRot -= 360.0F;
|
||||
- }
|
||||
-
|
||||
- while (newRot - prevRot >= 180.0F) {
|
||||
- prevRot += 360.0F;
|
||||
- }
|
||||
+ prevRot += Math.round((newRot - prevRot) / 360.0F) * 360.0F; // Paper - stop large look changes from crashing the server
|
||||
|
||||
return Mth.lerp(0.2F, prevRot, newRot);
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Mon, 9 Aug 2021 20:45:46 -0700
|
||||
Subject: [PATCH] Fire EntityChangeBlockEvent in more places
|
||||
|
||||
Co-authored-by: ChristopheG <61288881+chrisgdt@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LightningBolt.java b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
index 80740ca823915fb2c854f13445d81964e0e971e5..255fb5e922c63130708e4bcab208b4db52a58387 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
@@ -98,7 +98,7 @@ public class LightningBolt extends Entity {
|
||||
}
|
||||
|
||||
this.powerLightningRod();
|
||||
- LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition());
|
||||
+ LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition(), this); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
this.gameEvent(GameEvent.LIGHTNING_STRIKE);
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class LightningBolt extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
- private static void clearCopperOnLightningStrike(Level world, BlockPos pos) {
|
||||
+ private static void clearCopperOnLightningStrike(Level world, BlockPos pos, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
BlockState iblockdata = world.getBlockState(pos);
|
||||
BlockPos blockposition1;
|
||||
BlockState iblockdata1;
|
||||
@@ -206,24 +206,29 @@ public class LightningBolt extends Entity {
|
||||
}
|
||||
|
||||
if (iblockdata1.getBlock() instanceof WeatheringCopper) {
|
||||
- world.setBlockAndUpdate(blockposition1, WeatheringCopper.getFirst(world.getBlockState(blockposition1)));
|
||||
+ // Paper start - call EntityChangeBlockEvent
|
||||
+ BlockState newBlock = WeatheringCopper.getFirst(world.getBlockState(blockposition1));
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1, newBlock)) {
|
||||
+ world.setBlockAndUpdate(blockposition1, newBlock);
|
||||
+ }
|
||||
+ // Paper end
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
|
||||
int i = world.random.nextInt(3) + 3;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
int k = world.random.nextInt(8) + 1;
|
||||
|
||||
- LightningBolt.randomWalkCleaningCopper(world, blockposition1, blockposition_mutableblockposition, k);
|
||||
+ LightningBolt.randomWalkCleaningCopper(world, blockposition1, blockposition_mutableblockposition, k, lightning); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- private static void randomWalkCleaningCopper(Level world, BlockPos pos, BlockPos.MutableBlockPos mutablePos, int count) {
|
||||
+ private static void randomWalkCleaningCopper(Level world, BlockPos pos, BlockPos.MutableBlockPos mutablePos, int count, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
mutablePos.set(pos);
|
||||
|
||||
for (int j = 0; j < count; ++j) {
|
||||
- Optional<BlockPos> optional = LightningBolt.randomStepCleaningCopper(world, mutablePos);
|
||||
+ Optional<BlockPos> optional = LightningBolt.randomStepCleaningCopper(world, mutablePos, lightning); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
|
||||
if (optional.isEmpty()) {
|
||||
break;
|
||||
@@ -234,7 +239,7 @@ public class LightningBolt extends Entity {
|
||||
|
||||
}
|
||||
|
||||
- private static Optional<BlockPos> randomStepCleaningCopper(Level world, BlockPos pos) {
|
||||
+ private static Optional<BlockPos> randomStepCleaningCopper(Level world, BlockPos pos, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
Iterator iterator = BlockPos.randomInCube(world.random, 10, pos, 1).iterator();
|
||||
|
||||
BlockPos blockposition1;
|
||||
@@ -251,6 +256,7 @@ public class LightningBolt extends Entity {
|
||||
|
||||
BlockPos blockposition1Final = blockposition1; // CraftBukkit - decompile error
|
||||
WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1Final, iblockdata1)) // Paper - call EntityChangeBlockEvent
|
||||
world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
|
||||
});
|
||||
world.levelEvent(3002, blockposition1, -1);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java b/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
|
||||
index 2c443b421e342ebfbdf941a431ba20560521920b..91b68ee3605afdb845405e455c869e48a7fc9aab 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
|
||||
@@ -27,6 +27,12 @@ public class TryLaySpawnOnWaterNearLand {
|
||||
BlockPos blockPos3 = blockPos2.above();
|
||||
if (world.getBlockState(blockPos3).isAir()) {
|
||||
BlockState blockState = frogSpawn.defaultBlockState();
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos3, blockState)) {
|
||||
+ isPregnant.erase(); // forgot pregnant memory
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
world.setBlock(blockPos3, blockState, 3);
|
||||
world.gameEvent(GameEvent.BLOCK_PLACE, blockPos3, GameEvent.Context.of(entity, blockState));
|
||||
world.playSound((Player)null, entity, SoundEvents.FROG_LAY_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
diff --git a/src/main/java/net/minecraft/world/item/AxeItem.java b/src/main/java/net/minecraft/world/item/AxeItem.java
|
||||
index 2f8ae1786a4c4438515c59fa56acaefdff60703d..18898e16ec42f6b694b06e09d9174b60d62450d7 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/AxeItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/AxeItem.java
|
||||
@@ -54,6 +54,11 @@ public class AxeItem extends DiggerItem {
|
||||
}
|
||||
|
||||
if (optional4.isPresent()) {
|
||||
+ // Paper start - EntityChangeBlockEvent
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, optional4.get())) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (player instanceof ServerPlayer) {
|
||||
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/EnderEyeItem.java b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
||||
index 1fddc9025a9e5079f05dd6c86f6ca43c5d51d9c3..6d45e3ebea6721b9c168fea572e9bd610eb54431 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
||||
@@ -43,6 +43,11 @@ public class EnderEyeItem extends Item {
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
BlockState iblockdata1 = (BlockState) iblockdata.setValue(EndPortalFrameBlock.HAS_EYE, true);
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), blockposition, iblockdata1)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, world, blockposition);
|
||||
world.setBlock(blockposition, iblockdata1, 2);
|
||||
diff --git a/src/main/java/net/minecraft/world/item/HoneycombItem.java b/src/main/java/net/minecraft/world/item/HoneycombItem.java
|
||||
index 5ab115834cddb9ab3209c11bd0fe657b06a02eb2..eaa263db594d5cf8758c8205ea06bbd37d56cdd4 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/HoneycombItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/HoneycombItem.java
|
||||
@@ -39,6 +39,14 @@ public class HoneycombItem extends Item implements SignApplicator {
|
||||
return getWaxed(blockState).map((state) -> {
|
||||
Player player = context.getPlayer();
|
||||
ItemStack itemStack = context.getItemInHand();
|
||||
+ // Paper start - EntityChangeBlockEvent
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, state)) {
|
||||
+ if (!player.isCreative()) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (player instanceof ServerPlayer) {
|
||||
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/PotionItem.java b/src/main/java/net/minecraft/world/item/PotionItem.java
|
||||
index 8c79ca75089e739d4899421106833e42e4e57280..88df7093c47f2a90f79a55797a04d7e4f51ed549 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/PotionItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/PotionItem.java
|
||||
@@ -107,6 +107,12 @@ public class PotionItem extends Item {
|
||||
BlockState iblockdata = world.getBlockState(blockposition);
|
||||
|
||||
if (context.getClickedFace() != Direction.DOWN && iblockdata.is(BlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(itemstack) == Potions.WATER) {
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityhuman, blockposition, Blocks.MUD.defaultBlockState())) {
|
||||
+ entityhuman.containerMenu.sendAllDataToRemote();
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
world.playSound((Player) null, blockposition, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
entityhuman.setItemInHand(context.getHand(), ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
||||
entityhuman.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
||||
index 32995cb5efdad0bc34ecacacb78cccd21220ba8d..21212462e6b415e96536a27b2c009d1562f18946 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
||||
@@ -36,20 +36,29 @@ public class ShovelItem extends DiggerItem {
|
||||
Player player = context.getPlayer();
|
||||
BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
|
||||
BlockState blockState3 = null;
|
||||
+ Runnable afterAction = null; // Paper
|
||||
if (blockState2 != null && level.getBlockState(blockPos.above()).isAir()) {
|
||||
- level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ afterAction = () -> level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
|
||||
blockState3 = blockState2;
|
||||
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
|
||||
+ afterAction = () -> { // Paper
|
||||
if (!level.isClientSide()) {
|
||||
level.levelEvent((Player)null, 1009, blockPos, 0);
|
||||
}
|
||||
|
||||
CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
|
||||
+ }; // Paper
|
||||
blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
if (blockState3 != null) {
|
||||
if (!level.isClientSide) {
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), blockPos, blockState3)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ afterAction.run();
|
||||
+ // Paper end
|
||||
level.setBlock(blockPos, blockState3, 11);
|
||||
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(player, blockState3));
|
||||
if (player != null) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||
index 4f24d5453522c68c22f15beed87e5237163c701a..38cb52d185e543c4df9eebfcd856df6fa80ba0ed 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||
@@ -231,6 +231,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(itemstack.getItem())) {
|
||||
if (i < 7 && !world.isClientSide) {
|
||||
BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack);
|
||||
+ // Paper start - handle cancelled events
|
||||
+ if (iblockdata1 == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
||||
player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
||||
@@ -254,11 +259,16 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
if (i < 7 && ComposterBlock.COMPOSTABLES.containsKey(stack.getItem())) {
|
||||
// CraftBukkit start
|
||||
double rand = world.getRandom().nextDouble();
|
||||
- BlockState iblockdata1 = ComposterBlock.addItem(user, state, DummyGeneratorAccess.INSTANCE, pos, stack, rand);
|
||||
- if (state == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(user, pos, iblockdata1)) {
|
||||
+ BlockState iblockdata1 = null; // Paper
|
||||
+ if (false && (state == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(user, pos, iblockdata1))) { // Paper - move event call into addItem
|
||||
return state;
|
||||
}
|
||||
iblockdata1 = ComposterBlock.addItem(user, state, world, pos, stack, rand);
|
||||
+ // Paper start - handle cancelled events
|
||||
+ if (iblockdata1 == null) {
|
||||
+ return state;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
|
||||
stack.shrink(1);
|
||||
@@ -299,11 +309,13 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
return iblockdata1;
|
||||
}
|
||||
|
||||
+ @Nullable // Paper
|
||||
static BlockState addItem(@Nullable Entity user, BlockState state, LevelAccessor world, BlockPos pos, ItemStack stack) {
|
||||
// CraftBukkit start
|
||||
return ComposterBlock.addItem(user, state, world, pos, stack, world.getRandom().nextDouble());
|
||||
}
|
||||
|
||||
+ @Nullable // Paper - make it nullable
|
||||
static BlockState addItem(@Nullable Entity entity, BlockState iblockdata, LevelAccessor generatoraccess, BlockPos blockposition, ItemStack itemstack, double rand) {
|
||||
// CraftBukkit end
|
||||
int i = (Integer) iblockdata.getValue(ComposterBlock.LEVEL);
|
||||
@@ -314,6 +326,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
} else {
|
||||
int j = i + 1;
|
||||
BlockState iblockdata1 = (BlockState) iblockdata.setValue(ComposterBlock.LEVEL, j);
|
||||
+ // Paper start - move the EntityChangeBlockEvent here to avoid conflict later for the compost events
|
||||
+ if (entity != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1)) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
generatoraccess.setBlock(blockposition, iblockdata1, 3);
|
||||
generatoraccess.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entity, iblockdata1));
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
||||
index 0bb9cbdceaca055860e7a2a887426c6ba3194b3e..9cfb2d3dbb06b189765293233a28b3ebd1898946 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
||||
@@ -120,7 +120,7 @@ public class DummyGeneratorAccess implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public void gameEvent(GameEvent event, Vec3 emitterPos, GameEvent.Context emitter) {
|
||||
- // Used by BlockComposter
|
||||
+ // Used by ComposterBlock
|
||||
}
|
||||
|
||||
@Override
|
45
patches/server/0839-Missing-eating-regain-reason.patch
Normal file
45
patches/server/0839-Missing-eating-regain-reason.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
||||
Date: Fri, 5 Aug 2022 12:16:51 +0200
|
||||
Subject: [PATCH] Missing eating regain reason
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
||||
index 40af8405c6f3ecc5a8168bb62607eb79862cefa6..de51ce9875e12961e6e549e87d76f492d2f19787 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
||||
@@ -387,7 +387,7 @@ public class Cat extends TamableAnimal implements VariantHolder<CatVariant> {
|
||||
if (!(item instanceof DyeItem)) {
|
||||
if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
|
||||
this.usePlayerItem(player, hand, itemstack);
|
||||
- this.heal((float) item.getFoodProperties().getNutrition());
|
||||
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index 3aa98f7c282cb4884589cb83b1546b924e66f096..faf3e31f23d71bbc345bf98d4240490ac4677843 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -384,7 +384,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
|
||||
} else {
|
||||
boolean bl = this.getHealth() < this.getMaxHealth();
|
||||
if (bl) {
|
||||
- this.heal(2.0F);
|
||||
+ this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper
|
||||
}
|
||||
|
||||
boolean bl2 = this.isTamed() && this.getAge() == 0 && this.canFallInLove();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java b/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
index 91fb62807b3c5600c83d4dc8d3fadf36e94e2133..5f61c97478f005aaaaad1b027118079db7275cf7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
@@ -196,7 +196,7 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
}
|
||||
|
||||
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
||||
- this.heal(f);
|
||||
+ this.heal(f, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper
|
||||
flag = true;
|
||||
}
|
||||
|
45
patches/server/0840-Missing-effect-cause.patch
Normal file
45
patches/server/0840-Missing-effect-cause.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
||||
Date: Tue, 16 Aug 2022 19:44:55 +0200
|
||||
Subject: [PATCH] Missing effect cause
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
index c1b95715a1ae8c89ce98848332b1e9e1c905a6f5..aa850cfaa0534d57e83f37360724da2428a48a18 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -424,7 +424,7 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
||||
player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, j, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit
|
||||
}
|
||||
|
||||
- player.removeEffect(MobEffects.DIG_SLOWDOWN);
|
||||
+ player.removeEffect(MobEffects.DIG_SLOWDOWN, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/item/HoneyBottleItem.java b/src/main/java/net/minecraft/world/item/HoneyBottleItem.java
|
||||
index c8e783014a6a09d59e85715a7fbf2a5f65201e77..5cba503c7342f66018af568be200999e14aa8d6e 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/HoneyBottleItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/HoneyBottleItem.java
|
||||
@@ -28,7 +28,7 @@ public class HoneyBottleItem extends Item {
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
- user.removeEffect(MobEffects.POISON);
|
||||
+ user.removeEffect(MobEffects.POISON, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper
|
||||
}
|
||||
|
||||
if (stack.isEmpty()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java
|
||||
index e6d4dfdbe824cc3dbbad988cdc2ca7c7f6c7a99f..5cf732818a1f1811de2a408d9165c48a61466b3e 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java
|
||||
@@ -66,7 +66,7 @@ public class SuspiciousStewItem extends Item {
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level world, LivingEntity user) {
|
||||
ItemStack itemStack = super.finishUsingItem(stack, world, user);
|
||||
listPotionEffects(itemStack, (effect) -> {
|
||||
- user.addEffect(effect.createEffectInstance());
|
||||
+ user.addEffect(effect.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper
|
||||
});
|
||||
return user instanceof Player && ((Player)user).getAbilities().instabuild ? itemStack : new ItemStack(Items.BOWL);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nex <nex@bits.team>
|
||||
Date: Thu, 24 Feb 2022 16:28:07 +0100
|
||||
Subject: [PATCH] Added byte array serialization/deserialization for
|
||||
PersistentDataContainers
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
||||
index 64110e74c6f6f0433219a721b490970ee33c0b00..65013fd2ca24c4bf1cfd67e314927e72542d3e68 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
||||
@@ -168,5 +168,26 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
|
||||
|
||||
return this.customDataTags.containsKey(key.toString());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public byte[] serializeToBytes() throws java.io.IOException {
|
||||
+ net.minecraft.nbt.CompoundTag root = this.toTagCompound();
|
||||
+ java.io.ByteArrayOutputStream byteArrayOutput = new java.io.ByteArrayOutputStream();
|
||||
+ try (java.io.DataOutputStream dataOutput = new java.io.DataOutputStream(byteArrayOutput)) {
|
||||
+ net.minecraft.nbt.NbtIo.write(root, dataOutput);
|
||||
+ return byteArrayOutput.toByteArray();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void readFromBytes(byte[] bytes, boolean clear) throws java.io.IOException {
|
||||
+ if (clear) {
|
||||
+ this.clear();
|
||||
+ }
|
||||
+ try (java.io.DataInputStream dataInput = new java.io.DataInputStream(new java.io.ByteArrayInputStream(bytes))) {
|
||||
+ net.minecraft.nbt.CompoundTag compound = net.minecraft.nbt.NbtIo.read(dataInput);
|
||||
+ this.putAll(compound);
|
||||
+ }
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MelnCat <melncatuwu@gmail.com>
|
||||
Date: Mon, 19 Sep 2022 14:16:10 -0700
|
||||
Subject: [PATCH] Add a consumer parameter to ProjectileSource#launchProjectile
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 661638716cd4d1b20745f3a196f6d060b3de570c..c45d7e1262534255025392a804c9e4f47213f637 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -509,8 +509,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
- @SuppressWarnings("unchecked")
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
|
||||
+ // Paper start - launchProjectile consumer
|
||||
+ return this.launchProjectile(projectile, velocity, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, org.bukkit.util.Consumer<T> function) {
|
||||
+ // Paper end - launchProjectile consumer
|
||||
Preconditions.checkState(!this.getHandle().generation, "Cannot launch projectile during world generation");
|
||||
|
||||
net.minecraft.world.level.Level world = ((CraftWorld) getWorld()).getHandle();
|
||||
@@ -593,6 +600,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
if (velocity != null) {
|
||||
((T) launch.getBukkitEntity()).setVelocity(velocity);
|
||||
}
|
||||
+ // Paper start - launchProjectile consumer
|
||||
+ if (function != null) {
|
||||
+ function.accept((T) launch.getBukkitEntity());
|
||||
+ }
|
||||
+ // Paper end - launchProjectile consumer
|
||||
|
||||
world.addFreshEntity(launch);
|
||||
return (T) launch.getBukkitEntity();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
|
||||
index 7f9a716ea65f98d1c8487438949f1d5bc8becc4a..24156e1cd819584c1856cf6d30b4d510691136b6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
|
||||
@@ -56,6 +56,13 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
|
||||
@Override
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
|
||||
+ // Paper start - launchProjectile consumer
|
||||
+ return this.launchProjectile(projectile, velocity, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, org.bukkit.util.Consumer<T> function) {
|
||||
+ // Paper end - launchProjectile consumer
|
||||
Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
|
||||
// Copied from BlockDispenser.dispense()
|
||||
BlockSource sourceblock = new BlockSource((ServerLevel) this.dispenserBlock.getLevel(), this.dispenserBlock.getBlockPos(), this.dispenserBlock.getBlockState(), this.dispenserBlock);
|
||||
@@ -146,6 +153,11 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
if (velocity != null) {
|
||||
((T) launch.getBukkitEntity()).setVelocity(velocity);
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (function != null) {
|
||||
+ function.accept((T) launch.getBukkitEntity());
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
world.addFreshEntity(launch);
|
||||
return (T) launch.getBukkitEntity();
|
39
patches/server/0843-Call-BlockPhysicsEvent-more-often.patch
Normal file
39
patches/server/0843-Call-BlockPhysicsEvent-more-often.patch
Normal file
|
@ -0,0 +1,39 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
||||
Date: Sun, 7 Aug 2022 22:16:36 +0200
|
||||
Subject: [PATCH] Call BlockPhysicsEvent more often
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||
index 7d54abc2553f4b319df4d533a0b689c1807b6102..598dc0d3a2b9387e76d7e4e19e54c4573a24bc54 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||
@@ -119,7 +119,27 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
|
||||
public boolean runNext(Level world) {
|
||||
BlockPos blockPos = this.sourcePos.relative(NeighborUpdater.UPDATE_ORDER[this.idx++]);
|
||||
BlockState blockState = world.getBlockState(blockPos);
|
||||
- NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, this.sourcePos, false);
|
||||
+ // Paper start
|
||||
+ try {
|
||||
+ boolean cancelled = false;
|
||||
+ org.bukkit.craftbukkit.CraftWorld cworld = world.getWorld();
|
||||
+ if (cworld != null) {
|
||||
+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(
|
||||
+ org.bukkit.craftbukkit.block.CraftBlock.at(world, blockPos),
|
||||
+ org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(blockState),
|
||||
+ org.bukkit.craftbukkit.block.CraftBlock.at(world, sourcePos));
|
||||
+
|
||||
+ if (!event.callEvent()) {
|
||||
+ cancelled = true;
|
||||
+ }
|
||||
+ }
|
||||
+ if (!cancelled) { // continue to check for adjacent block (increase idx)
|
||||
+ NeighborUpdater.executeUpdate(world, blockState, blockPos, this.sourceBlock, this.sourcePos, false);
|
||||
+ }
|
||||
+ } catch (StackOverflowError ex) {
|
||||
+ world.lastPhysicsProblem = new BlockPos(blockPos);
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.idx < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.idx] == this.skipDirection) {
|
||||
++this.idx;
|
||||
}
|
55
patches/server/0844-Configurable-chat-thread-limit.patch
Normal file
55
patches/server/0844-Configurable-chat-thread-limit.patch
Normal file
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 18 Sep 2022 06:33:17 +0100
|
||||
Subject: [PATCH] Configurable chat thread limit
|
||||
|
||||
By default, spigot shifts chat over to an unbounded thread pool,
|
||||
on a normal server, this really offers no gains, the creation of a thread
|
||||
on submitting to the pool on these servers eats more time vs just running it in
|
||||
the netty pipeline, however, on servers using plugins which do work in here, there
|
||||
could be some overall benefits to moving this stuff outside of the pipeline.
|
||||
|
||||
In general, this patch does two things:
|
||||
1) Exposes the core size for the pool, this allows for ensuring that a number of threads
|
||||
sit around in the pool, mitigating the need for creating new threads; This IS however
|
||||
caveated, the ThreadPoolExecutor will ONLY create core threads as they're needed, it
|
||||
just won't allow for us to dip back under the # of core threads, this can potentially
|
||||
be mitigated by calling prestartCoreThread, however, I'm not sure if there is much justification
|
||||
for this
|
||||
2) Exposes a max size for the pool, as stated, by default this is unbounded, for most
|
||||
servers limiting the size of the pool is going to have 0 effects given how fast chat
|
||||
is actually processed, this is honestly really just exposed for the misnomers or people
|
||||
who just wanna ensure that this won't grow over a specific size if chat gets stupidly active
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
index 4b3bb5fad1d80c9baea20ca224663b1ebc2b83e9..eb4a70f4e21e46f61e60235fb0569c0d6b2672f9 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
@@ -262,13 +262,26 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public Misc misc;
|
||||
|
||||
public class Misc extends ConfigurationPart {
|
||||
+
|
||||
+ public ChatThreads chatThreads;
|
||||
public class ChatThreads extends ConfigurationPart.Post {
|
||||
private int chatExecutorCoreSize = -1;
|
||||
private int chatExecutorMaxSize = -1;
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
- // TODO: FILL
|
||||
+ //noinspection ConstantConditions
|
||||
+ if (net.minecraft.server.MinecraftServer.getServer() == null) return; // In testing env, this will be null here
|
||||
+ int _chatExecutorMaxSize = (chatExecutorMaxSize <= 0) ? Integer.MAX_VALUE : chatExecutorMaxSize; // This is somewhat dumb, but, this is the default, do we cap this?;
|
||||
+ int _chatExecutorCoreSize = Math.max(chatExecutorCoreSize, 0);
|
||||
+
|
||||
+ if (_chatExecutorMaxSize < _chatExecutorCoreSize) {
|
||||
+ _chatExecutorMaxSize = _chatExecutorCoreSize;
|
||||
+ }
|
||||
+
|
||||
+ java.util.concurrent.ThreadPoolExecutor executor = (java.util.concurrent.ThreadPoolExecutor) net.minecraft.server.MinecraftServer.getServer().chatExecutor;
|
||||
+ executor.setCorePoolSize(_chatExecutorCoreSize);
|
||||
+ executor.setMaximumPoolSize(_chatExecutorMaxSize);
|
||||
}
|
||||
}
|
||||
public int maxJoinsPerTick = 5;
|
Loading…
Add table
Add a link
Reference in a new issue