make the controller great again

This commit is contained in:
Raoul Van den Berge
2015-12-23 15:54:53 +01:00
parent 7574747c46
commit 532574a1b8
15 changed files with 35 additions and 22 deletions

View File

@@ -11,6 +11,8 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import storagecraft.item.ItemStorageCell;
import storagecraft.proxy.CommonProxy; import storagecraft.proxy.CommonProxy;
@Mod(modid = StorageCraft.ID, version = StorageCraft.VERSION) @Mod(modid = StorageCraft.ID, version = StorageCraft.VERSION)
@@ -33,10 +35,16 @@ public class StorageCraft
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID); public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID);
public static final CreativeTabs TAB = new CreativeTabs(ID) public static final CreativeTabs TAB = new CreativeTabs(ID)
{ {
@Override
public ItemStack getIconItemStack()
{
return new ItemStack(StorageCraftItems.STORAGE_CELL, 1, ItemStorageCell.TYPE_1K);
}
@Override @Override
public Item getTabIconItem() public Item getTabIconItem()
{ {
return Item.getItemFromBlock(StorageCraftBlocks.CONTROLLER); return null;
} }
}; };
@SidedProxy(clientSide = "storagecraft.proxy.ClientProxy", serverSide = "storagecraft.proxy.ServerProxy") @SidedProxy(clientSide = "storagecraft.proxy.ClientProxy", serverSide = "storagecraft.proxy.ServerProxy")

View File

@@ -13,7 +13,7 @@ import storagecraft.tile.TileController;
public class BlockController extends BlockBase implements ITileEntityProvider public class BlockController extends BlockBase implements ITileEntityProvider
{ {
private IIcon sideIcon; private IIcon sideIcon;
private IIcon[] icons = new IIcon[8]; private IIcon[] icons = new IIcon[9];
public BlockController() public BlockController()
{ {
@@ -48,7 +48,7 @@ public class BlockController extends BlockBase implements ITileEntityProvider
@Override @Override
public void registerBlockIcons(IIconRegister register) public void registerBlockIcons(IIconRegister register)
{ {
for (int i = 0; i <= 7; ++i) for (int i = 0; i <= 8; ++i)
{ {
icons[i] = register.registerIcon("storagecraft:controller" + i); icons[i] = register.registerIcon("storagecraft:controller" + i);
} }
@@ -59,24 +59,24 @@ public class BlockController extends BlockBase implements ITileEntityProvider
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{ {
if (side == 0 || side == 1) TileController tile = (TileController) world.getTileEntity(x, y, z);
if (side == tile.getDirection().ordinal())
{ {
return sideIcon; return icons[(int) ((float) tile.getEnergyStored(null) / (float) tile.getMaxEnergyStored(null) * 8f)];
} }
TileController controller = (TileController) world.getTileEntity(x, y, z); return sideIcon;
return icons[(int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * 7f)];
} }
@Override @Override
public IIcon getIcon(int side, int meta) public IIcon getIcon(int side, int meta)
{ {
if (side == 0 || side == 1) if (side == 3)
{ {
return sideIcon;
}
return icons[0]; return icons[0];
} }
return sideIcon;
}
} }

View File

@@ -8,6 +8,6 @@ public class ContainerController extends ContainerBase
{ {
super(player); super(player);
addPlayerInventory(8, 108); addPlayerInventory(8, 99);
} }
} }

View File

@@ -8,9 +8,14 @@ public class GuiController extends GuiBase
{ {
private TileController controller; private TileController controller;
private int barX = 8;
private int barY = 20;
private int barWidth = 16;
private int barHeight = 58;
public GuiController(ContainerController container, TileController controller) public GuiController(ContainerController container, TileController controller)
{ {
super(container, 176, 190); super(container, 176, 181);
this.controller = controller; this.controller = controller;
} }
@@ -33,23 +38,22 @@ public class GuiController extends GuiBase
drawTexturedModalRect(x, y, 0, 0, xSize, ySize); drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
int barX = 17;
int barY = 25;
int barWidth = 16;
int barHeight = 58;
int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight); int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight);
drawTexturedModalRect(x + barX, y + barY + barHeight - barHeightNew, 178, 0, barWidth, barHeightNew); drawTexturedModalRect(x + barX, y + barY + barHeight - barHeightNew, 178, 0 + (barHeight - barHeightNew), barWidth, barHeightNew);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY)
{ {
drawString(7, 7, t("gui.storagecraft:controller")); drawString(7, 7, t("gui.storagecraft:controller"));
drawString(7, 96, t("container.inventory")); drawString(7, 87, t("container.inventory"));
drawString(45, 24, t("misc.storagecraft:energyStored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null))); drawString(31, 20, t("misc.storagecraft:energyUsage", controller.getEnergyUsage()));
drawString(45, 44, t("misc.storagecraft:energyUsage", controller.getEnergyUsage()));
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY))
{
drawTooltip(mouseX, mouseY, t("misc.storagecraft:energyStored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null)));
}
} }
} }

View File

@@ -119,6 +119,7 @@ public class GuiGrid extends GuiBase
public boolean isHoveringOverClear(int mouseX, int mouseY) public boolean isHoveringOverClear(int mouseX, int mouseY)
{ {
// @TODO: Use inBounds
return mouseX >= 81 && mouseX <= 87 && mouseY >= 105 && mouseY <= 111; return mouseX >= 81 && mouseX <= 87 && mouseY >= 105 && mouseY <= 111;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB