Fixed pegasi dropping the entity they were carrying upon a relog

This commit is contained in:
Sollace 2023-01-09 01:27:22 +01:00
parent 44802abf1b
commit 8c04bb710a
4 changed files with 19 additions and 7 deletions

View file

@ -40,8 +40,8 @@ repositories {
maven { name 'entity-reach-attributes'; url 'https://maven.jamieswhiteshirt.com/libs-release' }
maven { name 'trinkets'; url 'https://ladysnake.jfrog.io/artifactory/mods' }
maven { name 'mod-menu'; url 'https://maven.terraformersmc.com/' }
maven { name 'minelp'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' }
maven { name 'minelp-release'; url 'https://repo.minelittlepony-mod.com/maven/release' }
maven { name 'minelp-snapshot'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' }
maven { name 'minelp-releases'; url 'https://repo.minelittlepony-mod.com/maven/release' }
}
dependencies {

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.ability;
import java.util.List;
import java.util.UUID;
import java.util.stream.StreamSupport;
import com.minelittlepony.unicopia.Race;
@ -76,6 +77,10 @@ public class CarryAbility implements Ability<Hit> {
player.removeAllPassengers();
for (Entity passenger : passengers) {
passenger.refreshPositionAfterTeleport(player.getPos());
Living<?> l = Living.living(passenger);
if (l != null) {
l.setCarrier((UUID)null);
}
}
}

View file

@ -150,6 +150,15 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", entity, e);
}
if (!(entity instanceof PlayerEntity)) {
if (!entity.hasVehicle() && getCarrierId().isPresent() && !asWorld().isClient && entity.age % 10 == 0) {
UUID carrierId = getCarrierId().get();
Entity carrier = ((ServerWorld)asWorld()).getEntity(carrierId);
asEntity().startRiding(carrier, true);
Living.transmitPassengers(carrier);
}
}
if (invinsibilityTicks > 0) {
invinsibilityTicks--;
}

View file

@ -1,10 +1,6 @@
package com.minelittlepony.unicopia.entity.player;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable;
@ -297,6 +293,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
if (vehicle instanceof Trap) {
if (((Trap)vehicle).attemptDismount(entity)) {
setCarrier((UUID)null);
entity.stopRiding();
entity.refreshPositionAfterTeleport(vehicle.getPos());
Living.transmitPassengers(vehicle);
@ -304,6 +301,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
entity.setSneaking(false);
}
} else {
setCarrier((UUID)null);
entity.stopRiding();
entity.refreshPositionAfterTeleport(vehicle.getPos());
Living.transmitPassengers(vehicle);