Jump to content

Recommended Posts

Posted (edited)

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

×   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



×
×
  • Create New...

Important Information

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