mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-20 15:20:25 +00:00
World -> ServerWorld
This commit is contained in:
@@ -21,7 +21,7 @@ import org.bukkit.Location;
|
||||
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
|
||||
@@ -48,14 +48,14 @@ public class BukkitEntity implements Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void world(World world) {
|
||||
public void world(ServerWorld world) {
|
||||
Location newLoc = entity.getLocation().clone();
|
||||
newLoc.setWorld(BukkitAdapter.adapt(world));
|
||||
entity.teleport(newLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World world() {
|
||||
public ServerWorld world() {
|
||||
return BukkitAdapter.adapt(entity.getWorld());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.bukkit.Location;
|
||||
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ public class BukkitPlayer implements Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void world(World world) {
|
||||
public void world(ServerWorld world) {
|
||||
Location newLoc = delegate.getLocation().clone();
|
||||
newLoc.setWorld(BukkitAdapter.adapt(world));
|
||||
delegate.teleport(newLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World world() {
|
||||
public ServerWorld world() {
|
||||
return BukkitAdapter.adapt(delegate.getWorld());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
@@ -36,7 +38,6 @@ import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.BukkitEntity;
|
||||
import com.dfsek.terra.bukkit.BukkitPlayer;
|
||||
@@ -173,11 +174,11 @@ public final class BukkitAdapter {
|
||||
return ((BukkitCommandSender) sender).getHandle();
|
||||
}
|
||||
|
||||
public static World adapt(org.bukkit.World world) {
|
||||
return new BukkitWorld(world);
|
||||
public static ServerWorld adapt(org.bukkit.World world) {
|
||||
return new BukkitServerWorld(world);
|
||||
}
|
||||
|
||||
public static org.bukkit.World adapt(World world) {
|
||||
public static org.bukkit.World adapt(ServerWorld world) {
|
||||
return (org.bukkit.World) world.getHandle();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
|
||||
public class BukkitChunk implements Chunk {
|
||||
@@ -63,7 +63,7 @@ public class BukkitChunk implements Chunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
public ServerWorld getWorld() {
|
||||
return BukkitAdapter.adapt(delegate.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||
@@ -99,7 +98,7 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return new BukkitWorld(delegate.getWorld());
|
||||
public ServerWorld getWorld() {
|
||||
return new BukkitServerWorld(delegate.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.bukkit.BukkitEntity;
|
||||
@@ -38,10 +37,10 @@ import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public class BukkitWorld implements World {
|
||||
public class BukkitServerWorld implements ServerWorld {
|
||||
private final org.bukkit.World delegate;
|
||||
|
||||
public BukkitWorld(org.bukkit.World delegate) {
|
||||
public BukkitServerWorld(org.bukkit.World delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@@ -125,7 +124,7 @@ public class BukkitWorld implements World {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof BukkitWorld other)) return false;
|
||||
if(!(obj instanceof BukkitServerWorld other)) return false;
|
||||
return other.getHandle().equals(delegate);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -56,7 +56,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.Chunkified;
|
||||
@@ -90,7 +89,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
private final TerraBiomeSource biomeSource;
|
||||
private ChunkGenerator delegate;
|
||||
private ConfigPack pack;
|
||||
private ServerWorld world;
|
||||
private net.minecraft.server.world.ServerWorld world;
|
||||
|
||||
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack) {
|
||||
super(biomeSource, new StructuresConfig(false));
|
||||
@@ -228,9 +227,9 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
|
||||
@Override
|
||||
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView heightmapType) {
|
||||
int height = ((World) world).getMaxHeight();
|
||||
while(height >= ((World) world).getMinHeight() && !heightmap.getBlockPredicate().test(
|
||||
((FabricBlockState) ((World) world).getGenerator().getBlock((World) world, x, height - 1, z)).getHandle())) {
|
||||
int height = ((ServerWorld) world).getMaxHeight();
|
||||
while(height >= ((ServerWorld) world).getMinHeight() && !heightmap.getBlockPredicate().test(
|
||||
((FabricBlockState) ((ServerWorld) world).getGenerator().getBlock((ServerWorld) world, x, height - 1, z)).getHandle())) {
|
||||
height--;
|
||||
}
|
||||
return height;
|
||||
@@ -240,7 +239,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView view) {
|
||||
BlockState[] array = new BlockState[view.getHeight()];
|
||||
for(int y = view.getBottomY() + view.getHeight() - 1; y >= view.getBottomY(); y--) {
|
||||
array[y] = ((FabricBlockState) ((World) world).getGenerator().getBlock((World) world, x, y, z)).getHandle();
|
||||
array[y] = ((FabricBlockState) ((ServerWorld) world).getGenerator().getBlock((ServerWorld) world, x, y, z)).getHandle();
|
||||
}
|
||||
return new VerticalBlockSample(view.getBottomY(), array);
|
||||
}
|
||||
@@ -268,7 +267,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
|
||||
}
|
||||
|
||||
public void setWorld(ServerWorld world) {
|
||||
public void setWorld(net.minecraft.server.world.ServerWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.implementations.chunk;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -29,7 +30,6 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ public abstract class ChunkRegionMixin {
|
||||
return centerPos.getPos().z;
|
||||
}
|
||||
|
||||
public World terraChunk$getWorld() {
|
||||
return (World) this;
|
||||
public ServerWorld terraChunk$getWorld() {
|
||||
return (ServerWorld) this;
|
||||
}
|
||||
|
||||
// getHandle already added in world/ChunkRegionMixin.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.implementations.chunk;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -31,7 +32,6 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ public abstract class WorldChunkMixin {
|
||||
return ((net.minecraft.world.chunk.Chunk) (Object) this).getPos().z;
|
||||
}
|
||||
|
||||
public World terra$getWorld() {
|
||||
return (World) world;
|
||||
public ServerWorld terra$getWorld() {
|
||||
return (ServerWorld) world;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ public abstract class EntityMixin {
|
||||
teleport(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public World terra$world() {
|
||||
return (World) world;
|
||||
public ServerWorld terra$world() {
|
||||
return (ServerWorld) world;
|
||||
}
|
||||
|
||||
public void terra$sendMessage(String message) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
@@ -48,7 +47,7 @@ import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
@@ -64,7 +63,7 @@ public abstract class ChunkRegionMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerWorld world;
|
||||
private net.minecraft.server.world.ServerWorld world;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@@ -79,9 +78,9 @@ public abstract class ChunkRegionMixin {
|
||||
|
||||
@Inject(at = @At("RETURN"),
|
||||
method = "<init>(Lnet/minecraft/server/world/ServerWorld;Ljava/util/List;Lnet/minecraft/world/chunk/ChunkStatus;I)V")
|
||||
public void injectConstructor(ServerWorld world, List<net.minecraft.world.chunk.Chunk> list, ChunkStatus chunkStatus, int i,
|
||||
public void injectConstructor(net.minecraft.server.world.ServerWorld world, List<net.minecraft.world.chunk.Chunk> list, ChunkStatus chunkStatus, int i,
|
||||
CallbackInfo ci) {
|
||||
this.config = ((World) world).getConfig();
|
||||
this.config = ((ServerWorld) world).getConfig();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -146,8 +145,8 @@ public abstract class ChunkRegionMixin {
|
||||
return centerPos.getPos().z;
|
||||
}
|
||||
|
||||
public World terraWorld$getWorld() {
|
||||
return (World) world;
|
||||
public ServerWorld terraWorld$getWorld() {
|
||||
return (ServerWorld) world;
|
||||
}
|
||||
|
||||
public WorldConfig terraWorld$getConfig() {
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListener;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
@@ -49,7 +48,7 @@ import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||
@@ -58,8 +57,8 @@ import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
@Implements(@Interface(iface = World.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
@Mixin(net.minecraft.server.world.ServerWorld.class)
|
||||
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ServerWorldMixin {
|
||||
private WorldConfig config;
|
||||
@Shadow
|
||||
@@ -81,20 +80,20 @@ public abstract class ServerWorldMixin {
|
||||
net.minecraft.world.gen.chunk.ChunkGenerator chunkGenerator, boolean debugWorld, long seed,
|
||||
List<Spawner> spawners, boolean shouldTickTime, CallbackInfo ci) {
|
||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||
config = ((FabricChunkGeneratorWrapper) chunkGenerator).getPack().toWorldConfig((World) this);
|
||||
config = ((FabricChunkGeneratorWrapper) chunkGenerator).getPack().toWorldConfig((ServerWorld) this);
|
||||
}
|
||||
}
|
||||
|
||||
public Entity terra$spawnEntity(Vector3 location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ServerWorld) (Object) this));
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((net.minecraft.server.world.ServerWorld) (Object) this));
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
((ServerWorld) (Object) this).spawnEntity(entity);
|
||||
((net.minecraft.server.world.ServerWorld) (Object) this).spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
}
|
||||
|
||||
public void terra$setBlockData(int x, int y, int z, BlockState data, boolean physics) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
((ServerWorld) (Object) this).setBlockState(pos, ((FabricBlockState) data).getHandle(), physics ? 3 : 1042);
|
||||
((net.minecraft.server.world.ServerWorld) (Object) this).setBlockState(pos, ((FabricBlockState) data).getHandle(), physics ? 3 : 1042);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
@@ -103,15 +102,15 @@ public abstract class ServerWorldMixin {
|
||||
}
|
||||
|
||||
public int terra$getMaxHeight() {
|
||||
return (((ServerWorld) (Object) this).getBottomY()) + ((ServerWorld) (Object) this).getHeight();
|
||||
return (((net.minecraft.server.world.ServerWorld) (Object) this).getBottomY()) + ((net.minecraft.server.world.ServerWorld) (Object) this).getHeight();
|
||||
}
|
||||
|
||||
public Chunk terra$getChunkAt(int x, int z) {
|
||||
return (Chunk) ((ServerWorld) (Object) this).getChunk(x, z);
|
||||
return (Chunk) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunk(x, z);
|
||||
}
|
||||
|
||||
public BlockState terra$getBlockData(int x, int y, int z) {
|
||||
return new FabricBlockState(((ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z)));
|
||||
return new FabricBlockState(((net.minecraft.server.world.ServerWorld) (Object) this).getBlockState(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
public BlockEntity terra$getBlockState(int x, int y, int z) {
|
||||
@@ -119,7 +118,7 @@ public abstract class ServerWorldMixin {
|
||||
}
|
||||
|
||||
public int terra$getMinHeight() {
|
||||
return ((ServerWorld) (Object) this).getBottomY();
|
||||
return ((net.minecraft.server.world.ServerWorld) (Object) this).getBottomY();
|
||||
}
|
||||
|
||||
public ChunkGenerator terra$getGenerator() {
|
||||
@@ -127,7 +126,7 @@ public abstract class ServerWorldMixin {
|
||||
}
|
||||
|
||||
public BiomeProvider terra$getBiomeProvider() {
|
||||
return ((TerraBiomeSource) ((ServerWorld) (Object) this).getChunkManager().getChunkGenerator().getBiomeSource()).getProvider();
|
||||
return ((TerraBiomeSource) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager().getChunkGenerator().getBiomeSource()).getProvider();
|
||||
}
|
||||
|
||||
public WorldConfig terra$getConfig() {
|
||||
|
||||
Reference in New Issue
Block a user