本文整理汇总了Java中codechicken.lib.inventory.InventoryUtils类的典型用法代码示例。如果您正苦于以下问题:Java InventoryUtils类的具体用法?Java InventoryUtils怎么用?Java InventoryUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InventoryUtils类属于codechicken.lib.inventory包,在下文中一共展示了InventoryUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findIngred
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public DistributedIngred findIngred(final List<DistributedIngred> ingredStacks, final ItemStack pstack) {
for (final DistributedIngred istack : ingredStacks) {
if (istack.isSaw) {
if (this.sameSaw(pstack, istack.stack)) {
return istack;
}
continue;
}
else {
if (InventoryUtils.canStack(pstack, istack.stack)) {
return istack;
}
continue;
}
}
return null;
}
示例2: givePlayerItem
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
if (stack.getItem() == null) {
player.addChatComponentMessage(setColour(new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
return;
}
int given = stack.stackSize;
if(doGive) {
if (infinite)
player.inventory.addItemStackToInventory(stack);
else
given -= InventoryUtils.insertItem(player.inventory, stack, false);
}
sendNotice(player, new ChatComponentTranslation("commands.give.success", stack.func_151000_E(), infinite ? "\u221E" : Integer.toString(given), player.getCommandSenderName()), "notify-item");
player.openContainer.detectAndSendChanges();
}
示例3: slotClick
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
@Override
public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, int modifier) {
ItemStack held = player.inventory.getItemStack();
if (button == 0 && modifier == 1) {
NEIClientUtils.cheatItem(getStack(), button, -1);
} else if (button == 1) {
putStack(null);
} else if (held != null) {
if (isItemValid(held)) {
putStack(InventoryUtils.copyStack(held, 1));
player.inventory.setItemStack(null);
}
} else if (getHasStack())
player.inventory.setItemStack(getStack());
return null;
}
示例4: fillTankWithContainer
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player)
{
ItemStack stack = player.getCurrentEquippedItem();
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if(liquid == null)
return false;
if(tank.fill(ForgeDirection.UNKNOWN, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode)
return false;
tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if(!player.capabilities.isCreativeMode)
InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);
player.inventoryContainer.detectAndSendChanges();
return true;
}
示例5: fillTankWithContainer
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player) {
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (liquid == null) {
return false;
}
if (tank.fill(liquid, false) != liquid.amount && !player.capabilities.isCreativeMode) {
return false;
}
tank.fill(liquid, true);
if (!player.capabilities.isCreativeMode) {
InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);
}
player.inventoryContainer.detectAndSendChanges();
return true;
}
示例6: givePlayerItem
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
if (stack.getItem() == null) {
player.addChatComponentMessage(setColour(new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
return;
}
int given = stack.stackSize;
if(doGive) {
if (infinite)
player.inventory.addItemStackToInventory(stack);
else
given -= InventoryUtils.insertItem(player.inventory, stack, false);
}
sendNotice(player, new ChatComponentTranslation("commands.give.success", stack.getChatComponent(), infinite ? "\u221E" : Integer.toString(given), player.getCommandSenderName()), "notify-item");
player.openContainer.detectAndSendChanges();
}
示例7: isSatsified
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
private boolean isSatsified(ItemAttachment ia, InventoryRange access) {
boolean filterSet = false;
for (ItemStack filter : ia.filters) {
if (!filter.isEmpty()) {
filterSet = true;
if (ia.regulate) {
if (countMatchingStacks(access, filter, !ia.a_eject) < filterCount(ia, filter)) {
return false;
}
} else {
if (InventoryUtils.getInsertibleQuantity(access, filter) > 0) {
return false;
}
}
}
}
return filterSet || !hasEmptySpace(access);
}
示例8: insertAmount
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
private int insertAmount(ItemStack stack, ItemAttachment ia, InventoryRange range) {
int filter = filterCount(ia, stack);
if (filter == 0) {
return 0;
}
int fit = InventoryUtils.getInsertibleQuantity(range, stack);
if (fit == 0) {
return 0;
}
if (ia.regulate && filter > 0) {
fit = Math.min(fit, filter - countMatchingStacks(range, stack, true));
}
return fit > 0 ? fit : 0;
}
示例9: activate
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public void activate(int subHit, EntityPlayer player) {
ItemStack held = player.inventory.getCurrentItem();
if (held.isEmpty()) {
if (!items[subHit].isEmpty()) {
giveOrDropItem(items[subHit], player);
}
items[subHit] = ItemStack.EMPTY;
} else {
if (!InventoryUtils.areStacksIdentical(held, items[subHit])) {
ItemStack old = items[subHit];
items[subHit] = ItemUtils.copyStack(held, 1);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
if (!old.isEmpty()) {
giveOrDropItem(old, player);
}
}
}
timeout = 2400;
IBlockState state = world.getBlockState(getPos());
world.notifyBlockUpdate(getPos(), state, state, 3);
markDirty();
}
示例10: givePlayerItem
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
if (stack.getItem() == null) {
player.sendMessage(setColour(new TextComponentTranslation("nei.chat.give.noitem"), TextFormatting.WHITE));
return;
}
int given = stack.getCount();
if (doGive) {
if (infinite) {
player.inventory.addItemStackToInventory(stack);
} else {
given -= InventoryUtils.insertItem(player.inventory, stack, false);
}
}
sendNotice(player, new TextComponentTranslation("commands.give.success", stack.getTextComponent(), infinite ? "\u221E" : Integer.toString(given), player.getName()), "notify-item");
player.openContainer.detectAndSendChanges();
}
示例11: saveBannedItems
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void saveBannedItems() {
File file = new File(saveDir, "banneditems.cfg");
try {
if(!file.exists())
file.createNewFile();
PrintWriter p = new PrintWriter(file);
p.println("#Saved in this format for external editing. The format isn't that hard to figure out. If you think you're up to it, modify it here!");
for (ItemStackMap.Entry<Set<String>> entry : bannedItems.entries()) {
NBTTagCompound key = InventoryUtils.savePersistant(entry.key, new NBTTagCompound());
key.removeTag("Count");
if(key.getByte("Damage") == 0) key.removeTag("Damage");
p.print(key.toString());
p.print("=[");
int i = 0;
for (String s : entry.value) {
if(i++ != 0) p.print(", ");
p.print(s);
}
p.println("]");
}
p.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例12: assignIngredients
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks)
{
ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
for(PositionedStack posstack : ingredients)//assign what we need and have
{
DistributedIngred biggestIngred = null;
ItemStack permutation = null;
int biggestSize = 0;
for(ItemStack pstack : posstack.items)
{
for(int j = 0; j < ingredStacks.size(); j++)
{
DistributedIngred istack = ingredStacks.get(j);
if(!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount-istack.distributed < pstack.stackSize)
continue;
int relsize = (istack.invAmount-istack.invAmount/istack.recipeAmount*istack.distributed)/pstack.stackSize;
if(relsize > biggestSize)
{
biggestSize = relsize;
biggestIngred = istack;
permutation = pstack;
break;
}
}
}
if(biggestIngred == null)//not enough ingreds
return null;
biggestIngred.distributed+=permutation.stackSize;
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
}
return assignedIngredients;
}
示例13: findIngred
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public DistributedIngred findIngred(List<DistributedIngred> ingredStacks, ItemStack pstack)
{
for(DistributedIngred istack : ingredStacks)
if(InventoryUtils.canStack(pstack, istack.stack))
return istack;
return null;
}
示例14: sendOpenPotionWindow
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void sendOpenPotionWindow() {
ItemStack[] potionStore = new ItemStack[9];
InventoryUtils.readItemStacksFromTag(potionStore, NEIClientConfig.global.nbt.getCompoundTag("potionStore").getTagList("items", 10));
PacketCustom packet = new PacketCustom(channel, 24);
for (ItemStack stack : potionStore)
packet.writeItemStack(stack);
packet.sendToServer();
}
示例15: dump
import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
@Override
public Iterable<String[]> dump(int mode) {
LinkedList<String[]> list = new LinkedList<String[]>();
for (ItemStack stack : ItemPanel.items)
list.add(new String[]{
Item.itemRegistry.getNameForObject(stack.getItem()),
Integer.toString(Item.getIdFromItem(stack.getItem())),
Integer.toString(InventoryUtils.actualDamage(stack)),
stack.stackTagCompound == null ? "false" : "true",
EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.itemDisplayNameShort(stack))
});
return list;
}