Crafter fixes
This commit is contained in:
		| @@ -1,7 +1,11 @@ | |||||||
| package refinedstorage.gui; | 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.container.ContainerCrafter; | ||||||
| import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; | import refinedstorage.gui.sidebutton.SideButtonRedstoneMode; | ||||||
|  | import refinedstorage.item.ItemPattern; | ||||||
| import refinedstorage.tile.TileCrafter; | import refinedstorage.tile.TileCrafter; | ||||||
|  |  | ||||||
| public class GuiCrafter extends GuiBase { | public class GuiCrafter extends GuiBase { | ||||||
| @@ -29,9 +33,35 @@ public class GuiCrafter extends GuiBase { | |||||||
|         drawTexture(x, y, 0, 0, width, height); |         drawTexture(x, y, 0, 0, width, height); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private int calculateOffsetOnScale(int pos, float scale) { | ||||||
|  |         float multiplier = (pos / scale); | ||||||
|  |         return (int) multiplier; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void drawForeground(int mouseX, int mouseY) { |     public void drawForeground(int mouseX, int mouseY) { | ||||||
|         drawString(7, 7, t("gui.refinedstorage:crafter")); |         drawString(7, 7, t("gui.refinedstorage:crafter")); | ||||||
|         drawString(7, 77, t("container.inventory")); |         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(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,9 +4,11 @@ import net.minecraft.entity.player.EntityPlayer; | |||||||
| import net.minecraft.inventory.Container; | import net.minecraft.inventory.Container; | ||||||
| import net.minecraft.inventory.IInventory; | import net.minecraft.inventory.IInventory; | ||||||
| import net.minecraft.item.ItemStack; | import net.minecraft.item.ItemStack; | ||||||
|  | import net.minecraft.nbt.NBTTagCompound; | ||||||
| import net.minecraft.util.text.ITextComponent; | import net.minecraft.util.text.ITextComponent; | ||||||
| import refinedstorage.container.ContainerCrafter; | import refinedstorage.container.ContainerCrafter; | ||||||
| import refinedstorage.inventory.InventorySimple; | import refinedstorage.inventory.InventorySimple; | ||||||
|  | import refinedstorage.util.InventoryUtils; | ||||||
|  |  | ||||||
| public class TileCrafter extends TileMachine implements IInventory { | public class TileCrafter extends TileMachine implements IInventory { | ||||||
|     private InventorySimple inventory = new InventorySimple("crafter", PATTERN_SLOTS + 4, this); |     private InventorySimple inventory = new InventorySimple("crafter", PATTERN_SLOTS + 4, this); | ||||||
| @@ -27,6 +29,20 @@ public class TileCrafter extends TileMachine implements IInventory { | |||||||
|         return ContainerCrafter.class; |         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 |     @Override | ||||||
|     public int getSizeInventory() { |     public int getSizeInventory() { | ||||||
|         return inventory.getSizeInventory(); |         return inventory.getSizeInventory(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Raoul Van den Berge
					Raoul Van den Berge