本文整理汇总了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());
}
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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));
}
}
示例7: GuiAnimaGenerator
import net.minecraft.inventory.Container; //导入依赖的package包/类
public GuiAnimaGenerator(Container inventorySlotsIn)
{
super(inventorySlotsIn);
xSize = WIDTH;
ySize = HEIGHT;
}
示例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);
}
}
示例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)));
}
}
示例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);
}
示例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;
}
}
}
示例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"));
}
示例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;
}
示例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();
}
示例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();
}
}
}