Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonThings compatibility for creating materials #1743

Open
wants to merge 5 commits into
base: 1.20.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ dependencies {
modImplementation(forge.ae2) { transitive = false }
modCompileOnly("curse.maven:ae2wtlib-459929:5217955")

//AlmostUnified
modCompileOnly(forge.almostUnified.forge)

// KJS
modImplementation forge.kubejs

Expand All @@ -76,6 +73,5 @@ dependencies {
modImplementation(forge.javd) { transitive = false }
modRuntimeOnly("curse.maven:trenzalore-870210:4848244")

// Runtime only testing mods
//modRuntimeOnly(forge.worldStripper)
}
modImplementation(forge.jsonThings)
}
15 changes: 7 additions & 8 deletions gradle/scripts/repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,32 @@ repositories {
url = "https://maven.blamejared.com/"
} // JEI
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.dev"
} // JEI mirror, AE2
maven { url = "https://maven.parchmentmc.org" } // Parchment mappings
maven { url = "https://maven.quiltmc.org/repository/release" } // Quilt Mappings
maven { url = "https://maven.firstdarkdev.xyz/snapshots" } // LDLib
maven { // Flywheel
maven {
url = "https://maven.tterrag.com/"
content {
// need to be specific here due to version overlaps
includeGroup("com.jozufozu.flywheel")
includeGroup("com.tterrag.registrate")
includeGroup("com.simibubi.create")
}
}
} // Flywheel
maven { url = "https://maven.theillusivec4.top/" } // Curios
maven { // TOP
maven {
url "https://maven.k-4u.nl"
}
} // TOP
maven {
// saps.dev Maven (KubeJS and Rhino)
url = "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
}
}
} // saps.dev Maven (KubeJS and Rhino)
maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes
maven { url 'https://jitpack.io' } // Mixin Extras, Fabric ASM
maven { url = 'https://jitpack.io' } // Mixin Extras, Fabric ASM
maven { url = 'https://www.dogforce-games.com/maven/' }
}
1 change: 1 addition & 0 deletions gradle/scripts/resources.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ processResources {
"emi_version": forge.versions.emi.get(),
"top_version": forge.versions.theoneprobe.get(),
"jade_version": forge.versions.jade.get(),
"jsonthings_version": forge.versions.jsonThings.get(),
"mod_license": mod_license,
"mod_name": mod_name,
"mod_description": mod_description,
Expand Down
12 changes: 4 additions & 8 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencyResolutionManagement {
def emiVersion = "1.1.11"
def ae2Version = "15.0.18"
def kjsVersion = "2001.6.4-build.120"
def auVersion = "1.20.1-0.6.0"

// Forge
def forgeVersion = "47.1.3"
Expand All @@ -32,7 +31,7 @@ dependencyResolutionManagement {
def flywheelForgeVersion = "0.6.10-10"
def topForgeVersion = "1.20.1-10.0.1-3"
def jadeForgeVersion = "11.6.3"
def worldStripperForgeFile = "4578579"
def jsonThingsVersion = "0.9.1"
def javdVersion = "4803995"

// Libs
Expand Down Expand Up @@ -96,16 +95,13 @@ dependencyResolutionManagement {
library("mixinextras-forge", "io.github.llamalad7", "mixinextras-forge").versionRef(mixinextras)

def configuration = version("configuration", configurationVersion)
library("configuration", "dev.toma.configuration", "configuration-forge-1.20.1").versionRef(configuration)

def worldStripper = version("worldStripper", worldStripperForgeFile)
library("worldStripper", "curse.maven", "worldStripper-250603").versionRef(worldStripper)
library("configuration", "dev.toma.configuration", "configuration-forge-${minecraftVersion}").versionRef(configuration)

def ae2 = version("ae2", ae2Version)
library("ae2", "appeng", "appliedenergistics2-forge").versionRef(ae2)

def au = version("au", auVersion)
library("almostUnified-forge", "com.almostreliable.mods", "almostunified-forge").versionRef(au)
def jsonThings = version("jsonThings", jsonThingsVersion)
library("jsonThings", "dev.gigaherz.jsonthings", "JsonThings-${minecraftVersion}").versionRef(jsonThings)

def javd = version("javd", javdVersion)
library("javd", "curse.maven", "javd-370890").versionRef(javd)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static int[] tiersBetween(int minInclusive, int maxInclusive) {
MODID_RUBIDIUM = "rubidium",
MODID_EMBEDDIUM = "embeddium",
MODID_CREATE = "create",
MODID_REBORN_ENERGY = "team_reborn_energy",
MODID_JSONTHINGS = "jsonthings",
MODID_ALMOSTUNIFIED = "almostunified",
MODID_CURIOS = "curios",
MODID_AE2WTLIB = "ae2wtlib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.mojang.serialization.Codec;
import dev.latvian.mods.rhino.util.HideFromJS;
import dev.latvian.mods.rhino.util.RemapPrefixForJS;
import it.unimi.dsi.fastutil.ints.IntArrayList;
Expand All @@ -48,6 +49,10 @@

public class Material implements Comparable<Material> {

public static final Codec<Material> CODEC = ResourceLocation.CODEC.xmap(
rl -> GTCEuAPI.materialManager.getRegistry(rl.getNamespace()).get(rl.getPath()),
Material::getResourceLocation);

/**
* Basic Info of this Material.
*
Expand Down Expand Up @@ -527,8 +532,11 @@ public void verifyMaterial() {
@RemapPrefixForJS("kjs$")
public static class Builder extends BuilderBase<Material> {

@Getter
private final MaterialInfo materialInfo;
@Getter
private final MaterialProperties properties;
@Getter
private final MaterialFlags flags;

/*
Expand Down Expand Up @@ -1245,7 +1253,7 @@ public Material register() {
* Holds the basic info for a Material, like the name, color, id, etc..
*/
@Accessors(chain = true)
private static class MaterialInfo {
public static class MaterialInfo {

/**
* The modid and unlocalized name of this Material.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@

import com.gregtechceu.gtceu.data.recipe.misc.alloyblast.AlloyBlastRecipeProducer;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.level.material.Fluid;

import com.google.common.base.Preconditions;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;

import java.util.function.Supplier;

@NoArgsConstructor
public class AlloyBlastProperty implements IMaterialProperty<AlloyBlastProperty> {

public static final Codec<AlloyBlastProperty> CODEC = RecordCodecBuilder.create(instance -> instance.group(
BuiltInRegistries.FLUID.byNameCodec().optionalFieldOf("fluid", null)
.xmap(fluid1 -> (Supplier<Fluid>) () -> fluid1, Supplier::get)
.forGetter(val -> (Supplier<Fluid>) val.fluidSupplier),
ExtraCodecs.POSITIVE_INT.optionalFieldOf("temperature", -1).forGetter(val -> val.temperature))
.apply(instance, AlloyBlastProperty::new));

/**
* Internal material fluid field
*/
private Supplier<? extends Fluid> fluidSupplier;
@Getter
private int temperature;

@Getter
Expand All @@ -28,6 +42,11 @@ public AlloyBlastProperty(int temperature) {
this.temperature = temperature;
}

public AlloyBlastProperty(Supplier<? extends Fluid> fluidSupplier, int temperature) {
this.fluidSupplier = fluidSupplier;
this.temperature = temperature;
}

@Override
public void verifyProperty(MaterialProperties materialProperties) {
materialProperties.ensureSet(PropertyKey.BLAST);
Expand All @@ -51,8 +70,4 @@ public void setTemperature(int fluidTemperature) {
Preconditions.checkArgument(fluidTemperature > 0, "Invalid temperature");
this.temperature = fluidTemperature;
}

public int getTemperature() {
return temperature;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
package com.gregtechceu.gtceu.api.data.chemical.material.properties;

import org.jetbrains.annotations.NotNull;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.util.StringRepresentable;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Locale;

@AllArgsConstructor
public class BlastProperty implements IMaterialProperty<BlastProperty> {

public static final Codec<BlastProperty> CODEC = RecordCodecBuilder.create(instance -> instance.group(
ExtraCodecs.POSITIVE_INT.fieldOf("blast_temperature").forGetter(val -> val.blastTemperature),
GasTier.CODEC.fieldOf("gas_tier").forGetter(val -> val.gasTier),
ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("duration_override", -1)
.forGetter(val -> val.durationOverride),
ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("eut_override", -1).forGetter(val -> val.EUtOverride))
.apply(instance, BlastProperty::new));

/**
* Blast Furnace Temperature of this Material.
* If below 1000K, Primitive Blast Furnace recipes will be also added.
Expand All @@ -12,100 +30,58 @@ public class BlastProperty implements IMaterialProperty<BlastProperty> {
* If a Material with this Property has a Fluid, its temperature
* will be set to this if it is the default Fluid temperature.
*/
@Getter
private int blastTemperature;

/**
* The {@link GasTier} of this Material, representing which Gas EBF recipes will be generated.
* <p>
* Default: null, meaning no Gas EBF recipes.
*/
@Getter
@Setter
private GasTier gasTier = null;

/**
* The duration of the EBF recipe, overriding the stock behavior.
* <p>
* Default: -1, meaning the duration will be: material.getAverageMass() * blastTemperature / 50
*/
@Getter
@Setter
private int durationOverride = -1;

/**
* The EU/t of the EBF recipe, overriding the stock behavior.
* <p>
* Default: -1, meaning the EU/t will be 120.
*/
private int eutOverride = -1;
@Getter
@Setter
private int EUtOverride = -1;

public BlastProperty(int blastTemperature) {
this.blastTemperature = blastTemperature;
}

public BlastProperty(int blastTemperature, GasTier gasTier, int eutOverride, int durationOverride) {
this.blastTemperature = blastTemperature;
this.gasTier = gasTier;
this.eutOverride = eutOverride;
this.durationOverride = durationOverride;
}

/**
* Default property constructor.
*/
public BlastProperty() {
this(0);
}

public int getBlastTemperature() {
return blastTemperature;
}

public void setBlastTemperature(int blastTemp) {
if (blastTemp <= 0) throw new IllegalArgumentException("Blast Temperature must be greater than zero!");
this.blastTemperature = blastTemp;
}

public GasTier getGasTier() {
return gasTier;
}

public void setGasTier(@NotNull GasTier tier) {
this.gasTier = tier;
}

public int getDurationOverride() {
return durationOverride;
}

public void setDurationOverride(int duration) {
this.durationOverride = duration;
}

public int getEUtOverride() {
return eutOverride;
}

public void setEutOverride(int eut) {
this.eutOverride = eut;
}

@Override
public void verifyProperty(MaterialProperties properties) {
properties.ensureSet(PropertyKey.INGOT, true);
}

public static GasTier validateGasTier(String gasTierName) {
if (gasTierName == null) return null;
else if ("LOW".equalsIgnoreCase(gasTierName)) return GasTier.LOW;
else if ("MID".equalsIgnoreCase(gasTierName)) return GasTier.MID;
else if ("HIGH".equalsIgnoreCase(gasTierName)) return GasTier.HIGH;
else if ("HIGHER".equalsIgnoreCase(gasTierName)) return GasTier.HIGHER;
else if ("HIGHEST".equalsIgnoreCase(gasTierName)) return GasTier.HIGHEST;
else {
String message = "Gas Tier must be either \"LOW\", \"MID\", \"HIGH\", \"HIGHER\", or \"HIGHEST\"";
throw new IllegalArgumentException(
"Could not find valid gas tier for name: " + gasTierName + ". " + message);
}
}

public enum GasTier {
public enum GasTier implements StringRepresentable {

// Tiers used by GTCEu
LOW,
Expand All @@ -117,5 +93,11 @@ public enum GasTier {
HIGHEST;

public static final GasTier[] VALUES = values();
public static final Codec<GasTier> CODEC = StringRepresentable.fromEnum(GasTier::values);

@Override
public String getSerializedName() {
return name().toUpperCase(Locale.ROOT);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package com.gregtechceu.gtceu.api.data.chemical.material.properties;

import net.minecraft.util.ExtraCodecs;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.Getter;

public class DustProperty implements IMaterialProperty<DustProperty> {

public static final Codec<DustProperty> CODEC = RecordCodecBuilder.create(instance -> instance.group(
ExtraCodecs.POSITIVE_INT.optionalFieldOf("harvest_level", 2).forGetter(val -> val.harvestLevel),
ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("burn_time", 0).forGetter(val -> val.burnTime))
.apply(instance, DustProperty::new));

/**
* Tool level needed to harvest block of this Material.
* <p>
Expand Down
Loading
Loading