public MeltingRecipe(RecipeMatch input, FluidStack output, int temperature) { this.input = input; this.output = new FluidStack(output, input.amountMatched); this.temperature = temperature; }
@Override public boolean canDrainFluidType(FluidStack fluid) { return fluid.getFluid() == FluidRegistry.WATER; } }
public FluidStack getUsableFluid() { if(fluid == null) { return null; } FluidStack stack = this.fluid.copy(); stack.amount -= locked; return stack; }
/** * Used to ensure that a fluidstack is valid. Basically when you return a fluidstack, * you should ALWAYS take the fluid from the FluidRegistry. This isn't possible in all cases for us * hence we replace the FluidStack with a FluidStack containing the correct fluid. * * Example: Entity X melts into a specific fluid with specific NBT. However in game Fluid X is not the default fluid * anymore. We change the returned stack to contain the default fluid instead of the fluid used during setup. * * @return A save FluidStack or null if there is no valid fluid for the fluidstack */ public static FluidStack getValidFluidStackOrNull(FluidStack possiblyInvalidFluidstack) { FluidStack fluidStack = possiblyInvalidFluidstack; if(!FluidRegistry.isFluidDefault(fluidStack.getFluid())) { Fluid fluid = FluidRegistry.getFluid(fluidStack.getFluid().getName()); if(fluid != null) { fluidStack = new FluidStack(fluid, fluidStack.amount, fluidStack.tag); } else { fluidStack = null; } } return fluidStack; } }
public MeltingRecipe(RecipeMatch input, FluidStack output) { this(input, output, calcTemperature(output.getFluid().getTemperature(output), input.amountMatched)); }
protected static <T extends Fluid> T registerFluid(T fluid) { fluid.setUnlocalizedName(Util.prefix(fluid.getName())); FluidRegistry.registerFluid(fluid); return fluid; }
public int getBrightness() { if(containsFluid()) { assert tank.getFluid() != null; return tank.getFluid().getFluid().getLuminosity(); } return 0; }
public class BlockTinkerFluid extends BlockFluidClassic { public BlockTinkerFluid(Fluid fluid, Material material) { super(fluid, material); setCreativeTab(TinkerRegistry.tabSmeltery); } @Nonnull @Override public String getUnlocalizedName() { Fluid fluid = FluidRegistry.getFluid(fluidName); if(fluid != null) { return fluid.getUnlocalizedName(); } return super.getUnlocalizedName(); } @Override public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } }
public enum TankCapacityGetter implements IItemPropertyGetter { INSTANCE; @Override public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) { if(!stack.hasTagCompound()) { return 0; } FluidStack fluid = FluidStack.loadFluidStackFromNBT(stack.getTagCompound()); if (fluid != null && fluid.amount > 0) { return (float)fluid.amount / TileTank.CAPACITY; } return 0; } } }
public static int calcCooldownTime(Fluid fluid, int amount) { // minimum time = faucet animation time :I int time = 24; int temperature = fluid.getTemperature() - 300; return time + (temperature * amount) / 1600; } }
public CastingRecipe(ItemStack output, Fluid fluid, int amount, int time) { this(output, null, new FluidStack(fluid, amount), time, false, false); }
/** * Returns a meltingrecipe for the given recipematch, that returns the given fluid-output combination * but the temperature required for it is as if timeAmount would be returned. */ public static MeltingRecipe forAmount(RecipeMatch recipeMatch, FluidStack output, int timeAmount) { return new MeltingRecipe(recipeMatch, output, calcTemperature(output.getFluid().getTemperature(), timeAmount)); }
private boolean validFluid(FluidStack fluid) { return fluid != null && fluid.getFluid() != null && fluid.amount > 0; } }
public FluidStack getResult() { return output.copy(); }
public FluidStack getFluidStack( ItemStack is ) { if( is.hasTagCompound() ) { NBTTagCompound tag = is.getTagCompound(); return FluidStack.loadFluidStackFromNBT( tag ); } return null; }
public MeltingRecipe(RecipeMatch input, Fluid output, int temperature) { this(input, new FluidStack(output, input.amountMatched), temperature); }
public MeltingRecipe(RecipeMatch input, Fluid output) { this(input, new FluidStack(output, input.amountMatched)); }
public CastingRecipe(ItemStack output, RecipeMatch cast, Fluid fluid, int amount, int time) { this(output, cast, new FluidStack(fluid, amount), time, false, false); }