• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IDrawer类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer的典型用法代码示例。如果您正苦于以下问题:Java IDrawer类的具体用法?Java IDrawer怎么用?Java IDrawer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

IDrawer类属于com.jaquadro.minecraft.storagedrawers.api.storage包,在下文中一共展示了IDrawer类的34个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getItemHandler

点赞 3

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public static IItemHandler getItemHandler(World world, BlockPos pos, EnumFacing side, boolean includeEntities) {
	TileEntity te = world.getTileEntity(pos);
	if (te instanceof IDrawer) {
		return new DrawerWrapper((IDrawer) te);
	} else if (te instanceof IDrawerGroup) {
		return new DrawerGroupWrapper((IDrawerGroup) te);
	} else if (te == null || !te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
		IInventory inv = includeEntities ? TileEntityHopper.getInventoryAtPosition(world, pos.getX(), pos.getY(), pos.getZ()) : (te instanceof IInventory ? (IInventory) te : null);
		if (inv != null) {
			if (inv instanceof ISidedInventory) {
				return new SidedInvWrapper((ISidedInventory) inv, side);
			} else {
				return new InvWrapper(inv);
			}
		} else
			return null;
	} else {
		return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
	}
}
 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:21,
代码来源:TomsModUtils.java

示例2: setStoredItem

点赞 3

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public void setStoredItem (int slot, ItemStack itemPrototype, int amount) {
    if (itemPrototype != null && convRate != null && convRate[0] == 0) {
        //populateSlots(itemPrototype);
        for (int i = 0; i < getDrawerCount(); i++) {
            if (BaseDrawerData.areItemsEqual(protoStack[i], itemPrototype))
                pooledCount = (pooledCount % convRate[i]) + convRate[i] * amount;
        }

        for (int i = 0; i < getDrawerCount(); i++) {
            if (i == slot)
                continue;

            IDrawer drawer = getDrawer(i);
            if (drawer instanceof CompDrawerData)
                ((CompDrawerData) drawer).refresh();
        }
    }
    else if (itemPrototype == null) {
        setStoredItemCount(slot, 0);
    }
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:23,
代码来源:DummyCentralInventory.java

示例3: onTransferInventory

点赞 3

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public void onTransferInventory(IInventory target, BlockData data,
		EntityPlayer player, World world, int x, int y, int z, int side,
		float hitX, float hitY, float hitZ) {
	if(data.tileData == null || data.tileData.hasNoTags())
		return;
	List<IDrawer> drawers=getDrawers(data);
	if(drawers == null || drawers.isEmpty())
		return;
	for(IDrawer drawer : drawers){
		while(drawer.getStoredItemCount() > 0){
			ItemStack stack = drawer.getStoredItemCopy();
			if(stack == null || stack.stackSize < 1)
				break;
			if(!drawer.canItemBeExtracted(stack))
				break;
			int orig = stack.stackSize;
			InventoryMerger.mergeStackIntoInventory(stack, target, side);
			int dif = orig-stack.stackSize;
			if(dif == 0)
				break;
			drawer.setStoredItemCount(drawer.getStoredItemCount()-dif);
		}
	}
	setDrawers(drawers, data);
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:27,
代码来源:StorageDrawersDollyTileHandler.java

示例4: getDrawers

点赞 3

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
private List<IDrawer> getDrawers(BlockData data){
	if(data.block instanceof BlockCompDrawers)
		return getCompDrawers(data);
	int capacity = data.tileData.getInteger("Cap");
	EnumSet<LockAttribute> lockAttributes = null;
       if (data.tileData.hasKey("Lock"))
           lockAttributes = LockAttribute.getEnumSet(data.tileData.getByte("Lock"));
       DummyStorageProvider provider = new DummyStorageProvider(capacity, lockAttributes);
	
	NBTTagList slots = data.tileData.getTagList("Slots", Constants.NBT.TAG_COMPOUND);
	List<IDrawer> drawers = new ArrayList<IDrawer>();
	for (int i = 0, n = slots.tagCount(); i < n; i++) {
           NBTTagCompound slot = slots.getCompoundTagAt(i);
           IDrawer drawer = createDrawer(provider, i);
           drawer.readFromNBT(slot);
           drawers.add(drawer);
       }
	return drawers;
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:20,
代码来源:StorageDrawersDollyTileHandler.java

示例5: setCompDrawers

点赞 3

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
private void setCompDrawers(List<IDrawer> drawers, BlockData data){
	NBTTagList slots = new NBTTagList();
	for(IDrawer drawer : drawers){
		NBTTagCompound nbt = new NBTTagCompound();
		drawer.writeToNBT(nbt);
		slots.appendTag(nbt);
	}
	data.tileData.setTag("Slots", slots);
	DummyCentralInventory centralInventory = ((CompDrawerDataWrapper) drawers.get(0)).centralInventoryDummy;
	
	data.tileData.setInteger("Count", centralInventory.pooledCount);

       if (data.tileData.hasKey("Conv0") || centralInventory.getConvRates()[0] > 0)
       	data.tileData.setByte("Conv0", (byte)centralInventory.getConvRates()[0]);
       if (data.tileData.hasKey("Conv1") || centralInventory.getConvRates()[1] > 0)
       	data.tileData.setByte("Conv1", (byte)centralInventory.getConvRates()[1]);
       if (data.tileData.hasKey("Conv1") || centralInventory.getConvRates()[2] > 0)
       	data.tileData.setByte("Conv2", (byte)centralInventory.getConvRates()[2]);
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:20,
代码来源:StorageDrawersDollyTileHandler.java

示例6: extractItem

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public static ItemStack extractItem(IDrawer drawer, int amount, boolean simulate) {
	if (drawer.isEmpty()) {
		return ItemStack.EMPTY;
	} else if (drawer.canItemBeExtracted(drawer.getStoredItemPrototype())) {
		int ext = Math.min(drawer.getStoredItemCount(), amount);
		ItemStack s = drawer.getStoredItemPrototype().copy();
		if (!simulate)
			drawer.setStoredItemCount(drawer.getStoredItemCount() - ext);
		s.setCount(ext);
		return s;
	} else {
		return ItemStack.EMPTY;
	}
}
 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:15,
代码来源:DrawerWrapper.java

示例7: getStackInSlot

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public ItemStack getStackInSlot(int slot) {
	IDrawer d = drawer.getDrawer(slot);
	ItemStack s = d.getStoredItemPrototype().copy();
	s.setCount(d.getStoredItemCount());
	return s;
}
 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:8,
代码来源:DrawerGroupWrapper.java

示例8: rebuildBitLookup

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
protected void rebuildBitLookup (Map<Integer, List<SlotRecord>> lookup, List<SlotRecord> records) {
    lookup.clear();
    boolean invBased = false;

    for (int i = 0; i < records.size(); i++) {
        SlotRecord record = records.get(i);
        IDrawerGroup group = getGroupForSlotRecord(record);
        if (group == null)
            continue;

        int drawerSlot = (invBased) ? group.getDrawerInventory().getDrawerSlot(record.slot) : record.slot;
        if (!group.isDrawerEnabled(drawerSlot))
            continue;

        IDrawer drawer = group.getDrawer(drawerSlot);
        if (drawer.isEmpty())
            continue;

        ItemStack item = drawer.getStoredItemPrototype();
        if (BitDrawers.cnb_api.getItemType(item) == ItemType.CHISLED_BIT) {
            try {
                IBitBrush brush = BitDrawers.cnb_api.createBrush(item);
                if (BitDrawers.config.debugTrace)
                    BDLogger.info("Rebuilding: %s %d %d %d", item.getDisplayName(), record.slot, i, brush.getStateID());
                List<SlotRecord> slotRecords = lookup.get(brush.getStateID());
                if (slotRecords == null) {
                    slotRecords = new ArrayList<>();
                    lookup.put(brush.getStateID(), slotRecords);
                }
                slotRecords.add(record);
            } catch (APIExceptions.InvalidBitItem invalidBitItem) {}
        }
    }
    if (BitDrawers.config.debugTrace)
        BDLogger.info("Rebuilt: %d entries", lookup.size());
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:37,
代码来源:TileBitController.java

示例9: getAccessibleBitDrawer

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
protected IDrawer getAccessibleBitDrawer(SlotRecord slotRecord, GameProfile profile) {
    if (slotRecord == null)
        return null;
    IDrawerGroup group = this.getGroupForSlotRecord(slotRecord);
    if (!(group instanceof IProtectable) || SecurityManager.hasAccess(profile, (IProtectable) group)) {
        return group.getDrawer(slotRecord.slot);
    }
    return null;
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:10,
代码来源:TileBitController.java

示例10: fillBag

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public int fillBag(IBitBag bag, GameProfile profile) {
    final Integer result[] = new Integer[1];
    result[0] = 0;
    if (BitDrawers.config.debugTrace)
        BDLogger.info("TileBitController.fillBag");
    
    drawerBitLookup.forEach((blockStateID, slotList) -> {
        try {
            ItemStack bit = BitDrawers.cnb_api.getBitItem(new BitBrush(blockStateID).getState());
            int addSlot = -1;
            for (int i = 0; i < bag.getSlots(); i++) {
                ItemStack test = bag.getStackInSlot(i);
                if (test == null) {
                    if (addSlot == -1)
                        addSlot = i;
                    continue;
                }
                if (test.stackSize < bag.getBitbagStackSize() && BitHelper.areItemsEqual(test, bit)) {
                    addSlot = i;
                    break;
                }
            }
            final int doAddSlot = addSlot;
            
            if (addSlot > -1) {
                slotList.stream().forEachOrdered(slotRecord -> {
                    IDrawer drawer = getAccessibleBitDrawer(slotRecord, profile);
                    if (drawer != null)
                        result[0] += fillBagSlot(bag, doAddSlot, drawer);
                });
            }
        } catch (APIExceptions.InvalidBitItem invalidBitItem) {}
    });
    
    return result[0];
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:37,
代码来源:TileBitController.java

示例11: fillBagSlot

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
protected int fillBagSlot(IBitBag bag, int slot, IDrawer drawer) {
    if (BitDrawers.config.debugTrace)
        BDLogger.info("TileBitController:fillBagSlot %d %s", slot, drawer.getStoredItemPrototype()==null?"null":drawer.getStoredItemPrototype().getDisplayName());
    if (drawer.getStoredItemCount() == 0)
        return 0;
    
    int toAdd = bag.getBitbagStackSize();
    ItemStack item = bag.getStackInSlot(slot);
    if (item != null)
        toAdd -= item.stackSize;
    item = drawer.getStoredItemPrototype().copy();
    item.stackSize = toAdd;
    ItemStack test = bag.insertItem(slot, item.copy(), true);
    if (test != null) {
        toAdd -= test.stackSize;
    }
    if (toAdd == 0)
        return 0;
    
    toAdd = Math.min(toAdd, drawer.getStoredItemCount());
    drawer.setStoredItemCount(drawer.getStoredItemCount() - toAdd);
    item.stackSize = toAdd;
    test = bag.insertItem(slot, item, false);
    if (test != null) {
        if (test.stackSize != 0) {
            BDLogger.error("Could not insert simulated bit amount into bag. Something went very wrong.");
        }
    }

    return toAdd;
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:32,
代码来源:TileBitController.java

示例12: putItemsIntoSlot

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public int putItemsIntoSlot (int slot, ItemStack stack, int count) {
    if (BitDrawers.config.debugTrace)
        BDLogger.info("TileBitDrawers:putItemsIntoSlot %d %s %d", slot, stack==null?"null":stack.getDisplayName(), count);
    int added = 0;
    if (stack != null) {
        if (BitDrawers.cnb_api.getItemType(stack) == ItemType.CHISLED_BLOCK) {
            return putChiseledBlockIntoDrawer(stack, count);
        } else if (convRate != null && convRate[0] == 0) {
            populateSlots(stack);

            for (int i = 0; i < getDrawerCount(); i++) {
                if (BaseDrawerData.areItemsEqual(protoStack[i], stack))
                    added = super.putItemsIntoSlot(i, stack, count);
            }

            for (int i = 0; i < getDrawerCount(); i++) {
                IDrawer drawer = getDrawer(i);
                if (drawer instanceof BitDrawerData)
                    ((BitDrawerData) drawer).refresh();
            }

        }
    }

    return added + super.putItemsIntoSlot(slot, stack, count);
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:28,
代码来源:TileBitDrawers.java

示例13: putChiseledBlockIntoDrawer

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public int putChiseledBlockIntoDrawer (ItemStack stack, int count) {
    if (BitDrawers.config.debugTrace)
        BDLogger.info("TileBitDrawers:putChiseledBlockIntoDrawer %s %d", stack==null?"null":stack.getDisplayName(), count);
    count = Math.min(count, stack.stackSize);
    IDrawer drawer = getDrawer(1);
    IBitAccess access = BitDrawers.cnb_api.createBitItem(stack);
    if (convRate == null || convRate[0] == 0 || access == null)
        return 0;
    BitHelper.BitCounter counter = new BitHelper.BitCounter();
    access.visitBits(counter);
    IBitBrush stored = null;
    try {
        stored = BitDrawers.cnb_api.createBrush(drawer.getStoredItemPrototype());
    } catch (APIExceptions.InvalidBitItem invalidBitItem) {
        BDLogger.error("Failed to create bit brush for stored bit");
        BDLogger.error(invalidBitItem);
        return 0;
    }
    if (counter.counts.size() != 1 || !counter.counts.containsKey(stored.getStateID()) || counter.counts.get(stored.getStateID()) == 0) {
        if (BitDrawers.config.debugTrace)
            BDLogger.info("TileBitDrawers:putChiseledBlockIntoDrawer Not Matched %d", counter.counts.size());
        return 0;
    }
    
    int bitSize = counter.counts.get(stored.getStateID());
    int canStore = isVoid()?count:drawer.getRemainingCapacity() / bitSize;
    int toStore = Math.min(canStore, count);
    int toStoreBits = toStore * bitSize;
    ItemStack store = drawer.getStoredItemPrototype().copy();
    store.stackSize = toStoreBits;
    int storedBits = super.putItemsIntoSlot(1, store, toStoreBits);
    if (storedBits != toStoreBits) {
        BDLogger.error("Couldn't store bits when inserting chiseled block. This is not supposed to happen at this point.");
        toStore = storedBits / bitSize;
    }
    stack.stackSize -= toStore;
    return toStore;
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:39,
代码来源:TileBitDrawers.java

示例14: readFromPortableNBT

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public void readFromPortableNBT (NBTTagCompound tag) {
    pooledCount = 0;

    for (int i = 0; i < getDrawerCount(); i++) {
        protoStack[i] = null;
        convRate[i] = 0;
    }

    super.readFromPortableNBT(tag);

    pooledCount = tag.getInteger("Count");

    if (tag.hasKey("Conv0"))
        convRate[0] = tag.getInteger("Conv0");
    if (tag.hasKey("Conv1"))
        convRate[1] = tag.getInteger("Conv1");
    if (tag.hasKey("Conv2"))
        convRate[2] = tag.getInteger("Conv2");

    for (int i = 0; i < getDrawerCount(); i++) {
        IDrawer drawer = getDrawer(i);
        if (drawer instanceof BitDrawerData)
            ((BitDrawerData) drawer).refresh();
    }

    if (getWorld() != null && !getWorld().isRemote) {
        IBlockState state = getWorld().getBlockState(getPos());
        getWorld().notifyBlockUpdate(getPos(), state, state, 3);
    }
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:32,
代码来源:TileBitDrawers.java

示例15: setStoredItem

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public IDrawer setStoredItem (int slot, ItemStack itemPrototype, int amount) {
    if (BitDrawers.config.debugTrace)
        BDLogger.info("setStoredItem %d %s %d", slot, itemPrototype==null?"null":itemPrototype.getDisplayName(), amount);
    if (itemPrototype != null && convRate != null && convRate[0] == 0) {
        populateSlots(itemPrototype);
        for (int i = 0; i < getDrawerCount(); i++) {
            if (BaseDrawerData.areItemsEqual(protoStack[i], itemPrototype))
                pooledCount = (pooledCount % convRate[i]) + convRate[i] * amount;
        }

        for (int i = 0; i < getDrawerCount(); i++) {
            if (i == slot)
                continue;

            IDrawer drawer = getDrawer(i);
            if (drawer instanceof BitDrawerData)
                ((BitDrawerData) drawer).refresh();
        }

        if (getWorld() != null && !getWorld().isRemote) {
            IBlockState state = getWorld().getBlockState(getPos());
            getWorld().notifyBlockUpdate(getPos(), state, state, 3);
        }
    }
    else if (itemPrototype == null) {
        setStoredItemCount(slot, 0);
    }
    return getDrawer(slot);
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:31,
代码来源:TileBitDrawers.java

示例16: refresh

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public void refresh () {
    for (int i = 0; i < getDrawerCount(); i++) {
        IDrawer drawer = getDrawer(i);
        if (drawer instanceof BitDrawerData)
            ((BitDrawerData) drawer).refresh();
    }
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:8,
代码来源:TileBitDrawers.java

示例17: fillBagSlot

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
protected int fillBagSlot(IBitBag bag, int slot, IDrawer drawer, TileEntityDrawers tileDrawers) {
    int toAdd = bag.getBitbagStackSize();
    ItemStack item = bag.getStackInSlot(slot);
    if (item != null)
        toAdd -= item.stackSize;
    item = drawer.getStoredItemPrototype().copy();
    item.stackSize = toAdd;
    ItemStack test = bag.insertItem(slot, item.copy(), true);
    if (test != null) {
        toAdd -= test.stackSize;
    }
    if (toAdd == 0)
        return 0;
    int retrieved = 0;
    while (true) {
        ItemStack temp = tileDrawers.takeItemsFromSlot(1, toAdd);
        if (temp == null || temp.stackSize == 0)
            break;
        retrieved += temp.stackSize;
        toAdd -= temp.stackSize;
        if (toAdd == 0)
            break;
    }
    if (retrieved == 0)
        return 0;
    item.stackSize = retrieved;
    test = bag.insertItem(slot, item, false);
    if (test != null) {
        if (test.stackSize != 0) {
            BDLogger.error("Could not insert simulated bit amount into bag. Something went very wrong.");
        }
    }
    
    return retrieved;
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:36,
代码来源:BlockBitDrawers.java

示例18: setStoredItemRedir

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public IDrawer setStoredItemRedir (ItemStack itemPrototype, int amount) {
    IDrawer target = central.setStoredItem(slot, itemPrototype, amount);
    refresh();

    return target;
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:8,
代码来源:BitDrawerData.java

示例19: DummyCentralInventory

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public DummyCentralInventory(ItemStack[] protoStack, int pooledCount, int[] convRate, 
		EnumSet<LockAttribute> lockAttributes, int capacity){
	this.protoStack=protoStack;
	this.pooledCount = pooledCount;
	this.convRate = convRate;
	this.lockAttributes = lockAttributes;
	this.capacity = capacity;
	drawers = new IDrawer[3];
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:10,
代码来源:DummyCentralInventory.java

示例20: refresh

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public void refresh () {
    for (int i = 0; i < getDrawerCount(); i++) {
        IDrawer drawer = getDrawer(i);
        if (drawer instanceof CompDrawerData)
            ((CompDrawerData) drawer).refresh();
    }
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:8,
代码来源:DummyCentralInventory.java

示例21: canTransferInventory

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public boolean canTransferInventory(BlockData data, EntityPlayer player) {
	if(data.tileData == null || data.tileData.hasNoTags())
		return false;
	List<IDrawer> drawers=getDrawers(data);
	if(drawers == null || drawers.isEmpty())
		return false;
	for(IDrawer drawer : drawers){
		if(drawer.getStoredItemCount() > 0)
			return true;
	}
	return false;
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:14,
代码来源:StorageDrawersDollyTileHandler.java

示例22: getCompDrawers

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
private List<IDrawer> getCompDrawers(BlockData data){
	int capacity = data.tileData.getInteger("Cap");
	EnumSet<LockAttribute> lockAttributes = null;
       if (data.tileData.hasKey("Lock"))
           lockAttributes = LockAttribute.getEnumSet(data.tileData.getByte("Lock"));
       DummyCentralInventory centralInventory = new DummyCentralInventory(new ItemStack[3], 0, new int[3], lockAttributes, capacity);
       
       NBTTagList slots = data.tileData.getTagList("Slots", Constants.NBT.TAG_COMPOUND);
	List<IDrawer> drawers = new ArrayList<IDrawer>();
	for (int i = 0, n = slots.tagCount(); i < n; i++) {
           NBTTagCompound slot = slots.getCompoundTagAt(i);
           centralInventory.getDrawers()[i] = createDrawer(centralInventory, i);
           centralInventory.getDrawers()[i].readFromNBT(slot);
           drawers.add(centralInventory.getDrawers()[i]);
       }
	centralInventory.pooledCount = data.tileData.getInteger("Count");

       if (data.tileData.hasKey("Conv0"))
       	centralInventory.getConvRates()[0] = data.tileData.getByte("Conv0");
       if (data.tileData.hasKey("Conv1"))
       	centralInventory.getConvRates()[1] = data.tileData.getByte("Conv1");
       if (data.tileData.hasKey("Conv2"))
       	centralInventory.getConvRates()[2] = data.tileData.getByte("Conv2");

       for (int i = 0; i < drawers.size(); i++) {
           IDrawer drawer = drawers.get(i);
           if (drawer instanceof CompDrawerData)
               ((CompDrawerData) drawer).refresh();
       }

	return drawers;
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:33,
代码来源:StorageDrawersDollyTileHandler.java

示例23: setDrawers

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
private void setDrawers(List<IDrawer> drawers, BlockData data){
	if(data.block instanceof BlockCompDrawers){
		setCompDrawers(drawers, data);
		return;
	}
	NBTTagList slots = new NBTTagList();
	for(IDrawer drawer : drawers){
		NBTTagCompound nbt = new NBTTagCompound();
		drawer.writeToNBT(nbt);
		slots.appendTag(nbt);
	}
	data.tileData.setTag("Slots", slots);
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:14,
代码来源:StorageDrawersDollyTileHandler.java

示例24: DrawerWrapper

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public DrawerWrapper(IDrawer drawer) {
	this.drawer = drawer;
}
 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:4,
代码来源:DrawerWrapper.java

示例25: getSlotLimit

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
public int getSlotLimit(int slot) {
	IDrawer d = drawer.getDrawer(slot);
	return d.getMaxCapacity(d.getStoredItemPrototype());
}
 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:6,
代码来源:DrawerGroupWrapper.java

示例26: DrawerPopulatedEvent

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public DrawerPopulatedEvent (IDrawer drawer) {
    this.drawer = drawer;
}
 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:4,
代码来源:DrawerPopulatedEvent.java

示例27: insertChiseledBlocks

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
protected int insertChiseledBlocks(ItemStack stack, GameProfile profile) {
    if (BitDrawers.config.debugTrace)
        BDLogger.info("TileBitController:insertChiseledBlocks %s", stack==null?"null":stack.getDisplayName());
    if (stack == null)
        return 0;
    if (BitDrawers.cnb_api.getItemType(stack) == ItemType.CHISLED_BLOCK) {
        IBitAccess access = BitDrawers.cnb_api.createBitItem(stack);
        if (access == null)
            return 0;
        BitHelper.BitCounter counter = new BitHelper.BitCounter();
        access.visitBits(counter);
        List<BitCollectorData> data = null;
        
        try {
            data = BitCollectorData.collect(counter);
        } catch (APIExceptions.InvalidBitItem invalidBitItem) {
            BDLogger.error("Failed to create bit brush for stored bit");
            BDLogger.error(invalidBitItem);
            return 0;
        }
        
        data.stream().forEachOrdered(bitData -> {
            for (Integer slot : this.enumerateDrawersForInsertion(bitData.stack, true)) {
                IDrawerGroup group = this.getGroupForDrawerSlot(slot);
                if (!(group instanceof IProtectable) || SecurityManager.hasAccess(profile, (IProtectable) group)) {
                    IDrawer drawer = this.getDrawer(slot);
                    ItemStack itemProto = drawer.getStoredItemPrototype();
                    if (itemProto == null) {
                        break;
                    }

                    bitData.drawers.add(drawer);
                    if (bitData.canStore >= 0) {
                        if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) {
                            bitData.canStore = -1;
                        } else {
                            bitData.canStore += drawer.getRemainingCapacity();
                        }
                    }

                }
            }
            
            bitData.calc();
        });
        
        OptionalInt test = data.stream().mapToInt(x -> x.canStoreItems).min();
        final int maxItems = Math.min(test.isPresent()?test.getAsInt():0, stack.stackSize);
        
        if (maxItems == 0) {
            if (BitDrawers.config.debugTrace)
                BDLogger.info("TileBitController:insertChiseledBlocks No Space");
            return 0;
        }
        
        data.stream().forEachOrdered(bitData -> {
            bitData.toStore(maxItems);
            bitData.drawers.stream().forEachOrdered(drawer -> {
                if (bitData.toStore > 0) {
                    int stored = insertItemsIntoDrawer(drawer, bitData.toStore);
                    if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) {
                        bitData.toStore = 0;
                    } else {
                        bitData.stored(stored);
                    }
                }
            });
        });
        
        OptionalInt left = data.stream().mapToInt(x -> x.toStore).max();
        if (left.isPresent() && left.getAsInt() > 0) {
            BDLogger.error("Couldn't store bits when inserting chiseled block. This is not supposed to happen at this point.");
        }
        stack.stackSize -= maxItems;
        return maxItems;
    } else {
        return -1;
    }
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:80,
代码来源:TileBitController.java

示例28: createDrawer

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Override
protected IDrawer createDrawer (int slot) {
    return new BitDrawerData(getCentralInventory(), slot);
}
 

开发者ID:Belgabor,
项目名称:DrawersBits,
代码行数:5,
代码来源:TileBitDrawers.java

示例29: getDrawer

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
IDrawer getDrawer(int slot){
	if (slot < 0 || slot >= drawers.length)
           return null;

       return drawers[slot];
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:7,
代码来源:DummyCentralInventory.java

示例30: getDrawers

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
public IDrawer[] getDrawers(){
	return drawers;
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:4,
代码来源:DummyCentralInventory.java

示例31: createDrawer

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
private IDrawer createDrawer(DummyCentralInventory centralInventory, int slot){
	return new CompDrawerDataWrapper(centralInventory, slot);
}
 

开发者ID:AnimeniacYuuto,
项目名称:InventoryTools,
代码行数:4,
代码来源:StorageDrawersDollyTileHandler.java

示例32: getDrawer

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Nonnull
@Override
public IDrawer getDrawer(int slot) {
	return this;
}
 

开发者ID:Aroma1997,
项目名称:BetterChests,
代码行数:6,
代码来源:BlockHandler.java

示例33: setStoredItem

点赞 2

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
@Nonnull
@Override
public IDrawer setStoredItem(@Nonnull ItemStack itemPrototype) {
	buffer = itemPrototype.copy();
	return this;
}
 

开发者ID:Aroma1997,
项目名称:BetterChests,
代码行数:7,
代码来源:BlockHandler.java

示例34: transformItemName

点赞 1

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; //导入依赖的package包/类
String transformItemName (IDrawer drawer, String defaultName); 

开发者ID:tom5454,
项目名称:Toms-Mod,
代码行数:2,
代码来源:IWailaTooltipHandler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)