本文整理汇总了Java中net.minecraftforge.fluids.capability.IFluidTankProperties.getContents方法的典型用法代码示例。如果您正苦于以下问题:Java IFluidTankProperties.getContents方法的具体用法?Java IFluidTankProperties.getContents怎么用?Java IFluidTankProperties.getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fluids.capability.IFluidTankProperties
的用法示例。
在下文中一共展示了IFluidTankProperties.getContents方法的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: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
};
}
示例7: 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;
}
示例8: 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));
}
}
示例9: 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);
}
示例10: getFluids
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
@Override
public FluidStackList getFluids() {
FluidStackList fluids = new FluidStackList();
IFluidHandler handler = getTank();
if (handler !=null) {
IFluidTankProperties prop = handler.getTankProperties()[0];
if (prop != null) {
FluidStack stack = prop.getContents();
if(stack !=null && stack.amount > 0){
fluids.add(stack);
}
}
}
return fluids;
}
示例11: insertFluid
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
@Override
public int insertFluid(EStorageNetwork network, FluidStack stack, boolean matching, boolean sim) {
IFluidHandler handler = getTank();
if (handler !=null) {
int ret = 0;
if(matching){
IFluidTankProperties prop = handler.getTankProperties()[0];
if (prop != null) {
FluidStack internalStack = prop.getContents();
if(internalStack !=null){
if(FluidUtil.canCombine(stack, internalStack)){
ret = handler.fill(stack, !sim);
}
}
}
} else {
ret = handler.fill(stack, !sim);
}
if(ret > 0){
FluidStack copy = stack.copy();
copy.amount = ret;
Iterator<IInsertListener> iter = network.listeners.iterator();
while (iter.hasNext()) {
iter.next().onFluidInserted(copy);
}
}
return ret;
}
return 0;
}
示例12: transferFluid
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
protected void transferFluid(EnumFacing face)
{
if (this.getIO(face) !=IOType.OUT || this.oMode == OutputMode.NONE) {
return;
}
TileEntity tile = getWorld().getTileEntity(getPos().offset(face));
if(tile == null || !isFluidHandler(tile, face))return;
IFluidHandler fHandler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face.getOpposite());
int out = this.outputAmt;
if(this.oMode == OutputMode.CHECK){
IFluidTankProperties[] infoArray = fHandler.getTankProperties();
for(int t = 0; t < infoArray.length; t++){
IFluidTankProperties info = infoArray[t];
if(info.getContents() !=null){
if(info.getContents().amount >= this.outputAmt){
return;
}else{
out-=info.getContents().amount;
break;
}
}
}
}
FluidStack copy = tank.getFluid().copy();
copy.amount = Math.min(tank.getFluidAmount(), out);
if(tank.getFluidAmount() == 0)return;
this.drainInternal(fHandler.fill(copy, true), true);
this.tankDirty = true;
}
示例13: comparatorInput
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
@Override
public int comparatorInput() {
IFluidTankProperties tank = getStorage().getTankProperties()[0];
FluidStack fluid = tank.getContents();
if (fluid == null) {
fluid = FluidUtils.emptyFluid();
}
return fluid.amount * 14 / tank.getCapacity() + (fluid.amount > 0 ? 1 : 0);
}
示例14: onItemUse
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack stack = player.getHeldItem(hand);
if(player.isSneaking())
{
if(stack != null)
{
IFluidHandler fluidHandler = stack.getCapability(FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.DOWN);
if(fluidHandler != null)
{
IFluidTankProperties[] props = fluidHandler.getTankProperties();
int number = 1;
for(IFluidTankProperties prop : props)
{
FluidStack contents = prop.getContents();
if(contents == null)
LogHelper.info("Tank " + number + ": EMPTY");
else
LogHelper.info("Tank " + number + ": " + contents.getFluid().getName() + " (" + contents.amount + ")");
number++;
}
}
}
}
else
{
IModeHandler modeHandler = stack.getCapability(MODE_CAPABILITY, EnumFacing.DOWN);
if(modeHandler != null)
{
int mode = modeHandler.nextMode();
player.sendMessage(new TextComponentString("Current Mode: " + MODE.values()[mode].name()));
}
}
return EnumActionResult.PASS;
}
示例15: getFluidAmount
import net.minecraftforge.fluids.capability.IFluidTankProperties; //导入方法依赖的package包/类
@Override
public int getFluidAmount(FluidStack like) {
IFluidTankProperties[] tankInfo = fluidHandler.getTankProperties();
int amount = 0;
for (IFluidTankProperties tank : tankInfo) {
FluidStack contents = tank.getContents();
if(contents != null && contents.isFluidEqual(like)) {
amount += contents.amount;
}
}
return amount;
}