#Advanced Block with gui [ 1.21.5 ]

65 messages · Page 1 of 1 (latest)

tired radish
#

Hey guys I am making a mod and I want to add a block that when you insert something in the first slot of the gui it comes out like something else in the other.
Here is the code

austere stratus
#

I mean you could check out the crafting table code

tired radish
#

yeah I did but it didnt help that much because the custom block is registered as an normal block nt an advanced one and when I made the Custom block with the entities files and screen files it had so many errors

tired radish
austere stratus
tired radish
#

ok

#

wait

austere stratus
# tired radish wait

In your PressingTableScreenHandler, where ur making a new SimpleInventory, add curly braces around it instead of just making a new SimpleInventory, or whatever u call it, and in there override markDirty

#

Im pretty sure markDirty gets called whenever an inventory slot changes

tired radish
#

hey @austere stratus I am geting errors on this code


import com.cl1ppz12.strike.Strike;
import com.cl1ppz12.strike.screen.PressingTableScreenHandler;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;

public class ModScreenHandlers {
    public static ScreenHandlerType<PressingTableScreenHandler> PRESSING_TABLE;

    public static void registerAllScreenHandlers() {
        PRESSING_TABLE = Registry.register(
                Registries.SCREEN_HANDLER,
                Identifier.of(Strike.MOD_ID, "pressing_table"),
                new ScreenHandlerType<PressingTableScreenHandler>(
                        (ScreenHandlerType<PressingTableScreenHandler> type, int syncId, net.minecraft.entity.player.PlayerInventory inventory) ->
                                new PressingTableScreenHandler(syncId, PlayerInventory playerInventory, Inventory inventory)
                )

        );
    }
}

the error

Strike Mod v.1\src\main\java\com\cl1ppz12\strike\screen\ModScreenHandlers.java:21: error: ')' or ',' expected
new PressingTableScreenHandler(syncId, PlayerInventory playerInventory, Inventory inventory)
^

austere stratus
#

I mean, put new PressingTableScreenHandler instead of new ScreenHandlerType<PressingTableScreenHandler>

#

i think

tired radish
#

wait

#

If I am making this difficult for you I am sorry

#

Strike Mod v.1\src\main\java\com\cl1ppz12\strike\screen\ModScreenHandlers.java:20: error: '(' or '[' expected
);

#

package com.cl1ppz12.strike.screen;

import com.cl1ppz12.strike.Strike;
import com.cl1ppz12.strike.screen.PressingTableScreenHandler;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;

public class ModScreenHandlers {
public static ScreenHandlerType<PressingTableScreenHandler> PRESSING_TABLE;

public static void registerAllScreenHandlers() {
    PRESSING_TABLE = Registry.register(
            Registries.SCREEN_HANDLER,
            Identifier.of(Strike.MOD_ID, "pressing_table"),
            new PressingTableScreenHandler
    );
}

}

#

@austere stratus

austere stratus
#

you gotta

#

add the

#

new PressingTableScreenHandler(stuff here)

tired radish
#

ohh

#

like this

                        (ScreenHandlerType<PressingTableScreenHandler> type, int syncId, net.minecraft.entity.player.PlayerInventory inventory) ->
                                new PressingTableScreenHandler(syncId, PlayerInventory playerInventory, Inventory inventory)
                )```
#

@austere stratus

austere stratus
#

sup

tired radish
#

I am still getting the error

#

Strike Mod v.1\src\main\java\com\cl1ppz12\strike\screen\ModScreenHandlers.java:21: error: ')' or ',' expected
new PressingTableScreenHandler(syncId, PlayerInventory playerInventory, Inventory inventory)
^

austere stratus
#

Im not really sure, thats about all i know

tired radish
#

Should We ask someone else

#

Or Do you know someone else

austere stratus
#

I dont rlly know anyone good at coding

#

ask in mod dev 1 or 2

tired radish
#

ok

lime mesa
#

You have the Screen and Menu for it right ?

tired radish
#

yes if you mean the screen java files and entity

lime mesa
#

wait what you want to do first tho ? Like what Block with GUI, what should it do

tired radish
#

when you r-click the block it opens a gui with two slots,
In the first one you put a listed item in the code
And in the second one it comes out like a different Item

lime mesa
#

they should stay in the block or not ?

tired radish
#

no

lime mesa
#

bcz then I think you dont need a BlockEntity for that and you can do everything in the Menu or Screen

tired radish
#

like the crafting table but with one slot to craft and one slot for result

#

If you want I can send you the code, just tell me which one

lime mesa
#

and the block opens the menu atleast ?

tired radish
lime mesa
#

what error

tired radish
#

the error I am getting in the ModScreenHandlers

#

wana look

#

the Code


import com.cl1ppz12.strike.Strike;
import com.cl1ppz12.strike.screen.PressingTableScreenHandler;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;

public class ModScreenHandlers {
    public static ScreenHandlerType<PressingTableScreenHandler> PRESSING_TABLE;

    public static void registerAllScreenHandlers() {
        PRESSING_TABLE = Registry.register(
                Registries.SCREEN_HANDLER,
                Identifier.of(Strike.MOD_ID, "pressing_table"),
                new PressingTableScreenHandler(
                        (ScreenHandlerType<PressingTableScreenHandler> type, int syncId, net.minecraft.entity.player.PlayerInventory inventory) ->
                                new PressingTableScreenHandler(syncId, PlayerInventory playerInventory, Inventory inventory)
                )

        );
    }
}

The Error

                                new PressingTableScreenHandler(syncId, PlayerInventory playerInventory, Inventory inventory)
                                                                                      ^```
lime mesa
#

doesnt the IDE also tells you if you have missing code?

lime mesa
#

you cant init the class with the variable's type and name as parameter

tired radish
#

ok [ but because I am a new dev can you te me what to do in my code ]

lime mesa
#

you need to learn for yourself better than asking others basic java but, you cant use PlayerInventory playerInventory as parameter, you have to use an already existing variable

tired radish
#

ok i will try, thanks for the help

#

But one last question where did you learn Fabric Coding ( Do you have a specific website exept the fabric developer guide )

austere stratus
lime mesa
#

also I learned NeoForge first then Fabric bcz I wanted to port my mods on it

tired radish
#

Hey @lime mesa Do you recommend any discord servers?

lime mesa
#

for ?

tired radish
#

for modding and coding

#

To learn

lime mesa
#

or discord, ask here in #mod-dev-1 / #mod-dev-2 stuff