From 8c04bb710ab291443f1eaef9d12556f1bac3335a Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 9 Jan 2023 01:27:22 +0100 Subject: [PATCH] Fixed pegasi dropping the entity they were carrying upon a relog --- build.gradle | 4 ++-- .../minelittlepony/unicopia/ability/CarryAbility.java | 5 +++++ .../java/com/minelittlepony/unicopia/entity/Living.java | 9 +++++++++ .../com/minelittlepony/unicopia/entity/player/Pony.java | 8 +++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index df5b1ec0..e77683d3 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java index 822cab12..cd3277c4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java @@ -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 { player.removeAllPassengers(); for (Entity passenger : passengers) { passenger.refreshPositionAfterTeleport(player.getPos()); + Living l = Living.living(passenger); + if (l != null) { + l.setCarrier((UUID)null); + } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index f756cd74..8cc4616e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -150,6 +150,15 @@ public abstract class Living implements Equine, 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--; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 13c2c1cf..ad3c2232 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -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 implements Copyable, 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 implements Copyable, Update entity.setSneaking(false); } } else { + setCarrier((UUID)null); entity.stopRiding(); entity.refreshPositionAfterTeleport(vehicle.getPos()); Living.transmitPassengers(vehicle);