Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.15.2][Solved] DeferredRegistry can't stack BlockItems

Featured Replies

Posted

Hey,

Since I use deferredregistry for my blocks, I can't stack them anymore.

BlockInit.java

Spoiler

@Mod.EventBusSubscriber(modid = MyMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class BlockInit
{
    public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MyMod.MOD_ID);

    private static final Block.Properties BASE = Block.Properties.create(Material.ROCK).hardnessAndResistance(1.5F).harvestLevel(2).harvestTool(ToolType.PICKAXE);

    public static final RegistryObject<Block> HEX_RED = BLOCKS.register("hex_red", () -> new HexBlock(BASE));
    public static final RegistryObject<Block> HEX_GREEN = BLOCKS.register("hex_green", () -> new HexBlock(BASE));
    public static final RegistryObject<Block> HEX_BLUE = BLOCKS.register("hex_blue", () -> new HexBlock(BASE));
    public static final RegistryObject<Block> HEX_CYAN = BLOCKS.register("hex_cyan", () -> new HexBlock(BASE));
    public static final RegistryObject<Block> HEX_MAGENTA = BLOCKS.register("hex_magenta", () -> new HexBlock(BASE));
    public static final RegistryObject<Block> HEX_YELLOW = BLOCKS.register("hex_yellow", () -> new HexBlock(BASE));
    public static final RegistryObject<Block> HEX_ORANGE = BLOCKS.register("hex_orange", () -> new HexBlock(BASE));

    @SubscribeEvent
    public static void registerItems(final RegistryEvent.Register<Item> event)
    {
        final IForgeRegistry<Item> registry = event.getRegistry();

        BlockInit.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block ->
        {
            registry.register(new BlockItem(block, ItemInit.BASE_PROP).setRegistryName(block.getRegistryName()));
        });
    }
}

 

 MyMod.java

Spoiler

@Mod(MOD_ID)
public class MyMod
{
    public static final String MOD_ID = "mymod";

    public MyMod()
    {
        final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

        eventBus.addListener(this::setup);
        eventBus.addListener(this::clientSetup);

		ItemInit.ITEMS.register(eventBus);
        BlockInit.BLOCKS.register(eventBus);

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {}

    private void clientSetup(final FMLClientSetupEvent event)
    {}

 

I use the same Item.Properties for my basic items and they all can be stacked

Item.Properties BASE_PROP = new Item.Properties().maxStackSize(64).group(ItemGroupInit.instance);

I tried with and without .maxStackSize(64)

 

Thanks in advance.

 

EDIT: Solved, using the same Item.Properties for all items made my AxeItem set all other Items maxStackSize to 1

Edited by QuantumSoul
Solved

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.