KubeJS (Old)

KubeJS (Old)

3M Downloads

KubeJS-Generated REI Groupings Appear Empty In Settings (But Work)

Brittank88 opened this issue ยท 0 comments

commented

Minecraft Version

1.20.1

KubeJS Version

2001.6.5-build.14

Rhino Version

2001.2.2-build.18

Architectury Version

9.2.14

Forge/Fabric Version

NeoForge 47.1.106

Describe your issue

I am using the following scripts to generate gun groupings from Timeless & Classics Guns: Zero v1.0.2 (and its additional gun packs). The groupings work, but in REI's settings, they appear empty (see screenshots attached underneath code):

TaCZ.js
// Priority: 0

global.tacz_process_categories = (dict, item_type, tacz_interface, tacz_abstract_item, tacz_type_enum) => {
	for (const tab_type of tacz_type_enum.values()) {
		console.log(`Processing TaCZ ${item_type} category: ${tab_type.toString()}`);

		var type_snakecase = tab_type.toString().toLowerCase().replace(' ', '_');

		if (!(type_snakecase in dict)) dict[type_snakecase] = [];

		var itemstacks = tacz_abstract_item.fillItemCategory(tab_type);
		if (itemstacks.length === 0) continue;
		console.log(`Adding ${itemstacks.length} ${item_type} items to ${type_snakecase}:`);
		console.log(
			itemstacks.map(itemstack =>
				tacz_interface[`getI${item_type}OrNull`](itemstack)[`get${item_type}Id`](itemstack)
			)
		);
		dict[type_snakecase] = dict[type_snakecase].concat(itemstacks.map(itemstack => itemstack.strongNBT()));
	}
};

global.tacz_process_enum_as_title = type => {
	switch (type) {
		case 'mg':
			return 'Machine Guns';
		case 'smg':
			return 'Submachine Guns';
		case 'rpg':
			return 'Rocket-Propelled Grenades';
		default:
			return type
				.replace('_', ' ')
				.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase());
	}
};
Groupings.js (relevant section/s only)
const tacz_IGun = Java.loadClass('com.tacz.guns.api.item.IGun');
const tacz_AbstractGunItem = Java.loadClass('com.tacz.guns.api.item.gun.AbstractGunItem');
const tacz_GunTabType = Java.loadClass('com.tacz.guns.api.item.GunTabType');

const tacz_IAttachment = Java.loadClass('com.tacz.guns.api.item.IAttachment');
const tacz_AttachmentItem = Java.loadClass('com.tacz.guns.item.AttachmentItem');
const tacz_AttachmentType = Java.loadClass('com.tacz.guns.api.item.attachment.AttachmentType');

const gun_itemstacks = {};
global.tacz_process_categories(gun_itemstacks, 'Gun', tacz_IGun, tacz_AbstractGunItem, tacz_GunTabType);

const attachment_itemstacks = {};
global.tacz_process_categories(
	attachment_itemstacks,
	'Attachment',
	tacz_IAttachment,
	tacz_AttachmentItem,
	tacz_AttachmentType
);

REIEvents.groupEntries(event => {
	// Gun Categories are so much fun...
	for (const [gun_type_snakecase, itemstacks] of Object.entries(gun_itemstacks)) {
		event.groupItems(
			`kubejs:rei_groups/tacz/guns/${gun_type_snakecase}`,
			global.tacz_process_enum_as_title(gun_type_snakecase),
			itemstacks
		);
	}
	// Attachment Categories are also fun...
	for (const [attachment_type_snakecase, itemstacks] of Object.entries(attachment_itemstacks)) {
		event.groupItems(
			`kubejs:rei_groups/tacz/attachments/${attachment_type_snakecase}`,
			global.tacz_process_enum_as_title(attachment_type_snakecase),
			itemstacks
		);
	}
}
Screenshots

Working groupings...
image

...but empty in settings...
image

Crash report/logs

No response