Fix disk drive crash

This commit is contained in:
Raoul Van den Berge
2016-08-24 01:46:26 +02:00
parent 59d5f95063
commit 97166cb252
5 changed files with 29 additions and 37 deletions

View File

@@ -15,7 +15,6 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui; import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDiskDrive; import refinedstorage.tile.TileDiskDrive;
// @TODO: Fix bug where it doesn't display correctly
public class BlockDiskDrive extends BlockNode { public class BlockDiskDrive extends BlockNode {
private static final PropertyInteger STORED = PropertyInteger.create("stored", 0, 7); private static final PropertyInteger STORED = PropertyInteger.create("stored", 0, 7);

View File

@@ -38,10 +38,6 @@ public enum EnumFluidStorageType implements IStringSerializable {
} }
public static EnumFluidStorageType getById(int id) { public static EnumFluidStorageType getById(int id) {
if (id == 5) {
return TYPE_CREATIVE;
}
for (EnumFluidStorageType type : EnumFluidStorageType.values()) { for (EnumFluidStorageType type : EnumFluidStorageType.values()) {
if (type.getId() == id) { if (type.getId() == id) {
return type; return type;

View File

@@ -38,10 +38,6 @@ public enum EnumItemStorageType implements IStringSerializable {
} }
public static EnumItemStorageType getById(int id) { public static EnumItemStorageType getById(int id) {
if (id == 5) {
return TYPE_CREATIVE;
}
for (EnumItemStorageType type : EnumItemStorageType.values()) { for (EnumItemStorageType type : EnumItemStorageType.values()) {
if (type.getId() == id) { if (type.getId() == id) {
return type; return type;

View File

@@ -159,8 +159,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
@Override @Override
public void update() { public void update() {
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (stored != getStoredForDisplayServer()) { if (stored != getStoredForDisplay()) {
stored = getStoredForDisplayServer(); stored = getStoredForDisplay();
updateBlock(); updateBlock();
} }
@@ -317,7 +317,8 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
markDirty(); markDirty();
} }
public int getStoredForDisplayServer() { public int getStoredForDisplay() {
if (!worldObj.isRemote) {
float stored = 0; float stored = 0;
float capacity = 0; float capacity = 0;
@@ -327,7 +328,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
if (disk != null) { if (disk != null) {
int diskCapacity = disk.getItem() == RefinedStorageItems.STORAGE_DISK ? EnumItemStorageType.getById(disk.getItemDamage()).getCapacity() : EnumFluidStorageType.getById(disk.getItemDamage()).getCapacity(); int diskCapacity = disk.getItem() == RefinedStorageItems.STORAGE_DISK ? EnumItemStorageType.getById(disk.getItemDamage()).getCapacity() : EnumFluidStorageType.getById(disk.getItemDamage()).getCapacity();
if (capacity == -1) { if (diskCapacity == -1) {
return 0; return 0;
} }
@@ -343,7 +344,6 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
return (int) Math.floor((stored / capacity) * 7F); return (int) Math.floor((stored / capacity) * 7F);
} }
public int getStoredForDisplay() {
return stored; return stored;
} }

View File

@@ -24,6 +24,7 @@ public interface IType {
if (value == 0 || value == 1) { if (value == 0 || value == 1) {
((IType) tile).setType(value); ((IType) tile).setType(value);
// @TODO: This doesn't work serverside
tile.getWorld().playerEntities.stream() tile.getWorld().playerEntities.stream()
.filter(p -> p.openContainer instanceof ContainerBase && ((ContainerBase) p.openContainer).getTile().getPos().equals(tile.getPos())) .filter(p -> p.openContainer instanceof ContainerBase && ((ContainerBase) p.openContainer).getTile().getPos().equals(tile.getPos()))
.forEach(p -> p.openContainer.detectAndSendChanges()); .forEach(p -> p.openContainer.detectAndSendChanges());