mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 12:32:23 +00:00
Replace Worktable's book with a small X
This commit is contained in:
1 parent
488d08616b
commit
a73fd60d1f
5 files changed
+29
-36
No files matched your search
@@ -193,6 +193,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
|
||||
private LinkedList<Recipe> recipes = new LinkedList<Recipe>();
|
||||
private long lastUpdate;
|
||||
public final int capacity = 9;
|
||||
|
||||
public long getLastUpdate() {
|
||||
return lastUpdate;
|
||||
@@ -204,10 +205,13 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
recipe.updateLastUse(world);
|
||||
|
||||
Recipe memory = getMemorized(crafting, world);
|
||||
if (memory != null)
|
||||
recipes.remove(memory);
|
||||
if (memory != null) {
|
||||
int index = recipes.indexOf(memory);
|
||||
recipes.set(index, recipe);
|
||||
return;
|
||||
}
|
||||
|
||||
if (recipes.size() < 8) {
|
||||
if (recipes.size() < capacity) {
|
||||
recipes.add(recipe);
|
||||
return;
|
||||
}
|
||||
@@ -413,7 +417,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
}
|
||||
|
||||
public void chooseRecipe(int recipeIndex) {
|
||||
if (recipeIndex == 9) {
|
||||
if (recipeIndex >= memorized.capacity) {
|
||||
for (int slot = 0; slot < craftingInventory.getSizeInventory(); slot++) {
|
||||
craftingInventory.setInventorySlotContents(slot, null);
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC
|
||||
tile.setRecipe(craftMatrix);
|
||||
}
|
||||
|
||||
public void clearRecipe() {
|
||||
sendRecipeClick(0, tile.getMemory().capacity);
|
||||
}
|
||||
|
||||
public void sendRecipeClick(int mouseButton, int recipeIndex) {
|
||||
PacketPayload payload = new PacketPayload(2, 0, 0);
|
||||
payload.intPayload[0] = mouseButton;
|
||||
|
||||
@@ -82,36 +82,21 @@ public class GuiWorktable extends GuiForestryTitled<TileWorktable> {
|
||||
}
|
||||
}
|
||||
|
||||
private class BookSlot extends Widget {
|
||||
private class ClearWorktable extends Widget {
|
||||
|
||||
private final ItemStack BOOK = new ItemStack(Items.book);
|
||||
|
||||
public BookSlot(WidgetManager manager, int xPos, int yPos) {
|
||||
public ClearWorktable(WidgetManager manager, int xPos, int yPos) {
|
||||
super(manager, xPos, yPos);
|
||||
width = 7;
|
||||
height = 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int startX, int startY) {
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
manager.gui.drawItemStack(BOOK, startX + xPos, startY + yPos);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLegacyTooltip(EntityPlayer player) {
|
||||
return StringUtil.localize("gui.worktable.clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
container.sendRecipeClick(mouseButton, 9);
|
||||
container.clearRecipe();
|
||||
}
|
||||
}
|
||||
private final TileWorktable worktable;
|
||||
@@ -125,18 +110,18 @@ public class GuiWorktable extends GuiForestryTitled<TileWorktable> {
|
||||
this.tile = tile;
|
||||
container = (ContainerWorktable) inventorySlots;
|
||||
|
||||
widgetManager.add(new BookSlot(widgetManager, 128, 38));
|
||||
final int spacing = 18;
|
||||
int slot = 0;
|
||||
for (int y = 0; y < 3; y++) {
|
||||
int yPos = 20 + (y * spacing);
|
||||
for (int x = 0; x < 3; x++) {
|
||||
int xPos = 110 + (x * spacing);
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, xPos, yPos, slot));
|
||||
slot += 1;
|
||||
}
|
||||
}
|
||||
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 146, 20, 0));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 146, 38, 1));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 146, 56, 2));
|
||||
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 128, 56, 3));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 110, 56, 4));
|
||||
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 110, 38, 5));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 110, 20, 6));
|
||||
widgetManager.add(new MemorizedSlot(widgetManager, 128, 20, 7));
|
||||
widgetManager.add(new ClearWorktable(widgetManager, 66, 19));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user