implement entity teleportation and biome locate

This commit is contained in:
dfsek
2021-03-10 02:46:00 -07:00
parent 67aae87754
commit 41933b84a0
16 changed files with 284 additions and 102 deletions
@@ -5,6 +5,8 @@ import com.dfsek.terra.api.platform.entity.Entity;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.fabric.world.FabricAdapter;
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
import com.dfsek.terra.fabric.world.handles.world.FabricWorldHandle;
import net.minecraft.server.world.ServerWorld;
public class FabricEntity implements Entity {
private final net.minecraft.entity.Entity delegate;
@@ -28,6 +30,12 @@ public class FabricEntity implements Entity {
return new Location(new FabricWorldAccess(delegate.world), FabricAdapter.adapt(delegate.getBlockPos()));
}
@Override
public void setLocation(Location location) {
delegate.teleport(location.getX(), location.getY(), location.getZ());
delegate.moveToWorld((ServerWorld) ((FabricWorldHandle) location).getWorld());
}
@Override
public World getWorld() {
return new FabricWorldAccess(delegate.world);
@@ -5,7 +5,9 @@ import com.dfsek.terra.api.platform.entity.Player;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.fabric.world.FabricAdapter;
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
import com.dfsek.terra.fabric.world.handles.world.FabricWorldHandle;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
public class FabricPlayer implements Player {
@@ -34,4 +36,10 @@ public class FabricPlayer implements Player {
public World getWorld() {
return new FabricWorldAccess(delegate.world);
}
@Override
public void setLocation(Location location) {
delegate.teleport(location.getX(), location.getY(), location.getZ());
delegate.moveToWorld((ServerWorld) ((FabricWorldHandle) location).getWorld());
}
}