• Recently Browsing

    No registered users viewing this page.

  • Posts

    • private void setup(final FMLCommonSetupEvent event) { PacketHandler.register(); } Should I do it just like this? (The method is in Arknights.java) I'm new to modding... And the problem becomes more and more complicated... I test the mod with out packet handler but it still tells me "Received empty payload on channel fml:handshake". I also test the method leftclick in my item. I add "System.out.print("A"); " to the method, and when I left click, an "A" prints to the terminal. Does it means the packet is succesfully sent? If so, why it doesn't spawn an arrow? Could you tell me how to spawn entities properly?  
    • Yep, PR: https://github.com/MinecraftForge/MinecraftForge/pull/6421 I’m currently working on the Forge docs for the config system, here’s my tutorial on them in the meantime.
    • I don't know how this is so hard to understand. The registration of your network channel must happen in FMLCommonSetupEvent. You are still not doing that. Now you are calling newSimpleChannel from the constructor of PacketHandler, which you call from the constructor of Arknights. This is not in FMLCommonSetupEvent.
    • yea... but can I register custom BiomeProvider with this method? Only settings
    • Maybe I need an example... The former code reference ProjectE, and it use the static initializer. And the documentation is static too. I try to register it in a not static initializer (maybe in a wrong way), and it doesn't work. When I left click, nothing has happened.   By the way, the thrown error appears when I join the world, and when I delete the packet registry, it still appears.  Here is the code: PacketHandler.java package arknights.network; import arknights.network.packets.LeftClickPacket; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; public final class PacketHandler { private static final String PROTOCOL_VERSION = Integer.toString(1); public SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel( new ResourceLocation("corruption","main") ,() -> PROTOCOL_VERSION , PROTOCOL_VERSION::equals , PROTOCOL_VERSION::equals); int id = 0; public void register(){ HANDLER.registerMessage(id++, LeftClickPacket.class, LeftClickPacket::encode, LeftClickPacket::decode, LeftClickPacket.Handler::handle); } }   Arknights.java Here is the whole class. I think there is something not so relevant, so I provide a simple one. public class Arknights { //something //code I add public static final PacketHandler PACKETHANDLER = new PacketHandler(); public Arknights() { // Register methods for modloading //code I add PACKETHANDLER.register(); // Register ourselves for server and other game events we are interested in }   BaseItem.java package arknights.item; import arknights.Arknights; import arknights.network.PacketHandler; import arknights.network.packets.LeftClickPacket; import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; public class BaseItem extends Item { public BaseItem(Properties p_i48487_1_) { super(p_i48487_1_); MinecraftForge.EVENT_BUS.addListener(this::emptyLeftClick); } public void emptyLeftClick(PlayerInteractEvent.LeftClickEmpty event){ Arknights.PACKETHANDLER.HANDLER.sendToServer(new LeftClickPacket()); } public void leftClick(LivingEntity livingEntity, World worldIn, ItemStack stack){ } }  
  • Topics

  • Who's Online (See full list)