summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomRenderItem.java167
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HTMLParagraphView.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HtmlImageGenerator.java125
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/LargeHTMLEditorKit.java132
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SynchronousHTMLEditorKit.java36
7 files changed, 8 insertions, 490 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
new file mode 100644
index 00000000..c4d3b57b
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
@@ -0,0 +1,4 @@
+package io.github.moulberry.notenoughupdates;
+
+public class CustomItems {
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomRenderItem.java
deleted file mode 100644
index bf194e33..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomRenderItem.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package io.github.moulberry.notenoughupdates;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.*;
-import net.minecraft.client.renderer.block.model.BakedQuad;
-import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
-import net.minecraft.client.renderer.entity.RenderItem;
-import net.minecraft.client.renderer.texture.TextureMap;
-import net.minecraft.client.renderer.texture.TextureUtil;
-import net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.client.resources.model.IBakedModel;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumFacing;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.Vec3i;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-public class CustomRenderItem {
-
- public static void renderItemIntoGUI(RenderItem renderItem, ItemStack stack, int x, int y, boolean effect) {
- IBakedModel ibakedmodel = renderItem.getItemModelMesher().getItemModel(stack);
- GlStateManager.pushMatrix();
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
- Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
- GlStateManager.enableRescaleNormal();
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
- GlStateManager.enableBlend();
- GlStateManager.blendFunc(770, 771);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- setupGuiTransform(x, y, ibakedmodel.isGui3d());
- ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GUI);
- renderItem(renderItem, stack, ibakedmodel, effect);
- GlStateManager.disableAlpha();
- GlStateManager.disableRescaleNormal();
- GlStateManager.disableLighting();
- GlStateManager.popMatrix();
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
- Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
- }
-
- private static void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d) {
- GlStateManager.translate((float)xPosition, (float)yPosition, 0);
- GlStateManager.translate(8.0F, 8.0F, 0.0F);
- GlStateManager.scale(1.0F, 1.0F, -1.0F);
- GlStateManager.scale(0.5F, 0.5F, 0.5F);
-
- if (isGui3d) {
- GlStateManager.scale(40.0F, 40.0F, 40.0F);
- GlStateManager.rotate(210.0F, 1.0F, 0.0F, 0.0F);
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.enableLighting();
- } else {
- GlStateManager.scale(64.0F, 64.0F, 64.0F);
- GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
- GlStateManager.disableLighting();
- }
- }
-
- public static void renderItem(RenderItem renderItem, ItemStack stack, IBakedModel model, boolean effect) {
- if (stack != null) {
- GlStateManager.pushMatrix();
- GlStateManager.scale(0.5F, 0.5F, 0.5F);
-
- if (model.isBuiltInRenderer()) {
- GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.translate(-0.5F, -0.5F, -0.5F);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.enableRescaleNormal();
- TileEntityItemStackRenderer.instance.renderByItem(stack);
- } else {
- GlStateManager.translate(-0.5F, -0.5F, -0.5F);
- Class<?>[] paramsRM = new Class[]{IBakedModel.class, ItemStack.class};
- Method renderModelMethod = Utils.getMethod(RenderItem.class, paramsRM,
- "renderModel", "func_175036_a");
- if(renderModelMethod != null) {
- renderModelMethod.setAccessible(true);
- try {
- renderModelMethod.invoke(renderItem, model, stack);
- } catch(Exception e) {}
- }
-
- if (stack.hasEffect() && effect) {
- Class<?>[] paramsRE = new Class[]{IBakedModel.class};
- Method renderEffectMethod = Utils.getMethod(RenderItem.class, paramsRE,
- "renderEffect", "func_180451_a");
- if(renderEffectMethod != null) {
- renderEffectMethod.setAccessible(true);
- try {
- renderEffectMethod.invoke(renderItem, model);
- } catch(Exception e) {}
- }
- }
- }
-
- GlStateManager.popMatrix();
- }
- }
-
- /*private static void renderModel(IBakedModel model, ItemStack stack)
- {
- renderModel(model, -1, stack);
- }
-
- private static void renderModel(IBakedModel model, int color)
- {
- renderModel(model, color, (ItemStack)null);
- }
-
- private static void renderModel(IBakedModel model, int color, ItemStack stack)
- {
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.ITEM);
-
- for (EnumFacing enumfacing : EnumFacing.values())
- {
- renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color, stack);
- }
-
- renderQuads(worldrenderer, model.getGeneralQuads(), color, stack);
- tessellator.draw();
- }
-
- private static void putQuadNormal(WorldRenderer renderer, BakedQuad quad)
- {
- Vec3i vec3i = quad.getFace().getDirectionVec();
- renderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
- }
-
- private static void renderQuad(WorldRenderer renderer, BakedQuad quad, int color)
- {
- renderer.addVertexData(quad.getVertexData());
- renderer.putColor4(color);
- putQuadNormal(renderer, quad);
- }
-
- private static void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color, ItemStack stack)
- {
- boolean flag = color == -1 && stack != null;
- int i = 0;
-
- for (int j = quads.size(); i < j; ++i)
- {
- BakedQuad bakedquad = (BakedQuad)quads.get(i);
- int k = color;
-
- if (flag && bakedquad.hasTintIndex())
- {
- k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex());
-
- if (EntityRenderer.anaglyphEnable)
- {
- k = TextureUtil.anaglyphColor(k);
- }
-
- k = k | -16777216;
- }
-
- net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
- }
- }*/
-
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
new file mode 100644
index 00000000..88ffe16e
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
@@ -0,0 +1,4 @@
+package io.github.moulberry.notenoughupdates.mixins;
+
+public class MixinInventoryEffectRenderer {
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HTMLParagraphView.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HTMLParagraphView.java
deleted file mode 100644
index ab4be4a7..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HTMLParagraphView.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package io.github.moulberry.notenoughupdates.util;
-
-import javax.swing.text.Element;
-import javax.swing.text.FlowView;
-import javax.swing.text.View;
-import javax.swing.text.html.ParagraphView;
-
-class HTMLParagraphView extends ParagraphView {
-
- public static int MAX_VIEW_SIZE=100;
-
- public HTMLParagraphView(Element elem) {
- super(elem);
- strategy = new HTMLParagraphView.HTMLFlowStrategy();
- }
-
- public static class HTMLFlowStrategy extends FlowStrategy {
- protected View createView(FlowView fv, int startOffset, int spanLeft, int rowIndex) {
- View res=super.createView(fv, startOffset, spanLeft, rowIndex);
- if (res.getEndOffset()-res.getStartOffset()> MAX_VIEW_SIZE) {
- res = res.createFragment(startOffset, startOffset+ MAX_VIEW_SIZE);
- }
- return res;
- }
-
- }
- public int getResizeWeight(int axis) {
- return 0;
- }
-} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HtmlImageGenerator.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HtmlImageGenerator.java
deleted file mode 100644
index 40866a00..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HtmlImageGenerator.java
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// Source code recreated from a .class file by IntelliJ IDEA
-// (powered by Fernflower decompiler)
-//
-package io.github.moulberry.notenoughupdates.util;
-
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import javax.imageio.ImageIO;
-import javax.swing.JEditorPane;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.ImageView;
-import javax.swing.text.html.StyleSheet;
-
-public class HtmlImageGenerator {
- public JEditorPane editorPane = this.createJEditorPane();
- static final Dimension DEFAULT_SIZE = new Dimension(800, 800);
-
- public HtmlImageGenerator() {
- }
-
- public ComponentOrientation getOrientation() {
- return this.editorPane.getComponentOrientation();
- }
-
- public void setOrientation(ComponentOrientation orientation) {
- this.editorPane.setComponentOrientation(orientation);
- }
-
- public Dimension getSize() {
- return this.editorPane.getSize();
- }
-
- public void setSize(Dimension dimension) {
- this.editorPane.setSize(dimension);
- }
-
- public void loadUrl(URL url) {
- try {
- this.editorPane.setPage(url);
- } catch (IOException var3) {
- throw new RuntimeException(String.format("Exception while loading %s", url), var3);
- }
- }
-
- public void loadUrl(String url) {
- try {
- this.editorPane.setPage(url);
- } catch (IOException var3) {
- throw new RuntimeException(String.format("Exception while loading %s", url), var3);
- }
- }
-
- public void loadHtml(String html) {
- this.editorPane.setText(html);
- this.onDocumentLoad();
- }
-
- public void saveAsImage(String file) {
- this.saveAsImage(new File(file));
- }
-
- public void saveAsImage(File file) {
- BufferedImage img = this.getBufferedImage();
-
- try {
- ImageIO.write(img, "png", file);
- } catch (IOException var4) {
- throw new RuntimeException(String.format("Exception while saving '%s' image", file), var4);
- }
- }
-
- protected void onDocumentLoad() {
- }
-
- public Dimension getDefaultSize() {
- return DEFAULT_SIZE;
- }
-
- public BufferedImage getBufferedImage() {
- Dimension prefSize = this.editorPane.getPreferredSize();
- BufferedImage img = new BufferedImage(prefSize.width, this.editorPane.getPreferredSize().height, 2);
- Graphics graphics = img.getGraphics();
- this.editorPane.setSize(prefSize);
- this.editorPane.paint(graphics);
- return img;
- }
-
- public void addCss(String css) {
- HTMLEditorKit kit = (HTMLEditorKit) editorPane.getEditorKitForContentType("text/html");
- kit.getStyleSheet().addRule(css);
- }
-
- public void setScale(float factor) {
- editorPane.getDocument().putProperty("ZOOM_FACTOR", new Double(factor));
- }
-
- protected JEditorPane createJEditorPane() {
- JEditorPane editorPane = new JEditorPane();
- editorPane.setSize(this.getDefaultSize());
- editorPane.setEditable(false);
- HTMLEditorKit kit = new LargeHTMLEditorKit();
- editorPane.setEditorKitForContentType("text/html", kit);
- editorPane.setBackground(new Color(0, true));
- editorPane.setContentType("text/html");
- editorPane.addPropertyChangeListener(new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("page")) {
- HtmlImageGenerator.this.onDocumentLoad();
- }
-
- }
- });
- return editorPane;
- }
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/LargeHTMLEditorKit.java b/src/main/java/io/github/moulberry/notenoughupdates/util/LargeHTMLEditorKit.java
deleted file mode 100644
index 7b69a541..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/LargeHTMLEditorKit.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package io.github.moulberry.notenoughupdates.util;
-
-import javax.swing.text.*;
-import javax.swing.text.html.*;
-import java.awt.*;
-import java.awt.geom.AffineTransform;
-
-public class LargeHTMLEditorKit extends HTMLEditorKit {
-
- ViewFactory factory = new MyViewFactory();
-
- @Override
- public ViewFactory getViewFactory() {
- return factory;
- }
-
- public Document createDefaultDocument() {
- HTMLDocument doc = (HTMLDocument)super.createDefaultDocument();
- doc.setAsynchronousLoadPriority(-1);
- return doc;
- }
-
- class MyViewFactory extends HTMLFactory {
- @Override
- public View create(Element elem) {
- AttributeSet attrs = elem.getAttributes();
- Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
- Object o = (elementName != null) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
- if (o instanceof HTML.Tag) {
- HTML.Tag kind = (HTML.Tag) o;
- if (kind == HTML.Tag.HTML) {
- return new HTMLBlockView(elem);
- }
- }
- View view = super.create(elem);
- if(view instanceof ImageView) {
- //((ImageView)view).setLoadsSynchronously(true);
- }
- return view;
- }
-
- }
-
-
- private class HTMLBlockView extends BlockView {
-
- public HTMLBlockView(Element elem) {
- super(elem, View.Y_AXIS);
- }
-
- @Override
- protected void layout(int width, int height) {
- if (width<Integer.MAX_VALUE) {
- super.layout(new Double(width / getZoomFactor()).intValue(),
- new Double(height *
- getZoomFactor()).intValue());
- }
- }
-
- public double getZoomFactor() {
- Double scale = (Double) getDocument().getProperty("ZOOM_FACTOR");
- if (scale != null) {
- return scale.doubleValue();
- }
-
- return 1;
- }
-
- @Override
- public void paint(Graphics g, Shape allocation) {
- Graphics2D g2d = (Graphics2D) g;
- double zoomFactor = getZoomFactor();
- AffineTransform old = g2d.getTransform();
- g2d.scale(zoomFactor, zoomFactor);
- super.paint(g2d, allocation);
- g2d.setTransform(old);
- }
-
- @Override
- public float getMinimumSpan(int axis) {
- float f = super.getMinimumSpan(axis);
- f *= getZoomFactor();
- return f;
- }
-
- @Override
- public float getMaximumSpan(int axis) {
- float f = super.getMaximumSpan(axis);
- f *= getZoomFactor();
- return f;
- }
-
- @Override
- public float getPreferredSpan(int axis) {
- float f = super.getPreferredSpan(axis);
- f *= getZoomFactor();
- return f;
- }
-
- @Override
- public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
- double zoomFactor = getZoomFactor();
- Rectangle alloc;
- alloc = a.getBounds();
- Shape s = super.modelToView(pos, alloc, b);
- alloc = s.getBounds();
- alloc.x *= zoomFactor;
- alloc.y *= zoomFactor;
- alloc.width *= zoomFactor;
- alloc.height *= zoomFactor;
-
- return alloc;
- }
-
- @Override
- public int viewToModel(float x, float y, Shape a,
- Position.Bias[] bias) {
- double zoomFactor = getZoomFactor();
- Rectangle alloc = a.getBounds();
- x /= zoomFactor;
- y /= zoomFactor;
- alloc.x /= zoomFactor;
- alloc.y /= zoomFactor;
- alloc.width /= zoomFactor;
- alloc.height /= zoomFactor;
-
- return super.viewToModel(x, y, alloc, bias);
- }
-
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SynchronousHTMLEditorKit.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SynchronousHTMLEditorKit.java
deleted file mode 100644
index 7f02baa7..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SynchronousHTMLEditorKit.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package io.github.moulberry.notenoughupdates.util;
-
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.View;
-import javax.swing.text.ViewFactory;
-import javax.swing.text.html.HTMLDocument;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.ImageView;
-import javax.swing.text.html.HTMLEditorKit.HTMLFactory;
-
-public class SynchronousHTMLEditorKit extends HTMLEditorKit {
- public SynchronousHTMLEditorKit() {
- }
-
- public Document createDefaultDocument() {
- HTMLDocument doc = (HTMLDocument)super.createDefaultDocument();
- doc.setAsynchronousLoadPriority(-1);
- return doc;
- }
-
- public ViewFactory getViewFactory() {
- return new HTMLFactory() {
- public View create(Element elem) {
- View view = super.create(elem);
- if (view instanceof ImageView) {
- //((ImageView)view).setLoadsSynchronously(true);
- }
-
- return view;
- }
- };
- }
-
-
-}