Do not run close logic for inventories on chunk unload
Still call the event and change the active container though. We want to avoid close logic because it's possible to load the chunk through it. This should also be OK from a leak prevention/ state desync POV because the TE is getting unloaded anyways.
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
}
|
||||
|
||||
private boolean isEquipped(Item item) {
|
||||
@@ -513,6 +541,13 @@
|
||||
@@ -513,6 +541,18 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -104,11 +104,16 @@
|
||||
+ this.containerMenu = this.inventoryMenu;
|
||||
+ }
|
||||
+ // Paper end - Inventory close reason
|
||||
+ // Paper start - special close for unloaded inventory
|
||||
+ public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
|
||||
+ this.containerMenu = this.inventoryMenu;
|
||||
+ }
|
||||
+ // Paper end - special close for unloaded inventory
|
||||
+
|
||||
public void closeContainer() {
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
@@ -523,8 +558,14 @@
|
||||
@@ -523,8 +563,14 @@
|
||||
public void rideTick() {
|
||||
if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
|
||||
this.stopRiding();
|
||||
@@ -125,7 +130,7 @@
|
||||
super.rideTick();
|
||||
this.oBob = this.bob;
|
||||
this.bob = 0.0F;
|
||||
@@ -593,6 +634,7 @@
|
||||
@@ -593,6 +639,7 @@
|
||||
this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft());
|
||||
this.playShoulderEntityAmbientSound(this.getShoulderEntityRight());
|
||||
if (!this.level().isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) {
|
||||
@@ -133,7 +138,7 @@
|
||||
this.removeEntitiesOnShoulder();
|
||||
}
|
||||
|
||||
@@ -719,7 +761,14 @@
|
||||
@@ -719,7 +766,14 @@
|
||||
|
||||
@Nullable
|
||||
public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) {
|
||||
@@ -149,7 +154,7 @@
|
||||
this.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
@@ -809,7 +858,7 @@
|
||||
@@ -809,7 +863,7 @@
|
||||
}
|
||||
|
||||
if (nbt.contains("LastDeathLocation", 10)) {
|
||||
@@ -158,7 +163,7 @@
|
||||
Logger logger = Player.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -817,7 +866,7 @@
|
||||
@@ -817,7 +871,7 @@
|
||||
}
|
||||
|
||||
if (nbt.contains("current_explosion_impact_pos", 9)) {
|
||||
@@ -167,7 +172,7 @@
|
||||
Logger logger1 = Player.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger1);
|
||||
@@ -854,7 +903,7 @@
|
||||
@@ -854,7 +908,7 @@
|
||||
}
|
||||
|
||||
this.getLastDeathLocation().flatMap((globalpos) -> {
|
||||
@@ -176,7 +181,7 @@
|
||||
Logger logger = Player.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -886,10 +935,10 @@
|
||||
@@ -886,10 +940,10 @@
|
||||
if (this.isDeadOrDying()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -189,7 +194,7 @@
|
||||
}
|
||||
|
||||
if (world.getDifficulty() == Difficulty.EASY) {
|
||||
@@ -901,7 +950,13 @@
|
||||
@@ -901,7 +955,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +209,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -923,10 +978,29 @@
|
||||
@@ -923,10 +983,29 @@
|
||||
}
|
||||
|
||||
public boolean canHarmPlayer(Player player) {
|
||||
@@ -237,7 +242,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -966,32 +1040,38 @@
|
||||
@@ -966,32 +1045,38 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +295,7 @@
|
||||
}
|
||||
|
||||
public boolean isTextFilteringEnabled() {
|
||||
@@ -1061,13 +1141,19 @@
|
||||
@@ -1061,13 +1146,19 @@
|
||||
|
||||
@Override
|
||||
public void removeVehicle() {
|
||||
@@ -312,7 +317,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1144,10 +1230,15 @@
|
||||
@@ -1144,10 +1235,15 @@
|
||||
|
||||
f *= 0.2F + f2 * f2 * 0.8F;
|
||||
f1 *= f2;
|
||||
@@ -329,7 +334,7 @@
|
||||
if (iprojectile.deflect(ProjectileDeflection.AIM_DEFLECT, this, this, true)) {
|
||||
this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource());
|
||||
return;
|
||||
@@ -1159,7 +1250,7 @@
|
||||
@@ -1159,7 +1255,7 @@
|
||||
boolean flag1;
|
||||
|
||||
if (this.isSprinting() && flag) {
|
||||
@@ -338,7 +343,7 @@
|
||||
flag1 = true;
|
||||
} else {
|
||||
flag1 = false;
|
||||
@@ -1168,7 +1259,9 @@
|
||||
@@ -1168,7 +1264,9 @@
|
||||
f += itemstack.getItem().getAttackDamageBonus(target, f, damagesource);
|
||||
boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround() && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity && !this.isSprinting();
|
||||
|
||||
@@ -348,7 +353,7 @@
|
||||
f *= 1.5F;
|
||||
}
|
||||
|
||||
@@ -1202,13 +1295,17 @@
|
||||
@@ -1202,13 +1300,17 @@
|
||||
if (target instanceof LivingEntity) {
|
||||
LivingEntity entityliving1 = (LivingEntity) target;
|
||||
|
||||
@@ -368,7 +373,7 @@
|
||||
}
|
||||
|
||||
LivingEntity entityliving2;
|
||||
@@ -1223,8 +1320,13 @@
|
||||
@@ -1223,8 +1325,13 @@
|
||||
if (entityliving2 != this && entityliving2 != target && !this.isAlliedTo((Entity) entityliving2) && (!(entityliving2 instanceof ArmorStand) || !((ArmorStand) entityliving2).isMarker()) && this.distanceToSqr((Entity) entityliving2) < 9.0D) {
|
||||
float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2;
|
||||
|
||||
@@ -384,7 +389,7 @@
|
||||
Level world = this.level();
|
||||
|
||||
if (world instanceof ServerLevel) {
|
||||
@@ -1235,26 +1337,43 @@
|
||||
@@ -1235,26 +1342,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +437,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1308,9 +1427,14 @@
|
||||
@@ -1308,9 +1432,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +454,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1351,7 +1475,14 @@
|
||||
@@ -1351,7 +1480,14 @@
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason reason) {
|
||||
@@ -465,7 +470,7 @@
|
||||
this.inventoryMenu.removed(this);
|
||||
if (this.containerMenu != null && this.hasContainerOpen()) {
|
||||
this.doCloseContainer();
|
||||
@@ -1391,7 +1522,13 @@
|
||||
@@ -1391,7 +1527,13 @@
|
||||
}
|
||||
|
||||
public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos pos) {
|
||||
@@ -480,7 +485,7 @@
|
||||
this.sleepCounter = 0;
|
||||
return Either.right(Unit.INSTANCE);
|
||||
}
|
||||
@@ -1545,12 +1682,24 @@
|
||||
@@ -1545,12 +1687,24 @@
|
||||
}
|
||||
|
||||
public void startFallFlying() {
|
||||
@@ -506,7 +511,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1664,11 +1813,30 @@
|
||||
@@ -1664,11 +1818,30 @@
|
||||
public int getXpNeededForNextLevel() {
|
||||
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
|
||||
}
|
||||
@@ -538,7 +543,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1748,13 +1916,20 @@
|
||||
@@ -1748,13 +1921,20 @@
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
|
||||
@@ -566,7 +571,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1798,26 +1973,55 @@
|
||||
@@ -1798,26 +1978,55 @@
|
||||
|
||||
public void removeEntitiesOnShoulder() {
|
||||
if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) {
|
||||
@@ -629,7 +634,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2003,20 +2207,31 @@
|
||||
@@ -2003,20 +2212,31 @@
|
||||
@Override
|
||||
public ImmutableList<Pose> getDismountPoses() {
|
||||
return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING);
|
||||
|
||||
Reference in New Issue
Block a user