From 32af02239dc6a40c49212a82cafc96f497e9f6fd Mon Sep 17 00:00:00 2001 From: danyadev Date: Thu, 30 Oct 2025 19:30:10 +0300 Subject: [PATCH 1/3] refactor TileCertusQuartzTank (#346) --- dependencies.gradle | 18 +- gradle.properties | 4 +- settings.gradle | 2 +- .../common/tile/TileCertusQuartzTank.java | 245 ++++++++---------- 4 files changed, 127 insertions(+), 142 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index ad704349..70b9831f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -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:rv3-beta-718-GTNH:dev') + api('com.github.GTNewHorizons:NotEnoughItems:2.8.25-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-725-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:1.12.7: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.83: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.7:dev") { transitive = false } - runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.4:dev") + runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.4.0:dev") } diff --git a/gradle.properties b/gradle.properties index 0f96f766..4194930b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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..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! diff --git a/settings.gradle b/settings.gradle index 9105fb71..05c912eb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,7 +17,7 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.47' } diff --git a/src/main/java/com/glodblock/github/common/tile/TileCertusQuartzTank.java b/src/main/java/com/glodblock/github/common/tile/TileCertusQuartzTank.java index aa54e130..d8917c26 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileCertusQuartzTank.java +++ b/src/main/java/com/glodblock/github/common/tile/TileCertusQuartzTank.java @@ -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 From b0f0c22eaef85acc339ebbcb86b6f00609744932 Mon Sep 17 00:00:00 2001 From: Dream Master Date: Fri, 31 Oct 2025 13:59:53 +0100 Subject: [PATCH 2/3] update --- dependencies.gradle | 8 ++++---- gradle.properties | 6 ++++++ gradle/wrapper/gradle-wrapper.jar | Bin 43705 -> 43764 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 4 ++-- gradlew.bat | 4 ++-- settings.gradle | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 70b9831f..c6a9bbc4 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -34,8 +34,8 @@ * 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.25-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-725-GTNH: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.7:dev') api("com.github.GTNewHorizons:GTNHLib:0.7.3:dev") @@ -48,7 +48,7 @@ dependencies { compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false } 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.83: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' } @@ -57,7 +57,7 @@ dependencies { compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23: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.7:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.9:dev") { transitive = false } runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.4.0:dev") } diff --git a/gradle.properties b/gradle.properties index 4194930b..b7f8f5bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -174,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. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 9bbc975c742b298b441bfb90dbc124400a3751b9..1b33c55baabb587c669f562ae36f953de2481846 100644 GIT binary patch delta 642 zcmdmamFde>rVZJA^}0Q$xegf!xPEW^+5YDM%iT2bEgct9o+jH~+sJas#HZ=szO|** z=Pj=X_vx?W&DSwKck|WWn~hffsvnQ+42*W$b7b0$SCcOoZ`{W{^$^pk;4>8-A*-)$ z?n(Po`1$6Jn_u?t-L+tsPyZ2#X}8T6OS8pAU;kdgd+_Hw4z4TW0p9E!T+=f7-c&O% zFic^X{7^$?^Ho04eona9n#mGMxKhA=~8B%JN`M zMhm5wc-2v)$``sY$!Q`9xiU@DhI73ZxiGEKg>yIPs)NmWwMdF-ngLXpZSqV5ez36n zVkxF2rjrjWR+_xr6e6@_u@s~2uv{9vi*1pj2)BjFD+-%@&pRVP1f{O1glxTOp2-62Ph;v z`N1+vCd)9ea)af*Ol1*JCfnp$%Uu}%OuoN7g2}3C@`L5FlP#(sA=|h@iixuZC?qp^ z=L$=v$ZoI}|87Wh=&h7udff{aieKr*l+zDp?pf)_bbRvUf>kn;HCDMXNlgbbo!QRK I1x7am0No)LiU0rr delta 584 zcmexzm1*ZyrVZJAexH5Moc8h7)w{^+t*dqJ%=yhh23L$9JpFV=_k`zJ-?Q4DI*eSe z+ES)HSrVnWLtJ&)lO%hRkV9zl5qqWRt0e;bb zPPo`)y?HTAyZI&u&X<|2$FDHCf4;!v8}p=?Tm`^F0`u(|1ttf~&t$qP3KUSD>@TJQ zRwJ}Pim6NzEc8KA6)e;S6gs8=7IIL8sQL*MYEuRYO;Uj<%3UbMbV&^&!Zvx+LKmjT z8Zch6rYP7Tw?$Hn(UTJwWiS=$f{lB(C=e*%usDV})0AQIK~sat=ND@+Gg*Pyij!rR z*fa02W|%BsV++>4W{DKDGSIUEHd2$P+8ct!RF+CHDowUuTEZOZ%rJSQv*qOXOSPDN zT|sP-$p*_3ncsWB*qoD7JQcyZ9xan%cJP6Tb4-?AZpr*F6v98hoNaPJm@HV`yya5N z))6pqFXn@}P(3T0nEzM8*c_9KtE9o|_pFd&K35GBXP^9Kg(b6GH-z8S4GDzIl~T+b zdLd#meKKHu$5u))8cu$=GKINkGDPOUD)!0$C(BH(U!}!-e;Q0ok8Sc?V1zRO04>ts AA^-pY diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37f853b1..d4081da4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index faf93008..23d15a93 100755 --- a/gradlew +++ b/gradlew @@ -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. diff --git a/gradlew.bat b/gradlew.bat index 9d21a218..db3a6ac2 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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 diff --git a/settings.gradle b/settings.gradle index 05c912eb..e883289b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,7 +17,7 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.47' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48' } From 6490451dc80ff07e04b629a10b5268ca17e52a61 Mon Sep 17 00:00:00 2001 From: danyadev Date: Mon, 3 Nov 2025 17:13:46 +0300 Subject: [PATCH 3/3] fix waila body flickering when looking at a certus quartz tank (#350) --- .../CertusQuartzTankWailaDataProvider.java | 30 ++++++++ .../waila/VanillaTileWailaDataProvider.java | 71 ------------------- .../github/crossmod/waila/WailaInit.java | 7 +- .../vanilla/FluidInvWailaDataProvider.java | 50 ------------- .../java/com/glodblock/github/util/Util.java | 33 --------- 5 files changed, 33 insertions(+), 158 deletions(-) create mode 100644 src/main/java/com/glodblock/github/crossmod/waila/CertusQuartzTankWailaDataProvider.java delete mode 100644 src/main/java/com/glodblock/github/crossmod/waila/VanillaTileWailaDataProvider.java delete mode 100644 src/main/java/com/glodblock/github/crossmod/waila/vanilla/FluidInvWailaDataProvider.java diff --git a/src/main/java/com/glodblock/github/crossmod/waila/CertusQuartzTankWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/CertusQuartzTankWailaDataProvider.java new file mode 100644 index 00000000..22e418f4 --- /dev/null +++ b/src/main/java/com/glodblock/github/crossmod/waila/CertusQuartzTankWailaDataProvider.java @@ -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 getWailaBody(final ItemStack itemStack, final List 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; + } +} diff --git a/src/main/java/com/glodblock/github/crossmod/waila/VanillaTileWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/VanillaTileWailaDataProvider.java deleted file mode 100644 index c1b6018c..00000000 --- a/src/main/java/com/glodblock/github/crossmod/waila/VanillaTileWailaDataProvider.java +++ /dev/null @@ -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 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 getWailaHead(final ItemStack itemStack, final List currentToolTip, - final IWailaDataAccessor accessor, final IWailaConfigHandler config) { - for (final IWailaDataProvider provider : this.providers) { - provider.getWailaHead(itemStack, currentToolTip, accessor, config); - } - - return currentToolTip; - } - - @Override - public List getWailaBody(final ItemStack itemStack, final List currentToolTip, - final IWailaDataAccessor accessor, final IWailaConfigHandler config) { - for (final IWailaDataProvider provider : this.providers) { - provider.getWailaBody(itemStack, currentToolTip, accessor, config); - } - - return currentToolTip; - } - - @Override - public List getWailaTail(final ItemStack itemStack, final List 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; - } -} diff --git a/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java b/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java index aecc6110..8cbf4293 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java @@ -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); } } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/vanilla/FluidInvWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/vanilla/FluidInvWailaDataProvider.java deleted file mode 100644 index 807f1358..00000000 --- a/src/main/java/com/glodblock/github/crossmod/waila/vanilla/FluidInvWailaDataProvider.java +++ /dev/null @@ -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 getWailaBody(final ItemStack itemStack, final List 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; - } -} diff --git a/src/main/java/com/glodblock/github/util/Util.java b/src/main/java/com/glodblock/github/util/Util.java index ade70cc5..aa69e5bf 100644 --- a/src/main/java/com/glodblock/github/util/Util.java +++ b/src/main/java/com/glodblock/github/util/Util.java @@ -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; @@ -510,36 +507,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 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)); }