Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Dying results in chunks not reloading correctly #78

Open
mworzala opened this issue Nov 25, 2023 · 0 comments
Open

Dying results in chunks not reloading correctly #78

mworzala opened this issue Nov 25, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mworzala
Copy link

Walk away from spawn and kill yourself, the chunks around spawn will not be sent correctly.

package net.minestom.demo.abc;

import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player;
import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.extras.MojangAuth;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.InstanceManager;
import net.minestom.server.instance.block.Block;
import net.minestom.server.tag.Tag;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.world.DimensionType;

public class Main {
    public static void main(String[] args) {
        // Initialize
        MinecraftServer minecraftServer = MinecraftServer.init();
        MinecraftServer.setBrandName("Prismarine");
        InstanceManager instanceManager = MinecraftServer.getInstanceManager();
        MojangAuth.init();

        // Define, Register and Generate a Dimension
        DimensionType lobby = DimensionType.builder(NamespaceID.from("prismarine:lobby"))
                .ambientLight(2.0f)
                .build();
        MinecraftServer.getDimensionTypeManager().addDimension(lobby);

        InstanceContainer instanceContainer = instanceManager.createInstanceContainer(lobby);
        instanceContainer.setGenerator(unit ->
                unit.modifier().fillHeight(0, 2, Block.STONE));
        Tag<String> tag = Tag.String("lobby");
        instanceContainer.setTag(tag, "lobby");
        instanceManager.registerInstance(instanceContainer);
        ////instanceContainer.saveChunksToStorage();

        // Callback from joining to specify the spawning instance and spawn position
        GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
        globalEventHandler.addListener(PlayerLoginEvent.class, playerLoginEvent -> {
            final Player player = playerLoginEvent.getPlayer();
            playerLoginEvent.setSpawningInstance(instanceContainer);
            player.setRespawnPoint(new Pos(0, 10, 0));
            player.setGameMode(GameMode.SURVIVAL);
        });


        // Register Commands
        MinecraftServer.getCommandManager().register(new Command("kill") {
            {
                setDefaultExecutor((sender, context) -> {
                    sender.asPlayer().kill();
                });
            }
        });

        // > kill command im using for referance
        //public KillCommand() {
        //  super("kill", "suicide");
        //
        //  setDefaultExecutor(((sender, context) -> {
        //      sender.sendMessage("Usage: /kill");
        //  }));
        //
        //  addSyntax((sender, context) -> {
        //      if (sender instanceof Player)
        //          ((Player) sender).kill();
        //  });
        //}
        // < end

        // Start the server
        minecraftServer.start("0.0.0.0", 25565);
    }
}
@mworzala mworzala added the bug Something isn't working label Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant