Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
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;

@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);
}
}