use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.
the class ItemChemthrower method onPlayerStoppedUsing.
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase player, int timeLeft) {
FluidStack fs = this.getFluid(stack);
if (fs != null) {
int duration = getMaxItemUseDuration(stack) - timeLeft;
fs.amount -= IEConfig.Tools.chemthrower_consumption * duration;
if (fs.amount <= 0)
ItemNBTHelper.remove(stack, "Fluid");
else
ItemNBTHelper.setFluidStack(stack, "Fluid", fs);
}
}
use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.
the class ItemDrill method finishUpgradeRecalculation.
@Override
public void finishUpgradeRecalculation(ItemStack stack) {
FluidStack fs = getFluid(stack);
if (fs != null && fs.amount > getCapacity(stack, 2000)) {
fs.amount = getCapacity(stack, 2000);
ItemNBTHelper.setFluidStack(stack, "Fluid", fs);
}
}
use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.
the class ItemChemthrower method onUsingTick.
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
FluidStack fs = this.getFluid(stack);
if (fs != null && fs.getFluid() != null) {
int duration = getMaxItemUseDuration(stack) - count;
int consumed = IEConfig.Tools.chemthrower_consumption;
if (consumed * duration <= fs.amount) {
Vec3d v = player.getLookVec();
int split = 8;
boolean isGas = fs.getFluid().isGaseous() || ChemthrowerHandler.isGas(fs.getFluid());
float scatter = isGas ? .15f : .05f;
float range = isGas ? .5f : 1f;
if (getUpgrades(stack).getBoolean("focus")) {
range += .25f;
scatter -= .025f;
}
boolean ignite = ChemthrowerHandler.isFlammable(fs.getFluid()) && ItemNBTHelper.getBoolean(stack, "ignite");
for (int i = 0; i < split; i++) {
Vec3d vecDir = v.addVector(player.getRNG().nextGaussian() * scatter, player.getRNG().nextGaussian() * scatter, player.getRNG().nextGaussian() * scatter);
EntityChemthrowerShot chem = new EntityChemthrowerShot(player.worldObj, player, vecDir.xCoord * 0.25, vecDir.yCoord * 0.25, vecDir.zCoord * 0.25, fs);
chem.motionX = vecDir.xCoord * range;
chem.motionY = vecDir.yCoord * range;
chem.motionZ = vecDir.zCoord * range;
if (ignite)
chem.setFire(10);
if (!player.worldObj.isRemote)
player.worldObj.spawnEntityInWorld(chem);
}
if (count % 4 == 0) {
if (ignite)
player.playSound(IESounds.sprayFire, .5f, 1.5f);
else
player.playSound(IESounds.spray, .5f, .75f);
}
} else
player.stopActiveHand();
} else
player.stopActiveHand();
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class TileTankIronValve method update.
@Override
public void update() {
super.update();
if (Game.isClient(worldObj))
return;
decrementFilling();
if (isMaster) {
TileEntity tileBelow = tileCache.getTileOnSide(EnumFacing.DOWN);
TileTankIronValve valveBelow = null;
if (tileBelow instanceof TileTankIronValve) {
valveBelow = (TileTankIronValve) tileBelow;
if (valveBelow.isStructureValid() && valveBelow.getPatternMarker() == 'T') {
//noinspection ConstantConditions
StandardTank tankBelow = valveBelow.getTankManager().get(0);
assert tankBelow != null;
FluidStack liquid = tankBelow.getFluid();
if (liquid != null && liquid.amount >= tankBelow.getCapacity() - FluidTools.BUCKET_VOLUME) {
valveBelow = null;
FluidStack fillStack = liquid.copy();
fillStack.amount = FluidTools.BUCKET_VOLUME - (tankBelow.getCapacity() - liquid.amount);
if (fillStack.amount > 0) {
int used = tank.fill(fillStack, false);
if (used > 0) {
fillStack = tankBelow.drain(used, true);
tank.fill(fillStack, true);
}
}
}
} else
valveBelow = null;
}
if (valveBelow != null) {
FluidStack available = tankManager.drain(0, FluidTools.BUCKET_VOLUME, false);
if (available != null && available.amount > 0) {
int used = valveBelow.fill(available, true);
tankManager.drain(0, used, true);
}
}
}
if (getPatternPosition().getY() - getPattern().getMasterOffset().getY() == 0) {
TankManager tMan = getTankManager();
if (tMan != null)
tMan.push(tileCache, Predicates.notInstanceOf(TileTankBase.class), FLUID_OUTPUTS, 0, FLOW_RATE);
}
TileMultiBlock masterBlock = getMasterBlock();
if (masterBlock instanceof TileTankBase) {
TileTankBase masterTileTankBase = (TileTankBase) masterBlock;
int compValue = masterTileTankBase.getComparatorValue();
if (previousComparatorValue != compValue) {
previousComparatorValue = compValue;
getWorld().notifyNeighborsOfStateChange(getPos(), null);
}
}
if (previousStructureValidity != isStructureValid())
getWorld().notifyNeighborsOfStateChange(getPos(), null);
previousStructureValidity = isStructureValid();
}
use of net.minecraftforge.fluids.FluidStack in project Railcraft by Railcraft.
the class TileFluidLoader method processCart.
@Override
protected void processCart(EntityMinecart cart) {
if (cart instanceof EntityLocomotiveSteam) {
EntityLocomotiveSteam loco = (EntityLocomotiveSteam) cart;
if (!loco.isSafeToFill()) {
retractPipe();
return;
}
}
AdvancedFluidHandler tankCart = getFluidHandler(cart, EnumFacing.UP);
if (tankCart == null)
return;
boolean cartNeedsFilling = cartNeedsFilling(tankCart);
if (cartNeedsFilling && needsPipe)
extendPipe();
else
retractPipe();
setProcessing(false);
if (cartNeedsFilling && (!needsPipe || pipeIsExtended())) {
FluidStack moved = FluidUtil.tryFluidTransfer(tankCart, tank, RailcraftConfig.getTankCartFillRate(), true);
setProcessing(Fluids.isNotEmpty(moved));
}
if (isProcessing())
setPowered(false);
if (cart instanceof IFluidCart)
((IFluidCart) cart).setFilling(isProcessing());
if (tankCart.isTankFull(tank.getFluidType()))
setResetTimer(RESET_WAIT);
}
Aggregations