Skip to content

Adding your own gases

Pyrofab edited this page Feb 12, 2018 · 6 revisions

Gases have their own registry. As such, you can register new gases using the appropriate registry event, like so:

public void addGases(RegistryEvent.Register<IGas> event) {
  event.register(new Gas(GasTypes.SMOKE, 0xFFF4C242).setRegistryName(YourMod.MOD_ID, "my_smoke"));
}

The code above will register a new colored smoke, which is the most basic gas you can make. It will automatically add the corresponding tube and grenade to gaspunk's creative tab as well. There are however several ways of adding custom behaviour for your gas. First, create a class that implements IGas, preferably extending the provided Gas class. You can then override its methods to your liking.

The most useful method to override should be applyEffect. This method is called every tick when an entity is breathing your gas. Most parameters should be fairly explicit, though you may be wondering what concentration is. Gas clouds actually compute the clear path distance in blocks between the emission point and the affected entities. That concentration is the computed distance divided by the maximum gas propagation distance.

Lingering gases

If your gas implements ILingeringGas, a potion effect will automatically get registered along with it. You can use this potion effect to affect entities after they've left your gas cloud.

Clone this wiki locally