Skip to content

[EN] TFG Custom Kubejs Scripts

Pyritie edited this page Sep 1, 2025 · 14 revisions

Startup Scripts

General Info

  • Other kubejs binders still work with any of these methods e.g. .tagBlock()
  • Unless otherwise stated--All new methods can accept cardinal based block state jsons to allow them to rotate around the y-axis. Example below.

Example of a cardinal block state json. v

{
  "variants": {
    "facing=east": {
      "model": "tfg:block/test",
      "y": 270
    },
    "facing=north": {
      "model": "tfg:block/test",
      "y": 180
    },
    "facing=south": {
      "model": "tfg:block/test"
    },
    "facing=west": {
      "model": "tfg:block/test",
      "y": 90
    }
  }
}



Particle Emitter Blocks

There are two methods available for creating particle emitting blocks; tfg:particle_emitter_decoration and tfg:particle_emitter. Creating a particle_emitter_decoration with make a block with properties similar to a grass block--With random offset, smaller box size, canSurvive conditions, etc. Creating a particle_emitter will create a normal minecraft block.

Method

	event.create(string name, 'tfg:particle_emitter_decoration') // or 'tfg:particle_emitter'
		.particleOffset(double x, double y, double z)        // Determines the offset range that the particles spawn at. (default: 0.25, 1.0, 0.25)
		.particleVelocity(double x, double y, double z)      // Determines the velocity of the particles. (default: 0.0, 0.07, 0.0)
		.particle(string simpleParticleType)                 // Determines the type of particle
		.dustColor(float r, float g, float b, float scale)   // Optional. If particle type is 'minecraft:dust', assigns color and scale. (float from 0.0 to 1.0)
		.particleCount(int)                                  // Determines the number of particles spawning per tick. (Default: 1)
		.particleForced(boolean)                             // Determines if the particles will be visible from a far distance. (Default: false)

Example

StartupEvents.registry('block', event => {
	event.create('tfg:test', 'tfg:particle_emitter_decoration')		
		.particleOffset(0.3, 2, 0.3)                        //x, y, z
		.particleVelocity(0, 0.1, 0)                        //x, y, z
		.particle('minecraft:dust')
		.dustColor(0.0, 1.0, 0.2, 1.5)                      //r, g, b, scale
		.particleCount(6)
		.particleForced(true)
})

The above example will make a decoration block that spawns green minecraft:dust particles above the block. v particle_emitter_decoration_example Notes:

  • Forcing particles will enable them to appear at far distances, but they will not generate if the player is not within range.
  • All binders are optional, the builder method has pre set defaults.
  • Particles in Minecraft behave with their own custom hard-coded physics on a per-particle basis. A particle may not generate as you might expect.



Decorative Plant Blocks

There are two methods available for decorative plant blocks tfg:decorative_plant and tfg:tall_decorative_plant. Decorative_plant will create a block with typical plant block attributes like random offset, instant break, non place able on unsupported faces, and smaller box size. While the tall_decorative block does the same thing but as an n-block tall plant. Use the height() method to set the maximum height of the tall block, up to a maximum of 5. By default the builder will automatically make loot tables for harvesting the plant with knives, hoes, and scythes. Both of these also support waterlogging with water, sea water, spring water, and mars water. (More fluids can be added via Core)

Methods

event.create(string name, 'tfg:decorative_plant')      // Default box size (3, 0, 3, 13, 7, 13)
event.create(string name, 'tfg:tall_decorative_plant') // Default box size (2, 0, 2, 14, 16, 14)

Examples

StartupEvents.registry('block', event => {
	event.create('tfg:test', 'tfg:decorative_plant')
		.soundType('nether_wart')        
		.tagItem('tfg:venus_plants')
		.box(3, 0, 3, 13, 14, 13)
})
StartupEvents.registry('block', event => {
	event.create('tfg:test', 'tfg:tall_decorative_plant')
		.soundType('nether_wart')
		.tagItem('tfg:venus_plants')
		.lightLevel(0.4)
		.renderType('translucent')
		.height(3) // 2 by default
})

You will also need to provide a blockstate file for the tall_decorative_plant, like this: You will need to provide states for ALL of the possible heights from 0 to 4, even if some are unused! Otherwise you get log spam.

{
  "variants": {
    "height=0": {
      "model": "tfg:block/test_bottom"
    },
    "height=1": {
      "model": "tfg:block/test_top"
    },
    "height=2": {
      "model": ""
    },
    "height=3": {
      "model": ""
    },
    "height=4": {
      "model": ""
    }
  }
}

An example of tfg:decorative_plant. v decorative_plant_example An example of tfg:tall_decorative_plant. v double_decorative_plant_example Notes:

  • Tall decorative blocks do not currently support cardinal block states.



Clone this wiki locally