More changes, reorganization
This commit is contained in:
parent
b958f0d07f
commit
d43a78dcf8
25 changed files with 598 additions and 308 deletions
80
machinemuse/general/geometry/Colour.java
Normal file
80
machinemuse/general/geometry/Colour.java
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
package machinemuse.general.geometry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class representing an RGBA colour and various helper functions. Mainly to
|
||||||
|
* improve readability elsewhere.
|
||||||
|
*
|
||||||
|
* @author MachineMuse
|
||||||
|
*/
|
||||||
|
public class Colour {
|
||||||
|
/**
|
||||||
|
* The RGBA values are stored as floats from 0.0F (nothing) to 1.0F (full
|
||||||
|
* saturation/opacity)
|
||||||
|
*/
|
||||||
|
public float r, g, b, a;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Just sets the RGBA values to the parameters.
|
||||||
|
*/
|
||||||
|
public Colour(float r, float g, float b, float a) {
|
||||||
|
this.r = r;
|
||||||
|
this.g = g;
|
||||||
|
this.b = b;
|
||||||
|
this.a = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Secondary constructor. Sets RGB accordingly and sets alpha to 1.0F (full
|
||||||
|
* opacity)
|
||||||
|
*/
|
||||||
|
public Colour(float r, float g, float b) {
|
||||||
|
this(r, g, b, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes colours in the integer format that Minecraft uses, and converts.
|
||||||
|
*/
|
||||||
|
public Colour(int c) {
|
||||||
|
this.a = (c >> 24 & 255) / 255.0F;
|
||||||
|
this.r = (c >> 16 & 255) / 255.0F;
|
||||||
|
this.g = (c >> 8 & 255) / 255.0F;
|
||||||
|
this.b = (c & 255) / 255.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this colour as an int in Minecraft's format (I think)
|
||||||
|
*
|
||||||
|
* @return int value of this colour
|
||||||
|
*/
|
||||||
|
public int getInt() {
|
||||||
|
int val = 0;
|
||||||
|
val = val | ((int) (a * 255) << 24);
|
||||||
|
val = val | ((int) (b * 255) << 16);
|
||||||
|
val = val | ((int) (g * 255) << 8);
|
||||||
|
val = val | ((int) (r * 255));
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a colour with RGB set to the same value ie. a shade of grey.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static Colour getGreyscale(float value, float alpha) {
|
||||||
|
return new Colour(value, value, value, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a colour at interval interval along a linear gradient from this
|
||||||
|
* to target
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Colour interpolate(Colour target, float interval) {
|
||||||
|
float complement = 1 - interval;
|
||||||
|
return new Colour(
|
||||||
|
this.r * complement + target.r * interval,
|
||||||
|
this.g * complement + target.g * interval,
|
||||||
|
this.b * complement + target.b * interval,
|
||||||
|
this.a * complement + target.a * interval);
|
||||||
|
}
|
||||||
|
}
|
27
machinemuse/general/geometry/Point2D.java
Normal file
27
machinemuse/general/geometry/Point2D.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package machinemuse.general.geometry;
|
||||||
|
|
||||||
|
public class Point2D {
|
||||||
|
private float x;
|
||||||
|
private float y;
|
||||||
|
|
||||||
|
public Point2D(float x, float y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(float x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(float y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,26 +1,88 @@
|
||||||
package machinemuse.powersuits.client;
|
package machinemuse.powersuits.client;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.gui.MuseGui;
|
||||||
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.client.renderer.RenderEngine;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.storage.MapData;
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
|
|
||||||
public class EquipmentRenderer implements IItemRenderer {
|
public class EquipmentRenderer implements IItemRenderer {
|
||||||
private static final boolean useRenderHelper = true;
|
private static final boolean useRenderHelper = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forge checks this to see if our custom renderer will handle a certain
|
||||||
|
* type of rendering.
|
||||||
|
*
|
||||||
|
* type can be:
|
||||||
|
*
|
||||||
|
* ENTITY - When the item is floating in the world, e.g. after being tossed
|
||||||
|
* or dropped by a mob.
|
||||||
|
*
|
||||||
|
* INVENTORY - Drawing it on an inventory slot.
|
||||||
|
*
|
||||||
|
* EQUIPPED - Rendering the item in an entity's hand e.g. endermen.
|
||||||
|
*
|
||||||
|
* FIRST_PERSON_MAP - Drawing it in the viewing player's hand
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||||
return useRenderHelper;
|
return useRenderHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to actually render the item. type is as above, item is the item to
|
||||||
|
* render, and data is some extra data depending on the type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||||
|
switch (type) {
|
||||||
|
case ENTITY:
|
||||||
|
RenderBlocks renderEntity = (RenderBlocks) data[0];
|
||||||
|
EntityItem entityEntity = (EntityItem) data[1];
|
||||||
|
break;
|
||||||
|
case INVENTORY:
|
||||||
|
RenderBlocks renderInventory = (RenderBlocks) data[0];
|
||||||
|
break;
|
||||||
|
case EQUIPPED:
|
||||||
|
RenderBlocks renderEquipped = (RenderBlocks) data[0];
|
||||||
|
EntityLiving entityEquipped = (EntityLiving) data[1];
|
||||||
|
break;
|
||||||
|
case FIRST_PERSON_MAP:
|
||||||
|
EntityPlayer playerFirstPerson = (EntityPlayer) data[0];
|
||||||
|
RenderEngine engineFirstPerson = (RenderEngine) data[1];
|
||||||
|
MapData mapDataFirstPerson = (MapData) data[2];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
MuseGui muse = new MuseGui();
|
||||||
|
muse.drawCircleAround(8, 8, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to use the RenderHelper for this item. Helper can be:
|
||||||
|
*
|
||||||
|
* ENTITY_ROTATION - Isometric rotation, for block items
|
||||||
|
*
|
||||||
|
* ENTITY_BOBBING - Up-and-down bobbing effect for EntityItem
|
||||||
|
*
|
||||||
|
* EQUIPPED_BLOCK - Determines if the currently equipped item should be
|
||||||
|
* rendered as a 3D block or as a 2D texture.
|
||||||
|
*
|
||||||
|
* BLOCK_3D - Determines if the item should equate to a block that has
|
||||||
|
* RenderBlocks.renderItemIn3d return true
|
||||||
|
*
|
||||||
|
* INVENTORY_BLOCK - Determines if the item should be rendered in GUI
|
||||||
|
* inventory slots as a 3D block or as a 2D texture.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
|
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
|
||||||
ItemRendererHelper helper) {
|
ItemRendererHelper helper) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
|
||||||
MuseGui muse = new MuseGui();
|
|
||||||
muse.drawCircleAround(8, 8, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
package machinemuse.powersuits.client;
|
|
||||||
|
|
||||||
import machinemuse.powersuits.common.ContainerTinkerTable;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
public class GuiTinkerTable extends GuiContainer {
|
|
||||||
public IInventory[] armorInventory;
|
|
||||||
|
|
||||||
public GuiTinkerTable(ContainerTinkerTable container) {
|
|
||||||
super(container);
|
|
||||||
this.xSize = 256;
|
|
||||||
this.ySize = 226;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the buttons (and other controls) to the screen in question.
|
|
||||||
*/
|
|
||||||
public void initGui()
|
|
||||||
{
|
|
||||||
super.initGui();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void drawNthItem(ItemStack stack, int n) {
|
|
||||||
// // TBI
|
|
||||||
// // draw item
|
|
||||||
// // draw a button if it's moddable
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void drawSelection() {
|
|
||||||
// // if(selectedSlot != null) {
|
|
||||||
// // drawCircleAround(selectedSlot.position, renderEngine, selectedSlot);
|
|
||||||
// // }
|
|
||||||
// // for (Augmentation a : Augmentation.getAllAugs()) {
|
|
||||||
// // if (a.canGoInSlot(selectedSlot.getType())) {
|
|
||||||
// //
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void drawLayout(AugLayout layout) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void drawBackground() {
|
|
||||||
// this.drawDefaultBackground();
|
|
||||||
// this.drawRectangularBackground();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void drawScreen(int par1, int par2, float par3) {
|
|
||||||
// super.drawScreen(par1, par2, par3);
|
|
||||||
// drawBackground();
|
|
||||||
// drawItemList();
|
|
||||||
// if (editingItem != null && editingLayout != null) {
|
|
||||||
// drawLayout(editingLayout);
|
|
||||||
// if (selectedSlot != null) {
|
|
||||||
// drawSelection();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void drawItemList() {
|
|
||||||
// List<ItemStack> items = new ArrayList<ItemStack>();
|
|
||||||
// for (int i = 0; i < 4; i++) {
|
|
||||||
// ItemStack item = editingPlayer.inventory.armorItemInSlot(i);
|
|
||||||
// this.drawItemAt(new Point2Df(0, 0), this.mc.renderEngine, item);
|
|
||||||
// items.add(item);
|
|
||||||
// }
|
|
||||||
// for (int i = 0; i < 9; i++) {
|
|
||||||
// items.add(editingPlayer.inventory.mainInventory[i]);
|
|
||||||
// }
|
|
||||||
// this.drawItemsOnVerticalLine(items, new Point2Df(-0.9f, 0), 0.9f,
|
|
||||||
// this.mc.renderEngine);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw the foreground layer for the GuiContainer (everything in front of
|
|
||||||
* the items)
|
|
||||||
*/
|
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
|
||||||
{
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
int color = 0;
|
|
||||||
double weight = 0.0;
|
|
||||||
double capacity = 0.0;
|
|
||||||
|
|
||||||
this.fontRenderer.drawString("Weight: " + weight, 8, 104,
|
|
||||||
color);
|
|
||||||
this.fontRenderer.drawString("Capacity: " + capacity, 8, 114,
|
|
||||||
color);
|
|
||||||
this.fontRenderer.drawString("Speed: " + capacity, 8, 124,
|
|
||||||
color);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawAugmentationContainerBackground(int paddingX,
|
|
||||||
int paddingY, int j) {
|
|
||||||
int n = 0; // set N to the number of augs in that item, plus 1
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
this.drawTexturedModalRect(
|
|
||||||
paddingX + 35, // where on the screen
|
|
||||||
paddingY + 8 + 18 * j,
|
|
||||||
0, // where in the texture
|
|
||||||
227,
|
|
||||||
18 * i, // how much
|
|
||||||
18);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw the background layer for the GuiContainer (everything behind the
|
|
||||||
* items)
|
|
||||||
*/
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2,
|
|
||||||
int par3)
|
|
||||||
{
|
|
||||||
int textureIndex = this.mc.renderEngine
|
|
||||||
.getTexture("/img/tinktablegui.png");
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.renderEngine.bindTexture(textureIndex);
|
|
||||||
int paddingX = (this.width - this.xSize) / 2;
|
|
||||||
int paddingY = (this.height - this.ySize) / 2;
|
|
||||||
int numrows = 5;
|
|
||||||
this.drawTexturedModalRect(paddingX, paddingY, 0, 0, this.xSize,
|
|
||||||
this.ySize);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,147 +0,0 @@
|
||||||
package machinemuse.powersuits.client;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.renderer.RenderEngine;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
public class MuseGui extends GuiScreen {
|
|
||||||
protected static RenderItem itemRenderer = new RenderItem();
|
|
||||||
private final boolean usePretty = true;
|
|
||||||
private static final int numSegments = 360;
|
|
||||||
private static final int xcenter = 8;
|
|
||||||
private static final int ycenter = 8;
|
|
||||||
private static final Tessellator tesselator = Tessellator.instance;
|
|
||||||
|
|
||||||
public static final double theta = (2 * Math.PI) / numSegments;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the buttons (and other controls) to the screen in question.
|
|
||||||
*/
|
|
||||||
public void initGui() {
|
|
||||||
super.initGui();
|
|
||||||
this.controlList.clear();
|
|
||||||
Keyboard.enableRepeatEvents(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawRectangularBackground() {
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glEnable(GL11.GL_LINE_SMOOTH);
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
GL11.glBegin(GL11.GL_QUADS);
|
|
||||||
GL11.glColor4f(0.5f, 0.5f, 0.5f, 0.8f);
|
|
||||||
GL11.glVertex2d(0, 0);
|
|
||||||
GL11.glVertex2d(width - 10, 0);
|
|
||||||
GL11.glVertex2d(width - 10, height - 10);
|
|
||||||
GL11.glVertex2d(0, height - 10);
|
|
||||||
GL11.glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawItemsOnVerticalLine(List<ItemStack> items, Point2Df offset,
|
|
||||||
float lineheight, RenderEngine engine) {
|
|
||||||
if (items.size() < 1) {
|
|
||||||
return;
|
|
||||||
} else if (items.size() < 2) {
|
|
||||||
drawItemAt(offset, engine, items.get(0));
|
|
||||||
} else {
|
|
||||||
int top = (int) (offset.getAbsY(height) - height * lineheight / 2);
|
|
||||||
int bottom = (int) (offset.getAbsY(height) + height * lineheight
|
|
||||||
/ 2);
|
|
||||||
Point2Df position = new Point2Df(offset.x, top * 2.0f / height - 1);
|
|
||||||
int step = (top - bottom) / (items.size() - 1);
|
|
||||||
for (int i = 0; i < items.size(); i++) {
|
|
||||||
drawItemAt(position, engine, items.get(i));
|
|
||||||
position.y += step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawItemAt(Point2Df p, RenderEngine engine,
|
|
||||||
ItemStack item) {
|
|
||||||
itemRenderer.renderItemAndEffectIntoGUI(this.fontRenderer, engine,
|
|
||||||
item, p.getAbsX(width) - xcenter, p.getAbsY(height) - ycenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawCircleAround(float xoffset, float yoffset, float radius) {
|
|
||||||
int start = (int) (System.currentTimeMillis() / 4 % 360);
|
|
||||||
double x = radius * Math.sin(theta * start);
|
|
||||||
double y = radius * Math.cos(theta * start);
|
|
||||||
double tf = Math.tan(theta);
|
|
||||||
double rf = Math.cos(theta);
|
|
||||||
double tx;
|
|
||||||
double ty;
|
|
||||||
Colour c = new Colour(0.0f, 1.0f, 0.0f, 0.0f);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glEnable(GL11.GL_LINE_SMOOTH);
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
GL11.glBegin(GL11.GL_LINE_LOOP);
|
|
||||||
for (int i = 0; i < numSegments; i++) {
|
|
||||||
GL11.glColor4f(c.r, c.g, c.b, c.a);
|
|
||||||
GL11.glVertex2d(x + xoffset, y + yoffset);
|
|
||||||
tx = y;
|
|
||||||
ty = -x;
|
|
||||||
x += tx * tf;
|
|
||||||
y += ty * tf;
|
|
||||||
x *= rf;
|
|
||||||
y *= rf;
|
|
||||||
c.r += theta / 7;
|
|
||||||
c.b += theta / 7;
|
|
||||||
c.a += theta / 2;
|
|
||||||
}
|
|
||||||
GL11.glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Colour {
|
|
||||||
public float r;
|
|
||||||
public float g;
|
|
||||||
public float b;
|
|
||||||
public float a;
|
|
||||||
|
|
||||||
public Colour(float r, float g, float b, float a) {
|
|
||||||
this.r = r;
|
|
||||||
this.g = g;
|
|
||||||
this.b = b;
|
|
||||||
this.a = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Colour(float r, float g, float b) {
|
|
||||||
this(r, g, b, 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Colour(int c) {
|
|
||||||
this.r = (c >> 16 & 255) / 255.0F;
|
|
||||||
this.g = (c >> 8 & 255) / 255.0F;
|
|
||||||
this.b = (c & 255) / 255.0F;
|
|
||||||
this.a = 1.0F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Point2Df {
|
|
||||||
/*
|
|
||||||
* point representation where [-1,-1] is the top left corner of the
|
|
||||||
* screen and [1,1] is the bottom right.
|
|
||||||
*/
|
|
||||||
public float x;
|
|
||||||
public float y;
|
|
||||||
|
|
||||||
public Point2Df(float x, float y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAbsX(int width) {
|
|
||||||
return (int) ((x + 1) * width / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAbsY(int height) {
|
|
||||||
return (int) ((y + 1) * height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.common.block.BlockTinkerTable;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.StepSound;
|
import net.minecraft.block.StepSound;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -101,7 +102,6 @@ public class Config extends Configuration {
|
||||||
PowerArmorLegs(2, "powerArmorLegs", "Power Armor Legs"),
|
PowerArmorLegs(2, "powerArmorLegs", "Power Armor Legs"),
|
||||||
PowerArmorFeet(3, "powerArmorFeet", "Power Armor Feet"),
|
PowerArmorFeet(3, "powerArmorFeet", "Power Armor Feet"),
|
||||||
PowerTool(4, "powerTool", "Power Tool"),
|
PowerTool(4, "powerTool", "Power Tool"),
|
||||||
Augmentation(5, "modularAugmentation", "Modular Augmentation"),
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common;
|
||||||
|
|
||||||
import machinemuse.powersuits.client.GuiTinkerTable;
|
import machinemuse.powersuits.gui.GuiTinkerTable;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
@ -10,13 +10,12 @@ public class GuiHandler implements IGuiHandler {
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
||||||
int x, int y, int z) {
|
int x, int y, int z) {
|
||||||
return new ContainerTinkerTable(player, world, x, y, z);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
|
||||||
int x, int y, int z) {
|
int x, int y, int z) {
|
||||||
return new GuiTinkerTable(new ContainerTinkerTable(player, world, x, y,
|
return new GuiTinkerTable(player);
|
||||||
z));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import machinemuse.powersuits.client.ClientPacketHandler;
|
import machinemuse.powersuits.client.ClientPacketHandler;
|
||||||
|
import machinemuse.powersuits.common.block.BlockTinkerTable;
|
||||||
|
import machinemuse.powersuits.common.item.ItemPowerArmor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraftforge.common.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
|
@ -55,7 +57,6 @@ public class PowersuitsMod {
|
||||||
allItems.add(new ItemPowerArmor(
|
allItems.add(new ItemPowerArmor(
|
||||||
Config.Items.values()[i]));
|
Config.Items.values()[i]));
|
||||||
}
|
}
|
||||||
allItems.add(new ItemAugmentation(Config.Items.Augmentation));
|
|
||||||
|
|
||||||
proxy.registerRenderers();
|
proxy.registerRenderers();
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
|
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package machinemuse.powersuits.common.augmentation;
|
||||||
|
|
||||||
|
public abstract class Augmentation {
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
|
public abstract float getWeight();
|
||||||
|
|
||||||
|
public abstract boolean isValidForSlot(int slot);
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.block;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.common.CommonProxy;
|
||||||
|
import machinemuse.powersuits.common.Config;
|
||||||
|
import machinemuse.powersuits.common.PowersuitsMod;
|
||||||
|
import machinemuse.powersuits.common.Config.Blocks;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
5
machinemuse/powersuits/common/item/IModularItem.java
Normal file
5
machinemuse/powersuits/common/item/IModularItem.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package machinemuse.powersuits.common.item;
|
||||||
|
|
||||||
|
public interface IModularItem {
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.item;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.common.CommonProxy;
|
||||||
|
import machinemuse.powersuits.common.Config;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumArmorMaterial;
|
import net.minecraft.item.EnumArmorMaterial;
|
||||||
|
@ -9,8 +11,9 @@ import net.minecraft.util.DamageSource;
|
||||||
import net.minecraftforge.common.ISpecialArmor;
|
import net.minecraftforge.common.ISpecialArmor;
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
|
||||||
public class ItemPowerArmor extends ItemArmor implements ISpecialArmor {
|
public class ItemPowerArmor extends ItemArmor implements ISpecialArmor,
|
||||||
protected ItemPowerArmor(Config.Items item) {
|
IModularItem {
|
||||||
|
public ItemPowerArmor(Config.Items item) {
|
||||||
super(Config.getAssignedItemID(item), // itemID
|
super(Config.getAssignedItemID(item), // itemID
|
||||||
EnumArmorMaterial.IRON, // Material
|
EnumArmorMaterial.IRON, // Material
|
||||||
item.iconIndex, // Texture index
|
item.iconIndex, // Texture index
|
|
@ -1,8 +1,8 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.item;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
public class ItemPowerTool extends Item {
|
public class ItemPowerTool extends Item implements IModularItem {
|
||||||
|
|
||||||
public ItemPowerTool(int par1) {
|
public ItemPowerTool(int par1) {
|
||||||
super(par1);
|
super(par1);
|
|
@ -1,7 +1,8 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public abstract class AugLayout {
|
public abstract class AugLayout {
|
||||||
private List<AugSlot> slots;
|
private List<AugSlot> slots;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class AugSlot {
|
public class AugSlot {
|
||||||
private List<AugSlot> connectedSlots;
|
private List<AugSlot> connectedSlots;
|
||||||
private SlotType type;
|
private SlotType type;
|
|
@ -1,7 +1,8 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.common.item.ItemPowerArmor;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
|
@ -1,7 +1,9 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.common.item.ItemPowerArmor;
|
||||||
|
import machinemuse.powersuits.common.item.ItemPowerTool;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
|
@ -1,8 +1,10 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import machinemuse.powersuits.common.Config;
|
||||||
|
import machinemuse.powersuits.common.Config.Items;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
|
@ -1,4 +1,4 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
|
@ -1,4 +1,4 @@
|
||||||
package machinemuse.powersuits.common;
|
package machinemuse.powersuits.common.trash;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
29
machinemuse/powersuits/gui/Clickable.java
Normal file
29
machinemuse/powersuits/gui/Clickable.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package machinemuse.powersuits.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import machinemuse.general.geometry.Point2D;
|
||||||
|
|
||||||
|
public abstract class Clickable {
|
||||||
|
private Point2D position;
|
||||||
|
|
||||||
|
public Clickable() {
|
||||||
|
position = new Point2D(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Clickable(Point2D point) {
|
||||||
|
position = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2D getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(Point2D position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean hitBox(float x, float y);
|
||||||
|
|
||||||
|
public abstract List<String> getToolTip();
|
||||||
|
}
|
19
machinemuse/powersuits/gui/ClickableAugmentation.java
Normal file
19
machinemuse/powersuits/gui/ClickableAugmentation.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package machinemuse.powersuits.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ClickableAugmentation extends Clickable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hitBox(float x, float y) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getToolTip() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
machinemuse/powersuits/gui/ClickableItem.java
Normal file
29
machinemuse/powersuits/gui/ClickableItem.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package machinemuse.powersuits.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import machinemuse.general.geometry.Point2D;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ClickableItem extends Clickable {
|
||||||
|
public static final Point2D offset = new Point2D(8, 8);
|
||||||
|
private ItemStack item;
|
||||||
|
|
||||||
|
public ClickableItem(ItemStack item, Point2D pos) {
|
||||||
|
super(pos);
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hitBox(float x, float y) {
|
||||||
|
boolean hitx = Math.abs(x - getPosition().getX()) < offset.getX();
|
||||||
|
boolean hity = Math.abs(y - getPosition().getY()) < offset.getY();
|
||||||
|
return hitx && hity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getToolTip() {
|
||||||
|
return item.getTooltip(null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
87
machinemuse/powersuits/gui/GuiTinkerTable.java
Normal file
87
machinemuse/powersuits/gui/GuiTinkerTable.java
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
package machinemuse.powersuits.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import machinemuse.general.geometry.Colour;
|
||||||
|
import machinemuse.powersuits.common.item.IModularItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class GuiTinkerTable extends MuseGui {
|
||||||
|
protected EntityPlayer player;
|
||||||
|
protected ArrayList<ItemStack> modularItems;
|
||||||
|
|
||||||
|
public GuiTinkerTable(EntityPlayer player) {
|
||||||
|
this.player = player;
|
||||||
|
this.modularItems = new ArrayList<ItemStack>();
|
||||||
|
this.xSize = 256;
|
||||||
|
this.ySize = 226;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the buttons (and other controls) to the screen in question.
|
||||||
|
*/
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||||
|
ItemStack stack = player.inventory.getStackInSlot(i);
|
||||||
|
if (stack != null && stack.getItem() instanceof IModularItem) {
|
||||||
|
modularItems.add(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void drawNthItem(ItemStack stack, int n) {
|
||||||
|
// // TBI
|
||||||
|
// // draw item
|
||||||
|
// // draw a button if it's moddable
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void drawSelection() {
|
||||||
|
// // if(selectedSlot != null) {
|
||||||
|
// // drawCircleAround(selectedSlot.position, renderEngine, selectedSlot);
|
||||||
|
// // }
|
||||||
|
// // for (Augmentation a : Augmentation.getAllAugs()) {
|
||||||
|
// // if (a.canGoInSlot(selectedSlot.getType())) {
|
||||||
|
// //
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public void drawLayout(AugLayout layout) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
public void drawBackground() {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
this.drawRectangularBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawScreen(int par1, int par2, float par3) {
|
||||||
|
super.drawScreen(par1, par2, par3);
|
||||||
|
drawBackground();
|
||||||
|
drawItemList();
|
||||||
|
Colour colour = Colour.getGreyscale(1.0F, 1.0F);
|
||||||
|
// if (editingItem != null && editingLayout != null) {
|
||||||
|
// drawLayout(editingLayout);
|
||||||
|
// if (selectedSlot != null) {
|
||||||
|
// drawSelection();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawItemList() {
|
||||||
|
this.drawItemsOnVerticalLine(modularItems, -0.9F, 0.0F,
|
||||||
|
0.9f,
|
||||||
|
this.mc.renderEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
212
machinemuse/powersuits/gui/MuseGui.java
Normal file
212
machinemuse/powersuits/gui/MuseGui.java
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
package machinemuse.powersuits.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import machinemuse.general.geometry.Colour;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.renderer.RenderEngine;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class MuseGui extends GuiScreen {
|
||||||
|
protected static RenderItem itemRenderer = new RenderItem();
|
||||||
|
private final boolean usePretty = true;
|
||||||
|
private static final int numSegments = 360;
|
||||||
|
private static final int xcenter = 8;
|
||||||
|
private static final int ycenter = 8;
|
||||||
|
private static final Tessellator tesselator = Tessellator.instance;
|
||||||
|
private long creationTime;
|
||||||
|
int xSize, ySize;
|
||||||
|
|
||||||
|
public static final double theta = (2 * Math.PI) / numSegments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the buttons (and other controls) to the screen in question.
|
||||||
|
*/
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
this.controlList.clear();
|
||||||
|
Keyboard.enableRepeatEvents(true);
|
||||||
|
creationTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawRectangularBackground() {
|
||||||
|
int xpadding = (width - xSize) / 2;
|
||||||
|
int ypadding = (height - ySize) / 2;
|
||||||
|
|
||||||
|
drawGradientRect(
|
||||||
|
xpadding, ypadding,
|
||||||
|
xpadding + xSize, ypadding + ySize,
|
||||||
|
Colour.getGreyscale(0.8f, 0.8f),
|
||||||
|
Colour.getGreyscale(0.3f, 0.8f));
|
||||||
|
|
||||||
|
// GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
// GL11.glEnable(GL11.GL_LINE_SMOOTH);
|
||||||
|
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
// GL11.glBegin(GL11.GL_QUADS);
|
||||||
|
// GL11.glColor4f(0.5f, 0.5f, 0.5f, 0.8f);
|
||||||
|
// GL11.glVertex2d(0, 0);
|
||||||
|
// GL11.glVertex2d(width - 10, 0);
|
||||||
|
// GL11.glVertex2d(width - 10, height - 10);
|
||||||
|
// GL11.glVertex2d(0, height - 10);
|
||||||
|
// GL11.glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawItemsOnVerticalLine(ArrayList<ItemStack> items,
|
||||||
|
float xoffset,
|
||||||
|
float yoffset,
|
||||||
|
float lineheight, RenderEngine engine) {
|
||||||
|
if (items.size() < 1) {
|
||||||
|
return;
|
||||||
|
} else if (items.size() < 2) {
|
||||||
|
drawItemAt(xoffset, yoffset, engine, items.get(0));
|
||||||
|
} else {
|
||||||
|
float step = 2 * lineheight / (items.size() - 1);
|
||||||
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
drawItemAt(xoffset, yoffset - lineheight + i * step, engine,
|
||||||
|
items.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns absolute screen coordinates (0 to width) from a relative
|
||||||
|
* coordinate (-1.0F to +1.0F)
|
||||||
|
*
|
||||||
|
* @param relx
|
||||||
|
* Relative X coordinate
|
||||||
|
* @return Absolute X coordinate
|
||||||
|
*/
|
||||||
|
public int absX(float relx) {
|
||||||
|
int absx = (int) ((relx + 1) * xSize / 2);
|
||||||
|
int xpadding = (width - xSize) / 2;
|
||||||
|
return absx + xpadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns absolute screen coordinates (0 to width) from a relative
|
||||||
|
* coordinate (-1.0F to +1.0F)
|
||||||
|
*
|
||||||
|
* @param relx
|
||||||
|
* Relative Y coordinate
|
||||||
|
* @return Absolute Y coordinate
|
||||||
|
*/
|
||||||
|
public int absY(float rely) {
|
||||||
|
int absy = (int) ((rely + 1) * ySize / 2);
|
||||||
|
int ypadding = (height - ySize) / 2;
|
||||||
|
return absy + ypadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the specified itemstack at the *relative* coordinates x,y. Used
|
||||||
|
* mainly in clickables.
|
||||||
|
*/
|
||||||
|
public void drawItemAt(float x, float y, RenderEngine engine,
|
||||||
|
ItemStack item) {
|
||||||
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
|
// GL11.glDepthFunc(GL11.GL_GREATER);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
|
||||||
|
itemRenderer.zLevel = 100.0F;
|
||||||
|
itemRenderer.renderItemAndEffectIntoGUI(this.fontRenderer, engine,
|
||||||
|
item, absX(x) - xcenter, absY(y) - ycenter);
|
||||||
|
Minecraft.getMinecraft().fontRenderer.drawString(
|
||||||
|
item.getItem().getItemDisplayName(item).substring(12, 16),
|
||||||
|
absX(x) - xcenter, absY(y) - ycenter,
|
||||||
|
Colour.getGreyscale(1.0F, 1.0F).getInt());
|
||||||
|
// drawCircleAround(absX(x), absY(y), 8);
|
||||||
|
itemRenderer.zLevel = 0.0F;
|
||||||
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||||
|
// GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawCircleAround(float xoffset, float yoffset,
|
||||||
|
float radius) {
|
||||||
|
int start = (int) (System.currentTimeMillis() / 4 % 360);
|
||||||
|
double x = radius * Math.sin(theta * start);
|
||||||
|
double y = radius * Math.cos(theta * start);
|
||||||
|
double tf = Math.tan(theta);
|
||||||
|
double rf = Math.cos(theta);
|
||||||
|
double tx;
|
||||||
|
double ty;
|
||||||
|
Colour c = new Colour(0.0f, 1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
texturelessOn();
|
||||||
|
|
||||||
|
GL11.glBegin(GL11.GL_LINE_LOOP);
|
||||||
|
for (int i = 0; i < numSegments; i++) {
|
||||||
|
GL11.glColor4f(c.r, c.g, c.b, c.a);
|
||||||
|
GL11.glVertex2d(x + xoffset, y + yoffset);
|
||||||
|
tx = y;
|
||||||
|
ty = -x;
|
||||||
|
x += tx * tf;
|
||||||
|
y += ty * tf;
|
||||||
|
x *= rf;
|
||||||
|
y *= rf;
|
||||||
|
c.r += theta / 7;
|
||||||
|
c.b += theta / 7;
|
||||||
|
c.a += theta / 2;
|
||||||
|
}
|
||||||
|
GL11.glEnd();
|
||||||
|
|
||||||
|
texturelessOff();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call before doing any pure geometry (ie. with colours rather than
|
||||||
|
* textures).
|
||||||
|
*/
|
||||||
|
public static void texturelessOn() {
|
||||||
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_LINE_SMOOTH);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call after doing pure geometry (ie. with colours) to go back to the
|
||||||
|
* texture mode (default).
|
||||||
|
*/
|
||||||
|
public static void texturelessOff() {
|
||||||
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a rectangle with a vertical gradient between the specified colors.
|
||||||
|
*/
|
||||||
|
protected void drawGradientRect(int left, int top, int right, int bottom,
|
||||||
|
Colour c1, Colour c2)
|
||||||
|
{
|
||||||
|
texturelessOn();
|
||||||
|
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setColorRGBA_F(c1.r, c1.g, c1.b, c1.a);
|
||||||
|
tessellator.addVertex((double) right, (double) top,
|
||||||
|
(double) this.zLevel);
|
||||||
|
tessellator
|
||||||
|
.addVertex((double) left, (double) top, (double) this.zLevel);
|
||||||
|
|
||||||
|
tessellator.setColorRGBA_F(c2.r, c2.g, c2.b, c2.a);
|
||||||
|
tessellator.addVertex((double) left, (double) bottom,
|
||||||
|
(double) this.zLevel);
|
||||||
|
tessellator.addVertex((double) right, (double) bottom,
|
||||||
|
(double) this.zLevel);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
texturelessOff();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue