Fixed storage GUIs overflowing on large numbers. Fixes #2098
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
- Increased the speed of autocrafting (raoulvdberge)
|
- Increased the speed of autocrafting (raoulvdberge)
|
||||||
- Fixed External Storage sending storage updates when it is disabled (raoulvdberge)
|
- Fixed External Storage sending storage updates when it is disabled (raoulvdberge)
|
||||||
- Fixed slight performance issue with loading Crafters from disk (raoulvdberge)
|
- Fixed slight performance issue with loading Crafters from disk (raoulvdberge)
|
||||||
|
- Fixed storage GUIs overflowing on large numbers (raoulvdberge)
|
||||||
- Added a completion percentage to the Crafting Monitor (raoulvdberge)
|
- Added a completion percentage to the Crafting Monitor (raoulvdberge)
|
||||||
- Updated Russian translation (kellixon)
|
- Updated Russian translation (kellixon)
|
||||||
|
|
||||||
|
@@ -16,6 +16,18 @@ public interface IQuantityFormatter {
|
|||||||
*/
|
*/
|
||||||
String formatWithUnits(int qty);
|
String formatWithUnits(int qty);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a quantity as they are formatted in the Grid.
|
||||||
|
* Formatted as following: "####0.#".
|
||||||
|
* <p>
|
||||||
|
* If the quantity is equal to or bigger than 1000 it will be displayed as the quantity divided by 1000 (without any decimals) and a "K" appended.
|
||||||
|
* If the quantity is equal to or bigger than 1000000 it will be displayed as the quantity divided by 1000000 (without any decimals) and a "M" appended.
|
||||||
|
*
|
||||||
|
* @param qty the quantity
|
||||||
|
* @return the formatted quantity
|
||||||
|
*/
|
||||||
|
String formatWithUnits(long qty);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a quantity as they are formatted on the disk tooltips.
|
* Formats a quantity as they are formatted on the disk tooltips.
|
||||||
* Formatted as following: "#,###".
|
* Formatted as following: "#,###".
|
||||||
@@ -25,6 +37,15 @@ public interface IQuantityFormatter {
|
|||||||
*/
|
*/
|
||||||
String format(int qty);
|
String format(int qty);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a quantity as they are formatted on the disk tooltips.
|
||||||
|
* Formatted as following: "#,###".
|
||||||
|
*
|
||||||
|
* @param qty the quantity
|
||||||
|
* @return the formatted quantity
|
||||||
|
*/
|
||||||
|
String format(long qty);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Divides quantity by 1000 and appends "B".
|
* Divides quantity by 1000 and appends "B".
|
||||||
*
|
*
|
||||||
|
@@ -18,7 +18,7 @@ public interface IGuiStorage {
|
|||||||
|
|
||||||
TileDataParameter<AccessType, ?> getAccessTypeParameter();
|
TileDataParameter<AccessType, ?> getAccessTypeParameter();
|
||||||
|
|
||||||
int getStored();
|
long getStored();
|
||||||
|
|
||||||
int getCapacity();
|
long getCapacity();
|
||||||
}
|
}
|
||||||
|
@@ -293,12 +293,12 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStored() {
|
public long getStored() {
|
||||||
return TileExternalStorage.STORED.getValue();
|
return TileExternalStorage.STORED.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity() {
|
public long getCapacity() {
|
||||||
return TileExternalStorage.CAPACITY.getValue();
|
return TileExternalStorage.CAPACITY.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -304,12 +304,12 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStored() {
|
public long getStored() {
|
||||||
return TileDiskDrive.STORED.getValue();
|
return TileDiskDrive.STORED.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity() {
|
public long getCapacity() {
|
||||||
return TileDiskDrive.CAPACITY.getValue();
|
return TileDiskDrive.CAPACITY.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -252,12 +252,12 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStored() {
|
public long getStored() {
|
||||||
return TileFluidStorage.STORED.getValue();
|
return TileFluidStorage.STORED.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity() {
|
public long getCapacity() {
|
||||||
return getType().getCapacity();
|
return getType().getCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -251,12 +251,12 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStored() {
|
public long getStored() {
|
||||||
return TileStorage.STORED.getValue();
|
return TileStorage.STORED.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity() {
|
public long getCapacity() {
|
||||||
return getType().getCapacity();
|
return getType().getCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,11 @@ public class QuantityFormatter implements IQuantityFormatter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String formatWithUnits(int qty) {
|
public String formatWithUnits(int qty) {
|
||||||
|
return formatWithUnits((long) qty);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String formatWithUnits(long qty) {
|
||||||
if (qty >= 1_000_000) {
|
if (qty >= 1_000_000) {
|
||||||
float qtyShort = (float) qty / 1_000_000F;
|
float qtyShort = (float) qty / 1_000_000F;
|
||||||
|
|
||||||
@@ -46,6 +51,11 @@ public class QuantityFormatter implements IQuantityFormatter {
|
|||||||
return formatter.format(qty);
|
return formatter.format(qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String format(long qty) {
|
||||||
|
return formatter.format(qty);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String formatInBucketForm(int qty) {
|
public String formatInBucketForm(int qty) {
|
||||||
return bucketFormatter.format((float) qty / (float) Fluid.BUCKET_VOLUME) + " B";
|
return bucketFormatter.format((float) qty / (float) Fluid.BUCKET_VOLUME) + " B";
|
||||||
|
@@ -5,9 +5,9 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.NetworkNodeDiskDrive;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.NetworkNodeDiskDrive;
|
||||||
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.*;
|
import com.raoulvdberge.refinedstorage.tile.config.*;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -23,8 +23,8 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
public static final TileDataParameter<Integer, TileDiskDrive> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer, TileDiskDrive> MODE = IFilterable.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileDiskDrive> TYPE = IType.createParameter();
|
public static final TileDataParameter<Integer, TileDiskDrive> TYPE = IType.createParameter();
|
||||||
public static final TileDataParameter<AccessType, TileDiskDrive> ACCESS_TYPE = IAccessType.createParameter();
|
public static final TileDataParameter<AccessType, TileDiskDrive> ACCESS_TYPE = IAccessType.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileDiskDrive> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
public static final TileDataParameter<Long, TileDiskDrive> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
|
||||||
int stored = 0;
|
long stored = 0;
|
||||||
|
|
||||||
for (IStorageDisk storage : t.getNode().getItemDisks()) {
|
for (IStorageDisk storage : t.getNode().getItemDisks()) {
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
@@ -40,13 +40,13 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
|
|
||||||
return stored;
|
return stored;
|
||||||
});
|
});
|
||||||
public static final TileDataParameter<Integer, TileDiskDrive> CAPACITY = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
public static final TileDataParameter<Long, TileDiskDrive> CAPACITY = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
|
||||||
int capacity = 0;
|
long capacity = 0;
|
||||||
|
|
||||||
for (IStorageDisk storage : t.getNode().getItemDisks()) {
|
for (IStorageDisk storage : t.getNode().getItemDisks()) {
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
if (storage.getCapacity() == -1) {
|
if (storage.getCapacity() == -1) {
|
||||||
return -1;
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
capacity += storage.getCapacity();
|
capacity += storage.getCapacity();
|
||||||
@@ -56,7 +56,7 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
for (IStorageDisk storage : t.getNode().getFluidDisks()) {
|
for (IStorageDisk storage : t.getNode().getFluidDisks()) {
|
||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
if (storage.getCapacity() == -1) {
|
if (storage.getCapacity() == -1) {
|
||||||
return -1;
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
capacity += storage.getCapacity();
|
capacity += storage.getCapacity();
|
||||||
|
@@ -4,9 +4,9 @@ import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.*;
|
import com.raoulvdberge.refinedstorage.tile.config.*;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
@@ -19,8 +19,8 @@ public class TileExternalStorage extends TileNode<NetworkNodeExternalStorage> {
|
|||||||
public static final TileDataParameter<Integer, TileExternalStorage> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer, TileExternalStorage> MODE = IFilterable.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileExternalStorage> TYPE = IType.createParameter();
|
public static final TileDataParameter<Integer, TileExternalStorage> TYPE = IType.createParameter();
|
||||||
public static final TileDataParameter<AccessType, TileExternalStorage> ACCESS_TYPE = IAccessType.createParameter();
|
public static final TileDataParameter<AccessType, TileExternalStorage> ACCESS_TYPE = IAccessType.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileExternalStorage> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
public static final TileDataParameter<Long, TileExternalStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
|
||||||
int stored = 0;
|
long stored = 0;
|
||||||
|
|
||||||
for (IStorageExternal<ItemStack> storage : t.getNode().getItemStorages()) {
|
for (IStorageExternal<ItemStack> storage : t.getNode().getItemStorages()) {
|
||||||
stored += storage.getStored();
|
stored += storage.getStored();
|
||||||
@@ -32,8 +32,8 @@ public class TileExternalStorage extends TileNode<NetworkNodeExternalStorage> {
|
|||||||
|
|
||||||
return stored;
|
return stored;
|
||||||
});
|
});
|
||||||
public static final TileDataParameter<Integer, TileExternalStorage> CAPACITY = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
public static final TileDataParameter<Long, TileExternalStorage> CAPACITY = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> {
|
||||||
int capacity = 0;
|
long capacity = 0;
|
||||||
|
|
||||||
for (IStorageExternal<ItemStack> storage : t.getNode().getItemStorages()) {
|
for (IStorageExternal<ItemStack> storage : t.getNode().getItemStorages()) {
|
||||||
capacity += storage.getCapacity();
|
capacity += storage.getCapacity();
|
||||||
|
@@ -6,8 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.config.IAccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
|
import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ public class TileFluidStorage extends TileNode<NetworkNodeFluidStorage> {
|
|||||||
public static final TileDataParameter<Integer, TileFluidStorage> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer, TileFluidStorage> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileFluidStorage> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer, TileFluidStorage> MODE = IFilterable.createParameter();
|
||||||
public static final TileDataParameter<AccessType, TileFluidStorage> ACCESS_TYPE = IAccessType.createParameter();
|
public static final TileDataParameter<AccessType, TileFluidStorage> ACCESS_TYPE = IAccessType.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileFluidStorage> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getStorage().getStored());
|
public static final TileDataParameter<Long, TileFluidStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> (long) t.getNode().getStorage().getStored());
|
||||||
|
|
||||||
public TileFluidStorage() {
|
public TileFluidStorage() {
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
|
@@ -6,8 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.config.IAccessType;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
|
import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ public class TileStorage extends TileNode<NetworkNodeStorage> {
|
|||||||
public static final TileDataParameter<Integer, TileStorage> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer, TileStorage> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileStorage> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer, TileStorage> MODE = IFilterable.createParameter();
|
||||||
public static final TileDataParameter<AccessType, TileStorage> ACCESS_TYPE = IAccessType.createParameter();
|
public static final TileDataParameter<AccessType, TileStorage> ACCESS_TYPE = IAccessType.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileStorage> STORED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getStorage().getStored());
|
public static final TileDataParameter<Long, TileStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> (long) t.getNode().getStorage().getStored());
|
||||||
|
|
||||||
public TileStorage() {
|
public TileStorage() {
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
|
@@ -109,4 +109,26 @@ public final class RSSerializers {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final DataSerializer<Long> LONG_SERIALIZER = new DataSerializer<Long>() {
|
||||||
|
@Override
|
||||||
|
public void write(PacketBuffer buf, Long value) {
|
||||||
|
buf.writeLong(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long read(PacketBuffer buf) throws IOException {
|
||||||
|
return buf.readLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataParameter<Long> createKey(int id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long copyValue(Long value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user