-
Notifications
You must be signed in to change notification settings - Fork 2
Adding Sippables: Code
If you find that StatusEffects don't accommodate your needs - and know how to type gradlew build - you can create your very own, one-of-a-kind Sippable. It's very simple.
First, Navigate to your ModInitializer#onInitialize or any init()-like method that gets called from it in some other class.
Then, type in the following:
SippableRegistryCallback.EVENT.register(() -> { });Next, you'll want to choose one of the "fromThing" methods in Sippable that make sure your Sippable gets passed to the registry:
Currently doesn't exist as of 0.6.1, oops!
Queries the TagRegistry for a specified tag, then registers the given Sippable for all of its values.
Loops the fluid registry using the given predicate, and registers the given Sippable for any match.
Once you've chosen the method that seems attractive, you can put it inside the callback lambda and fill out the parameters.
Let's say I want to make a Sippable that randomly teleports the player around, and make it associated with all of the fluids that haveender as their identifier path:
SippableRegistryCallback.EVENT.register(() -> {
Sippable.fromPredicate("ender", new Sippable() {
@Override
public void onSipped(FluidKey drank, World world, PlayerEntity player) {
BlockPos randPos = player.getBlockPos().add(-8 + world.random.nextInt(17), world.random.nextInt(8), -8 + world.random.nextInt(17));
if (!world.getBlockState(randPos).getMaterial().isSolid()) {
player.setPos(randPos.getX(), randPos.getY(), randPos.getZ());
player.playSound(SoundEvents.ENTITY_ENDERMAN_TELEPORT, 1.0F, 1.0F);
}
}
});
});That's pretty much it!