本文整理汇总了Java中com.enderio.core.common.util.FluidUtil类的典型用法代码示例。如果您正苦于以下问题:Java FluidUtil类的具体用法?Java FluidUtil怎么用?Java FluidUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FluidUtil类属于com.enderio.core.common.util包,在下文中一共展示了FluidUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
TileEntity te = world.getTileEntity(x, y, z);
if (entityPlayer.isSneaking()) {
return false;
}
if (te instanceof ITankAccess) {
if (FluidUtil.fillInternalTankFromPlayerHandItem(world, x, y, z, entityPlayer, (ITankAccess) te)) {
return true;
}
if (FluidUtil.fillPlayerHandItemFromInternalTank(world, x, y, z, entityPlayer, (ITankAccess) te)) {
return true;
}
}
return openGui(world, x, y, z, entityPlayer, side);
}
示例2: fillEmptyContainer
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
private boolean fillEmptyContainer() {
FluidAndStackResult fill = FluidUtil.tryFillContainer(inventory[0], getOutputTanks()[0].getFluid());
if (fill.result.fluidStack == null) {
return false;
}
if (inventory[1] != null) {
if (inventory[1].isStackable() && ItemUtil.areStackMergable(inventory[1], fill.result.itemStack)
&& inventory[1].stackSize < inventory[1].getMaxStackSize()) {
fill.result.itemStack.stackSize += inventory[1].stackSize;
} else {
return false;
}
}
getOutputTanks()[0].setFluid(fill.remainder.fluidStack);
setInventorySlotContents(0, fill.remainder.itemStack);
setInventorySlotContents(1, fill.result.itemStack);
setTanksDirty();
markDirty();
return false;
}
示例3: onBlockActivated
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof TileDrain)) {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
TileDrain drain = (TileDrain) te;
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (item == null) {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
//now check for empty fluid containers to fill
if (FluidUtil.fillPlayerHandItemFromInternalTank(world, x, y, z, entityPlayer, drain)) {
return true;
}
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
示例4: onBlockActivated
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public boolean onBlockActivated(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityPlayer entityPlayer,
@Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
if (!entityPlayer.isSneaking()) {
TileReservoir tank = getTileEntity(world, pos);
if (tank != null) {
if (ToolUtil.isToolEquipped(entityPlayer, hand)) {
tank.setAutoEject(!tank.isAutoEject());
world.notifyBlockUpdate(pos, state, state, 3);
return true;
}
if (tank.tank.getAvailableSpace() >= Fluid.BUCKET_VOLUME && FluidUtil.fillInternalTankFromPlayerHandItem(world, pos, entityPlayer, hand, tank)) {
return true;
} else if (!tank.tank.isFull()
&& FluidUtil.fillInternalTankFromPlayerHandItem(world, pos, entityPlayer, hand, new ReservoirTankWrapper(tank, world, pos))) {
return true;
}
if (FluidUtil.fillPlayerHandItemFromInternalTank(world, pos, entityPlayer, hand, tank)) {
return true;
}
}
} else if (ToolUtil.breakBlockWithTool(this, world, pos, side, entityPlayer, hand, permissionNodeWrenching)) {
return true;
}
return false; // super also has fluid transfer code, avoid that
}
示例5: render
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
public boolean render(@Nonnull ItemStack stack, int xPosition, int yPosition, int barOffset, boolean alwaysShow) {
IFluidHandler cap = FluidUtil.getFluidHandlerCapability(stack);
if (cap == null || cap.getTankProperties() == null || cap.getTankProperties().length <= 0) {
return false;
}
IFluidTankProperties tank = cap.getTankProperties()[0];
if (tank == null || tank.getCapacity() <= 0) {
return false;
}
int maxFluid = tank.getCapacity();
FluidStack fluidStack = tank.getContents();
int fluidAmount = fluidStack == null ? 0 : fluidStack.amount;
if (alwaysShow || shouldShowBar(maxFluid, fluidAmount)) {
double level = (double) fluidAmount / (double) maxFluid;
boolean up = stack.getItem().showDurabilityBar(stack);
boolean top = stack.getCount() != 1;
render(level, xPosition, yPosition, top ? 12 - barOffset : up ? 2 + barOffset : barOffset, (barOffset & 1) == 0);
return true;
}
return false;
}
示例6: matches
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
boolean foundStick = false;
boolean foundFluid = false;
for (int i = 0; i < inv.getSizeInventory() && (!foundStick || !foundFluid); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (Prep.isValid(stack)) {
foundStick |= isStick(stack);
if (!foundFluid) {
final FluidStack fluidStack = FluidUtil.tryDrainContainer(stack, new NutDistTank()).result.fluidStack;
if (fluidStack != null && fluidStack.amount >= Fluid.BUCKET_VOLUME) {
foundFluid = true;
}
}
}
}
return foundStick && foundFluid;
}
示例7: addDetailedEntries
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public void addDetailedEntries(@Nonnull ItemStack itemstack, @Nullable EntityPlayer entityplayer, @Nonnull List<String> list, boolean flag) {
FluidStack fluid = FluidUtil.getFluidTypeFromItem(itemstack);
if (fluid != null) {
IFluidFuel fuel = FluidFuelRegister.instance.getFuel(fluid);
if (fuel != null) {
list.add(Lang.FUEL_HEADING.get());
list.add(TextFormatting.ITALIC + " " + LangPower.RFt(fuel.getPowerPerCycle()));
list.add(TextFormatting.ITALIC + " " + Lang.FUEL_BURNTIME.get(fuel.getTotalBurningTime()));
} else {
IFluidCoolant coolant = FluidFuelRegister.instance.getCoolant(fluid);
if (coolant != null) {
list.add(Lang.COOLANT_HEADING.get());
list.add(TextFormatting.ITALIC + " " + Lang.COOLANT_DEGREES.get(LangPower.format(coolant.getDegreesCoolingPerMB(100) * 1000)));
}
}
}
}
示例8: doPush
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
protected boolean doPush(@Nullable ForgeDirection dir) {
if (dir == null || isSideDisabled(dir.ordinal())) {
return false;
}
boolean res = super.doPush(dir);
if (outputTank.getFluidAmount() > 0) {
BlockCoord loc = getLocation().getLocation(dir);
IFluidHandler target = FluidUtil.getFluidHandler(worldObj, loc);
if (target != null) {
if (target.canFill(dir.getOpposite(), outputTank.getFluid().getFluid())) {
FluidStack push = outputTank.getFluid().copy();
push.amount = Math.min(push.amount, IO_MB_TICK);
int filled = target.fill(dir.getOpposite(), push, true);
if (filled > 0) {
outputTank.drain(filled, true);
tanksDirty = true;
return res;
}
}
}
}
return res;
}
示例9: drainFullContainer
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
private boolean drainFullContainer() {
FluidAndStackResult fill = FluidUtil.tryDrainContainer(inventory[getSlotDefinition().getMinInputSlot()], this);
if (fill.result.fluidStack == null) {
return false;
}
int slot = getSlotDefinition().getMinOutputSlot();
if (inventory[slot] != null && fill.result.itemStack != null) {
if (inventory[slot].isStackable() && ItemUtil.areStackMergable(inventory[slot], fill.result.itemStack)
&& inventory[slot].stackSize < inventory[slot].getMaxStackSize()) {
fill.result.itemStack.stackSize += inventory[slot].stackSize;
} else {
return false;
}
}
getInputTank(fill.result.fluidStack).setFluid(fill.remainder.fluidStack);
setInventorySlotContents(getSlotDefinition().getMinInputSlot(), fill.remainder.itemStack);
if (fill.result.itemStack != null) {
setInventorySlotContents(slot, fill.result.itemStack);
}
setTanksDirty();
markDirty();
return false;
}
示例10: doPush
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
protected boolean doPush(@Nullable ForgeDirection dir) {
if (dir == null || isSideDisabled(dir.ordinal())) {
return false;
}
boolean res = super.doPush(dir);
if(tank.getFluidAmount() > 0) {
BlockCoord loc = getLocation().getLocation(dir);
IFluidHandler target = FluidUtil.getFluidHandler(worldObj, loc);
if(target != null) {
if(target.canFill(dir.getOpposite(), tank.getFluid().getFluid())) {
FluidStack push = tank.getFluid().copy();
push.amount = Math.min(push.amount, IO_MB_TICK);
int filled = target.fill(dir.getOpposite(), push, true);
if(filled > 0) {
tank.drain(filled, true);
tankDirty = true;
return res;
}
}
}
}
return res;
}
示例11: isMachineItemValidForSlot
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public boolean isMachineItemValidForSlot(int i, @Nonnull ItemStack item) {
if (canVoidItems() && voidMode == VoidMode.ALWAYS && i < 2) {
return false;
}
if (i == 0) {
return FluidUtil.getFluidTypeFromItem(item) != null;
} else if (i == 1) {
return FluidUtil.hasEmptyCapacity(item) || canBeMended(item);
} else if (i == 2 && canVoidItems()) {
return voidMode == VoidMode.ALWAYS || (voidMode == VoidMode.NEVER ? false : !FluidUtil.isFluidContainer(item));
}
return false;
}
示例12: fillEmptyContainer
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
private boolean fillEmptyContainer() {
final int input = getSlotDefinition().getMinInputSlot() + 1;
final ItemStack inputStack = getStackInSlot(input);
if (Prep.isInvalid(inputStack) || tank.isEmpty()) {
return false;
}
final FluidTank outputTank = getOutputTanks()[0];
final FluidAndStackResult fill = FluidUtil.tryFillContainer(inputStack, outputTank.getFluid());
if (fill.result.fluidStack == null) {
return false;
}
final int output = getSlotDefinition().getMaxOutputSlot();
final ItemStack outputStack = getStackInSlot(output);
if (Prep.isValid(outputStack) && Prep.isValid(fill.result.itemStack)) {
if (outputStack.isStackable() && ItemUtil.areStackMergable(outputStack, fill.result.itemStack)
&& (fill.result.itemStack.getCount() + outputStack.getCount()) <= outputStack.getMaxStackSize()) {
fill.result.itemStack.grow(outputStack.getCount());
} else {
return false;
}
}
outputTank.setFluid(fill.remainder.fluidStack);
setInventorySlotContents(input, fill.remainder.itemStack);
setInventorySlotContents(output, fill.result.itemStack);
setTanksDirty();
markDirty();
return false;
}
示例13: drainFullContainer
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
private boolean drainFullContainer() {
final int input = getSlotDefinition().getMinInputSlot();
final ItemStack inputStack = getStackInSlot(input);
if (Prep.isInvalid(inputStack) || tank.isFull()) {
return false;
}
final FluidAndStackResult fill = FluidUtil.tryDrainContainer(inputStack, this);
if (fill.result.fluidStack == null) {
return false;
}
final int output = getSlotDefinition().getMinOutputSlot();
final ItemStack outputStack = getStackInSlot(output);
if (Prep.isValid(outputStack) && Prep.isValid(fill.result.itemStack)) {
if (outputStack.isStackable() && ItemUtil.areStackMergable(outputStack, fill.result.itemStack)
&& (fill.result.itemStack.getCount() + outputStack.getCount()) <= outputStack.getMaxStackSize()) {
fill.result.itemStack.grow(outputStack.getCount());
} else {
return false;
}
}
getInputTank(fill.result.fluidStack).setFluid(fill.remainder.fluidStack);
setInventorySlotContents(input, fill.remainder.itemStack);
if (Prep.isValid(fill.result.itemStack)) {
setInventorySlotContents(output, fill.result.itemStack);
}
setTanksDirty();
markDirty();
return false;
}
示例14: setFluid
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
public boolean setFluid(int index, ItemStack stack) {
if(stack == null) {
return setFluid(index, (FluidStack) null);
}
FluidStack f = FluidUtil.getFluidTypeFromItem(stack);
if (f == null || f.getFluid() == null) {
return false;
}
return setFluid(index, f);
}
示例15: canFill
import com.enderio.core.common.util.FluidUtil; //导入依赖的package包/类
@Override
public boolean canFill(EnumFacing from, FluidStack fluid) {
if (!getConnectionMode(from).acceptsInput() || network == null || fluid == null || fluid.amount <= 0) {
return false;
}
if (tank.getFluid() == null) {
return true;
}
if (fluid != null && FluidUtil.areFluidsTheSame(fluid.getFluid(), tank.getFluid().getFluid())) {
return true;
}
return false;
}