Skip to content

Commit

Permalink
Add DroneHatch to fusion reactor (GTNewHorizons#2670)
Browse files Browse the repository at this point in the history
* Add DroneHatch to fusion reactor

* Reduce input hatch requirement

* Change location to avoid conflict
  • Loading branch information
RealSilverMoon authored Jul 15, 2024
1 parent e0d55a7 commit de36e0a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
import static gregtech.api.enums.Textures.BlockIcons.*;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_StructureUtility.filterByMTETier;
import static gregtech.api.util.GT_StructureUtility.ofFrame;
import static gregtech.api.util.GT_Utility.filterValidMTEs;
Expand Down Expand Up @@ -64,6 +65,7 @@
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.tileentities.machines.IDualInputHatch;
import gregtech.common.tileentities.machines.multi.drone.GT_MetaTileEntity_Hatch_DroneDownLink;

public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMultiBlockBase_EM
implements IConstructable, ISurvivalConstructable, IOverclockDescriptionProvider {
Expand Down Expand Up @@ -106,6 +108,14 @@ protected IStructureDefinition<LargeFusionComputer> computeValue(Class<?> type)
.dot(2)
.buildAndChain(x.getCasingBlock(), x.getCasingMeta())))
.addElement('F', lazy(x -> ofFrame(x.getFrameBox())))
.addElement(
'D',
lazy(
x -> buildHatchAdder(LargeFusionComputer.class).adder(LargeFusionComputer::addDroneHatch)
.hatchId(9401)
.casingIndex(x.textureIndex())
.dot(3)
.buildAndChain(x.getCasingBlock(), x.getCasingMeta())))
.build();
}
};
Expand Down Expand Up @@ -525,6 +535,15 @@ private boolean addFluidIO(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCas
return false;
}

private boolean addDroneHatch(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
if (aBaseMetaTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DroneDownLink tHatch)) return false;
tHatch.updateTexture(aBaseCasingIndex);
return addToMachineList(aBaseMetaTileEntity, aBaseCasingIndex);
}

@Override
public IStructureDefinition<LargeFusionComputer> getStructure_EM() {
return STRUCTURE_DEFINITION.get(getClass());
Expand Down Expand Up @@ -692,7 +711,7 @@ public boolean getDefaultHasMaintenanceChecks() {
" CCHCC CCHCC ", " CCHCC CCHCC ",
" CCHCE ECHCC ", " ECHCC CCHCE ",
" CCHCE ECHCC ", " CCHCCC CCCHCC ",
" CCHCCCC CCCCHCC ", " ECHHCCCCC FCCCCCF CCCCCHHCE ",
" CCHCCCC CCCCHCC ", " ECHHCCCCC FCCDCCF CCCCCHHCE ",
" CCCHHCCCCC CCCCCHHCCC ", " CCCCHHHCC CCHHHCCCC ",
" CCCCCHHHHHHHHHCCCCC ", " CCCCC CCCCC ",
" CC CC ", " FCCCCCF ", };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import gregtech.api.util.GT_Utility;
import gregtech.api.util.shutdown.ShutDownReason;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
import gregtech.common.tileentities.machines.multi.drone.GT_MetaTileEntity_Hatch_DroneDownLink;

public abstract class GT_MetaTileEntity_FusionComputer
extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_FusionComputer>
Expand All @@ -96,7 +97,7 @@ protected IStructureDefinition<GT_MetaTileEntity_FusionComputer> computeValue(Cl
" h h ", " h h ", " i i ", " h h ",
" i i ", " h h ", " h h ", " h h ",
" hh hh ", " ihi ", " ", },
{ " xhx ", " hhccchh ", " eccxhxcce ", " eceh hece ",
{ " xhx ", " hhccchh ", " eccxdxcce ", " eceh hece ",
" hce ech ", " hch hch ", "xcx xcx", "hch hch",
"xcx xcx", " hch hch ", " hce ech ", " eceh hece ",
" eccx~xcce ", " hhccchh ", " xhx ", },
Expand All @@ -111,7 +112,7 @@ protected IStructureDefinition<GT_MetaTileEntity_FusionComputer> computeValue(Cl
lazy(
t -> buildHatchAdder(GT_MetaTileEntity_FusionComputer.class)
.atLeast(
ImmutableMap.of(InputHatch.withAdder(GT_MetaTileEntity_FusionComputer::addInjector), 2))
ImmutableMap.of(InputHatch.withAdder(GT_MetaTileEntity_FusionComputer::addInjector), 1))
.hatchItemFilterAnd(t2 -> filterByMTETier(t2.tier(), Integer.MAX_VALUE))
.casingIndex(53)
.dot(1)
Expand All @@ -134,6 +135,15 @@ protected IStructureDefinition<GT_MetaTileEntity_FusionComputer> computeValue(Cl
.casingIndex(53)
.dot(3)
.buildAndChain(t.getCasing(), t.getCasingMeta())))
.addElement(
'd',
lazy(
t -> buildHatchAdder(GT_MetaTileEntity_FusionComputer.class)
.adder(GT_MetaTileEntity_FusionComputer::addDroneHatch)
.hatchId(9401)
.casingIndex(53)
.dot(4)
.buildAndChain(t.getCasing(), t.getCasingMeta())))
.build();
}
};
Expand Down Expand Up @@ -223,9 +233,7 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {

@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
return checkPiece(STRUCTURE_PIECE_MAIN, 7, 1, 12) && mInputHatches.size() > 1
&& !mOutputHatches.isEmpty()
&& !mEnergyHatches.isEmpty();
return checkPiece(STRUCTURE_PIECE_MAIN, 7, 1, 12) && !mOutputHatches.isEmpty() && !mEnergyHatches.isEmpty();
}

private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
Expand Down Expand Up @@ -257,6 +265,15 @@ private boolean addExtractor(IGregTechTileEntity aBaseMetaTileEntity, int aBaseC
return mOutputHatches.add(tHatch);
}

private boolean addDroneHatch(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) {
if (aBaseMetaTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DroneDownLink tHatch)) return false;
tHatch.updateTexture(aBaseCasingIndex);
return addToMachineList(aBaseMetaTileEntity, aBaseCasingIndex);
}

public abstract Block getCasing();

public abstract int getCasingMeta();
Expand Down

0 comments on commit de36e0a

Please sign in to comment.