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 (#879)
Browse files Browse the repository at this point in the history
* Add RawOre items and processing

* Added textures

* Change to a switch instead of elseif and add shouldFortune check

Removed isNatural check since GT++ Ores aren't TileEntities

* update

* update

* Fixed the controller texture for the turbines.

* The file is not called anywhere?

This file doesn't seem to be used anywhere. Maybe it's worth removing?

* update

* update

* Update random code

* fixed

* Add Silk Touch

* Update dependencies.gradle

* Update dependencies.gradle

---------

Co-authored-by: Ethryan <3237986+Ethryan@users.noreply.github.com>
Co-authored-by: Pilad <piladt@gmail.com>
  • Loading branch information
3 people authored May 22, 2024
1 parent 23494ad commit 38f38a9
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 19 deletions.
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.46.09:dev')
api("com.github.GTNewHorizons:bartworks:0.10.0:dev")
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.46.23:dev')
api("com.github.GTNewHorizons:bartworks:0.10.11:dev")

implementation('curse.maven:cofh-core-69162:2388751')
// https://www.curseforge.com/minecraft/mc-mods/advancedsolarpanels
Expand All @@ -12,7 +12,7 @@ dependencies {
compileOnly('com.github.GTNewHorizons:Binnie:2.3.4:dev') {transitive = false}
compileOnly('curse.maven:PlayerAPI-228969:2248928') {transitive=false}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:Chisel:2.14.1-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:Chisel:2.15.0-GTNH:dev') {transitive=false}

runtimeOnly('com.github.GTNewHorizons:ForestryMC:4.9.0:dev') {transitive=false}
}
84 changes: 84 additions & 0 deletions src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
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.enchantment.EnchantmentHelper;
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;
Expand All @@ -29,6 +37,8 @@
public class BlockBaseOre extends BasicBlock implements ITexturedBlock {

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

public BlockBaseOre(final Material material, final BlockTypes blockType) {
super(
Expand Down Expand Up @@ -130,4 +140,78 @@ 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 (EnchantmentHelper.getSilkTouchModifier(player)) {
shouldSilkTouch = true;
super.harvestBlock(worldIn, player, x, y, z, meta);

if (shouldSilkTouch) {
shouldSilkTouch = false;
}
return;
}

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<>();
if (shouldSilkTouch) {
drops.add(ItemUtils.simpleMetaStack(this, metadata, 1));
} else {
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 && fortune > 0) {
int aMinAmount = 1;
// Max applicable fortune
if (fortune > 3) fortune = 3;
long amount = (long) new Random().nextInt(fortune) + aMinAmount;
for (int i = 0; i < amount; i++) {
drops.add(
ItemUtils.getItemStackOfAmountFromOreDictNoBroken(
"oreRaw" + this.blockMaterial.getLocalizedName(),
1));
}
} 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

0 comments on commit 38f38a9

Please sign in to comment.