Skip to content

Commit

Permalink
Fix max nearby entities class check (#9967)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonytheMacaroni authored Nov 25, 2023
1 parent ed753d3 commit 334b2f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions patches/server/0856-Fix-a-bunch-of-vanilla-bugs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ https://bugs.mojang.com/browse/MC-174630
https://bugs.mojang.com/browse/MC-153086
Fix the beacon deactivation sound always playing when broken

https://bugs.mojang.com/browse/MC-259321
Fix spawners checking max nearby entities with correct type

== AT ==
public net/minecraft/world/entity/Mob leashInfoTag

Expand Down Expand Up @@ -124,7 +127,7 @@ index b71be5e7e18f884cf35cc3a940c87e744e00f811..81d3d664d4397e528a02e50469622c4f
return this.anyPlayerCloseEnoughForSpawning(pos, false);
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 6b923585821a252943ea6a765c3b02217eb7a21e..008b0944dba1622e682ee21637273fb87f93dd37 100644
index 1f1cdf5516eab738e5d434eb5f2933ff3d7a1359..c5f0439133f3ab609324f21f68027edebed049c5 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1005,7 +1005,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
Expand Down Expand Up @@ -396,7 +399,7 @@ index ca6a2b9840c9ade87ec8effab01d4f184fe876b7..43129ecefcc8beccbcf2978f262b1ce8
stack.shrink(1);
}
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index ae2b95f53e875716489821dc9b0a3a35039bfcc9..9284c550ab2fe21331986a70eac414147662003d 100644
index ae2b95f53e875716489821dc9b0a3a35039bfcc9..e4a5871d8f07e2b4c12b94b6372afe3a34b13071 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -46,6 +46,22 @@ public abstract class BaseSpawner {
Expand All @@ -408,8 +411,8 @@ index ae2b95f53e875716489821dc9b0a3a35039bfcc9..9284c550ab2fe21331986a70eac41414
+ return new net.minecraft.world.level.entity.EntityTypeTest<>() {
+ @Nullable
+ @Override
+ public T tryCast(B clazz) {
+ return (T)(clazz.equals(clazz.getClass()) ? clazz : null);
+ public T tryCast(B entity) {
+ return (T)(clazz.equals(entity.getClass()) ? entity : null);
+ }
+
+ @Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ index 236ab643cdd65b3572860aedf1f5ac18ff96139a..65bb221993147a558995b36fb835f7b8
Slot clickedSlot = this.player.containerMenu.getSlot(packet.getSlotNum());
if (clickedSlot.mayPickup(this.player)) {
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
index 3ef712299fe248602b0b117c0a8e285cdf4e05c2..5d298b11f74cd2da47e6613ced621ab62aa73a7b 100644
index 3ef712299fe248602b0b117c0a8e285cdf4e05c2..aea228ea9fee51c25a03ce1c54bf9dff0741e053 100644
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
@@ -423,6 +423,7 @@ public abstract class AbstractContainerMenu {
Expand All @@ -33,10 +33,12 @@ index 3ef712299fe248602b0b117c0a8e285cdf4e05c2..5d298b11f74cd2da47e6613ced621ab6
slot = (Slot) this.slots.get(slotIndex);
itemstack = this.getCarried();
if (AbstractContainerMenu.canItemQuickReplace(slot, itemstack, true) && slot.mayPlace(itemstack) && (this.quickcraftType == 2 || itemstack.getCount() > this.quickcraftSlots.size()) && this.canDragTo(slot)) {
@@ -598,6 +599,7 @@ public abstract class AbstractContainerMenu {
@@ -597,7 +598,8 @@ public abstract class AbstractContainerMenu {
Slot slot2;
int j2;

if (actionType == ClickType.SWAP) {
- if (actionType == ClickType.SWAP) {
+ if (actionType == ClickType.SWAP && (button == 40 || button >= 0 && button < 9)) { // Paper
+ if (slotIndex < 0 || button < 0) return; // Paper
slot2 = (Slot) this.slots.get(slotIndex);
itemstack1 = playerinventory.getItem(button);
Expand Down

0 comments on commit 334b2f2

Please sign in to comment.