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

Commit

Permalink
Add RawOre items and processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethryan committed Apr 20, 2024
1 parent 6b0cc80 commit 90336e0
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.155:dev')
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.154-pre:dev')
api("com.github.GTNewHorizons:bartworks:0.9.21:dev")

implementation('curse.maven:cofh-core-69162:2388751')
Expand Down
54 changes: 54 additions & 0 deletions src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package gtPlusPlus.core.block.base;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.GT_Mod;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.ITexture;
import gregtech.api.objects.XSTR;
import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.api.interfaces.ITexturedBlock;
import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer;
Expand All @@ -29,6 +35,8 @@
public class BlockBaseOre extends BasicBlock implements ITexturedBlock {

private final Material blockMaterial;
protected static boolean shouldFortune = false;
public boolean mNatural = false;

public BlockBaseOre(final Material material, final BlockTypes blockType) {
super(
Expand Down Expand Up @@ -130,4 +138,50 @@ public ITexture[] getTexture(Block block, ForgeDirection side) {
@Override
public void registerBlockIcons(IIconRegister p_149651_1_) {}

@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<>();
// TODO: Silk Touch?
switch (GT_Mod.gregtechproxy.oreDropSystem) {
case Item -> {
drops.add(
ItemUtils.getItemStackOfAmountFromOreDictNoBroken(
"oreRaw" + this.blockMaterial.getLocalizedName(),
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(x ^ y ^ z);
long amount = (long) Math.max(1, tRandom.nextInt(1 + Math.min(3, fortune)));
drops.add(
ItemUtils.getItemStackOfAmountFromOreDictNoBroken(
"oreRaw" + this.blockMaterial.getLocalizedName(),
(int) amount));
} else {
drops.add(
ItemUtils.getItemStackOfAmountFromOreDictNoBroken(
"oreRaw" + this.blockMaterial.getLocalizedName(),
1));
}
}
case UnifiedBlock -> {
// Unified ore
drops.add(ItemUtils.simpleMetaStack(this, metadata, 1));
}
case PerDimBlock -> {
// Per Dimension ore
drops.add(ItemUtils.simpleMetaStack(this, metadata, 1));
}
case Block -> {
// Regular ore
drops.add(ItemUtils.simpleMetaStack(this, metadata, 1));
}
}
return drops;
}

}
10 changes: 10 additions & 0 deletions src/main/java/gtPlusPlus/core/item/base/ore/BaseItemRawOre.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gtPlusPlus.core.item.base.ore;

import gtPlusPlus.core.material.Material;

public class BaseItemRawOre extends BaseOreComponent {

public BaseItemRawOre(final Material material) {
super(material, BaseOreComponent.ComponentTypes.RAWORE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public boolean registerComponent() {
aKey = OrePrefixes.dustPure.name();
} else if (componentType == ComponentTypes.MILLED) {
aKey = OrePrefixes.milled.name();
} else if (componentType == ComponentTypes.RAWORE) {
aKey = OrePrefixes.rawOre.name();
}

ItemStack x = aMap.get(aKey);
Expand Down Expand Up @@ -241,6 +243,7 @@ public static enum ComponentTypes {
CRUSHED("crushed", "Crushed ", " Ore", true),
CRUSHEDCENTRIFUGED("crushedCentrifuged", "Centrifuged Crushed ", " Ore", true),
CRUSHEDPURIFIED("crushedPurified", "Purified Crushed ", " Ore", true),
RAWORE("oreRaw", "Raw ", " Ore", true),
MILLED("milled", "Milled ", " Ore", true);

private final String COMPONENT_NAME;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/gtPlusPlus/core/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,10 @@ public final ItemStack getMilled(final int stacksize) {
return getComponentByPrefix(OrePrefixes.milled, stacksize);
}

public final ItemStack getRawOre(final int stacksize) {
return getComponentByPrefix(OrePrefixes.rawOre, stacksize);
}

public final boolean hasSolidForm() {
if (ItemUtils
.checkForInvalidItems(new ItemStack[] { getDust(1), getBlock(1), getTinyDust(1), getSmallDust(1) })) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gtPlusPlus/core/material/MaterialGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import gtPlusPlus.core.item.base.ore.BaseItemImpureDust;
import gtPlusPlus.core.item.base.ore.BaseItemPurifiedCrushedOre;
import gtPlusPlus.core.item.base.ore.BaseItemPurifiedDust;
import gtPlusPlus.core.item.base.ore.BaseItemRawOre;
import gtPlusPlus.core.item.base.plates.BaseItemPlate;
import gtPlusPlus.core.item.base.plates.BaseItemPlateDense;
import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble;
Expand Down Expand Up @@ -357,6 +358,7 @@ public static void generateOreMaterial(final Material matInfo, boolean generateO
temp = new BaseItemPurifiedCrushedOre(matInfo);
temp = new BaseItemImpureDust(matInfo);
temp = new BaseItemPurifiedDust(matInfo);
temp = new BaseItemRawOre(matInfo);

Logger.MATERIALS(
"Generated all ore components for " + matInfo.getLocalizedName()
Expand Down Expand Up @@ -398,6 +400,7 @@ public static boolean generateOreMaterialWithAllExcessComponents(final Material
temp = new BaseItemPurifiedCrushedOre(matInfo);
temp = new BaseItemImpureDust(matInfo);
temp = new BaseItemPurifiedDust(matInfo);
temp = new BaseItemRawOre(matInfo);

Logger.MATERIALS(
"Generated all ore & base components for " + matInfo.getLocalizedName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ public static void generateRecipes(final Material material) {
tVoltageMultiplier / 2)) {
Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate ore to Crushed ore'");
}
// Macerate raw ore to Crushed
if (GT_Values.RA.addPulveriserRecipe(
material.getRawOre(1),
new ItemStack[] { material.getCrushed(2) },
new int[] { 10000 },
20 * 20,
tVoltageMultiplier / 2)) {
Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate raw ore to Crushed ore'");
}

// Macerate Centrifuged to Pure Dust
if (GT_Values.RA.addPulveriserRecipe(
material.getCrushedCentrifuged(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ private void generateRecipes(final Material material, final boolean disableOptio
tVoltageMultiplier / 2)) {
Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate ore to Crushed ore'");
}
// Macerate raw ore to Crushed
if (GT_Values.RA.addPulveriserRecipe(
material.getRawOre(1),
new ItemStack[] { material.getCrushed(2) },
new int[] { 10000 },
20 * 20,
tVoltageMultiplier / 2)) {
Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate raw ore to Crushed ore'");
}
// Macerate Crushed to Impure Dust
if (GT_Values.RA.addPulveriserRecipe(
material.getCrushed(1),
Expand Down
Loading

0 comments on commit 90336e0

Please sign in to comment.