Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Trouble registering packets
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
epicMinecrafter666Xx

Trouble registering packets

By epicMinecrafter666Xx, August 26, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

epicMinecrafter666Xx    0

epicMinecrafter666Xx

epicMinecrafter666Xx    0

  • Tree Puncher
  • epicMinecrafter666Xx
  • Members
  • 0
  • 7 posts
Posted August 26, 2020

 

I keep getting this message

"[19:05:18] [Render thread/WARN] [minecraft/ClientPlayNetHandler]: Unknown custom packet identifier: morecontent:main"

when i send a packet instead of doing whatever that packet should do.

 

here are the classes

 

PacketHandler and the packet

 

public class PacketHandler {
    private static final String PROTOCOL_VERSION = "1";
    public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
            new ResourceLocation(MoreContent.MOD_ID, "main"),
            () -> PROTOCOL_VERSION,
            PROTOCOL_VERSION::equals,
            PROTOCOL_VERSION::equals
    );


    public static void register() {
        int ID = 0;
        INSTANCE.registerMessage(++ID, AnimationPacket.class, AnimationPacket::encode, AnimationPacket::new, AnimationPacket::handle);
    }
}
public class AnimationPacket {
    private int entityId;
    private int animationIndex;



    AnimationPacket(final PacketBuffer packetBuffer) {
        this.entityId = packetBuffer.readInt();
        this.animationIndex = packetBuffer.readInt();
    }

    public AnimationPacket(int entityId, int index) {
        this.entityId = entityId;
        this.animationIndex = index;
    }

    void encode(final PacketBuffer packetBuffer) {
        packetBuffer.writeInt(this.entityId);
        packetBuffer.writeInt(this.animationIndex);
    }


    public static void handle(AnimationPacket msg, Supplier<NetworkEvent.Context> ctx) {
        NetworkEvent.Context context = ctx.get();
        if (context.getDirection().getReceptionSide() == LogicalSide.SERVER) {
            ctx.get().enqueueWork(() -> {
                Entity entity = Objects.requireNonNull(context.getSender()).world.getEntityByID(msg.entityId);
                if(entity instanceof AnimatedEntity) {
                    
                    ((AnimatedEntity) entity).spawnExplosionParticle();
                }
                });
                ctx.get().setPacketHandled(true);
        }
    }
}

 

Main

@Mod("morecontent")
@Mod.EventBusSubscriber(
        modid = "morecontent",
        bus = Mod.EventBusSubscriber.Bus.MOD
)
public class MoreContent {
    public static MoreContent INSTANCE;
    public static final String MOD_ID = "morecontent";
    public static final Logger LOGGER = LogManager.getLogger("morecontent");

    public MoreContent() {
        INSTANCE = this;
        MinecraftForge.EVENT_BUS.register(this);
        PacketHandler.register();
        new RegistryEvents();

        MinecraftForge.EVENT_BUS.register(EventHandler.class);

    }

    @SubscribeEvent
    public void setupCommon(FMLCommonSetupEvent event) {
        DeferredWorkQueue.runLater(() -> {
            RegistryEvents.addBiomeTypes();
            RegistryEvents.registerBiomesToDictionary();

        });
    }

    @SubscribeEvent
    public static void clientSetup(FMLClientSetupEvent event) {
        RenderHandler.registerEntityRenders();
        RenderHandler.registerBlockRenders();
    }
}

 

this is how i send the packet:

PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new AnimationPacket(this.getEntityId(), 1));

  • Quote

Share this post


Link to post
Share on other sites

epicMinecrafter666Xx    0

epicMinecrafter666Xx

epicMinecrafter666Xx    0

  • Tree Puncher
  • epicMinecrafter666Xx
  • Members
  • 0
  • 7 posts
Posted August 26, 2020 (edited)

Updates

 

I noticed that i had to register them in the FMLCommonSetupEvent but now when i send a packet i get a crash along with this message

 

[19:51:22] [Server thread/ERROR] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Attempted to register channel morecontent:main even though registry phase is over


"[19:51:22] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
java.lang.ExceptionInInitializerError: null

Edited August 26, 2020 by epicMinecrafter666Xx
  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2407

Draco18s

Draco18s    2407

  • Reality Controller
  • Draco18s
  • Members
  • 2407
  • 15945 posts
Posted August 26, 2020

This:

35 minutes ago, epicMinecrafter666Xx said:

@Mod.EventBusSubscriber( modid = "morecontent", bus = Mod.EventBusSubscriber.Bus.MOD )

This:

35 minutes ago, epicMinecrafter666Xx said:

MinecraftForge.EVENT_BUS.register(this);

And this:

35 minutes ago, epicMinecrafter666Xx said:

MinecraftForge.EVENT_BUS.register(EventHandler.class);

 

 

All do the same thing (the first two literally do except for different busses and the only event methods you have are all FORGE bus events; the second does the same thing, but to a different class).

Pick one.

 

Then there's this:

36 minutes ago, epicMinecrafter666Xx said:

new RegistryEvents();

Which either also does the same thing or does nothing (you didn't share that class). And is either way confusing.

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

epicMinecrafter666Xx    0

epicMinecrafter666Xx

epicMinecrafter666Xx    0

  • Tree Puncher
  • epicMinecrafter666Xx
  • Members
  • 0
  • 7 posts
Posted August 26, 2020

RegistryEvents is where i register the blocks, items and biomes

 

@Mod.EventBusSubscriber(
        bus = Bus.MOD
)
public class RegistryEvents {


    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MoreContent.MOD_ID);
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MoreContent.MOD_ID);
    public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, MoreContent.MOD_ID);

    @SubscribeEvent
    public static void onEntityRegistry(Register<EntityType<?>> event) {
        ModEntityTypes.register(event.getRegistry());
    }


    public RegistryEvents() {
        BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
        ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        BIOMES.register(FMLJavaModLoadingContext.get().getModEventBus());
    }

    //*************************ITEMS****************************************************************//

     public static final RegistryObject<Item> ENDER_BEAST_ARCHER = ITEMS.register("ender_beast_archer_spawn_egg", () -> new SpawnEggItem(ModEntityTypes.ENDERBEASTARCHER, 3286365, 4859178, (new Item.Properties()).group(ItemGroup.MISC)));

    //BLOCKITEMS

    public static final RegistryObject<Item> FIERCE_SAND_ITEM = ITEMS.register("fierce_sand", () -> new BlockItem(RegistryEvents.FIERCE_SAND.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
    public static final RegistryObject<Item> FIERCE_SANDSTONE_ITEM = ITEMS.register("fierce_sandstone", () -> new BlockItem(RegistryEvents.FIERCE_SANDSTONE.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
    public static final RegistryObject<Item> FOSSILS_ITEM = ITEMS.register("fossils", () -> new BlockItem(RegistryEvents.FOSSILS.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
    public static final RegistryObject<Item> ERODED_STONE_ITEM = ITEMS.register("eroded_stone", () -> new BlockItem(RegistryEvents.ERODED_STONE.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));

    public static final RegistryObject<Item> DEAD_GRASS_ITEM = ITEMS.register("dead_grass", () -> new BlockItem(RegistryEvents.DEAD_GRASS.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> DESERTS_HOPE_ITEM = ITEMS.register("deserts_hope", () -> new BlockItem(RegistryEvents.DESERTS_HOPE.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));

    public static final RegistryObject<Item> SPIKED_VINE_ITEM = ITEMS.register("spiked_vine", () -> new BlockItem(RegistryEvents.SPIKED_VINE.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> SPIKY_FRUIT_ITEM = ITEMS.register("spiky_fruit", () -> new Item(new Item.Properties().group(ItemGroup.FOOD).food(ModFoods.SPIKY_FRUIT)));
    public static final RegistryObject<Item> GOLDEN_SPIKY_FRUIT_ITEM = ITEMS.register("golden_spiky_fruit", () -> new Item(new Item.Properties().group(ItemGroup.FOOD).food(ModFoods.GOLDEN_SPIKY_FRUIT)));


    /////
    public static final RegistryObject<Item> LARGE_ACACIA_TORCH_ITEM = ITEMS.register("large_acacia_torch", () -> new BlockItem(RegistryEvents.LARGE_ACACIA_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> LARGE_BIRCH_TORCH_ITEM = ITEMS.register("large_birch_torch", () -> new BlockItem(RegistryEvents.LARGE_BIRCH_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> LARGE_DARK_OAK_TORCH_ITEM = ITEMS.register("large_dark_oak_torch", () -> new BlockItem(RegistryEvents.LARGE_DARK_OAK_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> LARGE_JUNGLE_TORCH_ITEM = ITEMS.register("large_jungle_torch", () -> new BlockItem(RegistryEvents.LARGE_JUNGLE_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> LARGE_OAK_TORCH_ITEM = ITEMS.register("large_oak_torch", () -> new BlockItem(RegistryEvents.LARGE_OAK_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
    public static final RegistryObject<Item> LARGE_SPRUCE_TORCH_ITEM = ITEMS.register("large_spruce_torch", () -> new BlockItem(RegistryEvents.LARGE_SPRUCE_TORCH.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));


    //*************************BLOCKS***************************************************************//

    public static final RegistryObject<Block> FIERCE_SAND = BLOCKS.register("fierce_sand", () -> new SandBlock(16760677, Block.Properties.create(Material.SAND, MaterialColor.SAND).hardnessAndResistance(0.5F).harvestTool(ToolType.SHOVEL).sound(SoundType.SAND)));
    public static final RegistryObject<Block> FIERCE_SANDSTONE = BLOCKS.register("fierce_sandstone", () -> new Block(Block.Properties.create(Material.ROCK, MaterialColor.SAND).hardnessAndResistance(0.9F).harvestTool(ToolType.PICKAXE).sound(SoundType.STONE)));
    public static final RegistryObject<Block> FOSSILS = BLOCKS.register("fossils", () -> new Block(Block.Properties.create(Material.ROCK, MaterialColor.DIRT).hardnessAndResistance(1.0F).harvestTool(ToolType.PICKAXE).sound(SoundType.STONE)));
    public static final RegistryObject<Block> ERODED_STONE = BLOCKS.register("eroded_stone", () -> new Block(Block.Properties.create(Material.ROCK, MaterialColor.DIRT).hardnessAndResistance(1.0F).harvestTool(ToolType.PICKAXE).sound(SoundType.STONE)));

    public static final RegistryObject<Block> SPIKED_VINE = BLOCKS.register("spiked_vine", () -> new SpikedVineBlock(Block.Properties.create(Material.PLANTS, MaterialColor.GRASS).hardnessAndResistance(0.5F).harvestTool(ToolType.AXE).sound(SoundType.PLANT)));
    public static final RegistryObject<Block> SPIKY_FRUIT = BLOCKS.register("spiky_fruit", () -> new SpikyFruitBlock(Block.Properties.create(Material.PLANTS, MaterialColor.ORANGE_TERRACOTTA).hardnessAndResistance(0.5F).harvestTool(ToolType.AXE).sound(SoundType.PLANT)));
    public static final RegistryObject<Block> DEAD_GRASS = BLOCKS.register("dead_grass", () -> new DeserticBushBlock(Block.Properties.create(Material.PLANTS, MaterialColor.GOLD).zeroHardnessAndResistance().sound(SoundType.PLANT).doesNotBlockMovement()));
    public static final RegistryObject<Block> DESERTS_HOPE = BLOCKS.register("deserts_hope", () -> new FlowerBlock(Effects.REGENERATION, 8, Block.Properties.create(Material.PLANTS).zeroHardnessAndResistance().sound(SoundType.PLANT).doesNotBlockMovement()));

    ////
    public static final RegistryObject<Block> POTTED_DESERTS_HOPE = BLOCKS.register("potted_deserts_hope", () -> new FlowerPotBlock(RegistryEvents.DESERTS_HOPE.get(), Block.Properties.create(Material.MISCELLANEOUS).zeroHardnessAndResistance().notSolid()));

    public static final RegistryObject<Block> LARGE_ACACIA_TORCH = BLOCKS.register("large_acacia_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> LARGE_BIRCH_TORCH = BLOCKS.register("large_birch_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> LARGE_DARK_OAK_TORCH = BLOCKS.register("large_dark_oak_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> LARGE_JUNGLE_TORCH = BLOCKS.register("large_jungle_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> LARGE_OAK_TORCH = BLOCKS.register("large_oak_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD)));
    public static final RegistryObject<Block> LARGE_SPRUCE_TORCH = BLOCKS.register("large_spruce_torch", () -> new LargeTorchBlock(Block.Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0.75F).sound(SoundType.WOOD)));

    
    ////////BIOMES/////////
    
    public static final RegistryObject<Biome> RAMMERS_VALLEY = BIOMES.register("rammers_valley", RammersValleyBiome::new);

    public static void registerBiomesToDictionary() {
        BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(RAMMERS_VALLEY.get(), 30));
    }

    public static void addBiomeTypes() {
        BiomeDictionary.addTypes(RAMMERS_VALLEY.get(), BiomeDictionary.Type.DRY, BiomeDictionary.Type.SANDY, BiomeDictionary.Type.OVERWORLD);
    }
}

 

apparently if i delete new RegistryEvents();  Minecraft throws me this: More Content (more content) encountered an error during the load_registries event phase

 

the other thing you pointed out were infact useless.

 

@Mod("morecontent")
@Mod.EventBusSubscriber(modid = "morecontent", bus = Mod.EventBusSubscriber.Bus.MOD)
public class MoreContent {
    public static MoreContent INSTANCE;
    public static final String MOD_ID = "morecontent";
    public MoreContent() {
        INSTANCE = this;
        new RegistryEvents();
    }

    @SubscribeEvent
    public void setupCommon(FMLCommonSetupEvent event) {
        PacketHandler.register();
        DeferredWorkQueue.runLater(() -> {
            RegistryEvents.addBiomeTypes();
            RegistryEvents.registerBiomesToDictionary();

        });
    }

    @SubscribeEvent
    public static void clientSetup(FMLClientSetupEvent event) {
        RenderHandler.registerEntityRenders();
        RenderHandler.registerBlockRenders();
    }
}

 

i registered the packets on FMLCommonSetup and i get a crash when i use a packet along with this

 

[19:51:22] [Server thread/ERROR] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Attempted to register channel morecontent:main even though registry phase is over


"[19:51:22] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
java.lang.ExceptionInInitializerError: null

 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2407

Draco18s

Draco18s    2407

  • Reality Controller
  • Draco18s
  • Members
  • 2407
  • 15945 posts
Posted August 26, 2020

I understand your issue with with the networking. However I'm pointing out that you're hurling all of your classes at the event bus four different ways and you don't need to do that.

 

And I was right:

1 hour ago, epicMinecrafter666Xx said:

BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());

ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());

BIOMES.register(FMLJavaModLoadingContext.get().getModEventBus());

You're doing more registration, yet another way.

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      I am getting an error

      By diesieben07 · Posted 27 minutes ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • Keigo
      I am getting an error

      By Keigo · Posted 28 minutes ago

      there  
    • Keigo
      I am getting an error

      By Keigo · Posted 29 minutes ago

      debug.log
    • diesieben07
      Can't download pixelmon

      By diesieben07 · Posted 30 minutes ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • diesieben07
      Task :runClient FAILED | Build failed with an exeption.

      By diesieben07 · Posted 30 minutes ago

      1.14 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
  • Topics

    • Keigo
      6
      I am getting an error

      By Keigo
      Started 3 hours ago

    • shimmy360@gmail.com
      1
      Can't download pixelmon

      By shimmy360@gmail.com
      Started 39 minutes ago

    • IchBinEinToast
      1
      Task :runClient FAILED | Build failed with an exeption.

      By IchBinEinToast
      Started 43 minutes ago

    • CrooKameron
      1
      my all mod's didn't working :(

      By CrooKameron
      Started 17 hours ago

    • Luis_ST
      1
      [1.16.5] [Bug?] Enchantments can Apply to all Tools

      By Luis_ST
      Started 2 hours ago

  • Who's Online (See full list)

    • LexManos
    • Novârch
    • zOnlyKroks
    • Zemelua
    • diesieben07
    • Keigo
    • shimmy360@gmail.com
    • Choonster
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Trouble registering packets
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community