Paper/Spigot-Server-Patches/0452-Do-not-allow-bees-to-load-chunks-for-beehives.patch
Aikar f37381ea8a
Optimize Network Manager to not need synchronization
Removes synchronization from sending packets
Makes normal packet sends no longer need to be wrapped and queued like it use to work.
Adds more packet queue immunities on top of keep alive to let the following scenarios go out
without delay:
  - Keep Alive
  - Chat
  - Kick
  - All of the packets during the Player Joined World event

Hoping that latter one helps join timeout issues more too for slow connections.

Removes processing packet queue off of main thread
  - for the few cases where it is allowed, order is not necessary nor
    should it even be happening concurrently in first place (handshaking/login/status)

Ensures packets sent asynchronously are dispatched on main thread

This helps ensure safety for ProtocolLib as packet listeners
are commonly accessing world state. This will allow you to schedule
a packet to be sent async, but itll be dispatched sync for packet
listeners to process.

This should solve some deadlock risks

This may provide a decent performance improvement because thread synchronization incurs a cache reset
so by avoiding ever entering a synchronized block, we get to avoid that, and packet sending is a really
hot activity.
2020-05-06 05:28:47 -04:00

46 lines
2.3 KiB
Diff

From 93c5f228e9cf15809c3bb58aa9053697d17e7131 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Tue, 17 Mar 2020 14:18:50 -0500
Subject: [PATCH] Do not allow bees to load chunks for beehives
diff --git a/src/main/java/net/minecraft/server/EntityBee.java b/src/main/java/net/minecraft/server/EntityBee.java
index c7d79efdf6e..dd1d246aeb5 100644
--- a/src/main/java/net/minecraft/server/EntityBee.java
+++ b/src/main/java/net/minecraft/server/EntityBee.java
@@ -315,6 +315,7 @@ public class EntityBee extends EntityAnimal implements EntityBird {
if (this.hivePos == null) {
return false;
} else {
+ if (!this.world.isLoadedAndInBounds(hivePos)) return false; // Paper
TileEntity tileentity = this.world.getTileEntity(this.hivePos);
return tileentity instanceof TileEntityBeehive && ((TileEntityBeehive) tileentity).d();
@@ -334,6 +335,7 @@ public class EntityBee extends EntityAnimal implements EntityBird {
}
private boolean i(BlockPosition blockposition) {
+ if (!this.world.isLoadedAndInBounds(blockposition)) return false; // Paper
TileEntity tileentity = this.world.getTileEntity(blockposition);
return tileentity instanceof TileEntityBeehive ? !((TileEntityBeehive) tileentity).isFull() : false;
@@ -593,6 +595,7 @@ public class EntityBee extends EntityAnimal implements EntityBird {
@Override
public boolean g() {
if (EntityBee.this.hasHivePos() && EntityBee.this.eI() && EntityBee.this.hivePos.a((IPosition) EntityBee.this.getPositionVector(), 2.0D)) {
+ if (!EntityBee.this.world.isLoadedAndInBounds(EntityBee.this.hivePos)) return false; // Paper
TileEntity tileentity = EntityBee.this.world.getTileEntity(EntityBee.this.hivePos);
if (tileentity instanceof TileEntityBeehive) {
@@ -616,6 +619,7 @@ public class EntityBee extends EntityAnimal implements EntityBird {
@Override
public void c() {
+ if (!EntityBee.this.world.isLoadedAndInBounds(EntityBee.this.hivePos)) return; // Paper
TileEntity tileentity = EntityBee.this.world.getTileEntity(EntityBee.this.hivePos);
if (tileentity instanceof TileEntityBeehive) {
--
2.26.2