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,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]);
}
}