Question about chances within the config. 1.18.2
ShadowSharkWolf opened this issue · 14 comments
Hi there,
I have a question
If I made the chance of bonemeal 0.25 or 25% chance...shouldn't I have a chance to get the other three items within the config file? So far I've input 700 total Wooden logs to be composted and all I've gotten so far is bonemeal. It feels like the config file isn't being noticed by the mod or isn't being implemented by the mod when the game starts.
Minecraft: 1.18.2
Fabric: 0.14.10
Compost: 1.1.0
Config: https://gist.github.com/ShadowSharkWolf/9254ab9ac140e151d5696bc7e61e9e6d
I like this mod as well.
Well in my own testing in Fabric 1.18.2, I am getting results as expected. Here is from 40 attempts with these settings.
{
"items": [
{
"item": "minecraft:emerald",
"chance": 0.25,
"min": 1,
"max": 1
},
{
"item": "minecraft:diamond",
"chance": 0.5,
"min": 1,
"max": 1
},
{
"item": "minecraft:gold_ingot",
"chance": 1.0,
"min": 1,
"max": 1
}
]
}
Given the chances, it should be roughly 40 gold, 20 diamonds, and 10 emeralds. This seems to come as expected.
So, back to your issue, perhaps it is some mod conflict? Given your own settings, in 40 attempts it should give roughly 10 each of the items you have listed.
Looks like it is pretty accurate. Of course I do not have your mods installed, so I did not receive any of the modded item. So, I can say it is either a mod conflict, you are somehow losing track of the other items, or you are just extremely unlucky. Just because there is a 25% chance does not mean you will receive 175 when you put in 700. You can end up with 0. It is possible, but just extremely unlucky. I suggest you meditate and do some ॐs to align your mind with the random number generator. Perhaps then you can end up getting 700 on a 25% chance from 700 and have complete control over the outcome. :D
But yes, please consider looking into a mod conflict, as something is obviously wrong here.
It is interesting that you are only getting bone meal; I may have inadvertently done something wrong when backporting, but I will tell you that the way this works you have a chance of not generating anything when emptying the composter. Each one you have set to 0.25, so each only has a 1 in 4 chance to succeed. This is not a cumulative total.
Basically as the code goes, it runs a chance to spawn for each entry in the config.
As far as my testing went, I was certain that for each version it was outputting custom entries and removing the default bone meal entry. I will go back and look at this once I am done fixing some 1.19.3 stuff for other mods.
I feel the only mod conflicts there could be is Data Driven Composter or Fabricae Ex Nihilo both are for 1.18.2. I use the data driven composter to allow most anything to be put into the composter. I then use this mod compost to compost those items into dirt. At least, that is how it used to be before the update.
Anyway thanks for the extra information I will try and do some conflict searching within minecraft mods and see what is up. I will then put up an error report towards the correct mod in question.
I know what happened now! When inputting items directly from your own inventory into the composter without automation via hoppers it will give you the items mentioned within the config file as seen in your pictures. The way I was doing it was automating the process via the hoppers from a chest above the hopper and a compost underneath the hopper and another hopper underneath the composter with a chest for outputting the items. Seen here:
And here is what the output chest was getting:
Me thinks that if you automate the process without any user input directly the output will be the default bonemeal, but with direct input from the player, only without automation, the items you get will come from the config file.
Ah I see where the issue is. Okay, I will fix this. I didn't understand the purpose of the composter having an inventory, I was thinking it was for the villager AI to focus on it.
Basically when you extract it by hand you are spawning an item, but when a hopper wants to pull from it, it doesn't spawn it, it instead extracts its inventory, which requires it having an inventory. When it gets the full state it gives itself the inventory of bone meal (this was before changed to dirt). When it extracts it looks to see if it has bone meal (changed to dirt) inside of it. I removed this part because I misunderstood its purpose.
Well I am at a little bit of a roadblock, because as the hopper only takes one of the very first item in an inventory at a time, only one of the first item to populate gets taken for every emptying of the composter. I have yet to conclude whether this might require modification of the hopper or not, which is kinda scope creep that I don't really want here.
Unless I can figure out how to make sure it takes all items out of the inventory before resetting via hopper extraction, I may need to just leave it with a disclaimer of the aforementioned caveat.
I want to try a little experiment from another mod that uses item transfer pipes/fluid transfer pipes just to see if that could work instead of the hoppers I used. If it works, then I suppose the caveat would stay and just mention using item pipes instead. I'll let you know ASAP.
Edit: As far as Modern Dynamics is concerned, the item pipes extract only bonemeal like hoppers do. Oh well, I tried...
Yes, the hopper is not what controls the inventory. I will have to modify the hopper's extraction, however, to get more than just 1 of the first item of the composter.
There will be a limitation in that when it runs the extract it can only take what can fit in the 5 hopper slots and anything else is lost. So if you have more than 5 different items that a hopper can take, you are limited in what you can get out. Basically there is a bottleneck to what it can accomplish.
I probably will not be supporting other mods' extraction blocks in regards to their limitations.
That's fine. I figured that you would only get a limit of five from hoppers and the rest would get lost or voided from the inventory. Oh well, thanks for the information.
I think I have a way to work around that issue though. Since the items get spit out from the composter from the top and get flung short distances away from the composter sometimes, I could just put hoppers around the composter instead of underneath to pick up the items getting spit out it from manually inputting the items from my inventory into it and manually outputting the items.
Anyways, thanks again for humoring me and responding to my issue. I appreciate that.
The way a player gets items from a composter and the way a hopper extracts them are different.
When a hopper gets to level 8 (full), it is given an inventory of whatever it may be.
Player interaction causes item entities to spawn. These are not the same items as in the inventory, so if you have a range or chance on, for example, an apple, you may spawn a different count of apples than what was created for the inventory (this is why you are currently only getting bone meal from the hopper process). When you click as a player, it generates these item entities that pop out, and then immediately after the composter is set to level 0, which doing so clears the inventory.
When a hopper extracts from a composter at level 8, it is transferring the inventory of the composter into the hopper, and afterwards does the same set to level 0 thus clearing the inventory. It does something different for finding item entities in its vicinity.
Well I have yet to come up with a way to get it to work with an 8 tick delay as I want, but for now I will release a version that at least somewhat works with the hopper.
I've added a boolean option "shuffle" to shuffle around the list of items, on by default, so if you want to items past no. 5 on the list you can randomly get it, or just have the order set by the json if "false".