本文整理汇总了Java中net.minecraft.entity.IMerchant类的典型用法代码示例。如果您正苦于以下问题:Java IMerchant类的具体用法?Java IMerchant怎么用?Java IMerchant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMerchant类属于net.minecraft.entity包,在下文中一共展示了IMerchant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayVillagerTradeGui
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.onCraftGuiOpened(this);
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
IChatComponent ichatcomponent = villager.getDisplayName();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
}
}
示例2: ContainerMerchant
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public ContainerMerchant(InventoryPlayer playerInventory, IMerchant merchant, World worldIn)
{
this.theMerchant = merchant;
this.theWorld = worldIn;
this.merchantInventory = new InventoryMerchant(playerInventory.player, merchant);
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53));
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53));
this.addSlotToContainer(new SlotMerchantResult(playerInventory.player, merchant, this.merchantInventory, 2, 120, 53));
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
}
示例3: displayVillagerTradeGui
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
ITextComponent itextcomponent = villager.getDisplayName();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
}
}
示例4: func_190888_a
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_)
{
Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(p_190888_3_);
int i = MathHelper.getInt(p_190888_3_, enchantment.getMinLevel(), enchantment.getMaxLevel());
ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
int j = 2 + p_190888_3_.nextInt(5 + i * 10) + 3 * i;
if (enchantment.isTreasureEnchantment())
{
j *= 2;
}
if (j > 64)
{
j = 64;
}
p_190888_2_.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
示例5: displayVillagerTradeGui
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
ITextComponent itextcomponent = villager.getDisplayName();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
}
}
示例6: getTradePacket
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public XUPacketBase getTradePacket(final EntityPlayer player) {
final List<IMerchant> traders = this.getVillagers();
if (traders == null || traders.size() == 0) {
return null;
}
final NBTTagCompound pkt = new NBTTagCompound();
int n = 0;
pkt.setInteger("player_id", player.getEntityId());
for (int i = 0; i < traders.size(); ++i) {
final IMerchant v = traders.get(i);
pkt.setInteger("i" + i, ((EntityLiving)v).getEntityId());
pkt.setTag("t" + i, (NBTBase)v.getRecipes((EntityPlayer)null).getRecipiesAsTags());
++n;
}
if (n == 0) {
return null;
}
pkt.setInteger("n", n);
return new PacketVillager(this.xCoord, this.yCoord, this.zCoord, pkt);
}
示例7: addMerchantRecipe
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
@Override
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random rand) {
int i = 1;
if (this.priceInfo != null) {
i = this.priceInfo.getPrice(rand);
}
ItemStack itemstack;
ItemStack itemstack1;
if (i < 0) {
itemstack = new ItemStack(ModItems.trading_token);
itemstack1 = new ItemStack(this.itemToBuy.getItem(), abs(i), this.itemToBuy.getMetadata());
} else {
itemstack = new ItemStack(ModItems.trading_token, i);
itemstack1 = new ItemStack(this.itemToBuy.getItem(), 1, this.itemToBuy.getMetadata());
}
recipeList.add(new MerchantRecipe(itemstack, itemstack1));
}
示例8: ContainerTrading
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public ContainerTrading(InventoryPlayer playerInventory, IMerchant merchant, World worldIn) {
this.theMerchant = merchant;
this.world = worldIn;
this.merchantInventory = new InventoryMerchant(playerInventory.player, merchant);
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53));
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53));
this.addSlotToContainer(new SlotMerchantResult(playerInventory.player, merchant, this.merchantInventory, 2, 120, 53));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k) {
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
}
示例9: displayGUIMerchant
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
InventoryMerchant var3 = ((ContainerMerchant)this.openContainer).getMerchantInventory();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, var3.getSizeInventory(), par2Str != null));
MerchantRecipeList var4 = par1IMerchant.getRecipes(this);
if (var4 != null)
{
try
{
PacketBuffer var5 = new PacketBuffer(Unpooled.buffer());
var5.writeInt(this.currentWindowId);
var4.func_151391_a(var5);
this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", var5));
}
catch (IOException var6)
{
logger.error("Couldn\'t send trade list", var6);
}
}
}
示例10: ContainerMerchant
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public ContainerMerchant(InventoryPlayer par1InventoryPlayer, IMerchant par2IMerchant, World par3World)
{
this.theMerchant = par2IMerchant;
this.theWorld = par3World;
this.merchantInventory = new InventoryMerchant(par1InventoryPlayer.player, par2IMerchant);
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53));
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53));
this.addSlotToContainer(new SlotMerchantResult(par1InventoryPlayer.player, par2IMerchant, this.merchantInventory, 2, 120, 53));
int var4;
for (var4 = 0; var4 < 3; ++var4)
{
for (int var5 = 0; var5 < 9; ++var5)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var5 + var4 * 9 + 9, 8 + var5 * 18, 84 + var4 * 18));
}
}
for (var4 = 0; var4 < 9; ++var4)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4, 8 + var4 * 18, 142));
}
}
示例11: ContainerMerchant
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public ContainerMerchant(InventoryPlayer p_i1821_1_, IMerchant p_i1821_2_, World p_i1821_3_)
{
this.theMerchant = p_i1821_2_;
this.theWorld = p_i1821_3_;
this.merchantInventory = new InventoryMerchant(p_i1821_1_.player, p_i1821_2_);
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53));
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53));
this.addSlotToContainer(new SlotMerchantResult(p_i1821_1_.player, p_i1821_2_, this.merchantInventory, 2, 120, 53));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(p_i1821_1_, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(p_i1821_1_, i, 8 + i * 18, 142));
}
}
示例12: func_71030_a
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void func_71030_a(IMerchant p_71030_1_, String p_71030_2_) {
this.func_71117_bO();
this.field_71070_bA = new ContainerMerchant(this.field_71071_by, p_71030_1_, this.field_70170_p);
this.field_71070_bA.field_75152_c = this.field_71139_cq;
this.field_71070_bA.func_75132_a(this);
InventoryMerchant var3 = ((ContainerMerchant)this.field_71070_bA).func_75174_d();
this.field_71135_a.func_72567_b(new Packet100OpenWindow(this.field_71139_cq, 6, p_71030_2_ == null?"":p_71030_2_, var3.func_70302_i_(), p_71030_2_ != null));
MerchantRecipeList var4 = p_71030_1_.func_70934_b(this);
if(var4 != null) {
try {
ByteArrayOutputStream var5 = new ByteArrayOutputStream();
DataOutputStream var6 = new DataOutputStream(var5);
var6.writeInt(this.field_71139_cq);
var4.func_77200_a(var6);
this.field_71135_a.func_72567_b(new Packet250CustomPayload("MC|TrList", var5.toByteArray()));
} catch (IOException var7) {
var7.printStackTrace();
}
}
}
示例13: ContainerMerchant
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public ContainerMerchant(InventoryPlayer p_i1821_1_, IMerchant p_i1821_2_, World p_i1821_3_) {
this.field_75178_e = p_i1821_2_;
this.field_75177_g = p_i1821_3_;
this.field_75176_f = new InventoryMerchant(p_i1821_1_.field_70458_d, p_i1821_2_);
this.func_75146_a(new Slot(this.field_75176_f, 0, 36, 53));
this.func_75146_a(new Slot(this.field_75176_f, 1, 62, 53));
this.func_75146_a(new SlotMerchantResult(p_i1821_1_.field_70458_d, p_i1821_2_, this.field_75176_f, 2, 120, 53));
int var4;
for(var4 = 0; var4 < 3; ++var4) {
for(int var5 = 0; var5 < 9; ++var5) {
this.func_75146_a(new Slot(p_i1821_1_, var5 + var4 * 9 + 9, 8 + var5 * 18, 84 + var4 * 18));
}
}
for(var4 = 0; var4 < 9; ++var4) {
this.func_75146_a(new Slot(p_i1821_1_, var4, 8 + var4 * 18, 142));
}
}
示例14: func_72501_a
import net.minecraft.entity.IMerchant; //导入依赖的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));
}
}
示例15: displayGUIMerchant
import net.minecraft.entity.IMerchant; //导入依赖的package包/类
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str)
{
this.incrementWindowID();
this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory();
this.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, inventorymerchant.getSizeInventory(), par2Str != null));
MerchantRecipeList merchantrecipelist = par1IMerchant.getRecipes(this);
if (merchantrecipelist != null)
{
try
{
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
dataoutputstream.writeInt(this.currentWindowId);
merchantrecipelist.writeRecipiesToStream(dataoutputstream);
this.playerNetServerHandler.sendPacketToPlayer(new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray()));
}
catch (IOException ioexception)
{
ioexception.printStackTrace();
}
}
}