mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
fix: generate populators in every chunk
This commit is contained in:
parent
ac66fc7d69
commit
3a28551e97
@ -1,11 +1,13 @@
|
|||||||
package com.dfsek.terra.minestom;
|
package com.dfsek.terra.minestom;
|
||||||
|
|
||||||
|
import com.dfsek.terra.minestom.world.MinestomProtoWorld;
|
||||||
import com.dfsek.terra.minestom.world.TerraMinestomWorldBuilder;
|
import com.dfsek.terra.minestom.world.TerraMinestomWorldBuilder;
|
||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.coordinate.Pos;
|
import net.minestom.server.coordinate.Pos;
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
||||||
|
import net.minestom.server.event.player.PlayerSpawnEvent;
|
||||||
import net.minestom.server.instance.Instance;
|
import net.minestom.server.instance.Instance;
|
||||||
|
|
||||||
|
|
||||||
@ -30,10 +32,13 @@ public class TerraMinestomExample {
|
|||||||
|
|
||||||
MinecraftServer.getGlobalEventHandler().addListener(AsyncPlayerConfigurationEvent.class, event -> {
|
MinecraftServer.getGlobalEventHandler().addListener(AsyncPlayerConfigurationEvent.class, event -> {
|
||||||
event.setSpawningInstance(instance);
|
event.setSpawningInstance(instance);
|
||||||
event.getPlayer().setGameMode(GameMode.CREATIVE);
|
|
||||||
event.getPlayer().setRespawnPoint(new Pos(0.0, 100.0, 0.0));
|
event.getPlayer().setRespawnPoint(new Pos(0.0, 100.0, 0.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MinecraftServer.getGlobalEventHandler().addListener(PlayerSpawnEvent.class, event -> {
|
||||||
|
event.getPlayer().setGameMode(GameMode.SPECTATOR);
|
||||||
|
});
|
||||||
|
|
||||||
server.start("localhost", 25565);
|
server.start("localhost", 25565);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,9 @@ public class MinestomProtoWorld implements ProtoWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
|
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
|
||||||
int globalX = this.x * 16 + x;
|
int cx = x >> 4;
|
||||||
int globalZ = this.z * 16 + z;
|
int cz = y >> 4;
|
||||||
modifier.setBlock(globalX, y, globalZ, (Block) data.getHandle());
|
modifier.setBlock(x, y, z, (Block) data.getHandle());
|
||||||
int cx = globalX >> 4;
|
|
||||||
int cz = globalZ >> 4;
|
|
||||||
cache.at(cx, cz)
|
cache.at(cx, cz)
|
||||||
.setBlock(x & 15, y, z & 15, data);
|
.setBlock(x & 15, y, z & 15, data);
|
||||||
}
|
}
|
||||||
@ -71,7 +69,7 @@ public class MinestomProtoWorld implements ProtoWorld {
|
|||||||
public BlockState getBlockState(int x, int y, int z) {
|
public BlockState getBlockState(int x, int y, int z) {
|
||||||
int chunkX = x >> 4;
|
int chunkX = x >> 4;
|
||||||
int chunkZ = z >> 4;
|
int chunkZ = z >> 4;
|
||||||
return cache.at(chunkX + this.x, chunkZ + this.z)
|
return cache.at(chunkX, chunkZ)
|
||||||
.getBlock(x & 15, y, z & 15);
|
.getBlock(x & 15, y, z & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user