Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Brittank88 opened this issue Jul 30, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Brittank88
Copy link

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

@Brittank88 Brittank88 added the bug Something isn't working label Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant