From 95e3f5624c45ec1d01eb7aa4dc047d5261cc94ab Mon Sep 17 00:00:00 2001 From: Ethryan <3237986+Ethryan@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:30:08 +0200 Subject: [PATCH] Implement rawores --- .../material/BW_MetaGenerated_Block_TE.java | 42 +++++++++++++- .../bartworks/system/material/Werkstoff.java | 1 + .../system/material/WerkstoffLoader.java | 7 ++- .../recipe/RawOreLoader.java | 58 +++++++++++++++++++ 4 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java index 5aba6c84..67697706 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java @@ -16,6 +16,7 @@ import static com.github.bartimaeusnek.bartworks.MainMod.BW_Network_instance; import java.util.ArrayList; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -26,11 +27,18 @@ import com.github.bartimaeusnek.bartworks.common.net.MetaBlockPacket; +import gregtech.GT_Mod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_OreDictUnificator; public abstract class BW_MetaGenerated_Block_TE extends TileEntity implements ITexturedTileEntity { public short mMetaData; + protected static boolean shouldFortune = false; + public boolean mNatural = false; @Override public boolean canUpdate() { @@ -63,11 +71,41 @@ public Packet getDescriptionPacket() { public ArrayList getDrops(int aFortune) { ArrayList rList = new ArrayList<>(); - if (this.mMetaData < 0) { + if (this.mMetaData <= 0) { rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); return rList; } - rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + Materials aOreMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData).getBridgeMaterial(); + switch (GT_Mod.gregtechproxy.oreDropSystem) { + case Item -> { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + case FortuneItem -> { + // if shouldFortune and isNatural then get fortune drops + // if not shouldFortune or not isNatural then get normal drops + // if not shouldFortune and isNatural then get normal drops + // if shouldFortune and not isNatural then get normal drops + if (shouldFortune && this.mNatural) { + Random tRandom = new XSTR(this.xCoord ^ this.yCoord ^ this.zCoord); + long amount = (long) Math.max(1, tRandom.nextInt((1 + Math.min(3, aFortune)))); + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, amount)); + } else { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } + case UnifiedBlock -> { + // Unified ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + case PerDimBlock -> { + // Per Dimension ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + case Block -> { + // Regular ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + } return rList; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index 5d6e82a9..8b215e3d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -710,6 +710,7 @@ public static void initPrefixLogic() { Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushed, 0b1000); Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushedPurified, 0b1000); Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushedCentrifuged, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.rawOre, 0b1000); Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.cell, 0b10000); Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.capsule, 0b10000); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index 19e74375..2fcacf39 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -55,6 +55,7 @@ import static gregtech.api.enums.OrePrefixes.plateQuadruple; import static gregtech.api.enums.OrePrefixes.plateQuintuple; import static gregtech.api.enums.OrePrefixes.plateTriple; +import static gregtech.api.enums.OrePrefixes.rawOre; import static gregtech.api.enums.OrePrefixes.ring; import static gregtech.api.enums.OrePrefixes.rotor; import static gregtech.api.enums.OrePrefixes.screw; @@ -108,6 +109,7 @@ import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.MoltenCellLoader; import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.MultipleMetalLoader; import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.OreLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.RawOreLoader; import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.SimpleMetalLoader; import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe.ToolLoader; import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.registration.AssociationLoader; @@ -1496,8 +1498,8 @@ public static void run() { IWerkstoffRunnable[] werkstoffRunnables = { new ToolLoader(), new DustLoader(), new GemLoader(), new SimpleMetalLoader(), new CasingLoader(), new AspectLoader(), new OreLoader(), - new CrushedLoader(), new CraftingMaterialLoader(), new CellLoader(), new MoltenCellLoader(), - new MultipleMetalLoader(), new MetalLoader(), new BlockLoader() }; + new RawOreLoader(), new CrushedLoader(), new CraftingMaterialLoader(), new CellLoader(), + new MoltenCellLoader(), new MultipleMetalLoader(), new MetalLoader(), new BlockLoader() }; long timepreone = 0; for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { @@ -1684,6 +1686,7 @@ private static void addItemsForGeneration() { WerkstoffLoader.items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); WerkstoffLoader.items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); WerkstoffLoader.items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); + WerkstoffLoader.items.put(rawOre, new BW_MetaGenerated_Items(rawOre)); } if ((WerkstoffLoader.toGenerateGlobal & 0b10000) != 0) { WerkstoffLoader.items.put(cell, new BW_MetaGenerated_Items(cell)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java new file mode 100644 index 00000000..f48d070d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; + +public class RawOreLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(rawOre) && werkstoff.hasItemType(ingot) && !werkstoff.getStats().isBlastFurnace()) + GT_ModHandler.addSmeltingRecipe( + WerkstoffLoader.getCorrespondingItemStack(rawOre, werkstoff), + werkstoff.get(ingot)); + + if (werkstoff.hasItemType(rawOre)) { + + GT_Values.RA.stdBuilder().itemInputs(werkstoff.get(rawOre)) + .itemOutputs(werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(crushed)) + .duration(16 * TICKS).eut(10).addTo(hammerRecipes); + + GT_ModHandler.addPulverisationRecipe( + werkstoff.get(rawOre), + werkstoff.get(crushed, 2), + werkstoff.contains(SubTag.CRYSTAL) ? werkstoff.get(gem) : werkstoff.getOreByProduct(0, dust), + werkstoff.getNoOfByProducts() > 0 ? 5 : 0, + Materials.Stone.getDust(1), + 50, + true); + } + } +}