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

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

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

Block.getItemDropped介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return Blocks.DIRT.getItemDropped(state, rand, fortune);
}

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return Blocks.DIRT.getItemDropped(state, rand, fortune);
}

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

/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return !this.canDrop ? Items.AIR : super.getItemDropped(state, rand, fortune);
}

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

/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return !this.canDrop ? Items.AIR : super.getItemDropped(state, rand, fortune);
}

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

@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return isFire ? ModBlocks.charedDirt.getItemDropped(ModBlocks.charedDirt.getDefaultState(), rand, fortune) : ModBlocks.frozenDirt.getItemDropped(ModBlocks.frozenDirt.getDefaultState(), rand, fortune);
}

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

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  if (state.getValue(HALF) == EnumBlockTorchHalf.LOWER)
    return Items.AIR;
  else {
    return super.getItemDropped(state, rand, fortune);
  }
}

代码示例来源:origin: joshiejack/Mariculture

@Override
public Item getItemDropped(IBlockState state, Random rand, int side) {
  return !doesDrop(state) ? null : super.getItemDropped(state, rand, side);
}

代码示例来源:origin: TeamWizardry/Wizardry

@Nonnull
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return Blocks.DIRT.getItemDropped(Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, DirtType.DIRT), rand, fortune);
}

代码示例来源:origin: Vazkii/Quark

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
  return Blocks.DIRT.getItemDropped(Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
}

代码示例来源:origin: cabaletta/baritone

public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
  if (!Baritone.settings().mineScanDroppedItems.get()) {
    return new ArrayList<>();
  }
  Set<Item> searchingFor = new HashSet<>();
  for (Block block : mining) {
    Item drop = block.getItemDropped(block.getDefaultState(), new Random(), 0);
    Item ore = Item.getItemFromBlock(block);
    searchingFor.add(drop);
    searchingFor.add(ore);
  }
  List<BlockPos> ret = new ArrayList<>();
  for (Entity entity : world.loadedEntityList) {
    if (entity instanceof EntityItem) {
      EntityItem ei = (EntityItem) entity;
      if (searchingFor.contains(ei.getItem().getItem())) {
        ret.add(new BlockPos(entity));
      }
    }
  }
  return ret;
}

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

@Override
public Item getItemDropped(IBlockState blockState, Random random, int zero) {
  return getBlockFromState(blockState).getBlock().getItemDropped(getBlockFromState(blockState), random, zero);
}

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

public void setBlockHarvested(Block block, int meta) {
  Random rand = new Random();
  if (block != null) {
    Utils.dropStack(getEntityWorld(), getPosition(), new ItemStack(block.getItemDropped(block.getStateFromMeta(meta), rand, 0), rand.nextInt(2) + 1));
    Utils.dropStack(getEntityWorld(), getPosition(), new ItemStack(block.getItemDropped(block.getDefaultState(), rand, 0), rand.nextInt(2) + 1));
  }
}

代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
  switch (type)
  {
    case RAW:
      return ItemRock.get(rock);
    case CLAY:
    case CLAY_GRASS:
      return Items.CLAY_BALL; // todo: own clay or event for clay making?
    default:
      return super.getItemDropped(state, rand, fortune);
    case GRASS:
    case DRY_GRASS:
    case PATH:
      return Item.getItemFromBlock(get(rock, Rock.Type.DIRT));
  }
}

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

@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
  List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
  if (state.getValue(HALF) == EnumBlockHalf.UPPER) {
    IBlockState iblockstate = world.getBlockState(pos.down());
    ret.add(new ItemStack(iblockstate.getBlock().getItemDropped(iblockstate, RANDOM, fortune)));
  } else {
    if (state.getValue(VARIANT) == EnumPlantType.SUNDEW)
      ret.add(new ItemStack(ModItems.MATERIALS, 1, ItemMaterials.EnumErebusMaterialsType.BIO_LUMINESCENCE.ordinal()));
    else if (state.getValue(VARIANT) == EnumPlantType.WEEPING_BLUEBELL)
      ret.add(new ItemStack(ModItems.MATERIALS, 1, ItemMaterials.EnumErebusMaterialsType.BLUEBELL_PETAL.ordinal()));
    else if (state.getValue(VARIANT) == EnumPlantType.BULLRUSH)
      ret.add(new ItemStack(ModItems.MATERIALS, 1, ItemMaterials.EnumErebusMaterialsType.PAPYRUS.ordinal()));
    else if (state.getValue(VARIANT) == EnumPlantType.TALL_BLOOM)
      ret.add(new ItemStack(this, 1, getMetaFromState(state)));
    else if (state.getValue(VARIANT) == EnumPlantType.TANGLED_STALK_MUSHROOM)
      ret.add(new ItemStack(this, 1, getMetaFromState(state)));
    else if (state.getValue(VARIANT) == EnumPlantType.HIGH_CAPPED_MUSHROOM)
      ret.add(new ItemStack(this, 1, getMetaFromState(state)));
    else {
      ItemStack seed = ForgeHooks.getGrassSeed(RANDOM, fortune);
      if (!seed.isEmpty())
        ret.add(seed);
      else
        ret.add(new ItemStack(this, 1, getMetaFromState(state)));
    }
  }
  return ret;
}

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

protected void findBlockDataForDirection(EnumFacing direction) {
 World world = cb.getBundleworld();
 BlockPos blockPos = cb.getLocation().offset(direction);
 if (!world.isAirBlock(blockPos)) {
  IBlockState bs = world.getBlockState(blockPos);
  Block b = bs.getBlock();
  if (b != null && b != ConduitRegistry.getConduitModObjectNN().getBlock()) {
   try {// TODO: This seems wrong. pickBlock?
    Item item = b.getItemDropped(bs.getActualState(world, blockPos), world.rand, 0);
    if (item != null) {
     stacks.put(direction, new ItemStack(item, 1, b.damageDropped(bs)));
    }
   } catch (Throwable t) {
   }
  }
 }
}

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

public static ItemStack getItemFromBlock(
    @Nonnull final IBlockState state )
{
  final Block blk = state.getBlock();
  final Item i = blk.getItemDropped( state, RAND, 0 );
  final int meta = blk.getMetaFromState( state );
  final int damage = blk.damageDropped( state );
  final Item blockVarient = Item.getItemFromBlock( blk );
  // darn conversions...
  if ( blk == Blocks.GRASS )
  {
    return new ItemStack( Blocks.GRASS );
  }
  if ( i == null || blockVarient == null || blockVarient != i )
  {
    return ModUtil.getEmptyStack();
  }
  if ( blockVarient instanceof ItemBlock )
  {
    final ItemBlock ib = (ItemBlock) blockVarient;
    if ( meta != ib.getMetadata( damage ) )
    {
      // this item dosn't drop itself... BAIL!
      return ModUtil.getEmptyStack();
    }
  }
  return new ItemStack( i, 1, damage );
}

代码示例来源:origin: OpenMods/OpenModsLib

private void dropBlock() {
  final Block block = blockState.getBlock();
  Random rand = world.rand;
  final int count = block.quantityDropped(blockState, 0, rand);
  for (int i = 0; i < count; i++) {
    final Item item = block.getItemDropped(blockState, rand, 0);
    if (item != null) {
      ItemStack toDrop = new ItemStack(item, 1, block.damageDropped(blockState));
      entityDropItem(toDrop, 0.1f);
    }
  }
  if (tileEntity instanceof IInventory) {
    IInventory inv = (IInventory)tileEntity;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
      ItemStack is = inv.getStackInSlot(i);
      if (is != null) entityDropItem(is, 0.1f);
    }
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

@SubscribeEvent
  public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
    IBlockState state = event.getState();
    Block block = state.getBlock();
    if (block instanceof BlockLeaves && !(block instanceof BlockForestryLeaves)) {
      EntityPlayer player = event.getHarvester();
      if (player != null) {
        ItemStack harvestingTool = player.getHeldItemMainhand();
        if (harvestingTool.getItem() instanceof IToolGrafter) {
          if (event.getDrops().isEmpty()) {
            World world = event.getWorld();
            Item itemDropped = block.getItemDropped(state, world.rand, 3);
            if (itemDropped != Items.AIR) {
              event.getDrops().add(new ItemStack(itemDropped, 1, block.damageDropped(state)));
            }
          }

          harvestingTool.damageItem(1, player);
          if (harvestingTool.isEmpty()) {
            net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, harvestingTool, EnumHand.MAIN_HAND);
          }
        }
      }
    }
  }
}

代码示例来源:origin: CoFH/ThermalDynamics

if (item == state.getBlock().getItemDropped(state, minecraft.world.rand, 0)) {

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

@Override
protected void actionPerformed(GuiButton button) throws IOException {
 if (button.id != redstoneBtn.id && button.id != slider.id) {
  EntityPlayer player = ModCyclic.proxy.getClientPlayer();
  BlockPosDim dim = ItemLocation.getPosition(tile.getStackInSlot(button.id));
  if (dim == null) {
   UtilChat.addChatMessage(player, "wireless.empty");
  }
  else if (dim.dimension != player.dimension) {
   UtilChat.addChatMessage(player, "wireless.dimension");
  }
  else {
   BlockPos target = dim.toBlockPos();
   if (tile.getWorld().isAreaLoaded(target, target.up())) {
    //get target
    IBlockState statehere = tile.getWorld().getBlockState(target);
    Block block = statehere.getBlock();
    //example: mek/thermal use crazy item stack NBT + Block metadata 
    int meta = block.damageDropped(statehere);
    ItemStack dropped = new ItemStack(block.getItemDropped(statehere, player.world.rand, 0), 1, meta);
    UtilChat.addChatMessage(player, dropped.getDisplayName() + " <" + block.getRegistryName().toString() + ":" + meta + ">");
   }
   else {
    UtilChat.addChatMessage(player, "wireless.unloaded");
   }
  }
 }
}

相关文章

Block类方法