Code improvements

This commit is contained in:
Raoul Van den Berge
2016-06-05 20:13:38 +02:00
parent 58028ffafc
commit 82c74f82b4
4 changed files with 13 additions and 16 deletions

View File

@@ -170,21 +170,18 @@ public class GuiGrid extends GuiBase {
} }
public boolean isHoveringOverClear(int mouseX, int mouseY) { public boolean isHoveringOverClear(int mouseX, int mouseY) {
if (grid.getType() == EnumGridType.CRAFTING) { switch (grid.getType()) {
return inBounds(81, 105, 7, 7, mouseX, mouseY); case CRAFTING:
} else if (grid.getType() == EnumGridType.PATTERN) { return inBounds(81, 105, 7, 7, mouseX, mouseY);
return inBounds(64, 105, 7, 7, mouseX, mouseY); case PATTERN:
return inBounds(64, 105, 7, 7, mouseX, mouseY);
default:
return false;
} }
return false;
} }
public boolean isHoveringOverCreatePattern(int mouseX, int mouseY) { public boolean isHoveringOverCreatePattern(int mouseX, int mouseY) {
if (grid.getType() == EnumGridType.PATTERN) { return grid.getType() == EnumGridType.PATTERN && inBounds(152, 124, 16, 16, mouseX, mouseY) && ((TileGrid) grid).mayCreatePattern();
return inBounds(152, 124, 16, 16, mouseX, mouseY) && ((TileGrid) grid).mayCreatePattern();
}
return false;
} }
@Override @Override
@@ -297,9 +294,9 @@ public class GuiGrid extends GuiBase {
} }
if (qty >= 1000000) { if (qty >= 1000000) {
return String.format("%.1f", (float) qty / 1000000).replace(",", ".").replace(".0", "") + "M"; return String.format(Locale.US, "%.1f", Math.floor(qty / 1000000)).replace(".0", "") + "M";
} else if (qty >= 1000) { } else if (qty >= 1000) {
return String.format("%.1f", (float) qty / 1000).replace(",", ".").replace(".0", "") + "K"; return String.format(Locale.US, "%.1f", Math.floor(qty / 1000)).replace(".0", "") + "K";
} else if (qty == 1) { } else if (qty == 1) {
return null; return null;
} else if (qty == 0) { } else if (qty == 0) {

View File

@@ -1,6 +1,6 @@
package refinedstorage.tile.config; package refinedstorage.tile.config;
public class ModeConstants { public final class ModeConstants {
public static final int WHITELIST = 0; public static final int WHITELIST = 0;
public static final int BLACKLIST = 1; public static final int BLACKLIST = 1;
} }

View File

@@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import refinedstorage.RefinedStorageUtils; import refinedstorage.RefinedStorageUtils;
public class ModeFilter { public final class ModeFilter {
public static boolean respectsMode(IItemHandler filters, IModeConfig mode, int compare, ItemStack stack) { public static boolean respectsMode(IItemHandler filters, IModeConfig mode, int compare, ItemStack stack) {
if (mode.getMode() == ModeConstants.WHITELIST) { if (mode.getMode() == ModeConstants.WHITELIST) {
int slots = 0; int slots = 0;

View File

@@ -9,7 +9,7 @@ import refinedstorage.tile.TileRelay;
import java.util.Set; import java.util.Set;
public class ControllerSearcher { public final class ControllerSearcher {
public static TileController search(World world, BlockPos current, Set<String> visited) { public static TileController search(World world, BlockPos current, Set<String> visited) {
if (visited.contains(current.getX() + "," + current.getY() + "," + current.getZ())) { if (visited.contains(current.getX() + "," + current.getY() + "," + current.getZ())) {
return null; return null;