Jump to content

Recommended Posts

Posted

Good day,

I made a fully functional double input furnace. Except now I want to make it so it creates random output. I suppose that I will need to make the output slot have maximum stack of 1, but in inventory I want for the items to stack.

So I am asking for your help:

How do I make the output slot have maximum stack of 1 and how to create the random output?

Posted

You want the results to be different (and random) and stack?

 

These two statements do not go together.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

He's asking how to limit the stack size to 1, so it wouldn't be stackable in the slot, while vanilla stacking behavior would still be in effect in the normal player inventory.

 

Since it's a furnace, you should have a TileEntity with this method in it already (assuming you implemented ISidedInventory, which you should have if you're making a furnace):

@Override
public int getInventoryStackLimit() {
return 64;
}

Do I need to say more?  :P

 

For the random output, how are you storing your recipes? Does it matter what the inputs are at all, or should it be totally random? If it's totally random, then one option would be to make a List of ItemStacks and use list.get(rand.nextInt(list.size())) to return a random stack from within the list.

Posted

Tried that, it limits all the slots (even the coal one)

Basicly I want to not stack it in the output slot, but stack it outside the slot (in inventory)

EDIT: And about those recipes, I'll show you an example:

Slot 1 = Item.arrow

Slot 2 = Item.bone

Output slot = 25% Item.ingotGold, 10% Item.ingotGold, 5% Item.diamond, 60% Block.cobblestone

And becouse the item couldn't stack, I want to limit only the output slot to 1 item at a time.

 

My recipes look like this:

private static ItemStack getOutput(int i, int j)
	{
		if (i == Elementum.uraniumItem.itemID && j == Elementum.ironCell.itemID)
		{
			return new ItemStack(Elementum.uraniumCell, 1);
		}
		return null;
	}

Posted

Then it's a matter of just not processing input when the output slot isn't null, and the disallowing of the player putting items in the output slot (which you can do in the Container).

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Posted

I really recommend not making it hardcoded and creating a recipe list instead (unless the random items are the same for every input item off course).

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Posted

So create a custom output slot with this method:

@Override
public int getSlotStackLimit() {
   return 1;
}

When adding slots to your Container, be sure to use your custom slot only for your output.

 

Look through the Slot class to see the other methods mentioned by MineMaarten - you will need them to prevent the player from putting things into the slot.

 

From your recipe code, it didn't look random at all. It's still a recipe requiring two specific items to return a specific output... I'd suggest you take a good look at the vanilla FurnaceRecipes class. Do you see where it returns the smelting result? Well, instead of returning a specific ItemStack, store a custom int or whatever in the HashMap that tells you what random list to pull the item from:

// I'll modify the vanilla for 2 itemstacks
public ItemStack getSmeltingResult(ItemStack item1, ItemStack item2) 
    {
        if (item1 == null || item2 == null) { return null; }

        int randomList = -1;

        if (metaSmeltingList.containsKey(Arrays.asList(item1.itemID, item1.getItemDamage(), item2.itemID, item2.getItemDamage()))
        randomList = metaSmeltingList.get(Arrays.asList(item1.itemID, item1.getItemDamage(), item2.itemID, item2.getItemDamage()));
        
        ItemStack output = null;

        switch(randomList) {
        case 1: // you put in an arrow and a stick or whatever
             // output = select from random list one containing gold, cobblestone, etc.
        case 2: // you put in dirt and gunpowder or whatever
             // output = select from random list two
        default: // for value of -1 or other unhandled cases

        return output;
       }
}

Something of that nature should work.

Posted

Alright. Fixed it now! Thank you everyone for your help :)

Used:

private static ItemStack getOutput(int i, int j)
	{
		if (i == Item.clay.itemID && j == Item.paper.itemID)
		{
			Random rand = new Random();
			int randNum = rand.nextInt(10);
			if(randNum == 1){
				return new ItemStack(Item.bone, 1);
			}
			if(randNum == 2){
				return new ItemStack(Item.stick, 1);
			}
			else{
			return new ItemStack(Item.arrow, 1);
			}
		}
		return null;
	}

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

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