Skip to content
This repository was archived by the owner on May 2, 2025. It is now read-only.

Material Generators

Luke Graham Landry edited this page Mar 7, 2023 · 1 revision

Material generators are the heart of your progression. They produce materials that you can spend in the shop or on upgrading your base. Generators can be upgraded to increase production of materials.

There's a keybind (M by default) to view your current storage and production of materials.

Data Pack Format

Each different type of material generator is its own entry in a data pack. These are defined by json files in the materialgenerators folder.

A single generator type can generate multiple types of materials if you want and they types of materials can change as it levels up.

Object Structure:

  • tiers: a list of data for each level.
    • cost: how many materials must be spent to upgrade to this level.
    • production: how many materials are generated at this level.
    • minBaseLevel: determines when a team unlocks the ability to upgrade to this tier. Optional, defaults to 0.
  • capture: configure requirements to claim the generator. Optional, defaults to just right click it.
    • waves: a list of resource locations of Attack Waves. Required. An empty list will allow instant capture by right clicking.
    • radiusBlocks: a team member must stay within x blocks of the generator during the capturing process. Optional, defaults to infinity.
    • durationTicks: how long until the capture times out. Optional, defaults to infinity.
    • failOnTimeout: what happens when the capture times out. If true, the capture will fail. If false, the capture will succeed. Optional, defaults to false.

Both cost and production are a MaterialCollection: simply a map of material type resource locations to integers representing an amount.

Currently there is no need to register the individual type of material separately. Anything that is referenced by a generator type will exist in game. This does mean that you have to be careful to spell everything correctly as you can accidentally create a new type of material.

Use the command below to get a block item that places a generator of a certain type to test it out. Since the data is stored as nbt, these can also be added to loot tables.

/give @p basedefense:looted_generator{type:"basedefense:metal",tier:0}

The capture field give you a way to make claiming terrain generators more challenging. When its configured for a type, right clicking the generator will start an attack instead of directly claiming the generator. Very similar to the nightly base attacks. If the team successfully defends the generator from the monsters, they capture it.

Config

Edit the world/serverconfig/basedefense-synced.json5 file.

The global rate at which materials are generated is defined by the materialGenerationTickInterval field. Each generator a team owns will add its production to their storage once per interval. It's measured in ticks (twentieths of a second).

Which type of generator should be used when a Terrain Generator spawns depends on the biome. The terrainGeneratorTypes field is a map of biome resource locations to generator type resource locations. The first time you open a world, the generated config file will contain all the registered biomes (including modded ones), set to basedefense:empty.

The icon to use for rendering each material type in guis is set by materialTextures. It's a map of material resource locations to 16x16 texture locations. Ex. "basedefense:silver": "minecraft:textures/item/iron_ingot.png",.

Clone this wiki locally