diff --git a/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_stick_sublevels/ClientPacketListenerMixin.java b/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_stick_sublevels/ClientPacketListenerMixin.java index b8bc2e5e..5a1a65d1 100644 --- a/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_stick_sublevels/ClientPacketListenerMixin.java +++ b/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_stick_sublevels/ClientPacketListenerMixin.java @@ -105,11 +105,12 @@ public abstract class ClientPacketListenerMixin { if (subLevel != null && actuallyInSubLevel && existingSubLevel != subLevel) { entity.setPos(subLevel.logicalPose().transformPositionInverse(entity.position())); } else if (existingSubLevel != null && subLevel == null) { - entity.setPos(existingSubLevel.logicalPose().transformPosition(entity.position())); + final Vec3 newPos = existingSubLevel.logicalPose().transformPosition(entity.position()); + entity.moveTo(newPos.x, newPos.y, newPos.z); } entity.lerpTo(pX, pY, pZ, pYRot, pXRot, pLerpSteps); extension.sable$setPlotPosition(null); } } -} \ No newline at end of file +} diff --git a/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entity_sublevel_collision/AbstractMinecartMixin.java b/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entity_sublevel_collision/AbstractMinecartMixin.java index a31c7a46..05f711f8 100644 --- a/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entity_sublevel_collision/AbstractMinecartMixin.java +++ b/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entity_sublevel_collision/AbstractMinecartMixin.java @@ -1,13 +1,14 @@ package dev.ryanhcode.sable.mixin.entity.entity_sublevel_collision; import dev.ryanhcode.sable.Sable; -import dev.ryanhcode.sable.index.SableTags; +import dev.ryanhcode.sable.api.entity.EntitySubLevelUtil; import dev.ryanhcode.sable.sublevel.SubLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.vehicle.AbstractMinecart; import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -15,22 +16,21 @@ @Mixin(AbstractMinecart.class) public abstract class AbstractMinecartMixin extends Entity { - public AbstractMinecartMixin(final EntityType entityType, final Level level) { super(entityType, level); } + @Shadow public abstract boolean isOnRails(); + @Inject(method = "tick", at = @At("TAIL")) private void sable$postTick(final CallbackInfo ci) { - if (!this.getType().is(SableTags.DESTROY_WHEN_LEAVING_PLOT)) { - return; - } + if (this.level().isClientSide) return; final SubLevel containingSubLevel = Sable.HELPER.getContaining(this); + if (containingSubLevel == null) return; + + if (this.isOnRails()) return; - // Destroy us if we're in #sable:destroy_when_leaving_plot and we've left the plot - if (containingSubLevel != null && !this.getBoundingBox().intersects(containingSubLevel.getPlot().getBoundingBox().toAABB().inflate(0.5))) { - this.kill(); - } + EntitySubLevelUtil.kickEntity(containingSubLevel, this); } }