mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-20 12:29:50 +00:00
Chisel item refactor.
Add chisel slot to autochisel. Refactor slot tooltip and valid items.
This commit is contained in:
1 parent
9202778b4d
commit
71e839831f
21 files changed
+288
-318
No files matched your search
@@ -13,15 +13,19 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
|
||||
import com.cricketcraft.chisel.inventory.ContainerAutoChisel;
|
||||
import com.cricketcraft.chisel.inventory.ContainerAutoChisel.SlotUpgrade;
|
||||
import com.cricketcraft.chisel.inventory.ContainerAutoChisel.SlotAutoChisel;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class GuiAutoChisel extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png");
|
||||
|
||||
private TileEntityAutoChisel autochisel;
|
||||
|
||||
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) {
|
||||
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
|
||||
autochisel = tileEntityAutoChisel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -34,16 +38,17 @@ public class GuiAutoChisel extends GuiContainer {
|
||||
|
||||
for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
|
||||
if (mouseInside(slot, mouseX - x, mouseY - y)) {
|
||||
if (slot instanceof SlotUpgrade) {
|
||||
this.func_146283_a(Lists.newArrayList(((SlotUpgrade) slot).upgradeType.getLocalizedName()), mouseX - x, mouseY - y);
|
||||
} else if (slot.slotNumber == 1) {
|
||||
this.func_146283_a(Lists.newArrayList(StatCollector.translateToLocal("autochisel.slot.target.tooltip")), mouseX - x, mouseY - y);
|
||||
if (slot instanceof SlotAutoChisel) {
|
||||
String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
|
||||
if (!Strings.isNullOrEmpty(tt)) {
|
||||
this.func_146283_a(Lists.newArrayList(StatCollector.translateToLocal(tt)), mouseX - x, mouseY - y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
}
|
||||
|
||||
|
||||
private boolean mouseInside(Slot slot, int x, int y) {
|
||||
return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16 && y >= slot.yDisplayPosition && y <= slot.yDisplayPosition + 16;
|
||||
}
|
||||
|
||||
@@ -116,29 +116,19 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
||||
|
||||
private static EntityItem ghostItem;
|
||||
|
||||
private final RenderItem renderTargetAndChisel, renderBase;
|
||||
private final RenderItem renderItem;
|
||||
|
||||
public RenderAutoChisel() {
|
||||
Chisel.renderAutoChiselId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
renderTargetAndChisel = new RenderItem() {
|
||||
renderItem = new RenderItem() {
|
||||
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
renderTargetAndChisel.setRenderManager(RenderManager.instance);
|
||||
|
||||
renderBase = new RenderItem() {
|
||||
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
renderBase.setRenderManager(RenderManager.instance);
|
||||
renderItem.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
private static final Random rand = new Random();
|
||||
@@ -148,7 +138,7 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
||||
|
||||
// Render Blocks
|
||||
TileEntityAutoChisel autoChisel = (TileEntityAutoChisel) tile;
|
||||
EntityItem item = autoChisel.getItemForRendering(1);
|
||||
EntityItem item = autoChisel.getItemForRendering(TileEntityAutoChisel.TARGET);
|
||||
|
||||
rand.setSeed(tile.xCoord + tile.yCoord + tile.zCoord);
|
||||
rand.nextBoolean();
|
||||
@@ -170,17 +160,26 @@ public class RenderAutoChisel extends TileEntitySpecialRenderer implements ISimp
|
||||
GL11.glRotatef(autoChisel.zRot, 0, 0, 1);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
|
||||
renderTargetAndChisel.doRender(item, 0, 0, 0, 0, 0);
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
EntityItem item2 = autoChisel.getItemForRendering(0);
|
||||
|
||||
if (item2 != null) {
|
||||
item = autoChisel.getItemForRendering(TileEntityAutoChisel.BASE);
|
||||
if (item != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.4, y + 0.83, z + 0.5);
|
||||
renderBase.doRender(item2, 0, 0, 0, 0, 0);
|
||||
GL11.glTranslated(x + 0.35, y + 0.934, z + 0.5);
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
item = autoChisel.getItemForRendering(TileEntityAutoChisel.CHISEL);
|
||||
if (item != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.7, y + 1, z + 0.5);
|
||||
GL11.glTranslated(-0.12, 0, 0);
|
||||
GL11.glScalef(0.9f, 0.9f, 0.9f);
|
||||
renderItem.doRender(item, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user