类net.minecraft.inventory.InventoryBasic源码实例Demo

下面列出了怎么用net.minecraft.inventory.InventoryBasic的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TofuCraftReload   文件: EntityTofunian.java
public EntityTofunian(World worldIn) {
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setSize(0.45F, 1.4F);
    ((PathNavigateGround) this.getNavigator()).setBreakDoors(true);
    this.setCanPickUpLoot(true);
}
 
源代码2 项目: NotEnoughItems   文件: NEIServerPacketHandler.java
private void openPotionGui(EntityPlayerMP player, PacketCustom packet) {
    InventoryBasic b = new InventoryBasic("potionStore", true, 9);
    for (int i = 0; i < b.getSizeInventory(); i++) {
        b.setInventorySlotContents(i, packet.readItemStack());
    }
    ServerUtils.openSMPContainer(player, new ContainerPotionCreator(player.inventory, b), (player1, windowId) -> {
        PacketCustom packet1 = new PacketCustom(channel, 24);
        packet1.writeByte(windowId);
        packet1.sendToPlayer(player1);
    });
}
 
源代码3 项目: NotEnoughItems   文件: ContainerPotionCreator.java
public ContainerPotionCreator(InventoryPlayer inventoryPlayer, IInventory potionStoreInv) {
    playerInv = inventoryPlayer;
    potionInv = new InventoryBasic("Potion", true, 1);
    this.potionStoreInv = potionStoreInv;

    addSlotToContainer(new SlotPotion(potionInv, 0, 25, 102));
    for (int i = 0; i < 9; i++) {
        addSlotToContainer(new SlotPotionStore(potionStoreInv, i, 8 + i * 18, 14));
    }
    bindPlayerInventory(inventoryPlayer, 8, 125);
}
 
源代码4 项目: NotEnoughItems   文件: ContainerPotionCreator.java
public ContainerPotionCreator(InventoryPlayer inventoryPlayer, IInventory potionStoreInv) {
    playerInv = inventoryPlayer;
    potionInv = new InventoryBasic("Potion", true, 1);
    this.potionStoreInv = potionStoreInv;

    addSlotToContainer(new SlotPotion(potionInv, 0, 25, 102));
    for (int i = 0; i < 9; i++)
        addSlotToContainer(new SlotPotionStore(potionStoreInv, i, 8 + i * 18, 14));
    bindPlayerInventory(inventoryPlayer, 8, 125);
}
 
/**
 * Keep ticking a continuous task that has already been started
 */
public void updateTask()
{
    super.updateTask();
    this.villager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.villager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.villager.world;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate))
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR)
        {
            InventoryBasic inventorybasic = this.villager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (!itemstack.isEmpty())
                {
                    if (itemstack.getItem() == Items.WHEAT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.POTATO)
                    {
                        world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.CARROT)
                    {
                        world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() instanceof net.minecraftforge.common.IPlantable) {
                        if(((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlantType(world,blockpos) == net.minecraftforge.common.EnumPlantType.Crop) {
                            world.setBlockState(blockpos, ((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlant(world,blockpos),3);
                            flag = true;
                        }
                    }
                }

                if (flag)
                {
                    itemstack.shrink(1);

                    if (itemstack.isEmpty())
                    {
                        inventorybasic.setInventorySlotContents(i, ItemStack.EMPTY);
                    }

                    break;
                }
            }
        }

        this.currentTask = -1;
        this.runDelay = 10;
    }
}
 
源代码6 项目: TofuCraftReload   文件: EntityTofunian.java
public InventoryBasic getVillagerInventory() {
    return villagerInventory;
}
 
源代码7 项目: Signals   文件: CapabilityMinecartDestination.java
public InventoryBasic getFuelInv(){
    return fuelInv;
}
 
源代码8 项目: PneumaticCraft   文件: GuiSearcher.java
/**
 * Returns the creative inventory
 */
public InventoryBasic getInventory(){
    return inventory;
}
 
源代码9 项目: HoloInventory   文件: TileRequest.java
@Override
public ResponseMessage onMessage(TileRequest message, MessageContext ctx)
{
    World world = DimensionManager.getWorld(message.dim);
    if (world == null) return null;
    TileEntity te = world.getTileEntity(message.pos);
    if (te == null) return null;

    if (Helper.banned.contains(te.getClass().getCanonicalName())) return null;
    if (te instanceof ILockableContainer && !ctx.getServerHandler().player.canOpen(((ILockableContainer) te).getLockCode())) return null;

    if (te instanceof TileEntityEnderChest)
    {
        return new PlainInventory(message.pos, ctx.getServerHandler().player.getInventoryEnderChest());
    }
    else if (te instanceof BlockJukebox.TileEntityJukebox)
    {
        InventoryBasic ib = new InventoryBasic("minecraft:jukebox", false, 1);
        ib.setInventorySlotContents(0, ((BlockJukebox.TileEntityJukebox) te).getRecord());
        return new PlainInventory(message.pos, ib).setName(Blocks.JUKEBOX.getUnlocalizedName());
    }
    else if (te instanceof TileEntityChest)
    {
        Block b = world.getBlockState(message.pos).getBlock();
        if (b instanceof BlockChest)
        {
            IInventory i = ((BlockChest) b).getLockableContainer(world, message.pos);
            if (i != null) return new PlainInventory(message.pos, i);
            return null;
        }
        return new PlainInventory(message.pos, ((TileEntityChest) te));
    }
    else if (te instanceof IInventory)
    {
        return new PlainInventory(message.pos, (IInventory) te);
    }
    else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
    {
        IItemHandler iih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        if (iih == null)
        {
            HoloInventory.getLogger().warn("Error: Block at {} (Class: {} Te: {} Block: {}) returned null after indicating the capability is available.", message.pos, te.getClass().getName(), te, te.getBlockType());
            return null;
        }
        if (te instanceof INamedItemHandler) {
        	INamedItemHandler namedHandler = (INamedItemHandler) te;
        	return new PlainInventory(message.pos, namedHandler.getItemHandlerName(), iih);
        }
        return new PlainInventory(message.pos, te.getBlockType().getUnlocalizedName(), iih);
    }

    return null;
}