aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/recipe/metadata
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/recipe/metadata')
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/EmptyRecipeMetadataStorage.java50
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/IRecipeMetadataStorage.java34
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/PCBFactoryTierKey.java30
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgrade.java7
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgradeKey.java32
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/PurificationPlantBaseChanceKey.java28
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/RecipeMetadataStorage.java56
-rw-r--r--src/main/java/gregtech/api/recipe/metadata/SimpleRecipeMetadataKey.java27
8 files changed, 264 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/recipe/metadata/EmptyRecipeMetadataStorage.java b/src/main/java/gregtech/api/recipe/metadata/EmptyRecipeMetadataStorage.java
new file mode 100644
index 0000000000..f7831f1485
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/EmptyRecipeMetadataStorage.java
@@ -0,0 +1,50 @@
+package gregtech.api.recipe.metadata;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import org.jetbrains.annotations.Contract;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public final class EmptyRecipeMetadataStorage implements IRecipeMetadataStorage {
+
+ public static EmptyRecipeMetadataStorage INSTANCE = new EmptyRecipeMetadataStorage();
+
+ private EmptyRecipeMetadataStorage() {}
+
+ @Override
+ public <T> void store(RecipeMetadataKey<T> key, @Nullable T value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ @Override
+ public <T> T getMetadata(RecipeMetadataKey<T> key) {
+ return null;
+ }
+
+ @Contract("_, !null -> !null")
+ @Nullable
+ @Override
+ public <T> T getMetadataOrDefault(RecipeMetadataKey<T> key, @Nullable T defaultValue) {
+ return defaultValue;
+ }
+
+ @Override
+ public Set<Map.Entry<RecipeMetadataKey<?>, Object>> getEntries() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public IRecipeMetadataStorage copy() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/IRecipeMetadataStorage.java b/src/main/java/gregtech/api/recipe/metadata/IRecipeMetadataStorage.java
new file mode 100644
index 0000000000..52141937cf
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/IRecipeMetadataStorage.java
@@ -0,0 +1,34 @@
+package gregtech.api.recipe.metadata;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import org.jetbrains.annotations.Contract;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+
+/**
+ * Stores set of metadata for the recipe with key {@link RecipeMetadataKey}. More explicit way to store various info
+ * on recipe than special value or special object. Type of the metadata can be anything.
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public interface IRecipeMetadataStorage {
+
+ <T> void store(RecipeMetadataKey<T> key, @Nullable T value);
+
+ @Nullable
+ <T> T getMetadata(RecipeMetadataKey<T> key);
+
+ @Contract("_, !null -> !null")
+ @Nullable
+ <T> T getMetadataOrDefault(RecipeMetadataKey<T> key, @Nullable T defaultValue);
+
+ Set<Map.Entry<RecipeMetadataKey<?>, Object>> getEntries();
+
+ IRecipeMetadataStorage copy();
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/PCBFactoryTierKey.java b/src/main/java/gregtech/api/recipe/metadata/PCBFactoryTierKey.java
new file mode 100644
index 0000000000..05db919b57
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/PCBFactoryTierKey.java
@@ -0,0 +1,30 @@
+package gregtech.api.recipe.metadata;
+
+import static gregtech.api.util.GT_Utility.trans;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+/**
+ * Minimum tier required for the PCB factory recipe.
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class PCBFactoryTierKey extends RecipeMetadataKey<Integer> {
+
+ public static final PCBFactoryTierKey INSTANCE = new PCBFactoryTierKey();
+
+ private PCBFactoryTierKey() {
+ super(Integer.class, "pcb_factory_tier");
+ }
+
+ @Override
+ public void drawInfo(RecipeDisplayInfo recipeInfo, @Nullable Object value) {
+ int tier = cast(value, 1);
+ recipeInfo.drawText(trans("336", "PCB Factory Tier: ") + tier);
+ }
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgrade.java b/src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgrade.java
new file mode 100644
index 0000000000..6d76ae05c3
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgrade.java
@@ -0,0 +1,7 @@
+package gregtech.api.recipe.metadata;
+
+public enum PCBFactoryUpgrade {
+
+ NONE,
+ BIO
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgradeKey.java b/src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgradeKey.java
new file mode 100644
index 0000000000..8257f1e6ef
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/PCBFactoryUpgradeKey.java
@@ -0,0 +1,32 @@
+package gregtech.api.recipe.metadata;
+
+import static gregtech.api.util.GT_Utility.trans;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+/**
+ * If bio upgrade is required for the PCB factory recipe.
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class PCBFactoryUpgradeKey extends RecipeMetadataKey<PCBFactoryUpgrade> {
+
+ public static final PCBFactoryUpgradeKey INSTANCE = new PCBFactoryUpgradeKey();
+
+ private PCBFactoryUpgradeKey() {
+ super(PCBFactoryUpgrade.class, "pcb_factory_bio_upgrade");
+ }
+
+ @Override
+ public void drawInfo(RecipeDisplayInfo recipeInfo, @Nullable Object value) {
+ PCBFactoryUpgrade upgrade = cast(value);
+ if (upgrade == PCBFactoryUpgrade.BIO) {
+ recipeInfo.drawText(trans("337", "Upgrade Required: ") + trans("338", "Bio"));
+ }
+ }
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/PurificationPlantBaseChanceKey.java b/src/main/java/gregtech/api/recipe/metadata/PurificationPlantBaseChanceKey.java
new file mode 100644
index 0000000000..8884ff51f4
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/PurificationPlantBaseChanceKey.java
@@ -0,0 +1,28 @@
+package gregtech.api.recipe.metadata;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+/**
+ * Base success chance for Purification Plant recipes
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class PurificationPlantBaseChanceKey extends RecipeMetadataKey<Float> {
+
+ public static final PurificationPlantBaseChanceKey INSTANCE = new PurificationPlantBaseChanceKey();
+
+ private PurificationPlantBaseChanceKey() {
+ super(Float.class, "purification_plant_base_chance");
+ }
+
+ @Override
+ public void drawInfo(RecipeDisplayInfo recipeInfo, @Nullable Object value) {
+ double chance = cast(value, 0.0f);
+ recipeInfo.drawText("Base success chance: " + chance + "%");
+ }
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/RecipeMetadataStorage.java b/src/main/java/gregtech/api/recipe/metadata/RecipeMetadataStorage.java
new file mode 100644
index 0000000000..5b65d8a600
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/RecipeMetadataStorage.java
@@ -0,0 +1,56 @@
+package gregtech.api.recipe.metadata;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import org.jetbrains.annotations.Contract;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.FieldsAreNonnullByDefault;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+@FieldsAreNonnullByDefault
+public final class RecipeMetadataStorage implements IRecipeMetadataStorage {
+
+ private final Map<RecipeMetadataKey<?>, Object> metadata = new HashMap<>();
+
+ public RecipeMetadataStorage() {}
+
+ private RecipeMetadataStorage(Map<RecipeMetadataKey<?>, Object> metadata) {
+ this.metadata.putAll(metadata);
+ }
+
+ @Override
+ public <T> void store(RecipeMetadataKey<T> key, @Nullable T value) {
+ metadata.put(key, key.cast(value));
+ }
+
+ @Nullable
+ @Override
+ public <T> T getMetadata(RecipeMetadataKey<T> key) {
+ return key.cast(metadata.get(key));
+ }
+
+ @Contract("_, !null -> !null")
+ @Nullable
+ @Override
+ public <T> T getMetadataOrDefault(RecipeMetadataKey<T> key, @Nullable T defaultValue) {
+ return key.cast(metadata.getOrDefault(key, defaultValue));
+ }
+
+ @Override
+ public Set<Map.Entry<RecipeMetadataKey<?>, Object>> getEntries() {
+ return metadata.entrySet();
+ }
+
+ @Override
+ public IRecipeMetadataStorage copy() {
+ return new RecipeMetadataStorage(metadata);
+ }
+}
diff --git a/src/main/java/gregtech/api/recipe/metadata/SimpleRecipeMetadataKey.java b/src/main/java/gregtech/api/recipe/metadata/SimpleRecipeMetadataKey.java
new file mode 100644
index 0000000000..19395f11a0
--- /dev/null
+++ b/src/main/java/gregtech/api/recipe/metadata/SimpleRecipeMetadataKey.java
@@ -0,0 +1,27 @@
+package gregtech.api.recipe.metadata;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import gregtech.api.recipe.RecipeMetadataKey;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+/**
+ * Simple metadata key that does not draw anything on NEI.
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class SimpleRecipeMetadataKey<T> extends RecipeMetadataKey<T> {
+
+ private SimpleRecipeMetadataKey(Class<T> clazz, String identifier) {
+ super(clazz, identifier);
+ }
+
+ public static <T> RecipeMetadataKey<T> create(Class<T> clazz, String identifier) {
+ return new SimpleRecipeMetadataKey<>(clazz, identifier);
+ }
+
+ @Override
+ public void drawInfo(RecipeDisplayInfo recipeInfo, @Nullable Object value) {}
+}