48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
package com.zontreck.util;
|
|
|
|
import com.zontreck.events.TeleportEvent;
|
|
import com.zontreck.libzontreck.vectors.WorldPosition;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import java.time.Duration;
|
|
|
|
public class TeleportRunnable implements Runnable {
|
|
|
|
public final boolean IgnoreEvent;
|
|
public final TeleportContainer Action;
|
|
public TeleportRunnable(TeleportContainer cont, boolean eventless){
|
|
Action = cont;
|
|
IgnoreEvent=eventless;
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
Action.OldPosition = new WorldPosition(Action.PlayerInst);
|
|
|
|
if(!IgnoreEvent)
|
|
{
|
|
|
|
if(MinecraftForge.EVENT_BUS.post(new TeleportEvent(Action)))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
if(Action.world_pos.Dimension.equalsIgnoreCase((new WorldPosition(Action.PlayerInst).Dimension))) {
|
|
Action.PlayerInst.setPos(Action.Position);
|
|
}else {
|
|
Action.PlayerInst.changeDimension(Action.Dimension);
|
|
|
|
try {
|
|
Thread.sleep(1000);
|
|
} catch (InterruptedException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
|
|
Action.PlayerInst.setPos(Action.Position);
|
|
}
|
|
|
|
Action.PlayerInst.onUpdateAbilities();
|
|
Action.PlayerInst.giveExperiencePoints(1);
|
|
}
|
|
}
|