Skip to content

Commit

Permalink
some ct support
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 committed Jan 28, 2022
1 parent ac020ef commit 02d36c3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/main/java/gregtech/api/fluids/fluidType/FluidType.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package gregtech.api.fluids.fluidType;

import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.liquid.ILiquidStack;
import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.unification.material.Material;
import gregtech.api.util.GTLog;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;

@ZenClass()
@ZenRegister
public abstract class FluidType {

private static final Map<String, FluidType> FLUID_TYPES = new HashMap<>();
Expand All @@ -29,7 +40,7 @@ public FluidType(@Nonnull String name, @Nonnull String prefix, @Nonnull String s
}

public String getNameForMaterial(@Nonnull Material material) {
return this.prefix + "." + material.toString() + "." + this.suffix;
return this.prefix + "." + material + "." + this.suffix;
}

public static void setFluidProperties(@Nonnull FluidType fluidType, @Nonnull Fluid fluid) {
Expand All @@ -38,19 +49,35 @@ public static void setFluidProperties(@Nonnull FluidType fluidType, @Nonnull Flu

protected abstract void setFluidProperties(@Nonnull Fluid fluid);

@ZenMethod
@Optional.Method(modid = GTValues.MODID_CT)
public static void setFluidPropertiesCT(FluidType fluidType, @Nonnull ILiquidStack liquidStack) {
Material material = GregTechAPI.MATERIAL_REGISTRY.getObject(liquidStack.getName());
if (material == null) {
GTLog.logger.warn("LiquidStack {} does not have a FluidProperty!", liquidStack.getName());
return;
}

fluidType.setFluidProperties(material.getFluid());
}

@ZenGetter
public String getLocalization() {
return this.localization;
}

@ZenGetter
public String getPrefix() {
return this.prefix;
}

@ZenGetter
public String getName() {
return this.name;
}

@Nullable
@ZenMethod
public static FluidType getByName(@Nonnull String name) {
return FLUID_TYPES.get(name);
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/gregtech/api/fluids/fluidType/FluidTypes.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
package gregtech.api.fluids.fluidType;

import crafttweaker.annotations.ZenRegister;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenProperty;

@ZenClass("mods.gregtech.material.FluidTypes")
@ZenRegister
public class FluidTypes {

@ZenProperty
public static final FluidType LIQUID = new FluidTypeLiquid("liquid", "", "", "gregtech.fluid.generic");

@ZenProperty
public static final FluidType ACID = new FluidTypeAcid("acid", "", "", "gregtech.fluid.generic");

@ZenProperty
public static final FluidType GAS = new FluidTypeGas("gas", "", "", "gregtech.fluid.generic");

@ZenProperty
public static final FluidType PLASMA = new FluidTypePlasma("plasma", "plasma", "", "gregtech.fluid.plasma");
}

0 comments on commit 02d36c3

Please sign in to comment.