Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Add rawOre processing to PlatinumOverhaul and add ore drops #10

Merged
merged 21 commits into from
May 22, 2024
Merged
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
5 changes: 3 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ dependencies {
runtimeOnlyNonPublishable('com.github.GTNewHorizons:waila:1.7.3:dev')

compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-alpha50:api') { transitive = false }
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.46.18:dev')

api('com.github.GTNewHorizons:GT5-Unofficial:5.09.46.23:dev')
api("com.github.GTNewHorizons:TecTech:5.4.2:dev")
api("com.github.GTNewHorizons:GalacticGregGT5:1.1.0:dev") {
exclude group:"com.github.GTNewHorizons", module:"bartworks"
}
api("com.github.GTNewHorizons:Avaritia:1.49:dev")
implementation("com.github.GTNewHorizons:TinkersConstruct:1.12.1-GTNH:dev")

compileOnly("TGregworks:TGregworks:1.7.10-GTNH-1.0.25:deobf") {transitive = false}
compileOnly("TGregworks:TGregworks:1.7.10-GTNH-1.0.26:deobf") {transitive = false}
compileOnly("com.github.GTNewHorizons:OpenComputers:1.10.11-GTNH:api") {transitive = false}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,4 +63,53 @@ public ITexture[] getTexture(Block aBlock, ForgeDirection side) {
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void readFromNBT(NBTTagCompound aNBT) {

@Override
public void writeToNBT(NBTTagCompound aNBT) {
aNBT.setShort("m", this.mMetaData);
super.writeToNBT(aNBT);
aNBT.setShort("m", this.mMetaData);
}

@Override
Expand All @@ -63,7 +63,7 @@ public Packet getDescriptionPacket() {

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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
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;
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;

Expand Down Expand Up @@ -71,6 +74,7 @@ public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMet
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity instanceof BW_MetaGeneratedOreTE metaTE) {
metaTE.mMetaData = (short) aMetaData;
metaTE.mNatural = true;
}

return true;
Expand Down Expand Up @@ -105,4 +109,25 @@ public void getSubBlocks(Item aItem, CreativeTabs aTab, List<ItemStack> aList) {
}
}
}

@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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
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;
Expand Down Expand Up @@ -922,10 +923,12 @@ private static boolean isInBlackList(ItemStack stack) {

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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}