Fix StackOverflow possibility with undead horses

This commit is contained in:
Camotoy 2022-03-01 15:44:13 -05:00
parent 0fd903e0a0
commit e163301d23
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
1 changed files with 14 additions and 4 deletions

View File

@ -130,6 +130,11 @@ public class AbstractHorseEntity extends AnimalEntity {
@Nonnull
@Override
protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) {
return testHorseInteraction(itemInHand);
}
@Nonnull
protected InteractiveTag testHorseInteraction(@Nonnull GeyserItemStack itemInHand) {
boolean isBaby = isBaby();
if (!isBaby) {
if (getFlag(EntityFlag.TAMED) && session.isSneaking()) {
@ -175,6 +180,11 @@ public class AbstractHorseEntity extends AnimalEntity {
@Nonnull
@Override
protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) {
return mobHorseInteract(itemInHand);
}
@Nonnull
protected final InteractionResult mobHorseInteract(@Nonnull GeyserItemStack itemInHand) {
boolean isBaby = isBaby();
if (!isBaby) {
if (getFlag(EntityFlag.TAMED) && session.isSneaking()) {
@ -243,11 +253,11 @@ public class AbstractHorseEntity extends AnimalEntity {
if (!getFlag(EntityFlag.TAMED)) {
return InteractiveTag.NONE;
} else if (isBaby()) {
return testMobInteraction(itemInHand);
return testHorseInteraction(itemInHand);
} else if (session.isSneaking()) {
return InteractiveTag.OPEN_CONTAINER;
} else if (!passengers.isEmpty()) {
return testMobInteraction(itemInHand);
return testHorseInteraction(itemInHand);
} else {
if (session.getItemMappings().getStoredItems().saddle() == itemInHand.getJavaId()) {
return InteractiveTag.OPEN_CONTAINER;
@ -265,12 +275,12 @@ public class AbstractHorseEntity extends AnimalEntity {
if (!getFlag(EntityFlag.TAMED)) {
return InteractionResult.PASS;
} else if (isBaby()) {
return mobInteract(itemInHand);
return mobHorseInteract(itemInHand);
} else if (session.isSneaking()) {
// Opens inventory
return InteractionResult.SUCCESS;
} else if (!passengers.isEmpty()) {
return mobInteract(itemInHand);
return mobHorseInteract(itemInHand);
} else {
// The client tests for saddle but it doesn't matter for us at this point.
return InteractionResult.SUCCESS;