当前位置: 首页>>代码示例>>Java>>正文


Java FluidUtil.interactWithFluidHandler方法代码示例

本文整理汇总了Java中net.minecraftforge.fluids.FluidUtil.interactWithFluidHandler方法的典型用法代码示例。如果您正苦于以下问题:Java FluidUtil.interactWithFluidHandler方法的具体用法?Java FluidUtil.interactWithFluidHandler怎么用?Java FluidUtil.interactWithFluidHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fluids.FluidUtil的用法示例。


在下文中一共展示了FluidUtil.interactWithFluidHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interactWithFluidItem

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
private boolean interactWithFluidItem(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing)
{
    if (getContent().canInteractWithFluidItem.get(getSubtype(state)).orElse(true))
    {
        TileEntity tile = worldIn.getTileEntity(pos);
        if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing))
        {
            if (worldIn.isRemote)
            {
                return true;
            }

            if (FluidUtil.interactWithFluidHandler(playerIn, hand, worldIn, pos, facing))
            {
                playerIn.inventoryContainer.detectAndSendChanges();
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:22,代码来源:BlockMixin.java

示例2: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote) {
        TileEntity te = worldIn.getTileEntity(pos);
        if(te != null && te instanceof TileFluidTank) {
            ItemStack activeHand = playerIn.getHeldItem(hand);
            if(!activeHand.isEmpty() && FluidUtil.getFluidHandler(activeHand) !=  null) {
                FluidTank ft = ((TileFluidTank) te).getTank();
                boolean canFillPrev = ft.canFill();
                boolean canDrainPrev = ft.canDrain();
                ft.setCanFill(true);
                ft.setCanDrain(true);
                try {
                    FluidUtil.interactWithFluidHandler(playerIn, hand, ft);
                } finally {
                    ft.setCanFill(canFillPrev);
                    ft.setCanDrain(canDrainPrev);
                }
                return true;
            }
            playerIn.openGui(ModularMachinery.MODID, CommonProxy.GuiType.TANK_INVENTORY.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
        }
    }
    return true;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:26,代码来源:BlockFluidOutputHatch.java

示例3: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public boolean onBlockActivated(ItemStack stack, EntityPlayer player) {
	if (stack == null)
		return false;
	
	//Bucketing out the fluid.
	if (stack != null && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
		boolean result = FluidUtil.interactWithFluidHandler(stack, tank, player);
		if (result) {
			PacketHandler.sendNBTUpdate(this);
		}
		return true;
	}
	
	//Adding a meltable.
	ItemStack addStack = stack.copy(); addStack.stackSize = 1;
	ItemStack insertStack = itemHandler.insertItem(0, addStack, true);
	if (!ItemStack.areItemStacksEqual(addStack, insertStack)) {
		itemHandler.insertItem(0, addStack, false);
		stack.stackSize--;
		PacketHandler.sendNBTUpdate(this);
		return true;
	}
	return true;
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:25,代码来源:TileCrucible.java

示例4: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldStack = player.getHeldItem(hand);
    ItemStack cauldron = getDrops(world, pos, state, 0).get(0);

    if (player.isSneaking() && (player.getHeldItemMainhand().isEmpty() && player.getHeldItemOffhand().isEmpty())) {
        this.onBlockDestroyedByPlayer(world, pos, state);
        InventoryHandlerHelper.giveItem(player, hand, cauldron);
        world.setBlockToAir(pos);
    }
    TileFluidTank tank = new TileFluidTank(0);
    if (cauldron.getTagCompound() != null) {
        tank.readFromNBT(cauldron.getTagCompound());
    }

    if (removeDye(world, pos, player, hand, heldStack, tank)) {
        return true;
    }

    //Fluid handling
    FluidUtil.interactWithFluidHandler(player, hand, world, pos, facing);

    return FluidUtil.getFluidHandler(heldStack) != null;
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:25,代码来源:BlockModCauldron.java

示例5: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  // check the TE
  TileEntityFluidCable te = (TileEntityFluidCable) world.getTileEntity(pos);
  boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side);
  if (te != null) {
    if (world.isRemote == false) { //server side
      FluidStack fs = te.getCurrentFluidStack();
      String msg = null;
      if (fs != null) {
        // UtilChat.lang("cyclic.fluid.amount") +
        msg = fs.getLocalizedName();
        if (te.getIncomingStrings() != "") {
          msg += " (" + UtilChat.lang("cyclic.fluid.flowing") + te.getIncomingStrings() + ")";
        }
      }
      else {
        msg = UtilChat.lang("cyclic.fluid.empty");
      }
      UtilChat.sendStatusMessage(player, msg);
    }
  }
  // otherwise return true if it is a fluid handler to prevent in world placement
  return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:26,代码来源:BlockFluidCable.java

示例6: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  // check the TE
  TileEntityBaseMachineFluid te = (TileEntityBaseMachineFluid) world.getTileEntity(pos);
  boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side);
  if (te != null) {
    if (world.isRemote == false) { //server side
      String message = null;
      FluidStack fs = te.getCurrentFluidStack();
      if (fs != null) {
        String amtStr = fs.amount + " / " + te.getCapacity() + " ";
        message = UtilChat.lang("cyclic.fluid.amount") + amtStr + fs.getLocalizedName();
      }
      else {
        message = UtilChat.lang("cyclic.fluid.empty");
      }
      String powered = world.isBlockPowered(pos) ? "cyclic.redstone.on" : "cyclic.redstone.off";
      UtilChat.sendStatusMessage(player, message + "; " + UtilChat.lang(powered));
    }
  }
  // otherwise return true if it is a fluid handler to prevent in world placement
  return success || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:BlockFluidPump.java

示例7: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  // check the TE
  TileEntityBucketStorage te = (TileEntityBucketStorage) world.getTileEntity(pos);
  boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side);
  if (te != null) {
    if (world.isRemote == false) { //server side
      FluidStack fs = te.getCurrentFluidStack();
      if (fs != null) {
        String amtStr = fs.amount + " / " + te.getCapacity() + " ";
        UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + amtStr + fs.getLocalizedName());
      }
      else {
        UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.empty"));
      }
    }
  }
  // otherwise return true if it is a fluid handler to prevent in world placement
  return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:21,代码来源:BlockBucketStorage.java

示例8: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
/**
 * with thanks and gratitude @KnightMiner https://github.com/KnightMiner/Ceramics/blob/1.11/src/main/java/knightminer/ceramics/blocks/BlockBarrel.java
 * 
 * 
 */
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  // check the TE
  TileEntityHydrator te = (TileEntityHydrator) world.getTileEntity(pos);
  FluidStack bucket = FluidUtil.getFluidContained(player.getHeldItem(hand));
  boolean success = false;
  if (bucket == null || bucket.getFluid() == FluidRegistry.WATER) {//THEN let fluid insert happen
    success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side);
  }
  if (te != null) {
    if (!world.isRemote) {
      int currentFluid = te.getField(Fields.FLUID.ordinal());
      UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid);
    }
  }
  // otherwise return true if it is a fluid handler to prevent in world placement
  return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:BlockHydrator.java

示例9: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) 
{
    // allow fluid handling logic to happen
    if(!world.isRemote && player.getHeldItem(hand).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))
    {
        TileEntity te = world.getTileEntity(pos);
        if(te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
        {
            IFluidHandler fluidHandler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
            if(FluidUtil.interactWithFluidHandler(player, hand, fluidHandler))
                return true;
        }
    }
    return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:17,代码来源:ModularTankBlock.java

示例10: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	TileCreosoteCollector tile=(TileCreosoteCollector) worldIn.getTileEntity(pos);
	if(worldIn.isRemote)
		return playerIn.getHeldItem(hand).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
	return FluidUtil.interactWithFluidHandler(playerIn, hand, tile.creosote);
}
 
开发者ID:EnderiumSmith,项目名称:CharcoalPit,代码行数:9,代码来源:BlockCreosoteCollector.java

示例11: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float par7, float par8,
        float par9) {

    ItemStack current = entityplayer.getHeldItem(hand);
    TileEntity tile = world.getTileEntity(pos);

    if (tile instanceof TileEntityTank) {
    	TileEntityTank tank = (TileEntityTank) tile;
    	if (ItemStackTools.isValid(current)) {
        	if(ToolUtil.isToolEquipped(entityplayer, hand)){
        		return ToolUtil.breakBlockWithTool(this, world, pos, entityplayer, hand);
        	}            

        	IFluidHandlerItem containerFluidHandler = FluidUtil.getFluidHandler(current);
        	if (containerFluidHandler != null)
        	{
        		if(FluidUtil.interactWithFluidHandler(entityplayer, hand, world, pos, side)){
        			return true;
        		}
        	}
    	}
    	
        if(!world.isRemote){
    		if(tank.tank !=null){
    			FluidStack fluid = tank.tank.getFluid();
    			if(fluid == null){
    				ChatUtil.sendNoSpam(entityplayer, "Fluid: (Empty) 0 mB / "+tank.tank.getCapacity()+" mB");
    			}
    			else ChatUtil.sendNoSpam(entityplayer, "Fluid: ("+fluid.getLocalizedName()+") "+fluid.amount+" mB / "+tank.tank.getCapacity()+" mB");
    		}
		}
		return true;
    } 
    return false;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:37,代码来源:BlockTank.java

示例12: activate

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean activate(EntityPlayer player, int subHit, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (subHit == 4) {
        pressure_state.invert();
        return true;
    }
    return FluidUtil.interactWithFluidHandler(player, hand, getStorage());
}
 
开发者ID:TheCBProject,项目名称:EnderStorage,代码行数:10,代码来源:TileEnderTank.java

示例13: interactWithFluidHandler

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static boolean interactWithFluidHandler(IFluidHandler tankOnSide, EntityPlayer playerIn, EnumHand hand) {
	if (tankOnSide != null) {
		FluidActionResult r = FluidUtil.interactWithFluidHandler(playerIn.getHeldItem(hand), tankOnSide, playerIn);
		if (r.success)
			playerIn.setHeldItem(hand, r.result);
		return r.success;
	} else
		return false;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:11,代码来源:TomsModUtils.java

示例14: fillBlockWithFluid

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public boolean fillBlockWithFluid(World worldIn, BlockPos pos, EntityPlayer playerIn, ItemStack heldItem, EnumFacing side)
{
    TileEntity tile = worldIn.getTileEntity(pos);
    if(tile == null || !tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
    {
        return false;
    }

    IFluidHandler fluidHandler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
    FluidUtil.interactWithFluidHandler(heldItem, fluidHandler, playerIn);
    return heldItem != null && !(heldItem.getItem() instanceof ItemBlock);
}
 
开发者ID:CyberdyneCC,项目名称:HazardousResearch,代码行数:13,代码来源:BlockMachineBase.java

示例15: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  // check the TE
  TileEntityXpPylon te = (TileEntityXpPylon) world.getTileEntity(pos);
  boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side);
  if (te != null) {
    if (!world.isRemote) {
      int currentFluid = te.getField(TileEntityXpPylon.Fields.EXP.ordinal());
      UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid);
    }
  }
  // otherwise return true if it is a fluid handler to prevent in world placement
  return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:15,代码来源:BlockXpPylon.java


注:本文中的net.minecraftforge.fluids.FluidUtil.interactWithFluidHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。