Skip to content

Commit

Permalink
Added mode swap button to Utupu Tanuri (#3499)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <dream-master@gmx.net>
  • Loading branch information
Nockyx and Dream-Master authored Nov 15, 2024
1 parent e233cc3 commit 9a06e61
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ dependencies {
compileOnly rfg.deobf("curse.maven:biomes-o-plenty-220318:2499612")

compileOnly('com.github.GTNewHorizons:SC2:2.2.0:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:Binnie:2.4.3:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Binnie:2.4.4:dev') {transitive = false}
compileOnly('curse.maven:PlayerAPI-228969:2248928') {transitive=false}
compileOnly('com.github.GTNewHorizons:BlockRenderer6343:1.2.14:dev'){transitive=false}

Expand All @@ -106,7 +106,7 @@ dependencies {
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:ForestryMC:4.9.16:dev")
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:neiaddons:1.16.0:dev')
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:MagicBees:2.8.5-GTNH:dev')
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:Binnie:2.4.3:dev')
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:Binnie:2.4.4:dev')

testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.TAE;
import gregtech.api.gui.modularui.GTUITextures;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
Expand All @@ -63,9 +64,10 @@ public class MTEIndustrialDehydrator extends GTPPMultiBlockBase<MTEIndustrialDeh
private static int CASING_TEXTURE_ID;
private static final String mCasingName = "Vacuum Casing";
private HeatingCoilLevel mHeatingCapacity;
private boolean mDehydratorMode = false;
private int mCasing;
private static IStructureDefinition<MTEIndustrialDehydrator> STRUCTURE_DEFINITION = null;
private static final int MACHINEMODE_VACUUMFURNACE = 0;
private static final int MACHINEMODE_DEHYDRATOR = 1;

public MTEIndustrialDehydrator(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
Expand Down Expand Up @@ -165,7 +167,8 @@ protected int getCasingTextureId() {

@Override
public RecipeMap<?> getRecipeMap() {
return mDehydratorMode ? GTPPRecipeMaps.chemicalDehydratorNonCellRecipes : GTPPRecipeMaps.vacuumFurnaceRecipes;
return (machineMode == MACHINEMODE_VACUUMFURNACE) ? GTPPRecipeMaps.vacuumFurnaceRecipes
: GTPPRecipeMaps.chemicalDehydratorNonCellRecipes;
}

@Nonnull
Expand Down Expand Up @@ -225,22 +228,36 @@ protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe

@Override
public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) {
mDehydratorMode = !mDehydratorMode;
String aMode = mDehydratorMode ? "Dehydrator" : "Vacuum Furnace";
PlayerUtils.messagePlayer(aPlayer, "Mode: " + aMode);
mLastRecipe = null;
setMachineMode(nextMachineMode());
PlayerUtils.messagePlayer(
aPlayer,
String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName()));
}

@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("mDehydratorMode", mDehydratorMode);
public boolean supportsMachineModeSwitch() {
return true;
}

@Override
public void setMachineModeIcons() {
machineModeIcons.clear();
machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_STEAM);
machineModeIcons.add(GTUITextures.OVERLAY_BUTTON_MACHINEMODE_LPF_FLUID);
}

@Override
public String getMachineModeName() {
return StatCollector.translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_DEHYDRATOR.mode." + machineMode);
}

@Override
public void loadNBTData(NBTTagCompound aNBT) {
// Migrates old NBT tag to the new one
if (aNBT.hasKey("mDehydratorMode")) {
machineMode = aNBT.getBoolean("mDehydratorMode") ? MACHINEMODE_DEHYDRATOR : MACHINEMODE_VACUUMFURNACE;
}
super.loadNBTData(aNBT);
mDehydratorMode = aNBT.getBoolean("mDehydratorMode");
}

public HeatingCoilLevel getCoilLevel() {
Expand All @@ -255,7 +272,7 @@ public void setCoilLevel(HeatingCoilLevel aCoilLevel) {
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
super.getWailaNBTData(player, tile, tag, world, x, y, z);
tag.setBoolean("mode", mDehydratorMode);
tag.setInteger("mode", machineMode);
}

@Override
Expand All @@ -266,8 +283,9 @@ public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDat
currentTip.add(
StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " "
+ EnumChatFormatting.WHITE
+ StatCollector
.translateToLocal("GT5U.GTPP_MULTI_INDUSTRIAL_DEHYDRATOR.mode." + (tag.getBoolean("mode") ? 1 : 0))
+ StatCollector.translateToLocal(
"GT5U.GTPP_MULTI_INDUSTRIAL_DEHYDRATOR.mode."
+ (tag.getBoolean("mode") ? MACHINEMODE_DEHYDRATOR : MACHINEMODE_VACUUMFURNACE))
+ EnumChatFormatting.RESET);
}
}

0 comments on commit 9a06e61

Please sign in to comment.