aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2024-05-22 22:05:09 +0200
committerGitHub <noreply@github.com>2024-05-22 22:05:09 +0200
commitf69b4802390464c3b93d5a10a427fa5285375489 (patch)
tree03df3dcf5a357422b855b880ed2920758cf56f90 /src
parent5a0ef92140eea89f69c531033fd78dd3cbb48a00 (diff)
downloadGT5-Unofficial-f69b4802390464c3b93d5a10a427fa5285375489.tar.gz
GT5-Unofficial-f69b4802390464c3b93d5a10a427fa5285375489.tar.bz2
GT5-Unofficial-f69b4802390464c3b93d5a10a427fa5285375489.zip
Add rawOre processing to PlatinumOverhaul and add ore drops (#10)
* Add rawOre to PlatinumOverhaul * Implement rawores * update deps for use right version * update * Moved drops code and implement isNatural check. * update * Removed duplicate entry It gets it from super. * update * update * update * Update the Random code * fixed * Implement Silk Touch * Update dependencies.gradle --------- Co-authored-by: Ethryan <3237986+Ethryan@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java73
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java4
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java25
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java11
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java1
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java7
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java58
7 files changed, 171 insertions, 8 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java
index f4bf46dbe0..c53ef3f523 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java
@@ -13,16 +13,40 @@
package com.github.bartimaeusnek.bartworks.system.material;
+import java.util.ArrayList;
+import java.util.Random;
+
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
+import gregtech.GT_Mod;
+import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.interfaces.ITexture;
import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_OreDictUnificator;
public class BW_MetaGeneratedOreTE extends BW_MetaGenerated_Block_TE {
+ protected static boolean shouldFortune = false;
+ protected static boolean shouldSilkTouch = false;
+ public boolean mNatural = false;
+
+ @Override
+ public void readFromNBT(NBTTagCompound aNBT) {
+ super.readFromNBT(aNBT);
+ this.mNatural = aNBT.getBoolean("n");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound aNBT) {
+ super.writeToNBT(aNBT);
+ aNBT.setBoolean("n", this.mNatural);
+ }
+
@Override
public ITexture[] getTexture(Block aBlock, ForgeDirection side) {
Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData);
@@ -39,4 +63,53 @@ public class BW_MetaGeneratedOreTE extends BW_MetaGenerated_Block_TE {
protected Block GetProperBlock() {
return WerkstoffLoader.BWOres;
}
+
+ @Override
+ public ArrayList<ItemStack> getDrops(int aFortune) {
+ ArrayList<ItemStack> rList = new ArrayList<>();
+ if (this.mMetaData <= 0) {
+ rList.add(new ItemStack(Blocks.cobblestone, 1, 0));
+ return rList;
+ }
+ Materials aOreMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData).getBridgeMaterial();
+ if (shouldSilkTouch) {
+ rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData));
+ } else {
+ 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 && aFortune > 0) {
+ int aMinAmount = 1;
+ // Max applicable fortune
+ if (aFortune > 3) aFortune = 3;
+ long amount = (long) new Random().nextInt(aFortune) + aMinAmount;
+ for (int i = 0; i < amount; i++) {
+ rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1));
+ }
+ } 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/BW_MetaGenerated_Block_TE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Block_TE.java
index 5aba6c84a1..e29de514a5 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
@@ -45,8 +45,8 @@ public abstract class BW_MetaGenerated_Block_TE extends TileEntity implements IT
@Override
public void writeToNBT(NBTTagCompound aNBT) {
- aNBT.setShort("m", this.mMetaData);
super.writeToNBT(aNBT);
+ aNBT.setShort("m", this.mMetaData);
}
@Override
@@ -63,7 +63,7 @@ public abstract class BW_MetaGenerated_Block_TE extends TileEntity implements IT
public ArrayList<ItemStack> getDrops(int aFortune) {
ArrayList<ItemStack> rList = new ArrayList<>();
- if (this.mMetaData < 0) {
+ if (this.mMetaData <= 0) {
rList.add(new ItemStack(Blocks.cobblestone, 1, 0));
return rList;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java
index 08251573b3..7f1e56607f 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java
@@ -19,6 +19,8 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -26,6 +28,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import net.minecraftforge.common.util.FakePlayer;
import com.github.bartimaeusnek.bartworks.util.MathUtils;
@@ -71,6 +74,7 @@ public class BW_MetaGenerated_Ores extends BW_MetaGenerated_Blocks {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity instanceof BW_MetaGeneratedOreTE metaTE) {
metaTE.mMetaData = (short) aMetaData;
+ metaTE.mNatural = true;
}
return true;
@@ -105,4 +109,25 @@ public class BW_MetaGenerated_Ores extends BW_MetaGenerated_Blocks {
}
}
}
+
+ @Override
+ public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) {
+ if (EnchantmentHelper.getSilkTouchModifier(player)) {
+ BW_MetaGeneratedOreTE.shouldSilkTouch = true;
+ super.harvestBlock(worldIn, player, x, y, z, meta);
+
+ if (BW_MetaGeneratedOreTE.shouldSilkTouch) {
+ BW_MetaGeneratedOreTE.shouldSilkTouch = false;
+ }
+ return;
+ }
+
+ if (!(player instanceof FakePlayer)) {
+ BW_MetaGeneratedOreTE.shouldFortune = true;
+ }
+ super.harvestBlock(worldIn, player, x, y, z, meta);
+ if (BW_MetaGeneratedOreTE.shouldFortune) {
+ BW_MetaGeneratedOreTE.shouldFortune = false;
+ }
+ }
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java
index b8fdac7497..5db1bcdf56 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/GT_Enhancement/PlatinumSludgeOverHaul.java
@@ -73,6 +73,7 @@ import static gregtech.api.enums.OrePrefixes.dustSmall;
import static gregtech.api.enums.OrePrefixes.dustTiny;
import static gregtech.api.enums.OrePrefixes.ingot;
import static gregtech.api.enums.OrePrefixes.nugget;
+import static gregtech.api.enums.OrePrefixes.rawOre;
import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes;
import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes;
import static gregtech.api.recipe.RecipeMaps.fluidHeaterRecipes;
@@ -922,10 +923,12 @@ public class PlatinumSludgeOverHaul {
if (stack.getItem() instanceof GT_Generic_Item) {
if (!BW_Util.checkStackAndPrefix(stack)) return false;
- return !Arrays.asList(PlatinumSludgeOverHaul.OPBLACKLIST)
- .contains(GT_OreDictUnificator.getAssociation(stack).mPrefix)
- || Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST)
- .contains(GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial);
+ if (GT_OreDictUnificator.getAssociation(stack).mPrefix != rawOre) {
+ return !Arrays.asList(PlatinumSludgeOverHaul.OPBLACKLIST)
+ .contains(GT_OreDictUnificator.getAssociation(stack).mPrefix)
+ || Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST)
+ .contains(GT_OreDictUnificator.getAssociation(stack).mMaterial.mMaterial);
+ }
}
if (GTPlusPlus.isModLoaded()) {
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 5d6e82a929..8b215e3d36 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 class Werkstoff implements IColorModulationContainer, ISubTagContainer {
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 ebae7763c5..338b18eff1 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.plateDouble;
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.reci
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;
@@ -1498,8 +1500,8 @@ public class WerkstoffLoader {
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) {
@@ -1686,6 +1688,7 @@ public class WerkstoffLoader {
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 0000000000..f48d070d2e
--- /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);
+ }
+ }
+}