當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryPlayer類代碼示例

本文整理匯總了Java中net.minecraft.entity.player.InventoryPlayer的典型用法代碼示例。如果您正苦於以下問題:Java InventoryPlayer類的具體用法?Java InventoryPlayer怎麽用?Java InventoryPlayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InventoryPlayer類屬於net.minecraft.entity.player包,在下文中一共展示了InventoryPlayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendSlotContents

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
@Override
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack) {
	
	Slot slot = containerToSend.getSlot(slotInd);
	boolean charge = true;
	
	if (slot != null) {
		if (slot.inventory instanceof InventoryPlayer) {
			// We don't charge for changes to the player's inventory.
			charge = false;
		}
	}
	
	System.out.println("Send slot contents for "+slotInd+":");
	if (stack == null)
		System.out.println(" - No contents");
	else
		System.out.println(" - "+stack.stackSize+" "+stack.getDisplayName());
	
	if (charge) {
		System.out.println("Charging a fee for data transfer...");
		this.chargeForAccess(1);
	}
	
}
 
開發者ID:astronautlabs,項目名稱:rezolve,代碼行數:26,代碼來源:RemoteShellEntity.java

示例2: ContainerCreative

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerCreative(EntityPlayer player)
{
    InventoryPlayer inventoryplayer = player.inventory;

    for (int i = 0; i < 5; ++i)
    {
        for (int j = 0; j < 9; ++j)
        {
            this.addSlotToContainer(new Slot(GuiContainerCreative.basicInventory, i * 9 + j, 9 + j * 18, 18 + i * 18));
        }
    }

    for (int k = 0; k < 9; ++k)
    {
        this.addSlotToContainer(new Slot(inventoryplayer, k, 9 + k * 18, 112));
    }

    this.scrollTo(0.0F);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:20,代碼來源:GuiContainerCreative.java

示例3: ContainerHopper

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerHopper(InventoryPlayer playerInventory, IInventory hopperInventoryIn, EntityPlayer player)
{
    this.hopperInventory = hopperInventoryIn;
    hopperInventoryIn.openInventory(player);
    int i = 51;

    for (int j = 0; j < hopperInventoryIn.getSizeInventory(); ++j)
    {
        this.addSlotToContainer(new Slot(hopperInventoryIn, j, 44 + j * 18, 20));
    }

    for (int l = 0; l < 3; ++l)
    {
        for (int k = 0; k < 9; ++k)
        {
            this.addSlotToContainer(new Slot(playerInventory, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
        }
    }

    for (int i1 = 0; i1 < 9; ++i1)
    {
        this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 58 + i));
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:ContainerHopper.java

示例4: ContainerMerchant

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的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));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:ContainerMerchant.java

示例5: canCraft

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public boolean canCraft() {
	if(currentEnergy <= 0) {
		FMLLog.log(Level.INFO, "Ba");
		currentEnergy = 0;
		return false;
	} else {
		FMLLog.log(Level.INFO, "Bb");
		InventoryCrafting inv = new InventoryCrafting(new ContainerAutoWorkBench(new InventoryPlayer(null), this), 3, 3);
		for(int i = 1; i < machineItemStacks.length - 1; i++) {
			inv.setInventorySlotContents(i - 1, machineItemStacks[i - 1]);
			FMLLog.log(Level.INFO, "Bc" + (i - 1));
		}
		ItemStack stack = AutoWorkBenchRecipes.smelting().getSmeltingResult(inv, worldObj, Tier.normal)[0];
		FMLLog.log(Level.INFO, "Bd" + (stack != null));
		return stack != null;
	}
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:18,代碼來源:TileEntityAutoWorkBench.java

示例6: ContainerProgrammer

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerProgrammer(InventoryPlayer inventoryPlayer, TileEntityProgrammer te) {
    super(te);

    addSlotToContainer(new SlotItemHandler(te.getPrimaryInventory(), 0, 326, 15) {
        @Override
        public boolean isItemValid(@Nonnull ItemStack stack) {
            return isProgrammableItem(stack);
        }
    });

    // Add the player's inventory slots to the container
    for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
        for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) {
            addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 95 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
        }
    }

    // Add the player's action bar slots to the container
    for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) {
        addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 95 + actionBarSlotIndex * 18, 232));
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:23,代碼來源:ContainerProgrammer.java

示例7: removeItemsFromPlayer

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
/**
 * Removes the given amount of items from the given player inventory. Scans through multiple inventory slots if needed.
 * 
 * @param inv - {@link net.minecraft.entity.player.InventoryPlayer Player inventory} to interact with.
 * @param item - {@link net.minecraft.item.Item Item type} to remove.
 * @param meta - Item metadata; set to {@code -1} to disregard item metadata.
 * @param qty - Number of items to remove.
 */
private static void removeItemsFromPlayer(InventoryPlayer inv, Item item, int meta, int qty){

	for(int i=0; i<inv.mainInventory.length; ++i){

		ItemStack stack = inv.mainInventory[i];
		if (stack == null) {
			continue;
		}

		if(stack.getItem().equals(item)){
			if(stack.getItemDamage() == meta || meta == -1){
				if(stack.stackSize <= qty){
					qty -= stack.stackSize;
					inv.removeStackFromSlot(i);
				}else{
					stack.stackSize -= qty;
					inv.setInventorySlotContents(i, stack);
					return;
				}
			}
		}
	}
}
 
開發者ID:DonBruce64,項目名稱:OpenFlexiTrack,代碼行數:32,代碼來源:BlockSurveyFlag.java

示例8: ContainerAmmoFurnace

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerAmmoFurnace(InventoryPlayer playerInventory, IInventory furnaceInventory) {
	this.tileFurnace = furnaceInventory;
	for (int i = 0; i < 9; i++)
		this.addSlotToContainer(new Slot(furnaceInventory, i, 9 + (i % 3) * 18, 17 + (i / 3) * 18));
	this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 9, 80, 53));
	for (int i = 0; i < 9; i++)
		this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, furnaceInventory, i + 10,
				116 + (i % 3) * 18, 17 + (i / 3) * 18));

	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));
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:17,代碼來源:ContainerAmmoFurnace.java

示例9: ContainerBrewingStand

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerBrewingStand(InventoryPlayer playerInventory, IInventory tileBrewingStandIn)
{
    this.tileBrewingStand = tileBrewingStandIn;
    this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 0, 56, 46));
    this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 1, 79, 53));
    this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 2, 102, 46));
    this.theSlot = this.addSlotToContainer(new ContainerBrewingStand.Ingredient(tileBrewingStandIn, 3, 79, 17));

    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));
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:ContainerBrewingStand.java

示例10: ContainerBrewingStand

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerBrewingStand(InventoryPlayer playerInventory, IInventory tileBrewingStandIn)
{
    this.tileBrewingStand = tileBrewingStandIn;
    this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 0, 56, 51));
    this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 1, 79, 58));
    this.addSlotToContainer(new ContainerBrewingStand.Potion(playerInventory.player, tileBrewingStandIn, 2, 102, 51));
    this.theSlot = this.addSlotToContainer(new ContainerBrewingStand.Ingredient(tileBrewingStandIn, 3, 79, 17));
    this.addSlotToContainer(new ContainerBrewingStand.Fuel(tileBrewingStandIn, 4, 17, 17));

    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));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:ContainerBrewingStand.java

示例11: ContainerApiary

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerApiary(InventoryPlayer playerInventory, IInventory inventory) {
	this.apiary = inventory;
	this.addSlotToContainer(new SlotBee(inventory, 0, 26, 34));

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 6; j++) {
			this.addSlotToContainer(new SlotItem(inventory, j + i * 6 + 1, 62 + j * 18, 16 + i * 18));
		}
	}

	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));
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:21,代碼來源:ContainerApiary.java

示例12: GuiEnchantment

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable nameable)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.nameable = nameable;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:GuiEnchantment.java

示例13: ContainerPersonalCharger

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public ContainerPersonalCharger(final EntityPlayer player, TileEntityBase tile) {

        tilePersonalCharger = (TilePersonalCharger) tile;
        InventoryPlayer inventory = player.inventory;
        addPlayerSlots(inventory);
        addUpgradeSlots(((TilePersonalCharger) tile).getUpgradeStackHandler());
    }
 
開發者ID:CreeperShift,項目名稱:WirelessCharger,代碼行數:8,代碼來源:ContainerPersonalCharger.java

示例14: combineSlots

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
static void combineSlots(EntityPlayerMP player, int dst, int add)
{
    InventoryPlayer inv = player.inventory;
    ItemStack dstStack = inv.getStackInSlot(dst);
    ItemStack addStack = inv.getStackInSlot(add);

    if (addStack == null)
        return;    // Combination is a no-op.

    if (dstStack == null)   // Do a straight move - nothing to combine with.
    {
        inv.setInventorySlotContents(dst, addStack);
        inv.setInventorySlotContents(add, null);
        return;
    }

    // Check we can combine. This logic comes from InventoryPlayer.storeItemStack():
    boolean itemsMatch = dstStack.getItem() == addStack.getItem();
    boolean dstCanStack = dstStack.isStackable() && dstStack.stackSize < dstStack.getMaxStackSize() && dstStack.stackSize < inv.getInventoryStackLimit();
    boolean subTypesMatch = !dstStack.getHasSubtypes() || dstStack.getMetadata() == addStack.getMetadata();
    boolean tagsMatch = ItemStack.areItemStackTagsEqual(dstStack, addStack);
    if (itemsMatch && dstCanStack && subTypesMatch && tagsMatch)
    {
        // We can combine, so figure out how much we have room for:
        int limit = Math.min(dstStack.getMaxStackSize(), inv.getInventoryStackLimit());
        int room = limit - dstStack.stackSize;
        if (addStack.stackSize > room)
        {
            // Not room for all of it, so shift across as much as possible.
            addStack.stackSize -= room;
            dstStack.stackSize += room;
        }
        else
        {
            // Room for the whole lot, so empty out the add slot.
            dstStack.stackSize += addStack.stackSize;
            inv.setInventorySlotContents(add, null);
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:41,代碼來源:InventoryCommandsImplementation.java

示例15: GuiEnchantment

import net.minecraft.entity.player.InventoryPlayer; //導入依賴的package包/類
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable p_i45502_3_)
{
    super(new ContainerEnchantment(inventory, worldIn));
    this.playerInventory = inventory;
    this.container = (ContainerEnchantment)this.inventorySlots;
    this.field_175380_I = p_i45502_3_;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:8,代碼來源:GuiEnchantment.java


注:本文中的net.minecraft.entity.player.InventoryPlayer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。