Class WeightedFluidVolume<T>
java.lang.Object
alexiil.mc.lib.attributes.fluid.volume.FluidVolume
alexiil.mc.lib.attributes.fluid.volume.WeightedFluidVolume<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
Fields inherited from class alexiil.mc.lib.attributes.fluid.volume.FluidVolume
BASE_UNIT, BOTTLE, BUCKET, DESERIALIZER, fluidKey -
Constructor Summary
ConstructorsConstructorDescriptionWeightedFluidVolume(WeightedFluidKey<T> key, com.google.gson.JsonObject json, WeightedFluidVolume.WeightedJsonGetter<T> keyGetter) Json deserialiser that assumes the values are complicated, and so need a more complex json element than just a string to deserialise.WeightedFluidVolume(WeightedFluidKey<T> key, com.google.gson.JsonObject json, WeightedFluidVolume.WeightedStringGetter<T> keyGetter) Json deserialiser that assumes the values are simple and require just a string to deserialise.WeightedFluidVolume(WeightedFluidKey<T> key, net.minecraft.nbt.NbtCompound tag) WeightedFluidVolume(WeightedFluidKey<T> key, T value, int amount) Deprecated, for removal: This API element is subject to removal in a future version.WeightedFluidVolume(WeightedFluidKey<T> key, T value, FluidAmount amount) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAmount(T value, FluidAmount amount) voidaddAmount(T value, FluidAmount amount, FluidAmount.FluidMergeRounding rounding) voidaddAmounts(Map<T, FluidAmount> sources) protected abstract booleanprotected WeightedFluidVolume<T>copy0()protected final Tprotected voidfromMcBufferInternal(net.minecraft.network.PacketByteBuf buffer) protected net.minecraft.text.TextgetTextFor(T value) List<net.minecraft.text.Text>getTooltipText(net.minecraft.client.item.TooltipContext ctx) protected voidmergeInternal(FluidVolume vol, FluidAmount.FluidMergeResult result) Actually merges twoFluidVolume's together.protected final voidprotected abstract TreadValue(net.minecraft.nbt.NbtCompound holder) Inverse ofwriteValue(NbtCompound, Object).protected TreadValueFromMcBuffer(net.minecraft.network.PacketByteBuf buffer) protected voidreadValuesFromMcBuffer(net.minecraft.network.PacketByteBuf buffer, Map<T, FluidAmount> map) protected abstract StringsaveName()protected WeightedFluidVolume<T>split0(FluidAmount toTake, RoundingMode rounding) com.google.gson.JsonObjecttoJson()protected abstract com.google.gson.JsonElementprotected voidtoMcBufferInternal(net.minecraft.network.PacketByteBuf buffer) net.minecraft.nbt.NbtCompoundtoTag(net.minecraft.nbt.NbtCompound tag) protected abstract voidwriteValue(net.minecraft.nbt.NbtCompound holder, T value) protected voidwriteValuesToMcBuffer(net.minecraft.network.PacketByteBuf buffer, Map<T, FluidAmount> map) protected voidwriteValueToMcBuffer(net.minecraft.network.PacketByteBuf buffer, T value) Methods inherited from class alexiil.mc.lib.attributes.fluid.volume.FluidVolume
addFullTooltip, addFullTooltip, addFullTooltip, addTooltipExtras, addTooltipNameAmount, addTooltipProperties, addTooltipTemperature, amount, areEqualExceptAmounts, areFullyEqual, canMerge, copy, create, create, create, equals, fromJson, fromMcBuffer, fromTag, getAmount, getAmount_F, getFlowingSprite, getFullTooltip, getFullTooltip, getFullTooltip, getName, getProperty, getRawAmount, getRawAmount_F, getRawFluid, getRenderColor, getRenderer, getSprite, getStillSprite, hashCode, isEmpty, localizeAmount, localizeAmount, localizeInTank, localizeInTank, merge, merge, merge, merge, merge0, mergeInto, mergeInto, mergeInto, multiplyAmount, parseAmount, render, renderGuiRect, setAmount, setAmount, setProperty, split, split, split, toMcBuffer, toString, toTag, withAmount
-
Constructor Details
-
WeightedFluidVolume
-
WeightedFluidVolume
@Deprecated(since="0.6.4", forRemoval=true) public WeightedFluidVolume(WeightedFluidKey<T> key, T value, int amount) Deprecated, for removal: This API element is subject to removal in a future version. -
WeightedFluidVolume
-
WeightedFluidVolume
public WeightedFluidVolume(WeightedFluidKey<T> key, com.google.gson.JsonObject json, WeightedFluidVolume.WeightedStringGetter<T> keyGetter) throws com.google.gson.JsonSyntaxException Json deserialiser that assumes the values are simple and require just a string to deserialise. It is only ever necessary for subclasses to call one of these constructors.- Throws:
com.google.gson.JsonSyntaxException- See Also:
-
WeightedFluidVolume
public WeightedFluidVolume(WeightedFluidKey<T> key, com.google.gson.JsonObject json, WeightedFluidVolume.WeightedJsonGetter<T> keyGetter) throws com.google.gson.JsonSyntaxException Json deserialiser that assumes the values are complicated, and so need a more complex json element than just a string to deserialise. It is only ever necessary for subclasses to call one of these constructors.- Throws:
com.google.gson.JsonSyntaxException- See Also:
-
-
Method Details
-
toJson
public com.google.gson.JsonObject toJson()- Overrides:
toJsonin classFluidVolume
-
toMcBufferInternal
protected void toMcBufferInternal(net.minecraft.network.PacketByteBuf buffer) - Overrides:
toMcBufferInternalin classFluidVolume
-
fromMcBufferInternal
protected void fromMcBufferInternal(net.minecraft.network.PacketByteBuf buffer) - Overrides:
fromMcBufferInternalin classFluidVolume
-
normalize
protected final void normalize() -
toTag
public net.minecraft.nbt.NbtCompound toTag(net.minecraft.nbt.NbtCompound tag) - Overrides:
toTagin classFluidVolume
-
saveName
- Returns:
- The name to use when saving/loading the
valuesmap to/from disk. This is only used intoTag(NbtCompound),WeightedFluidVolume(WeightedFluidKey, NbtCompound),toJson(),WeightedFluidVolume(WeightedFluidKey, JsonObject, WeightedStringGetter), andWeightedFluidVolume(WeightedFluidKey, JsonObject, WeightedJsonGetter), so you can move things around before these are called.
-
defaultValue
- Returns:
- The default value to use if none is present.
-
readValue
Inverse ofwriteValue(NbtCompound, Object). -
writeValue
- Parameters:
holder- TheNbtCompoundto store the key in. Either "Amount" or "AmountF" might be overwritten by this class. (If in doubt it is better to use an embedded compound to store all of the data, using a key like "Name" or "Value").
-
areJsonValuesCompact
protected abstract boolean areJsonValuesCompact()- Returns:
- True if the weights should be serialised to json in "compact" form (where the value is serialised into a
single string, and read back with
WeightedFluidVolume.WeightedStringGetter), or "full" form (and read back withWeightedFluidVolume.WeightedJsonGetter).
-
toJson
- Returns:
- The value, turned into a
JsonElement. If the subclass callsWeightedFluidVolume(WeightedFluidKey, JsonObject, WeightedStringGetter)(and thus returns true fromareJsonValuesCompact()) then this must be aJsonPrimitivewith a string, that can read back with theWeightedFluidVolume.WeightedStringGetter. Otherwise there are no limits on what this can return, other than that theWeightedFluidVolume.WeightedJsonGettershould be able to read back the given value from the returned json.
-
writeValuesToMcBuffer
protected void writeValuesToMcBuffer(net.minecraft.network.PacketByteBuf buffer, Map<T, FluidAmount> map) -
readValuesFromMcBuffer
protected void readValuesFromMcBuffer(net.minecraft.network.PacketByteBuf buffer, Map<T, FluidAmount> map) -
readValueFromMcBuffer
-
writeValueToMcBuffer
-
getTextFor
-
getFluidKey
- Overrides:
getFluidKeyin classFluidVolume- Returns:
- The
FluidKeyfor this volume. Subclasses may override this to use a return type for their key class.
-
getValues
- Returns:
- An unmodifiable view of the values map.
-
copy0
- Overrides:
copy0in classFluidVolume
-
split0
- Overrides:
split0in classFluidVolume- Parameters:
toTake- A valid subtractable amount.- Returns:
- A new
FluidVolumewith the given amount that has been removed from this.
-
mergeInternal
Description copied from class:FluidVolumeActually merges twoFluidVolume's together. OnlyFluidVolume.merge(FluidVolume, FluidMergeRounding, Simulation)should call this. (Except for subclasses that override this method).- Overrides:
mergeInternalin classFluidVolume- Parameters:
vol- The other fluid volume. This will always be the same class as this. This should change the amount of the other fluid toFluidAmount.FluidMergeResult.excess.
-
addAmount
-
addAmount
-
addAmounts
-
getTooltipText
- Overrides:
getTooltipTextin classFluidVolume
-