Finished Arcane Packager gui

This commit is contained in:
makeo committed 2015-11-16 22:55:24 +01:00
1 parent 327057f82f
commit ee4ced0a7a
7 files changed
+118 -16

No files matched your search

@@ -1,14 +1,19 @@
package makeo.gadomancy.client.gui;
import makeo.gadomancy.common.blocks.tiles.TileArcanePackager;
import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw;
import makeo.gadomancy.common.containers.ContainerArcanePackager;
import makeo.gadomancy.common.utils.ColorHelper;
import makeo.gadomancy.common.utils.SimpleResourceLocation;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import java.awt.*;
/**
* This class is part of the Gadomancy Mod
* Gadomancy is Open Source and distributed under the
@@ -34,16 +39,21 @@ public class ArcanePackagerGui extends GuiContainer {
@Override
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
GL11.glEnable(GL11.GL_BLEND);
this.mc.renderEngine.bindTexture(TEXTURE);
int baseX = this.guiLeft;
int baseY = this.guiTop;
drawTexturedModalRect(89, 67, 210, 0, tile.progress, 9);
drawTexturedModalRect(baseX + 89, baseY + 67, 210, 0, tile.progress, 9);
if(tile.autoStart) {
drawTexturedModalRect(baseX + 89, baseY + 67, 210, 0, 8, 8);
if(tile.useEssentia) {
drawTexturedModalRect(91, 97, 249, 10, 8, 8);
}
if(tile.autoStart) {
drawTexturedModalRect(91, 110, 249, 10, 8, 8);
}
if(tile.disguise) {
drawTexturedModalRect(91, 123, 249, 10, 8, 8);
}
GL11.glDisable(GL11.GL_BLEND);
}
@@ -56,11 +66,53 @@ public class ArcanePackagerGui extends GuiContainer {
int var5 = (this.width - this.xSize) / 2;
int var6 = (this.height - this.ySize) / 2;
drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
drawString(100, 98, "gadomancy.info.ArcanePackager.useEssentia", tile.useEssentia ? Color.WHITE : Color.GRAY);
drawString(100, 111, "gadomancy.info.ArcanePackager.autoStart", tile.autoStart ? Color.WHITE : Color.GRAY);
drawString(100, 124, "gadomancy.info.ArcanePackager.disguisePackage", tile.disguise ? Color.WHITE : Color.GRAY);
GL11.glDisable(GL11.GL_BLEND);
}
private void drawString(int x, int y, String unlocalized, Color color) {
GL11.glPushMatrix();
GL11.glTranslatef(this.guiLeft + x, this.guiTop + y, 0);
GL11.glScalef(0.5F, 0.5F, 0.0F);
this.fontRendererObj.drawString(StatCollector.translateToLocal(unlocalized), 0, 0, ColorHelper.toHex(color));
GL11.glPopMatrix();
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
int baseX = (this.width - this.xSize) / 2;
int baseY = (this.height - this.ySize) / 2;
int checkX = x - baseX - 90;
int checkY = y - baseY - 97;
if(checkX >= 0 && checkX < 8 && checkY >= 0 && checkY < 8) {
tile.useEssentia = !tile.useEssentia;
this.mc.playerController.sendEnchantPacket(this.inventorySlots.windowId, tile.useEssentia ? 0 : 1);
}
checkY = y - baseY - 110;
if(checkX >= 0 && checkX < 8 && checkY >= 0 && checkY < 8) {
tile.autoStart = !tile.autoStart;
this.mc.playerController.sendEnchantPacket(this.inventorySlots.windowId, tile.autoStart ? 2 : 3);
}
checkY = y - baseY - 123;
if(checkX >= 0 && checkX < 8 && checkY >= 0 && checkY < 8) {
tile.disguise = !tile.disguise;
this.mc.playerController.sendEnchantPacket(this.inventorySlots.windowId, tile.disguise ? 4 : 5);
}
}
}
@@ -96,10 +96,10 @@ public class InfusionClawGui extends GuiContainer {
int checkX = x - baseX - 114;
int checkY = y - baseY - 36;
if(checkX >= 0 && checkX <= 8 && checkY >= 0 && checkY <= 8) {
if(checkX >= 0 && checkX < 8 && checkY >= 0 && checkY < 8) {
TileInfusionClaw tile = ((TileInfusionClaw)container.clawInv);
this.mc.playerController.sendEnchantPacket(this.inventorySlots.windowId, tile.isLocked() ? 0 : 1);
tile.setIsLocked(tile.isLocked());
tile.setIsLocked(!tile.isLocked());
}
}
}
@@ -85,7 +85,7 @@ public class BlockStoneMachine extends Block {
@Override
public boolean hasTileEntity(int metadata) {
return metadata == 15 || metadata == 0 || metadata == 1 || metadata == 2 || metadata == 3;// || metadata == 4;
return metadata == 15 || metadata == 0 || metadata == 1 || metadata == 2 || metadata == 3 || metadata == 4;
}
@Override
@@ -94,7 +94,7 @@ public class BlockStoneMachine extends Block {
list.add(new ItemStack(item, 1, 1));
list.add(new ItemStack(item, 1, 2));
list.add(new ItemStack(item, 1, 3));
//list.add(new ItemStack(item, 1, 4));
list.add(new ItemStack(item, 1, 4));
}
@Override
@@ -119,9 +119,9 @@ public class BlockStoneMachine extends Block {
return new TileBlockProtector();
} else if (metadata == 3) {
return new TileManipulationFocus();
}/* else if(metadata == 4) {
} else if(metadata == 4) {
return new TileArcanePackager();
}*/
}
return null;
}
@@ -219,10 +219,10 @@ public class BlockStoneMachine extends Block {
}
} else if (metadata == 1) {
return ConfigBlocks.blockStoneDevice.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
} /*else if(metadata == 4) {
} else if(metadata == 4) {
player.openGui(Gadomancy.instance, 2, world, x, y, z);
return true;
}*/
}
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}
@@ -5,6 +5,7 @@ import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/**
* This class is part of the Gadomancy Mod
@@ -18,10 +19,35 @@ public class TileArcanePackager extends SynchronizedTileEntity implements IInven
private ItemStack[] contents = new ItemStack[12];
//0 - 46
public int progress = 20;
public byte progress = 20;
public boolean autoStart = false;
public boolean useEssentia = false;
public boolean disguise = false;
@Override
public void readCustomNBT(NBTTagCompound compound) {
progress = compound.getByte("progress");
byte settings = compound.getByte("settings");
autoStart = (settings & 1) == 1;
useEssentia = (settings & 2) == 2;
disguise = (settings & 4) == 4;
}
@Override
public void writeCustomNBT(NBTTagCompound compound) {
compound.setByte("progress", progress);
byte settings = (byte) (autoStart ? 1 : 0);
settings |= useEssentia ? 2 : 0;
settings |= disguise ? 4 : 0;
compound.setByte("settings", settings);
}
public void markForUpdate() {
markDirty();
getWorldObj().markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public int getSizeInventory() {
@@ -1,5 +1,6 @@
package makeo.gadomancy.common.containers;
import makeo.gadomancy.common.blocks.tiles.TileArcanePackager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -46,6 +47,24 @@ public class ContainerArcanePackager extends Container {
}
}
@Override
public boolean enchantItem(EntityPlayer player, int id) {
TileArcanePackager tile = (TileArcanePackager) packagerInv;
switch (id) {
case 0: tile.useEssentia = true; break;
case 1: tile.useEssentia = false; break;
case 2: tile.autoStart = true; break;
case 3: tile.autoStart = false; break;
case 4: tile.disguise = true; break;
case 5: tile.disguise = false; break;
}
tile.markForUpdate();
return false;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;