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 'entity-reach-attributes'; url 'https://maven.jamieswhiteshirt.com/libs-release' }
maven { name 'trinkets'; url 'https://ladysnake.jfrog.io/artifactory/mods' } maven { name 'trinkets'; url 'https://ladysnake.jfrog.io/artifactory/mods' }
maven { name 'mod-menu'; url 'https://maven.terraformersmc.com/' } maven { name 'mod-menu'; url 'https://maven.terraformersmc.com/' }
maven { name 'minelp'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' } maven { name 'minelp-snapshot'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' }
maven { name 'minelp-release'; url 'https://repo.minelittlepony-mod.com/maven/release' } maven { name 'minelp-releases'; url 'https://repo.minelittlepony-mod.com/maven/release' }
} }
dependencies { dependencies {

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.ability; package com.minelittlepony.unicopia.ability;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
@ -76,6 +77,10 @@ public class CarryAbility implements Ability<Hit> {
player.removeAllPassengers(); player.removeAllPassengers();
for (Entity passenger : passengers) { for (Entity passenger : passengers) {
passenger.refreshPositionAfterTeleport(player.getPos()); 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); 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) { if (invinsibilityTicks > 0) {
invinsibilityTicks--; invinsibilityTicks--;
} }

View file

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