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

Commit

Permalink
Implement rawores
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethryan committed Apr 16, 2024
1 parent 3aa2e29 commit 95e3f56
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -63,11 +71,41 @@ 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;
}
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;
}
}
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);
}
}
}

0 comments on commit 95e3f56

Please sign in to comment.