Add a method of guaranteeing a drop regardless of the weight
WittyWhiscash opened this issue ยท 2 comments
As the title states.
The use case for this suggestion is based on having a guaranteed drop with a chance of another. For example, say I wanted to have clay blocks drop Pyrotech clumps (2-4) guaranteed, and 25% of the time have clay balls (1-2) drop.
Implementation is up to you, but I could see it being a drop strategy that, when an item is defined with no weight, guarantees the drop.
Yeah, I think this is a great idea. This use case has come up several times now and the solution isn't very intuitive or precise.
I think it would be better implemented as a separate parameter, though. Maybe something like the following.
ZenScript
import mods.dropt.Dropt;
Dropt.list("list_name")
.add(Dropt.rule()
.matchBlocks(["minecraft:stone"])
.addDrop(Dropt.drop()
.force(true) // <-- here
.items([<minecraft:string>])
)
);
Json
{
"rules": [
{
"match": {
"blocks": {
"blocks": [
"minecraft:stone:0"
]
}
},
"drops": [
{
"force": true, // <-- here
"item": {
"items" : [
"minecraft:string"
]
}
}
]
}
]
}
API
@SubscribeEvent
public void on(DroptLoadRulesEvent event) {
List<IDroptRuleBuilder> list = new ArrayList<>();
list.add(DroptAPI.rule()
.matchBlocks(new String[]{
"minecraft:stone"
})
.addDrops(new IDroptDropBuilder[]{
DroptAPI.drop().force(true).items(new String[]{ // <-- here
DroptAPI.itemString(Items.STRING)
})
})
);
ResourceLocation resourceLocation = new ResourceLocation("my_mod_id", "rule_list_name");
int priority = 0;
DroptAPI.registerRuleList(resourceLocation, priority, list);
}
If the rule matches, forced drops should always drop and not count toward the dropCount
or be affected by the dropStrategy: UNIQUE
. Forced drops should also not affect replaceStrategy: REPLACE_ITEMS_IF_SELECTED
or replaceStrategy: REPLACE_ALL_IF_SELECTED
because a forced item drop would just result in negating the effectiveness of the _IF_SELECTED
and essentially have the same effect as just REPLACE_ITEMS
and REPLACE_ALL
.