@Optional.Method(modid = "mekanism") private boolean finishWithMekanismHandling(HybridTank handler, ResultChance chance) { if(this.required instanceof HybridFluidGas && handler instanceof HybridGasTank) { GasStack gasOut = ((HybridFluidGas) this.required).asGasStack(); HybridGasTank gasTankHandler = (HybridGasTank) handler; int fillableGas = gasTankHandler.receiveGas(EnumFacing.UP, gasOut, false); if(chance.canProduce(this.chance)) { return fillableGas >= gasOut.amount; } return fillableGas >= gasOut.amount && gasTankHandler.receiveGas(EnumFacing.UP, gasOut, true) >= gasOut.amount; } else { FluidStack outStack = this.required.asFluidStack(); if(outStack != null) { int fillableAmount = handler.fillInternal(outStack.copy(), false); if(chance.canProduce(this.chance)) { return fillableAmount >= outStack.amount; } FluidStack copyOut = outStack.copy(); if(this.tagDisplay != null ){ copyOut.tag = this.tagDisplay.copy(); } return fillableAmount >= outStack.amount && handler.fillInternal(copyOut.copy(), true) >= copyOut.amount; } } return false; }
@Nullable @Override public FluidStack drain(FluidStack resource, boolean doDrain) { FluidStack drained = null; if(tile != null) for (EnumFacing facing : EnumFacing.HORIZONTALS) { if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing)) { IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing); drained = capability.drain(resource,doDrain); if(drained != null) break; } } return drained; }
@Override public void addTooltip(int mouseX, int mouseY, List<String> curTip, boolean shift) { Fluid fluid = null; int amt = 0; int capacity = 0; if (tank.getFluid() != null) { fluid = tank.getFluid().getFluid(); amt = tank.getFluidAmount(); } capacity = tank.getCapacity(); if (fluid == null || amt == 0 || capacity == 0) { curTip.add(amt + "/" + capacity + " mb"); curTip.add(TextFormatting.GRAY + I18n.format("gui.liquid.empty")); } else { curTip.add(amt + "/" + capacity + " mb"); curTip.add(TextFormatting.GRAY + fluid.getLocalizedName(new FluidStack(fluid, amt))); } }
@Nullable @Override public FluidStack drain(int maxDrain, boolean doDrain) { if (container.stackSize != 1 || maxDrain < Fluid.BUCKET_VOLUME) { return null; } FluidStack fluidStack = getFluid(); if (fluidStack != null) { if (doDrain) { setFluid(null); } return fluidStack; } return null; }
@Nullable @Override public FluidStack drain(int maxDrain, boolean doDrain) { FluidStack drained = null; if(tile != null) for (EnumFacing facing : EnumFacing.HORIZONTALS) { if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing)) { IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing); drained = capability.drain(maxDrain,doDrain); if(drained != null) break; } } return drained; }
private T matchFluidStack(Iterable<T> ingredients, T ingredientToMatch) { if(Iterables.isEmpty(ingredients)) { return null; } FluidStack stack = ingredientToMatch.asFluidStack(); if(stack == null) { return null; } Fluid fluidMatch = stack.getFluid(); for (T hybridFluid : ingredients) { FluidStack hybridFluidStack = hybridFluid.asFluidStack(); if(hybridFluidStack == null) { continue; } if(hybridFluidStack.getFluid() == fluidMatch) { return hybridFluid; } } return null; }
@Nullable @Override public FluidStack drain(FluidStack resource, boolean doDrain) { if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME) { return null; } FluidStack fluidStack = getFluid(); if (fluidStack != null && fluidStack.isFluidEqual(resource)) { if (doDrain) { setFluid(null); } return fluidStack; } return null; }
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { RenderBlocks renderblocks = (RenderBlocks) data[0]; Block block = Block.getBlockFromItem(item.getItem()); if (item.hasTagCompound()) { NBTTagCompound tag = item.stackTagCompound; if (tag.hasKey("Fluid")) { FluidStack liquid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("Fluid")); if (liquid != null) { GL11.glEnable(GL11.GL_BLEND); float height = ((float) liquid.amount / (float) 8000 * (float) 0.99); renderblocks.setRenderBounds(0.01, 0.01, 0.01, 0.99, height, 0.99); Utils.renderInventoryBlock(renderblocks, GrandFluidTank.renderblocks, liquid.getFluid()); GL11.glDisable(GL11.GL_BLEND); } } GL11.glEnable(GL11.GL_ALPHA_TEST); renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1); Utils.renderInventoryBlock(renderblocks, block, GrandFluidTank.glassfluidtank.getIcon(0, 0)); GL11.glDisable(GL11.GL_ALPHA_TEST); } }
@Override public boolean equals(Object obj) { if (obj instanceof RecipeOutputFluid) { RecipeOutputFluid ro = (RecipeOutputFluid) obj; if (outputs.size() == ro.outputs.size() && (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) { Iterator<FluidStack> itA = outputs.iterator(); Iterator<FluidStack> itB = ro.outputs.iterator(); while (itA.hasNext() && itB.hasNext()) { FluidStack stackA = itA.next(); FluidStack stackB = itB.next(); if (stackA.isFluidStackIdentical(stackB)) return false; } return true; } } return false; }
private void drawFluid(Minecraft minecraft, final int xPosition, final int yPosition, @Nullable FluidStack fluidStack) { if (fluidStack == null) { return; } Fluid fluid = fluidStack.getFluid(); if (fluid == null) { return; } TextureAtlasSprite fluidStillSprite = getStillFluidSprite(minecraft, fluid); int fluidColor = fluid.getColor(fluidStack); int scaledAmount = (fluidStack.amount * height) / capacityMb; if (fluidStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) { scaledAmount = MIN_FLUID_HEIGHT; } if (scaledAmount > height) { scaledAmount = height; } drawTiledSprite(minecraft, xPosition, yPosition, width, height, fluidColor, scaledAmount, fluidStillSprite); }
@Nullable private FluidStack getStack(IBlockState blockState) { Material material = blockState.getMaterial(); if (material == Material.WATER && blockState.getValue(BlockLiquid.LEVEL) == 0) { return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME); } else if (material == Material.LAVA && blockState.getValue(BlockLiquid.LEVEL) == 0) { return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME); } else { return null; } }
public static void addTooltip(ItemStack stack, World world, List<String> curInfo, boolean sneaking) { if (stack.getTagCompound() != null && stack.getItem() instanceof ItemSemiBlockBase) { if (stack.getTagCompound().getBoolean("invisible")) curInfo.add(I18n.format("gui.logisticFrame.invisible")); if (stack.getTagCompound().hasKey("filters") && stack.getTagCompound().getTagList("filters", 10).tagCount() > 0 || stack.getTagCompound().hasKey("fluidFilters") && stack.getTagCompound().getTagList("fluidFilters", 10).tagCount() > 0) { String key = SemiBlockManager.getKeyForSemiBlock(SemiBlockManager.getSemiBlockForItem((ItemSemiBlockBase) stack.getItem())); if (sneaking) { curInfo.add(I18n.format(String.format("gui.%s.filters", key))); SemiBlockRequester requester = new SemiBlockRequester(); requester.onPlaced(PneumaticCraftRepressurized.proxy.getPlayer(), stack, null); ItemStack[] stacks = new ItemStack[requester.getFilters().getSlots()]; for (int i = 0; i < stacks.length; i++) { stacks[i] = requester.getFilters().getStackInSlot(i); } PneumaticCraftUtils.sortCombineItemStacksAndToString(curInfo, stacks); for (int i = 0; i < 9; i++) { FluidStack fluid = requester.getTankFilter(i).getFluid(); if (fluid != null) { curInfo.add("-" + fluid.amount / 1000 + "B " + fluid.getLocalizedName()); } } } else { curInfo.add(I18n.format(String.format("gui.%s.hasFilters", key))); } } } }
@Override public int amountRequested(FluidStack stack) { int totalRequestingAmount = getTotalRequestedAmount(stack); if (totalRequestingAmount > 0) { TileEntity te = getTileEntity(); int count = 0; for (EnumFacing facing : EnumFacing.VALUES) { if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) { IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing); for (IFluidTankProperties properties : handler.getTankProperties()) { FluidStack contents = properties.getContents(); if (contents != null && contents.getFluid() == stack.getFluid()) { count += contents.amount; } } if (count > 0) break; } } if (count == 0) return 0; count += getIncomingFluid(stack.getFluid()); return Math.max(0, Math.min(stack.amount, totalRequestingAmount - count)); } return 0; }
private boolean suckLiquid() { Block block = world.getBlockState(getPos().offset(EnumFacing.DOWN, currentDepth + 1)).getBlock(); Fluid fluid = FluidRegistry.lookupFluidForBlock(block); if (fluid == null) { pumpingLake = null; return false; } FluidStack fluidStack = new FluidStack(fluid, 1000); if (tank.fill(fluidStack, false) == 1000) { if (pumpingLake == null) { findLake(block); } BlockPos curPos = null; boolean foundSource = false; while (pumpingLake.size() > 0) { curPos = pumpingLake.get(0); if (getWorld().getBlockState(curPos).getBlock() == block && FluidUtils.isSourceBlock(getWorld(), curPos)) { foundSource = true; break; } pumpingLake.remove(0); } if (pumpingLake.size() == 0) { pumpingLake = null; } else if (foundSource) { getWorld().setBlockToAir(curPos); tank.fill(fluidStack, true); addAir(-100); status = Status.PUMPING; } } return true; }
@SubscribeEvent public static void registerGeoBurnables(RegistryEvent.Register<IGeoburnable> event){ IForgeRegistry<IGeoburnable> reg = event.getRegistry(); reg.register(new BlockGeoburnable(Blocks.MAGMA, 40, 1)); reg.register(new BlockGeoburnable(Blocks.FIRE, 80, 2){ @Override public ItemStack getJEIIcon() { return new ItemStack(Items.FLINT_AND_STEEL); } }); reg.register(new BlockGeoburnable(Blocks.LAVA, 160, 3){ @Override public ItemStack getJEIIcon() { return FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME)); } }); }
@Override public int fill(FluidStack resource, boolean doFill) { if (resource == null || resource.amount <= 0) return 0; resource = resource.copy(); int totalFillAmount = 0; for (IFluidHandler handler : subHandlers) { int fillAmount = handler.fill(resource, doFill); totalFillAmount += fillAmount; resource.amount -= fillAmount; if (resource.amount <= 0) break; } return totalFillAmount; }
private List<String> getLiquidXPText() { List<String> liquidXpText = new ArrayList<String>(); liquidXpText.add("gui.tab.info.aerialInterface.liquidXp.info"); for (Fluid fluid : PneumaticCraftAPIHandler.getInstance().liquidXPs.keySet()) { liquidXpText.add(TextFormatting.DARK_AQUA + new FluidStack(fluid, 1).getLocalizedName() + " (" + fluid.getName() + ")"); } return liquidXpText; }
private List<String> getAllFuels() { List<String> fuels = new ArrayList<String>(); fuels.add("L/Bucket | Fluid"); for (Map.Entry<String, Integer> map : sortByValue(PneumaticCraftAPIHandler.getInstance().liquidFuels).entrySet()) { String value = map.getValue() / 1000 + ""; while (fontRenderer.getStringWidth(value) < 25) { value = value + " "; } Fluid fluid = FluidRegistry.getFluid(map.getKey()); fuels.add(value + "| " + fluid.getLocalizedName(new FluidStack(fluid, 1))); } return fuels; }
@Override public void onDrink(World world, BlockPos pos, FluidStack stack, EntityPlayer player, boolean fromFluidContainer) { player.attackEntityFrom(DamageSource.LAVA, 7); player.setFire(30); NBTTagCompound tag = player.getEntityData(); tag.setLong("lavaDrink", world.getTotalWorldTime()); }
@Nullable @Override public FluidStack drain(int maxDrain, boolean doDrain) { if (container.stackSize != 1) { return null; } FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container); if (contained != null) { if (contained.amount <= maxDrain) { ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(container); if (emptyContainer != null) { if (doDrain) { if (FluidContainerRegistry.hasNullEmptyContainer(container)) { emptyContainer.stackSize = 0; } container.deserializeNBT(emptyContainer.serializeNBT()); } return contained; } } } return null; }
public static int getFill(ItemStack stack) { if(stack.getItem() instanceof UniversalBucket) return FORGE_INPUT_AMOUNT.get(FluidStack.loadFluidStackFromNBT(stack.getTagCompound()).getFluid()); for(ItemStack stack1 : ITEMLIQUID_MAP.keySet()) if(stack1.isItemEqual(stack)) return 64; return HarshenUtils.getObjectFromItemMap(INPUT_FILLBY, stack); }
@Override public void setRecipe(IRecipeLayout recipeLayout, MachineRecipeWrapper recipeWrapper, IIngredients ingredients) { super.setRecipe(recipeLayout, recipeWrapper, ingredients); IGuiItemStackGroup stacks = recipeLayout.getItemStacks(); IGuiFluidStackGroup fluids = recipeLayout.getFluidStacks(); List<List<ItemStack>> inputItems = ingredients.getInputs(ItemStack.class); List<List<FluidStack>> inputFluids = ingredients.getInputs(FluidStack.class); List<List<ItemStack>> outputItems = ingredients.getOutputs(ItemStack.class); List<List<FluidStack>> outputFluids = ingredients.getOutputs(FluidStack.class); initItems(stacks, true, module.inputSlots, 0); initItems(stacks, false, module.outputSlots, module.inputSlots); initFluids(fluids, true, module.inputTanks, 0); initFluids(fluids, false, module.outputTanks, module.inputTanks.length); for (int i = 0; i < inputItems.size(); i++) { stacks.set(i, inputItems.get(i)); } for (int i = 0; i < outputItems.size(); i++) { stacks.set(module.inputSlots + i, outputItems.get(i)); } for (int i = 0; i < inputFluids.size(); i++) { fluids.set(i, inputFluids.get(i)); } for (int i = 0; i < outputFluids.size(); i++) { fluids.set(module.inputTanks.length + i, outputFluids.get(i)); } }
public static FluidStack mixFluid(FluidStack plastic, FluidStack otherPlastic) { if (plastic == null) return otherPlastic; if (otherPlastic == null) return plastic; int[] otherColor = getColor3(otherPlastic); int[] color = getColor3(plastic); double ratio = (double) plastic.amount / (plastic.amount + otherPlastic.amount); int[] newColor = new int[3]; for (int i = 0; i < 3; i++) { newColor[i] = (int) (ratio * color[i] + (1 - ratio) * otherColor[i]); } NBTTagCompound newTag = new NBTTagCompound(); newTag.setInteger("color", (newColor[0] << 16) + (newColor[1] << 8) + newColor[2]); // newTag.setInteger("temperature", (int)(ratio * getTemperatureS(plastic) + (1 - ratio) * getTemperatureS(otherPlastic))); return new FluidStack(Fluids.PLASTIC, plastic.amount + otherPlastic.amount, newTag); }
private PlasticMixerRecipeWrapper(FluidStack input, ItemStack output) { addInputLiquid(input, 146, 11); addIngredient(new PositionedStack(new ItemStack(Items.DYE, 1, 1), 121, 19)); addIngredient(new PositionedStack(new ItemStack(Items.DYE, 1, 2), 121, 37)); addIngredient(new PositionedStack(new ItemStack(Items.DYE, 1, 4), 121, 55)); addOutput(new PositionedStack(output, 92, 55)); setUsedTemperature(76, 22, PneumaticValues.PLASTIC_MIXER_MELTING_TEMP); }
@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType())) return 0; AxisAlignedBB area = getWorkingArea(); List<EntityLiving> mobs = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, area); if (mobs.size() == 0) return 0; EntityLiving mob = mobs.get(this.getWorld().rand.nextInt(mobs.size())); this.outMeat.fill(new FluidStack(FluidsRegistry.MEAT, (int) (mob.getHealth() * BlockRegistry.mobSlaughterFactoryBlock.getMeatValue())), true); this.outPink.fill(new FluidStack(FluidsRegistry.PINK_SLIME, (int) mob.getHealth()), true); mob.setDropItemsWhenDead(false); mob.attackEntityFrom(CommonProxy.custom, mob.getMaxHealth()); return 1; }
@Override public void getIngredients(@Nonnull IIngredients ingredients) { ingredients.setInputLists(ItemStack.class, input.stream().map(PositionedStack::getStacks).collect(Collectors.toList())); ingredients.setInputs(FluidStack.class, inputLiquids.stream().map(WidgetTank::getFluid).collect(Collectors.toList())); ingredients.setOutputLists(ItemStack.class, output.stream().map(PositionedStack::getStacks).collect(Collectors.toList())); ingredients.setOutputs(FluidStack.class, outputLiquids.stream().map(WidgetTank::getFluid).collect(Collectors.toList())); }
public void consumeFluids(ArrayList<FluidStack> fluids, FluidMixingRecipe recipe) { for (FluidTank tank : tanks) { FluidStack tankFluid = tank.getFluid(); boolean doContinue = true; for (int j = 0; j < recipe.inputs.size() && doContinue; j++) { FluidStack recipeFluid = recipe.inputs.get(j); if (recipeFluid != null && tankFluid != null && recipeFluid.getFluid() == tankFluid.getFluid()) { doContinue = false; tank.drain(recipeFluid.amount,true); } } } }
/** * TODO: raise a PR to get this into IGW. This adds support for Forge filled buckets (use "item/bucket/{fluid_name}") * * @param stack * @return */ static String getNameFromStack(ItemStack stack) { if (stack.getItem().getRegistryName().toString().equals("forge:bucketfilled")) { FluidStack fluidStack = FluidUtil.getFluidContained(stack); if (fluidStack != null) { return "item/bucket/" + fluidStack.getFluid().getName(); } else { return "item/bucket"; } } return stack.getUnlocalizedName().replace("tile.", "block/").replace("item.", "item/"); }
public static String getStackDescription(IIngredient stack) { Object internalObject = stack.getInternal(); if(internalObject instanceof ItemStack) { return getStackDescription((ItemStack) internalObject); } else if(internalObject instanceof FluidStack) { return getStackDescription((FluidStack) internalObject); } else if(internalObject instanceof IOreDictEntry) { return getStackDescription(((IOreDictEntry) internalObject).getName()); } else { return "null"; } }
@Nonnull public static Optional<StrawHandler> getStrawHandler(@Nonnull FluidStack stack) { List<StrawHandler> current = Lists.newArrayList(IFRegistries.STRAW_HANDLER_REGISTRY); current.sort(Comparator.comparingInt(StrawHandler::getPriority)); for (StrawHandler handler : current) { if (handler.validFluid(stack)) return Optional.of(handler); } return Optional.empty(); }
public BasicThermopneumaticProcessingPlantRecipe(FluidStack inputLiquid, @Nonnull ItemStack inputItem, FluidStack outputLiquid, double requiredTemperature, float requiredPressure) { this.inputItem = inputItem; this.inputLiquid = inputLiquid; this.outputLiquid = outputLiquid; this.requiredTemperature = requiredTemperature; this.requiredPressure = requiredPressure; }
@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType()) || isWorkFinished) return 0; if (tank.getFluidAmount() + 1000 <= tank.getCapacity()) { if (blocks == null) { blocks = new PriorityQueue<>(Comparator.comparingDouble(value -> (this.pos).distanceSq(((BlockPos) value).getX(), this.pos.getY() - 1, ((BlockPos) value).getZ()))); BlockUtils.getBlockPosInAABB(getWorkingArea()).stream().filter(pos1 -> !this.world.isOutsideBuildHeight(pos1) && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(pos1).getBlock()) != null && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(pos1).getBlock()).getName().equals(fluid)).forEach(pos1 -> blocks.add(pos1)); } if (blocks.isEmpty()) { isWorkFinished = true; blocks = null; return 0; } BlockPos peeked = blocks.peek(); while (!blocks.isEmpty() && (this.world.isOutsideBuildHeight(peeked) || FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()) == null || !FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()).getName().equals(fluid) || this.world.getBlockState(peeked).getBlock().getMetaFromState(this.world.getBlockState(peeked)) != 0)) { blocks.poll(); if (!blocks.isEmpty()) peeked = blocks.peek(); } if (blocks.isEmpty()) { blocks = null; return 0; } while (this.world.getBlockState(peeked).getBlock().equals(this.world.getBlockState(peeked.add(0, -1, 0)).getBlock())) { peeked = peeked.add(0, -1, 0); } FluidStack stack = new FluidStack(FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()), 1000); tank.fill(stack, true); this.world.setBlockState(peeked, Blocks.COBBLESTONE.getDefaultState()); return 1; } return 0; }
@Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { if (container.getTagCompound() == null) { container.setTagCompound(new NBTTagCompound()); } if (!container.getTagCompound().hasKey("Fluid") || maxDrain == 0) { return null; } FluidStack stack = FluidStack.loadFluidStackFromNBT(container.getTagCompound().getCompoundTag("Fluid")); if (stack == null) { return null; } int drained = Math.min(stack.amount, maxDrain); if (doDrain && ItemHelper.getItemDamage(container) != CREATIVE) { if (maxDrain >= stack.amount) { container.getTagCompound().removeTag("Fluid"); return stack; } NBTTagCompound fluidTag = container.getTagCompound().getCompoundTag("Fluid"); fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - drained); container.getTagCompound().setTag("Fluid", fluidTag); } stack.amount = drained; return stack; }
private MachineRecipe getActiveRecipe() { NonNullList<ItemStack> input = invHandler.getInputStacks(); List<FluidStack> inputFluid = Arrays.stream(supplier.inputTanks) .map(fluidSource::getFluidTank) .map(IFluidTank::getFluid) .collect(Collectors.toList()); return MachineManager.findMatchingRecipe(supplier.recipeList, input, inputFluid, tile.getWorld()); }
private String fluidStackToString(FluidStack stack) { if (stack==null) return "null"; if (stack.getFluid()==null) return "fluid_null"; String tagString = "null"; if (stack.tag != null) tagString = "{"+stack.tag.toString()+"}"; return "{fluid:"+stack.getFluid().getName()+", tag:"+tagString+", amount:"+stack.amount+"}"; }
private void requireFluid(MachineComponent.IOType ioType, ILiquidStack stack) { FluidStack mcFluid = CraftTweakerMC.getLiquidStack(stack); if(mcFluid == null) { CraftTweakerAPI.logError("Fluidstack not found/unknown fluid: " + stack.toString()); return; } if(stack.getTag() != null) { mcFluid.tag = CraftTweakerMC.getNBTCompound(stack.getTag()); } ComponentRequirement.RequirementFluid rf = new ComponentRequirement.RequirementFluid(ioType, mcFluid); appendComponent(rf); }
@Override public List<FluidStack> getFluidResult() { return outputFluidStacks.stream() .map(FluidStack::copy) .collect(Collectors.toList()); }
void payout() { TileEntity returning = getReturningTileEntity(); TileEntity provider = getProvidingTileEntity(); if (pendingPayments > 0) { int paying = Math.min(pendingPayments, 50); paying = ContainerAmadron.capShoppingAmount(this, paying, AmadronOfferManager.getItemHandler(provider), AmadronOfferManager.getItemHandler(returning), AmadronOfferManager.getFluidHandler(provider), AmadronOfferManager.getFluidHandler(returning), null); if (paying > 0) { pendingPayments -= paying; if (getInput() instanceof ItemStack) { ItemStack deliveringItems = (ItemStack) getInput(); int amount = deliveringItems.getCount() * paying; List<ItemStack> stacks = new ArrayList<>(); while (amount > 0) { ItemStack stack = deliveringItems.copy(); stack.setCount(Math.min(amount, stack.getMaxStackSize())); stacks.add(stack); amount -= stack.getCount(); } DroneRegistry.getInstance().deliverItemsAmazonStyle(returning.getWorld(), returning.getPos(), stacks.toArray(new ItemStack[stacks.size()])); } else { FluidStack deliveringFluid = ((FluidStack) getInput()).copy(); deliveringFluid.amount *= paying; DroneRegistry.getInstance().deliverFluidAmazonStyle(returning.getWorld(), returning.getPos(), deliveringFluid); } } } }
@Override public IFluidTankProperties[] getTankProperties() { float percentFilled = fluidBlock.getFilledPercentage(world, blockPos); if (percentFilled < 0) { percentFilled *= -1; } int amountFilled = Math.round(Fluid.BUCKET_VOLUME * percentFilled); FluidStack fluid = amountFilled > 0 ? new FluidStack(fluidBlock.getFluid(), amountFilled) : null; return new FluidTankProperties[]{ new FluidTankProperties(fluid, Fluid.BUCKET_VOLUME, false, true)}; }
public static MachineRecipe findMatchingRecipe(ResourceLocation list, NonNullList<ItemStack> input, List<FluidStack> inputFluid, World worldIn) { if (list.toString().equals("minecraft:vanilla")) { if (input.size() == 1 && !input.get(0).isEmpty()) { return new VanillaFurnaceRecipe(FurnaceRecipes.instance().getSmeltingResult(input.get(0))); } else { return MachineRecipe.EMPTY; } } return findMatchingRecipe(getRecipes(list), input, inputFluid, worldIn); }