-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
3,412 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/io/github/moulberry/notenoughupdates/AllowEmptyHTMLTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package io.github.moulberry.notenoughupdates; | ||
|
||
import info.bliki.htmlcleaner.TagNode; | ||
import info.bliki.wiki.filter.ITextConverter; | ||
import info.bliki.wiki.model.IWikiModel; | ||
import info.bliki.wiki.tags.HTMLTag; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class AllowEmptyHTMLTag extends HTMLTag { | ||
public AllowEmptyHTMLTag(String name) { | ||
super(name); | ||
} | ||
|
||
public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException { | ||
boolean newLinesAfterTag = false; | ||
boolean newLinesAfterChildren = false; | ||
TagNode node = this; | ||
String name = node.getName(); | ||
List<Object> children = node.getChildren(); | ||
|
||
if (NEW_LINES) { | ||
switch (name) { | ||
case "div": | ||
case "p": | ||
case "li": | ||
case "td": | ||
buf.append('\n'); | ||
break; | ||
case "table": | ||
case "ul": | ||
case "ol": | ||
case "th": | ||
case "tr": | ||
buf.append('\n'); | ||
newLinesAfterTag = true; | ||
newLinesAfterChildren = true; | ||
break; | ||
case "pre": | ||
buf.append('\n'); | ||
newLinesAfterTag = false; | ||
newLinesAfterChildren = true; | ||
break; | ||
case "blockquote": | ||
newLinesAfterChildren = true; | ||
break; | ||
} | ||
} | ||
buf.append('<'); | ||
buf.append(name); | ||
|
||
Map<String, String> tagAtttributes = node.getAttributes(); | ||
|
||
appendAttributes(buf, tagAtttributes); | ||
|
||
if (children.size() == 0) { | ||
buf.append(" />"); | ||
} else { | ||
buf.append('>'); | ||
if (newLinesAfterTag) { | ||
buf.append('\n'); | ||
} | ||
converter.nodesToText(children, buf, model); | ||
if (newLinesAfterChildren) { | ||
buf.append('\n'); | ||
} | ||
buf.append("</"); | ||
buf.append(node.getName()); | ||
buf.append('>'); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/io/github/moulberry/notenoughupdates/GuiItemRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.github.moulberry.notenoughupdates; | ||
|
||
import com.google.gson.JsonObject; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.inventory.GuiCrafting; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.inventory.ContainerWorkbench; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.inventory.Slot; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class GuiItemRecipe extends GuiCrafting { | ||
|
||
private ItemStack[] craftMatrix; | ||
private String text; | ||
private String craftText = ""; | ||
private NEUManager manager; | ||
|
||
public GuiItemRecipe(ItemStack[] craftMatrix, JsonObject result, String text, NEUManager manager) { | ||
super(Minecraft.getMinecraft().thePlayer.inventory, Minecraft.getMinecraft().theWorld); | ||
this.craftMatrix = craftMatrix; | ||
this.text = text; | ||
this.manager = manager; | ||
|
||
ContainerWorkbench cw = (ContainerWorkbench) this.inventorySlots; | ||
for(int i=0; i<Math.min(craftMatrix.length, 9); i++) { | ||
if(craftMatrix[i] == null) continue; | ||
cw.craftMatrix.setInventorySlotContents(i, craftMatrix[i]); | ||
} | ||
if(result.has("crafttext")) { | ||
craftText = result.get("crafttext").getAsString(); | ||
} | ||
cw.craftResult.setInventorySlotContents(0, manager.jsonToStack(result)); | ||
} | ||
|
||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { | ||
String t = text.equals("") ? I18n.format("container.crafting", new Object[0]) : text; | ||
int xPos = 28; | ||
if(this.fontRendererObj.getStringWidth(t) > this.xSize - 40) { | ||
xPos = 4; | ||
} | ||
if(t.contains("\u00a7")) { | ||
this.fontRendererObj.drawStringWithShadow(t, xPos, 6, 4210752); | ||
} else { | ||
this.fontRendererObj.drawString(t, xPos, 6, 4210752); | ||
} | ||
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); | ||
|
||
this.fontRendererObj.drawString(craftText, 88, 19, 4210752); | ||
} | ||
|
||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { | ||
} | ||
|
||
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) { | ||
if(slotId >= 1 && slotId <= 9) { | ||
ItemStack click = craftMatrix[slotId-1]; | ||
if(click != null) { | ||
manager.displayGuiItemRecipe(manager.getInternalNameForItem(click), ""); | ||
} | ||
} | ||
} | ||
|
||
/*public void handleMouseInput() throws IOException { | ||
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); | ||
int height = scaledresolution.getScaledHeight(); | ||
int mouseX = Mouse.getX() / scaledresolution.getScaleFactor(); | ||
int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor(); | ||
if(mouseY > this.guiTop + this.ySize - 94 || mouseY < this.guiTop || | ||
mouseX < this.guiLeft || mouseX > this.guiLeft+this.xSize) { | ||
//Potentially allow mouse input in the future. For now this is still broken. | ||
//super.handleMouseInput(); | ||
} | ||
}*/ | ||
|
||
public void onCraftMatrixChanged(IInventory inventoryIn){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.