mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 21:59:05 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -25,18 +25,19 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiMerchantAdd extends GuiContainer
|
||||
{
|
||||
public class GuiMerchantAdd extends GuiContainer {
|
||||
private static final ResourceLocation merchantGuiTextures = new ResourceLocation("textures/gui/container/villager.png");
|
||||
|
||||
/** Instance of IMerchant interface. */
|
||||
/**
|
||||
* Instance of IMerchant interface.
|
||||
*/
|
||||
private IMerchant theIMerchant;
|
||||
private MerchantButton nextRecipeButtonIndex;
|
||||
private MerchantButton previousRecipeButtonIndex;
|
||||
private int currentRecipeIndex;
|
||||
private String field_94082_v;
|
||||
public GuiMerchantAdd()
|
||||
{
|
||||
|
||||
public GuiMerchantAdd() {
|
||||
super(new ContainerMerchantAdd(Minecraft.getMinecraft().thePlayer, ServerEventsHandler.Merchant, Minecraft.getMinecraft().theWorld));
|
||||
this.theIMerchant = ServerEventsHandler.Merchant;
|
||||
this.field_94082_v = I18n.format("entity.Villager.name");
|
||||
@@ -45,16 +46,15 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
public void initGui()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.buttonList.add(this.nextRecipeButtonIndex = new MerchantButton(1, i + 120 + 27, j + 24 - 1, true));
|
||||
this.buttonList.add(this.previousRecipeButtonIndex = new MerchantButton(2, i + 36 - 19, j + 24 - 1, false));
|
||||
this.buttonList.add(new GuiNpcButton(4, i + xSize, j + 20, 60, 20, "gui.remove"));
|
||||
this.buttonList.add(new GuiNpcButton(5, i + xSize, j + 50, 60, 20, "gui.add"));
|
||||
this.buttonList.add(new GuiNpcButton(4, i + xSize, j + 20, 60, 20, "gui.remove"));
|
||||
this.buttonList.add(new GuiNpcButton(5, i + xSize, j + 50, 60, 20, "gui.add"));
|
||||
this.nextRecipeButtonIndex.enabled = false;
|
||||
this.previousRecipeButtonIndex.enabled = false;
|
||||
}
|
||||
@@ -62,8 +62,7 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
this.fontRendererObj.drawString(this.field_94082_v, this.xSize / 2 - this.fontRendererObj.getStringWidth(this.field_94082_v) / 2, 6, CustomNpcResourceListener.DefaultTextColor);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
@@ -71,14 +70,12 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Called from the main game loop to update the screen.
|
||||
*/
|
||||
public void updateScreen()
|
||||
{
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer);
|
||||
|
||||
if (merchantrecipelist != null)
|
||||
{
|
||||
if (merchantrecipelist != null) {
|
||||
this.nextRecipeButtonIndex.enabled = this.currentRecipeIndex < merchantrecipelist.size() - 1;
|
||||
this.previousRecipeButtonIndex.enabled = this.currentRecipeIndex > 0;
|
||||
}
|
||||
@@ -87,72 +84,62 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
|
||||
*/
|
||||
protected void actionPerformed(GuiButton par1GuiButton)
|
||||
{
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
boolean flag = false;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if (par1GuiButton == this.nextRecipeButtonIndex)
|
||||
{
|
||||
if (par1GuiButton == this.nextRecipeButtonIndex) {
|
||||
++this.currentRecipeIndex;
|
||||
flag = true;
|
||||
}
|
||||
else if (par1GuiButton == this.previousRecipeButtonIndex)
|
||||
{
|
||||
} else if (par1GuiButton == this.previousRecipeButtonIndex) {
|
||||
--this.currentRecipeIndex;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if(par1GuiButton.id == 4){
|
||||
if (par1GuiButton.id == 4) {
|
||||
MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer);
|
||||
if(currentRecipeIndex < merchantrecipelist.size()){
|
||||
merchantrecipelist.remove(currentRecipeIndex);
|
||||
if(currentRecipeIndex > 0)
|
||||
currentRecipeIndex--;
|
||||
if (currentRecipeIndex < merchantrecipelist.size()) {
|
||||
merchantrecipelist.remove(currentRecipeIndex);
|
||||
if (currentRecipeIndex > 0)
|
||||
currentRecipeIndex--;
|
||||
PacketClient.sendClient(new MerchantUpdatePacket(ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist));
|
||||
}
|
||||
}
|
||||
|
||||
if(par1GuiButton.id == 5){
|
||||
ItemStack item1 = this.inventorySlots.getSlot(0).getStack();
|
||||
ItemStack item2 = this.inventorySlots.getSlot(1).getStack();
|
||||
ItemStack sold = this.inventorySlots.getSlot(2).getStack();
|
||||
if(item1 == null && item2 != null){
|
||||
item1 = item2;
|
||||
item2 = null;
|
||||
}
|
||||
if (par1GuiButton.id == 5) {
|
||||
ItemStack item1 = this.inventorySlots.getSlot(0).getStack();
|
||||
ItemStack item2 = this.inventorySlots.getSlot(1).getStack();
|
||||
ItemStack sold = this.inventorySlots.getSlot(2).getStack();
|
||||
if (item1 == null && item2 != null) {
|
||||
item1 = item2;
|
||||
item2 = null;
|
||||
}
|
||||
|
||||
if(item1 != null && sold != null){
|
||||
item1 = item1.copy();
|
||||
sold = sold.copy();
|
||||
if(item2 != null)
|
||||
item2 = item2.copy();
|
||||
MerchantRecipe recipe = new MerchantRecipe(item1, item2, sold);
|
||||
recipe.func_82783_a(Integer.MAX_VALUE - 8);
|
||||
if (item1 != null && sold != null) {
|
||||
item1 = item1.copy();
|
||||
sold = sold.copy();
|
||||
if (item2 != null)
|
||||
item2 = item2.copy();
|
||||
MerchantRecipe recipe = new MerchantRecipe(item1, item2, sold);
|
||||
recipe.func_82783_a(Integer.MAX_VALUE - 8);
|
||||
|
||||
MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer);
|
||||
merchantrecipelist.add(recipe);
|
||||
PacketClient.sendClient(new MerchantUpdatePacket(ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
((ContainerMerchantAdd)this.inventorySlots).setCurrentRecipeIndex(this.currentRecipeIndex);
|
||||
if (flag) {
|
||||
((ContainerMerchantAdd) this.inventorySlots).setCurrentRecipeIndex(this.currentRecipeIndex);
|
||||
ByteBuf bytebuf = Unpooled.buffer();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
bytebuf.writeInt(this.currentRecipeIndex);
|
||||
this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", bytebuf));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
} catch (Exception exception) {
|
||||
//field_147039_u.error("Couldn\'t send trade info", exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
bytebuf.release();
|
||||
}
|
||||
}
|
||||
@@ -161,9 +148,8 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(merchantGuiTextures);
|
||||
@@ -172,13 +158,11 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer);
|
||||
|
||||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty())
|
||||
{
|
||||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
|
||||
int i1 = this.currentRecipeIndex;
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(i1);
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe) merchantrecipelist.get(i1);
|
||||
|
||||
if (merchantrecipe.isRecipeDisabled())
|
||||
{
|
||||
if (merchantrecipe.isRecipeDisabled()) {
|
||||
mc.getTextureManager().bindTexture(merchantGuiTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
@@ -191,19 +175,17 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3)
|
||||
{
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
super.drawScreen(par1, par2, par3);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer);
|
||||
|
||||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty())
|
||||
{
|
||||
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
int i1 = this.currentRecipeIndex;
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(i1);
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe) merchantrecipelist.get(i1);
|
||||
GL11.glPushMatrix();
|
||||
ItemStack itemstack = merchantrecipe.getItemToBuy();
|
||||
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
|
||||
@@ -217,10 +199,9 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack, k + 36, l + 24);
|
||||
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack, k + 36, l + 24);
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24);
|
||||
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24);
|
||||
if (itemstack1 != null) {
|
||||
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24);
|
||||
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack1, k + 62, l + 24);
|
||||
}
|
||||
|
||||
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, mc.getTextureManager(), itemstack2, k + 120, l + 24);
|
||||
@@ -228,16 +209,11 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
itemRender.zLevel = 0.0F;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
if (this.func_146978_c(36, 24, 16, 16, par1, par2))
|
||||
{
|
||||
if (this.func_146978_c(36, 24, 16, 16, par1, par2)) {
|
||||
this.renderToolTip(itemstack, par1, par2);
|
||||
}
|
||||
else if (itemstack1 != null && this.func_146978_c(62, 24, 16, 16, par1, par2))
|
||||
{
|
||||
} else if (itemstack1 != null && this.func_146978_c(62, 24, 16, 16, par1, par2)) {
|
||||
this.renderToolTip(itemstack1, par1, par2);
|
||||
}
|
||||
else if (this.func_146978_c(120, 24, 16, 16, par1, par2))
|
||||
{
|
||||
} else if (this.func_146978_c(120, 24, 16, 16, par1, par2)) {
|
||||
this.renderToolTip(itemstack2, par1, par2);
|
||||
}
|
||||
|
||||
@@ -251,53 +227,44 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
/**
|
||||
* Gets the Instance of IMerchant interface.
|
||||
*/
|
||||
public IMerchant getIMerchant()
|
||||
{
|
||||
public IMerchant getIMerchant() {
|
||||
return this.theIMerchant;
|
||||
}
|
||||
|
||||
static ResourceLocation func_110417_h()
|
||||
{
|
||||
static ResourceLocation func_110417_h() {
|
||||
return merchantGuiTextures;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
static class MerchantButton extends GuiButton
|
||||
{
|
||||
private final boolean field_146157_o;
|
||||
static class MerchantButton extends GuiButton {
|
||||
private final boolean field_146157_o;
|
||||
|
||||
public MerchantButton(int par1, int par2, int par3, boolean par4)
|
||||
{
|
||||
super(par1, par2, par3, 12, 19, "");
|
||||
this.field_146157_o = par4;
|
||||
}
|
||||
public MerchantButton(int par1, int par2, int par3, boolean par4) {
|
||||
super(par1, par2, par3, 12, 19, "");
|
||||
this.field_146157_o = par4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
p_146112_1_.getTextureManager().bindTexture(GuiMerchantAdd.merchantGuiTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
|
||||
int k = 0;
|
||||
int l = 176;
|
||||
@Override
|
||||
public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) {
|
||||
if (this.visible) {
|
||||
p_146112_1_.getTextureManager().bindTexture(GuiMerchantAdd.merchantGuiTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
|
||||
int k = 0;
|
||||
int l = 176;
|
||||
|
||||
if (!this.enabled)
|
||||
{
|
||||
l += this.width * 2;
|
||||
}
|
||||
else if (flag)
|
||||
{
|
||||
l += this.width;
|
||||
}
|
||||
|
||||
if (!this.field_146157_o)
|
||||
{
|
||||
k += this.height;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, l, k, this.width, this.height);
|
||||
if (!this.enabled) {
|
||||
l += this.width * 2;
|
||||
} else if (flag) {
|
||||
l += this.width;
|
||||
}
|
||||
|
||||
if (!this.field_146157_o) {
|
||||
k += this.height;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, l, k, this.width, this.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user