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

Commit

Permalink
Add void excess option to yotta fluid tank (#100)
Browse files Browse the repository at this point in the history
* Add void excess option to yotta fluid tank

* derp

* Added own localization of void excess toggle messages
  • Loading branch information
minecraft7771 authored Nov 4, 2022
1 parent d9c4f5e commit 4c5ead4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
} else {
int added = host.mStorage.subtract(host.mStorageCurrent).intValue();
if (doFill) host.addFluid(added);
return added;
return host.getIsVoidExcessEnabled() ? resource.amount : added;
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -63,6 +65,8 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM
protected final String YOTTANK_MID = mName + "mid";
protected final String YOTTANK_TOP = mName + "top";

protected boolean voidExcessEnabled = false;

public YottaFluidTank(int id, String name, String nameRegional) {
super(id, name, nameRegional);
}
Expand Down Expand Up @@ -102,6 +106,7 @@ public void loadNBTData(NBTTagCompound aNBT) {
mStorage = new BigInteger(tAmount, 10);
mStorageCurrent = new BigInteger(tAmountCurrent, 10);
mFluidName = aNBT.getString("mFluidName");
voidExcessEnabled = aNBT.getBoolean("voidExcessEnabled");
super.loadNBTData(aNBT);
}

Expand All @@ -110,6 +115,7 @@ public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setString("mStorage", mStorage.toString(10));
aNBT.setString("mStorageCurrent", mStorageCurrent.toString(10));
aNBT.setString("mFluidName", mFluidName);
aNBT.setBoolean("voidExcessEnabled", voidExcessEnabled);
super.saveNBTData(aNBT);
}

Expand All @@ -120,6 +126,10 @@ public boolean checkRecipe_EM(ItemStack aStack) {
return true;
}

public boolean getIsVoidExcessEnabled() {
return voidExcessEnabled;
}

public boolean reduceFluid(long amount) {
BigInteger tmp = new BigInteger(amount + "");
if (mStorageCurrent.compareTo(tmp) < 0) {
Expand Down Expand Up @@ -357,7 +367,11 @@ public boolean onRunningTick(ItemStack aStack) {
} else {
BigInteger delta = mStorage.subtract(mStorageCurrent);
mStorageCurrent = mStorageCurrent.add(delta);
tFluid.amount -= delta.intValue();
if (voidExcessEnabled) {
tFluid.amount = 0;
} else {
tFluid.amount -= delta.intValue();
}
}
}
}
Expand Down Expand Up @@ -406,6 +420,18 @@ public void construct(ItemStack stackSize, boolean hintsOnly) {
}
}

@Override
public boolean onSolderingToolRightClick(
byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (aSide == getBaseMetaTileEntity().getFrontFacing()) {
voidExcessEnabled ^= true;
aPlayer.addChatMessage(new ChatComponentTranslation(
voidExcessEnabled ? "yottank.chat.voidExcessEnabled" : "yottank.chat.voidExcessDisabled"));
return true;
}
return false;
}

@Override
public String[] getStructureDescription(ItemStack stackSize) {
return DescTextLocalization.addText("YOTTank.hint", 8);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/goodgenerator/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ yothatch.chat.0=Set storage priority to %s.
yothatch.chat.1=Set to %s mode
yottank.chat.0=Clear the lock filter
yottank.chat.1=Lock to %s
yottank.chat.voidExcessEnabled=Void Excess Enabled
yottank.chat.voidExcessDisabled=Void Excess Disabled
preciseassembler.chat.0=Precise Mode
preciseassembler.chat.1=Normal Mode
essentiaoutputhatch.chat.0=Cleared.
Expand Down

0 comments on commit 4c5ead4

Please sign in to comment.