Jump to content

Recommended Posts

Posted

Alright, so I'm very new to coding and modding. I'm trying to create a crafting recipe of a block, but it just doesn't work. I'm trying to follow as many YouTube tutorials as possible, but they're just all over the place! I'm probably missing a whole chunk of code or something. Again, I'm very new to this, so any help is appreciated!!

unknown.png

Posted

Screenshots are a terrible way to share code, btw ;) use code blocks, or even better a github repo of your project. Google up on it, github is pretty easy!!

 

What version is this for?

Posted

Yes lol. Its just a placeholder for now.

Here's my main mod class:

package com.pixxibunny.minecraftmod;

import com.pixxibunny.minecraftmod.util.RegistryHandler;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod("modid")
public class MinecraftMod
{
    private static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "modid";

    public MinecraftMod() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        RegistryHandler.init();

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event) { }

    private void doClientStuff(final FMLClientSetupEvent event) { }

    public static final ItemGroup TAB = new ItemGroup("modTab") {
        @Override
        public ItemStack createIcon() {return new ItemStack(RegistryHandler.ROSE.get());
        }
    };

}

 

Posted

Wow! That worked! Thank you so much! One last problem, I hope you don't mind... I have it so that the block can be broken with an iron pick but it doesn't drop in any instance when harvested. Any ideas?

Here is my RoseBlock class:
 

package com.pixxibunny.minecraftmod.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;

public class RoseBlock extends Block {

    public RoseBlock() {
        super(Block.Properties.create(Material.IRON)
                .hardnessAndResistance(5.0f,6.0f)
                .sound(SoundType.METAL)
                .harvestLevel(2)
                .harvestTool(ToolType.PICKAXE));

    }
}

 

Posted
1 minute ago, PixxiBunny said:

Ah, no, I don't. How would I go about setting that up?

Same as you did for recipes. Create the package, then add the block you want to drop.

Posted

You can view what minecraft does but, I'm not familiar with IntelliJ and were to look for it though. There should be a Reference Library you can peruse through for the source code of minecraft.

Posted

I've created a loot_tables package. Here's what I have:

unknown.png

Here is the code within the loot_tables.blocks for the rose_crystal_block.json:
 

{
    "type": "minecraft:crafting_shaped",

    "pattern":
    [
        "RRR",
        "RRR",
        "RRR"
    ],

    "key":
    {
        "R":
        {
            "item": "modid:rose_crystal_thing"
        }
    },

    "result":
    {
        "item": "modid:rose_crystal_block",
        "count": 1
    }
}

This is the exact same thing I have in the recipe json. I had no idea what to do lol.

Posted

No, the recipe does not go in the loot_table. Just the block you want to drop.

 

Spoiler

{
	"type": "minecraft:block",
	"pools": [
	{
		"rolls": 1,
		"entries": [
		{
			"type": "minecraft:item",
			"name": "minecraftmod:rose_crystal_block"
		}
		
		]
	}
	]
}

 

 

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.