本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}