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

Add nano forge t4 #3630

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static gregtech.api.util.GTStructureUtility.ofFrame;
import static gregtech.api.util.GTUtility.filterValidMTEs;

import javax.annotation.Nonnull;

Expand All @@ -24,6 +25,9 @@
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;

import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
Expand All @@ -43,6 +47,8 @@
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.metatileentity.implementations.MTEHatchInput;
import gregtech.api.metatileentity.implementations.MTEHatchInputBus;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
Expand All @@ -52,7 +58,9 @@
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.api.util.ParallelHelper;
import gregtech.common.blocks.BlockCasings8;
import gregtech.common.tileentities.machines.MTEHatchInputBusME;

public class MTENanoForge extends MTEExtendedPowerMultiBlockBase<MTENanoForge> implements ISurvivalConstructable {

Expand Down Expand Up @@ -232,21 +240,79 @@ public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}

int drainedMagmatter = 0;

@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@Override
protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) {
if (mSpecialTier == 4) {
boolean foundNanite = false;
ItemStack inputNanite = recipe.mOutputs[0];
int busWithNaniteIndex = 0;
int slotWithNaniteIndex = 0;

for (int i = 0; i < mInputBusses.size(); i++) {
if (foundNanite) {
break;
}
MTEHatchInputBus inputBus = mInputBusses.get(i);
ItemStack[] busInventory = inputBus.getRealInventory();
for (int j = 0; j < busInventory.length; j++) {
ItemStack inputItem = null;
if (inputBus instanceof MTEHatchInputBusME meBus) {
if (j == 18) {
break;
}
inputItem = meBus.getRealInventory()[j + 16];
} else {
inputItem = inputBus.getStackInSlot(j);
}
if (inputItem != null && inputItem.isItemEqual(inputNanite)) {
busWithNaniteIndex = i;
slotWithNaniteIndex = j;
foundNanite = true;
break;
}
}
}

if (foundNanite) {
for (MTEHatchInput hatch : filterValidMTEs(mInputHatches)) {
FluidStack drained = hatch.drain(
ForgeDirection.UNKNOWN,
MaterialsUEVplus.MagMatter.getMolten(Integer.MAX_VALUE),
true);
if (drained == null) {
continue;
}
drainedMagmatter = drained.amount;
mInputBusses.get(busWithNaniteIndex)
.decrStackSize(slotWithNaniteIndex, 1);
}
}
} else {
drainedMagmatter = 0;
}
maxParallel = Math.max((int) (drainedMagmatter / (144 / Math.pow(2, 4 - mSpecialTier))), 1);
return recipe.mSpecialValue <= mSpecialTier ? CheckRecipeResultRegistry.SUCCESSFUL
: CheckRecipeResultRegistry.NO_RECIPE;
}

@NotNull
@Override
protected ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe) {
return super.createParallelHelper(recipe);
}

@Nonnull
@Override
protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) {
return super.createOverclockCalculator(recipe)
.setDurationDecreasePerOC(mSpecialTier > recipe.mSpecialValue ? 4.0 : 2.0);
.setDurationDecreasePerOC(mSpecialTier > recipe.mSpecialValue ? 4.0 : 2.0)
.setSpeedBoost(Math.pow(0.9999, maxParallel));
}
};
}
Expand Down Expand Up @@ -285,6 +351,12 @@ && checkPiece(STRUCTURE_PIECE_TIER2, -7, 14, 4)
&& checkPiece(STRUCTURE_PIECE_TIER3, 14, 26, 4)) {
mSpecialTier = 3;
}

if (aStack.isItemEqual(MaterialsUEVplus.Eternity.getNanite(1))
&& checkPiece(STRUCTURE_PIECE_TIER2, -7, 14, 4)
&& checkPiece(STRUCTURE_PIECE_TIER3, 14, 26, 4)) {
mSpecialTier = 4;
}
}

if (mMaintenanceHatches.size() != 1) {
Expand Down
Loading