Skip to content

Use a datamap instead #36

Description

@wolfieboy09

object.has("burnTime") ?
object.get("burnTime").getAsInt() :
object.has("superHeat") && object.get("superHeat").getAsBoolean() ?
32 : 20
// Lava Burn Time per Mb is 20, create mod codes sets that 32 * 1000 / 10 for any superheat
// This is from BlazeBurnerBlockEntity#tryUpdateFuel (Line 193)
, object.has("superHeat") && object.get("superHeat").getAsBoolean() // default not to superheat
, object.has("amountConsumedPerTick") ?
object.get("amountConsumedPerTick").getAsInt() :
object.has("superHeat") && object.get("superHeat").getAsBoolean() ?
10 : 1 // default not to consume 10 if superHeat, 1 if not

Like, why??

Just do something like

public record LiquidFuel(
        Holder<Fluid> fluid,
        int burnTime,
        int amountConsumedPerTick,
        boolean superHeat
) {
    public static final Codec<LiquidFuel> LIQUID_FUEL_CODEC = RecordCodecBuilder.create(inst -> inst.group(
            FluidStack.FLUID_NON_EMPTY_CODEC.fieldOf("fluid").forGetter(LiquidFuel::fluid),
            Codec.INT.fieldOf("burnTime").forGetter(LiquidFuel::burnTime),
            Codec.INT.fieldOf("amountConsumedPerTick").forGetter(LiquidFuel::amountConsumedPerTick),
            Codec.BOOL.optionalFieldOf("superHeat", false).forGetter(LiquidFuel::superHeat)
    ).apply(inst, LiquidFuel::new));
}

Then for a datamap

    public static final DataMapType<Fluid, LiquidFuel> LIQUID_FUEL = DataMapType.builder(
            ResourceLocation.withNamespaceAndPath("createliquidfuel", "liquid_fuel"),
            Registries.FLUID,
            LiquidFuel.CODEC
    ).synced(
            LiquidFuel.CODEC,
            true
    ).build();

So people can attach this to datagen and not play dark magic

I beg of you for this feature. Save us all from your Gson and Triplet hell.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions