Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Temporarily add Multi-Amp support to some GT++ Multis via upgrade chip #867

Closed
wants to merge 6 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static enum ASSEMBLY_LINE_RESEARCH {
RESEARCH_8_TURBINE_AUTOMATION("Turbine Automation", "You really don't want to share this with anyone!"),
RESEARCH_9_CLOAKING("Cloaking Technologies", "Sneaking around like a mouse"),
RESEARCH_10_SPARGING("Gas Sparging", "Blowing gas for results"),
RESEARCH_11_MOLECULAR_TRANSFORMER("Molecular Transformation", "Turning things into something better");
RESEARCH_11_MOLECULAR_TRANSFORMER("Molecular Transformation", "Turning things into something better"),
RESEARCH_12_HIGH_AMPERAGE("High-Amp Technologies", "I want it louder, more power.");

private final String mName;
private final String mDesc;
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import static gregtech.api.enums.Mods.GregTech;
import static gregtech.api.enums.Mods.Railcraft;
import static gregtech.api.enums.Mods.RemoteIO;
import static gregtech.api.recipe.RecipeMaps.assemblerRecipes;
import static gregtech.api.util.GT_RecipeBuilder.HOURS;
import static gregtech.api.util.GT_RecipeBuilder.INGOTS;
import static gregtech.api.util.GT_RecipeBuilder.SECONDS;
import static gregtech.api.util.GT_RecipeConstants.AssemblyLine;
import static gregtech.api.util.GT_RecipeConstants.RESEARCH_ITEM;
import static gregtech.api.util.GT_RecipeConstants.RESEARCH_TIME;

import java.util.List;

Expand All @@ -26,6 +33,7 @@
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.TierEU;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
Expand Down Expand Up @@ -252,6 +260,7 @@ private static void run() {
advHeatExchanger();
chiselBuses();
solidifierHatches();
maUpgradeChip();

gt4FarmManager();
gt4Inventory();
Expand Down Expand Up @@ -3063,4 +3072,40 @@ private static void solidifierHatches() {
(int) GT_Values.VP[componentTier]);
}
}

private static void maUpgradeChip() {
// research item recipe
GT_Values.RA.stdBuilder()
.itemInputs(
GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUIV, 64),
ItemList.Casing_Coil_Hypogen.get(64),
GT_Utility.getIntegratedCircuit(1))
.itemOutputs(ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_12_HIGH_AMPERAGE, 1))
.duration(20 * SECONDS).eut(TierEU.RECIPE_UIV).addTo(assemblerRecipes);

// upgrade chip recipe

GT_Values.RA.stdBuilder()
.metadata(
RESEARCH_ITEM,
ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_12_HIGH_AMPERAGE, 1))
.metadata(RESEARCH_TIME, 2 * HOURS)
.itemInputs(
ItemList.Field_Generator_UIV.get(32),
ItemList.Electric_Motor_UEV.get(64),
ItemList.Wireless_Dynamo_Energy_UMV.get(32),
ALLOY.PIKYONIUM.getGear(8),
new Object[] { CI.getTieredCircuitOreDictName(7), 64 },
new Object[] { CI.getTieredCircuitOreDictName(8), 32 },
new Object[] { CI.getTieredCircuitOreDictName(9), 16 },
GregtechItemList.Laser_Lens_Special.get(1),
ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, 64))
.fluidInputs(
ALLOY.NITINOL_60.getFluidStack(144 * 9 * 4),
ALLOY.ENERGYCRYSTAL.getFluidStack(144 * 9 * 8),
ALLOY.TUMBAGA.getFluidStack(144 * 9 * 32),
Materials.Nichrome.getMolten(16 * INGOTS))
.itemOutputs(GregtechItemList.MultiAmp_Upgrade_Chip.get(1)).eut(TierEU.RECIPE_UIV).duration(2 * HOURS)
.addTo(AssemblyLine);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ public enum GregtechItemList implements GregtechItemContainer {
// Pellet Mold
Pellet_Mold,

// Upgrade chip for Distillus
// Upgrade chips
Distillus_Upgrade_Chip,
Maceration_Upgrade_Chip,
MultiAmp_Upgrade_Chip,

// Milling Balls
Milling_Ball_Alumina,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ public String[] getInfoData() {
"" + EnumChatFormatting.YELLOW
+ Long.toString(getMaxInputVoltage())
+ EnumChatFormatting.RESET
+ " EU/t(*2A) "
+ " EU/t(*"
+ EnumChatFormatting.YELLOW
+ Long.toString(getMaxInputAmps())
+ EnumChatFormatting.RESET
+ ") "
+ StatCollector.translateToLocal("GTPP.machines.tier")
+ ": "
+ EnumChatFormatting.YELLOW
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;

import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti;
import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel;

import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.util.GT_ExoticEnergyInputHelper;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;

// how to use this class
// extend this instead of GregtechMeta_MultiBlockBase
// change Energy to Energy.or(ExoticEnergy) in structure definition
// make sure checkHatch is called in checkMachine

public abstract class GregtechMeta_MultiBlockBase_ExoticCapable<T extends GregtechMeta_MultiBlockBase<T>>
extends GregtechMeta_MultiBlockBase<T> {

private boolean multiAmp = false;

public GregtechMeta_MultiBlockBase_ExoticCapable(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}

public GregtechMeta_MultiBlockBase_ExoticCapable(String aName) {
super(aName);
}

@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == 0 && !multiAmp) {
ItemStack aGuiStack = this.getControllerSlot();
if (GregtechItemList.MultiAmp_Upgrade_Chip.isStackEqual(aGuiStack, false, true)) {
multiAmp = true;
mInventory[1] = ItemUtils.depleteStack(aGuiStack);
markDirty();
// schedule a structure check
mUpdated = true;
}
}
}

@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side,
float aX, float aY, float aZ) {
if (!multiAmp && !aPlayer.isSneaking()) {
ItemStack heldItem = aPlayer.getHeldItem();
if (GregtechItemList.MultiAmp_Upgrade_Chip.isStackEqual(heldItem, false, true)) {
multiAmp = true;
aPlayer.setCurrentItemOrArmor(0, ItemUtils.depleteStack(heldItem));
if (getBaseMetaTileEntity().isServerSide()) {
markDirty();
aPlayer.inventory.markDirty();
// schedule a structure check
mUpdated = true;
}
return true;
}
}
return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ);
}

@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("mExotic", multiAmp);
}

@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
if (!aNBT.hasKey("mExotic")) multiAmp = false;
else multiAmp = aNBT.getBoolean("mExotic");
}

@Override
public void initDefaultModes(NBTTagCompound aNBT) {
super.initDefaultModes(aNBT);
if (aNBT == null || !aNBT.hasKey("mExotic")) {
multiAmp = false;
} else {
multiAmp = aNBT.getBoolean("mExotic");
}
}

@Override
public void setItemNBT(NBTTagCompound aNBT) {
super.setItemNBT(aNBT);
aNBT.setBoolean("mExotic", multiAmp);
}

@Override
public void addAdditionalTooltipInformation(ItemStack stack, List<String> tooltip) {
super.addAdditionalTooltipInformation(stack, tooltip);
NBTTagCompound aNBT = stack.getTagCompound();
int tier;
if (aNBT == null || !aNBT.hasKey("mExotic") || !aNBT.getBoolean("mExotic")) {
return;
} else {
tooltip.add(StatCollector.translateToLocal("tooltip.multi_amp_enabled"));
}
}

@Override
public List<GT_MetaTileEntity_Hatch> getExoticAndNormalEnergyHatchList() {
List<GT_MetaTileEntity_Hatch> tHatches = new ArrayList<>();
tHatches.addAll(mExoticEnergyHatches);
tHatches.addAll(mEnergyHatches);
return tHatches;
}

private boolean checkExotics() {
for (GT_MetaTileEntity_Hatch tHatch : getExoticAndNormalEnergyHatchList()) {
if (tHatch instanceof GT_MetaTileEntity_Hatch_EnergyTunnel
|| (!multiAmp && tHatch instanceof GT_MetaTileEntity_Hatch_EnergyMulti)) {
return false;
}
}
return true;
}

@Override
public boolean checkHatch() {
return checkExotics() && super.checkHatch();
}

@Override
protected void setProcessingLogicPower(ProcessingLogic logic) {
logic.setAvailableVoltage(getMaxInputVoltage());
logic.setAvailableAmperage(multiAmp ? getMaxInputAmps() : 1);
logic.setAmperageOC(!multiAmp);
}

/*
* As far as I can tell, this never runs. It just doesn't work, and I have no idea what is going on in
* GregtechMeta_MultiBlockBase that makes it not work
* @Override public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { boolean exotic
* = addExoticEnergyInputToMachineList(aTileEntity, aBaseCasingIndex); return super.addToMachineList(aTileEntity,
* aBaseCasingIndex) || exotic; }
*/

@Override
public boolean addToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) {
boolean exotic = false;
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch hatch
&& GT_ExoticEnergyInputHelper.isExoticEnergyInput(aMetaTileEntity)) {
hatch.updateTexture(aBaseCasingIndex);
hatch.updateCraftingIcon(this.getMachineCraftingIcon());
exotic = mExoticEnergyHatches.add(hatch);
}
return super.addToMachineList(aMetaTileEntity, aBaseCasingIndex) || exotic;
}

@Override
public String[] getInfoData() {
System.out.println("MCMEME");
for (GT_MetaTileEntity_Hatch tHatch : this.getExoticEnergyHatches()) {
System.out.println("FUGGO");
}
for (GT_MetaTileEntity_Hatch tHatch : this.mAllEnergyHatches) {
System.out.println(tHatch.mName);
}

for (GT_MetaTileEntity_Hatch tHatch : this.mTecTechEnergyHatches) {
System.out.println(tHatch.mName);
}
return super.getInfoData();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,17 @@ public void generateMetaItems() {
.set(this.addItem(151, "Distillus Upgrade Chip", "Used to upgrade Distillus to Tier 2"));
GregtechItemList.Maceration_Upgrade_Chip
.set(this.addItem(152, "Maceration Upgrade Chip", "Used to upgrade Maceration Stack to Tier 2"));
GregtechItemList.MultiAmp_Upgrade_Chip.set(
this.addItem(
153,
"Multi-Amp Upgrade Chip",
"Used to make some machines compatible with Multi-Amp energy Hatchs."));
/*
* +"\n" + "Disables tierskipping " +"\n" +
* "Supports Extruder, LPF, Cutting Machine, Mixer, Press, and Forge Hammer " TODO: not sure if there is an easy
* way to get multiline tooltips here
*/

}

public void registerCustomCircuits() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.enums.GT_HatchElement.Energy;
import static gregtech.api.enums.GT_HatchElement.ExoticEnergy;
import static gregtech.api.enums.GT_HatchElement.InputBus;
import static gregtech.api.enums.GT_HatchElement.InputHatch;
import static gregtech.api.enums.GT_HatchElement.Maintenance;
Expand Down Expand Up @@ -39,11 +40,12 @@
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase_ExoticCapable;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;

public class GregtechMetaTileEntity_IndustrialCuttingMachine extends
GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialCuttingMachine> implements ISurvivalConstructable {
public class GregtechMetaTileEntity_IndustrialCuttingMachine
extends GregtechMeta_MultiBlockBase_ExoticCapable<GregtechMetaTileEntity_IndustrialCuttingMachine>
implements ISurvivalConstructable {

private boolean mCuttingMode = true;
private int mCasing;
Expand Down Expand Up @@ -94,9 +96,13 @@ public IStructureDefinition<GregtechMetaTileEntity_IndustrialCuttingMachine> get
{ "CCC", "CCC", "CCC", "CCC", "CCC" }, }))
.addElement(
'C',
buildHatchAdder(GregtechMetaTileEntity_IndustrialCuttingMachine.class)
.atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy, Muffler)
.casingIndex(getCasingTextureIndex()).dot(1).buildAndChain(
buildHatchAdder(GregtechMetaTileEntity_IndustrialCuttingMachine.class).atLeast(
InputBus,
InputHatch,
OutputBus,
Maintenance,
Energy.or(ExoticEnergy),
Muffler).casingIndex(getCasingTextureIndex()).dot(1).buildAndChain(
onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings2Misc, 13))))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.enums.GT_HatchElement.Energy;
import static gregtech.api.enums.GT_HatchElement.ExoticEnergy;
import static gregtech.api.enums.GT_HatchElement.InputBus;
import static gregtech.api.enums.GT_HatchElement.Maintenance;
import static gregtech.api.enums.GT_HatchElement.Muffler;
Expand All @@ -30,11 +31,12 @@
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase_ExoticCapable;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;

public class GregtechMetaTileEntity_IndustrialExtruder extends
GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialExtruder> implements ISurvivalConstructable {
public class GregtechMetaTileEntity_IndustrialExtruder
extends GregtechMeta_MultiBlockBase_ExoticCapable<GregtechMetaTileEntity_IndustrialExtruder>
implements ISurvivalConstructable {

private int mCasing;
private static IStructureDefinition<GregtechMetaTileEntity_IndustrialExtruder> STRUCTURE_DEFINITION = null;
Expand Down Expand Up @@ -85,7 +87,7 @@ public IStructureDefinition<GregtechMetaTileEntity_IndustrialExtruder> getStruct
.addElement(
'C',
buildHatchAdder(GregtechMetaTileEntity_IndustrialExtruder.class)
.atLeast(InputBus, OutputBus, Maintenance, Energy, Muffler)
.atLeast(InputBus, OutputBus, Maintenance, Energy.or(ExoticEnergy), Muffler)
.casingIndex(getCasingTextureIndex()).dot(1).buildAndChain(
onElementPass(
x -> ++x.mCasing,
Expand Down
Loading