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()); } }
@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; }
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; }
@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()); }
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; }
/** * 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)); } }
public GuiAnimaGenerator(Container inventorySlotsIn) { super(inventorySlotsIn); xSize = WIDTH; ySize = HEIGHT; }
@Override public void handleClientSide(PacketUpdateGui message, EntityPlayer player) { Container container = player.openContainer; if (container instanceof ContainerPneumaticBase) { ((ContainerPneumaticBase) container).updateField(message.syncId, message.value); } }
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))); } }
public GuiBarrel(Container inventorySlotsIn, TileEntityBarrel te) { super(inventorySlotsIn); this.te = te; this.xSize = 176; this.ySize = 166; te.getAltar(true); }
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; } } }
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")); }
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; }
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(); }
/** * 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(); } } }
/** * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual * contents of that slot. */ public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack) { if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting)) { if (!this.isChangingQuantityOnly) { this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack)); } } }
@Override public void sendContainerToPlayer(Container containerIn) { if(m_realPlayer != null) { syncToRealPlayer(); m_realPlayer.sendContainerToPlayer(containerIn); syncPublicFieldsFromReal(); } else { super.sendContainerToPlayer(containerIn); } }
@Override public void sendAllContents(Container containerToSend, NonNullList<ItemStack> itemsList) { if(m_realPlayer != null) { syncToRealPlayer(); m_realPlayer.sendAllContents(containerToSend, itemsList); syncPublicFieldsFromReal(); } else { super.sendAllContents(containerToSend, itemsList); } }
private void updateDragSplitting() { ItemStack itemstack = this.mc.player.inventory.getItemStack(); if (!itemstack.func_190926_b() && this.dragSplitting) { if (this.dragSplittingLimit == 2) { this.dragSplittingRemnant = itemstack.getMaxStackSize(); } else { this.dragSplittingRemnant = itemstack.func_190916_E(); for (Slot slot : this.dragSplittingSlots) { ItemStack itemstack1 = itemstack.copy(); ItemStack itemstack2 = slot.getStack(); int i = itemstack2.func_190926_b() ? 0 : itemstack2.func_190916_E(); Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i); int j = Math.min(itemstack1.getMaxStackSize(), slot.getItemStackLimit(itemstack1)); if (itemstack1.func_190916_E() > j) { itemstack1.func_190920_e(j); } this.dragSplittingRemnant -= itemstack1.func_190916_E() - i; } } } }
@Override public void sendWindowProperty(Container containerIn, int varToUpdate, int newValue) { if(m_realPlayer != null) { syncToRealPlayer(); m_realPlayer.sendWindowProperty(containerIn, varToUpdate, newValue); syncPublicFieldsFromReal(); } else { super.sendWindowProperty(containerIn, varToUpdate, newValue); } }
/** * 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) { this.mc.playerController.sendSlotPacket(stack, slotInd); }
@Override public Container createServerGui(EntityPlayer player, World world, int x, int y, int z) { return new BundlerContainer(player.inventory, (BundlerEntity) world.getTileEntity(new BlockPos(x, y, z))); }
public int getComparatorInputOverride(World worldIn, BlockPos pos) { return Container.calcRedstone(worldIn.getTileEntity(pos)); }
@Override public Container createServerGui(EntityPlayer player, World world, int x, int y, int z) { return new RemoteShellContainer(player.inventory, (RemoteShellEntity) world.getTileEntity(new BlockPos(x, y, z))); }
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerEnchantment(playerInventory, this.world, this.pos); }
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerShulkerBox(playerInventory, this, playerIn); }
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerHopper(playerInventory, this, playerIn); }
/** * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual * contents of that slot. */ public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack) { this.mc.playerController.sendSlotPacket(stack, slotInd); }
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) { return Container.calcRedstone(worldIn.getTileEntity(pos)); }
public void func_175173_a(Container p_175173_1_, IInventory p_175173_2_) { }
@Override public abstract Container createServerGui(EntityPlayer player, World world, int x, int y, int z);
public GuiLiquidCompressor(Container container, TileEntityLiquidCompressor te, String texture) { super(container, te, texture); }
/** * update the crafting window inventory with the items in the list */ public void updateCraftingInventory(Container containerToSend, List<ItemStack> itemsList) { }
public InventoryWorkbenchAdditionalMaterials(Container container_, int size) { stackList = new ItemStack[size]; container = container_; }