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


Java Container類代碼示例

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


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

示例1: doTest

import net.minecraft.inventory.Container; //導入依賴的package包/類
private void doTest(boolean inOrder, boolean enoughDamage)
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {enoughDamage ? 5 : 5000, 0},
                                                                           new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.APPLE));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(inOrder ? 3 : 4, new ItemStack(Items.WOODEN_SWORD));
    inv.setInventorySlotContents(inOrder ? 4 : 3, new ItemStack(Items.APPLE));

    assertSame(enoughDamage, recipe.matches(inv, null));

    if (enoughDamage)
    {
        NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
        assertSame(Items.WOODEN_SWORD, remaining.get(inOrder ? 3 : 4).getItem());
        assertEquals(5, remaining.get(inOrder ? 3 : 4).getItemDamage());
    }
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:26,代碼來源:DamageableShapelessOreRecipeTest.java

示例2: getCraftingGrid

import net.minecraft.inventory.Container; //導入依賴的package包/類
@Override
public InventoryCrafting getCraftingGrid() {
    InventoryCrafting invCrafting = new InventoryCrafting(new Container() {
        @Override
        public boolean canInteractWith(EntityPlayer p_75145_1_) {
            return false;
        }

    }, 3, 3);
    for (int y = 0; y < 3; y++) {
        ProgWidgetItemFilter itemFilter = (ProgWidgetItemFilter) getConnectedParameters()[y];
        for (int x = 0; x < 3 && itemFilter != null; x++) {
            invCrafting.setInventorySlotContents(y * 3 + x, itemFilter.getFilter());
            itemFilter = (ProgWidgetItemFilter) itemFilter.getConnectedParameters()[0];
        }
    }
    return invCrafting;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:19,代碼來源:ProgWidgetCrafting.java

示例3: getComparatorInputOverride

import net.minecraft.inventory.Container; //導入依賴的package包/類
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    if (((Boolean)blockState.getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.HAS_INVENTORY});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:BlockRailDetector.java

示例4: test_useUpItem

import net.minecraft.inventory.Container; //導入依賴的package包/類
@Test
public void test_useUpItem()
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {60}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(3, new ItemStack(Items.WOODEN_SWORD));

    assertTrue(recipe.matches(inv, null));
    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(3).isEmpty());
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:20,代碼來源:DamageableShapelessOreRecipeTest.java

示例5: getComparatorInputOverride

import net.minecraft.inventory.Container; //導入依賴的package包/類
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:22,代碼來源:BlockRailDetector.java

示例6: handleConfirmTransaction

import net.minecraft.inventory.Container; //導入依賴的package包/類
/**
 * Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
 * and confirms if it is the case.
 */
public void handleConfirmTransaction(S32PacketConfirmTransaction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Container container = null;
    EntityPlayer entityplayer = this.gameController.thePlayer;

    if (packetIn.getWindowId() == 0)
    {
        container = entityplayer.inventoryContainer;
    }
    else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
    {
        container = entityplayer.openContainer;
    }

    if (container != null && !packetIn.func_148888_e())
    {
        this.addToSendQueue(new C0FPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:NetHandlerPlayClient.java

示例7: GuiAnimaGenerator

import net.minecraft.inventory.Container; //導入依賴的package包/類
public GuiAnimaGenerator(Container inventorySlotsIn)
{
	super(inventorySlotsIn);

	xSize = WIDTH;
	ySize = HEIGHT;
}
 
開發者ID:Lemonszz,項目名稱:Anima-Mundi,代碼行數:8,代碼來源:GuiAnimaGenerator.java

示例8: handleClientSide

import net.minecraft.inventory.Container; //導入依賴的package包/類
@Override
public void handleClientSide(PacketUpdateGui message, EntityPlayer player) {
    Container container = player.openContainer;
    if (container instanceof ContainerPneumaticBase) {
        ((ContainerPneumaticBase) container).updateField(message.syncId, message.value);
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:PacketUpdateGui.java

示例9: sendAllWindowProperties

import net.minecraft.inventory.Container; //導入依賴的package包/類
public void sendAllWindowProperties(Container containerIn, IInventory inventory)
{
    for (int i = 0; i < inventory.getFieldCount(); ++i)
    {
        this.connection.sendPacket(new SPacketWindowProperty(containerIn.windowId, i, inventory.getField(i)));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:EntityPlayerMP.java

示例10: GuiBarrel

import net.minecraft.inventory.Container; //導入依賴的package包/類
public GuiBarrel(Container inventorySlotsIn, TileEntityBarrel te) {
	super(inventorySlotsIn);
	this.te = te;
	this.xSize = 176;
	this.ySize = 166;
	te.getAltar(true);
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:8,代碼來源:GuiBarrel.java

示例11: updateDragSplitting

import net.minecraft.inventory.Container; //導入依賴的package包/類
private void updateDragSplitting()
{
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    if (itemstack != null && this.dragSplitting)
    {
        this.dragSplittingRemnant = itemstack.stackSize;

        for (Slot slot : this.dragSplittingSlots)
        {
            ItemStack itemstack1 = itemstack.copy();
            int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
            Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);

            if (itemstack1.stackSize > itemstack1.getMaxStackSize())
            {
                itemstack1.stackSize = itemstack1.getMaxStackSize();
            }

            if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
            {
                itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
            }

            this.dragSplittingRemnant -= itemstack1.stackSize - i;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:29,代碼來源:GuiContainer.java

示例12: GuiDankNull

import net.minecraft.inventory.Container; //導入依賴的package包/類
public GuiDankNull(Container container, EntityPlayer player) {
	super(container);
	this.player = player;
	ItemStack dankNull = DankNullUtils.getDankNull(player);
	pRenderItem = new DankNullRenderItem(Minecraft.getMinecraft().renderEngine, Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager(), Minecraft.getMinecraft().getItemColors(), dankNull, false, (ContainerDankNull) container);
	numRows = dankNull.getItemDamage();
	setWidth(210);
	setHeight(140 + (numRows * 20 + numRows + 1));
	setBackgroundTexture(new ResourceLocation(ModGlobals.MODID, "textures/gui/danknullscreen" + numRows + ".png"));
}
 
開發者ID:p455w0rd,項目名稱:DankNull,代碼行數:11,代碼來源:GuiDankNull.java

示例13: applyDrag

import net.minecraft.inventory.Container; //導入依賴的package包/類
protected void applyDrag()
{
    int i = 15 - Container.calcRedstoneFromInventory(this);
    float f = 0.98F + (float)i * 0.001F;
    this.motionX *= (double)f;
    this.motionY *= 0.0D;
    this.motionZ *= (double)f;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:9,代碼來源:EntityMinecartContainer.java

示例14: Open

import net.minecraft.inventory.Container; //導入依賴的package包/類
public CommandResult Open(CommandSource src, Container opencon, String inventoryTypeIn, String title) {
    final Player player = Tools.getPlayer(src, vt);
    final EntityPlayerMP MPlayer = (EntityPlayerMP) player;
    MPlayer.getNextWindowId();
    MPlayer.connection.sendPacket(new SPacketOpenWindow(MPlayer.currentWindowId, inventoryTypeIn, new TextComponentString(title)));
    MPlayer.openContainer = opencon;
    MPlayer.openContainer.windowId = MPlayer.currentWindowId;
    MPlayer.openContainer.addListener(MPlayer);

    return CommandResult.success();
}
 
開發者ID:poqdavid,項目名稱:VirtualTool,代碼行數:12,代碼來源:Invs.java

示例15: sendSlotContents

import net.minecraft.inventory.Container; //導入依賴的package包/類
/**
 * 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();
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:GuiRepair.java


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