Code style fixes
This commit is contained in:
@@ -111,85 +111,86 @@ public class GuiGrid extends GuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public void drawForeground(int mouseX, int mouseY) {
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
scrollbar.update(this, mouseX, mouseY);
|
scrollbar.update(this, mouseX, mouseY);
|
||||||
synchronized (grid.getController()) {
|
|
||||||
drawString(7, 7, t("gui.refinedstorage:grid"));
|
|
||||||
|
|
||||||
if (grid.getType() == EnumGridType.CRAFTING) {
|
synchronized (grid.getController()) {
|
||||||
drawString(7, 94, t("container.crafting"));
|
drawString(7, 7, t("gui.refinedstorage:grid"));
|
||||||
}
|
|
||||||
|
|
||||||
drawString(7, grid.getType() == EnumGridType.CRAFTING ? 163 : 113, t("container.inventory"));
|
if (grid.getType() == EnumGridType.CRAFTING) {
|
||||||
|
drawString(7, 94, t("container.crafting"));
|
||||||
int x = 8;
|
|
||||||
int y = 20;
|
|
||||||
|
|
||||||
List<StorageItem> items = getItems();
|
|
||||||
|
|
||||||
hoveringSlotId = -1;
|
|
||||||
|
|
||||||
int slot = getOffset() * 9;
|
|
||||||
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
|
||||||
|
|
||||||
for (int i = 0; i < 9 * getVisibleRows(); ++i) {
|
|
||||||
if (slot < items.size()) {
|
|
||||||
int qty = items.get(slot).getQuantity();
|
|
||||||
|
|
||||||
String text;
|
|
||||||
|
|
||||||
if (qty >= 1000000) {
|
|
||||||
text = String.format("%.1f", (float) qty / 1000000).replace(",", ".").replace(".0", "") + "M";
|
|
||||||
} else if (qty >= 1000) {
|
|
||||||
text = String.format("%.1f", (float) qty / 1000).replace(",", ".").replace(".0", "") + "K";
|
|
||||||
} else if (qty == 1) {
|
|
||||||
text = null;
|
|
||||||
} else {
|
|
||||||
text = String.valueOf(qty);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawItem(x, y, items.get(slot).toItemStack(), true, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
drawString(7, grid.getType() == EnumGridType.CRAFTING ? 163 : 113, t("container.inventory"));
|
||||||
hoveringSlotId = slot;
|
|
||||||
|
|
||||||
|
int x = 8;
|
||||||
|
int y = 20;
|
||||||
|
|
||||||
|
List<StorageItem> items = getItems();
|
||||||
|
|
||||||
|
hoveringSlotId = -1;
|
||||||
|
|
||||||
|
int slot = getOffset() * 9;
|
||||||
|
|
||||||
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
|
||||||
|
for (int i = 0; i < 9 * getVisibleRows(); ++i) {
|
||||||
if (slot < items.size()) {
|
if (slot < items.size()) {
|
||||||
// We need to use the ID, because if we filter, the client-side index will change
|
int qty = items.get(slot).getQuantity();
|
||||||
// while the serverside's index will still be the same.
|
|
||||||
hoveringId = items.get(slot).getId();
|
String text;
|
||||||
|
|
||||||
|
if (qty >= 1000000) {
|
||||||
|
text = String.format("%.1f", (float) qty / 1000000).replace(",", ".").replace(".0", "") + "M";
|
||||||
|
} else if (qty >= 1000) {
|
||||||
|
text = String.format("%.1f", (float) qty / 1000).replace(",", ".").replace(".0", "") + "K";
|
||||||
|
} else if (qty == 1) {
|
||||||
|
text = null;
|
||||||
|
} else {
|
||||||
|
text = String.valueOf(qty);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawItem(x, y, items.get(slot).toItemStack(), true, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
int color = grid.isConnected() ? -2130706433 : 0xFF5B5B5B;
|
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
||||||
|
hoveringSlotId = slot;
|
||||||
|
|
||||||
GlStateManager.disableLighting();
|
if (slot < items.size()) {
|
||||||
GlStateManager.disableDepth();
|
// We need to use the ID, because if we filter, the client-side index will change
|
||||||
zLevel = 190;
|
// while the serverside's index will still be the same.
|
||||||
GlStateManager.colorMask(true, true, true, false);
|
hoveringId = items.get(slot).getId();
|
||||||
drawGradientRect(x, y, x + 16, y + 16, color, color);
|
}
|
||||||
zLevel = 0;
|
|
||||||
GlStateManager.colorMask(true, true, true, true);
|
int color = grid.isConnected() ? -2130706433 : 0xFF5B5B5B;
|
||||||
GlStateManager.enableLighting();
|
|
||||||
GlStateManager.enableDepth();
|
GlStateManager.disableLighting();
|
||||||
|
GlStateManager.disableDepth();
|
||||||
|
zLevel = 190;
|
||||||
|
GlStateManager.colorMask(true, true, true, false);
|
||||||
|
drawGradientRect(x, y, x + 16, y + 16, color, color);
|
||||||
|
zLevel = 0;
|
||||||
|
GlStateManager.colorMask(true, true, true, true);
|
||||||
|
GlStateManager.enableLighting();
|
||||||
|
GlStateManager.enableDepth();
|
||||||
|
}
|
||||||
|
|
||||||
|
slot++;
|
||||||
|
|
||||||
|
x += 18;
|
||||||
|
|
||||||
|
if ((i + 1) % 9 == 0) {
|
||||||
|
x = 8;
|
||||||
|
y += 18;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
if (isHoveringOverValidSlot(items)) {
|
||||||
|
drawTooltip(mouseX, mouseY, items.get(hoveringSlotId).toItemStack());
|
||||||
|
}
|
||||||
|
|
||||||
x += 18;
|
if (isHoveringOverClear(mouseX, mouseY)) {
|
||||||
|
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
|
||||||
if ((i + 1) % 9 == 0) {
|
|
||||||
x = 8;
|
|
||||||
y += 18;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHoveringOverValidSlot(items)) {
|
|
||||||
drawTooltip(mouseX, mouseY, items.get(hoveringSlotId).toItemStack());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isHoveringOverClear(mouseX, mouseY)) {
|
|
||||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StorageItem> getItems() {
|
public List<StorageItem> getItems() {
|
||||||
|
@@ -49,16 +49,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
|||||||
if (!worldObj.isRemote) {
|
if (!worldObj.isRemote) {
|
||||||
int lastEnergy = energy.getEnergyStored();
|
int lastEnergy = energy.getEnergyStored();
|
||||||
|
|
||||||
if(isActive())
|
|
||||||
switch (getType()) {
|
|
||||||
case NORMAL:
|
|
||||||
energy.extractEnergy(energyUsage, false);
|
|
||||||
break;
|
|
||||||
case CREATIVE:
|
|
||||||
energy.setEnergyStored(energy.getMaxEnergyStored());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ticks % 20 == 0) {
|
if (ticks % 20 == 0) {
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
disconnectAll();
|
disconnectAll();
|
||||||
@@ -108,11 +98,22 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
|||||||
energyUsage += machine.getEnergyUsage();
|
energyUsage += machine.getEnergyUsage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lastEnergy != energy.getEnergyStored()) {
|
if (isActive()) {
|
||||||
worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
|
switch (getType()) {
|
||||||
|
case NORMAL:
|
||||||
|
energy.extractEnergy(energyUsage, false);
|
||||||
|
break;
|
||||||
|
case CREATIVE:
|
||||||
|
energy.setEnergyStored(energy.getMaxEnergyStored());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastEnergy != energy.getEnergyStored()) {
|
||||||
|
worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,8 +5,6 @@ import net.minecraft.inventory.IInventory;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.inventory.InventorySimple;
|
import refinedstorage.inventory.InventorySimple;
|
||||||
@@ -163,7 +161,10 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TileEntity getConnectedTile() {
|
public TileEntity getConnectedTile() {
|
||||||
if(worldObj == null) return null;
|
if (worldObj == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
||||||
|
|
||||||
if (tile instanceof IInventory || tile instanceof IDeepStorageUnit) {
|
if (tile instanceof IInventory || tile instanceof IDeepStorageUnit) {
|
||||||
|
@@ -42,7 +42,7 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if(worldObj == null) {
|
if (worldObj == null) {
|
||||||
super.update();
|
super.update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user