Merge branch 'master' into gui-reaper

This commit is contained in:
Martin Robertz authored and GitHub committed 2025-11-04 12:08:07 +01:00
commit 15ed08077a
13 files changed
+171 -305

No files matched your search

+9 -9
View File
@@ -34,11 +34,11 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.8.20-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:99:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.8.26-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-727-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.9.2:dev')
api("com.github.GTNewHorizons:GTNHLib:0.7.0:dev")
api('com.github.GTNewHorizons:waila:1.9.7:dev')
api("com.github.GTNewHorizons:GTNHLib:0.7.3:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:99:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
@@ -46,18 +46,18 @@ dependencies {
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.2-GTNH:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.17:dev')
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.0:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.10.3:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.65:dev') {
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.87:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.2-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.4-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.14-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.3:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.9:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.4:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.4.0:dev")
}
+9 -1
View File
@@ -96,7 +96,9 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -172,6 +174,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -2
View File
@@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -2
View File
@@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
}
@@ -20,19 +20,7 @@ import com.glodblock.github.util.BlockPos;
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
private FluidStack lastBeforeUpdate = null;
public FluidTank tank = new FluidTank(32000) {
@Override
public FluidTank readFromNBT(NBTTagCompound nbt) {
if (!nbt.hasKey("Empty")) {
FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
setFluid(fluid);
} else {
setFluid(null);
}
return this;
}
};
public FluidTank tank = new FluidTank(32000);
private boolean hasUpdate;
@Override
@@ -51,79 +39,74 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
}
public void compareAndUpdate() {
if (!this.worldObj.isRemote) {
FluidStack current = this.tank.getFluid();
if (current != null) {
if (this.lastBeforeUpdate != null) {
if (Math.abs(current.amount - this.lastBeforeUpdate.amount) >= 500) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
} else if (this.lastBeforeUpdate.amount < this.tank.getCapacity()
&& current.amount == this.tank.getCapacity()
|| this.lastBeforeUpdate.amount == this.tank.getCapacity()
&& current.amount < this.tank.getCapacity()) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
}
} else {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
}
} else if (this.lastBeforeUpdate != null) {
if (this.worldObj.isRemote) {
return;
}
FluidStack current = this.tank.getFluid();
if (current == null || this.lastBeforeUpdate == null) {
if (current != this.lastBeforeUpdate) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = null;
this.lastBeforeUpdate = current == null ? null : current.copy();
}
return;
}
boolean amountSufficientlyChanged = Math.abs(current.amount - this.lastBeforeUpdate.amount) >= 500;
boolean isFull = current.amount == this.tank.getCapacity();
boolean wasFull = this.lastBeforeUpdate.amount == this.tank.getCapacity();
boolean fullStateChanged = isFull != wasFull;
if (amountSufficientlyChanged || fullStateChanged) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
}
}
public FluidStack drain(FluidStack fluid, boolean doDrain, boolean findMainTank) {
if (findMainTank) {
int yOff = 0;
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
TileCertusQuartzTank mainTank = this;
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid();
if (offFluid != null && offFluid == fluid.getFluid()) {
mainTank = (TileCertusQuartzTank) this.worldObj
.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
continue;
}
}
break;
}
return mainTank != null ? mainTank.drain(fluid, doDrain, false) : null;
if (fluid == null || this.getFluid() == null || this.getFluid() != fluid.getFluid()) {
return null;
}
FluidStack drained = this.tank.drain(fluid.amount, doDrain);
if (findMainTank) {
// Main tank is the highest tank in the column with desired fluid
TileCertusQuartzTank mainTank = this;
TileCertusQuartzTank tankAbove;
while ((tankAbove = mainTank.getTankAbove()) != null) {
// We can't drain tank with different or null fluid
if (fluid.getFluid() != tankAbove.getFluid()) {
break;
}
mainTank = tankAbove;
}
return mainTank.drain(fluid, doDrain, false);
}
FluidStack drainedFluid = this.tank.drain(fluid.amount, doDrain);
int drained = drainedFluid != null ? drainedFluid.amount : 0;
compareAndUpdate();
if (drained == null || drained.amount < fluid.amount) {
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if (offTE instanceof TileCertusQuartzTank tileCertusQuartzTank) {
FluidStack externallyDrained = tileCertusQuartzTank.drain(
new FluidStack(fluid.getFluid(), fluid.amount - (drained != null ? drained.amount : 0)),
doDrain,
false);
if (drained < fluid.amount) {
TileCertusQuartzTank tankBelow = this.getTankBelow();
if (tankBelow != null) {
FluidStack fluidToDrain = new FluidStack(fluid.getFluid(), fluid.amount - drained);
FluidStack externallyDrained = tankBelow.drain(fluidToDrain, doDrain, false);
if (externallyDrained != null) return new FluidStack(
fluid.getFluid(),
(drained != null ? drained.amount : 0) + externallyDrained.amount);
else return drained;
if (externallyDrained != null) {
return new FluidStack(fluid.getFluid(), drained + externallyDrained.amount);
}
}
}
return drained;
return drainedFluid;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
if (this.tank.getFluid() == null || resource == null || resource.getFluid() != this.tank.getFluid().getFluid())
return null;
return drain(resource, doDrain, true);
}
@@ -135,35 +118,39 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
}
public int fill(FluidStack fluid, boolean doFill, boolean findMainTank) {
if (fluid == null || this.getFluid() != null && this.getFluid() != fluid.getFluid()) {
return 0;
}
if (findMainTank) {
int yOff = 0;
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
// Main tank is the lowest tank in the column with desired fluid
TileCertusQuartzTank mainTank = this;
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid();
if (offFluid == null || offFluid == fluid.getFluid()) {
mainTank = (TileCertusQuartzTank) this.worldObj
.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
continue;
}
TileCertusQuartzTank tankBelow;
while ((tankBelow = mainTank.getTankBelow()) != null) {
FluidStack fluidBelow = tankBelow.tank.getFluid();
// We can't fill already full tank
if (fluidBelow != null && fluidBelow.amount == tankBelow.tank.getCapacity()) {
break;
}
break;
// We can't fill tank with different fluid
if (tankBelow.getFluid() != null && fluid.getFluid() != tankBelow.getFluid()) {
break;
}
mainTank = tankBelow;
}
return mainTank != null ? mainTank.fill(fluid, doFill, false) : 0;
return mainTank.fill(fluid, doFill, false);
}
int filled = this.tank.fill(fluid, doFill);
compareAndUpdate();
if (filled < fluid.amount) {
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
if (offTE instanceof TileCertusQuartzTank tileCertusQuartzTank) {
return filled + tileCertusQuartzTank
.fill(new FluidStack(fluid.getFluid(), fluid.amount - filled), doFill, false);
TileCertusQuartzTank tankAbove = this.getTankAbove();
if (tankAbove != null) {
FluidStack fluidToFill = new FluidStack(fluid.getFluid(), fluid.amount - filled);
return filled + tankAbove.fill(fluidToFill, doFill, false);
}
}
@@ -175,8 +162,6 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
*/
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if (resource == null || this.tank.getFluid() != null && resource.getFluid() != this.tank.getFluid().getFluid())
return 0;
return fill(resource, doFill, true);
}
@@ -206,9 +191,8 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
@Override
public void updateEntity() {
super.updateEntity();
if (this.tank.getFluid() != null) {
TileCertusQuartzTank below = getTankBelow(this);
TileCertusQuartzTank below = getTankBelow();
if (below != null) {
FluidStack filled = this.tank.getFluid().copy();
filled.amount = below.fill(this.tank.getFluid(), true, true);
@@ -226,58 +210,57 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
}
}
private TileCertusQuartzTank getTankBelow(TileEntity tile) {
TileEntity tank = new BlockPos(tile).getOffSet(0, -1, 0).getTileEntity();
if (tank instanceof TileCertusQuartzTank) {
return (TileCertusQuartzTank) tank;
private TileCertusQuartzTank getTankAbove() {
TileEntity tile = new BlockPos(this).getOffSet(0, 1, 0).getTileEntity();
if (tile instanceof TileCertusQuartzTank tankTile) {
return tankTile;
}
return null;
}
public FluidTankInfo[] getTankInfo(boolean goToMainTank) {
if (!goToMainTank) return new FluidTankInfo[] { this.tank.getInfo() };
private TileCertusQuartzTank getTankBelow() {
TileEntity tile = new BlockPos(this).getOffSet(0, -1, 0).getTileEntity();
if (tile instanceof TileCertusQuartzTank tankTile) {
return tankTile;
}
return null;
}
int amount = 0, capacity = 0;
Fluid fluid = null;
int yOff = 0;
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
TileCertusQuartzTank mainTank;
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
if (((TileCertusQuartzTank) offTE).getFluid() == null
|| ((TileCertusQuartzTank) offTE).getFluid() == getFluid()) {
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
continue;
}
}
break;
public FluidTankInfo[] getTankInfo(boolean countAllTanksInColumn) {
if (!countAllTanksInColumn) {
return new FluidTankInfo[] { this.tank.getInfo() };
}
yOff -= 1;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
mainTank = (TileCertusQuartzTank) offTE;
if (mainTank.getFluid() == null || getFluid() == null || mainTank.getFluid() == getFluid()) {
FluidTankInfo info = mainTank.getTankInfo(false)[0];
if (info != null) {
capacity += info.capacity;
if (info.fluid != null) {
amount += info.fluid.amount;
if (info.fluid.getFluid() != null) fluid = info.fluid.getFluid();
}
}
offTE = new BlockPos(offTE).getOffSet(0, 1, 0).getTileEntity();
continue;
}
final FluidStack tankFluidStack = this.tank.getFluid();
final Fluid mainFluid = tankFluidStack != null ? tankFluidStack.getFluid() : null;
int amount = tankFluidStack == null ? 0 : tankFluidStack.amount;
int capacity = this.tank.getCapacity();
TileCertusQuartzTank tankAbove = this;
while ((tankAbove = tankAbove.getTankAbove()) != null) {
if (tankAbove.getFluid() == null || mainFluid != tankAbove.getFluid()) {
break;
}
break;
FluidTankInfo info = tankAbove.tank.getInfo();
amount += info.fluid == null ? 0 : info.fluid.amount;
capacity += info.capacity;
}
TileCertusQuartzTank tankBelow = this;
while ((tankBelow = tankBelow.getTankBelow()) != null) {
if (mainFluid == null || mainFluid != tankBelow.getFluid()) {
break;
}
FluidTankInfo info = tankBelow.tank.getInfo();
amount += info.fluid == null ? 0 : info.fluid.amount;
capacity += info.capacity;
}
return new FluidTankInfo[] {
new FluidTankInfo(fluid != null ? new FluidStack(fluid, amount) : null, capacity) };
new FluidTankInfo(mainFluid != null ? new FluidStack(mainFluid, amount) : null, capacity) };
}
@Override
@@ -0,0 +1,30 @@
package com.glodblock.github.crossmod.waila;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidTankInfo;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
public class CertusQuartzTankWailaDataProvider extends BaseWailaDataProvider {
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity instanceof TileCertusQuartzTank quartzTank) {
FluidTankInfo info = quartzTank.getTankInfo(true)[0];
if (info.fluid != null) {
currentToolTip
.add(Tooltip.fluidFormat(info.fluid.getLocalizedName(), info.fluid.amount, info.capacity));
}
}
return currentToolTip;
}
}
@@ -1,71 +0,0 @@
package com.glodblock.github.crossmod.waila;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.glodblock.github.crossmod.waila.vanilla.FluidInvWailaDataProvider;
import com.google.common.collect.Lists;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
public class VanillaTileWailaDataProvider implements IWailaDataProvider {
private final List<IWailaDataProvider> providers;
public VanillaTileWailaDataProvider() {
final IWailaDataProvider fluidInv = new FluidInvWailaDataProvider();
this.providers = Lists.newArrayList(fluidInv);
}
@Override
public ItemStack getWailaStack(final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaHead(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaBody(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public List<String> getWailaTail(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
for (final IWailaDataProvider provider : this.providers) {
provider.getWailaTail(itemStack, currentToolTip, accessor, config);
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
for (final IWailaDataProvider provider : this.providers) {
provider.getNBTData(player, te, tag, world, x, y, z);
}
return tag;
}
}
@@ -1,6 +1,6 @@
package com.glodblock.github.crossmod.waila;
import net.minecraft.tileentity.TileEntity;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import appeng.api.parts.IPartHost;
import appeng.tile.AEBaseTile;
@@ -26,9 +26,8 @@ public class WailaInit {
registrar.registerBodyProvider(tile, AEBaseTile.class);
registrar.registerNBTProvider(tile, AEBaseTile.class);
final IWailaDataProvider vanillaTile = new VanillaTileWailaDataProvider();
registrar.registerBodyProvider(vanillaTile, TileEntity.class);
registrar.registerNBTProvider(vanillaTile, TileEntity.class);
final IWailaDataProvider certusQuartzTank = new CertusQuartzTankWailaDataProvider();
registrar.registerBodyProvider(certusQuartzTank, TileCertusQuartzTank.class);
}
}
@@ -1,50 +0,0 @@
package com.glodblock.github.crossmod.waila.vanilla;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidTankInfo;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.crossmod.waila.Tooltip;
import com.glodblock.github.util.Util;
import appeng.integration.modules.waila.BaseWailaDataProvider;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
public class FluidInvWailaDataProvider extends BaseWailaDataProvider {
@Override
public List<String> getWailaBody(final ItemStack itemStack, final List<String> currentToolTip,
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
final TileEntity te = accessor.getTileEntity();
if (te instanceof TileCertusQuartzTank) {
if (accessor.getNBTData().hasKey("fluidInv")) {
NBTTagCompound data = (NBTTagCompound) accessor.getNBTData().getTag("fluidInv");
for (FluidTankInfo info : Util.FluidUtil.fluidTankInfoReadFromNBT(data)) {
if (info.fluid == null) continue;
currentToolTip
.add(Tooltip.fluidFormat(info.fluid.getLocalizedName(), info.fluid.amount, info.capacity));
}
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(final EntityPlayerMP player, final TileEntity te, final NBTTagCompound tag,
final World world, final int x, final int y, final int z) {
if (te instanceof TileCertusQuartzTank) {
NBTTagCompound data = new NBTTagCompound();
Util.FluidUtil.fluidTankInfoWriteToNBT(((TileCertusQuartzTank) te).getInternalFluid(), data);
tag.setTag("fluidInv", data);
te.writeToNBT(tag);
}
return tag;
}
}
@@ -7,8 +7,6 @@ import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import static net.minecraft.init.Items.glass_bottle;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,7 +22,6 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -517,36 +514,6 @@ public final class Util {
public static final ItemStack water_bucket = new ItemStack(Items.water_bucket, 1);
public static void fluidTankInfoWriteToNBT(FluidTankInfo[] infos, NBTTagCompound data) {
int i = 0;
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.amount > 0) {
NBTTagCompound fs = new NBTTagCompound();
info.fluid.writeToNBT(fs);
fs.setInteger("capacity", info.capacity);
data.setTag("#" + i, fs);
}
i++;
}
data.setInteger("fluidInvSize", i);
}
public static FluidTankInfo[] fluidTankInfoReadFromNBT(NBTTagCompound data) {
int i = 0;
List<FluidTankInfo> infos = new ArrayList<>();
while (data.hasKey("fluidInvSize") && i < data.getInteger("fluidInvSize")) {
if (data.hasKey("#" + i)) {
NBTTagCompound tag = (NBTTagCompound) data.getTag("#" + i);
FluidStack fs = FluidStack.loadFluidStackFromNBT(tag);
infos.add(new FluidTankInfo(fs, tag.getInteger("capacity")));
} else {
infos.add(new FluidTankInfo(null, 0));
}
i++;
}
return infos.toArray(new FluidTankInfo[0]);
}
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
}