本文整理了Java中net.minecraft.block.Block.getPickBlock()
方法的一些代码示例,展示了Block.getPickBlock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getPickBlock()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getPickBlock
暂无
代码示例来源: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: SleepyTrousers/EnderIO
@Override
public @Nonnull ItemStack getPickBlock(@Nonnull IBlockState state, @Nonnull RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos,
@Nonnull EntityPlayer player) {
final ItemStack pickBlock = super.getPickBlock(state, target, world, pos, player);
PaintUtil.setSourceBlock(pickBlock, getPaintSource(state, world, pos));
return pickBlock;
}
代码示例来源:origin: Lunatrius/Schematica
public static ItemStack getItemStack(final IBlockState blockState, final RayTraceResult rayTraceResult, final SchematicWorld world, final BlockPos pos, final EntityPlayer player) {
final Block block = blockState.getBlock();
try {
final ItemStack itemStack = block.getPickBlock(blockState, rayTraceResult, world, pos, player);
if (!itemStack.isEmpty()) {
return itemStack;
}
} catch (final Exception e) {
Reference.logger.debug("Could not get the pick block for: {}", blockState, e);
}
return ItemStack.EMPTY;
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public @Nonnull ItemStack getPickBlock(@Nonnull IBlockState state, @Nonnull RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos,
@Nonnull EntityPlayer player) {
if (checkParent(world, pos)) {
return getParentBlock(world, pos).getPickBlock(getParentBlockState(world, pos), target, world, getParentPos(pos), player);
} else {
return Prep.getEmpty();
}
}
代码示例来源:origin: SleepyTrousers/EnderCore
/**
* @deprecated override {@link #processPickBlock(IBlockState, RayTraceResult, World, BlockPos, EntityPlayer, ItemStack)} instead if possible
*/
@Override
@Deprecated
public @Nonnull ItemStack getPickBlock(@Nonnull IBlockState state, @Nonnull RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos,
@Nonnull EntityPlayer player) {
if (player.capabilities.isCreativeMode && GuiScreen.isCtrlKeyDown()) {
ItemStack nbtDrop = getNBTDrop(world, pos, state, 0, getTileEntity(world, pos));
if (nbtDrop != null) {
return nbtDrop;
}
}
return processPickBlock(state, target, world, pos, player, super.getPickBlock(state, target, world, pos, player));
}
代码示例来源:origin: ForestryMC/Binnie
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
TileCeramic ceramic = TileUtil.getTile(world, pos, TileCeramic.class);
if (ceramic != null) {
return ceramic.getStack();
}
return super.getPickBlock(state, target, world, pos, player);
}
代码示例来源:origin: OpenMods/OpenModsLib
@Override
@Nonnull
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
if (hasCapability(TileEntityCapability.CUSTOM_PICK_ITEM)) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof ICustomPickItem)
return ((ICustomPickItem)te).getPickBlock(player);
}
return suppressPickBlock()? ItemStack.EMPTY : super.getPickBlock(state, target, world, pos, player);
}
代码示例来源:origin: ForestryMC/Binnie
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
TileCeramicBrick ceramic = TileUtil.getTile(world, pos, TileCeramicBrick.class);
if (ceramic != null) {
return ceramic.pair().getStack(1);
}
return super.getPickBlock(state, target, world, pos, player);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final ItemStack g = directedBlock.getPickBlock( directedBlockState, mop, hostWorld, directedTile.getPos(), null );
if( !g.isEmpty() )
代码示例来源:origin: Vazkii/Patchouli
private static Pair<BookEntry, Integer> getHoveredEntry(Book book) {
Minecraft mc = Minecraft.getMinecraft();
RayTraceResult res = mc.objectMouseOver;
if(res != null && res.typeOfHit == Type.BLOCK) {
BlockPos pos = res.getBlockPos();
IBlockState state = mc.world.getBlockState(pos);
Block block = state.getBlock();
ItemStack picked = block.getPickBlock(state, res, mc.world, pos, mc.player);
if(!picked.isEmpty())
return book.contents.recipeMappings.get(ItemStackUtil.wrapStack(picked));
}
return null;
}
代码示例来源:origin: MightyPirates/TIS-3D
@Override
public ItemStack getPickBlock(final IBlockState state, final RayTraceResult target, final World world, final BlockPos pos, final EntityPlayer player) {
// Allow picking modules installed in the casing.
final TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileEntityCasing) {
final TileEntityCasing casing = (TileEntityCasing) tileEntity;
final ItemStack stack = casing.getStackInSlot(target.sideHit.ordinal());
if (!stack.isEmpty()) {
return stack.copy();
}
}
return super.getPickBlock(state, target, world, pos, player);
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
TileEntityBoundingBox te = getTileEntity(world, pos);
return te.getOwnerBlock().getPickBlock(world.getBlockState(te.getOwnerPos()), target, world, te.getOwnerPos(), player);
}
代码示例来源:origin: amadornes/MCMultiPart
public default ItemStack getPickPart(IPartInfo part, RayTraceResult hit, EntityPlayer player) {
return part.getState().getBlock().getPickBlock(part.getState(), hit, part.getPartWorld(), part.getPartPos(), player);
}
代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (player.isSneaking() && world.isRemote) {
IBlockState state = world.getBlockState(pos);
RayTraceResult rtr = new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos);
ItemStack stack = state.getBlock().getPickBlock(state, rtr, world, pos, player);
if (!stack.isEmpty()) {
for (ItemStack stack2 : BookPageRegistry.bookRecipes.keySet()) {
if (stack2.getItem() == stack.getItem() && stack2.getItemDamage() == stack.getItemDamage()) {
GuiJournal.openRecipeFor(stack2, player);
return EnumActionResult.SUCCESS;
}
}
}
}
return EnumActionResult.FAIL;
}
}
代码示例来源:origin: Direwolf20-MC/BuildingGadgets
@Nonnull
public static UniqueItem blockStateToUniqueItem(IBlockState state, EntityPlayer player, BlockPos pos) {
ItemStack itemStack;
//if (state.getBlock().canSilkHarvest(player.world, pos, state, player)) {
// itemStack = InventoryManipulation.getSilkTouchDrop(state);
//} else {
//}
try {
itemStack = state.getBlock().getPickBlock(state, null, player.world, pos, player);
} catch (Exception e) {
itemStack = InventoryManipulation.getSilkTouchDrop(state);
}
if (itemStack.isEmpty()) {
itemStack = InventoryManipulation.getSilkTouchDrop(state);
}
if (!itemStack.isEmpty()) {
UniqueItem uniqueItem = new UniqueItem(itemStack.getItem(), itemStack.getMetadata());
return uniqueItem;
}
UniqueItem uniqueItem = new UniqueItem(Items.AIR, 0);
return uniqueItem;
//throw new IllegalArgumentException("A UniqueItem could net be retrieved for the the follwing state (at position " + pos + "): " + state);
}
代码示例来源:origin: Direwolf20-MC/BuildingGadgets
public static IBlockState getSpecificStates(IBlockState originalState, World world, EntityPlayer player, BlockPos pos, ItemStack tool) {
IBlockState placeState = Blocks.AIR.getDefaultState();
Block block = originalState.getBlock();
ItemStack item = block.getPickBlock(originalState, null, world, pos, player);
int meta = item.getMetadata();
try {
placeState = originalState.getBlock().getStateForPlacement(world, pos, EnumFacing.UP, 0, 0, 0, meta, player, EnumHand.MAIN_HAND);
} catch (Exception var8) {
placeState = originalState.getBlock().getDefaultState();
}
for (IProperty prop : placeState.getPropertyKeys()) {
if (tool.getItem() instanceof GadgetCopyPaste) {
if (SAFE_PROPERTIES_COPY_PASTE.contains(prop)) {
placeState = placeState.withProperty(prop, originalState.getValue(prop));
}
} else {
if (SAFE_PROPERTIES.contains(prop)) {
placeState = placeState.withProperty(prop, originalState.getValue(prop));
}
}
}
return placeState;
}
代码示例来源:origin: McJtyMods/TheOneProbe
private static void requestBlockInfo(ProbeMode mode, RayTraceResult mouseOver, BlockPos blockPos, EntityPlayerSP player) {
World world = player.getEntityWorld();
IBlockState blockState = world.getBlockState(blockPos);
Block block = blockState.getBlock();
ItemStack pickBlock = block.getPickBlock(blockState, mouseOver, world, blockPos, player);
if (pickBlock == null || (!pickBlock.isEmpty() && pickBlock.getItem() == null)) {
// Protection for some invalid items.
pickBlock = ItemStack.EMPTY;
}
if (pickBlock != null && (!pickBlock.isEmpty()) && Config.getDontSendNBTSet().contains(pickBlock.getItem().getRegistryName())) {
pickBlock = pickBlock.copy();
pickBlock.setTagCompound(null);
}
PacketHandler.INSTANCE.sendToServer(new PacketGetInfo(world.provider.getDimension(), blockPos, mode, mouseOver, pickBlock));
}
代码示例来源:origin: McJtyMods/TheOneProbe
private static ProbeInfo getWaitingInfo(ProbeMode mode, RayTraceResult mouseOver, BlockPos blockPos, EntityPlayerSP player) {
ProbeInfo probeInfo = TheOneProbe.theOneProbeImp.create();
World world = player.getEntityWorld();
IBlockState blockState = world.getBlockState(blockPos);
Block block = blockState.getBlock();
ItemStack pickBlock = block.getPickBlock(blockState, mouseOver, world, blockPos, player);
IProbeHitData data = new ProbeHitData(blockPos, mouseOver.hitVec, mouseOver.sideHit, pickBlock);
IProbeConfig probeConfig = TheOneProbe.theOneProbeImp.createProbeConfig();
try {
DefaultProbeInfoProvider.showStandardBlockInfo(probeConfig, mode, probeInfo, blockState, block, world, blockPos, player, data);
} catch (Exception e) {
ThrowableIdentity.registerThrowable(e);
probeInfo.text(ERROR + "Error (see log for details)!");
}
probeInfo.text(ERROR + "Waiting for server...");
return probeInfo;
}
代码示例来源:origin: TehNut/HWYLA
@Nonnull
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
Block block = accessor.getBlock();
// Disguises silverfish blocks as their normal counterpart
if (block == silverfish && config.getConfig("vanilla.silverfish")) {
BlockSilverfish.EnumType type = accessor.getBlockState().getValue(BlockSilverfish.VARIANT);
return type.getModelBlock().getBlock().getPickBlock(type.getModelBlock(), accessor.getMOP(), accessor.getWorld(), accessor.getPosition(), accessor.getPlayer());
}
// Wheat crop should display Wheat item
if (block == crops)
return new ItemStack(Items.WHEAT);
// Beetroot crop should display Beetroot item
if (block == beet)
return new ItemStack(Items.BEETROOT);
// Display farmland instead of dirt
if (block == farmland)
return new ItemStack(Blocks.FARMLAND);
return ItemStack.EMPTY;
}
代码示例来源:origin: Ellpeck/ActuallyAdditions
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote && player.getItemInUseCount() <= 0) {
if (player.isSneaking()) {
IBlockState state = world.getBlockState(pos);
ItemStack pick = state.getBlock().getPickBlock(state, world.rayTraceBlocks(player.getPositionVector(), new Vec3d(pos.getX() + hitX, pos.getY() + hitY, pos.getZ() + hitZ)), world, pos, player);
saveData(pick, state, stack);
return EnumActionResult.SUCCESS;
} else if (loadData(stack) != null) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound compound = stack.getTagCompound();
if (compound.getInteger("CurrX") == 0 && compound.getInteger("CurrY") == 0 && compound.getInteger("CurrZ") == 0) {
compound.setInteger("FirstX", pos.getX());
compound.setInteger("FirstY", pos.getY());
compound.setInteger("FirstZ", pos.getZ());
player.setActiveHand(hand);
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.PASS;
}
内容来源于网络,如有侵权,请联系作者删除!