Jump to content

[SOLVED][1.8.9 ] Teleportation from a packet handler


heero

Recommended Posts

Hi,

 

What I want : Teleport the player when I hit the H key.

What I get : That work, but I get some strange warnings

 

My warnings :

00:34:37] [Client thread/INFO]: [CHAT] Player447 has just earned the achievement [Taking Inventory]
[00:34:43] [Netty Server IO #1/WARN]: ****************************************
[00:34:43] [Netty Server IO #1/WARN]: * There is an attempt to load a chunk (4,-1) in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager$PlayerInstance.<init>(PlayerManager.java:395)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager.getPlayerInstance(PlayerManager.java:106)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager.addPlayer(PlayerManager.java:150)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.ServerConfigurationManager.preparePlayer(ServerConfigurationManager.java:269)...
[00:34:43] [Netty Server IO #1/WARN]: ****************************************
[00:34:43] [server thread/WARN]: ****************************************
[00:34:43] [server thread/WARN]: * There is an attempt to load a chunk (-5,6) in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:43] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:43] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:43] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:99)
[00:34:43] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:200)
[00:34:43] [server thread/WARN]: *  at net.minecraft.world.World.getChunkFromChunkCoords(World.java:336)
[00:34:43] [server thread/WARN]: *  at net.minecraft.world.World.getChunkFromBlockCoords(World.java:328)...
[00:34:43] [server thread/WARN]: ****************************************
[00:34:43] [Netty Server IO #1/WARN]: ****************************************
[00:34:43] [Netty Server IO #1/WARN]: * There is an attempt to load a chunk (8,0) in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager$PlayerInstance.<init>(PlayerManager.java:395)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager.getPlayerInstance(PlayerManager.java:106)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager.addPlayer(PlayerManager.java:150)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.ServerConfigurationManager.preparePlayer(ServerConfigurationManager.java:269)...
[00:34:43] [Netty Server IO #1/WARN]: ****************************************
[00:34:43] [Netty Server IO #1/WARN]: ****************************************
[00:34:43] [Netty Server IO #1/WARN]: * There is an attempt to load a chunk (-2,- in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager$PlayerInstance.<init>(PlayerManager.java:395)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager.getPlayerInstance(PlayerManager.java:106)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.PlayerManager.addPlayer(PlayerManager.java:150)
[00:34:43] [Netty Server IO #1/WARN]: *  at net.minecraft.server.management.ServerConfigurationManager.preparePlayer(ServerConfigurationManager.java:269)...
[00:34:43] [Netty Server IO #1/WARN]: ****************************************
[00:34:44] [server thread/WARN]: ****************************************
[00:34:44] [server thread/WARN]: * There is an attempt to load a chunk (-10,4) in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:99)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:200)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.World.getChunkFromChunkCoords(World.java:336)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:376)...
[00:34:44] [server thread/WARN]: ****************************************
[00:34:44] [server thread/WARN]: ****************************************
[00:34:44] [server thread/WARN]: * There is an attempt to load a chunk (-1,-12) in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:99)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:200)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.World.getChunkFromChunkCoords(World.java:336)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:376)...
[00:34:44] [server thread/WARN]: ****************************************
[00:34:44] [server thread/WARN]: ****************************************
[00:34:44] [server thread/WARN]: * There is an attempt to load a chunk (-8,12) in di    >mension 3 that is already being loaded. This will cause weird chunk breakages.
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:152)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:129)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:99)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:200)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.World.getChunkFromChunkCoords(World.java:336)
[00:34:44] [server thread/WARN]: *  at net.minecraft.world.WorldServer.updateBlocks(WorldServer.java:376)...
[00:34:44] [server thread/WARN]: ****************************************

My code :

// ExampleMod
@Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
public class ExampleMod {
    public static final String MODID = "examplemod";
    public static final String VERSION = "1.0";
    public static final SimpleNetworkWrapper packetPipeline = NetworkRegistry.INSTANCE.newSimpleChannel("test");

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        GameRegistry.registerItem(new ItemTest().setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("item_test"), "item_test");

        GameRegistry.registerWorldGenerator(new WorldGeneratorTest(), 0);
        DimensionManager.registerProviderType(3, WorldProviderSurface.class, false);
        DimensionManager.registerDimension(3, 3);

        packetPipeline.registerMessage(HandlerTeleportation.class, PacketTeleportation.class, 0, Side.SERVER);
    }

    private class WorldGeneratorTest implements IWorldGenerator {
        @Override
        public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
        }
    }

    public class ItemTest extends Item {
        @Override
        public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
            if (!worldIn.isRemote) {
                return itemStackIn;
            }

            packetPipeline.sendToServer(new PacketTeleportation());

            return itemStackIn;
        }
    }
}


// HandlerTeleportation
public class HandlerTeleportation implements IMessageHandler<PacketTeleportation, IMessage> {
    @Override
    public IMessage onMessage(PacketTeleportation message, MessageContext ctx) {
        EntityPlayerMP player = ctx.getServerHandler().playerEntity;

        player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 3, new TeleporterTest(MinecraftServer.getServer().worldServerForDimension(3)));
        return null;
    }
}

// PacketTeleportation
public class PacketTeleportation implements IMessage {
    @Override
    public void fromBytes(ByteBuf buffer) {
    }

    @Override
    public void toBytes(ByteBuf buffer) {
    }
}

// TeleporterTest
public class TeleporterTest extends Teleporter {
    public TeleporterTest(WorldServer par1WorldServer) {
        super(par1WorldServer);
    }

    @Override
    public void placeInPortal(Entity entity, float rotationYaw) {
        entity.setPositionAndUpdate(0, 100, 0);
    }

    @Override
    public void removeStalePortalLocations(long par1) {
    }
}

 

The code doesn't show the key binding part, because it's not necesary to reproduce de bug.

If I try to teleport from the Item function itself, there is no warning.

Link to comment
Share on other sites

It may or may not be the source of the issue, but packet handlers are run on a separate thread where you can't safely interact with normal Minecraft classes. You need to schedule a task to run on the main thread, as explained here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.