-
Notifications
You must be signed in to change notification settings - Fork 0
Events
tttsaurus edited this page Sep 29, 2024
·
15 revisions
Firstly
import mods.fluidintetweaker.event.CustomFluidInteractionEvent;
CustomFluidInteractionEvent will be posted to Forge's EVENT_BUS when a fluid interaction is detected, and the output block will be placed after posting CustomFluidInteractionEvent since the placement is achieved by listening to CustomFluidInteractionEvent.
Available Getters
boolean isLiquidAboveAndBelowCaseIBlockState liquidBlockStateBeforeInteractionILiquidDefinition liquidBeforeInteractionString liquidInteractionRecipeKeyIWorld worldIBlockState blockStateIBlock blockIBlockPos positionint xint yint zboolean canceled
Available Setters
boolean canceled
Available Methods
void cancel()
import mods.fluidintetweaker.event.CustomFluidInteractionEvent;
// since zenutils 1.16.0
import mods.zenutils.EventPriority;
events.register(function(event as CustomFluidInteractionEvent)
{
event.cancel();
}, EventPriority.highest(), true);
// set the priority to the highest so it really cancels the event
By the way, the listening method below without using zenutils is also available.
events.onCustomFluidInteraction(function(event as CustomFluidInteractionEvent)
{
});
However, it's not capable of canceling the event successfully due to the priority reason.
In this case, flowing cobalt + water -> 70% stone & 30% cobalt ore.
import mods.fluidintetweaker.FITweaker;
import mods.fluidintetweaker.event.CustomFluidInteractionEvent;
var recipes as [string] = FITweaker.addRecipe(<liquid:cobalt>, false, <liquid:water>, <item:minecraft:stone>.asBlock());
FITweaker.addRecipe(<liquid:cobalt>, true, <liquid:water>, <item:minecraft:obsidian>.asBlock());
events.onCustomFluidInteraction(function(event as CustomFluidInteractionEvent)
{
var thisRecipe = event.liquidInteractionRecipeKey;
for recipe in recipes
{
if (recipe == thisRecipe)
{
// 30% chance to spawn a cobalt ore instead of the stone
var p = event.world.random.nextFloat(0, 1);
if (p <= 0.3f)
{
event.world.setBlockState(<blockstate:tconstruct:ore>, event.position);
}
}
}
});
In the Overworld, lava + water -> stone, but end stone instead in the End. (example provided by penteractgaming from CurseForge)
import mods.fluidintetweaker.FITweaker;
import mods.fluidintetweaker.event.CustomFluidInteractionEvent;
var recipes as [string] = FITweaker.addRecipe(<liquid:lava>, false, <liquid:water>, <item:minecraft:stone>.asBlock());
events.onCustomFluidInteraction(function(event as CustomFluidInteractionEvent)
{
var thisRecipe = event.liquidInteractionRecipeKey;
for recipe in recipes
{
if (recipe == thisRecipe)
{
val biome_name as string = event.world.getBiome(event.position).name;
if (biome_name == "The End")
event.world.setBlockState(<blockstate:minecraft:end_stone>, event.position);
}
}
});