1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Changed new item type example to register

This commit is contained in:
DJ1TJOO 2022-02-03 11:50:52 +01:00
parent 1eaae0288c
commit 9807e47f49

View File

@ -120,11 +120,10 @@ class Mod extends shapez.Mod {
this.modInterface.registerSprite("sprites/fluids/water.png", RESOURCES["water.png"]); this.modInterface.registerSprite("sprites/fluids/water.png", RESOURCES["water.png"]);
// Make the item spawn on the map // Make the item spawn on the map
this.modInterface.runAfterMethod(shapez.MapChunk, "generatePatches", function ({ this.modInterface.runAfterMethod(
rng, shapez.MapChunk,
chunkCenter, "generatePatches",
distanceToOriginInChunks, function ({ rng, chunkCenter, distanceToOriginInChunks }) {
}) {
// Generate a simple patch // Generate a simple patch
// ALWAYS use rng and NEVER use Math.random() otherwise the map will look different // ALWAYS use rng and NEVER use Math.random() otherwise the map will look different
// every time you resume the game // every time you resume the game
@ -132,7 +131,10 @@ class Mod extends shapez.Mod {
const fluidType = rng.choice(Array.from(Object.keys(enumFluidType))); const fluidType = rng.choice(Array.from(Object.keys(enumFluidType)));
this.internalGeneratePatch(rng, 4, FLUID_ITEM_SINGLETONS[fluidType]); this.internalGeneratePatch(rng, 4, FLUID_ITEM_SINGLETONS[fluidType]);
} }
}); }
);
this.modInterface.registerItem(FluidItem, itemData => FLUID_ITEM_SINGLETONS[itemData]);
} }
} }