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

Add RawOre items and processing #874

Closed
wants to merge 15 commits into from
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.46.05:dev')
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.46.07-pre:dev')
api("com.github.GTNewHorizons:bartworks:0.10.0:dev")

implementation('curse.maven:cofh-core-69162:2388751')
Expand Down
66 changes: 66 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,28 @@
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.entity.player.EntityPlayer;
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.FakePlayer;
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 +37,7 @@
public class BlockBaseOre extends BasicBlock implements ITexturedBlock {

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

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

@Override
public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) {
if (!(player instanceof FakePlayer)) {
shouldFortune = true;
}
super.harvestBlock(worldIn, player, x, y, z, meta);
if (shouldFortune) {
shouldFortune = false;
}
}

@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) {
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);
}
}
24 changes: 10 additions & 14 deletions src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,15 @@ public boolean registerComponent() {
aMap = new HashMap<>();
}
String aKey = "Invalid";
if (componentType == ComponentTypes.CRUSHED) {
aKey = OrePrefixes.crushed.name();
} else if (componentType == ComponentTypes.CRUSHEDCENTRIFUGED) {
aKey = OrePrefixes.crushedCentrifuged.name();
} else if (componentType == ComponentTypes.CRUSHEDPURIFIED) {
aKey = OrePrefixes.crushedPurified.name();
} else if (componentType == ComponentTypes.DUST) {
aKey = OrePrefixes.dust.name();
} else if (componentType == ComponentTypes.DUSTIMPURE) {
aKey = OrePrefixes.dustImpure.name();
} else if (componentType == ComponentTypes.DUSTPURE) {
aKey = OrePrefixes.dustPure.name();
} else if (componentType == ComponentTypes.MILLED) {
aKey = OrePrefixes.milled.name();
switch (componentType) {
case CRUSHED -> aKey = OrePrefixes.crushed.name();
case CRUSHEDCENTRIFUGED -> aKey = OrePrefixes.crushedCentrifuged.name();
case CRUSHEDPURIFIED -> aKey = OrePrefixes.crushedPurified.name();
case DUST -> aKey = OrePrefixes.dust.name();
case DUSTIMPURE -> aKey = OrePrefixes.dustImpure.name();
case DUSTPURE -> aKey = OrePrefixes.dustPure.name();
case MILLED -> aKey = OrePrefixes.milled.name();
case RAWORE -> aKey = OrePrefixes.rawOre.name();
}

ItemStack x = aMap.get(aKey);
Expand Down Expand Up @@ -241,6 +236,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 @@ -181,6 +181,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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading