mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Fluid rework derp fixes. (#6098)
* Fix nulls returning from non-null methods, and null-check of non-nullable values. * Fix missed computation of the isEmpty flag in FluidStack * Cleanup getAmount/isEmpty calls. * Remove redundant suppliers. That info is readily available from the vanilla Fluid / FluidState.
This commit is contained in:
1 parent
bae2ee0420
commit
d9f6659f2c
12 files changed
+55
-80
No files matched your search
@@ -69,6 +69,8 @@ public class FluidStack
|
||||
}
|
||||
this.fluidDelegate = fluid.delegate;
|
||||
this.amount = amount;
|
||||
|
||||
updateEmpty();
|
||||
}
|
||||
|
||||
public FluidStack(Fluid fluid, int amount, CompoundNBT nbt)
|
||||
@@ -170,7 +172,6 @@ public class FluidStack
|
||||
public void setAmount(int amount)
|
||||
{
|
||||
if (getRawFluid() == Fluids.EMPTY) throw new IllegalStateException("Can't modify the empty stack.");
|
||||
if (amount < 0) throw new IllegalStateException("The amount can't be negative.");
|
||||
this.amount = amount;
|
||||
updateEmpty();
|
||||
}
|
||||
@@ -217,8 +218,10 @@ public class FluidStack
|
||||
{
|
||||
getOrCreateTag();
|
||||
CompoundNBT child = tag.getCompound(childName);
|
||||
if (child == null)
|
||||
tag.put(childName, child = new CompoundNBT());
|
||||
if (!tag.contains(childName, Constants.NBT.TAG_COMPOUND))
|
||||
{
|
||||
tag.put(childName, child);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -302,13 +305,8 @@ public class FluidStack
|
||||
* The ItemStack for comparison
|
||||
* @return true if the Fluids (IDs and NBT Tags) are the same
|
||||
*/
|
||||
public boolean isFluidEqual(ItemStack other)
|
||||
public boolean isFluidEqual(@Nonnull ItemStack other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return FluidUtil.getFluidContained(other).map(this::isFluidEqual).orElse(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user