List of usage examples for net.minecraftforge.fluids FluidUtil getFluidContained
public static LazyOptional<FluidStack> getFluidContained(@Nonnull ItemStack container)
From source file:blusunrize.immersiveengineering.api.crafting.IngredientStack.java
public boolean matchesItemStack(ItemStack input) { if (input.isEmpty()) return false; if (this.fluid != null) { FluidStack fs = FluidUtil.getFluidContained(input); if (fs != null && fs.containsFluid(fluid)) return true; }//from w ww . j a v a 2 s .c om if (this.oreName != null) return ApiUtils.compareToOreName(input, oreName) && this.inputSize <= input.getCount(); if (this.stackList != null) { for (ItemStack iStack : this.stackList) if (OreDictionary.itemMatches(iStack, input, false) && this.inputSize <= input.getCount()) return true; } if (!OreDictionary.itemMatches(stack, input, false) || this.inputSize > input.getCount()) return false; if (this.useNBT) { if (this.stack.hasTagCompound() != input.hasTagCompound()) return false; if (!this.stack.hasTagCompound() && !input.hasTagCompound()) return true; return this.stack.getTagCompound().equals(input.getTagCompound()); } return true; }
From source file:blusunrize.immersiveengineering.api.crafting.IngredientStack.java
public boolean matchesItemStackIgnoringSize(ItemStack input) { if (input.isEmpty()) return false; if (this.fluid != null) { FluidStack fs = FluidUtil.getFluidContained(input); if (fs != null && fs.containsFluid(fluid)) return true; }/*from w w w . jav a 2 s . c o m*/ if (this.oreName != null) return ApiUtils.compareToOreName(input, oreName); if (this.stackList != null) { for (ItemStack iStack : this.stackList) if (OreDictionary.itemMatches(iStack, input, false)) return true; } if (!OreDictionary.itemMatches(stack, input, false)) return false; if (this.useNBT) { if (this.stack.hasTagCompound() != input.hasTagCompound()) return false; if (!this.stack.hasTagCompound() && !input.hasTagCompound()) return true; return this.stack.getTagCompound().equals(input.getTagCompound()); } return true; }
From source file:blusunrize.immersiveengineering.api.tool.AssemblerHandler.java
public static RecipeQuery createQueryFromItemStack(ItemStack stack) { if (FluidUtil.getFluidContained(stack) != null) return new RecipeQuery(FluidUtil.getFluidContained(stack), stack.getCount()); return new RecipeQuery(stack, stack.getCount()); }
From source file:blusunrize.immersiveengineering.client.gui.GuiFluidSorter.java
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); for (int side = 0; side < 6; side++) for (int i = 0; i < 8; i++) { int x = guiLeft + 4 + (side / 2) * 58 + (i < 3 ? i * 18 : i > 4 ? (i - 5) * 18 : i == 3 ? 0 : 36); int y = guiTop + 22 + (side % 2) * 76 + (i < 3 ? 0 : i > 4 ? 36 : 18); if (mouseX > x && mouseX < x + 16 && mouseY > y && mouseY < y + 16) { FluidStack fs = FluidUtil.getFluidContained(playerInventory.getItemStack()); setFluidInSlot(side, i, fs); }/*ww w . j a v a 2 s. c om*/ } }
From source file:blusunrize.immersiveengineering.common.blocks.metal.TileEntityBelljar.java
@SideOnly(Side.CLIENT) private ResourceLocation getSoilTexture() { ItemStack soil = inventory.get(SLOT_SOIL); ResourceLocation rl = curPlantHandler != null ? curPlantHandler.getSoilTexture(inventory.get(SLOT_SEED), soil, this) : null;//from w w w . j a v a 2 s . c o m if (rl == null) rl = BelljarHandler.getSoilTexture(soil); if (rl == null) { try { IBlockState state = Utils.getStateFromItemStack(soil); if (state != null) rl = ClientUtils.getSideTexture(state, EnumFacing.UP); } catch (Exception e) { rl = ClientUtils.getSideTexture(soil, EnumFacing.UP); } } if (rl == null && !soil.isEmpty() && Utils.isFluidRelatedItemStack(soil)) { FluidStack fs = FluidUtil.getFluidContained(soil); if (fs != null) rl = fs.getFluid().getStill(fs); } return rl; }
From source file:blusunrize.immersiveengineering.common.blocks.wooden.TileEntityWoodenBarrel.java
@Override public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) { FluidStack f = FluidUtil.getFluidContained(heldItem); boolean metal = this instanceof TileEntityMetalBarrel; if (f != null) if (!metal && f.getFluid().isGaseous(f)) { ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO + "noGasAllowed")); return true; } else if (!metal && f.getFluid().getTemperature(f) >= TileEntityWoodenBarrel.IGNITION_TEMPERATURE) { ChatUtils.sendServerNoSpamMessages(player, new TextComponentTranslation(Lib.CHAT_INFO + "tooHot")); return true; }/*from w ww . j a v a2 s . com*/ if (FluidUtil.interactWithFluidHandler(player, hand, tank)) { this.markDirty(); this.markContainingBlockForUpdate(null); return true; } return false; }
From source file:blusunrize.immersiveengineering.common.crafting.IngredientFluidStack.java
@Override public boolean apply(@Nullable ItemStack stack) { if (stack == null) { return false; } else {/*from w w w . j a v a 2 s. c o m*/ FluidStack fs = FluidUtil.getFluidContained(stack); return fs == null && this.fluid == null || fs != null && fs.containsFluid(fluid); } }
From source file:blusunrize.immersiveengineering.common.crafting.RecipeJerrycan.java
@Override public boolean matches(@Nonnull InventoryCrafting inv, World world) { ItemStack jerrycan = ItemStack.EMPTY; ItemStack container = ItemStack.EMPTY; int[] slots = getRelevantSlots(inv); if (slots[0] >= 0) jerrycan = inv.getStackInSlot(slots[0]); if (slots[1] >= 0) container = inv.getStackInSlot(slots[1]); if (!jerrycan.isEmpty() && !container.isEmpty()) { IFluidHandler handler = FluidUtil.getFluidHandler(container); FluidStack fs = handler.drain(Integer.MAX_VALUE, false); return fs == null || (fs.amount < handler.getTankProperties()[0].getCapacity() && fs.isFluidEqual(FluidUtil.getFluidContained(jerrycan))); }// w w w.j a v a 2s . co m return false; }
From source file:blusunrize.immersiveengineering.common.crafting.RecipeJerrycan.java
@Nonnull @Override//from ww w . j av a 2s . c o m public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) { ItemStack jerrycan = ItemStack.EMPTY; ItemStack container = ItemStack.EMPTY; FluidStack fs = null; int[] slots = getRelevantSlots(inv); if (slots[0] >= 0) { jerrycan = inv.getStackInSlot(slots[0]); fs = FluidUtil.getFluidContained(jerrycan); } if (slots[1] >= 0) container = inv.getStackInSlot(slots[1]); if (fs != null && !container.isEmpty()) { ItemStack newContainer = Utils.copyStackWithAmount(container, 1); IFluidHandlerItem handler = FluidUtil.getFluidHandler(newContainer); int accepted = handler.fill(fs, false); if (accepted > 0) { handler.fill(fs, true); newContainer = handler.getContainer();// Because buckets are silly // FluidUtil.getFluidHandler(jerrycan).drain(accepted,true); ItemNBTHelper.setInt(jerrycan, "jerrycanDrain", accepted); } return newContainer; } return ItemStack.EMPTY; }
From source file:blusunrize.immersiveengineering.common.crafting.RecipeJerrycan.java
private int[] getRelevantSlots(InventoryCrafting inv) { int[] ret = { -1, -1 }; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stackInSlot = inv.getStackInSlot(i); if (!stackInSlot.isEmpty()) if (ret[0] < 0 && IEContent.itemJerrycan.equals(stackInSlot.getItem()) && FluidUtil.getFluidContained(stackInSlot) != null) ret[0] = i;/*from w ww . j ava 2 s . c o m*/ else if (ret[1] < 0 && FluidUtil.getFluidHandler(stackInSlot) != null) ret[1] = i; else { ret[0] = ret[1] = -1; return ret; } } return ret; }