Skip to content

Commit

Permalink
Fix for fastminecart mod. (Fixes #1574)
Browse files Browse the repository at this point in the history
Signed-off-by: 秋雨落 <i@rain.cx>
  • Loading branch information
qyl27 committed Nov 29, 2024
1 parent d6fd237 commit 9fce044
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand Down Expand Up @@ -66,6 +67,7 @@ public abstract class AbstractMinecartMixin extends VehicleEntityMixin implement
maxSpeed = 0.4D;
}

@Unique
private transient Location arclight$prevLocation;

@Decorate(method = "tick", inject = true, at = @At("HEAD"))
Expand All @@ -76,14 +78,15 @@ public abstract class AbstractMinecartMixin extends VehicleEntityMixin implement
@Inject(method = "tick", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/vehicle/AbstractMinecart;setRot(FF)V"))
private void arclight$vehicleUpdateEvent(CallbackInfo ci) {
org.bukkit.World bworld = this.level().bridge$getWorld();
Location from = this.arclight$prevLocation;
this.arclight$prevLocation = null;
from.setWorld(bworld);
Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
Bukkit.getPluginManager().callEvent(new VehicleUpdateEvent(vehicle));
if (!from.equals(to)) {
Bukkit.getPluginManager().callEvent(new VehicleMoveEvent(vehicle, from, to));
Location from = this.arclight$prevLocation;
if (from != null) {
from.setWorld(bworld);
if (!from.equals(to)) {
Bukkit.getPluginManager().callEvent(new VehicleMoveEvent(vehicle, from, to));
}
}
}

Expand Down

0 comments on commit 9fce044

Please sign in to comment.