本文整理匯總了Java中net.minecraftforge.fluids.FluidStack.isFluidEqual方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidStack.isFluidEqual方法的具體用法?Java FluidStack.isFluidEqual怎麽用?Java FluidStack.isFluidEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fluids.FluidStack
的用法示例。
在下文中一共展示了FluidStack.isFluidEqual方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drain
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME)
{
return null;
}
FluidStack fluidStack = getFluid();
if (fluidStack != null && fluidStack.isFluidEqual(resource))
{
if (doDrain)
{
setFluid(null);
}
return fluidStack;
}
return null;
}
示例2: drain
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
{
return null;
}
FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
if (contained != null && contained.isFluidEqual(resource))
{
return drain(resource.amount, doDrain);
}
return null;
}
示例3: drain
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
{
return null;
}
FluidStack canDrain = drain(resource.amount, false);
if (canDrain != null)
{
if (canDrain.isFluidEqual(resource))
{
return drain(resource.amount, doDrain);
}
}
return null;
}
示例4: areEqual
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static boolean areEqual(FluidStack stack1, FluidStack stack2) {
if(stack1 == null || stack2 == null) {
return false;
}
return stack1.isFluidEqual(stack2);
}
示例5: onBlockActivated
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (world.isRemote) return true;
TileEntityBarrel barrel = (TileEntityBarrel) world.getTileEntity(pos);
world.notifyBlockUpdate(pos, state, state, 3);
ItemStack stack = player.getHeldItem(hand);
if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidHandlerItem itemHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
IFluidHandler barrelHandler = barrel.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
FluidStack fluidInItem = itemHandler.drain(Fluid.BUCKET_VOLUME, false);
FluidStack fluidInBarrel = barrelHandler.drain(Fluid.BUCKET_VOLUME, false);
if ((fluidInBarrel != null && fluidInBarrel.amount > 0) && (fluidInItem == null || fluidInItem.amount == 0 || (fluidInItem.isFluidEqual(fluidInBarrel) && fluidInItem.amount < Fluid.BUCKET_VOLUME))) {
itemHandler.fill(barrelHandler.drain(Fluid.BUCKET_VOLUME, true), true);
player.setHeldItem(hand, itemHandler.getContainer());
} else if (fluidInItem != null && fluidInItem.amount > 0 && fluidInItem.getFluid() != null && (fluidInBarrel == null || fluidInBarrel.amount == 0 || (fluidInBarrel.amount < Fluid.BUCKET_VOLUME && fluidInBarrel.isFluidEqual(fluidInItem)))) {
FluidStack fsin = itemHandler.drain(Fluid.BUCKET_VOLUME, true);
if (fsin != null && fsin.amount > 0 && fsin.getFluid() != null) {
barrelHandler.fill(fsin, true);
player.setHeldItem(hand, itemHandler.getContainer());
player.inventory.markDirty();
}
}
return true;
}
player.openGui(Bewitchment.instance, LibGui.BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
示例6: fluidStackEqual
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static boolean fluidStackEqual(FluidStack stack, FluidStack input, boolean checkCount)
{
if (stack == null && input == null)
return true;
if (stack == null ^ input == null)
return false;
return stack.isFluidEqual(input) && (!checkCount || input.amount <= stack.amount);
}
示例7: drain
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
{
return null;
}
return drain(resource.amount, doDrain);
}
示例8: drain
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
FluidStack contents = this.getContents();
if (contents == null || !resource.isFluidEqual(contents))
{
return null;
}
int requested = resource.amount;
int current = this.getContents().amount;
int drained = Math.min(requested, current);
FluidStack ret = this.getContents().copy();
ret.amount = drained;
if (doDrain)
{
if (drained == current)
{
this.setFluidStack(null);
}
else
{
contents.amount -= drained;
this.setFluidStack(contents);
}
}
return ret;
}
示例9: equals
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
protected boolean equals(FluidStack oldValue, FluidStack newValue) {
return oldValue.isFluidEqual(newValue) && oldValue.amount == newValue.amount;
}