Skip to content

Commit

Permalink
Boldarnator (industrial rock breaker) GPL (#3668)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 26, 2024
1 parent 793fe1d commit bb18163
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 174 deletions.
5 changes: 5 additions & 0 deletions src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,9 @@ public class GTPPRecipeMaps {
.useSpecialSlot()
.frontend(TGSFrontend::new)
.build();
public static final RecipeMap<RecipeMapBackend> multiblockRockBreakerRecipes = RecipeMapBuilder
.of("gt.recipe.multiblockrockbreaker")
.maxIO(2, 1, 0, 0)
.disableRegisterNEI()
.build();
}
2 changes: 2 additions & 0 deletions src/main/java/gtPlusPlus/core/handler/CompatHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderChemicalSkips;
import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderGTNH;
import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderGlueLine;
import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderIndustrialRockBreaker;
import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderNuclear;
import gtPlusPlus.xmod.gregtech.registration.gregtech.Gregtech4Content;
import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechAdvancedBoilers;
Expand Down Expand Up @@ -240,6 +241,7 @@ public static void startLoadingGregAPIBasedRecipes() {
RecipeLoaderNuclear.generate();
RecipeLoaderGlueLine.generate();
RecipeLoaderChemicalSkips.generate();
RecipeLoaderIndustrialRockBreaker.run();
// Add autogenerated Recipes from Item Components
for (Set<RunnableWithInfo<Material>> m : MaterialGenerator.mRecipeMapsToGenerate) {
for (RunnableWithInfo<Material> r : m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import static gregtech.api.enums.HatchElement.OutputBus;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
Expand All @@ -25,28 +25,24 @@
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;

import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.SoundResource;
import gregtech.api.enums.TAE;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.recipe.check.SimpleCheckRecipeResult;
import gregtech.api.util.GTLanguageManager;
import gregtech.api.util.GTOreDictUnificator;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.api.util.ParallelHelper;
import gregtech.common.pollution.PollutionConfig;
import gtPlusPlus.api.recipe.GTPPRecipeMaps;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;

Expand Down Expand Up @@ -84,7 +80,7 @@ protected MultiblockTooltipBuilder createTooltip() {
MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType(getMachineType())
.addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 8")
.addInfo("Circuit goes in the GUI slot")
.addInfo("Use Integrated Circuit to determine recipe")
.addInfo("1 = cobble, 2 = stone, 3 = obsidian")
.addInfo("Needs Water and Lava in input hatch")
.addPollutionAmount(getPollutionPerSecond(null))
Expand Down Expand Up @@ -167,170 +163,54 @@ protected int getCasingTextureId() {

@Override
public RecipeMap<?> getRecipeMap() {
return RecipeMaps.rockBreakerFakeRecipes;
return GTPPRecipeMaps.multiblockRockBreakerRecipes;
}

@NotNull
@Override
protected boolean filtersFluid() {
return false;
public Collection<RecipeMap<?>> getAvailableRecipeMaps() {
return Collections.singleton(RecipeMaps.rockBreakerFakeRecipes);
}

@Override
public boolean isCorrectMachinePart(final ItemStack aStack) {
return true;
}

private static GTRecipe sRecipe_Cobblestone;
private static GTRecipe sRecipe_SmoothStone;
private static GTRecipe sRecipe_Redstone;

private static void generateRecipes() {
sRecipe_Cobblestone = new GTRecipe(
false,
new ItemStack[] { GTUtility.getIntegratedCircuit(1) },
new ItemStack[] { ItemUtils.getSimpleStack(Blocks.cobblestone) },
null,
new int[] { 10000 },
null,
null,
16,
32,
0);
sRecipe_SmoothStone = new GTRecipe(
false,
new ItemStack[] { GTUtility.getIntegratedCircuit(2) },
new ItemStack[] { ItemUtils.getSimpleStack(Blocks.stone) },
null,
new int[] { 10000 },
null,
null,
16,
32,
0);
sRecipe_Redstone = new GTRecipe(
false,
new ItemStack[] { GTUtility.getIntegratedCircuit(3),
GTOreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L) },
new ItemStack[] { ItemUtils.getSimpleStack(Blocks.obsidian) },
null,
new int[] { 10000 },
null,
null,
128,
32,
0);
protected boolean filtersFluid() {
return false;
}

@Override
public @NotNull CheckRecipeResult checkProcessing() {
ArrayList<FluidStack> aFluids = this.getStoredFluids();
if (aFluids.isEmpty()) {
return CheckRecipeResultRegistry.NO_RECIPE;
}
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

boolean aHasWater = false;
boolean aHasLava = false;
for (FluidStack aFluid : aFluids) {
if (aFluid.getFluid() == FluidRegistry.WATER) {
aHasWater = true;
} else if (aFluid.getFluid() == FluidRegistry.LAVA) {
aHasLava = true;
}
}
ArrayList<ItemStack> aItems = this.getStoredInputs();
boolean aHasRedstone = false;
if (!aItems.isEmpty()) {
for (ItemStack aItem : aItems) {
if (GTUtility
.areStacksEqual(aItem, GTOreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))) {
aHasRedstone = true;
break;
@NotNull
@Override
protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) {
if (inputFluids.length == 0) return CheckRecipeResultRegistry.NO_RECIPE;
boolean aHasWater = false;
boolean aHasLava = false;
for (FluidStack aFluid : inputFluids) {
if (aFluid.getFluid() == FluidRegistry.WATER) {
aHasWater = true;
} else if (aFluid.getFluid() == FluidRegistry.LAVA) {
aHasLava = true;
}
}
}
}

if (!aHasWater) {
return SimpleCheckRecipeResult.ofFailure("no_water");
}
if (!aHasLava) {
return SimpleCheckRecipeResult.ofFailure("no_lava");
}
ItemStack aGuiCircuit = this.getControllerSlot();
if (!ItemUtils.isControlCircuit(aGuiCircuit)) {
return CheckRecipeResultRegistry.NO_RECIPE;
}

if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) {
generateRecipes();
}

int aCircuit = aGuiCircuit.getItemDamage();

GTRecipe tRecipe = null;
switch (aCircuit) {
case 1 -> tRecipe = sRecipe_Cobblestone;
case 2 -> tRecipe = sRecipe_SmoothStone;
case 3 -> {
if (aHasRedstone) {
tRecipe = sRecipe_Redstone;
if (!aHasWater) {
return SimpleCheckRecipeResult.ofFailure("no_water");
}
if (!aHasLava) {
return SimpleCheckRecipeResult.ofFailure("no_lava");
}
return CheckRecipeResultRegistry.SUCCESSFUL;
}
}

if (tRecipe == null) {
return CheckRecipeResultRegistry.NO_RECIPE;
}

ItemStack[] aItemInputs = aItems.toArray(new ItemStack[0]);
FluidStack[] aFluidInputs = new FluidStack[] {};

long tEnergy = getMaxInputEnergy();
// Remember last recipe - an optimization for findRecipe()
this.mLastRecipe = tRecipe;

ParallelHelper helper = new ParallelHelper().setRecipe(tRecipe)
.setItemInputs(aItemInputs)
.setFluidInputs(aFluidInputs)
.setAvailableEUt(tEnergy)
.setMaxParallel(getMaxParallelRecipes())
.setConsumption(true)
.setOutputCalculation(true)
.setEUtModifier(0.75F)
.setMachine(this);

if (batchMode) {
helper.enableBatchMode(128);
}

helper.build();

if (helper.getCurrentParallel() == 0) {
return CheckRecipeResultRegistry.ITEM_OUTPUT_FULL;
}

this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;

OverclockCalculator calculator = new OverclockCalculator().setRecipeEUt(tRecipe.mEUt)
.setEUt(tEnergy)
.setDuration(tRecipe.mDuration)
.setEUtDiscount(0.75)
.setSpeedBoost(1 / 3.0)
.setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplierDouble()))
.calculate();
lEUt = -calculator.getConsumption();
mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble());

mOutputItems = helper.getItemOutputs();
mOutputFluids = helper.getFluidOutputs();
updateSlots();
return CheckRecipeResultRegistry.SUCCESSFUL;
}.setSpeedBonus(1 / 3.0)
.setEuModifier(0.75)
.setMaxParallelSupplier(this::getMaxParallelRecipes);

}

@Override
public int getMaxParallelRecipes() {
return (8 * GTUtility.getTier(this.getMaxInputVoltage()));
return 8 * GTUtility.getTier(this.getMaxInputVoltage());
}

@Override
Expand All @@ -342,23 +222,4 @@ public int getMaxEfficiency(final ItemStack aStack) {
public int getPollutionPerSecond(final ItemStack aStack) {
return PollutionConfig.pollutionPerSecondMultiIndustrialRockBreaker;
}

@Override
public int getDamageToComponent(final ItemStack aStack) {
return 0;
}

@Override
public boolean explodesOnComponentBreak(final ItemStack aStack) {
return false;
}

@Override
public ArrayList<ItemStack> getStoredInputs() {
ArrayList<ItemStack> aInputs = super.getStoredInputs();
if (this.getControllerSlot() != null) {
aInputs.add(this.getControllerSlot());
}
return aInputs;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package gtPlusPlus.xmod.gregtech.loaders.recipe;

import static gregtech.api.util.GTRecipeBuilder.SECONDS;
import static gregtech.api.util.GTRecipeBuilder.TICKS;
import static gtPlusPlus.api.recipe.GTPPRecipeMaps.multiblockRockBreakerRecipes;

import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;

import gregtech.api.enums.GTValues;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.TierEU;
import gregtech.api.util.GTOreDictUnificator;
import gregtech.api.util.GTUtility;

public class RecipeLoaderIndustrialRockBreaker {

public static void run() {
GTValues.RA.stdBuilder()
.itemInputs(GTUtility.getIntegratedCircuit(1))
.itemOutputs(new ItemStack(Blocks.cobblestone, 1))
.duration(16 * TICKS)
.eut(TierEU.RECIPE_LV)
.addTo(multiblockRockBreakerRecipes);

GTValues.RA.stdBuilder()
.itemInputs(GTUtility.getIntegratedCircuit(2))
.itemOutputs(new ItemStack(Blocks.stone, 1))
.duration(16 * TICKS)
.eut(TierEU.RECIPE_LV)
.addTo(multiblockRockBreakerRecipes);

GTValues.RA.stdBuilder()
.itemInputs(
GTUtility.getIntegratedCircuit(3),
GTOreDictUnificator.get(OrePrefixes.dust, Materials.Redstone, 1L))
.itemOutputs(new ItemStack(Blocks.obsidian, 1))
.duration(6 * SECONDS + 8 * TICKS)
.eut(TierEU.RECIPE_LV)
.addTo(multiblockRockBreakerRecipes);
}
}

0 comments on commit bb18163

Please sign in to comment.