Crafter fixes

This commit is contained in:
Raoul Van den Berge
2016-04-28 22:24:11 +02:00
parent f861b776e2
commit a2e2a3a95e
2 changed files with 46 additions and 0 deletions

View File

@@ -1,7 +1,11 @@
package refinedstorage.gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import refinedstorage.container.ContainerCrafter;
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
import refinedstorage.item.ItemPattern;
import refinedstorage.tile.TileCrafter;
public class GuiCrafter extends GuiBase {
@@ -29,9 +33,35 @@ public class GuiCrafter extends GuiBase {
drawTexture(x, y, 0, 0, width, height);
}
private int calculateOffsetOnScale(int pos, float scale) {
float multiplier = (pos / scale);
return (int) multiplier;
}
@Override
public void drawForeground(int mouseX, int mouseY) {
drawString(7, 7, t("gui.refinedstorage:crafter"));
drawString(7, 77, t("container.inventory"));
RenderHelper.enableGUIStandardItemLighting();
for (int i = 0; i < 6; ++i) {
int x = i >= 3 ? 109 : 27;
int y = 19 + ((i - (i >= 3 ? 3 : 0)) * 18);
if (crafter.getStackInSlot(i) != null) {
ItemStack result = ItemPattern.getResult(crafter.getStackInSlot(i));
drawItem(x, y, result);
GlStateManager.pushMatrix();
float scale = 0.5f;
GlStateManager.scale(scale, scale, 1);
drawString(calculateOffsetOnScale(x + 20, scale), calculateOffsetOnScale(y + 6, scale), result.getDisplayName());
GlStateManager.popMatrix();
}
}
}
}

View File

@@ -4,9 +4,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.ITextComponent;
import refinedstorage.container.ContainerCrafter;
import refinedstorage.inventory.InventorySimple;
import refinedstorage.util.InventoryUtils;
public class TileCrafter extends TileMachine implements IInventory {
private InventorySimple inventory = new InventorySimple("crafter", PATTERN_SLOTS + 4, this);
@@ -27,6 +29,20 @@ public class TileCrafter extends TileMachine implements IInventory {
return ContainerCrafter.class;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
InventoryUtils.restoreInventory(inventory, 0, nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
InventoryUtils.saveInventory(inventory, 0, nbt);
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();