public static Set<Fluid> getRecipeFluids() { if (recipeFluids.isEmpty()) { for (IHygroregulatorRecipe recipe : recipes) { FluidStack fluidStack = recipe.getResource(); recipeFluids.add(fluidStack.getFluid()); } } return Collections.unmodifiableSet(recipeFluids); }
@Override public void changeClimate(int tickCount, IClimateControlled climateControlled) { if (transferTime <= 0) { FluidStack fluid = liquidTank.getFluid(); if (fluid != null) { currentRecipe = HygroregulatorManager.findMatchingRecipe(fluid); if (currentRecipe != null) { liquidTank.drainInternal(currentRecipe.getResource().amount, true); transferTime = currentRecipe.getTransferTime(); } } } if (transferTime > 0) { transferTime--; if (currentRecipe != null) { climateControlled.addHumidityChange(currentRecipe.getHumidChange(), 0.0f, 1.0f); climateControlled.addTemperatureChange(currentRecipe.getTempChange(), 0.0f, 2.0f); } else { transferTime = 0; } } if (tickCount % 20 == 0) { // Check if we have suitable items waiting in the item slot FluidHelper.drainContainers(tankManager, this, 0); } }
@Override public float getChangeForState(ClimateType type, IClimateManipulator manipulator) { if (type == ClimateType.HUMIDITY) { FluidStack fluid = resourceTank.getFluid(); if (fluid != null) { IHygroregulatorRecipe recipe = HygroregulatorManager.findMatchingRecipe(fluid); if (recipe != null) { return recipe.getHumidChange() / transformer.getSpeedModifier(); } } } float fluidChange = 0.0F; if (cachedStack != null) { IHygroregulatorRecipe recipe = HygroregulatorManager.findMatchingRecipe(cachedStack); if (recipe != null) { fluidChange = Math.abs(recipe.getTempChange()); } } return (0.05F + fluidChange) * 0.5F / transformer.getSpeedModifier(); }
@Nullable public static IHygroregulatorRecipe findMatchingRecipe(FluidStack liquid) { if (liquid.amount <= 0) { return null; } for (IHygroregulatorRecipe recipe : recipes) { FluidStack resource = recipe.getResource(); if (resource.isFluidEqual(liquid)) { return recipe; } } return null; }
private int getFluidCost(IClimateState state) { FluidStack fluid = resourceTank.getFluid(); if (fluid == null) { return 0; } IHygroregulatorRecipe recipe = HygroregulatorManager.findMatchingRecipe(fluid); if (recipe == null) { return 0; } return Math.round((1.0F + MathHelper.abs(state.getHumidity())) * transformer.getCostModifier() * recipe.getResource().amount); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound = super.writeToNBT(nbttagcompound); tankManager.writeToNBT(nbttagcompound); nbttagcompound.setInteger("TransferTime", transferTime); if (currentRecipe != null) { NBTTagCompound subcompound = new NBTTagCompound(); currentRecipe.getResource().writeToNBT(subcompound); nbttagcompound.setTag("CurrentLiquid", subcompound); } return nbttagcompound; }