Jump to content

Recommended Posts

Posted

I was following a tutorial and another forum post on here and I have been trying to get potion effects to activate with the press of a button and every time i try a single player world the game crashes

Key,KeyBinding,Packet Classes

public class key {


        private final int key;

        public key(int keyIn) {
            this.key = keyIn;
        }

        public static void encode(key msg, PacketBuffer buf) {
            buf.writeInt(msg.key);
        }

        public static key decode(PacketBuffer buf) {
            return new key(buf.readInt());
        }

        public static void handle(key msg, Supplier<NetworkEvent.Context> ctx) {
            if(msg.key==0) {
                ctx.get().enqueueWork(() -> {
                    ServerPlayerEntity sender = ctx.get().getSender();
                    sender.addPotionEffect(new EffectInstance(Effect.get(5),20)); });
            }
            ctx.get().setPacketHandled(true);
        }
    }
@Mod.EventBusSubscriber(modid = DungeonWars.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class keyBind {
    static KeyBinding[] keyBindings = new KeyBinding[]{new KeyBinding("key.strong", KeyConflictContext.UNIVERSAL, InputMappings.Type.KEYSYM, 33, "key.categories.strong")};


   static Boolean keyPress = false;

    @SubscribeEvent
    public static void onTick(TickEvent.ClientTickEvent event) {
        if (keyPress && !keyBindings[0].isKeyDown()) {
            keyPress = false;
        }
    }

    @SubscribeEvent
    public static void onInput(InputEvent.KeyInputEvent event) {
        if (event.getKey() == keyBindings[0].getKey().getKeyCode() ) {
           // CrudeTechMod.log("pressed");
            Packets.INSTANCE.sendToServer(new key(0));
            keyPress = true;
        }
    }

    public static void registerKeyBindings() {
        for (int i = 0; i < keyBindings.length; i++) {
            ClientRegistry.registerKeyBinding(keyBindings[i]);
        }
    }
public class Packets {
    private static final String PROTOCOL_VERSION = "1";
    public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
            new ResourceLocation(DungeonWars.MOD_ID, "main"),
            () -> PROTOCOL_VERSION,
            PROTOCOL_VERSION::equals,
            PROTOCOL_VERSION::equals
    );
    public static int i=0;
}
//(Main)

    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
        Packets.INSTANCE.registerMessage(Packets.i++, key.class, key::encode, key::decode, key::handle);
     }

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client
        keyBind.registerKeyBindings();
        //ClientRegistry.registerKeyBinding(keybinding);

    }

Log

java.lang.RuntimeException: Why did the advancements not load yet?!
	at net.minecraftforge.common.AdvancementLoadFix.loadVisibility(AdvancementLoadFix.java:51) ~[?:?] {re:classloading}
	at net.minecraft.advancements.PlayerAdvancements.load(PlayerAdvancements.java:157) ~[?:?] {re:classloading}
	at net.minecraft.advancements.PlayerAdvancements.<init>(PlayerAdvancements.java:65) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerList.getPlayerAdvancements(PlayerList.java:806) ~[?:?] {re:classloading}
	at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:167) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:395) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:120) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:64) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:246) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:152) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:903) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
	at net.minecraftforge.common.AdvancementLoadFix.loadVisibility(AdvancementLoadFix.java:51)
	at net.minecraft.advancements.PlayerAdvancements.load(PlayerAdvancements.java:157)
	at net.minecraft.advancements.PlayerAdvancements.<init>(PlayerAdvancements.java:65)
	at net.minecraft.server.management.PlayerList.getPlayerAdvancements(PlayerList.java:806)
	at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:167)
	at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:395)
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:120)
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:64)
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:246)

-- Ticking connection --
Details:
	Connection: net.minecraft.network.NetworkManager@2751f8c8
Stacktrace:
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:152)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:903)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662)
	at java.lang.Thread.run(Thread.java:748)

-- System Details --
Details:
	Minecraft Version: 1.15.2
	Minecraft Version ID: 1.15.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_251, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 762228824 bytes (726 MB) / 2077753344 bytes (1981 MB) up to 3799515136 bytes (3623 MB)
	CPUs: 8
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 5.1.0+69+master.79f13f7
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-2.2.0-service.jar eventbus PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-2.1.1-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 31.2
	Forge: net.minecraftforge:31.2.0
	FML Language Providers: 
		javafml@31.2
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {minecraft@1.15.2 DONE}
		forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar Forge {forge@31.2.0 DONE}
		main Minecraft World War: Dungeon Wars {mwwdungeonwars@1.15.2-1.0.0 DONE}
	Player Count: 0 / 8; []
	Data Packs: vanilla, mod:forge (incompatible), mod:mwwdungeonwars
	Type: Integrated Server (map_client.txt)

 

Posted

A few things I notice at first glance,

  1. I usually register my packets in my main constructor, don't know if that's relevant.
  2. Why do you have a static boolean for if the key is pressed, your keybind most likely won't work in multiplayer if you use it.
  3. The int parameter in your key class is completely useless, you should remove it.
  4. I think ctx.get.setPacketHandled(true) should always be called, whether or not your requirement was met, call it at the end of the handle method.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted (edited)
  On 6/18/2020 at 5:49 PM, Novârch said:

A few things I notice at first glance,

  1. I usually register my packets in my main constructor, don't know if that's relevant.
  2. Why do you have a static boolean for if the key is pressed, your keybind most likely won't work in multiplayer if you use it.
  3. The int parameter in your key class is completely useless, you should remove it.
  4. I think ctx.get.setPacketHandled(true) should always be called, whether or not your requirement was met, call it at the end of the handle method.
Expand  

Do you think keypress is what is making it crash because the rest of the points do not result in a server crash besides the setpackethandled

 

also i do call setpackethandled at the end of the handle method

Edited by greenecojr

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 🔻 SERVER IP: 90.146.113.53 Watch the Server-Trailer now!     ArenaSMP is a brand new minecraft survival server combining the vanilla survival experience with the following exciting enhancements: In the PVE Arena, combat skeletons whom will when defeated by the player reward them with money which can be spent to purchase ranks with cool permissions such as disguising as a mob, setting multiple homes, accessing the enderchest by command and many more! To enhance your gameplay there are few tough named skeletons with a minor percent chance to drop highly enchanted tools when defeated! But that isn't all, theres a whole world dedicated to bring you the most exciting minecraft experience you've ever had. The treasurehunt world, a place made of massive scary abandoned mineshafts and underground ruins, is populated by very though skeletons and zombies guarding the most powerful treasures including armor and weapons with unique enchantments that will change the way you progress in survival forever! Some secret places hiding the most powerful treasures are difficult to find, only those who look behind every path and corner where nobody else would look might get the chance becomming an undefeatable GOD. The Enderdragon is yet alive, will you be the one to hunt it down first? Will you become the next GOD in arenasmp? Join now! As a bonus, the first 5 players joining will instantly recive a free rankup! What does ArenaSMP offer exactly? • Vanilla like Survival experience, Nether and End World • Hub with portals to various locations • PVE Arena • Treasurehunt World with many secrets • Powerful Hidden Gear • Ranks to be purchased with ingame-money • Landprotection for all players • Players with any minecraft version can join • Shields are disabled, we use the 1.8 combatsystem including sword blocking • Change your skin with the /skins command • Creepers don't destroy blocks and Phantoms are disabled • Defeated skeletons reward the player with ingame-money • Anticheat enabled • Survival World will never reset • Automatic Daily Server Backups Watch the Server-Trailer now! https://www.youtube.com/watch?v=xl5GfTizasI 🔻 SERVER IP: 90.146.113.53
    • I'm simply trying to start up a forever world with mods, but I don't understand what this crash report means. Can I get someone to diagnose the problem? https://pastebin.com/yRsq3C2A
    • I've successfully setup multi mc with two instances and i've split the audio going into my headset and another going into my quest, it works perfectly although whenever i tab out into instance 1 (pc) and go into instance 2 (vr) i can hear the pc audio still and i can also hear the vr audio but only when i am focused on the window it instantly goes mute when i lose focus im not sure what to do i've tried messing around with the sound system classes in my client build but i cant get my gradle build to work i cant find a simple tweak for this version that solves this issue i just need instance 2 to constantly play audio regardless if im tabbed in or not
  • Topics

×
×
  • Create New...

Important Information

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