Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make small and tiny dusts a material flag and fix recipes that used them #2313

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 14 additions & 4 deletions src/main/java/gregtech/api/unification/OreDictUnifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.info.MaterialFlags;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.material.registry.MaterialRegistry;
import gregtech.api.unification.ore.OrePrefix;
Expand Down Expand Up @@ -310,10 +311,19 @@ public static ItemStack getDust(Material material, long materialAmount) {
return ItemStack.EMPTY;
if (materialAmount % M == 0 || materialAmount >= M * 16)
return get(OrePrefix.dust, material, (int) (materialAmount / M));
else if ((materialAmount * 4) % M == 0 || materialAmount >= M * 8)
return get(OrePrefix.dustSmall, material, (int) ((materialAmount * 4) / M));
else if ((materialAmount * 9) >= M)
return get(OrePrefix.dustTiny, material, (int) ((materialAmount * 9) / M));
else if ((materialAmount * 4) % M == 0 || materialAmount >= M * 8) {
if (material.hasFlag(MaterialFlags.GENERATE_SMALL_DUST))
return get(OrePrefix.dustSmall, material, (int) ((materialAmount * 4) / M));
else
return get(OrePrefix.dust, material, 1);
}
else if ((materialAmount * 9) >= M) {
if(material.hasFlag(MaterialFlags.GENERATE_TINY_DUST))
return get(OrePrefix.dustTiny, material, (int) (((materialAmount * 9) / M)));
else
return get(OrePrefix.dust, material, 1);
}

return ItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ public String toString() {
.requireProps(PropertyKey.DUST)
.build();

public static final MaterialFlag GENERATE_SMALL_DUST = new MaterialFlag.Builder("small_dust")
.requireProps(PropertyKey.DUST)
.build();

public static final MaterialFlag GENERATE_TINY_DUST = new MaterialFlag.Builder("tiny_dust")
.requireProps(PropertyKey.DUST)
.build();

/////////////////
// FLUID //
/////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static void register() {
.ore()
.color(0xFF6400).iconSet(SHINY)
.flags(EXT_METAL, MORTAR_GRINDABLE, GENERATE_SPRING, GENERATE_SPRING_SMALL, GENERATE_FINE_WIRE,
GENERATE_DOUBLE_PLATE)
GENERATE_DOUBLE_PLATE, GENERATE_TINY_DUST)
.element(Elements.Cu)
.cableProperties(V[MV], 1, 2)
.fluidPipeProperties(1696, 6, true)
Expand Down Expand Up @@ -352,6 +352,7 @@ public static void register() {
.liquid(new FluidBuilder().temperature(430))
.color(0x400080).iconSet(SHINY)
.element(Elements.In)
.flags(GENERATE_SMALL_DUST)
.build();

Iodine = new Material.Builder(49, gregtechId("iodine"))
Expand Down Expand Up @@ -427,6 +428,7 @@ public static void register() {
.ore()
.color(0xBDC7DB)
.element(Elements.Li)
.flags(GENERATE_TINY_DUST)
.build();

Livermorium = new Material.Builder(57, gregtechId("livermorium"))
Expand Down Expand Up @@ -593,6 +595,7 @@ public static void register() {
.dust()
.color(0xFFFF00)
.element(Elements.P)
.flags(GENERATE_SMALL_DUST)
.build();

Polonium = new Material.Builder(79, gregtechId("polonium"))
Expand All @@ -617,6 +620,7 @@ public static void register() {
.ore(true)
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu239)
.flags(GENERATE_TINY_DUST)
.build();

Plutonium241 = new Material.Builder(82, gregtechId("plutonium_241"))
Expand All @@ -632,6 +636,7 @@ public static void register() {
.liquid(new FluidBuilder().temperature(337))
.color(0xBEDCFF).iconSet(METALLIC)
.element(Elements.K)
.flags(GENERATE_TINY_DUST)
.build();

Praseodymium = new Material.Builder(84, gregtechId("praseodymium"))
Expand Down Expand Up @@ -869,15 +874,15 @@ public static void register() {
.ingot(3)
.liquid(new FluidBuilder().temperature(1405))
.color(0x32F032).iconSet(METALLIC)
.flags(EXT_METAL)
.flags(EXT_METAL, GENERATE_TINY_DUST)
.element(Elements.U238)
.build();

Uranium235 = new Material.Builder(117, gregtechId("uranium_235"))
.ingot(3)
.liquid(new FluidBuilder().temperature(1405))
.color(0x46FA46).iconSet(SHINY)
.flags(EXT_METAL)
.flags(EXT_METAL, GENERATE_TINY_DUST)
.element(Elements.U235)
.build();

Expand Down Expand Up @@ -953,7 +958,7 @@ public static void register() {
.liquid(new FluidBuilder().customStill())
.color(0x1E1E1E).iconSet(SHINY)
.flags(EXT_METAL, GENERATE_DOUBLE_PLATE, GENERATE_FOIL, GENERATE_GEAR, GENERATE_FINE_WIRE,
GENERATE_BOLT_SCREW)
GENERATE_BOLT_SCREW, GENERATE_TINY_DUST)
.element(Elements.Nq2)
.blast(b -> b
.temp(9000, GasTier.HIGH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void register() {
Ash = new Material.Builder(254, gregtechId("ash"))
.dust(1)
.color(0x969696)
.flags(DISABLE_DECOMPOSITION)
.flags(DISABLE_DECOMPOSITION, GENERATE_TINY_DUST)
.components(Carbon, 1)
.build();

Expand Down Expand Up @@ -81,7 +81,7 @@ public static void register() {
Bone = new Material.Builder(258, gregtechId("bone"))
.dust(1)
.color(0xFAFAFA)
.flags(MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES)
.flags(MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, GENERATE_TINY_DUST)
.components(Calcium, 1)
.build();

Expand Down Expand Up @@ -201,7 +201,7 @@ public static void register() {
DarkAsh = new Material.Builder(275, gregtechId("dark_ash"))
.dust(1)
.color(0x323232)
.flags(DISABLE_DECOMPOSITION)
.flags(DISABLE_DECOMPOSITION, GENERATE_TINY_DUST)
.components(Carbon, 1)
.build();

Expand Down Expand Up @@ -830,7 +830,7 @@ public static void register() {
.ingot(1)
.liquid(new FluidBuilder().temperature(1511))
.color(0xA0A0A0)
.flags(STD_METAL, DECOMPOSITION_BY_CENTRIFUGING)
.flags(STD_METAL, DECOMPOSITION_BY_CENTRIFUGING, GENERATE_SMALL_DUST)
.components(Arsenic, 1, Gallium, 1)
.blast(b -> b.temp(1200, GasTier.LOW).blastStats(VA[MV], 1200))
.build();
Expand Down Expand Up @@ -938,6 +938,7 @@ public static void register() {
.dust(1)
.color(0xFF084E)
.components(Potassium, 2, Chrome, 2, Oxygen, 7)
.flags(GENERATE_TINY_DUST)
.build();

ChromiumTrioxide = new Material.Builder(368, gregtechId("chromium_trioxide"))
Expand All @@ -950,6 +951,7 @@ public static void register() {
.dust(1)
.color(0xE6E6F0)
.components(Antimony, 2, Oxygen, 3)
.flags(GENERATE_TINY_DUST)
.build();

Zincite = new Material.Builder(370, gregtechId("zincite"))
Expand Down Expand Up @@ -997,7 +999,7 @@ public static void register() {
SodiumHydroxide = new Material.Builder(377, gregtechId("sodium_hydroxide"))
.dust(1)
.color(0x003380)
.flags(DISABLE_DECOMPOSITION)
.flags(DISABLE_DECOMPOSITION, GENERATE_TINY_DUST)
.components(Sodium, 1, Oxygen, 1, Hydrogen, 1)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static void register() {
Brick = new Material.Builder(2524, gregtechId("brick"))
.dust()
.color(0x9B5643).iconSet(ROUGH)
.flags(EXCLUDE_BLOCK_CRAFTING_RECIPES, NO_SMELTING, DECOMPOSITION_BY_CENTRIFUGING)
.flags(EXCLUDE_BLOCK_CRAFTING_RECIPES, NO_SMELTING, DECOMPOSITION_BY_CENTRIFUGING, GENERATE_SMALL_DUST)
.components(Clay, 1)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public static void register() {
.gem(0)
.liquid(new FluidBuilder().temperature(1200).customStill())
.color(0xFAFAFA).iconSet(GLASS)
.flags(GENERATE_LENS, NO_SMASHING, EXCLUDE_BLOCK_CRAFTING_RECIPES, DECOMPOSITION_BY_CENTRIFUGING)
.flags(GENERATE_LENS, NO_SMASHING, EXCLUDE_BLOCK_CRAFTING_RECIPES, DECOMPOSITION_BY_CENTRIFUGING,
GENERATE_SMALL_DUST, GENERATE_TINY_DUST)
.components(SiliconDioxide, 1)
.build();

Expand Down Expand Up @@ -145,7 +146,8 @@ public static void register() {
TricalciumPhosphate = new Material.Builder(2015, gregtechId("tricalcium_phosphate"))
.dust().ore(3, 1)
.color(0xFFFF00).iconSet(FLINT)
.flags(NO_SMASHING, NO_SMELTING, FLAMMABLE, EXPLOSIVE, DECOMPOSITION_BY_CENTRIFUGING)
.flags(NO_SMASHING, NO_SMELTING, FLAMMABLE, EXPLOSIVE, DECOMPOSITION_BY_CENTRIFUGING,
GENERATE_SMALL_DUST)
.components(Calcium, 3, Phosphate, 2)
.build();

Expand Down Expand Up @@ -381,7 +383,7 @@ public static void register() {
Flint = new Material.Builder(2049, gregtechId("flint"))
.gem(1)
.color(0x002040).iconSet(FLINT)
.flags(NO_SMASHING, MORTAR_GRINDABLE, DECOMPOSITION_BY_CENTRIFUGING)
.flags(NO_SMASHING, MORTAR_GRINDABLE, DECOMPOSITION_BY_CENTRIFUGING, GENERATE_TINY_DUST)
.components(SiliconDioxide, 1)
.toolStats(ToolProperty.Builder.of(0.0F, 1.0F, 64, 1)
.enchantability(5).ignoreCraftingTools()
Expand Down Expand Up @@ -491,7 +493,7 @@ public static void register() {
Clay = new Material.Builder(2063, gregtechId("clay"))
.dust(1)
.color(0xC8C8DC).iconSet(ROUGH)
.flags(MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES)
.flags(MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, GENERATE_SMALL_DUST)
.components(Sodium, 2, Lithium, 1, Aluminium, 2, Silicon, 2, Water, 6)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public static void register() {
Stone = new Material.Builder(1599, gregtechId("stone"))
.dust(2)
.color(0xCDCDCD).iconSet(ROUGH)
.flags(MORTAR_GRINDABLE, GENERATE_GEAR, NO_SMASHING, NO_SMELTING)
.flags(MORTAR_GRINDABLE, GENERATE_GEAR, NO_SMASHING, NO_SMELTING, GENERATE_SMALL_DUST)
.build();

Lava = new Material.Builder(1600, gregtechId("lava"))
Expand Down Expand Up @@ -517,7 +517,7 @@ public static void register() {
.wood()
.color(0x896727).iconSet(WOOD)
.flags(GENERATE_PLATE, GENERATE_ROD, GENERATE_BOLT_SCREW, GENERATE_LONG_ROD, GENERATE_GEAR,
GENERATE_FRAME)
GENERATE_FRAME, GENERATE_TINY_DUST, GENERATE_SMALL_DUST)
.fluidPipeProperties(340, 5, false)
.build();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/unification/ore/OrePrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public class OrePrefix {

// 1/4th of a Dust.
public static final OrePrefix dustSmall = new OrePrefix("dustSmall", M / 4, null, MaterialIconType.dustSmall,
ENABLE_UNIFICATION, hasDustProperty);
ENABLE_UNIFICATION, hasDustProperty.and(m -> m.hasFlag(GENERATE_SMALL_DUST)));
// 1/9th of a Dust.
public static final OrePrefix dustTiny = new OrePrefix("dustTiny", M / 9, null, MaterialIconType.dustTiny,
ENABLE_UNIFICATION, hasDustProperty);
ENABLE_UNIFICATION, hasDustProperty.and(m -> m.hasFlag(GENERATE_TINY_DUST)));
// Dust with impurities. 1 Unit of Main Material and 1/9 - 1/4 Unit of secondary Material
public static final OrePrefix dustImpure = new OrePrefix("dustImpure", M, null, MaterialIconType.dustImpure,
ENABLE_UNIFICATION, hasOreProperty,
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/gregtech/common/blocks/BlockSurfaceRock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gregtech.api.items.toolitem.ToolClasses;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.util.GTUtility;
import gregtech.common.blocks.properties.PropertyMaterial;
Expand Down Expand Up @@ -85,7 +86,7 @@ public AxisAlignedBB getBoundingBox(@NotNull IBlockState state, @NotNull IBlockA
}

private ItemStack getDropStack(IBlockState state, int amount) {
return OreDictUnifier.get(OrePrefix.dustTiny, getGtMaterial(state), amount);
return OreDictUnifier.get(OrePrefix.dust, getGtMaterial(state), amount);
}

@Override
Expand All @@ -98,8 +99,12 @@ public ItemStack getPickBlock(@NotNull IBlockState state, @NotNull RayTraceResul
@Override
public void getDrops(NonNullList<ItemStack> drops, @NotNull IBlockAccess world, @NotNull BlockPos pos,
@NotNull IBlockState state, int fortune) {
int amount = 3 + GTValues.RNG.nextInt((int) (2 + fortune * 1.5));
drops.add(getDropStack(state, amount));
int amount = GTValues.RNG.nextInt(Math.max(1, 9 - (fortune * 2)));
if (amount == 0) {
drops.add(getDropStack(state, 1));
} else {
drops.add(OreDictUnifier.get(OrePrefix.dust, Materials.Stone, 1));
}
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/gregtech/loaders/recipe/MachineRecipeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1239,40 +1239,40 @@ private static void registerRecyclingRecipes() {
.inputs(new ItemStack(Items.PORKCHOP))
.output(dust, Meat)
.chancedOutput(dust, Meat, 5000, 0)
.output(dustTiny, Bone)
.chancedOutput(dust, Bone, 1111, 0)
.duration(102).buildAndRegister();

MACERATOR_RECIPES.recipeBuilder()
.inputs(new ItemStack(Items.FISH, 1, GTValues.W))
.output(dust, Meat)
.chancedOutput(dust, Meat, 5000, 0)
.output(dustTiny, Bone)
.chancedOutput(dust, Bone, 1111, 0)
.duration(102).buildAndRegister();

MACERATOR_RECIPES.recipeBuilder()
.inputs(new ItemStack(Items.CHICKEN))
.output(dust, Meat)
.output(dustTiny, Bone)
.chancedOutput(dust, Bone, 1111, 0)
.duration(102).buildAndRegister();

MACERATOR_RECIPES.recipeBuilder()
.inputs(new ItemStack(Items.BEEF))
.output(dust, Meat)
.chancedOutput(dust, Meat, 5000, 0)
.output(dustTiny, Bone)
.chancedOutput(dust, Bone, 1111, 0)
.duration(102).buildAndRegister();

MACERATOR_RECIPES.recipeBuilder()
.inputs(new ItemStack(Items.RABBIT))
.output(dust, Meat)
.chancedOutput(dust, Meat, 5000, 0)
.output(dustTiny, Bone)
.chancedOutput(dust, Bone, 1111, 0)
.duration(102).buildAndRegister();

MACERATOR_RECIPES.recipeBuilder()
.inputs(new ItemStack(Items.MUTTON))
.output(dust, Meat)
.output(dustTiny, Bone)
.chancedOutput(dust, Bone, 1111, 0)
.duration(102).buildAndRegister();
}

Expand Down
21 changes: 19 additions & 2 deletions src/main/java/gregtech/loaders/recipe/RecyclingRecipes.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gregtech.loaders.recipe;

import gregtech.api.GTValues;
import gregtech.api.items.materialitem.MetaPrefixItem;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.RecipeMaps;
Expand All @@ -20,6 +21,8 @@
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.api.util.GTUtility;

import gregtech.api.util.SmallDigits;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Tuple;
Expand Down Expand Up @@ -112,14 +115,28 @@ private static void registerMaceratorRecycling(ItemStack input, List<MaterialSta
RecipeMaps.MACERATOR_RECIPES.getMaxOutputs(),
OreDictUnifier::getDust);

int mult = 1;
long matAmount = materials.get(0).amount;
if(matAmount < M) {
if((matAmount * 9) >= M && materials.get(0).material.hasFlag(GENERATE_TINY_DUST))
mult = 1;
else if ((matAmount * 4) % M == 0 && materials.get(0).material.hasFlag(GENERATE_SMALL_DUST))
mult = 1;
else
mult = (int) M / (int) matAmount;
}

// Exit if no valid Materials exist for this recycling Recipe.
if (outputs.size() == 0) return;

ItemStack in = input.copy();
in.setCount(input.getCount() * mult);

// Build the final Recipe.
RecipeBuilder<SimpleRecipeBuilder> recipe = RecipeMaps.MACERATOR_RECIPES.recipeBuilder()
.inputs(input.copy())
.inputs(in)
.outputs(outputs)
.duration(calculateDuration(outputs))
.duration(calculateDuration(outputs) * mult)
.EUt(2 * multiplier)
.category(RecipeCategories.MACERATOR_RECYCLING);

Expand Down
Loading
Loading