Skip to content

Commit

Permalink
Added schematic containers and loader. Added world-related classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nan1t committed Jan 24, 2022
1 parent 9f3fa80 commit 864a84b
Show file tree
Hide file tree
Showing 17 changed files with 684 additions and 97 deletions.
1 change: 1 addition & 0 deletions src/main/java/ru/nanit/limbo/LimboConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
public final class LimboConstants {

public static final String VELOCITY_INFO_CHANNEL = "velocity:player_info";
public static final String BRAND_CHANNEL = "minecraft:brand";

private LimboConstants() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public static void initPackets(LimboServer server) {

if (server.getConfig().isUseBrandName()){
PacketPluginMessage pluginMessage = new PacketPluginMessage();
pluginMessage.setChannel("minecraft:brand");
pluginMessage.setChannel(LimboConstants.BRAND_CHANNEL);
pluginMessage.setMessage(server.getConfig().getBrandName());
PACKET_PLUGIN_MESSAGE = PacketSnapshot.of(pluginMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PacketOut;
import ru.nanit.limbo.protocol.registry.Version;
import ru.nanit.limbo.world.DimensionRegistry;
import ru.nanit.limbo.world.dimension.DimensionRegistry;

public class PacketJoinGame implements PacketOut {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ru/nanit/limbo/server/LimboServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import ru.nanit.limbo.connection.ClientChannelInitializer;
import ru.nanit.limbo.connection.ClientConnection;
import ru.nanit.limbo.util.Logger;
import ru.nanit.limbo.world.DimensionRegistry;
import ru.nanit.limbo.world.dimension.DimensionRegistry;

import java.nio.file.Paths;
import java.util.concurrent.ScheduledFuture;
Expand Down
92 changes: 0 additions & 92 deletions src/main/java/ru/nanit/limbo/server/data/Position.java

This file was deleted.

51 changes: 51 additions & 0 deletions src/main/java/ru/nanit/limbo/world/BlockData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2020 Nan1t
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.nanit.limbo.world;

public class BlockData {

private final String state;
private final int id;
private final byte data;

public BlockData(String state, int id, byte data) {
this.state = state;
this.id = id;
this.data = data;
}

public BlockData(String state) {
this(state, 0, (byte) 0);
}

public BlockData(int id, byte data) {
this(null, id, data);
}

public String getState() {
return state;
}

public int getId() {
return id;
}

public byte getData() {
return data;
}
}
45 changes: 45 additions & 0 deletions src/main/java/ru/nanit/limbo/world/BlockEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2020 Nan1t
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.nanit.limbo.world;

import net.kyori.adventure.nbt.CompoundBinaryTag;

public class BlockEntity {

private final Location pos;
private final String id;
private final CompoundBinaryTag data;

public BlockEntity(Location pos, String id, CompoundBinaryTag data) {
this.pos = pos;
this.id = id;
this.data = data;
}

public Location getPos() {
return pos;
}

public String getId() {
return id;
}

public CompoundBinaryTag getData() {
return data;
}
}
34 changes: 34 additions & 0 deletions src/main/java/ru/nanit/limbo/world/BlockMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2020 Nan1t
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.nanit.limbo.world;

import ru.nanit.limbo.protocol.registry.Version;

public final class BlockMap {

public BlockData convert(int id, byte data, Version version) {
// TODO
return null;
}

public BlockData convert(String state, Version version) {
// TODO
return null;
}

}
106 changes: 106 additions & 0 deletions src/main/java/ru/nanit/limbo/world/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright (C) 2020 Nan1t
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.nanit.limbo.world;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.TypeSerializer;

import java.lang.reflect.Type;

public class Location {

private final double x;
private final double y;
private final double z;
private final float yaw;
private final float pitch;

Location(double x, double y, double z, float yaw, float pitch) {
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
}

Location(double x, double y, double z) {
this(x, y, z, 0.0F, 0.0F);
}

public double getX() {
return x;
}

public int getBlockX() {
return (int) x;
}

public double getY() {
return y;
}

public int getBlockY() {
return (int) y;
}

public double getZ() {
return z;
}

public int getBlockZ() {
return (int) z;
}

public float getYaw() {
return yaw;
}

public float getPitch() {
return pitch;
}

public static Location of(double x, double y, double z) {
return new Location(x, y, z);
}

public static Location of(double x, double y, double z, float yaw, float pitch) {
return new Location(x, y, z, yaw, pitch);
}

public static Location pos(int x, int y, int z) {
return new Location(x, y, z);
}

public static class Serializer implements TypeSerializer<Location> {

@Override
public Location deserialize(Type type, ConfigurationNode node) {
double x = node.node("x").getDouble(0);
double y = node.node("y").getDouble(0);
double z = node.node("z").getDouble(0);
float yaw = node.node("yaw").getFloat(0.0F);
float pitch = node.node("pitch").getFloat(0.0F);

return new Location(x, y, z, yaw, pitch);
}

@Override
public void serialize(Type type, @Nullable Location obj, ConfigurationNode node) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.nanit.limbo.world;
package ru.nanit.limbo.world.dimension;

import net.kyori.adventure.nbt.CompoundBinaryTag;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.nanit.limbo.world;
package ru.nanit.limbo.world.dimension;

import net.kyori.adventure.nbt.CompoundBinaryTag;
import net.kyori.adventure.nbt.ListBinaryTag;
Expand Down
Loading

0 comments on commit 864a84b

Please sign in to comment.