mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-23 16:49:10 +00:00
begin removing Location
This commit is contained in:
@@ -15,6 +15,6 @@ public class FixChunkCommand implements CommandTemplate {
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
BukkitChunkGeneratorWrapper.fixChunk(player.world().getChunkAt(player.position().toLocation(player.world())));
|
||||
BukkitChunkGeneratorWrapper.fixChunk(player.world().getChunkAt(player.position()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.bukkit.structure.WorldEditUtil;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
@@ -26,7 +26,7 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||
public Pair<Vector3, Vector3> getSelectedLocation(Player player) {
|
||||
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
||||
return Pair.of(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ public class PaperListener implements Listener {
|
||||
TerraWorld tw = main.getWorld(BukkitAdapter.adapt(e.getWorld()));
|
||||
TerraStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(tw.getConfig().getLocatable().get(name));
|
||||
if(config != null) {
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getOrigin()), 0, 500, location -> {
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getOrigin().toVector()), tw.getWorld(), 0, 500, location -> {
|
||||
if(location != null)
|
||||
e.setResult(BukkitAdapter.adapt(location.toLocation(BukkitAdapter.adapt(e.getWorld()))));
|
||||
e.setResult(BukkitAdapter.adapt(location).toLocation(e.getWorld()));
|
||||
main.getDebugLogger().info("Location: " + location);
|
||||
}, main);
|
||||
finder.run(); // Do this synchronously.
|
||||
|
||||
@@ -40,9 +40,9 @@ public class SpigotListener implements Listener {
|
||||
TerraStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(tw.getConfig().getLocatable().get("STRONGHOLD"));
|
||||
if(config != null) {
|
||||
main.getDebugLogger().info("Overriding Ender Signal...");
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getLocation()), 0, 500, location -> {
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getLocation().toVector()), tw.getWorld(), 0, 500, location -> {
|
||||
if(location != null)
|
||||
signal.setTargetLocation(BukkitAdapter.adapt(location.toLocation(BukkitAdapter.adapt(signal.getWorld()))));
|
||||
signal.setTargetLocation(BukkitAdapter.adapt(location).toLocation(e.getLocation().getWorld()));
|
||||
main.getDebugLogger().info("Location: " + location);
|
||||
}, main);
|
||||
finder.run(); // Do this synchronously so eye doesn't change direction several ticks after spawning.
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
@@ -75,8 +75,8 @@ public class BukkitWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location), ((BukkitEntityType) entityType).getHandle()));
|
||||
public Entity spawnEntity(Vector3 location, EntityType entityType) {
|
||||
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location).toLocation(delegate), ((BukkitEntityType) entityType).getHandle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -118,7 +118,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
||||
TerraStructure located = pack.getRegistry(TerraStructure.class).get(pack.getLocatable().get(name));
|
||||
if(located != null) {
|
||||
CompletableFuture<BlockPos> result = new CompletableFuture<>();
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(terraWorld.getBiomeProvider(), located, FabricAdapter.adapt(center).toLocation((World) world), 0, 500, location -> {
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(terraWorld.getBiomeProvider(), located, FabricAdapter.adapt(center), terraWorld.getWorld(), 0, 500, location -> {
|
||||
result.complete(FabricAdapter.adapt(location));
|
||||
}, TerraFabricPlugin.getInstance());
|
||||
finder.run(); // Do this synchronously.
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.util.WorldEditUtil;
|
||||
@@ -39,7 +39,7 @@ public class FabricWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||
public Pair<Vector3, Vector3> getSelectedLocation(Player player) {
|
||||
try {
|
||||
Class.forName("com.sk89q.worldedit.WorldEdit");
|
||||
} catch(ClassNotFoundException e) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
@@ -64,7 +65,7 @@ public abstract class ChunkRegionMixin {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Entity terraWorld$spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity terraWorld$spawnEntity(Vector3 location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ChunkRegion) (Object) this).toServerWorld());
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
((ChunkRegion) (Object) this).spawnEntity(entity);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
@@ -53,7 +54,7 @@ public abstract class ServerWorldMixin {
|
||||
((ServerWorld) (Object) this).setBlockState(pos, ((FabricBlockData) data).getHandle(), physics ? 3 : 1042);
|
||||
}
|
||||
|
||||
public Entity terra$spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity terra$spawnEntity(Vector3 location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ServerWorld) (Object) this));
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
((ServerWorld) (Object) this).spawnEntity(entity);
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.dfsek.terra.fabric.util;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@@ -12,7 +14,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class WorldEditUtil {
|
||||
public static Pair<Location, Location> getSelection(Player player) {
|
||||
public static Pair<Vector3, Vector3> getSelection(Player player) {
|
||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||
try {
|
||||
Region selection = worldEdit.getSessionManager()
|
||||
@@ -20,8 +22,8 @@ public final class WorldEditUtil {
|
||||
.getSelection(com.sk89q.worldedit.fabric.FabricAdapter.adapt((World) player.world()));
|
||||
BlockVector3 min = selection.getMinimumPoint();
|
||||
BlockVector3 max = selection.getMaximumPoint();
|
||||
LocationImpl l1 = new LocationImpl(player.world(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
||||
LocationImpl l2 = new LocationImpl(player.world(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||
Vector3 l1 = new Vector3Impl(min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
||||
Vector3 l2 = new Vector3Impl(max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||
return Pair.of(l1, l2);
|
||||
} catch(IncompleteRegionException e) {
|
||||
throw new IllegalStateException("No selection has been made", e);
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RawTree implements Tree { // TODO: implement
|
||||
@Override
|
||||
public boolean plant(LocationImpl l, Random r) {
|
||||
public boolean plant(Vector3 l, World world, Random r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user