Skip to content

Commit

Permalink
inline some codecs, remove redundant interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Aug 10, 2024
1 parent 892fde6 commit b2341c0
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 52 deletions.
25 changes: 2 additions & 23 deletions src/api/java/mekanism/api/chemical/ChemicalStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public final class ChemicalStack implements IHasTextComponent, IHasTranslationKe
*
* @since 10.6.0
*/
public static final Codec<Chemical> CHEMICAL_NON_EMPTY_CODEC = chemicalNonEmptyCodec(MekanismAPI.CHEMICAL_REGISTRY);
public static final Codec<Chemical> CHEMICAL_NON_EMPTY_CODEC = MekanismAPI.CHEMICAL_REGISTRY.byNameCodec().validate(chemical -> chemical.isEmptyType() ? DataResult.error(() -> "Chemical must not be mekanism:empty") : DataResult.success(chemical));
/**
* A standard codec for non-empty Chemical holders.
*
* @since 10.6.0
*/
public static final Codec<Holder<Chemical>> CHEMICAL_NON_EMPTY_HOLDER_CODEC = chemicalNonEmptyHolderCodec(MekanismAPI.CHEMICAL_REGISTRY);
public static final Codec<Holder<Chemical>> CHEMICAL_NON_EMPTY_HOLDER_CODEC = MekanismAPI.CHEMICAL_REGISTRY.holderByNameCodec().validate(chemical -> chemical.value().isEmptyType() ? DataResult.error(() -> "Chemical must not be mekanism:empty") : DataResult.success(chemical));
/**
* A standard map codec for Chemical stacks that does not accept empty stacks.
*
Expand Down Expand Up @@ -101,27 +101,6 @@ public static Codec<ChemicalStack> fixedAmountCodec(int amount) {
}


/**
* A standard codec for chemicals.
*
* @implNote Unlike for fluids we do this on the objects instead of on the holders, as we don't have builtin holders.
* @since 10.6.0
*/
protected static <CHEMICAL extends Chemical> Codec<CHEMICAL> chemicalNonEmptyCodec(Registry<CHEMICAL> registry) {
return registry.byNameCodec().validate(chemical -> chemical.isEmptyType() ? DataResult.error(() -> "Chemical must not be mekanism:empty")
: DataResult.success(chemical));
}

/**
* A standard codec for chemicals.
*
* @since 10.6.0
*/
protected static <CHEMICAL extends Chemical> Codec<Holder<CHEMICAL>> chemicalNonEmptyHolderCodec(Registry<CHEMICAL> registry) {
return registry.holderByNameCodec().validate(chemical -> chemical.value().isEmptyType() ? DataResult.error(() -> "Chemical must not be mekanism:empty")
: DataResult.success(chemical));
}

/**
* A standard codec for chemical stacks that does not accept empty stacks.
*
Expand Down
6 changes: 0 additions & 6 deletions src/api/java/mekanism/api/providers/IGasProvider.java

This file was deleted.

6 changes: 0 additions & 6 deletions src/api/java/mekanism/api/providers/IInfuseTypeProvider.java

This file was deleted.

5 changes: 0 additions & 5 deletions src/api/java/mekanism/api/providers/IPigmentProvider.java

This file was deleted.

4 changes: 0 additions & 4 deletions src/api/java/mekanism/api/providers/ISlurryProvider.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import mekanism.api.chemical.Chemical;
import mekanism.api.chemical.ChemicalStack;
import mekanism.api.providers.IChemicalProvider;
import mekanism.api.providers.IGasProvider;
import moze_intel.projecte.api.codec.NSSCodecHolder;
import moze_intel.projecte.api.nss.AbstractNSSTag;
import moze_intel.projecte.api.nss.NormalizedSimpleStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import mekanism.api.chemical.Chemical;
import mekanism.api.providers.IChemicalProvider;
import mekanism.api.providers.ISlurryProvider;
import mekanism.common.registration.MekanismDeferredHolder;
import net.minecraft.resources.ResourceKey;

Expand All @@ -18,10 +17,4 @@ public Chemical getChemical() {
return value();
}

public static class DeferredSlurry<SLURRY extends Chemical> extends DeferredChemical<SLURRY> implements ISlurryProvider {

public DeferredSlurry(ResourceKey<Chemical> key) {
super(key);
}
}
}

0 comments on commit b2341c0

Please sign in to comment.