本文整理了Java中net.minecraft.item.ItemStack.getItem()
方法的一些代码示例,展示了ItemStack.getItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.getItem()
方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:getItem
暂无
代码示例来源:origin: EngineHub/WorldEdit
@Override
public BaseItemStack getItemInHand(HandSide handSide) {
ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND);
return new BaseItemStack(ItemTypes.get(ForgeRegistries.ITEMS.getKey(is.getItem()).toString()));
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public AESharedItemStack( final ItemStack itemStack )
{
this.itemStack = itemStack;
this.itemId = Item.getIdFromItem( itemStack.getItem() );
this.itemDamage = itemStack.getItemDamage();
}
代码示例来源:origin: Vazkii/Botania
public static int getStackItemTime(ItemStack stack) {
if(stack.isEmpty())
return 0;
if(stack.getItem() == Item.getItemFromBlock(Blocks.SAND))
return stack.getItemDamage() == 1 ? 200 : 20;
if(stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND))
return 1200;
if(stack.getItem() == ModItems.manaResource)
return 1;
return 0;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private static IStorageCell<?> getStorageCell( final ItemStack input )
{
if( input != null )
{
final Item type = input.getItem();
if( type instanceof IStorageCell )
{
return (IStorageCell<?>) type;
}
}
return null;
}
代码示例来源:origin: Vazkii/Botania
public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) {
if(recursion > 5)
return false;
if(stack.getItemDamage() != Short.MAX_VALUE) {
ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE);
boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1);
if(general)
return true;
}
String key = getMagnetKey(stack);
return magnetBlacklist.contains(key);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public static IFacadePart isFacade( final ItemStack held, final AEPartLocation side )
{
if( held.getItem() instanceof IFacadeItem )
{
return ( (IFacadeItem) held.getItem() ).createPartFromItemStack( held, side );
}
return null;
}
代码示例来源:origin: Vazkii/Botania
@Override
public boolean collideBurst(IManaBurst burst, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
EntityThrowable entity = (EntityThrowable) burst;
dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack);
ItemStack compositeLens = getCompositeLens(stack);
if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens)
dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens);
return dead;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private ModelResourceLocation getMesh( ItemStack itemStack )
{
// If the stack has no color, don't use the colored model since the impact of calling getColor for every quad is
// extremely high,
// if the stack tries to re-search its inventory for a new paintball everytime
AEColor col = ( (ToolColorApplicator) itemStack.getItem() ).getActiveColor( itemStack );
return ( col != null ) ? MODEL_COLORED : MODEL_UNCOLORED;
}
代码示例来源:origin: Vazkii/Botania
public static String stackToString(ItemStack stack, boolean forceIgnore) {
if(stack.isEmpty())
return "NULL";
if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider)
return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);
return stack.getTranslationKey() + (forceIgnore || ignoreMeta(stack) ? "" : "~" + stack.getItemDamage());
}
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if(!stack.isEmpty() && stack.getItem() == ModItems.sparkUpgrade)
return super.insertItem(slot, stack, simulate);
else return stack;
}
};
代码示例来源:origin: Vazkii/Botania
@Override
public void apply(ItemStack stack, BurstProperties props) {
int storedColor = getStoredColor(stack);
if(storedColor != -1)
props.color = getLensColor(stack);
getLens(stack.getItemDamage()).apply(stack, props);
ItemStack compositeLens = getCompositeLens(stack);
if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens)
((ILens) compositeLens.getItem()).apply(compositeLens, props);
}
代码示例来源:origin: Vazkii/Botania
public OrechidRecipeWrapper(Map.Entry<String, Integer> entry) {
this.weight = entry.getValue();
final int amount = Math.max(1, Math.round((float) weight * 64 / getTotalOreWeight()));
// Shouldn't ever return an empty list since the ore weight
// list is filtered to only have ores with ItemBlocks
List<ItemStack> stackList = OreDictionary.getOres(entry.getKey()).stream()
.filter(s -> s.getItem() instanceof ItemBlock)
.map(ItemStack::copy)
.collect(Collectors.toList());
stackList.forEach(s -> s.setCount(amount));
outputStacks = Collections.singletonList(stackList);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public Item getItem()
{
final ItemStack is = this.getTextureItem();
if( is.isEmpty() )
{
return Items.AIR;
}
return is.getItem();
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public double getCharge( ItemStack stack )
{
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, poweredItem.getAECurrentPower( stack ) );
}
代码示例来源:origin: Vazkii/Botania
public int getManaCost() {
ItemStack stack = itemHandler.getStackInSlot(0);
if(recipe == null || stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer))
return 0;
IBrewContainer container = (IBrewContainer) stack.getItem();
return container.getManaCost(recipe.getBrew(), stack);
}
代码示例来源:origin: Vazkii/Botania
public static boolean doesOreExist(String key) {
return OreDictionary.doesOreNameExist(key)
&& OreDictionary.getOres(key).stream()
.anyMatch(s -> s.getItem() instanceof ItemBlock);
}
代码示例来源:origin: Vazkii/Botania
void buildEntries() {
entriesToDisplay.clear();
ILexicon lex = (ILexicon) stackUsed.getItem();
for(LexiconEntry entry : category == null ? BotaniaAPI.getAllEntries() : category.entries) {
if(entry.isVisible() && lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && matchesSearch(entry))
entriesToDisplay.add(entry);
}
Collections.sort(entriesToDisplay);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public ItemStack asItemStackRepresentation()
{
ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( !is.isEmpty() )
{
FluidDummyItem item = (FluidDummyItem) is.getItem();
item.setFluidStack( is, this.getFluidStack() );
return is;
}
return ItemStack.EMPTY;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
{
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
.getItem() instanceof ItemCreativeStorageCell )
{
return CreativeCellInventory.getCell( is );
}
return null;
}
代码示例来源:origin: Vazkii/Botania
@SubscribeEvent
public void leftClick(PlayerInteractEvent.LeftClickEmpty evt) {
if (!evt.getItemStack().isEmpty()
&& evt.getItemStack().getItem() == this) {
PacketHandler.sendToServer(new PacketLeftClick());
}
}
内容来源于网络,如有侵权,请联系作者删除!