Java Code Examples for net.minecraftforge.fluids.Fluid#getID()

The following examples show how to use net.minecraftforge.fluids.Fluid#getID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 6 votes vote down vote up
public boolean canFill(int tank, Fluid fluid) {
  if (tank < 0 || tank >= NUM_TANKS) {
    return false;
  }

  FluidStack fluidStack = tanks[tank].getFluid();
  if (fluidStack != null) {
    return fluidStack.getFluid().getID() == fluid.getID();
  } else if (tank == TANK_INPUT) {
    // TODO: Input tank can only be filled with compatible fluids from a registry
    return fluid.getName().equals("steam");
  } else {
    // Output tank can be filled with anything. Don't be a dumb.
    return true;
  }
}
 
Example 2
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 6 votes vote down vote up
public boolean canFill(int tank, Fluid fluid) {
  if (tank < 0 || tank >= NUM_TANKS) {
    return false;
  }

  FluidStack fluidStack = tanks[tank].getFluid();
  if (fluidStack != null) {
    return fluidStack.getFluid().getID() == fluid.getID();
  } else if (tank == TANK_INPUT) {
    // TODO: Input tank can only be filled with compatible fluids from a registry
    return fluid.getName().equals("steam");
  } else {
    // Output tank can be filled with anything. Don't be a dumb.
    return true;
  }
}
 
Example 3
Source File: FluidHelper.java    From BigReactors with MIT License 6 votes vote down vote up
public FluidStack drain(int idx, FluidStack resource,
		boolean doDrain) {
	if(resource == null || resource.amount <= 0 || idx < 0 || idx >= fluids.length) { return null; }
	
	Fluid existingFluid = getFluidType(idx);
	if(existingFluid == null || existingFluid.getID() != resource.getFluid().getID()) { return null; }
	
	FluidStack drained = resource.copy();
	if(!doDrain) {
		drained.amount = Math.min(resource.amount, getFluidAmount(idx));
	}
	else {
		drained.amount = drainFluidFromStack(idx, resource.amount);
	}

	return drained;
}
 
Example 4
Source File: MultiblockTurbine.java    From BigReactors with MIT License 6 votes vote down vote up
public boolean canFill(int tank, Fluid fluid) {
	if(tank < 0 || tank >= NUM_TANKS) { return false; }
	
	FluidStack fluidStack = tanks[tank].getFluid();
	if(fluidStack != null) {
		return fluidStack.getFluid().getID() == fluid.getID();
	}
	else if(tank == TANK_INPUT) {
		// TODO: Input tank can only be filled with compatible fluids from a registry
		return fluid.getName().equals("steam");
	}
	else {
		// Output tank can be filled with anything. Don't be a dumb.
		return true;
	}
}
 
Example 5
Source File: TileEntityPoweredInventoryFluid.java    From BigReactors with MIT License 6 votes vote down vote up
/**
 * Returns true if the given fluid can be inserted into the given direction.
 * 
 * More formally, this should return true if fluid is able to enter from the given direction.
 */
public boolean canFill(ForgeDirection from, Fluid fluid) {
	int tankIdx = 0;
	if(from != ForgeDirection.UNKNOWN) {
		tankIdx = getExposedTankFromSide(from.ordinal());
	}

	if(tankIdx == FLUIDTANK_NONE) { return false; }

	IFluidTank tank = tanks[tankIdx];
	if(tank.getFluidAmount() <= 0) {
		return true;
	}
	else {
		return tank.getFluid().fluidID == fluid.getID();
	}
}
 
Example 6
Source File: TileEntityPoweredInventoryFluid.java    From BigReactors with MIT License 6 votes vote down vote up
/**
 * Returns true if the given fluid can be extracted from the given direction.
 * 
 * More formally, this should return true if fluid is able to leave from the given direction.
 */
public boolean canDrain(ForgeDirection from, Fluid fluid) {
	int tankIdx = 0;
	if(from != ForgeDirection.UNKNOWN) {
		tankIdx = getExposedTankFromSide(from.ordinal());
	}

	if(tankIdx == FLUIDTANK_NONE) { return false; }

	IFluidTank tank = tanks[tankIdx];
	if(tank.getFluidAmount() <= 0) {
		return false;
	}
	else {
		return tank.getFluid().fluidID == fluid.getID();
	}
}
 
Example 7
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
public boolean canDrain(int tank, Fluid fluid) {
  if (tank < 0 || tank >= NUM_TANKS) {
    return false;
  }
  FluidStack fluidStack = tanks[tank].getFluid();
  if (fluidStack == null) {
    return false;
  }

  return fluidStack.getFluid().getID() == fluid.getID();
}
 
Example 8
Source File: MultiblockTurbineSimulator.java    From reactor_simulator with MIT License 5 votes vote down vote up
public boolean canDrain(int tank, Fluid fluid) {
  if (tank < 0 || tank >= NUM_TANKS) {
    return false;
  }
  FluidStack fluidStack = tanks[tank].getFluid();
  if (fluidStack == null) {
    return false;
  }

  return fluidStack.getFluid().getID() == fluid.getID();
}
 
Example 9
Source File: FluidHelper.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Drain some fluid from a given stack
 * @param idx Index of the stack (FUEL or WASTE)
 * @param amount Nominal amount to drain
 * @return Amount actually drained
 */
protected int drainFluidFromStack(int idx, Fluid fluid, int amount) {
	if(fluids[idx] == null) { return 0; }
	
	if(fluids[idx].getFluid().getID() != fluid.getID()) { return 0; }

	return drainFluidFromStack(idx, amount);
}
 
Example 10
Source File: MultiblockTurbine.java    From BigReactors with MIT License 5 votes vote down vote up
public boolean canDrain(int tank, Fluid fluid) {
	if(tank < 0 || tank >= NUM_TANKS) { return false; }
	FluidStack fluidStack = tanks[tank].getFluid();
	if(fluidStack == null) {
		return false;
	}
	
	return fluidStack.getFluid().getID() == fluid.getID();
}
 
Example 11
Source File: PacketTerminalFluid.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public PacketTerminalFluid(World world, int x, int y, int z, Fluid fluid)
{
	this.type = 1;
	this.world = world;
	this.x = x;
	this.y = y;
	this.z = z;
	fluidID = fluid.getID();
}
 
Example 12
Source File: ReactorFuel.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
public boolean isFuelEqual(Fluid fluid) {
	return referenceFluid.getID() == fluid.getID();
}
 
Example 13
Source File: CoolantContainer.java    From BigReactors with MIT License 4 votes vote down vote up
public boolean isAcceptedCoolant(Fluid fluid) {
	if(fluid == null) { return false; }
	
	// TODO: Lookup
	return fluid.getID() == FluidRegistry.WATER.getID();
}
 
Example 14
Source File: FluidHelper.java    From BigReactors with MIT License 4 votes vote down vote up
protected boolean canAddToStack(int idx, Fluid incoming) {
	if(idx < 0 || idx >= fluids.length || incoming == null) { return false; }
	else if(fluids[idx] == null) { return isFluidValidForStack(idx, incoming); }
	return fluids[idx].getFluid().getID() == incoming.getID();
}
 
Example 15
Source File: SpecialFluidStack.java    From ExtraCells1 with MIT License 4 votes vote down vote up
public SpecialFluidStack(Fluid fluid, long amount)
{
	fluidID = fluid.getID();
	this.amount = amount;
}
 
Example 16
Source File: FluidHelper.java    From BigReactors with MIT License 3 votes vote down vote up
public boolean canDrain(int idx, Fluid fluid) {
	if(fluid == null || idx < 0 || idx >= fluids.length) { return false; }

	if(fluids[idx] == null) { return false; }
	
	return fluids[idx].getFluid().getID() == fluid.getID();
}