#Custom MetalBundle Bundles

60 messages Β· Page 1 of 1 (latest)

spice rapids
#

Easy to use script to create new bundles that are useable from the [Forge Version] mod MetalBundles (https://www.curseforge.com/minecraft/mc-mods/metal-bundles)
To Use, just follow the example objects within the bundleList array inside of the startup script provided - and thats all you need to do!

Below i will be providing a Zip file, with some example textures (just recoloured iron bundles from the mod itself) and the scripts required within their necessary folders.```

Issue: The Filled Property wasnt registered, will fix when i figure out how to register the items onto it.```

grand surgeBOT
#

Paste version of kubejs.zip, addbundle.js, bundle_provider.js, custom_bundles.js from @spice rapids

earnest osprey
#

you can use text.remove(1) i think to remove the original one

#

it is a list of mutable components after all

spice rapids
grand surgeBOT
#

Paste version of addbundle.js, bundle_provider.js, custom_bundles.js, kubejs.zip from @spice rapids

crude sail
#

this is awesome, tysm!

dire cairn
#

Do you have the same for fabric version ?

#

const $ProviderReg = Java.loadClass('fuzs.metalbundles.data.ModItemContainerProvider');
Doesnt exist on fabric version

spice rapids
#

I dont use fabric, and just checking the github for the source, i cant seem to find an equivalent class for fabric that would just slot in? tbf i would try to just remove the containerProvider parts of the code and see if it is even needed on a fabric version? if you want to try and search for your self, this would be the source for the fabric version (make sure to check the common version as well): https://github.com/Fuzss/metalbundles/tree/main/1.20.1/Fabric/src/main/java/fuzs/metalbundles

Sorry for not rlly being able to help.

GitHub

Use bundles like never before with many intuitive interactions. And there's more bundles, much larger! - Fuzss/metalbundles

dire cairn
#

Yes I check it, all the others class are used on Fabric but not ModItemContainerProvider
So I don't know how to add my item

spice rapids
#

from making a very quick fabric environment and doing some small testing (may not have caught some issues), you can just remove (on fabric), the ModItemContainerProvider class and its uses within the startup file. the only issue ive found would be that the filling bar is not representative of the current capacity of the bundle (either shows empty if completely empty or always full) but that was also an issue of the original code as i didnt find a way at the time to get the model property to change, but other than that it works on fabric?

Ive attached a working startup folder with the class reference removed if you want to test it yourself?

grand surgeBOT
#

Paste version of custom_bundles.js from @spice rapids

dire cairn
#

I gonna test it now

spice rapids
#

Went back to this, and have fixed the texture and fill bar issues. code should work for both Fabric and Forge versions of 1.20.1 MetalBundles (https://www.curseforge.com/minecraft/mc-mods/metal-bundles).
Attaching separate JavaScript files in case the assets are not wanted, and a Zip containing all scripts and some example textures for every coloured bundle.

lmk if there are any other issues, but there shouldn't be.

grand surgeBOT
#

Paste version of custom_bundles.js, bundle_provider.js, addbundle.js, kubejs.zip from @spice rapids

dire cairn
#

Tucson much

worn tiger
#

how can i add custom sprites for bundles?

also, is it possible to limit which items can go in a bundle / prevent certain items from going in a specific bundle type?

worn tiger
#

ah, for the first question i partially figured it out, but can i also add filled variants? and if so, how?

spice rapids
# worn tiger ah, for the first question i partially figured it out, but can i also add filled...

you should be able to set custom filled textures as shown in the addBundle.js client file, more specifically:
⁨⁨⁨⁨```js
global.bundleList.forEach(bundle => {
let {id, colour, capacity} = bundle;
e.add(kubejs:models/item/${id}, {
"parent": kubejs:item/${colour}_bundle_asset, // <--- model for non-filled item
"overrides": [
{
"predicate": {
"kubejs:filled": 1.0
},
"model": kubejs:item/${colour}_bundle_filled_asset // <---- model for filled item
}
],
});
});


just either modify the logic here if you handle it differently or add a similar code segment after the current for your custom bundle to use your custom filled model, same for the none filled.

As for limiting what items can go into a bundle, the provider for the metal bundle has some functions to prevent items going into a bundle (as for whether they work, i am going to let you find out as it is currently 5am where i am and i do not have time to test πŸ™‚ )

The github for this is: https://github.com/Fuzss/iteminteractions/blob/main/1.20.4/Common/src/main/java/fuzs/iteminteractions/api/v1/provider/NestedTagItemProvider.java
and the specific methods are:
⁨⁨⁨⁨```java
public NestedTagItemProvider disallowValues(Collection<String> value)
public NestedTagItemProvider disallowValue(String value)
```⁩⁩⁩⁩

where value (i am assuming) is either the item id or tag. (for tag include # at the start of the string)
just predefine a provider in the startup script where you have called these methods beforehand and use that in the constructor. you could for convenience add a new property in the bundleList for disallowed items as an [] and automatically call disallowValues for this property. 

Hope this helps, if you need more just ping and ill get back to you when i can.
GitHub

A library for providing advanced inventory interactions for container items similar to bundles. - Fuzss/iteminteractions

worn tiger
#

thank you very much, i think disallowValue isn't quite what i'm looking for (i need only a specific set of items to BE allowed in the bundle and nothing else) but i'll see what i can do
and the custom sprites work perfectly

worn tiger
worn tiger
spice rapids
# worn tiger i guess if i could somehow generate an item tag containing every item except for...

you could create a new tag for it (eg "kubejs:fog_disallowed_items") and then in server scripts when making a tag, use Ingredient.All, to get all items in the game and remove the items you want to allow into the inventory, making a blacklist. (eg something like this)
⁨⁨```js
let /**@type {String[]}*/ allItems = Ingredient.all.getItemIds().toArray();

let FOG_Items = new Set([
// Allowed Items here

]);

let /**@type {String[]}*/ FOG_Items_blacklist = allItems.filter(item => !FOG_Items.has(${item})); // <-- contents for tag

worn tiger
#

oh tyvm! i honestly didn't think this was possible

#

yeah, i'll try that in a bit

#

sorry for asking so many questions, but i think i'm a little bit lost
i'm looking at this right now, this is the startup script - what would i do to add a disallowed tag? where would i call that disallowValues function?

spice rapids
#

are you intending for all bundles to share the same allow list or are you intending for each bundle item to have its own allow list? as i can give an example of a different startup script that would make it easier to do multiple if needed, but if they all are to share the same allow list, simply when creating a new provider (last method called in the screenshot) define the new $Provider before using it in the method, call the disallowValue method on the defined provider and then pass that provider into the function instead of the "new $Provider(...)" statement

worn tiger
#

ah, each bundle needs its own allow list, apologies

spice rapids
#

gimme a minute to just quickly write an edit that you can test, but it should be simple to do, just adding a new property into the bundle list (if you are using that), and using that in the same method above

worn tiger
#

i'm using the bundle list, yah

spice rapids
#

actually you can just do this and take the generated tag it expects and define the list in a tag event: ⁨```js
StartupEvents.registry('item', e => {
let provider = null;
global.bundleList.forEach(bundle => { // Iterating through each bundle in the bundle list
let {id, colour, capacity} = bundle; // Destructuring bundle object to extract id, colour, and capacity
e.createCustom(id, () => new $Bundle(capacity, new $Properties().stacksTo(1))); // Creating a custom item with id using MetalBundleItem

    if (Platform.isForge()) {
        if (!$ProviderReg) $ProviderReg = Java.loadClass('fuzs.metalbundles.data.ModItemContainerProvider');
        if (!provider) provider = new $ProviderReg(new $PackOutput('kubejs')); // Creating a new provider registration instance

        let _provider = new $Provider(capacity, Color.DYE[colour]);
        _provider.disallowValue(`#kubejs:${id}_disallowed_items`);

        provider["add(net.minecraft.resources.ResourceLocation,fuzs.puzzlesapi.api.iteminteractions.v1.provider.ItemContainerProvider)"]( // Adding provider with id and provider instance
            id, _provider // Creating a new MetalBundleProvider instance with capacity and color
        );
    };
});

});

worn tiger
#

lemme try

#

hmmm, that doesn't appear to be working
the tags get succesfully generated, but the bundles just allow items outside of their respective tags anyway

#

wait

#

nop

#

hold on

#

mydumbass, that is not how disallowed is spelled

#

okay let me try that again

#

still nothing

spice rapids
#

are you able to show your bundle list and your tags? so i can validate them and also do /kubejs hand while holding a item you expect to be blacklisted from the bundle to verify that they do infact have the tag?

worn tiger
#

yup, give me a moment

twin remnant
spice rapids
#

good to know, thanks for the info πŸ™‚

worn tiger
#

bundle list
⁨js global.bundleList = [ {id: "flask_of_holding", colour: "cyan", capacity: 16384}, {id: "wallet", colour: "brown", capacity: 16384}, {id: "parcel", colour: "brown", capacity: 16384}, ];⁩

my tags
⁨```js
let FOG_Items = new Set([
// Allowed Items here
"minecraft:potion",
"farmersdelight:apple_cider",
"farmersdelight:milk_bottle",
"farmersdelight:hot_cocoa",
"kubejs:serene_tea"
]);

let wallet_Items = new Set([
"kubejs:diamond_coin",
"createdeco:gold_coin",
"createdeco:netherite_coin",
"createdeco:brass_coin",
"createdeco:iron_coin",
"createdeco:copper_coin",
"createdeco:industrial_iron_coin",
"createdeco:zinc_coin"
])
let parcel_Items = new Set([
"minecraft:paper",
"minecraft:book_and_quill",
"minecraft:written_book",
"minecraft:book",
"minecraft:enchanted_book"
])

let /@type {String[]}*/ FOG_Items_blacklist = allItems.filter(item => !FOG_Items.has(${item})); // <-- contents for tag
let /
@type {String[]}/ wallet_Items_blacklist = allItems.filter(item => !wallet_Items.has(${item})); // <-- contents for tag
let /**@type {String[]}
/ parcel_Items_blacklist = allItems.filter(item => !parcel_Items.has(${item})); // <-- contents for tag

// Add tags to items
ServerEvents.tags("item", e => {
// Iterate through the bundle list and add tags for each bundle item
global.bundleList.forEach(bundle => {
let {id, colour, capacity} = bundle;
// Add the 'kubejs:bundles' tag to each bundle item
e.add('kubejs:bundles', kubejs:${id});
});
e.add('kubejs:flask_of_holding_disallowed_items', FOG_Items_blacklist)
e.add('kubejs:wallet_disallowed_items', wallet_Items_blacklist)
e.add('kubejs:parcel_disallowed_items', parcel_Items_blacklist)
});


my hand with rabbit hide, which i'd expect to be blacklisted from all 3 bundles:
#

and yet all 3 can hold the rabbit hide

spice rapids
#

did you define AllItems? and all 4 of these should be inside of the tag event, if they are outside they init with nothing as it is only guaranteed that Ingredient.All returns all items if it is inside of such an event

worn tiger
#

i diddefine allItems, yeah

#

it's up here, forgot to copyi t

spice rapids
#

place all 4 inside of the tag event scope, and place them before they are used (usually at the top), and then reload / relog and try again? πŸ™‚

worn tiger
#

i'll try

spice rapids
#

in the mean time, ill setup a test instance so i can be more useful for you lol πŸ™‚

worn tiger
#

thank you so much for all the help, by the way, i'd be totally lost otherwise

spice rapids
#

nw would be better if this was in a support ticket btw to avoid cluttering this chat, so past this issue just ping me with a support ticket link πŸ™‚

worn tiger
#

alrighty

tardy salmon
spice rapids
#

scrolling is handled the same way the mod handles it, so if i remember right, scrolling goes left to right row by row. if thats what your asking? otherwise just assume the scrolling is the exact same way as the mod is.