gui cheat overlay new files
This commit is contained in:
parent
424cf782bc
commit
705395472a
13 changed files with 2474 additions and 0 deletions
50
java/src/game/gui/container/GuiBrewing.java
Executable file
50
java/src/game/gui/container/GuiBrewing.java
Executable file
|
@ -0,0 +1,50 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.inventory.ContainerBrewingStand;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiBrewing extends GuiContainer
|
||||
{
|
||||
// private static final String brewingStandGuiTextures = "textures/gui/brewing_stand.png";
|
||||
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private IInventory tileBrewingStand;
|
||||
|
||||
public GuiBrewing(InventoryPlayer playerInv, IInventory p_i45506_2_)
|
||||
{
|
||||
super(new ContainerBrewingStand(playerInv, p_i45506_2_));
|
||||
this.playerInventory = playerInv;
|
||||
this.tileBrewingStand = p_i45506_2_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
String s = this.tileBrewingStand.getCommandName();
|
||||
this.drawString(s, 8, 6);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Args : renderPartialTicks, mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerBackgroundLayer()
|
||||
{
|
||||
int k = this.tileBrewingStand.getField(0);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
int l = (int)(28.0F * (1.0F - (float)k / 400.0F));
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
this.rect(97, 16, 9, l, 0xffff20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
53
java/src/game/gui/container/GuiChest.java
Executable file
53
java/src/game/gui/container/GuiChest.java
Executable file
|
@ -0,0 +1,53 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.ContainerChest;
|
||||
import game.inventory.IInventory;
|
||||
|
||||
|
||||
public class GuiChest extends GuiContainer
|
||||
{
|
||||
// /** The ResourceLocation containing the chest GUI texture. */
|
||||
// private static final String CHEST_GUI_TEXTURE = "textures/gui/generic_54.png";
|
||||
private IInventory upperChestInventory;
|
||||
private IInventory lowerChestInventory;
|
||||
|
||||
/**
|
||||
* window height is calculated with these values; the more rows, the heigher
|
||||
*/
|
||||
private int inventoryRows;
|
||||
|
||||
public GuiChest(IInventory upperInv, IInventory lowerInv)
|
||||
{
|
||||
super(new ContainerChest(upperInv, lowerInv, Game.getGame().thePlayer));
|
||||
this.upperChestInventory = upperInv;
|
||||
this.lowerChestInventory = lowerInv;
|
||||
// this.allowUserInput = false;
|
||||
int i = 222;
|
||||
int j = i - 108;
|
||||
this.inventoryRows = lowerInv.getSizeInventory() / 9;
|
||||
this.ySize = j + this.inventoryRows * 18;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.lowerChestInventory.getCommandName(), 8, 6);
|
||||
this.drawString(this.upperChestInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Args : renderPartialTicks, mouseX, mouseY
|
||||
*/
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
|
||||
//// this.rect(i, j + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
|
||||
// }
|
||||
}
|
1188
java/src/game/gui/container/GuiContainer.java
Executable file
1188
java/src/game/gui/container/GuiContainer.java
Executable file
File diff suppressed because it is too large
Load diff
42
java/src/game/gui/container/GuiCrafting.java
Executable file
42
java/src/game/gui/container/GuiCrafting.java
Executable file
|
@ -0,0 +1,42 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.inventory.ContainerWorkbench;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.world.BlockPos;
|
||||
import game.world.World;
|
||||
|
||||
public class GuiCrafting extends GuiContainer
|
||||
{
|
||||
// private static final String craftingTableGuiTextures = "textures/gui/crafting_table.png";
|
||||
|
||||
public GuiCrafting(InventoryPlayer playerInv, World worldIn)
|
||||
{
|
||||
this(playerInv, worldIn, BlockPos.ORIGIN);
|
||||
}
|
||||
|
||||
public GuiCrafting(InventoryPlayer playerInv, World worldIn, BlockPos blockPosition)
|
||||
{
|
||||
super(new ContainerWorkbench(playerInv, worldIn, blockPosition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString("Handwerk", 28, 6);
|
||||
this.drawString("Inventar", 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Args : renderPartialTicks, mouseX, mouseY
|
||||
// */
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(craftingTableGuiTextures);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
// }
|
||||
}
|
46
java/src/game/gui/container/GuiDispenser.java
Executable file
46
java/src/game/gui/container/GuiDispenser.java
Executable file
|
@ -0,0 +1,46 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.inventory.ContainerDispenser;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiDispenser extends GuiContainer
|
||||
{
|
||||
// private static final String dispenserGuiTextures = "textures/gui/dispenser.png";
|
||||
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
|
||||
/** The inventory contained within the corresponding Dispenser. */
|
||||
public IInventory dispenserInventory;
|
||||
|
||||
public GuiDispenser(InventoryPlayer playerInv, IInventory dispenserInv)
|
||||
{
|
||||
super(new ContainerDispenser(playerInv, dispenserInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.dispenserInventory = dispenserInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
String s = this.dispenserInventory.getCommandName();
|
||||
this.drawString(s, 8, 6);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Args : renderPartialTicks, mouseX, mouseY
|
||||
// */
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(dispenserGuiTextures);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
// }
|
||||
}
|
290
java/src/game/gui/container/GuiEnchant.java
Executable file
290
java/src/game/gui/container/GuiEnchant.java
Executable file
|
@ -0,0 +1,290 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.color.TextColor;
|
||||
import game.enchantment.Enchantment;
|
||||
import game.inventory.ContainerEnchantment;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.tileentity.IWorldNameable;
|
||||
import game.util.ExtMath;
|
||||
import game.world.World;
|
||||
|
||||
public class GuiEnchant extends GuiContainer
|
||||
{
|
||||
/** The ResourceLocation containing the Enchantment GUI texture location */
|
||||
// private static final String ENCHANTMENT_TABLE_GUI_TEXTURE = "textures/gui/enchanting_table.png";
|
||||
private static final String[] NAMES = "the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale ".split(" ");
|
||||
|
||||
/** The player inventory currently bound to this GuiEnchantment instance. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final Random nameRand = new Random();
|
||||
private final Random random = new Random();
|
||||
private final ContainerEnchantment container;
|
||||
private final IWorldNameable table;
|
||||
|
||||
public int field_147073_u;
|
||||
public float field_147071_v;
|
||||
public float field_147069_w;
|
||||
public float field_147082_x;
|
||||
public float field_147081_y;
|
||||
public float field_147080_z;
|
||||
public float field_147076_A;
|
||||
ItemStack field_147077_B;
|
||||
|
||||
public GuiEnchant(InventoryPlayer inventory, World worldIn, IWorldNameable table)
|
||||
{
|
||||
super(new ContainerEnchantment(inventory, worldIn));
|
||||
this.playerInventory = inventory;
|
||||
this.container = (ContainerEnchantment)this.inventorySlots;
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.table.getCommandName(), 12, 5);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the main game loop to update the screen.
|
||||
*/
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
this.func_147068_g();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
|
||||
*/
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
int l = mouseX - 60;
|
||||
int i1 = mouseY - (14 + 19 * k);
|
||||
|
||||
if (l >= 0 && i1 >= 0 && l < 108 && i1 < 19 && this.container.enchantItem(this.gm.thePlayer, k))
|
||||
{
|
||||
this.gm.controller.sendEnchantPacket(this.container.windowId, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addButtons() {
|
||||
super.addButtons();
|
||||
this.button(60, 14 + 19 * 0, 108, 19);
|
||||
this.button(60, 14 + 19 * 1, 108, 19);
|
||||
this.button(60, 14 + 19 * 2, 108, 19);
|
||||
}
|
||||
|
||||
/**
|
||||
* Args : renderPartialTicks, mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerBackgroundLayer()
|
||||
{
|
||||
this.nameRand.setSeed((long)this.container.xpSeed);
|
||||
|
||||
for (int l = 0; l < 3; ++l)
|
||||
{
|
||||
int i1 = 60;
|
||||
int j1 = i1 + 20;
|
||||
String s = this.getRandomName();
|
||||
int l1 = this.container.enchantLevels[l];
|
||||
|
||||
if (l1 == 0)
|
||||
{
|
||||
this.rect(i1, 14 + 19 * l, 108, 19, 0x404040);
|
||||
}
|
||||
else
|
||||
{
|
||||
String s1 = "" + l1;
|
||||
int i2 = 6839882;
|
||||
|
||||
if (/* (k < l + 1 || */ this.gm.thePlayer.experienceLevel < l1) // && !this.gm.thePlayer.creative)
|
||||
{
|
||||
this.rect(i1, 14 + 19 * l, 108, 19, 0x400000);
|
||||
this.rect(i1 + 1, 15 + 19 * l, 16, 16, 0x200000);
|
||||
this.drawString(s, j1, 16 + 19 * l); // , /*k1,*/ (i2 & 16711422) >> 1);
|
||||
i2 = 4226832;
|
||||
}
|
||||
else
|
||||
{
|
||||
// int j2 = SKC.getMouseX() - this.guiLeft - 60;
|
||||
// int k2 = SKC.getMouseY() - this.guiTop - (14 + 19 * l);
|
||||
|
||||
// if (j2 >= 0 && k2 >= 0 && j2 < 108 && k2 < 19)
|
||||
// {
|
||||
// this.rect(i1, 14 + 19 * l, 108, 19, 0x20ff20);
|
||||
// i2 = 16777088;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
this.rect(i1, 14 + 19 * l, 108, 19, 0x20ff20);
|
||||
// }
|
||||
|
||||
this.rect(i1 + 1, 15 + 19 * l, 16, 16, 0x008000);
|
||||
this.drawString(s, j1, 16 + 19 * l);
|
||||
i2 = 8453920;
|
||||
}
|
||||
|
||||
this.drawString(s1, j1 + 86 - this.getStringWidth(s1), 16 + 19 * l + 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
||||
*/
|
||||
public void drawScreen(int mouseX, int mouseY)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY);
|
||||
// boolean flag = this.gm.thePlayer.creative;
|
||||
// int i = this.container.getLapisAmount();
|
||||
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
int k = this.container.enchantLevels[j];
|
||||
int l = this.container.enchantmentIds[j];
|
||||
int i1 = j + 1;
|
||||
|
||||
if (this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l >= 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (l >= 0 && Enchantment.getEnchantmentById(l & 255) != null)
|
||||
{
|
||||
String s = Enchantment.getEnchantmentById(l & 255).getFormattedName((l & 65280) >> 8);
|
||||
sb.append(TextColor.WHITE + s + " . . . ?");
|
||||
}
|
||||
|
||||
// if (!flag)
|
||||
// {
|
||||
// if (l >= 0 && sb.length() != 0)
|
||||
// {
|
||||
// sb.append("\n");
|
||||
// }
|
||||
|
||||
if (this.gm.thePlayer.experienceLevel < k)
|
||||
{
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("Erfahrungsstufe %d erforderlich", this.container.enchantLevels[j]));
|
||||
}
|
||||
else
|
||||
{
|
||||
String s1 = "";
|
||||
|
||||
// if (i1 == 1)
|
||||
// {
|
||||
// s1 = I18n.format("container.enchant.lapis.one");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// s1 = I18n.format("container.enchant.lapis.many", i1);
|
||||
// }
|
||||
//
|
||||
// if (i >= i1)
|
||||
// {
|
||||
// list.add(ChatFormat.GRAY.toString() + "" + s1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// list.add(ChatFormat.RED.toString() + "" + s1);
|
||||
// }
|
||||
|
||||
if (i1 == 1)
|
||||
{
|
||||
s1 = "1 Erfahrungsstufe";
|
||||
}
|
||||
else
|
||||
{
|
||||
s1 = String.format("%d Erfahrungsstufen", i1);
|
||||
}
|
||||
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.LGRAY.toString() + "" + s1);
|
||||
}
|
||||
// }
|
||||
|
||||
this.hover(sb.toString(), mouseX, mouseY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getRandomName()
|
||||
{
|
||||
int i = this.nameRand.zrange(2) + 3;
|
||||
String s = "";
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
if (j > 0)
|
||||
{
|
||||
s = s + " ";
|
||||
}
|
||||
|
||||
String name = NAMES[this.nameRand.zrange(NAMES.length)];
|
||||
for(int z = 0; z < name.length(); z++) {
|
||||
s += (char)(name.charAt(z) - 0x61 + 0x80);
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private void func_147068_g()
|
||||
{
|
||||
ItemStack itemstack = this.inventorySlots.getSlot(0).getStack();
|
||||
|
||||
if (!ItemStack.areItemStacksEqual(itemstack, this.field_147077_B))
|
||||
{
|
||||
this.field_147077_B = itemstack;
|
||||
|
||||
while (true)
|
||||
{
|
||||
this.field_147082_x += (float)(this.random.zrange(4) - this.random.zrange(4));
|
||||
|
||||
if (this.field_147071_v > this.field_147082_x + 1.0F || this.field_147071_v < this.field_147082_x - 1.0F)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++this.field_147073_u;
|
||||
this.field_147069_w = this.field_147071_v;
|
||||
this.field_147076_A = this.field_147080_z;
|
||||
boolean flag = false;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (this.container.enchantLevels[i] != 0)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.field_147080_z += 0.2F;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_147080_z -= 0.2F;
|
||||
}
|
||||
|
||||
this.field_147080_z = ExtMath.clampf(this.field_147080_z, 0.0F, 1.0F);
|
||||
float f1 = (this.field_147082_x - this.field_147071_v) * 0.4F;
|
||||
float f = 0.2F;
|
||||
f1 = ExtMath.clampf(f1, -f, f);
|
||||
this.field_147081_y += (f1 - this.field_147081_y) * 0.9F;
|
||||
this.field_147071_v += this.field_147081_y;
|
||||
}
|
||||
}
|
71
java/src/game/gui/container/GuiFurnace.java
Executable file
71
java/src/game/gui/container/GuiFurnace.java
Executable file
|
@ -0,0 +1,71 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.inventory.ContainerFurnace;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.tileentity.TileEntityFurnace;
|
||||
|
||||
|
||||
public class GuiFurnace extends GuiContainer
|
||||
{
|
||||
// private static final String furnaceGuiTextures = "textures/gui/furnace.png";
|
||||
|
||||
/** The player inventory bound to this GUI. */
|
||||
private final InventoryPlayer playerInventory;
|
||||
private IInventory tileFurnace;
|
||||
|
||||
public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv)
|
||||
{
|
||||
super(new ContainerFurnace(playerInv, furnaceInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tileFurnace = furnaceInv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
String s = this.tileFurnace.getCommandName();
|
||||
this.drawString(s, 8, 6);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Args : renderPartialTicks, mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerBackgroundLayer()
|
||||
{
|
||||
this.rect(58, 36, 12, 14, 0x202020);
|
||||
if (TileEntityFurnace.isBurning(this.tileFurnace))
|
||||
{
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
k = Math.min(k, 13);
|
||||
this.rect(58, 36 + 13 - k, 12, k + 1, 0xff7f00);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
this.rect(79, 39, 24, 8, 0x606060);
|
||||
if(l > 0)
|
||||
this.rect(79, 39, l + 1, 8, 0xffaf00);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels)
|
||||
{
|
||||
int i = this.tileFurnace.getField(2);
|
||||
int j = this.tileFurnace.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels)
|
||||
{
|
||||
int i = this.tileFurnace.getField(1);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = 200;
|
||||
}
|
||||
|
||||
return this.tileFurnace.getField(0) * pixels / i;
|
||||
}
|
||||
}
|
49
java/src/game/gui/container/GuiHopper.java
Executable file
49
java/src/game/gui/container/GuiHopper.java
Executable file
|
@ -0,0 +1,49 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.ContainerHopper;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiHopper extends GuiContainer
|
||||
{
|
||||
// /** The ResourceLocation containing the gui texture for the hopper */
|
||||
// private static final String HOPPER_GUI_TEXTURE = "textures/gui/hopper.png";
|
||||
|
||||
/** The player inventory currently bound to this GUI instance */
|
||||
private IInventory playerInventory;
|
||||
|
||||
/** The hopper inventory bound to this GUI instance */
|
||||
private IInventory hopperInventory;
|
||||
|
||||
public GuiHopper(InventoryPlayer playerInv, IInventory hopperInv)
|
||||
{
|
||||
super(new ContainerHopper(playerInv, hopperInv, Game.getGame().thePlayer));
|
||||
this.playerInventory = playerInv;
|
||||
this.hopperInventory = hopperInv;
|
||||
// this.allowUserInput = false;
|
||||
this.ySize = 133;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.hopperInventory.getCommandName(), 8, 6);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Args : renderPartialTicks, mouseX, mouseY
|
||||
// */
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(HOPPER_GUI_TEXTURE);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
// }
|
||||
}
|
79
java/src/game/gui/container/GuiHorse.java
Executable file
79
java/src/game/gui/container/GuiHorse.java
Executable file
|
@ -0,0 +1,79 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.entity.animal.EntityHorse;
|
||||
import game.inventory.ContainerHorseInventory;
|
||||
import game.inventory.IInventory;
|
||||
|
||||
|
||||
public class GuiHorse extends GuiContainer
|
||||
{
|
||||
// private static final String horseGuiTextures = "textures/gui/horse.png";
|
||||
|
||||
/** The player inventory bound to this GUI. */
|
||||
private IInventory playerInventory;
|
||||
|
||||
/** The horse inventory bound to this GUI. */
|
||||
private IInventory horseInventory;
|
||||
|
||||
// /** The EntityHorse whose inventory is currently being accessed. */
|
||||
// private EntityHorse horseEntity;
|
||||
|
||||
// /** The mouse x-position recorded during the last rendered frame. */
|
||||
// private float mousePosx;
|
||||
//
|
||||
// /** The mouse y-position recorded during the last renderered frame. */
|
||||
// private float mousePosY;
|
||||
|
||||
public GuiHorse(IInventory playerInv, IInventory horseInv, EntityHorse horse)
|
||||
{
|
||||
super(new ContainerHorseInventory(playerInv, horseInv, horse, Game.getGame().thePlayer));
|
||||
this.playerInventory = playerInv;
|
||||
this.horseInventory = horseInv;
|
||||
// this.horseEntity = horse;
|
||||
// this.allowUserInput = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.horseInventory.getCommandName(), 8, 6);
|
||||
this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Args : renderPartialTicks, mouseX, mouseY
|
||||
// */
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(horseGuiTextures);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
//
|
||||
//// if (this.horseEntity.isChested())
|
||||
//// {
|
||||
//// this.rect(i + 79, j + 17, 0, this.ySize, 90, 54);
|
||||
//// }
|
||||
//
|
||||
//// if (this.horseEntity.canWearArmor())
|
||||
//// {
|
||||
//// this.rect(i + 7, j + 35, 0, this.ySize + 54, 18, 18);
|
||||
//// }
|
||||
//
|
||||
//// GuiInventory.drawEntityOnScreen(i + 51, j + 60, 17, (float)(i + 51) - this.mousePosx, (float)(j + 75 - 50) - this.mousePosY, this.horseEntity);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
||||
// */
|
||||
// public void drawScreen(int mouseX, int mouseY)
|
||||
// {
|
||||
// this.mousePosx = (float)mouseX;
|
||||
// this.mousePosY = (float)mouseY;
|
||||
// super.drawScreen(mouseX, mouseY);
|
||||
// }
|
||||
}
|
58
java/src/game/gui/container/GuiInventory.java
Executable file
58
java/src/game/gui/container/GuiInventory.java
Executable file
|
@ -0,0 +1,58 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.entity.npc.EntityNPC;
|
||||
|
||||
public class GuiInventory extends GuiContainer
|
||||
{
|
||||
// private final GuiCheat cheat;
|
||||
// private float oldMouseX;
|
||||
// private float oldMouseY;
|
||||
|
||||
public GuiInventory(EntityNPC player)
|
||||
{
|
||||
super(player.inventoryContainer);
|
||||
// this.allowUserInput = true;
|
||||
// this.cheat = cheat;
|
||||
}
|
||||
|
||||
// public void updateScreen()
|
||||
// {
|
||||
// this.updateActivePotionEffects();
|
||||
// }
|
||||
|
||||
// public void initGui()
|
||||
// {
|
||||
//// this.buttonList.clear();
|
||||
// super.initGui();
|
||||
// if(this.cheat != null)
|
||||
// this.buttonList.add(new Button(1, this.guiLeft + this.xSize - 16, this.guiTop + 4, 12, 12, "X"));
|
||||
// }
|
||||
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString("Handwerk", 86, 16);
|
||||
}
|
||||
|
||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
// {
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
// this.oldMouseX = (float)mouseX;
|
||||
// this.oldMouseY = (float)mouseY;
|
||||
// }
|
||||
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(inventoryBackground);
|
||||
// int i = this.guiLeft;
|
||||
// int j = this.guiTop;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
//// drawEntityOnScreen(i + 51, j + 75, 30, (float)(i + 51) - this.oldMouseX, (float)(j + 75 - 50) - this.oldMouseY, this.gm.thePlayer);
|
||||
// }
|
||||
|
||||
// public void actionPerformed(int button)
|
||||
// {
|
||||
// if(button == 1 && this.cheat != null && this.gm.thePlayer.inventory.getItemStack() == null)
|
||||
// this.gm.displayGuiScreen(this.cheat);
|
||||
// }
|
||||
}
|
44
java/src/game/gui/container/GuiMachine.java
Executable file
44
java/src/game/gui/container/GuiMachine.java
Executable file
|
@ -0,0 +1,44 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.ContainerMachine;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.tileentity.TileEntityMachine;
|
||||
|
||||
|
||||
public class GuiMachine extends GuiContainer
|
||||
{
|
||||
// private final String texture;
|
||||
private final IInventory playerInv;
|
||||
private final IInventory machineInv;
|
||||
private final TileEntityMachine machine;
|
||||
|
||||
public GuiMachine(InventoryPlayer player, IInventory inv, TileEntityMachine machine)
|
||||
{
|
||||
super(new ContainerMachine(player, machine, inv, Game.getGame().thePlayer));
|
||||
this.playerInv = player;
|
||||
this.machineInv = machine;
|
||||
// this.allowUserInput = false;
|
||||
this.ySize = 153;
|
||||
// this.texture = "textures/gui/" + texture + ".png";
|
||||
this.machine = machine;
|
||||
}
|
||||
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
this.drawString(this.machine.getStatus().color + this.machineInv.getCommandName() + " - " + this.machine.getStatus().name, 8, 6);
|
||||
this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.drawString(String.format("Temperatur: %d °", this.machine.getTemperature()), 8, 18);
|
||||
this.drawString(this.machine.formatDisplay(), 8, 28);
|
||||
}
|
||||
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(this.texture);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
// }
|
||||
}
|
286
java/src/game/gui/container/GuiMerchant.java
Executable file
286
java/src/game/gui/container/GuiMerchant.java
Executable file
|
@ -0,0 +1,286 @@
|
|||
package game.gui.container;
|
||||
|
||||
import game.inventory.ContainerMerchant;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.item.ItemStack;
|
||||
import game.packet.CPacketAction;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.ItemRenderer;
|
||||
import game.village.MerchantRecipe;
|
||||
import game.village.MerchantRecipeList;
|
||||
import game.window.WCF;
|
||||
import game.world.World;
|
||||
|
||||
public class GuiMerchant extends GuiContainer
|
||||
{
|
||||
// private static final String MERCHANT_GUI_TEXTURE = "textures/gui/trading.png";
|
||||
|
||||
private int selectedMerchantRecipe;
|
||||
private String chatComponent;
|
||||
|
||||
public GuiMerchant(InventoryPlayer inv, String name, World worldIn)
|
||||
{
|
||||
super(new ContainerMerchant(inv, null, worldIn));
|
||||
this.chatComponent = name != null ? name : "NSC";
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
||||
* window resizes, the buttonList is cleared beforehand.
|
||||
*/
|
||||
// public void initGui()
|
||||
// {
|
||||
// super.initGui();
|
||||
// }
|
||||
|
||||
public void addButtons() {
|
||||
super.addButtons();
|
||||
this.button(120 + 27, 24, 12, 16);
|
||||
this.button(36 - 19, 24, 12, 16);
|
||||
this.button(36 - 1, 24 - 1, 18, 18);
|
||||
this.button(62 - 1, 24 - 1, 18, 18);
|
||||
this.button(120 - 1, 24 - 1, 18, 18);
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
{
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
if(mouseX >= 147 && mouseX < 147 + 12 && mouseY >= 24 && mouseY < 24 + 16) {
|
||||
this.switchTrade(true);
|
||||
return;
|
||||
}
|
||||
else if(mouseX >= 17 && mouseX < 17 + 12 && mouseY >= 24 && mouseY < 24 + 16) {
|
||||
this.switchTrade(false);
|
||||
return;
|
||||
}
|
||||
// this.buttonList.add(new Button(1, i + 120 + 27, j + 24 - 1, 12, 19, ">"));
|
||||
// this.buttonList.add(new Button(2, i + 36 - 19, j + 24 - 1, 12, 19, "<"));
|
||||
|
||||
}
|
||||
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
String s = this.chatComponent;
|
||||
this.drawString(s, 8, 6);
|
||||
this.drawString("Inventar", 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
public void drawOverlays() {
|
||||
super.drawOverlays();
|
||||
MerchantRecipeList merchantrecipelist = this.getRecipes();
|
||||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
|
||||
int k = this.selectedMerchantRecipe;
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
|
||||
ItemStack itemstack = merchantrecipe.getItemToBuy();
|
||||
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
|
||||
ItemStack itemstack2 = merchantrecipe.getItemToSell();
|
||||
this.renderItemOverlayIntoGUI(itemstack, 36, 24, null);
|
||||
if(itemstack1 != null)
|
||||
this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null);
|
||||
this.renderItemOverlayIntoGUI(itemstack2, 120, 24, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
||||
*/
|
||||
public void switchTrade(boolean forward)
|
||||
{
|
||||
boolean flag = false;
|
||||
|
||||
if (forward)
|
||||
{
|
||||
++this.selectedMerchantRecipe;
|
||||
MerchantRecipeList merchantrecipelist = this.getRecipes();
|
||||
|
||||
if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size())
|
||||
{
|
||||
this.selectedMerchantRecipe = merchantrecipelist.size() - 1;
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
--this.selectedMerchantRecipe;
|
||||
|
||||
if (this.selectedMerchantRecipe < 0)
|
||||
{
|
||||
this.selectedMerchantRecipe = 0;
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe);
|
||||
// PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
|
||||
// packetbuffer.writeInt(this.selectedMerchantRecipe);
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.SELECT_TRADE,
|
||||
this.selectedMerchantRecipe));
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Args : renderPartialTicks, mouseX, mouseY
|
||||
// */
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(MERCHANT_GUI_TEXTURE);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
//// MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.gm.thePlayer);
|
||||
//
|
||||
//// if (merchantrecipelist != null && !merchantrecipelist.isEmpty())
|
||||
//// {
|
||||
//// int k = this.selectedMerchantRecipe;
|
||||
////
|
||||
//// if (k < 0 || k >= merchantrecipelist.size())
|
||||
//// {
|
||||
//// return;
|
||||
//// }
|
||||
//
|
||||
//// MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
|
||||
//
|
||||
//// if (merchantrecipe.isRecipeDisabled())
|
||||
//// {
|
||||
//// this.gm.getTextureManager().bindTexture(MERCHANT_GUI_TEXTURE);
|
||||
//// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//// GlState.disableLighting();
|
||||
//// this.rect(this.guiLeft + 83, this.guiTop + 21, 212, 0, 28, 21);
|
||||
//// this.rect(this.guiLeft + 83, this.guiTop + 51, 212, 0, 28, 21);
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
||||
*/
|
||||
public void drawScreen(int mouseX, int mouseY)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY);
|
||||
MerchantRecipeList merchantrecipelist = this.getRecipes();
|
||||
|
||||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty())
|
||||
{
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
int k = this.selectedMerchantRecipe;
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
|
||||
ItemStack itemstack = merchantrecipe.getItemToBuy();
|
||||
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
|
||||
ItemStack itemstack2 = merchantrecipe.getItemToSell();
|
||||
WCF.glPushMatrix();
|
||||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
GlState.disableLighting();
|
||||
GlState.enableRescaleNormal();
|
||||
GlState.enableColorMaterial();
|
||||
GlState.enableLighting();
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack, 36, 24);
|
||||
// this.itemRender.renderItemOverlays(itemstack, 36, 24);
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack1, 62, 24);
|
||||
// this.itemRender.renderItemOverlays(itemstack1, 62, 24);
|
||||
}
|
||||
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack2, 120, 24);
|
||||
// this.itemRender.renderItemOverlays(itemstack2, 120, 24);
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
GlState.disableLighting();
|
||||
|
||||
if (this.isPointInRegion(36, 24, 16, 16, mouseX, mouseY) && itemstack != null)
|
||||
{
|
||||
this.renderToolTip(itemstack, mouseX, mouseY);
|
||||
}
|
||||
else if (itemstack1 != null && this.isPointInRegion(62, 24, 16, 16, mouseX, mouseY) && itemstack1 != null)
|
||||
{
|
||||
this.renderToolTip(itemstack1, mouseX, mouseY);
|
||||
}
|
||||
else if (itemstack2 != null && this.isPointInRegion(120, 24, 16, 16, mouseX, mouseY) && itemstack2 != null)
|
||||
{
|
||||
this.renderToolTip(itemstack2, mouseX, mouseY);
|
||||
}
|
||||
// else if (merchantrecipe.isRecipeDisabled() && (this.isPointInRegion(83, 21, 28, 21, mouseX, mouseY) || this.isPointInRegion(83, 51, 28, 21, mouseX, mouseY)))
|
||||
// {
|
||||
// this.drawCreativeTabHoveringText(I18n.format("merchant.deprecated"), mouseX, mouseY);
|
||||
// }
|
||||
|
||||
WCF.glPopMatrix();
|
||||
GlState.enableLighting();
|
||||
GlState.enableDepth();
|
||||
ItemRenderer.enableStandardItemLighting();
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
// if(mouseX >= i + 147 && mouseX < i + 147 + 12 && mouseY >= j + 23 && mouseX < j + 23 + 19) {
|
||||
// SKC.highlight(i + 147, j + 23, 12, 19);
|
||||
// }
|
||||
// else if(mouseX >= i + 17 && mouseX < i + 17 + 12 && mouseY >= j + 23 && mouseX < j + 23 + 19) {
|
||||
// SKC.highlight(i + 17, j + 23, 12, 19);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void setRecipes(MerchantRecipeList recipes)
|
||||
{
|
||||
((ContainerMerchant)this.inventorySlots).getMerchantInventory().setRecipes(recipes);
|
||||
}
|
||||
|
||||
private MerchantRecipeList getRecipes()
|
||||
{
|
||||
return ((ContainerMerchant)this.inventorySlots).getMerchantInventory().getRecipes();
|
||||
}
|
||||
|
||||
// static class MerchantButton extends Button
|
||||
// {
|
||||
// private final boolean next;
|
||||
//
|
||||
// public MerchantButton(int buttonID, int x, int y, boolean isNext)
|
||||
// {
|
||||
// super(buttonID, x, y, 12, 19, "");
|
||||
// this.next = isNext;
|
||||
// }
|
||||
//
|
||||
// public void drawButton(Game gm, int mouseX, int mouseY)
|
||||
// {
|
||||
// if (this.visible)
|
||||
// {
|
||||
// gm.getTextureManager().bindTexture(GuiMerchant.MERCHANT_GUI_TEXTURE);
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||
// int i = 0;
|
||||
// int j = 176;
|
||||
//
|
||||
// if (!this.enabled)
|
||||
// {
|
||||
// j += this.width * 2;
|
||||
// }
|
||||
// else if (flag)
|
||||
// {
|
||||
// j += this.width;
|
||||
// }
|
||||
//
|
||||
// if (!this.next)
|
||||
// {
|
||||
// i += this.height;
|
||||
// }
|
||||
//
|
||||
// this.rect(this.xPosition, this.yPosition, j, i, this.width, this.height);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
218
java/src/game/gui/container/GuiRepair.java
Executable file
218
java/src/game/gui/container/GuiRepair.java
Executable file
|
@ -0,0 +1,218 @@
|
|||
package game.gui.container;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.Game;
|
||||
import game.inventory.Container;
|
||||
import game.inventory.ContainerRepair;
|
||||
import game.inventory.ICrafting;
|
||||
import game.inventory.IInventory;
|
||||
import game.inventory.InventoryPlayer;
|
||||
import game.item.ItemStack;
|
||||
import game.world.World;
|
||||
|
||||
public class GuiRepair extends GuiContainer implements ICrafting
|
||||
{
|
||||
// private static final String anvilResource = "textures/gui/anvil.png";
|
||||
|
||||
private ContainerRepair anvil;
|
||||
// private TextField nameField;
|
||||
private InventoryPlayer playerInventory;
|
||||
|
||||
public GuiRepair(InventoryPlayer inventoryIn, World worldIn)
|
||||
{
|
||||
super(new ContainerRepair(inventoryIn, worldIn, Game.getGame().thePlayer));
|
||||
this.playerInventory = inventoryIn;
|
||||
this.anvil = (ContainerRepair)this.inventorySlots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
||||
* window resizes, the buttonList is cleared beforehand.
|
||||
*/
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
// Keyboard.enableRepeatEvents(true);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
// this.nameField = new TextField(i + 62, j + 24, 103, 12);
|
||||
// this.nameField.setTextColor(-1);
|
||||
// this.nameField.setDisabledTextColour(-1);
|
||||
// this.nameField.setEnableBackgroundDrawing(false);
|
||||
// this.nameField.setMaxStringLength(30);
|
||||
this.inventorySlots.removeCraftingFromCrafters(this);
|
||||
this.inventorySlots.onCraftGuiOpened(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the screen is unloaded. Used to disable keyboard repeat events
|
||||
*/
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
// Keyboard.enableRepeatEvents(false);
|
||||
this.inventorySlots.removeCraftingFromCrafters(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
||||
*/
|
||||
public void drawGuiContainerForegroundLayer()
|
||||
{
|
||||
// GlState.disableLighting();
|
||||
// GlState.disableBlend();
|
||||
this.drawString("Amboss", 60, 6);
|
||||
|
||||
if (this.anvil.maximumCost > 0)
|
||||
{
|
||||
int i = 8453920;
|
||||
boolean flag = true;
|
||||
String s = String.format("Erfahrungskosten: %d", this.anvil.maximumCost);
|
||||
|
||||
if (this.anvil.maximumCost >= 40) // && !this.gm.thePlayer.creative)
|
||||
{
|
||||
s = "Zu teuer!";
|
||||
i = 16736352;
|
||||
}
|
||||
else if (!this.anvil.getSlot(2).getHasStack())
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else if (!this.anvil.getSlot(2).canTakeStack(this.playerInventory.player))
|
||||
{
|
||||
i = 16736352;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
int j = -16777216 | (i & 16579836) >> 2 | i & -16777216;
|
||||
int k = this.xSize - 8 - this.getStringWidth(s);
|
||||
int l = 67;
|
||||
|
||||
// if (FontRenderer.getUnicodeFlag())
|
||||
// {
|
||||
// drawRect(k - 3, l - 2, this.xSize - 7, l + 10, -16777216);
|
||||
// drawRect(k - 2, l - 1, this.xSize - 8, l + 9, -12895429);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
this.drawString(s, k, l + 1);
|
||||
this.drawString(s, k + 1, l);
|
||||
this.drawString(s, k + 1, l + 1);
|
||||
// }
|
||||
|
||||
this.drawString(s, k, l);
|
||||
}
|
||||
}
|
||||
|
||||
// GlState.enableLighting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
|
||||
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
|
||||
*/
|
||||
// protected void keyTyped(char typedChar, int keyCode)
|
||||
// {
|
||||
// if (this.nameField.textboxKeyTyped(typedChar, keyCode))
|
||||
//// {
|
||||
// this.renameItem();
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// super.keyTyped(typedChar, keyCode);
|
||||
//// }
|
||||
// }
|
||||
//
|
||||
// private void renameItem()
|
||||
// {
|
||||
// String s = this.nameField.getText();
|
||||
// Slot slot = this.anvil.getSlot(0);
|
||||
//
|
||||
// if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
|
||||
// {
|
||||
// s = "";
|
||||
// }
|
||||
//
|
||||
// this.anvil.updateItemName(s);
|
||||
// this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.ITEM, s));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
|
||||
// */
|
||||
// protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
// {
|
||||
// super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
// this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
||||
*/
|
||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
// {
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
// GlState.disableLighting();
|
||||
// GlState.disableBlend();
|
||||
// this.nameField.drawTextBox();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Args : renderPartialTicks, mouseX, mouseY
|
||||
// */
|
||||
// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY)
|
||||
// {
|
||||
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.gm.getTextureManager().bindTexture(anvilResource);
|
||||
// int i = (this.width - this.xSize) / 2;
|
||||
// int j = (this.height - this.ySize) / 2;
|
||||
//// this.rect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
//// this.rect(i + 59, j + 20, 0, this.ySize + (this.anvil.getSlot(0).getHasStack() ? 0 : 16), 110, 16);
|
||||
//
|
||||
//// if ((this.anvil.getSlot(0).getHasStack() || this.anvil.getSlot(1).getHasStack()) && !this.anvil.getSlot(2).getHasStack())
|
||||
//// {
|
||||
//// this.rect(i + 99, j + 45, this.xSize, 0, 28, 21);
|
||||
//// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* update the crafting window inventory with the items in the list
|
||||
*/
|
||||
public void updateCraftingInventory(Container containerToSend, List<ItemStack> itemsList)
|
||||
{
|
||||
this.sendSlotContents(containerToSend, 0, containerToSend.getSlot(0).getStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
|
||||
* contents of that slot. Args: Container, slot number, slot contents
|
||||
*/
|
||||
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
|
||||
{
|
||||
// if (slotInd == 0)
|
||||
// {
|
||||
// this.nameField.setText(stack == null ? "" : stack.getDisplayName());
|
||||
// this.nameField.setEnabled(stack != null);
|
||||
//
|
||||
// if (stack != null)
|
||||
// {
|
||||
// this.renameItem();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends two ints to the client-side Container. Used for furnace burning time, smelting progress, brewing progress,
|
||||
* and enchanting level. Normally the first int identifies which variable to update, and the second contains the new
|
||||
* value. Both are truncated to shorts in non-local SMP.
|
||||
*/
|
||||
public void sendProgressBarUpdate(Container containerIn, int varToUpdate, int newValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void sendAllWindowProperties(Container p_175173_1_, IInventory p_175173_2_)
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue