From 9807e47f49632d16ac2459fb67c8116235337b07 Mon Sep 17 00:00:00 2001 From: DJ1TJOO Date: Thu, 3 Feb 2022 11:50:52 +0100 Subject: [PATCH] Changed new item type example to register --- mod_examples/new_item_type.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/mod_examples/new_item_type.js b/mod_examples/new_item_type.js index 3cd52cef..3f47d4d2 100644 --- a/mod_examples/new_item_type.js +++ b/mod_examples/new_item_type.js @@ -120,19 +120,21 @@ class Mod extends shapez.Mod { this.modInterface.registerSprite("sprites/fluids/water.png", RESOURCES["water.png"]); // Make the item spawn on the map - this.modInterface.runAfterMethod(shapez.MapChunk, "generatePatches", function ({ - rng, - chunkCenter, - distanceToOriginInChunks, - }) { - // Generate a simple patch - // ALWAYS use rng and NEVER use Math.random() otherwise the map will look different - // every time you resume the game - if (rng.next() > 0.8) { - const fluidType = rng.choice(Array.from(Object.keys(enumFluidType))); - this.internalGeneratePatch(rng, 4, FLUID_ITEM_SINGLETONS[fluidType]); + this.modInterface.runAfterMethod( + shapez.MapChunk, + "generatePatches", + function ({ rng, chunkCenter, distanceToOriginInChunks }) { + // Generate a simple patch + // ALWAYS use rng and NEVER use Math.random() otherwise the map will look different + // every time you resume the game + if (rng.next() > 0.8) { + const fluidType = rng.choice(Array.from(Object.keys(enumFluidType))); + this.internalGeneratePatch(rng, 4, FLUID_ITEM_SINGLETONS[fluidType]); + } } - }); + ); + + this.modInterface.registerItem(FluidItem, itemData => FLUID_ITEM_SINGLETONS[itemData]); } }