List of usage examples for net.minecraftforge.fluids FluidStack areFluidStackTagsEqual
public static boolean areFluidStackTagsEqual(@Nonnull FluidStack stack1, @Nonnull FluidStack stack2)
From source file:blusunrize.immersiveengineering.common.blocks.wooden.TileEntityFluidSorter.java
public EnumFacing[][] getValidOutputs(EnumFacing inputSide, @Nullable FluidStack fluidStack) { if (fluidStack == null) return new EnumFacing[2][0]; ArrayList<EnumFacing> validFilteredInvOuts = new ArrayList<>(6); ArrayList<EnumFacing> validUnfilteredInvOuts = new ArrayList<>(6); for (EnumFacing side : EnumFacing.values()) if (side != inputSide && world.isBlockLoaded(getPos().offset(side))) { boolean unmapped = true; boolean allowed = false; filterIteration: {//from ww w . ja va 2 s .c o m for (FluidStack filterStack : filters[side.ordinal()]) if (filterStack != null) { unmapped = false; boolean b = filterStack.getFluid() == fluidStack.getFluid(); if (doNBT(side.ordinal())) b &= FluidStack.areFluidStackTagsEqual(filterStack, fluidStack); if (b) { allowed = true; break filterIteration; } } } if (allowed) validFilteredInvOuts.add(side); else if (unmapped) validUnfilteredInvOuts.add(side); } return new EnumFacing[][] { validFilteredInvOuts.toArray(new EnumFacing[0]), validUnfilteredInvOuts.toArray(new EnumFacing[0]) }; }
From source file:si.meansoft.traincraft.tile.TileEntityDistillery.java
/** * Like the old updateEntity(), except more generic. *//*from w ww . j ava2 s . c o m*/ @Override public void update() { if (!this.getWorld().isRemote) { boolean wasBurning = this.isBurning(); ItemStack input = this.getStackInSlot(0); ItemStack fuel = this.getStackInSlot(1); ItemStack output = this.getStackInSlot(4); DistilleryRecipes.RecipeHandler recipe = DistilleryRecipes.getRecipe(input); //TODO Fix this breaking when reloading the world because the recipe doesn't get saved properly if (recipe != null) { //Burn if ((fuel != ItemStack.EMPTY || this.currentBurnStack != ItemStack.EMPTY || this.currentBurn > 0)) { if (currentBurn <= 0 && !this.isTankFull()) { this.decrStackSize(1, 1); this.currentBurn = this.maxBurnTime = TileEntityFurnace.getItemBurnTime(fuel); } else { this.currentBurn--; } } //Distill if (!this.isCooking() && input != null && isBurning()) { if (this.tank.getFluidAmount() + recipe.outputFluid.amount <= this.tank.getCapacity()) { this.decrStackSize(0, 1); this.currentCookTime = this.maxCookTime = recipe.burnTime; this.currentBurnStack = recipe.outputStack.copy(); } } else { if (this.currentCookTime == 1 && this.isBurning()) { if (output == ItemStack.EMPTY) { if (this.currentBurnStack != ItemStack.EMPTY) this.setInventorySlotContents(4, this.currentBurnStack.copy()); if (recipe.outputFluid != null) { this.tank.fill(recipe.outputFluid.copy(), true); } this.currentBurnStack = ItemStack.EMPTY; this.currentCookTime--; dropXP(getWorld(), getPos(), recipe.outputExp); } else if (output.isItemEqual(this.currentBurnStack)) { if (output.copy().getCount() + this.currentBurnStack.copy().getCount() <= this .getInventoryStackLimit()) { this.incrStackSize(4, this.currentBurnStack.copy().getCount()); this.currentBurnStack = ItemStack.EMPTY; this.currentCookTime--; if (recipe.outputFluid != null) { this.tank.fill(recipe.outputFluid.copy(), true); } dropXP(getWorld(), getPos(), recipe.outputExp); } } this.markDirty(); } else if (this.isBurning()) { this.currentCookTime--; } else { this.currentCookTime++; } } } else { //Burn if (this.currentBurn > 0) { this.currentBurn--; } } //Filling Recipes: ItemStack fillingInput = getStackInSlot(2); ItemStack currentFillingOutputSlot = getStackInSlot(3); if (currentFillingOutputSlot == ItemStack.EMPTY || (ItemStack.areItemStacksEqual(fillingInput, currentFillingOutputSlot) && fillingInput.getCount() + currentFillingOutputSlot.getCount() <= getInventoryStackLimit())) { Pair<ItemStack, FluidStack> outputFilling = DistilleryRecipes.getFillingOutput(fillingInput, this.tank.getFluid()); if (outputFilling != null) { if ((ItemStack.areItemStacksEqual(currentFillingOutputSlot, outputFilling.getKey()) || currentFillingOutputSlot == ItemStack.EMPTY) && (FluidStack.areFluidStackTagsEqual(this.tank.getFluid(), outputFilling.getValue()))) { setInventorySlotContents(3, Util.decreaseItemStack(currentFillingOutputSlot, outputFilling.getKey())); } } } if (wasBurning != this.isBurning()) { setState(this.isBurning(), BlockDistillery.ACTIVE, getWorld(), getPos()); } if (this.maxBurnTime != this.lastMaxBurnTime || this.maxCookTime != this.lastMaxCookTime || this.currentCookTime != this.lastCurrentCookTime || this.currentBurn != this.lastCurrentBurn) { this.lastCurrentBurn = this.currentBurn; this.lastMaxBurnTime = this.maxBurnTime; this.lastMaxCookTime = this.maxCookTime; this.lastCurrentCookTime = this.currentCookTime; this.syncToClient(); } } }