net.minecraft.block.Block.onBlockActivated()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(221)

本文整理了Java中net.minecraft.block.Block.onBlockActivated()方法的一些代码示例,展示了Block.onBlockActivated()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.onBlockActivated()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:onBlockActivated

Block.onBlockActivated介绍

暂无

代码示例

代码示例来源:origin: McJtyMods/XNet

public static boolean activateBlock(Block block, World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  return block.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public boolean onBlockActivated(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityPlayer entityPlayer,
  @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
 if (checkParent(world, pos)) {
  return getParentBlock(world, pos).onBlockActivated(world, getParentPos(pos), getParentBlockState(world, pos), entityPlayer, hand, side, hitX, hitY, hitZ);
 } else {
  return false;
 }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

b.onBlockActivated( w, pos, w.getBlockState( pos ), p, hand, side, hitX, hitY, hitZ );

代码示例来源:origin: squeek502/VeganOption

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
  TileEntity tile = world.getTileEntity(pos);
  if (tile != null && tile instanceof TileEntityComposter)
  {
    return ((TileEntityComposter) tile).onActivated(player, side, hitX, hitY, hitZ);
  }
  return super.onBlockActivated(world, pos, state, player, hand, heldItem, side, hitX, hitY, hitZ);
}

代码示例来源:origin: squeek502/VeganOption

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
  if (super.onBlockActivated(world, pos, state, player, hand, heldItem, side, hitX, hitY, hitZ))
    return true;
  TileEntity tile = world.getTileEntity(pos);
  return tile instanceof TileEntityBasin && ((TileEntityBasin) tile).onBlockActivated(player, hand, side, hitX, hitY, hitZ);
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  BlockPos add = pos.add(0, -1, 0);
  IBlockState blockState = world.getBlockState(add);
  return blockState.getBlock().onBlockActivated(world, add, blockState, player, hand, side, hitX, hitY, hitZ);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

private void tryToggleRedstone(final BlockPos pos) {
 if (thrower instanceof EntityPlayer) {
  try {
   IBlockState blockState = world.getBlockState(pos);
   Block block = blockState.getBlock();
   boolean hasTriggered = block.onBlockActivated(world, pos, blockState, (EntityPlayer) this.thrower, EnumHand.MAIN_HAND, EnumFacing.UP, 0.5F, 0.5F, 0.5F);
   if (hasTriggered) {
    this.setRedstoneHasTriggered();
   }
  }
  catch (Throwable e) {
   //since activated can hit any block, be safe
   ModCyclic.logger.error("Error on activate block", e);
  }
 }
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  TileEntityBoundingBox te = getTileEntity(world, pos);
  IBlockState ownerState = world.getBlockState(te.getOwnerPos());
  if (ownerState.getBlock() == te.getOwnerBlock()) {
    return te.getOwnerBlock().onBlockActivated(world, te.getOwnerPos(), ownerState, player, hand, facing, hitX, hitY, hitZ);
  }
  return false;
}

代码示例来源:origin: vadis365/TheErebus

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  ItemStack itemstack = player.getHeldItem(hand);
  if (!itemstack.isEmpty() && (itemstack.getItem() == Items.FLINT_AND_STEEL || itemstack.getItem() == Items.FIRE_CHARGE)) {
    primeTnt(world, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
    world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
    if (itemstack.getItem() == Items.FLINT_AND_STEEL)
      itemstack.damageItem(1, player);
     else if (!player.capabilities.isCreativeMode)
      itemstack.shrink(1);
    return true;
  } else {
    return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
  }
}

代码示例来源:origin: amadornes/MCMultiPart

public default boolean onPartActivated(IPartInfo part, EntityPlayer player, EnumHand hand, RayTraceResult hit) {
  return part.getState().getBlock().onBlockActivated(part.getPartWorld(), part.getPartPos(), part.getState(), player, hand,
      hit.sideHit, (float) hit.hitVec.x - hit.getBlockPos().getX(), (float) hit.hitVec.y - hit.getBlockPos().getY(),
      (float) hit.hitVec.z - hit.getBlockPos().getZ());
}

代码示例来源:origin: TeamLapen/Vampirism

private static boolean blockWeaponTableFluids(TestInfo info) {
  info.world.setBlockState(info.pos, ModBlocks.weapon_table.getDefaultState());
  info.player.setHeldItem(info.player.getActiveHand(), new ItemStack(Items.LAVA_BUCKET));
  IBlockState block = info.world.getBlockState(info.pos);
  block.getBlock().onBlockActivated(info.world, info.pos, block, info.player, info.player.getActiveHand(), EnumFacing.random(info.world.rand), 0, 0, 0);
  block = info.world.getBlockState(info.pos);
  assert info.player.getHeldItem(info.player.getActiveHand()).getItem().equals(Items.BUCKET) : "Incorrect Fluid Container Handling";
  log("Block lava level: %s", block.getValue(BlockWeaponTable.LAVA));
  assert (block.getValue(BlockWeaponTable.LAVA) * BlockWeaponTable.MB_PER_META) == Fluid.BUCKET_VOLUME : "Incorrect Fluid Transaction";
  return true;
}

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player,
                EnumHand hand, EnumFacing side,
                float posX, float posY, float posZ) {
  if(blockState.getValue(ACTIVE)) {
    final Wrapper<BlockPos> tileLocationWrapper = new Wrapper<BlockPos>();
    TileColossalBloodChest.detector.detect(world, blockPos, null, new CubeDetector.IValidationAction() {
      @Override
      public L10NHelpers.UnlocalizedString onValidate(BlockPos location, IBlockState blockState) {
        if(blockState.getBlock() == ColossalBloodChest.getInstance()) {
          tileLocationWrapper.set(location);
        }
        return null;
      }
    }, false);
    BlockPos tileLocation = tileLocationWrapper.get();
    if(tileLocation != null) {
      world.getBlockState(tileLocation).getBlock().
          onBlockActivated(world, tileLocation, world.getBlockState(tileLocation),
              player, hand, side, posX, posY, posZ);
      return true;
    }
  }
  return super.onBlockActivated(world, blockPos, blockState, player, hand, side, posX, posY, posZ);
}

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player, EnumHand hand, EnumFacing side,
                float posX, float posY, float posZ) {
  if(blockState.getValue(ACTIVE)) {
    final Wrapper<BlockPos> tileLocationWrapper = new Wrapper<BlockPos>();
    TileSpiritFurnace.detector.detect(world, blockPos, null, new CubeDetector.IValidationAction() {
      @Override
      public L10NHelpers.UnlocalizedString onValidate(BlockPos location, IBlockState blockState) {
        if(blockState.getBlock() == SpiritFurnace.getInstance()) {
          tileLocationWrapper.set(location);
        }
        return null;
      }
    }, false);
    BlockPos tileLocation = tileLocationWrapper.get();
    if(tileLocation != null) {
      world.getBlockState(tileLocation).getBlock().
          onBlockActivated(world, tileLocation, world.getBlockState(tileLocation),
              player, hand, side, posX, posY, posZ);
      return true;
    }
  }
  return super.onBlockActivated(world, blockPos, blockState, player, hand, side, posX, posY, posZ);
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
  if(this == FurnitureBlocks.GRAND_CHAIR_BOTTOM && !playerIn.isSneaking())
  {
    if(SeatUtil.sitOnBlock(worldIn, pos.getX(), pos.getY(), pos.getZ(), playerIn, 6 * 0.0625))
    {
      worldIn.updateComparatorOutputLevel(pos, this);
      return true;
    }
  }
  else
  {
    worldIn.getBlockState(pos.down()).getBlock().onBlockActivated(worldIn, pos.down(), state, playerIn, hand, facing, hitX, hitY, hitZ);
  }
  return false;
}

代码示例来源:origin: MightyPirates/TIS-3D

return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

boolean result = FurnitureBlocks.BASIN.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
if (tileEntity != null)

代码示例来源:origin: Alex-the-666/Ice_and_Fire

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  ItemStack item = playerIn.inventory.getCurrentItem();
  if (!item.isEmpty()) {
    if (item.getItem() != null) {
      if (item.getItem() == Item.getItemFromBlock(ModBlocks.silverPile)) {
        if (!item.isEmpty()) {
          if (this.getMetaFromState(state) < 7) {
            WorldUtils.setBlock(worldIn, pos.getX(), pos.getY(), pos.getZ(), ModBlocks.silverPile, this.getMetaFromState(state) + 1, 3);
            if (!playerIn.capabilities.isCreativeMode) {
              item.shrink(1);
              if (item.isEmpty()) {
                playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, ItemStack.EMPTY);
              }
            }
            return true;
          }
        }
      }
    }
  }
  return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  ItemStack item = playerIn.inventory.getCurrentItem();
  if (!item.isEmpty()) {
    if (item.getItem() != null) {
      if (item.getItem() == Item.getItemFromBlock(ModBlocks.goldPile)) {
        if (!item.isEmpty()) {
          if (this.getMetaFromState(state) < 7) {
            WorldUtils.setBlock(worldIn, pos.getX(), pos.getY(), pos.getZ(), ModBlocks.goldPile, this.getMetaFromState(state) + 1, 3);
            if (!playerIn.capabilities.isCreativeMode) {
              item.shrink(1);
              if (item.isEmpty()) {
                playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, ItemStack.EMPTY);
              } else {
                playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, item);
              }
            }
            return true;
          }
        }
      }
    }
  }
  return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
  if(state.getValue(HALF) == BlockHalf.UPPER) {
    IBlockState downState = worldIn.getBlockState(pos.down());
    if(downState.getBlock() instanceof  WestIndianLilacBlock) {
      return downState.getBlock().onBlockActivated(worldIn, pos.down(), downState, playerIn, hand, side, hitX, hitY, hitZ);
    }
    return false;
  }
  int age = state.getValue(AGE);
  if (age == 2)
  {
    if (worldIn.isRemote) {
      return true;
    }
    IBlockState newState = state.withProperty(AGE, MathHelper.clamp(--age, 0, 2));
    worldIn.setBlockState(pos, newState);
    worldIn.setBlockState(pos.up(), newState.withProperty(HALF, BlockHalf.UPPER));
    ItemStack itemDrop = new ItemStack(ItemHandler.WEST_INDIAN_LILAC_BERRIES);
    EntityItem entityitem = new EntityItem(worldIn, playerIn.posX, playerIn.posY - 1.0D, playerIn.posZ, itemDrop);
    worldIn.spawnEntity(entityitem);
    if (!(playerIn instanceof FakePlayer))
    {
      entityitem.onCollideWithPlayer(playerIn);
    }
    return true;
  }
  return false;
}

代码示例来源:origin: PrinceOfAmber/Cyclic

stuffBehind.getBlock().onBlockActivated(worldObj, posBehind, stuffBehind, entityPlayer, event.getHand(), event.getFace(), 0, 0, 0);

相关文章

Block类方法