Add latest revisions after getting it functional
This commit is contained in:
parent
9653e273e4
commit
ffcecb8e8e
1443 changed files with 258988 additions and 6046 deletions
54
src/main/java/com/zontreck/util/TeleportRunnable.java
Normal file
54
src/main/java/com/zontreck/util/TeleportRunnable.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Action.PlayerInst.teleportTo(Action.Dimension, Action.Position.x, Action.Position.y, Action.Position.z, Action.Rotation.y, Action.Rotation.x);
|
||||
|
||||
Action.PlayerInst.onUpdateAbilities();
|
||||
|
||||
|
||||
Thread tx = new Thread(new Runnable(){
|
||||
public final TeleportContainer container=Action;
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
container.PlayerInst.onUpdateAbilities();
|
||||
container.PlayerInst.setPos(container.Position);
|
||||
container.PlayerInst.giveExperiencePoints(1);
|
||||
}
|
||||
});
|
||||
|
||||
tx.start();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue