本文整理汇总了Java中net.minecraftforge.fluids.capability.IFluidTankProperties类的典型用法代码示例。如果您正苦于以下问题:Java IFluidTankProperties类的具体用法?Java IFluidTankProperties怎么用?Java IFluidTankProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IFluidTankProperties类属于net.minecraftforge.fluids.capability包,在下文中一共展示了IFluidTankProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEvaluator
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {
@Override
protected boolean evaluate(BlockPos pos) {
TileEntity te = drone.world().getTileEntity(pos);
int count = 0;
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null) ) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
for (IFluidTankProperties prop : handler.getTankProperties()) {
FluidStack stack = prop.getContents();
if (stack != null) {
if (ProgWidgetLiquidFilter.isLiquidValid(stack.getFluid(), widget, 1)) {
count += stack.amount;
}
}
}
} else {
Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.world().getBlockState(pos).getBlock());
if (fluid != null && ProgWidgetLiquidFilter.isLiquidValid(fluid, widget, 1) && FluidUtils.isSourceBlock(drone.world(), pos)) {
count += 1000;
}
}
return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ?
count == ((ICondition) widget).getRequiredCount() :
count >= ((ICondition) widget).getRequiredCount();
}
};
}
示例2: amountRequested
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
public int amountRequested(FluidStack stack) {
int totalRequestingAmount = getTotalRequestedAmount(stack);
if (totalRequestingAmount > 0) {
TileEntity te = getTileEntity();
int count = 0;
for (EnumFacing facing : EnumFacing.VALUES) {
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
for (IFluidTankProperties properties : handler.getTankProperties()) {
FluidStack contents = properties.getContents();
if (contents != null && contents.getFluid() == stack.getFluid()) {
count += contents.amount;
}
}
if (count > 0) break;
}
}
if (count == 0) return 0;
count += getIncomingFluid(stack.getFluid());
return Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
}
return 0;
}
示例3: getTankProperties
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
public IFluidTankProperties[] getTankProperties() {
if(properties == null) { //Fingers crossed
ArrayList<IFluidTankProperties> importedProperties = new ArrayList<>();
if (tile != null)
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
IFluidTankProperties[] faceProperties = capability.getTankProperties();
importedProperties.addAll(Arrays.asList(faceProperties));
}
}
properties = importedProperties.toArray(new IFluidTankProperties[importedProperties.size()]);
}
return properties;
}
示例4: getTankInfo
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
public IFluidTankProperties[] getTankInfo(TileEntityPipeLiquid pipe, EnumFacing conDir) {
List<IFluidTankProperties> res = new ArrayList<IFluidTankProperties>(tanks.size());
NetworkTank tank = getTank(pipe, conDir);
for (NetworkTank target : tanks) {
if(!target.equals(tank) && target.isValid()) {
IFluidHandler fHandler = target.externalTank.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.tankDir);
IFluidTankProperties[] tTanks = fHandler.getTankProperties();
if(tTanks != null) {
for (IFluidTankProperties info : tTanks) {
res.add(info);
}
}
}
}
return res.toArray(new IFluidTankProperties[res.size()]);
}
示例5: getTankProperties
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
public IFluidTankProperties[] getTankProperties()
{
if (this.fluids.isEmpty())
return new IFluidTankProperties[0];
IFluidTankProperties[] properties = new IFluidTankProperties[fluids.size()];
for (int i = 0; i < fluids.size(); i++)
{
boolean first = i == 0;
int capacity2 = fluids.get(i).amount;
if (first)
capacity2 += getCapacity() - getFluidAmount();
properties[i] = new FluidTankProperties(fluids.get(i), capacity2, first, first);
}
return properties;
}
示例6: isValidInContainer
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
private boolean isValidInContainer(ItemStack stack) {
if (!ItemStackUtil.isEmpty(stack)) {
if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidHandlerItem handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
if (handler != null) {
IFluidTankProperties[] tanks = handler.getTankProperties();
if ((tanks != null) && (tanks.length > 0)) {
for(IFluidTankProperties tank: tanks) {
if (tank.canDrain()) {
FluidStack content = tank.getContents();
if ((content != null) && (content.amount > 0) && (content.getFluid() == FluidsRegistry.liquidXP)) {
return true;
}
}
}
}
}
}
}
return false;
}
示例7: isValidOutContainer
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
private boolean isValidOutContainer(ItemStack stack) {
if (!ItemStackUtil.isEmpty(stack)) {
Item item = stack.getItem();
if ((item == Items.GLASS_BOTTLE) || (item == Items.BUCKET)) {
return true;
}
if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidHandlerItem handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
if (handler != null) {
IFluidTankProperties[] tanks = handler.getTankProperties();
if ((tanks != null) && (tanks.length > 0)) {
for(IFluidTankProperties tank: tanks) {
if (tank.canFill()) {
FluidStack content = tank.getContents();
if ((content == null) || ((content.amount < tank.getCapacity()) && (content.getFluid() == FluidsRegistry.liquidXP))) {
return true;
}
}
}
}
}
}
}
return false;
}
示例8: getFluidStacksInInventory
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
public ArrayList<FluidStack> getFluidStacksInInventory(EnumFacing face){
ArrayList<FluidStack> result = new ArrayList<FluidStack>();
if (!hasInventoryOnSide(face.getIndex())) {
return result;
}
TileEntity te = world.getTileEntity(getPos().offset(face));
if (!te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face.getOpposite())) {
return result;
}
IFluidHandler fluidHandler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face.getOpposite());
for (IFluidTankProperties tank : fluidHandler.getTankProperties()) {
if (!(tank.getContents() == null)) {
result.add(tank.getContents());
}
}
return result;
}
示例9: getTankProperties
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
public IFluidTankProperties[] getTankProperties()
{
IFluidTankProperties[] ret = new IFluidTankProperties[tanks.size()];
for(int i = 0; i < ret.length; i++)
{
IFluidTankProperties[] temp = tanks.get(i).getTankProperties();
if(temp == null || temp.length < 1)
{
ret[i] = new FluidTankProperties(null, 0);
}
else
{
ret[i] = temp[0];
}
}
return ret;
}
示例10: getFluidPredicate
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
public static Predicate<ItemStack> getFluidPredicate(Fluid fluid) {
return new Predicate<ItemStack>() {
@Override
public boolean test(ItemStack itemStack) {
IFluidHandlerItem handler = FluidUtil.getFluidHandler(itemStack);
if (handler == null) {
return false;
}
for (IFluidTankProperties properties : handler.getTankProperties()) {
FluidStack stack = properties.getContents();
if (stack != null && stack.getFluid() == fluid) {
return true;
}
}
return false;
}
};
}
示例11: getRecieveTankInfo
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
public void getRecieveTankInfo(List<IFluidTankProperties> infos, Set<Channel> channels) {
if (inGetTankInfo) {
return;
}
try {
inGetTankInfo = true;
if (!hasRecieveChannel(channels, ChannelType.FLUID)) {
return;
}
Map<EnumFacing, IFluidHandler> fluidHandlers = getNeighbouringFluidHandlers();
for (Entry<EnumFacing, IFluidHandler> entry : fluidHandlers.entrySet()) {
IFluidTankProperties[] tanks = entry.getValue().getTankProperties();
if (tanks != null) {
for (IFluidTankProperties info : tanks) {
infos.add(info);
}
}
}
} finally {
inGetTankInfo = false;
}
}
示例12: render
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的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;
}
示例13: handleFluidTanks
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
public static void handleFluidTanks(ProbeMode mode, IProbeInfo probeInfo, IFluidHandler handler) {
int n = 1;
for (IFluidTankProperties properties : handler.getTankProperties()) {
FluidStack fluidStack = properties.getContents();
String fluidDesc = fluidStack == null ? I18n.translateToLocalFormatted("gui.liquid.empty") : fluidStack.amount + "mB " + fluidStack.getLocalizedName();
probeInfo.text(I18n.translateToLocalFormatted("waila.fluid", n++, fluidDesc));
}
}
示例14: getTankProperties
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
public IFluidTankProperties[] getTankProperties() {
updateXpFluid();
if (curXpFluid != null) {
EntityPlayer player = getPlayer();
if (player != null) {
return new FluidTankProperties[] {
new FluidTankProperties(
new FluidStack(curXpFluid, getPlayerXP(player) * PneumaticCraftAPIHandler.getInstance().liquidXPs.get(curXpFluid)),
Integer.MAX_VALUE)
};
}
}
return null;
}
示例15: onItemRightClick
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
init(stack);
if (getFluidStored(stack) >= FLUID_CAPACITY) {
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
RayTraceResult ray = rayTrace(worldIn, playerIn, true);
if (ray == null || ray.typeOfHit == null || hand == null) {
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
if (ray.typeOfHit == RayTraceResult.Type.BLOCK && hand == EnumHand.MAIN_HAND && !worldIn.isRemote) {
BlockPos blockpos = ray.getBlockPos();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Material material = iblockstate.getMaterial();
if (material == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0) {
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 11);
playerIn.addStat(StatList.getObjectUseStats(this));
playerIn.playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
addFluid(stack, 1000);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
else if (iblockstate.getBlock().hasTileEntity(iblockstate) && worldIn.getTileEntity(blockpos).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit)) {
IFluidHandler fluidHandler = worldIn.getTileEntity(blockpos).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit);
for (IFluidTankProperties property : fluidHandler.getTankProperties()) {
if (property.getContents().getFluid() == FluidRegistry.WATER && property.getContents().amount >= 1000 && property.canDrain()) {
fluidHandler.drain(new FluidStack(FluidRegistry.WATER, 1000), true);
addFluid(stack, 1000);
}
}
}
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}