本文整理汇总了Java中net.minecraft.client.gui.GuiMerchant类的典型用法代码示例。如果您正苦于以下问题:Java GuiMerchant类的具体用法?Java GuiMerchant怎么用?Java GuiMerchant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GuiMerchant类属于net.minecraft.client.gui包,在下文中一共展示了GuiMerchant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClientUpdate
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public static void onClientUpdate(TickEvent.ClientTickEvent event)
{
if(event.side == Side.CLIENT && event.phase == TickEvent.Phase.END)
{
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if (gui instanceof GuiMerchant) {
//IMerchant merchant = ((GuiMerchant) gui).getMerchant();
ContainerMerchant container = (ContainerMerchant) ((GuiMerchant) gui).inventorySlots;
if (container != null && (clientContainer == null || clientContainer.container != container)) {
clientContainer = new ContainerWrapper(container);
}
clientContainer.update();
}
else
{
clientContainer = null;
}
}
}
示例2: guiPostInit
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
if (Minecraft.getMinecraft().player != null) {
if ((event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative || event.getGui() instanceof GuiWearables)
&& !Minecraft.getMinecraft().player.getCapability(TF2weapons.INVENTORY_CAP, null).isEmpty()) {
// GuiContainer gui = (GuiContainer) event.getGui();
event.getButtonList().add(new GuiButton(97535627, event.getGui().width / 2 - 10, event.getGui().height / 2 + 95, 20, 20, "W"));
}
if (event.getGui() instanceof GuiMerchant)
if (((GuiMerchant) event.getGui()).getMerchant().getDisplayName().getUnformattedText().equals(I18n.format("entity.hale.name"))) {
event.getButtonList().add(new GuiButton(7578, event.getGui().width / 2 - 100, event.getGui().height / 2 - 110, 100, 20, "Change Team"));
event.getButtonList().add(new GuiButton(7579, event.getGui().width / 2, event.getGui().height / 2 - 110, 100, 20, "Recover Lost Items"));
}
Minecraft.getMinecraft().player.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 8;
}
}
示例3: guiPostAction
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) {
if (event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative)
if (event.getButton().id == 97535627) {
// Minecraft.getMinecraft().displayGuiScreen(null);
TF2weapons.network.sendToServer(new TF2Message.ShowGuiMessage(0));
}
if (event.getGui() instanceof GuiWearables)
if (event.getButton().id == 97535627) {
event.getGui().mc.displayGuiScreen(new GuiInventory(event.getGui().mc.player));
}
// PacketHandler.INSTANCE.sendToServer(new
// PacketOpenNormalInventory(event.getGui().mc.player));
if (event.getGui() instanceof GuiMerchant && event.getButton().id == 7578) {
ClientProxy.displayScreenJoinTeam();
}
else if (event.getGui() instanceof GuiMerchant && event.getButton().id == 7579) {
TF2weapons.network.sendToServer(new TF2Message.ActionMessage(18));
}
}
示例4: func_72501_a
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void func_72501_a(Packet250CustomPayload p_72501_1_) {
if("MC|TrList".equals(p_72501_1_.field_73630_a)) {
DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));
try {
int var3 = var2.readInt();
GuiScreen var4 = this.field_72563_h.field_71462_r;
if(var4 != null && var4 instanceof GuiMerchant && var3 == this.field_72563_h.field_71439_g.field_71070_bA.field_75152_c) {
IMerchant var5 = ((GuiMerchant)var4).func_74199_h();
MerchantRecipeList var6 = MerchantRecipeList.func_77204_a(var2);
var5.func_70930_a(var6);
}
} catch (IOException var7) {
var7.printStackTrace();
}
} else if("MC|Brand".equals(p_72501_1_.field_73630_a)) {
this.field_72563_h.field_71439_g.func_142020_c(new String(p_72501_1_.field_73629_c, Charsets.UTF_8));
}
}
示例5: func_73737_a
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void func_73737_a(Minecraft p_73737_1_, int p_73737_2_, int p_73737_3_) {
if(this.field_73748_h) {
p_73737_1_.func_110434_K().func_110577_a(GuiMerchant.func_110417_h());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean var4 = p_73737_2_ >= this.field_73746_c && p_73737_3_ >= this.field_73743_d && p_73737_2_ < this.field_73746_c + this.field_73747_a && p_73737_3_ < this.field_73743_d + this.field_73745_b;
int var5 = 0;
int var6 = 176;
if(!this.field_73742_g) {
var6 += this.field_73747_a * 2;
} else if(var4) {
var6 += this.field_73747_a;
}
if(!this.field_73749_j) {
var5 += this.field_73745_b;
}
this.func_73729_b(this.field_73746_c, this.field_73743_d, var6, var5, this.field_73747_a, this.field_73745_b);
}
}
示例6: handleCustomPayload
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla
* implemented channels are "MC|TrList" to acquire a MerchantRecipeList trades
* for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate
* the identifier of the default server resourcepack for the client to load.
*/
public void handleCustomPayload(S3FPacketCustomPayload packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName())) {
PacketBuffer packetbuffer = packetIn.getBufferData();
try {
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant
&& i == this.gameController.thePlayer.openContainer.windowId) {
IMerchant imerchant = ((GuiMerchant) guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
} catch (IOException ioexception) {
logger.error((String) "Couldn\'t load trade info", (Throwable) ioexception);
} finally {
packetbuffer.release();
}
} else if ("MC|Brand".equals(packetIn.getChannelName())) {
this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
} else if ("MC|BOpen".equals(packetIn.getChannelName())) {
ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
if (itemstack != null && itemstack.getItem() == Items.written_book) {
this.gameController
.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
}
示例7: tryMoveItemsVillager
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public static boolean tryMoveItemsVillager(GuiMerchant gui, Slot slot, boolean moveToOtherInventory, boolean isShiftDown)
{
if (isShiftDown)
{
// Try to fill the merchant's buy slots from the player inventory
if (moveToOtherInventory == false)
{
tryMoveItemsToMerchantBuySlots(gui, true);
}
// Move items from sell slot to player inventory
else if (slot.getHasStack())
{
tryMoveStacks(slot, gui, true, true, true);
}
// Scrolling over an empty output slot, clear the buy slots
else
{
tryMoveStacks(slot, gui, false, true, false);
}
}
else
{
// Scrolling items from player inventory into merchant buy slots
if (moveToOtherInventory == false)
{
tryMoveItemsToMerchantBuySlots(gui, false);
}
// Scrolling items from this slot/inventory into the other inventory
else if (slot.getHasStack())
{
moveOneSetOfItemsFromSlotToOtherInventory(gui, slot);
}
}
return false;
}
示例8: tryMoveItemsToMerchantBuySlots
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
private static void tryMoveItemsToMerchantBuySlots(GuiMerchant gui, boolean fillStacks)
{
MerchantRecipeList list = gui.getMerchant().getRecipes(gui.mc.player);
int index = 0;
try
{
index = fieldSelectedMerchantRecipe.getInt(gui);
}
catch (IllegalAccessException e)
{
ItemScroller.logger.warn("Failed to get the value of GuiMerchant.selectedMerchantRecipe");
}
if (list == null || list.size() <= index)
{
return;
}
MerchantRecipe recipe = list.get(index);
if (recipe == null)
{
return;
}
ItemStack buy1 = recipe.getItemToBuy();
ItemStack buy2 = recipe.getSecondItemToBuy();
if (isStackEmpty(buy1) == false)
{
fillBuySlot(gui, 0, buy1, fillStacks);
}
if (isStackEmpty(buy2) == false)
{
fillBuySlot(gui, 1, buy2, fillStacks);
}
}
示例9: npcTradeOpen
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public void npcTradeOpen(GuiOpenEvent event){
if(event.getGui() instanceof GuiMerchant){
if(((GuiMerchant) event.getGui()).getMerchant() instanceof NPCShop){
lastOpened = (NPCShop) ((GuiMerchant) event.getGui()).getMerchant();
}else{
Minecraft mc = Minecraft.getMinecraft();
event.setGui(new GuiNPCMerchant(mc.player.inventory, lastOpened, mc.world));
}
}
}
示例10: handleVanilla250Packet
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void handleVanilla250Packet(Packet250CustomPayload par1Packet250CustomPayload)
{
if ("MC|TrList".equals(par1Packet250CustomPayload.channel))
{
DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));
try
{
int i = datainputstream.readInt();
GuiScreen guiscreen = this.mc.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.mc.thePlayer.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getIMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readRecipiesFromStream(datainputstream);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
ioexception.printStackTrace();
}
}
else if ("MC|Brand".equals(par1Packet250CustomPayload.channel))
{
this.mc.thePlayer.func_142020_c(new String(par1Packet250CustomPayload.data, Charsets.UTF_8));
}
}
示例11: drawButton
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
* Draws this button to the screen.
*/
@Override
public void drawButton(Minecraft mc, int xCursor, int yCursor, float tick)
{
if(this.visible)
{
mc.getTextureManager().bindTexture(GuiMerchant.MERCHANT_GUI_TEXTURE);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
GL11.glColor4f(1F, 1F, 1F, 1F);
boolean flag = (xCursor >= this.x) && (yCursor >= this.y) && (xCursor < this.x + this.width) && (yCursor < this.y + this.height);
int yTexturePos = 0;
int xTexturePos = 176;
if(!this.enabled)
{
xTexturePos += this.width * 2;
}
else if(flag)
{
xTexturePos += this.width;
}
if(!this.isNextButton)
{
yTexturePos += this.height;
}
this.drawTexturedModalRect(this.x, this.y, xTexturePos, yTexturePos, this.width, this.height);
GL11.glPopAttrib();
}
}
示例12: displayVillagerTradeGui
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.worldObj));
}
示例13: handleCustomPayload
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
* resourcepack for the client to load.
*/
public void handleCustomPayload(S3FPacketCustomPayload packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer = packetIn.getBufferData();
try
{
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
}
finally
{
packetbuffer.release();
}
}
else if ("MC|Brand".equals(packetIn.getChannelName()))
{
this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
}
else if ("MC|BOpen".equals(packetIn.getChannelName()))
{
ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
if (itemstack != null && itemstack.getItem() == Items.written_book)
{
this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
}
示例14: displayVillagerTradeGui
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager) {
this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.worldObj));
}
示例15: displayVillagerTradeGui
import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.world));
}