Bug fixes

- Ports fabric disconnect fix to neoforge
- Fixes console error when trying to pickup non owned tamable mobs.
This commit is contained in:
Hanro50 2025-10-15 22:03:28 +02:00
parent 5cf2e87fe8
commit d35cb4ed72
2 changed files with 14 additions and 5 deletions

View File

@ -32,6 +32,8 @@ import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.Entity.RemovalReason;
import net.minecraft.world.entity.EntityReference;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.Animal;
@ -172,10 +174,13 @@ public class PickupHandler {
if (entity instanceof TamableAnimal tame) if (entity instanceof TamableAnimal tame)
{ {
UUID owner = tame.getOwnerReference().getUUID(); EntityReference<LivingEntity> ref = tame.getOwnerReference();
UUID playerID = player.getGameProfile().id(); if (ref != null) {
if (owner != null && !owner.equals(playerID)) UUID owner = tame.getOwnerReference().getUUID();
return false; UUID playerID = player.getGameProfile().id();
if (!owner.equals(playerID))
return false;
}
} }
if(!ListHandler.isPermitted(entity)) if(!ListHandler.isPermitted(entity))

View File

@ -20,7 +20,11 @@ public class CarryOnDataSyncHandler implements AttachmentSyncHandler<CarryOnData
@Override @Override
public boolean sendToPlayer(IAttachmentHolder holder, ServerPlayer to) { public boolean sendToPlayer(IAttachmentHolder holder, ServerPlayer to) {
if (to.connection == null || to.isRemoved()) ServerPlayer player = (ServerPlayer) holder;
// the isAlive check avoids us syncing attachment data about dead players. Which causes a disconnect
// player.tickCount <= 0 avoids us syncing attachment data about players the instant they spawn.
// Which also causes a disconnect as the player entity may not be synced yet.
if (to.connection == null || !player.isAlive() || player.tickCount <= 0)
return false; return false;
return AttachmentSyncHandler.super.sendToPlayer(holder, to); return AttachmentSyncHandler.super.sendToPlayer(holder, to);
} }