GithubHelp home page GithubHelp logo

unifytags's Introduction

UnifyTags

Description

If you find using this script finnicky, check out Almost Unified for a mod that functionally does the same thing. You can also turn on and off features from this script if you want part of it's functionality but not all of it; this allows you to use both the script and the mod side-by-side.

UnifyTags is an item unifier similar to InstantUnify and UniDict. It works through KubeJS and unifies items in the world, items in your inventory, and some recipes based upon tags (oreDict) so you will only ever have to worry about one ingot of a given material instead of the many given by different mods. You can configure what tags get unified in the server_scripts/unify.js script. Changes are applied on server reload, unless you utilize the cache.

Features

  • Unify item entities (and therefore drops from blocks except from quarries)
  • Unify items when they go into your inventory
  • Unify certain recipes automatically (like crafting and smelting)
  • Hide unified materials through JEI/REI (might require using the cache). Note that only REI works on Fabric.
  • Optionally cache all items in tags so they can work properly client side.

Installing

In order to run UnifyTags, you need KubeJS installed on either the forge or fabric version of Minecraft. After KubeJS is installed, drag and drop the three folders (server_scripts, client_scripts, and startup_scripts) into .minecraft/kubejs and UnifyTags will work on server startup or server reload. If you are running a server, you only need server_scripts installed server side and client_scripts installed client side; nevertheless, make sure that startup_scripts is placed into both the client and the server.

Using the Cache

In order to make unified materials hide themselves properly in JEI/REI, you may need to utilize the caching feature. This will save a list of tags and some configured options to a JSON file and will make it so any time you join any other server or reload JEI/REI those values will be used. To use the cache, set global["CACHE_TAGS"] = true in the startup file. To generate the cache, join a singleplayer world (you can find the cache in the /kubejs/config/ folder as unify_cache.json). You must delete the json file to clear the cache; any time you make a change to the configuration, or add/remove a mod that uses those tags, make sure to delete the cache, reboot the game, and regenerate the cache. Note that every client should also have the same copy of the cache as the server, to make sure the right items are hidden from REI that would be unified by the server.

License

Use this in whatever modpack you want, with or without telling me. Modify and sell it too if you want. I don't mind so long as you're honest about the script's origin and what you did to it.

Contact

Contact me on Discord and support me on Ko-Fi!

unifytags's People

Contributors

mathgeniuszach avatar

Stargazers

Artem Saikin avatar  avatar Francisco Puertas avatar Roman Zelenskiy avatar Cory J Reid avatar  avatar Krougal avatar Rolo Wilde avatar  avatar 六色 avatar Grégoire Joncour avatar Tayray avatar Monique avatar

Watchers

 avatar

unifytags's Issues

Iteration of tags and load order can cause errors

Occasionally iterating over a tag can occur before a tag is loaded. When this happens seems to be random. I need a way to delay this so iteration can occur after a tag is loaded but before recipes and such are loaded. The best time to do this seems to be at startup, but when at startup?

Incorrect event for ServerEvents.tags?

I'm getting this error when running the 1.17 script on 1.19.2 Minecraft.

[System] [CHAT] 1) unify.js#370: Error occurred while handling event 'ServerEvents.tags': TypeError: Cannot find function replaceInput in object dev.latvian.mods.kubejs.server.tag.PreTagEventJS@46844d32.
[System] [CHAT] More info in 'logs/kubejs/server.log'

Looking more at the script I noticed this:

if (global["V6P"]) {
    ServerEvents.tags("item", e_recipes)
    ServerEvents.recipes(e_recipes)
} else {
    onEvent("tags.items", e_tags_items)
    onEvent("recipes", e_recipes)
}

e_recipes looks to be modifying/unifying recipes, why is it being called when the server is working on tags?

Changing to:

if (global["V6P"]) {
    ServerEvents.tags("item", e_tags_items)
    ServerEvents.recipes(e_recipes)
} else {
    onEvent("tags.items", e_tags_items)
    onEvent("recipes", e_recipes)
}

fixed the issue.
The weird part is the script was working fine for a while, and randomly stopped working.

entity.spawned error in server console

Minecraft Version: 1.16.5
Server Type: Forge
Forge Version: 36.0.46
Mod Version: 1.1
KubeJS Version: 1605.3.6-build.172

Every time an item is spawned in the world such as dropped by a player or dropped from a block that was mined this error is displayed in the server console:
[02:59:56] [Server thread/ERROR] [KubeJS Server/]: Error occurred while handling event 'entity.spawned': Wrapped java.lang.NullPointerException (server_scripts:unify.js#136)

Despite the error it still converts the Ores and Ingots but would like to not have an error spam my server console.

Error: “Assignment to undeclared variable invnames”

I’m getting this error from KubeJS. I didn’t change the script except for adding a comment at the top crediting you as well as putting // in front of Tech Reborn, Assembly Line Machines, Futurepack, Tinkers’ Construct, and Tinkers’ Reforged, as those mods are not installed. I also moved Thermal Series (thermal) to the top of the priority list.

[ERR ] Error loading KubeJS script: Assignment to undeclared variable invnames (server_scripts:unify.js#387)

The code in question (#387):

invnames = new Set([
    "net.minecraft.inventory.container.PlayerContainer",
    "net.minecraft.class_1723",
    "net.minecraft.world.inventory.InventoryMenu"
])

The server script that is erroring does not seem to be working either. Lead, tin, and uraniujm ores from FTB Industrial Contraptions are generating rather than Thermal Series or Mekanism ores, silver ore from Occultism is generating, and no ores that I give myself with a command are being replaced. The client script that hides items from JEI does appear to be working, and it even seems like Mekanism’s tin and lead ores, to name a couple, aren’t even loaded to the game, which I assume is the work of the start-up script. But the server script isn’t working.

Versions

  • Minecraft: 1.18.2
  • Forge: 40.1.80 (latest)
  • UnifyTags: 1.14 (latest)
  • KubeJS: 1802.5.5-build.546 (latest)

Not unifying Lead, nickel and silver properly.

For some reason the script refuses allow the conversion of ore blocks(When silk touched) into dust. The normal stone variants only allow to be directly smelted into ingots. The deep slate variants are unaffected and have unified properly. Raw ore bits(When mined without silk touch) also remains functional.

I have not touched or configured the scripts save allowing all unified items to remain unhidden. The following image is verbatium as displayed for Silver, and nickel as well.
image_2022-08-08_150816222

Mods Unified,
Thermal Expansion
Immersive Engineering
Create

Error in server script

[ERROR] ! #355: Error occurred while handling event 'ServerEvents.recipes': TypeError: Cannot call method "forEach" of undefined (server_scripts:unify.js#355)

Recipe Output tag support

The script does not seem to modify recipes whose outputs are already tags to the 'priority' item of the tag.
For now I'm using this workaround for immersive engineering. Any official support would be much appreciated.

for (let [tag, stacks] of Object.entries(global["tagItems"])) {
        let priorityId = global["tagPriorityItems"][tag]
        for (let itemId of stacks) {
            if (global["unifyexclude"].has(itemId)) continue

            // Replace any time the item appears as an input, with the whole tag
            event.replaceInput({}, itemId, "#" + tag)
            // Replace any time the item appears as an output, with the priority item
            // (Unless this is the priority item itself, then do nothing)
            if (itemId != priorityId) event.replaceOutput({}, itemId, priorityId)
        }
       /// workaround
	event.forEachRecipe({type: /immersiveengineering:.*/}, (r) => {
		let result = r.json.get("results");
		if(result.has("base_ingredient")){
			if(result.get("base_ingredient").get("tag") == tag){
				var amount = parseInt(result.get("count"));
				r.json.remove("results");
				r.json.add("results", {
					item: priorityId,
					count: amount
				});
				r.save();
			}
		}else{
			if(result.get("tag") == tag){
				r.json.remove("results");
				r.json.add("results", {
					item: priorityId,
					count: 1
				});
				r.save();
			}
		}
	});
....
		

Issue with Tinker's Construct + Thermal Series (+others?) recipes for gold cast creation

Unify script faces issues with creating certain gold casts when using RECIPE_UNIFY value of TRUE.

With tconstruct:ingot_cast instead of using forge:ingots tag for the casting it defaults to forge:ingots/bronze and won't allow any other ingot to be used

With tconstruct:nugger_cast instead of using forge:nuggets tag it defaults to forge:nuggets/copper

With tconstruct:plate_cast instead of using forge:plates tag it defaults to... forge:plates/iron

with tconstruct:gear_cast instead of using... forge:gears it defaults to... forge:gears/iron

It seems to latch on to things that have thermal series only outputs and defaults to those types of input items. I think it might be related to line 341

event.replaceInput({}, itemId, "#" + tag)

may be related to issue #21

These scripts crashed my computer

After adding these scripts to the my mod pack folder and opening the game, my computer crashed and when I tried again, the same happened.

Confusion with raw ores

I was unsure if this is the correct place but a simple Kubejs script seems to be the easiest solution. There seems to be a bit of confusion regarding the usage of tags for raw ores in 1.18, causing many recipes and compatibility to break. For example, AllTheOres uses tags of the form forge:raw_ores/raw_xxx while immersive engineering in my case uses forge:raw_ores/xxx which seems to be more in line with other tags. Maybe adding a few lines to unify this to the script could be usefull. While I have some js experience getting this to work in minecraft could take some considerable amount of time for me so I just wanted to suggest it here.

Error in script : Undeclared variable

With the newest update of KubeJS, the script now throws errors:

[12:03:16] [ERR ] Error loading KubeJS script: Assignment to undeclared variable invnames (server_scripts:unify.js#385)

Minecraft: 1.18.2
KubeJS Version: 1802.5.5-build.546

How should I convert items

For example,convert cavesandcliffs:deepslate to quark:deepslate, their dictionaries all include forge: stone and cavesandcliffs:deepslate. I've been trying for a long time but haven't figured it out. Can you help me answer this question

[Question] Is it possible to add in exclusions or block-to-block conversions without using forge tags?

As the title suggests, I'm looking for a way to do specific replacements, or in some cases exclude specific items/blocks from conversion, as the catch-all nature of the tags in this causes some very problematic behavior with mods like Geolosys that add multiple ores of the same or similar type. The situations that arise from this are as following:

  1. Several geolosys ores share tags, as some are sources of multiple ores while others are single type (such as limonite tagged as both iron and nickel, while hematite is only iron). Using tag only conversion makes several materials unavailable depending on the conversion order (limonite is the only source of nickel through geolosys, and if it gets converted to hematite, nickel is impossible to acquire)
  2. The clusters dropped from mining geolosys ores are also tagged under forge:ores, resulting in either the clusters converting back into ore blocks when dropped (which makes them unusable in smelting recipes) or the blocks convert into clusters (which does some horrible breakage if global["unify_ore_gen"]="true")

I just wanted to know if it were possible to add in some kind of conversion blacklist or to allow block for block replacements somewhere in the script, or if it was something that would have to be rewritten to accommodate such changes.

Thanks for your time! And I greatly appreciate the fact that this script exists, it makes everything so much easier and cleaner overall.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.