diff --git a/src/main/java/gregtech/api/unification/material/Material.java b/src/main/java/gregtech/api/unification/material/Material.java index f258eacef73..d70a198f993 100644 --- a/src/main/java/gregtech/api/unification/material/Material.java +++ b/src/main/java/gregtech/api/unification/material/Material.java @@ -26,6 +26,7 @@ import gregtech.api.unification.material.properties.OreProperty; import gregtech.api.unification.material.properties.PolymerProperty; import gregtech.api.unification.material.properties.PropertyKey; +import gregtech.api.unification.material.properties.RawOreProperty; import gregtech.api.unification.material.properties.RotorProperty; import gregtech.api.unification.material.properties.WireProperties; import gregtech.api.unification.material.properties.WoodProperty; @@ -1040,21 +1041,25 @@ public Builder blast(UnaryOperator b) { public Builder ore() { properties.ensureSet(PropertyKey.ORE); + properties.ensureSet(PropertyKey.RAW_ORE); return this; } public Builder ore(boolean emissive) { properties.setProperty(PropertyKey.ORE, new OreProperty(1, 1, emissive)); + properties.setProperty(PropertyKey.RAW_ORE, new RawOreProperty(1, 1)); return this; } public Builder ore(int oreMultiplier, int byproductMultiplier) { properties.setProperty(PropertyKey.ORE, new OreProperty(oreMultiplier, byproductMultiplier)); + properties.setProperty(PropertyKey.RAW_ORE, new RawOreProperty(oreMultiplier, byproductMultiplier)); return this; } public Builder ore(int oreMultiplier, int byproductMultiplier, boolean emissive) { properties.setProperty(PropertyKey.ORE, new OreProperty(oreMultiplier, byproductMultiplier, emissive)); + properties.setProperty(PropertyKey.RAW_ORE, new RawOreProperty(oreMultiplier, byproductMultiplier)); return this; } diff --git a/src/main/java/gregtech/api/unification/material/info/MaterialIconType.java b/src/main/java/gregtech/api/unification/material/info/MaterialIconType.java index 23d4589d3b5..27a708e56c2 100644 --- a/src/main/java/gregtech/api/unification/material/info/MaterialIconType.java +++ b/src/main/java/gregtech/api/unification/material/info/MaterialIconType.java @@ -27,6 +27,8 @@ public class MaterialIconType { public static final MaterialIconType dustImpure = new MaterialIconType("dustImpure"); public static final MaterialIconType dustPure = new MaterialIconType("dustPure"); + public static final MaterialIconType rawOre = new MaterialIconType("rawOre"); + public static final MaterialIconType crushed = new MaterialIconType("crushed"); public static final MaterialIconType crushedPurified = new MaterialIconType("crushedPurified"); public static final MaterialIconType crushedCentrifuged = new MaterialIconType("crushedCentrifuged"); diff --git a/src/main/java/gregtech/api/unification/material/properties/PropertyKey.java b/src/main/java/gregtech/api/unification/material/properties/PropertyKey.java index 3ccd75e4f93..37e8f28b93e 100644 --- a/src/main/java/gregtech/api/unification/material/properties/PropertyKey.java +++ b/src/main/java/gregtech/api/unification/material/properties/PropertyKey.java @@ -13,6 +13,7 @@ public class PropertyKey { public static final PropertyKey ITEM_PIPE = new PropertyKey<>("item_pipe", ItemPipeProperties.class); public static final PropertyKey ORE = new PropertyKey<>("ore", OreProperty.class); + public static final PropertyKey RAW_ORE = new PropertyKey<>("raw_ore", RawOreProperty.class); public static final PropertyKey TOOL = new PropertyKey<>("tool", MaterialToolProperty.class); public static final PropertyKey EXTRATOOL = new PropertyKey<>("extra_tool", ExtraToolProperty.class); diff --git a/src/main/java/gregtech/api/unification/material/properties/RawOreProperty.java b/src/main/java/gregtech/api/unification/material/properties/RawOreProperty.java new file mode 100644 index 00000000000..3fa808c7bd9 --- /dev/null +++ b/src/main/java/gregtech/api/unification/material/properties/RawOreProperty.java @@ -0,0 +1,193 @@ +package gregtech.api.unification.material.properties; + +import gregtech.api.unification.material.Material; + +import net.minecraft.util.math.MathHelper; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +public class RawOreProperty implements IMaterialProperty { + + /** + * List of Ore byproducts. + *

+ * Default: none, meaning only this property's Material. + */ + // @ZenProperty + private final List oreByProducts = new ArrayList<>(); + + /** + * Crushed Ore output amount multiplier during Maceration. + *

+ * Default: 1 (no multiplier). + */ + // @ZenProperty + private int oreMultiplier; + + /** + * Byproducts output amount multiplier during Maceration. + *

+ * Default: 1 (no multiplier). + */ + // @ZenProperty + private int byProductMultiplier; + + /** + * Material to which smelting of this Ore will result. + *

+ * Material will have a Dust Property. + * Default: none. + */ + // @ZenProperty + @Nullable + private Material directSmeltResult; + + /** + * Material in which this Ore should be washed to give additional output. + *

+ * Material will have a Fluid Property. + * Default: none. + */ + // @ZenProperty + @Nullable + private Material washedIn; + + /** + * The amount of Material that the ore should be washed in + * in the Chemical Bath. + *

+ * Default 100 mb + */ + private int washedAmount = 100; + + /** + * During Electromagnetic Separation, this Ore will be separated + * into this Material and the Material specified by this field. + * Limit 2 Materials + *

+ * Material will have a Dust Property. + * Default: none. + */ + // @ZenProperty + private final List separatedInto = new ArrayList<>(); + + public RawOreProperty(int oreMultiplier, int byProductMultiplier) { + this.oreMultiplier = oreMultiplier; + this.byProductMultiplier = byProductMultiplier; + } + + /** + * Default values constructor. + */ + public RawOreProperty() { + this(1, 1); + } + + public void setOreMultiplier(int multiplier) { + this.oreMultiplier = multiplier; + } + + public int getOreMultiplier() { + return this.oreMultiplier; + } + + public void setByProductMultiplier(int multiplier) { + this.byProductMultiplier = multiplier; + } + + public int getByProductMultiplier() { + return this.byProductMultiplier; + } + + public void setDirectSmeltResult(@Nullable Material m) { + this.directSmeltResult = m; + } + + @Nullable + public Material getDirectSmeltResult() { + return this.directSmeltResult; + } + + public void setWashedIn(@Nullable Material m) { + this.washedIn = m; + } + + public void setWashedIn(@Nullable Material m, int washedAmount) { + this.washedIn = m; + this.washedAmount = washedAmount; + } + + public Pair getWashedIn() { + return Pair.of(this.washedIn, this.washedAmount); + } + + public void setSeparatedInto(Material... materials) { + this.separatedInto.addAll(Arrays.asList(materials)); + } + + @Nullable + public List getSeparatedInto() { + return this.separatedInto; + } + + /** + * Set the ore byproducts for this property + * + * @param materials the materials to use as byproducts + */ + public void setOreByProducts(@NotNull Material... materials) { + setOreByProducts(Arrays.asList(materials)); + } + + /** + * Set the ore byproducts for this property + * + * @param materials the materials to use as byproducts + */ + public void setOreByProducts(@NotNull Collection materials) { + this.oreByProducts.clear(); + this.oreByProducts.addAll(materials); + } + + /** + * Add ore byproducts to this property + * + * @param materials the materials to add as byproducts + */ + public void addOreByProducts(@NotNull Material... materials) { + this.oreByProducts.addAll(Arrays.asList(materials)); + } + + public List getOreByProducts() { + return this.oreByProducts; + } + + @Nullable + public final Material getOreByProduct(int index) { + if (this.oreByProducts.isEmpty()) return null; + return this.oreByProducts.get(MathHelper.clamp(index, 0, this.oreByProducts.size() - 1)); + } + + @NotNull + public final Material getOreByProduct(int index, @NotNull Material fallback) { + Material material = getOreByProduct(index); + return material != null ? material : fallback; + } + + @Override + public void verifyProperty(MaterialProperties properties) { + properties.ensureSet(PropertyKey.DUST, true); + + if (directSmeltResult != null) directSmeltResult.getProperties().ensureSet(PropertyKey.DUST, true); + if (washedIn != null) washedIn.getProperties().ensureSet(PropertyKey.FLUID, true); + separatedInto.forEach(m -> m.getProperties().ensureSet(PropertyKey.DUST, true)); + oreByProducts.forEach(m -> m.getProperties().ensureSet(PropertyKey.DUST, true)); + } +} diff --git a/src/main/java/gregtech/api/unification/ore/OrePrefix.java b/src/main/java/gregtech/api/unification/ore/OrePrefix.java index ad05ae197ae..e02794e452a 100644 --- a/src/main/java/gregtech/api/unification/ore/OrePrefix.java +++ b/src/main/java/gregtech/api/unification/ore/OrePrefix.java @@ -139,6 +139,7 @@ public class OrePrefix { mat -> Collections.singletonList(I18n.format("metaitem.dust.tooltip.purify"))); public static final OrePrefix dust = new OrePrefix("dust", M, null, MaterialIconType.dust, ENABLE_UNIFICATION, hasDustProperty); + public static final OrePrefix rawOre = new OrePrefix("oreRaw", M, null, MaterialIconType.rawOre, ENABLE_UNIFICATION, hasRawOreProperty); // A Nugget. Introduced by Eloraam public static final OrePrefix nugget = new OrePrefix("nugget", M / 9, null, MaterialIconType.nugget, @@ -341,6 +342,7 @@ public static class Conditions { public static final Predicate hasOreProperty = mat -> mat.hasProperty(PropertyKey.ORE); public static final Predicate hasGemProperty = mat -> mat.hasProperty(PropertyKey.GEM); public static final Predicate hasDustProperty = mat -> mat.hasProperty(PropertyKey.DUST); + public static final Predicate hasRawOreProperty = mat -> mat.hasProperty(PropertyKey.RAW_ORE); public static final Predicate hasIngotProperty = mat -> mat.hasProperty(PropertyKey.INGOT); public static final Predicate hasBlastProperty = mat -> mat.hasProperty(PropertyKey.BLAST); public static final Predicate hasRotorProperty = mat -> mat.hasProperty(PropertyKey.ROTOR); diff --git a/src/main/java/gregtech/common/CommonProxy.java b/src/main/java/gregtech/common/CommonProxy.java index 81d4c20a828..14ef510e216 100644 --- a/src/main/java/gregtech/common/CommonProxy.java +++ b/src/main/java/gregtech/common/CommonProxy.java @@ -33,6 +33,7 @@ import gregtech.common.blocks.MetaBlocks; import gregtech.common.blocks.OreItemBlock; import gregtech.common.blocks.StoneVariantBlock; +import gregtech.api.util.Mods; import gregtech.common.items.MetaItems; import gregtech.common.items.ToolItems; import gregtech.common.pipelike.cable.BlockCable; @@ -47,6 +48,7 @@ import gregtech.common.pipelike.optical.ItemBlockOpticalPipe; import gregtech.datafix.GTDataFixers; import gregtech.integration.groovy.GroovyScriptModule; +import gregtech.integration.jei.basic.OreByProduct; import gregtech.loaders.MaterialInfoLoader; import gregtech.loaders.OreDictionaryLoader; import gregtech.loaders.recipe.CraftingComponent; @@ -254,7 +256,12 @@ public static void registerItems(RegistryEvent.Register event) { for (IGTTool tool : ToolItems.getAllTools()) { registry.register(tool.get()); } - + + if (Mods.JustEnoughItems.isModLoaded()) + { + OreByProduct.addOreByProductPrefix(OrePrefix.rawOre); + } + GTRecipeManager.preLoad(); for (MTERegistry r : GregTechAPI.mteManager.getRegistries()) { diff --git a/src/main/java/gregtech/common/blocks/BlockOre.java b/src/main/java/gregtech/common/blocks/BlockOre.java index db69901b8ff..003146490ce 100644 --- a/src/main/java/gregtech/common/blocks/BlockOre.java +++ b/src/main/java/gregtech/common/blocks/BlockOre.java @@ -1,9 +1,12 @@ package gregtech.common.blocks; +import gregtech.api.GTValues; import gregtech.api.items.toolitem.ToolClasses; +import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.Material; import gregtech.api.unification.material.info.MaterialFlags; import gregtech.api.unification.material.properties.PropertyKey; +import gregtech.api.unification.ore.OrePrefix; import gregtech.api.unification.ore.StoneType; import gregtech.api.unification.ore.StoneTypes; import gregtech.api.util.GTUtility; @@ -28,6 +31,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; @@ -96,6 +100,26 @@ public Item getItemDropped(@NotNull IBlockState state, @NotNull Random rand, int IBlockState stoneOre = OreConfigUtils.getOreForMaterial(this.material).get(StoneTypes.STONE); return Item.getItemFromBlock(stoneOre.getBlock()); } + + @Override + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) + { + if(fortune > 0) + { + int i = GTValues.RNG.nextInt((fortune + 2) - 1); + + if (i < 0) + { + i = 0; + } + + drops.add(OreDictUnifier.get(OrePrefix.rawOre, material, i + 1)); + } + else + { + drops.add(OreDictUnifier.get(OrePrefix.rawOre, material, 1)); + } + } @Override public int damageDropped(@NotNull IBlockState state) { diff --git a/src/main/java/gregtech/common/items/MetaItems.java b/src/main/java/gregtech/common/items/MetaItems.java index 23c49bb279f..33ce91412a2 100644 --- a/src/main/java/gregtech/common/items/MetaItems.java +++ b/src/main/java/gregtech/common/items/MetaItems.java @@ -581,6 +581,7 @@ private MetaItems() {} orePrefixes.add(OrePrefix.dustTiny); orePrefixes.add(OrePrefix.dustImpure); orePrefixes.add(OrePrefix.dustPure); + orePrefixes.add(OrePrefix.rawOre); orePrefixes.add(OrePrefix.crushed); orePrefixes.add(OrePrefix.crushedPurified); orePrefixes.add(OrePrefix.crushedCentrifuged); diff --git a/src/main/java/gregtech/loaders/recipe/handlers/OreRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/OreRecipeHandler.java index 39db751beae..5eab94ced2a 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/OreRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/OreRecipeHandler.java @@ -45,6 +45,8 @@ public static void register() { OrePrefix.oreRedSand.addProcessingHandler(PropertyKey.ORE, OreRecipeHandler::processOre); } + OrePrefix.rawOre.addProcessingHandler(PropertyKey.ORE, OreRecipeHandler::processOre); + OrePrefix.crushed.addProcessingHandler(PropertyKey.ORE, OreRecipeHandler::processCrushedOre); OrePrefix.crushedPurified.addProcessingHandler(PropertyKey.ORE, OreRecipeHandler::processCrushedPurified); OrePrefix.crushedCentrifuged.addProcessingHandler(PropertyKey.ORE, OreRecipeHandler::processCrushedCentrifuged); diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index 3429aad9618..b86fbdc4640 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -1480,6 +1480,7 @@ item.material.oreprefix.dustSmall=Small Pile of %s Dust item.material.oreprefix.dustImpure=Impure Pile of %s Dust item.material.oreprefix.dustPure=Purified Pile of %s Dust item.material.oreprefix.dust=%s Dust +item.material.oreprefix.oreRaw=Raw %s Ore item.material.oreprefix.nugget=%s Nugget item.material.oreprefix.plateDense=Dense %s Plate item.material.oreprefix.plateDouble=Double %s Plate diff --git a/src/main/resources/assets/gregtech/models/item/material_sets/diamond/raw_ore.json b/src/main/resources/assets/gregtech/models/item/material_sets/diamond/raw_ore.json new file mode 100644 index 00000000000..6bf3f19d233 --- /dev/null +++ b/src/main/resources/assets/gregtech/models/item/material_sets/diamond/raw_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "gregtech:items/material_sets/diamond/raw_ore" + } +} diff --git a/src/main/resources/assets/gregtech/models/item/material_sets/dull/raw_ore.json b/src/main/resources/assets/gregtech/models/item/material_sets/dull/raw_ore.json new file mode 100644 index 00000000000..b2c7d531414 --- /dev/null +++ b/src/main/resources/assets/gregtech/models/item/material_sets/dull/raw_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "gregtech:items/material_sets/dull/raw_ore" + } +} diff --git a/src/main/resources/assets/gregtech/models/item/material_sets/fine/raw_ore.json b/src/main/resources/assets/gregtech/models/item/material_sets/fine/raw_ore.json new file mode 100644 index 00000000000..6e8f4b0e950 --- /dev/null +++ b/src/main/resources/assets/gregtech/models/item/material_sets/fine/raw_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "gregtech:items/material_sets/fine/raw_ore" + } +} diff --git a/src/main/resources/assets/gregtech/models/item/material_sets/metallic/raw_ore.json b/src/main/resources/assets/gregtech/models/item/material_sets/metallic/raw_ore.json new file mode 100644 index 00000000000..7cd35be96b5 --- /dev/null +++ b/src/main/resources/assets/gregtech/models/item/material_sets/metallic/raw_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "gregtech:items/material_sets/metallic/raw_ore" + } +} diff --git a/src/main/resources/assets/gregtech/models/item/material_sets/shiny/raw_ore.json b/src/main/resources/assets/gregtech/models/item/material_sets/shiny/raw_ore.json new file mode 100644 index 00000000000..69bf51364f3 --- /dev/null +++ b/src/main/resources/assets/gregtech/models/item/material_sets/shiny/raw_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "gregtech:items/material_sets/shiny/raw_ore" + } +} diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/diamond/raw_ore.png b/src/main/resources/assets/gregtech/textures/items/material_sets/diamond/raw_ore.png new file mode 100644 index 00000000000..cd85f7b1eee Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/diamond/raw_ore.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/diamond/raw_ore_secondary.png b/src/main/resources/assets/gregtech/textures/items/material_sets/diamond/raw_ore_secondary.png new file mode 100644 index 00000000000..030bc5cebe9 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/diamond/raw_ore_secondary.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/dull/raw_ore.png b/src/main/resources/assets/gregtech/textures/items/material_sets/dull/raw_ore.png new file mode 100644 index 00000000000..57cb47bbf72 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/dull/raw_ore.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/dull/raw_ore_secondary.png b/src/main/resources/assets/gregtech/textures/items/material_sets/dull/raw_ore_secondary.png new file mode 100644 index 00000000000..adcb5fd5c26 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/dull/raw_ore_secondary.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/fine/raw_ore.png b/src/main/resources/assets/gregtech/textures/items/material_sets/fine/raw_ore.png new file mode 100644 index 00000000000..1e2caa917ef Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/fine/raw_ore.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/fine/raw_ore_secondary.png b/src/main/resources/assets/gregtech/textures/items/material_sets/fine/raw_ore_secondary.png new file mode 100644 index 00000000000..919e81f2f04 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/fine/raw_ore_secondary.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/metallic/raw_ore.png b/src/main/resources/assets/gregtech/textures/items/material_sets/metallic/raw_ore.png new file mode 100644 index 00000000000..258bfe80df9 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/metallic/raw_ore.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/metallic/raw_ore_secondary.png b/src/main/resources/assets/gregtech/textures/items/material_sets/metallic/raw_ore_secondary.png new file mode 100644 index 00000000000..8070adab1d5 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/metallic/raw_ore_secondary.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore.png b/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore.png new file mode 100644 index 00000000000..bc6bebd5a87 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore_overlay.png b/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore_overlay.png new file mode 100644 index 00000000000..6cf067c696b Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore_overlay.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore_secondary.png b/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore_secondary.png new file mode 100644 index 00000000000..54f2df93def Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/material_sets/shiny/raw_ore_secondary.png differ