• Recently Browsing

    No registered users viewing this page.

  • Posts

    • 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){ } }  
    • Okay, that is definitely a misbehaving ad. Again: Please show the address bar. Yours is not showing.
    • I have attached a short screen capture. Bildschirmvideo aufnehmen 2020-01-22 um 11.13.20.mp4
    • Then you are still registering your network channel in a static initializer.
    • You have to keep in mind that Minecraft as Mojang releases it is obfuscated. The code is then deobfuscated into so called SRG names (unique identifiers for methods and fields, such as field_43112_a). These SRG names are then named by the community. So yes, names are not always ideal. As for renderButton in Widget: This name seems to actually come from Mojang and is probably a result of the refactoring of introducing the Widget class.   But in general yes, the GUI code in Minecraft is pretty messy. GUIs are hard.
  • Topics

  • Who's Online (See full list)