Skip to content

Conversation

@null2264
Copy link
Owner

@null2264 null2264 commented Apr 25, 2023

This PR not only introduced "advanced custom generator", but also reworked how the mod handles fluid interaction as a whole to make it more compatible with most mods that control fluid interaction since it will only cancel the original function on success and doesn't directly touch how Minecraft handle fluid interactions.

Planned to be released for v4.0.

Features

Advanced Generators

This will allow players (and modpack makers) to create a custom generator with custom fluids or blocks

{
    // You can disable advanced generators by setting it like this:
    // advanced: {}
    //
    // Or just delete it entirely.

    "advanced": {
        // This is the fluid that will touch another fluid (in this example, it's lava touching water)
        "minecraft:lava": {
            "minecraft:water": {  // For this example, we mimic cobblestone/stone generator's behaviour
                // Result format is similar to custom generators' format
                "results": {  // Mimic cobblestone generator
                    "*": [  // Unlike custom generators' format, wildcard is supported as a modifier (accept any block)
                        {
                            "id": "minecraft:cobblestone",
                            "weight": 100.0
                        }
                    ]
                },
                // Only triggered when lava touch water from the top
                "resultsFromTop": {  // Mimic stone generator, only works for fluids
                    "*": [
                        {
                            "id": "minecraft:stone",
                            "weight": 100.0
                        }
                    ]
                }
            },
            "b:minecraft:blue_ice": {  // Mimic basalt generator's behaviour
                "results": {  // Blocks only support "results"
                    "minecraft:soul_soil": [
                        {
                            "id": "minecraft:basalt",
                            "weight": 100.0
                        }
                    ]
                }
            },
            "create:honey": {
                "silent": true,  // This will prevent generator from making the extinguish sound effect when block is generated
                "results": {
                    "*": [
                        {
                            "id": "create:limestone",
                            "weight": 100.0
                        }
                    ]
                }
            }
        }
    }
}

Fluid Interaction API

This is mainly for mod developers. With this developers can now create a plugin for CobbleGen, and register a fluid interaction more easily.

To make one, you need to create a class that implements CobbleGenPlugin, for example:

public class CreateFluidInteraction implements CobbleGenPlugin
{
    public void registerInteraction() {
        if (!FabricLoader.getInstance().isModLoaded("create")) return;
        FLUID_INTERACTION.addGenerator(
                Fluids.LAVA,
                new CobbleGenerator(List.of(new WeightedBlock("create:limestone", 1.0)),
                                    AllFluids.HONEY.get(),
                                    false
                )
        );
        FLUID_INTERACTION.addGenerator(
                Fluids.LAVA,
                new CobbleGenerator(List.of(new WeightedBlock("create:scoria", 1.0)),
                                    AllFluids.CHOCOLATE.get(),
                                    false
                )
        );
    }
}

Then add your plugin location to a cobblegen_plugin entrypoint in fabric.mod.json, for example:

  "entrypoints": {
    "cobblegen_plugin": [
      "io.github.null2264.cobblegen.integration.create.CreateFluidInteraction"
    ]
  },

Checklist

  • Fluid Interaction API
    This should make CobbleGen more compatible with most mods that control fluid interactions
    • Make other generators use this API
    • Implement Advanced Custom Generator
  • Testing
    • Without Create/Porting Lib
      • 1.18.2
      • 1.19.2
    • With Create/Porting Lib
      • 1.18.2
      • 1.19.2

@null2264 null2264 marked this pull request as draft April 25, 2023 04:09
@null2264 null2264 added the enhancement New feature or request label Apr 25, 2023
@DemonSlayer112
Copy link

This looks amazing! :D
I assume if we wanted a basalt gen to work with only 1 block, like soul sand only, we would specifiy "blue_ice" as being "air"?

And if we did do this, how would the mod treat a normal basalt gen(lava near soulsoil and ice) apart from lava(near just....a soulsoil and air for instance)?

also for a little fun for people air is a outputable block xD
Ig this is amazing for farm testing

@null2264
Copy link
Owner Author

I assume if we wanted a basalt gen to work with only 1 block, like soul sand only, we would specifiy "blue_ice" as being "air"?

Correct

And if we did do this, how would the mod treat a normal basalt gen(lava near soulsoil and ice) apart from lava(near just....a soulsoil and air for instance)?

Because of how the mod is coded, it'll probably overwrite normal basalt gen unless you surround the generated block with blocks other than air and a blue ice.

Here's a working build for testing.
cobblegen.zip

@null2264 null2264 changed the base branch from 1.18+ to dev/1.18+/4.0 April 28, 2023 02:45
REI/EMI/JEI is broken in this commit, because config handler is overhauled to be processed on launch (and `/reload`). This will allow other people to add their own generator with relative ease.
@null2264 null2264 marked this pull request as ready for review May 10, 2023 12:33
@null2264 null2264 merged commit 09197a2 into dev/1.18+/4.0 May 10, 2023
@null2264 null2264 deleted the feat/fluidInteraction branch May 10, 2023 23:06
null2264 added a commit that referenced this pull request May 15, 2023
* feat: Fluid Interaction Overhaul (#23)

* feat: Advanced fluid interaction

* feat: Wildcard support

* chore: Exit early if advanced generator is not configured

* chore: Disable advanced generators by default

* feat: Allow users to define advanced custom stone generators

* chore: Simplify code

* chore: Simplify code

* feat: Silent generator

* refactor: Merge generators

* chore: Optimize code

* chore: Improving readability

* chore: Simplify code

* feat: Fluid Interaction API (Big overhaul)
REI/EMI/JEI is broken in this commit, because config handler is overhauled to be processed on launch (and `/reload`). This will allow other people to add their own generator with relative ease.

* fix: REI/EMI/JEI integration

* fix: Pipe always generate cobblestone instead of stone

* feat: Built-in plugin for Create mod

* refactor: Reformat code

* chore: Bump version to 4.0 (ALPHA)

* fix: HotFix after Play-test
* Empty fluid for all-fluid generators caused issues
* Fix Limestone and Scoria generators
* Crash caused by null generators
* Add 'WeightedBlock.fromBlock'

* chore: Bump version to 4.0.1
Also append version stage to modrinth releases

* fix: Registrate pain, fixes #26

* fix: More Registrate pain
Of course it doesn't work, why would it be

* chore: Bump version to 4.0.2

* feat: Config Sync for Recipe Viewers (#27)

* feat: PacketByteBuf stuff

* feat: Working recipe viewer sync
Recipe viewer should now use server-side generator config instead of client-side

* feat: Don't use Fabric API

* feat: Don't send data to fake players

* feat: Only send config when player has recipe viewer installed

* chore: Bump version to 4.0.3

* chore: Bump version to 4.0.3

* fix: Oops, messed up git

* chore: Switch to SLF4J

* fix: Another overhaul another basalt gen bug

* fix: Registrate pain (again)
Why is this stupid thing keep breaking

* chore: Bump version to 4.0.4

* chore: I give up, remove create mod built-in plugin
Fluid always return EmptyFluid for some reason. Could be caused by how fabric load mods... idk, whatever i'm done dealing with this stupid thing

* chore: Rework on how plugin being registered

* chore: Rearrange some stuff

* chore: Add helper class

* chore: Clean up

* chore: Apply CobbleGen late
This also make CobbleGen reload everytime you enter a singleplayer world (Probably better for most players anyway)

* chore: Bump version to 4.0.5

* chore: Re-added reload
Now that I think about it, keep loading json file seems like a bad idea... let's just load it when needed

* feat: Sync when server is reloaded

* chore: Move PlayerManagerMixin to network directory

* chore: Bump jankson version to 1.2.2

* chore: CobbleGen no longer use MixinExtras

* chore: Split built-in plugin and plugin for create mod

* chore: Clean up gradle
Fluid interaction no longer depends on Porting Lib to provide compatibility, so we no longer need to test the mod with and without Create

* chore: Polishing logs

* chore: Prepare beta release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants