use of net.minecraft.item.ItemStack in project BluePower by Qmunity.
the class ItemStackUtils method isSameOreDictStack.
public static boolean isSameOreDictStack(ItemStack stack1, ItemStack stack2) {
int[] ids = OreDictionary.getOreIDs(stack1);
for (int id : ids) {
String name = OreDictionary.getOreName(id);
List<ItemStack> oreDictStacks = OreDictionary.getOres(name);
for (ItemStack oreDictStack : oreDictStacks) {
if (OreDictionary.itemMatches(stack2, oreDictStack, false)) {
return true;
}
}
}
return false;
}
use of net.minecraft.item.ItemStack in project LogisticsPipes by RS485.
the class GuiStatistics method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouse_x, int mouse_y) {
GL11.glColor4d(1.0D, 1.0D, 1.0D, 1.0D);
for (int i = 0; i < TAB_COUNT; i++) {
GuiGraphics.drawGuiBackGround(mc, guiLeft + (25 * i) + 2, guiTop - 2, guiLeft + 27 + (25 * i), guiTop + 35, zLevel, false, true, true, false, true);
}
GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop + 20, right, bottom, zLevel, true);
GuiGraphics.drawGuiBackGround(mc, guiLeft + (25 * current_Tab) + 2, guiTop - 2, guiLeft + 27 + (25 * current_Tab), guiTop + 38, zLevel, true, true, true, false, true);
// First Tab
GuiGraphics.drawStatsBackground(mc, guiLeft + 6, guiTop + 3);
// Second Tab
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableGUIStandardItemLighting();
ItemStack stack = new ItemStack(Blocks.crafting_table, 0);
GuiScreen.itemRender.renderItemAndEffectIntoGUI(fontRendererObj, getMC().renderEngine, stack, guiLeft + 31, guiTop + 3);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GuiScreen.itemRender.zLevel = 0.0F;
if (current_Tab == 0) {
itemDisplay_1.renderItemArea(zLevel);
itemDisplay_1.renderPageNumber(right - 40, guiTop + 28);
if (itemDisplay_1.getSelectedItem() != null) {
TrackingTask task = null;
for (TrackingTask taskLoop : tile.tasks) {
if (taskLoop.item == itemDisplay_1.getSelectedItem().getItem()) {
task = taskLoop;
break;
}
}
if (task != null) {
GuiGraphics.drawSlotBackground(mc, guiLeft + 10, guiTop + 99);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableGUIStandardItemLighting();
GuiScreen.itemRender.renderItemAndEffectIntoGUI(fontRendererObj, getMC().renderEngine, task.item.makeNormalStack(1), guiLeft + 11, guiTop + 100);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GuiScreen.itemRender.zLevel = 0.0F;
mc.fontRenderer.drawString(StringUtils.getWithMaxWidth(task.item.getFriendlyName(), 136, fontRendererObj), guiLeft + 32, guiTop + 104, Color.getValue(Color.DARKER_GREY), false);
int xOrigo = xCenter - 68;
int yOrigo = yCenter + 90;
drawLine(xOrigo, yOrigo, xOrigo + 150, yOrigo, Color.DARKER_GREY);
drawLine(xOrigo, yOrigo, xOrigo, yOrigo - 80, Color.DARKER_GREY);
for (int k = -4; k < 5; k++) {
int begin = -4;
if (k == -4) {
begin = -1;
}
if (k == 0) {
begin = -1;
}
if (k == 4) {
begin = -1;
}
drawLine(xOrigo + begin, yCenter + 50 + k * 10, xOrigo + 5, yCenter + 50 + k * 10, Color.DARKER_GREY);
}
for (int k = 0; k < 16; k++) {
drawLine(xOrigo + k * 10, yOrigo - 4, xOrigo + k * 10, yOrigo + 4, Color.DARKER_GREY);
}
int time_left = 15 + move_left * 15;
int time_right = move_left * 15;
String right = "";
String left = "";
if (time_right == 0) {
right = "Now";
} else {
if (time_right / 60 != 0) {
right += (time_right / 60) + "h";
}
if (time_right % 60 != 0) {
right += (time_right % 60) + "min";
}
}
if (time_left / 60 != 0) {
left += (time_left / 60) + "h";
}
if (time_left % 60 != 0) {
left += (time_left % 60) + "min";
}
fontRendererObj.drawString(left, xOrigo - 12, yOrigo + 6, 0x404040);
fontRendererObj.drawString(right, xOrigo + 153 - fontRendererObj.getStringWidth(right), yOrigo + 6, 0x404040);
long[] data = new long[task.amountRecorded.length];
int pos = 0;
for (int i = task.arrayPos - 1; i >= 0; i--) {
data[pos++] = task.amountRecorded[i];
}
for (int i = task.amountRecorded.length - 1; i >= task.arrayPos; i--) {
data[pos++] = task.amountRecorded[i];
}
long lowest = Long.MAX_VALUE;
long highest = Long.MIN_VALUE;
int first = (15 * move_left);
for (int i = first; i <= first + 15 && i < data.length; i++) {
long point = data[i];
if (point > highest) {
highest = point;
}
if (point < lowest) {
lowest = point;
}
}
double averagey = ((double) highest + lowest) / 2;
fontRendererObj.drawString(StringUtils.getFormatedStackSize(highest, false), xOrigo - 1 - fontRendererObj.getStringWidth(StringUtils.getFormatedStackSize(highest, false)), guiTop + 117, 0x404040);
fontRendererObj.drawString(StringUtils.getFormatedStackSize((long) averagey, false), xOrigo - 1 - fontRendererObj.getStringWidth(StringUtils.getFormatedStackSize((long) averagey, false)), yCenter + 46, 0x404040);
fontRendererObj.drawString(StringUtils.getFormatedStackSize(lowest, false), xOrigo - 1 - fontRendererObj.getStringWidth(StringUtils.getFormatedStackSize(lowest, false)), bottom - 23, 0x404040);
float yScale = 80F / Math.max(highest - lowest, 0.5F);
int x = xOrigo + 150;
double yOff = data[first] - averagey;
int y = (yOrigo - 80 / 2) - (int) (yOff * yScale);
for (int i = first + 1; i < data.length; i++) {
long point = data[i];
int x1 = x - 10;
if (x1 < guiLeft + 15) {
break;
}
yOff = point - averagey;
int y1 = (yOrigo - 80 / 2) - (int) (yOff * yScale);
drawLine(x1, y1, x, y, Color.RED);
drawRect(x - 1, y - 1, x + 2, y + 2, Color.BLACK);
x = x1;
y = y1;
}
drawRect(x - 1, y - 1, x + 2, y + 2, Color.BLACK);
}
}
} else if (current_Tab == 1) {
itemDisplay_2.renderItemArea(zLevel);
itemDisplay_2.renderPageNumber(right - 50, guiTop + 66);
}
super.drawGuiContainerBackgroundLayer(f, mouse_x, mouse_y);
}
use of net.minecraft.item.ItemStack in project LogisticsPipes by RS485.
the class GuiChassiPipe method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
for (int i = 0; i < _chassiPipe.getChassiSize(); i++) {
ItemStack module = _moduleInventory.getStackInSlot(i);
if (module == null || _chassiPipe.getLogisticsModule().getSubModule(i) == null) {
((SmallGuiButton) buttonList.get(i)).visible = false;
} else {
((SmallGuiButton) buttonList.get(i)).visible = _chassiPipe.getLogisticsModule().getSubModule(i).hasGui();
}
}
if (_chassiPipe.getChassiSize() > 0) {
mc.fontRenderer.drawString(getModuleName(0), 40, 14, 0x404040);
}
if (_chassiPipe.getChassiSize() > 1) {
mc.fontRenderer.drawString(getModuleName(1), 40, 34, 0x404040);
}
if (_chassiPipe.getChassiSize() > 2) {
mc.fontRenderer.drawString(getModuleName(2), 40, 54, 0x404040);
}
if (_chassiPipe.getChassiSize() > 3) {
mc.fontRenderer.drawString(getModuleName(3), 40, 74, 0x404040);
}
if (_chassiPipe.getChassiSize() > 4) {
mc.fontRenderer.drawString(getModuleName(4), 40, 94, 0x404040);
mc.fontRenderer.drawString(getModuleName(5), 40, 114, 0x404040);
mc.fontRenderer.drawString(getModuleName(6), 40, 134, 0x404040);
mc.fontRenderer.drawString(getModuleName(7), 40, 154, 0x404040);
}
}
use of net.minecraft.item.ItemStack in project LogisticsPipes by RS485.
the class GuiChassiPipe method initGui.
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
left = width / 2 - xSize / 2;
top = height / 2 - ySize / 2;
buttonList.clear();
for (int i = 0; i < _chassiPipe.getChassiSize(); i++) {
buttonList.add(new SmallGuiButton(i, left + 5, top + 12 + 20 * i, 10, 10, "!"));
if (_moduleInventory == null) {
continue;
}
ItemStack module = _moduleInventory.getStackInSlot(i);
if (module == null || _chassiPipe.getLogisticsModule().getSubModule(i) == null) {
((SmallGuiButton) buttonList.get(i)).visible = false;
} else {
((SmallGuiButton) buttonList.get(i)).visible = _chassiPipe.getLogisticsModule().getSubModule(i).hasGui();
}
}
}
use of net.minecraft.item.ItemStack in project LogisticsPipes by RS485.
the class ModuleAdvancedExtractor method checkExtract.
private void checkExtract(IInventoryUtil invUtil) {
Map<ItemIdentifier, Integer> items = invUtil.getItemsAndCount();
for (Entry<ItemIdentifier, Integer> item : items.entrySet()) {
if (!CanExtract(item.getKey().makeNormalStack(item.getValue()))) {
continue;
}
List<Integer> jamList = new LinkedList<>();
Pair<Integer, SinkReply> reply = _service.hasDestination(item.getKey(), true, jamList);
if (reply == null) {
continue;
}
int itemsleft = itemsToExtract();
while (reply != null) {
int count = Math.min(itemsleft, item.getValue());
count = Math.min(count, item.getKey().getMaxStackSize());
if (reply.getValue2().maxNumberOfItems > 0) {
count = Math.min(count, reply.getValue2().maxNumberOfItems);
}
while (!_service.useEnergy(neededEnergy() * count) && count > 0) {
_service.spawnParticle(Particles.OrangeParticle, 2);
count--;
}
if (count <= 0) {
break;
}
ItemStack stackToSend = invUtil.getMultipleItems(item.getKey(), count);
if (stackToSend == null || stackToSend.stackSize == 0) {
break;
}
count = stackToSend.stackSize;
_service.sendStack(stackToSend, reply, itemSendMode());
itemsleft -= count;
if (itemsleft <= 0) {
break;
}
jamList.add(reply.getValue1());
reply = _service.hasDestination(item.getKey(), true, jamList);
}
return;
}
}
Aggregations