Flat world
This commit is contained in:
@@ -15,6 +15,7 @@ import mc.core.*;
|
||||
import mc.core.network.CSPacket;
|
||||
import mc.core.network.proto_125.netty.wrappers.WrapperNetChannel;
|
||||
import mc.core.network.proto_125.packets.*;
|
||||
import mc.core.world.World;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -28,6 +29,8 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
private Config config;
|
||||
@Autowired
|
||||
private PlayerManager playerManager;
|
||||
@Autowired
|
||||
private World world;
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext context) throws Exception {
|
||||
@@ -66,7 +69,6 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
}
|
||||
|
||||
public void onLoginPacket(Channel channel, LoginPacket packet) {
|
||||
final Location spawnLoc = new Location(0, 6, 0);
|
||||
Player player;
|
||||
|
||||
Optional<Player> optPlayer = playerManager.getPlayer(packet.getPlayerName());
|
||||
@@ -80,7 +82,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
}
|
||||
} else {
|
||||
player = playerManager.createPlayer(packet.getPlayerName());
|
||||
player.setLocation(spawnLoc);
|
||||
player.setLocation(world.getSpawn());
|
||||
player.setLook(new Look(0f, 0f));
|
||||
}
|
||||
|
||||
@@ -95,7 +97,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
|
||||
// send Spawn position
|
||||
SpawnPositionPacket spawnPkt = new SpawnPositionPacket();
|
||||
spawnPkt.setLocation(spawnLoc);
|
||||
spawnPkt.setLocation(world.getSpawn());
|
||||
channel.write(spawnPkt);
|
||||
|
||||
// send Player abilities
|
||||
@@ -124,6 +126,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
ChunkDataPacket chDataPkt = new ChunkDataPacket();
|
||||
chDataPkt.setX(0);
|
||||
chDataPkt.setZ(0);
|
||||
chDataPkt.setChunk(world.getChunk(0, 0));
|
||||
chDataPkt.setNeedInitChunk(true);
|
||||
chDataPkt.setYMin(1);
|
||||
chDataPkt.setYMax(0);
|
||||
|
||||
Reference in New Issue
Block a user