Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Help with crafting


Recommended Posts

Hi fellow modders! I just need a quick favor. Im in 1.6.4 and i want to know how I can make a crafting recipe somewhat like a cake, where when you craft the cake, it gives the bucket back when you take the item from the crafting table. Instead, I would like a recipe something like that, where i can get an item back from the crafting grid after the recipe is completed.


Thanks to anyone who answers in advance, and dont hesitate to ask questions if i wasnt clear. :D


Link to comment
Share on other sites

All I did for my container item was: nameofitem = new Item().setUnlocalizedName("nameofitem").setContainerItem(NameOfContainerItem);

This should work, and if not just do what diesieben07 said


Hey dude! "nameofitem = new Item().setUnlocalizedName("nameofitem").setContainerItem(NameOfContainerItem);" didnt work out for me, neither did diesieben07's way of doing it. My code looks like this :             


PortableJuicer = new NewItem(2034, "PortableJuicer").setContainerItem(PortableJuicer);

        GameRegistry.registerItem(PortableJuicer, "PortableJuicer");

        LanguageRegistry.addName(PortableJuicer, "Portable Juicer");


And it still doesnt work when I craft with it. It just disappears after crafting. Any more help?

Link to comment
Share on other sites

First of all... LanguageRegistry? Nope.


You set the containerItem to null...


Hey diesiben07, I was taught a different way to code the item. I only have been coding for about 4 months, and I know some Java, but im new to MCP, so pardon my mistakes. Right now I have this code, and it still doesnt work:


        PortableJuicer = new NewItem(2034, "PortableJuicer").setUnlocalizedName("Portable Juicer").setContainerItem(null);

        GameRegistry.registerItem(PortableJuicer, "PortableJuicer");


If this doesnt work, is there a example code for this I can look at?

Thanks in advance

Link to comment
Share on other sites

Here is an example of what I did.


public static ITEMCLASS nameofitem;


public static void initItems()


    nameofitem = new Item().setUnlocalizedName("nameofitem").setContainerItem(nameofOTHERitem);



The reason it is null is because you are initializing it on the same line you are trying to use it. So therefore when it tries to access it during initialization, it returns null, So you could either initialized the item then on the next line set its container item like so:


nameofitem = new Item().setUnlocalizedName("nameofitem");



or a bit of a better way is to use two separate items, one is the one used in crafting the other is the container item, like a milk bucket and bucket


nameofanitem = new Item().setUnlocalizedName("nameofanitem").setContainerItem(nameofitem);

Link to comment
Share on other sites

dude learn how to code minecraft, + look at vanilla code. also why coding it in 1.6.4


I'm enrolled in a Minecraft Modding class that also teaches Java, and we code in 1.6.4, then move to 1.7.10 and 1.8. I'm relatively new to MCP and I do know how to look for code in the files, but its not that easy for a newbie to do it.

Link to comment
Share on other sites

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Been there done that 😂 The words Forge & Fabric just look too similar if you're dyslexic, I guess 😅
    • My TileEntity implements IInventory (I know it's outdated, but I don't think IItemHandler would solve my problem) and I want to change things in the inventory if setItem is called. However, the container only shows the change after one action delay or if I reopen the container. Code (not finished): @Override public void setItem(int index, ItemStack stack) { this.items.set(index, stack); if (stack.getCount() > this.getMaxStackSize()) { stack.setCount(this.getMaxStackSize()); } //This is were the changes are not recognised instantaneously //Important is that I change the list that stores the items if(index == 9 || index == 10) { ItemStack input = this.items.get(9); int in = input.getCount(); if(in > 0) { ItemStack output = this.items.get(10); int out = output.getCount(); Item item; if(input.getItem().equals(Items.BUCKET)) item = ItemInit.CREOSOTE_BUCKET.get(); else item = ItemInit.CREOSOTE_GLASS.get(); if(output.getItem().equals(item) || output.isEmpty()) { ItemStack filledItem = new ItemStack(item); int amount = Math.min(filledItem.getMaxStackSize() - out, in); input.shrink(amount); filledItem.setCount(out + amount); items.set(10, filledItem); } } } this.setChanged(); } I also did this: //-----------------------------------------------------Synchronization----------------------------------------------------- @Override public SUpdateTileEntityPacket getUpdatePacket() { return new SUpdateTileEntityPacket(this.getBlockPos(), 1, getUpdateTag()); } @Override public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { this.load(this.level.getBlockState(this.getBlockPos()), pkt.getTag()); } @Override public CompoundNBT getUpdateTag() { return this.save(new CompoundNBT()); } @Override public void handleUpdateTag(BlockState state, CompoundNBT tag) { this.load(state, tag); } What can I do to solve this problem? I wanted to use packets to sync server and client, but I don't have a player in this context.
    • So I'm trying to make an ore generate in the end, and the veins are generating in huge sizes which are not desired. The first screenshot refers to a test where I set the max vein size to 3, and the second screenshot when I set it to 1. Screenshots   public class ModOreGeneration { public static void generateOres(final BiomeLoadingEvent event){ for(OreType ore: OreType.values()){ OreFeatureConfig oreFeatureConfig = new OreFeatureConfig( new BlockMatchRuleTest(Blocks.END_STONE), ore.getBlock().get().defaultBlockState(), ore.getMaxHeight() ); ConfiguredPlacement<TopSolidRangeConfig> configuredPlacement = Placement.RANGE.configured( new TopSolidRangeConfig(ore.getMinHeight(),ore.getMinHeight(), ore.getMaxHeight()) ); ConfiguredFeature<?,?> oreFeature = registerOreFeature(ore, oreFeatureConfig,configuredPlacement); event.getGeneration().addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, oreFeature); } } private static ConfiguredFeature<?,?> registerOreFeature(OreType ore, OreFeatureConfig oreFeatureConfig, ConfiguredPlacement configuredPlacement){ return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, ore.getBlock().get().getRegistryName(), Feature.ORE.configured(oreFeatureConfig).decorated(configuredPlacement).squared().count(ore.getMaxVeinSize())); } } public enum OreType { RUMBANITE(Lazy.of(ModBlocks.RUMBANITE_ORE),1,15,40); private final Lazy<Block> block; private final int maxVeinSize; private final int minHeight; private final int maxHeight; OreType(Lazy<Block> block, int maxVeinSize, int minHeight, int maxHeight) { this.block = block; this.maxVeinSize = maxVeinSize; this.minHeight = minHeight; this.maxHeight = maxHeight; } public Lazy<Block> getBlock() { return block; } public int getMaxVeinSize() { return maxVeinSize; } public int getMinHeight() { return minHeight; } public int getMaxHeight() { return maxHeight; } public static OreType get(Block block){ for(OreType ore : values()){ if(block == ore.block){ return ore; } } return null; } }  
    • What diesieben07 says, except the error's caused by Xaero's World Map, not the mini map   You're running XaerosWorldMap_1.19.0_Forge_1.18.jar which was released on Dec 28, 2021. They've since updated this mod a lot since they're currently at XaerosWorldMap_1.22.0_Forge_1.18.2.jar If I counted correctly, you're 11 updates behind on their releases, so it may be wise to either start a regular updating schedule or figure out a way to setup automated updates 😅 When you're waiting with updates until issues/errors arise, you're technically putting the server's data integrity at risk. Granted, this won't often result in permanent damages, but it could 😛  Also, there could be vulnerability patches that you're missing out on, which by the time they're patched become public-record, thus also known amongst any hacker that would want to exploit it. tl;dr: Updating the Xaero's mod will fix the issue, but given the severity of the outdated-ness, making changes as to how/when you're updating the software would be strongly advisable.
    • I wanted to make a block that melts like ice. I use the tick method in the BlockEntity to periodically check the light level. However  level.getBrightness(LightLayer.BLOCK,pos); always returns 0.
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.