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

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

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

Block.damageDropped介绍

暂无

代码示例

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

/**
 * This gets called every tick, please be careful with your checks.
 */
public boolean matches(World world, BlockPos pos, SubTileEntity pureDaisy, IBlockState state) {
  if(input instanceof Block)
    return state.getBlock() == input;
  if(input instanceof IBlockState)
    return state == input;
  ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
  String oredict = (String) input;
  return isOreDict(stack, oredict);
}

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

@Override
public String getBlockName(World world, RayTraceResult pos, EntityPlayer player) {
  BlockPos bPos = pos.getBlockPos();
  IBlockState state = world.getBlockState(bPos);
  ItemStack stack = state.getBlock().getPickBlock(state, pos, world, bPos, player);
  if(stack.isEmpty())
    stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
  if(stack.isEmpty())
    return null;
  String name = stack.getDisplayName();
  if(name == null || name.isEmpty())
    return null;
  return name;
}

代码示例来源:origin: portablejim/VeinMiner

/**
 * Uses the hooks from Block.getPickBlock() to check if the first and
 * second blocks give different metadata.
 * @param first BlockID of the first block.
 * @param second BlockID of the secound block.
 * @return If pick block on both blocks are the same.
 */
public static boolean arePickBlockEqual(BlockID first, BlockID second) {
  if(first == null || second == null) {
    return false;
  }
  int firstResultMeta = first.state.getBlock().damageDropped(first.state);
  int secondResultMeta = second.state.getBlock().damageDropped(second.state);
  return first.name.equals(second.name) && firstResultMeta == secondResultMeta;
}

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

default Iterable<ItemStack> getDropsFromFall(World world, BlockPos pos, IBlockState state, @Nullable NBTTagCompound teData, int fallTime, float fallDistance)
{
  return ImmutableList.of(new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state)));
}

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

@Override
public ItemStack getStack() {
  return new ItemStack(item, 1, state.getBlock().damageDropped(state));
}

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

/**
 * Creates an ItemStack representation of an IBlockState.
 *
 * @param state The state to use.
 * @param size The stack size to create.
 * @return An ItemStack which represents the passed state.
 */
@Deprecated
public static ItemStack getStackFromState (IBlockState state, int size) {
  
  return new ItemStack(state.getBlock(), size, state.getBlock().damageDropped(state));
}

代码示例来源:origin: Chisel-Team/Chisel

@Override
  public ItemStack getStack() {
    return new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
  }
}

代码示例来源:origin: sinkillerj/ProjectE

public static ItemStack stateToDroppedStack(IBlockState state, int stackSize)
  {
    return new ItemStack(state.getBlock(), stackSize, state.getBlock().damageDropped(state));
  }
}

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

public void addItemBlockState(IBlockState state, @Nonnull ItemStack stack) {
 if (state != null) {
  if (Prep.isInvalid(stack)) {
   stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
  }
  addItemModel(stack);
 }
}

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

public void addItemBlockStates(List<Pair<IBlockState, ItemStack>> states, @Nonnull ItemStack parent, Block parentBlock) {
 if (states == null || states.isEmpty()) {
  return;
 }
 for (Pair<IBlockState, ItemStack> pair : states) {
  IBlockState state = pair.getLeft();
  if (state != null) {
   ItemStack stack = pair.getRight();
   if (stack == null || Prep.isInvalid(stack)) {
    if (state.getBlock() == parentBlock) {
     stack = parent;
    } else {
     stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
    }
   }
   addItemModel(NullHelper.notnullJ(stack, "If you see this, the world will be ending yesterday half past yellow!"));
  }
 }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
protected ItemStack getStack() {
  return new ItemStack(Item.getItemFromBlock(state.getBlock()), 1, state.getBlock().damageDropped(state));
}

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

public static ItemStack getSilkTouchDrop(IBlockState state) {
  Item item = Item.getItemFromBlock(state.getBlock());
  int i = 0;
  if (item.getHasSubtypes()) {
    i = state.getBlock().damageDropped(state);
  }
  return new ItemStack(item, 1, i);
}

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

@Override
public String getLocalizedName() {
  return item != null ? item.getItemStackDisplayName(new ItemStack(item, 1, state.getBlock().damageDropped(state)))
      : state.getBlock().getLocalizedName();
}

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

public void addBlockStates(List<Pair<IBlockState, ItemStack>> states, @Nonnull ItemStack parent, Block parentBlock) {
 if (states == null || states.isEmpty()) {
  return;
 }
 BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
 for (Pair<IBlockState, ItemStack> pair : states) {
  IBlockState state = pair.getLeft();
  if (state != null) {
   ItemStack stack = pair.getRight();
   if (stack == null || Prep.isInvalid(stack)) {
    if (state.getBlock() == parentBlock) {
     stack = parent;
    } else {
     stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
    }
   }
   IBakedModel model = modelShapes.getModelForState(state);
   addBakedModel(model, NullHelper.notnullJ(stack, "If you see this, the world will be ending yesterday half past yellow!"));
  }
 }
}

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

public void addBlockState(IBlockState state, @Nonnull ItemStack stack, boolean allFacesToGeneral) {
 if (state != null) {
  if (Prep.isInvalid(stack)) {
   stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
  }
  BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
  IBakedModel model = modelShapes.getModelForState(state);
  addBakedModel(model, stack, allFacesToGeneral);
 }
}

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ){
  if(player.isSneaking()){
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    ItemStack blockStack = new ItemStack(block, 1, block.damageDropped(state));
    IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
    if(page != null){
      if(world.isRemote){
        forcedPage = page;
      }
      this.onItemRightClick(world, player, hand);
      return EnumActionResult.SUCCESS;
    }
  }
  return EnumActionResult.FAIL;
}

代码示例来源: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: 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: Ellpeck/ActuallyAdditions

private static boolean removeFittingItem(IBlockState state, EntityPlayer player) {
  Block block = state.getBlock();
  ItemStack stack = new ItemStack(block, 1, block.damageDropped(state));
  if (StackUtil.isValid(stack)) {
    for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
      ItemStack slot = player.inventory.getStackInSlot(i);
      if (StackUtil.isValid(slot) && slot.isItemEqual(stack)) {
        slot.shrink(1);
        if (!StackUtil.isValid(slot)) {
          player.inventory.setInventorySlotContents(i, StackUtil.getEmpty());
        }
        return true;
      }
    }
  }
  return false;
}

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

private boolean consumeFallingBlock(EntityFallingBlock fallingBlock) {
  ItemStack itemStack = new ItemStack(fallingBlock.getBlock().getBlock(), 1, fallingBlock.getBlock().getBlock().damageDropped(fallingBlock.getBlock()));
  if (!itemStack.isEmpty()) {
    try {
      mass = Math.addExact(mass, (long) MatterHelper.getMatterAmountFromItem(itemStack) * (long) itemStack.getCount());
      markDirty();
    } catch (ArithmeticException e) {
      return false;
    }
    fallingBlock.setDead();
    world.removeEntity(fallingBlock);
    return true;
  }
  return false;
}

相关文章

Block类方法