GithubHelp home page GithubHelp logo

kubejs's Introduction

KubeJS

Note: If you are a script developer (i.e. pack dev, server admin, etc.), you likely want to visit our website or the wiki instead.

(For a Table Of Contents, click the menu icon in the top left!)

Introduction

KubeJS is a multi-modloader Minecraft mod which lets you create scripts in the JavaScript programming language to manage your server using events, change recipes, add and edit (coming soon!) loot tables, customise your world generation, add new blocks and items, or use custom integration with other mods like FTB Quests for even more advanced features!

Issues and Feedback

If you think you've found a bug with the mod or want to ask for a new feature, feel free to open an issue here on GitHub, we'll try to get on it as soon as we can! Alternatively, you can also discuss your feature requests and suggestions with others using the Discussions tab.

And if you're just looking for help with KubeJS overall and the wiki didn't have the answer for what you were looking for, you can join our Discord server and ask for help in the support channels, as well!

License

KubeJS is distributed under the GNU Lesser General Public License v3.0, or LGPLv3. See our LICENSE file for more information.

Creating addons

Creating addon mods for KubeJS is easy! Just follow the following steps to your own liking, depending on how deep you want your integration to go!

Initial setup

To add a Gradle dependency on KubeJS, you will need to add the following repositories to your build.gradle's repositories:

repositories {
	maven {
		// Shedaniel's maven (Architectury API)
		url = "https://maven.architectury.dev"
		content {
			includeGroup "dev.architectury"
		}
	}

	maven {
		// saps.dev Maven (KubeJS and Rhino)
		url = "https://maven.saps.dev/minecraft"
		content {
			includeGroup "dev.latvian.mods"
		}
	}
}

You can then declare KubeJS as a regular compile-time dependency in your dependencies block:

// Loom (Fabric / Quilt / Architectury)
modImplementation("dev.latvian.mods:kubejs-<loader>:${kubejs_version}")

// ForgeGradle
implementation fg.deobf("dev.latvian.mods:kubejs-forge:${kubejs_version}")

// these two are unfortunately needed since fg.deobf doesn't respect transitive dependencies yet
implementation fg.deobf("dev.latvian.mods:rhino-forge:${rhino_version}")
implementation fg.deobf("dev.architectury:architectury-forge:${architectury_version}")

Just set the versions with most up-to-date version of the required mod(s), which you also find using these badges:

KubeJS Latest Version Rhino Latest Version Architectury Latest Version

(Note: The above badges may not represent the true latest version of these mods. As a basic rule of thumb, for KubeJS and Rhino, you should always be using the latest version compiled against your version of Minecraft, for example 1802.+ for Minecraft 1.18.2, while for Architectury, the corresponding major version will be provided. You can also click on the badge to see all versions of each mod)

You should of course use kubejs-forge for Forge projects and kubejs-fabric for Fabric projects. KubeJS' dependencies (notably, Rhino and Architectury) should all be downloaded automatically; otherwise, you may need to add them manually.

Fixing refmaps (ForgeGradle only)

KubeJS uses the official mappings for Minecraft ("mojmap"). Since the refmap remapper for Mixins on ModLauncher currently doesn't support non-MCP mappings, you will need to add some extra lines to your runs to keep it from crashing, as detailed here on the Mixin issue tracker. Be sure to regenerate your runs afterwards!

minecraft {
	runs {
		client {
			property 'mixin.env.remapRefMap', 'true'
			property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
		}
		// should be analogue for any other runs you have
	}
}

Creating a plugin

KubeJS plugins are the main way to add KubeJS integration to your mods through code. They contain various convenient hooks for addon developers, to allow things such as:

  • performing certain actions during or after plugin or KubeJS initialisation (init, afterInit, etc.)
  • adding classes to the class filter (registerClasses) as well as custom bindings (registerBindings) and type wrappers (registerWrappers) for easier interaction with native code in user scripts (See below for an explanation and example use cases)
  • registering custom recipe handlers for modded recipe types (registerRecipeTypes - See below for an example)
  • registering custom event handler groups for the KubeJS event system (registerEvents, this is necessary in order to have the event group be accessible from scripts)
  • attaching extra data to players, worlds or the server, such that it can be accessed by script developers later (attach(Player|World|Server)Data - Example)

Adding recipe handlers

To add custom recipe handlers for your own modded recipe types, use KubeJS plugins as noted above. A concrete example of this can be found here for integration with the Thermal series, but we'll give you a simple outline of the process here as well:

public class MyExamplePlugin extends KubeJSPlugin {
	@Override
	public void registerRecipeTypes(RegisterRecipeTypesEvent event) {
		// for custom recipe types based on shaped recipes, like non-mirrored or copying NBT
		event.registerShaped("mymod:shapedbutbetter");        // analogue: registerShapeless

		// this is what you usually want to use for custom machine recipe types and the like
		event.register("mymod:customtype", MyRecipeJS::new);
	}
}

public class MyRecipeJS extends RecipeJS {
	public OutputItem result; // represents a single output item stack, which may have a chance attached to it 
	public InputItem ingredient; // represents an input item ingredient or ingredient stack

	// create is invoked when a recipe is created through script code,
	// with args being the list of parameters passed to the recipe constructor
	// if an args.get(i) call is out of bounds, it will return null instead, so
	// you don't need to worry about checking for out of bounds
	@Override
	public void create(RecipeArguments args) {
		result = parseOutputItem(args.get(0));
		ingredient = parseInputItem(args.get(1));
	}

	// example of a custom property that can be set through scripts
	// in this case, the experience property is saved to the recipe's JSON immediately,
	// rather than storing it in a field and serializing it all at once later;
	// this is recommended for "optional" properties that likely won't be supplied during `create`
	public CookingRecipeJS xp(float xp) {
		json.addProperty("experience", Math.max(0F, xp));
		save();
		return this;
	}

	// this is invoked when a recipe is loaded from JSON
	// (mostly used for modifying existing recipes, since new recipes
	// added by scripts are done through `create` instead)
	@Override
	public void deserialize() {
		result = parseOutputItem(json.get("result"));
		ingredient = parseInputItem(json.get("ingredient"));
	}

	// this is used both by modified and newly created recipes
	// to serialize them to JSON; currently, it is *required*
	// by default that your recipes are JSON-serializable,
	// and while you may be able to get away with code-only recipes
	// e.g. through overriding `createRecipe`, this is unsupported
	// since the assumed use case is that all recipes have some JSON representation
	@Override
	public void serialize() {
		if (serializeOutputs) {
			json.add("result", outputToJson(result));
		}

		if (serializeInputs) {
			json.add("ingredient", inputToJson(ingredient));
		}
	}

	// the next two methods are used during bulk recipe modification
	// (through RecipeFilter) to find recipes that contain a certain in- or output
	@Override
	public boolean hasInput(IngredientMatch match) {
		return match.contains(ingredient);
	}

	@Override
	public boolean hasOutput(IngredientMatch match) {
		return match.contains(result);
	}

	// these two methods are used to replace a given in- or output item with another using the given transformer
	@Override
	public boolean replaceInput(IngredientMatch match, InputItem with, InputItemTransformer transformer) {
		if (match.contains(ingredient)) {
			ingredient = transformer.transform(this, match, ingredient, with);
			return true;
		}

		return false;
	}

	@Override
	public boolean replaceOutput(IngredientMatch match, OutputItem with, OutputItemTransformer transformer) {
		if (match.contains(result)) {
			result = transformer.transform(this, match, result, with);
			return true;
		}

		return false;
	}
}

Adding bindings

Similarly to adding custom recipe types, you may also add custom bindings to KubeJS (see AntimatterAPI for a simple example). Bindings can be anything from single value constants (like the global HOUR = 3600000 (ms)) to Java class and method wrappers (such as the builtin Item binding, which is wrapping the ItemWrapper class), and can be constrained to individual scopes, contexts and script types, as well!

Setting class filters

KubeJS offers native Java type access in script files, meaning that basic Java types can be referenced directly by using for example Java.loadClass("package.class"). While builtin filters exist to prevent users from accessing any internal or potentially harmful packages added by Minecraft or its libraries directly, you may still want to explicitly deny access to certain classes or packages in your mod (or explicitly allow certain classes within a generally blacklisted package). To do this, you may either provide a class filter using a KubeJS plugin or you can avoid adding KubeJS as a dependency entirely by providing a simple kubejs.classfilter.txt file in your mod's resources with the following format (Note that comments aren't allowed in the actual file):

+mymod.api // This will *explicitly allow* anything from the mymod.api package to be used in KubeJS
-mymod.api.MyModAPIImpl // This will deny access to the MyModAPIImpl class, while keeping the rest of the package accessible
-mymod.internal.HttpUtil // This will *explicitly deny* your class from being used in KubeJS

Contributing to KubeJS

Getting Started

If you want to contribute to KubeJS, you will first need to set up a development environment, which should be fairly simple. Just clone the repository using Git:

git clone https://github.com/KubeJS-Mods/KubeJS.git

and import the gradle project using an IDE of your choice! (Note: Eclipse is likely to have problems with Architectury's runs, but IDEA and VS Code should work fine.)

Building

Building KubeJS from source should be rather straightforward, as well, just run gradlew build in the root project, and the corresponding jars for Forge and Fabric should be in the respective module's build/libs directory (kubejs-<loader>-<version>.jar). The project will also produce a common jar; that one however should not be used in production.

Creating Pull Requests

When creating a pull request to KubeJS, please make sure you acknowledge the following:

  • We will usually not accept pull requests that add mod-specific support; those things are better suited as KubeJS plugins (optimally within the target mods themselves) or integration mods.
  • Please be sure to test your feature before creating a pull request. We are a rather small team and as such, can't spend all too much time on reviewing pull requests.
  • While not strictly required, please try to adhere by the repository's code style and conventions. A sample .editorconfig file exists to make this even easier for you to achieve (see the relevant EditorConfig plugin for your IDE)
  • If you are unsure whether your feature fits into KubeJS and would like to hear additional opinions on the matter, feel free to open an issue or a discussion to discuss it further with us first!

kubejs's People

Contributors

amirhan-taipovjan-greatest-i avatar anawesomguy avatar chiefarug avatar embeddedt avatar evanhsieh0415 avatar frinn38 avatar hunter19823 avatar imak9 avatar impleri avatar latvianmodder avatar llytho avatar lonevox avatar maxneedssnacks avatar melanx avatar michaelhillcox avatar notenoughmail avatar pietro-lopes avatar prunoideae avatar reabstraction avatar sciguyryan avatar screret avatar shartte avatar shedaniel avatar spiker985 avatar squiddev avatar squoshi avatar subordinalblue avatar technici4n avatar xaidee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubejs's Issues

Editing / Removing structure spawns

As you said, could be possible through worldgen event?
There was a mod for 1.12 that had the ability to disable specific structures by tapping into onChunkPopulate but that's probably changed by now I would assume.

Game crashes upon loading KubeJS

I was playing FTB Academy, and when, in the first stage of loading, the game reached KubeJS it crashed. Is this something wrong the mod or the modpack?

[1.16.4 forge, v 1604.3.2.121] Mekanism Addon doesn't work for Infusing

The example that was on the Curseforge page for the Mekanism addon for the Metallurgic Infuser doesn't seem to be working. Is the example incorrect? Otherwise, Kube and the mekanism addon seems to be working, the recipe I added with the crusher works fine. Here's the line I'm using, it's in events.listen for recipes, and other recipes in the same block are working.
event.recipes.mekanism.metallurgic_infusing('minecraft:comparator', 'minecraft:nether_quartz', 'mekanism:redstone', 20)
I've tried using item.of() on the inputs/outputs, no dice. Any help would be greatly appreciated. A few other questions that the docs weren't able to answer - Is there a way to add new fluids the same way you can add items and blocks? and is there a way, aside from making multiple recipes, to allow for multiple inputs, aside from forge tags? Aside from this, the mod's been working really well for what I want it to do, thanks for making it!

[Suggestion] Verbose output with "Skipping loading recipe"

I am building a mod pack and get a lot of "Skipping loading recipe" messages. Would it be possible to get the recipes in the output of this message so I can troubleshoot the reason they are being skipped?

Let me know if you need more details.

1.15.2 Incompatible with Immersive Portals (Forge)

I have 3 mods installed: KubeJS (and MixinBootstrap), Immersive Portals and Advanced Mining Dimension.

My script should allow the player to teleport to the mining dimension when they go to level 1 in the overworld.

// On world load events
events.listen('world.load', event => {
    event.server.runCommand('/gamerule sendCommandFeedback false')
})

// Dimension stacking
events.listen('player.tick', event => {
    if (event.player.isFake()) return null
    if (event.player.y == '1') {
        if (event.player.getWorld().getDimension().toString() == 'DimensionType{minecraft:overworld}') {
            event.server.runCommand(`/execute in mining_dimension:mining_world positioned ${event.player.x} ${event.player.y} ${event.player.z} run tp ${event.player} ~ 252 ~`)
            event.server.schedule(3, event.server, cb => {
                cb.data.runCommand(`/execute in mining_dimension:mining_world positioned ${event.player.x} 252 ${event.player.z} run fill ~ ~ ~ ~ ~1 ~ air replace #forge:stone`)
            })
        }
        if (event.player.getWorld().getDimension().toString() == 'DimensionType{mining_dimension:mining_world}') {
            event.server.runCommand(`/execute in minecraft:the_nether positioned ${event.player.x} ${event.player.y} ${event.player.z} run tp ${event.player} ~ 124 ~`)
            event.server.schedule(3, event.server, cb => {
                cb.data.runCommand(`/execute in minecraft:the_nether positioned ${event.player.x} 124 ${event.player.z} run fill ~ ~ ~ ~ ~1 ~ air replace #forge:stone`)
            })
        }
    }
    if (event.player.y == '125') {
        if (event.player.getWorld().getDimension().toString() == 'DimensionType{minecraft:the_nether}') {
            event.server.runCommand(`/execute in mining_dimension:mining_world positioned ${event.player.x} ${event.player.y} ${event.player.z} run tp ${event.player} ~ 2 ~`)
            event.server.schedule(3, event.server, cb => {
                cb.data.runCommand(`/execute in mining_dimension:mining_world positioned ${event.player.x} 2 ${event.player.z} run fill ~ ~ ~ ~ ~1 ~ air replace #forge:stone`)
                cb.data.runCommand(`/execute in mining_dimension:mining_world positioned ${event.player.x} 1 ${event.player.z} run fill ~ ~ ~ ~ ~ ~ cobblestone_slab replace air`)
            })
        }
    }
    if (event.player.y == '253') {
        if (event.player.getWorld().getDimension().toString() == 'DimensionType{mining_dimension:mining_world}') {
            event.server.runCommand(`/execute in minecraft:overworld positioned ${event.player.x} ${event.player.y} ${event.player.z} run tp ${event.player} ~ 2 ~`)
            event.server.schedule(1, event.server, cb => {
                cb.data.runCommand(`/execute in minecraft:overworld positioned ${event.player.x} 2 ${event.player.z} run fill ~ ~ ~ ~ ~1 ~ air replace #forge:stone`)
                cb.data.runCommand(`/execute in minecraft:overworld positioned ${event.player.x} 1 ${event.player.z} run fill ~ ~ ~ ~ ~ ~ cobblestone_slab replace air`)
            })
        }
    }
})

This script will work perfectly without immersive portals installed, but will fail to run properly with it.
The /reload command also sometimes causes a memory leak (minecraft runs out of memory)

there is no actual documentation in KubeJS's Aurora pages

KubeJS's "documentation" in Aurora doesn't actually provide documentation.
It just gives you a source/function map, and no actual documentation.
Absolutely jack-s*** about how to use anything.
All it tells you is the names of functions and arguments.
But nothing about what any of it does, nor what they're for.

Edit:
wouldn't be so bad if it had examples, but it doesn't.
Thank goodness for this documentation, would have no clue about how to use KubeJS without it.

Scripts dont load on java 1.8.0_111

I have been having issues with my server not have recipes made through kubejs through my own finding it does not work on java 1.8.0_111 I am not sure if this is an actual issue but it might help people that pay for hosting going crazy on why it works if you launch a server on your local machine and singleplayer and the recipes work

[1.16] /kubejs hand doesn't copy on click

The command /kubejs hand doesn't allow me to copy the output when clicked. Additionally, it would be nice if the item registry name was automatically applied to the clipboard tbh.

kubejs-2.7.2.56

KubeJS crashes during runData in development

[12:59:16] [modloading-worker-6/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Failed to create mod instance. ModID: kubejs, class dev.latvian.kubejs.KubeJS
java.lang.NullPointerException: null
	at dev.latvian.kubejs.client.KubeJSClient.init(KubeJSClient.java:40) ~[kubejs:1604.3.1.80] {re:classloading}
	at dev.latvian.kubejs.KubeJS.<init>(KubeJS.java:114) ~[kubejs:1604.3.1.80] {re:classloading}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_272] {}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_272] {}
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_272] {}
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_272] {}
	at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_272] {}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) ~[forge:35.0] {re:classloading}
	at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:110) ~[forge:?] {re:classloading}
	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) [?:1.8.0_272] {}
	at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) [?:1.8.0_272] {}
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_272] {}
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_272] {}
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_272] {}
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) [?:1.8.0_272] {}

Minecraft.getInstance() is returning null.

First issue

People like to write jokes as first submitted issue, so I will take this fun away from them

[1.15.2] Game Crash with kubejs-2.7.0.41.jar

Hi,

I'm using:

  • Forge 31.2.22
  • kubejs-2.7.0.41.jar
  • ftb-quests-2.0.2.246.jar

Error: Failed to create mod instance. ModID: ftbquests, class com.feed_the_beast.ftbquests.FTBQuests
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: dev/latvian/kubejs/documentation/DocumentationEvent

if I'm using kubejs-2.6.2.40.jar this works fine in this pack

latest.log

crash.txt

Minecraft Game Output

[1.16.3] KubeJS Does Not Load Mekanism Precision Sawmill Recipes

Issue description:

Precision Sawmill recipes do not register when KubeJS mod is loaded.

Steps to reproduce:

  1. Create a new 1.16.3 instance with Forge, Mekanism, JEI, and KubeJS using versions listed below.
  2. Start a new world and try to view sawmill uses or place logs in sawmill.

Version (make sure you are on the latest version before reporting):

Forge: 34.1.14
Mekanism: 10.0.11.436
Other relevant version:
KubeJS - 1603.2.8.70
JEI - 7.5.0.43

If a (crash)log is relevant for this issue, link it here: (It's almost always relevant)

latest.log

All other machinery from Mekanism (and other mods for that matter) that I've tested work fine. Only the precision sawmill and related factories do no have recipes loaded. Also tested with KubeJS version 2.8.0.65 and results were the same.

Extreme Reactors' recpies don't get removed for some reason

`events.listen('recipes', event => {

event.remove({id: 'angelring:itemring'})
event.remove({id: 'bigreactors:basic_reactorcasing'})
event.remove({id: 'bigreactors:reinforced_reactorcasing'})
event.shaped(Item.of('bigreactors:basic_reactorcasing', 2), [
	'IGI',
	'GCG',
	'IGI'
  ], {
	I: '#forge:ingots/iron',
	G: '#forge:ingots/graphite',
	C: 'thermal:machine_frame'
  })
event.shaped(Item.of('angelring:itemring', 1), [
	'GHG',
	'UDM',
	'GNG'],
	{
		G: '#forge:ingots/gold',
		H: 'simplyjetpacks:jetpack_ie3',
		U: 'simplyjetpacks:jetpack_mek4',
		D: 'angelring:itemdiamondring',
		M: 'mekanism:jetpack_armored',
		N: 'minecraft:nether_star'
	}
)
event.shaped(Item.of('bigreactors:reinforced_reactorcasing', 2), [
	'SGS',
	'GCG',
	'SGS'
  ], {
	S: '#forge:plates/steel',
	C: 'mekanism:steel_casing',
	G: '#forge:ingots/graphite'
  })

})`

Rest of the recipes from here work normally, but Extreme Reactor recipes are still there:
Screenshot_2
Screenshot_3

/kubejs docs Command Not Working

I downloaded kubejs.jar file from curse and moved it to my mods folder on my server. I start the server and open my client (running ftb academy 1.0.0). I type in the command "/kubejs docs" like it says i should do to find the documentation but an error pops up saying:

Invalid subcommand 'docs'! Available subcommands: reload

I just want to find the documentation for the mod so i can figure out what different scripts i will use on my server. If there is something I am missing I would gladly like to hear about it since im brand new to this mod and could have missed up big time. I know there are examples of code at https://kubejs.latvian.dev/ but having all the commands would greatly help more. If this is an upcoming feature I would like to know that.

Thank you for your time and I can't wait to start writing scripts using your powerful mod tool. If you want to contact me faster pm me using my discord name as I am apart of your LatMod Industries server and I am using the same name as github "ReelablePenny14". Or just respond below. Thanks again!

1.16.1 - game crashes at creating world screen

MC 1.16.1
Forge 32.0.38-39
kubejs-2.7.0.42.jar

Probably to be expected with a fresh, new Minecraft version, but the game crashes shortly after clicking Create World when KubeJS is enabled. Disabling it allows the world to load normally.

Also, the FML background in newer Forge versions is now an angry red, and the colors in your client.properties no longer seem to override it. I do have FancyMenu installed, but it seems to only affect the Mojang logo, so I think the red is from Forge themselves?

Just wanted to let you know. Thanks!

crash-2020-07-01_18.58.58-client.txt

Crash on spongeforge when stop server

When using kobejs with spongeforge mod, shutting down the server can cause kubrjs crash with theese log below.
After remove the spongeforge mod, the server can stop normally without any problems。

[13:24:51] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Done (5.830s)! For help, type "help" or "?"
>asdfasdfasdf
[13:24:55] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Unknown command. Try /help for a list of commands
>save-all
[13:24:58] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Saving...
[13:24:58] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Saved the world
>stop
[13:25:01] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Stopping the server
[13:25:01] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: Encountered an unexpected exception
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from KubeJS (kubejs)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 31
at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$MapIterator.nextEntry(Int2ObjectOpenHashMap.java:642) ~[Int2ObjectOpenHashMap$MapIterator.class:?]
at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$ValueIterator.next(Int2ObjectOpenHashMap.java:876) ~[Int2ObjectOpenHashMap$ValueIterator.class:?]
at dev.latvian.kubejs.world.KubeJSWorldEventHandler.onServerStopping(KubeJSWorldEventHandler.java:66) ~[KubeJSWorldEventHandler.class:?]
at dev.latvian.kubejs.KubeJS.onServerStopping(KubeJS.java:160) ~[KubeJS.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_251]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637) ~[forge-1.12.2-14.23.5.2838-universal.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_251]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[minecraft_server.1.12.2.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219) ~[forge-1.12.2-14.23.5.2838-universal.jar:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197) ~[forge-1.12.2-14.23.5.2838-universal.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_251]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[minecraft_server.1.12.2.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[minecraft_server.1.12.2.jar:?]
at net.minecraftforge.fml.common.LoadController.redirect$zza000$forgeImpl$PostEvent(LoadController.java:568) ~[LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136) ~[LoadController.class:?]
at net.minecraftforge.fml.common.Loader.serverStopping(Loader.java:805) ~[Loader.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStopping(FMLCommonHandler.java:308) ~[FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:533) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
[13:25:01] [Server thread/INFO] [STDOUT]: [net.minecraft.crash.CrashReport:func_85057_a:300]: Negative index in crash report handler (0/5)
[13:25:01] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: This crash report has been saved to: D:\NPCCRAFT\2020_1.12.2\NPC_KFW_SERVER_2020.\crash-reports\crash-2020-06-19_13.25.01-server.txt
[13:25:01] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Stopping server
[13:25:01] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving players
[13:25:01] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving worlds
[13:25:01] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'world'/0
[13:25:01] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'DIM-1'/-1
[13:25:01] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'DIM1'/1
[13:25:01] [Server thread/INFO] [Sponge]: Unloading world [world] (minecraft:overworld/0)
[13:25:01] [Server thread/INFO] [Sponge]: Unloading world [DIM-1] (minecraft:nether/-1)
[13:25:01] [Server thread/INFO] [Sponge]: Unloading world [DIM1] (minecraft:the_end/1)
[13:25:01] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.

KubeJS not replacing outputs in Mystical Agriculture

I've tried to make a script that unifies all ore outputs using tags and my preferred mod, however Mystical Agriculture is not playing nice with my script, outputting to whatever the mod outputs to by default. It unifies everything else in my modpack except for Mystical Agriculture outputs. Is this just not supported or is there an extra line of code I need so that it'll replace MA's recipe outputs?

unify.zip

[1.16] jei.hide.items event never fires

The below code does nothing, although taken from the example provided in your Discord

console.log('Hiding items in JEI, pre-event');

events.listen('jei.hide.items', (event) => {
    console.log('Hiding items in JEI');
    // event.hide('/\\w+:\\w+_spawn_egg/');
    // event.hide('/minecraft:lingering_potion/');
    // event.hide('/minecraft:splash_potion/');
    event.hide('appliedenergistics2:facade');
});

The console log at the top shows in the log, the one within the event does not.
kubejs-2.7.2.56

Related to BotanyPots/adding sapling stop working after KubeJS 1604.3.1.84

When I use this script (it's adding tree in botany pots), when a sapling is used in hopper botany pots, the tree grows but they stop at 100% and nothing append.
With KubeJS 1604.3.1.84 and before, the tree grow then it get harvest like any other crops.

I have try many version of many mods involve (BotanyPots, rhino, architectury, kubejs) and it's when I pass at KubeJS over 1604.3.1.84 that the issue occur. I'm not sure what to look at this point.

Mods list of my last test:
-Bookshelf-1.16.4-9.1.13.jar
-Botania-1.16.3-409.jar
-BotanyPots-1.16.4-6.0.7.jar
-Cucumber-1.16.4-4.1.5.jar
-MysticalAgradditions-1.16.4-4.1.2.jar
-MysticalAgriculture-1.16.4-4.1.3.jar
-MysticalCustomization-1.16.4-2.1.1.jar
-Patchouli-1.16.2-47.jar
-architectury-1.1.54-forge.jar
-curios-forge-1.16.4-4.0.3.0.jar
-jei-1.16.4-7.6.0.58.jar
-kubejs-1604.3.1.104-forge.jar
-rhino-1.7.13.9.jar

botany_pots.js.txt

ref: AllTheMods/ATM-6#379

1.16.4 - game crashes at creating world screen

Similar to #15
MC 1.16.4
Forge 35.4.36
KubeJS 1604.3.4.143-forge
Architectury 1.3.78-forge

When trying to create a new world, first time the game gives the errors in currently selected datapack error, then if tried a second time it gives the following crash (Trying to proceed in safe mode results in the same error):
https://pastebin.com/XuuS1R7m

Latest: https://cdn.discordapp.com/attachments/359814544090071040/798752079455715338/latest.log
Debug: https://cdn.discordapp.com/attachments/359814544090071040/798752114208669706/debug.log

[1.16.1] java.lang.NoSuchMethodError

Hi,

the game crash with the latest 1.16.1 forge version

Minecraft: 1.16.1
Forge: 32.0.69
kubejs-2.7.0.45.jar
MixinBootstrap-1.0.3.jar

Steps to reproduce:

  1. Start game
  2. Create new single player game
  3. Crash when the game reaches nearly 100% and try to join the world

crash-server.txt

latest.log

Just a coding question.

Hi, I'm creating my own mod and I'm trying to handle blockstates and models for items/blocks that are not registered during mod build which means I cannot just create jsons for those blocks/items because I don't know them yet.
I know that kubejs allows the user to add items/blocks themselves which results in the same problem. I tried to find out how you did that but I didn't quite get through your code. Could you give me a little hint?

Crash on crafting

Very weird crash that happens when crafting items from the Farmer's Delight mod using the knife. I haven't done an extensive amount of testing on this, since my pack takes a very long time to load and it crashes both the client and the server when it happens.

Let me know if I should be reporting this to the Farmer's Delight dev instead.

Client side crash log: https://paste.ee/p/EgZP7#qZL8RDOT4dUeGw6IuazHVlfPmv5EL5Xq
Server side crash log: https://paste.ee/p/OwtMO#r3WWWgvhH8XXAETAOAAF6Hz4nxpoTRin

Item and block types

Block types:

- Slab
- Stairs
- Fence
- Fence Gate
- Wall
- Pressure Plate
- Button

  • Door (?)
  • Trapdoor (?)
  • Pillar (like log, rotates X Y Z only)
  • Omnidirectional (need better name, basically like piston/dispenser)
  • Horizontal (like carved pumpkin)

Item types: Done now

- Pickaxe
- Axe
- Shovel
- Hoe
- Sword
- Helmet
- Chestplate
- Leggings
- Boots
- Bow

Modify existing blocks and items

Block properties:

  • material
  • materialColor
  • hasCollision
  • lightEmission
  • explosionResistance
  • destroyTime
  • requiresCorrectToolForDrops
  • isRandomlyTicking (?)
  • friction
  • speedFactor
  • jumpFactor
  • canOcclude (?)
  • isAir (?)
  • isValidSpawn (?)
  • isRedstoneConductor (?)
  • isSuffocating (?)
  • isViewBlocking (?)
  • hasPostProcess (?)
  • emissiveRendering (?)

Item properties:

  • category
  • rarity
  • craftingRemainingItem
  • maxDamage
  • maxStackSize
  • food (?)
  • isFireResistant

breaks IE treated wood recipe

From the debug log:

Parsing error loading recipe immersiveengineering:crafting/treated_wood_horizontal: Shaped recipe ingredient {"amount":1000,"fluid":"immersiveengineering:creosote","type":"immersiveengineering:fluid"} with key 'b' is not a valid ingredient!

Adding KubeJS to IE makes the recipe disappear.

Another issue related to IE treated wood

See BluSunrize/ImmersiveEngineering#4277

This is apparently different from #14 (reporter in the IE issue is using the latest 1.16.1 build of KubeJS). The error message is

[Render thread/ERROR] [KubeJS Server/]: Parsing error loading recipe immersiveengineering:crafting/treated_wood_horizontal: java.lang.IllegalStateException: Tag forge:creosote used before it was bound

This shouldn't ever happen in IE code unless you're reading recipes from JSON on the client. I was going to debug this a bit more, but apparently FG doesn't properly deobfuscate Mixins.

[1.15.2] KubeJs delete recipes in alloy_smelting of silents mechanisms

Versions

  • KubeJs: 2.7.1.3
  • MixinBootstrap: 1.0.3
  • Silent's Mechanisms: 0.7.6
  • Silent Lib: 4.6.4
  • Forge: 31.2.5

Expected Behavior

Actual Behavior

  • Recipes in silents_mechanisms/data/recipes/alloy_smelting/ don't works

Links/Images

Steps to Reproduce the Problem

  1. Install kubejs and mixinbootstrap
  2. Just look the craft list of alloy smelter

Adding this mod appears to immediately break fluid recipes using alternate containers

Version: kubejs-2.7.0.41.jar

EnigmaticaModpacks/Enigmatica5#387

PneumaticCraft introduced a tank in 1.15 that can be used in place of buckets for batch fluid crafting. Similarly Immersive Engineering has it's Jerry Can which serves the same function.

Both of these stop working as soon as KubeJS is installed. The recipe for Treated Wood, for instance, only works with buckets. The recipe for PNC's Speed Upgrades only works with buckets of lubricant. Removing KubeJS resolves the issue and allows both crafts to work normally with buckets, jerry cans, and pnc tanks

[1.16.1] KubeJS conflict with Silents Mechanisms alloy recipes

You may already be aware, since this is similar to issue #19, but having KubeJS enabled breaks all SilentMech alloy recipes. Could be an issue with Silents Mechanisms since it is pretty new to 1.16, but thought I'd try here first.

latest.log: https://pastebin.com/mDpJeZhJ

Lots of recipe parsing errors, e.g.:
[25Jul2020 17:00:22.577] [Render thread/ERROR] [KubeJS Server/]: Parsing error loading recipe silents_mechanisms:alloy_smelting/electrum_ingot: Silents Mechanisms alloy smelting recipe ingredient null is not a valid ingredient!

Forge: 32.0.75
SilentMechanisms-1.16.1-0.8.1+62.jar
SilentLib-1.16.1-4.7.0+58.jar
kubejs-2.7.2.49.jar (tried earlier versions also)

Thanks. I know it must feel like herding cats sometimes. 😹

[Issue] KubeJS causes server to freeze on server stop.

The behavior is like so.
Load up the server with KubeJS and dependencies.
Server runs fine.
type "stop"

[19:45:50] [Server thread/INFO] [minecraft/DedicatedServer]: Stopping the server
[19:45:50] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[19:45:50] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[19:45:50] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[19:45:50] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[19:45:50] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (world): All chunks are saved
[19:45:50] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether
[19:45:50] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[19:45:50] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end
[19:45:50] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[19:45:50] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (world): All chunks are saved
[19:45:50] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[19:45:50] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved

This is all that reports in the console. No error. No notice. It just never unloads. java server is still running, taking up resources, etc.

I then have to use ctrl+c to forcefully stop it.

I've isolated it to the latest version of kubejs, this doesn't happen without it being present.

The following are the only mods installed at the time of reporting. (On a new world)

architectury-1.2.68-forge.jar
Bookshelf-1.16.4-9.3.18.jar
ftb-gui-library-1604.1.1.26.jar
GameStages-1.16.4-6.0.1.jar
jei-1.16.4-7.6.1.63.jar
kubejs-1604.3.4.136-forge.jar
rhino-1.7.13.9.jar

forge 35.1.28
MC 1.16.4

Custom food items cannot use non-vanilla potion effects

Not sure if this extends to all events that deal with potions, but modded potion effects lead to a game crash when a food that uses them is consumed.

script used in item creation:
event.create('foxtail_ramen').displayName('Foxtail Ramen').food(function(food){
food.hunger(10)
food.saturation(1)
food.effect('minecraft:regeneration', 400, 0, 1.0)})
food.effect('farmersdelight:comfort', 2400, 0, 1.0)})
food.effect('farmersdelight:nourished', 2400, 0, 1.0)})

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.