当前位置: 首页>>代码示例>>Java>>正文


Java MinecraftReflection.isCraftItemStack方法代码示例

本文整理汇总了Java中com.comphenix.protocol.utility.MinecraftReflection.isCraftItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java MinecraftReflection.isCraftItemStack方法的具体用法?Java MinecraftReflection.isCraftItemStack怎么用?Java MinecraftReflection.isCraftItemStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.comphenix.protocol.utility.MinecraftReflection的用法示例。


在下文中一共展示了MinecraftReflection.isCraftItemStack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSkullTexture

import com.comphenix.protocol.utility.MinecraftReflection; //导入方法依赖的package包/类
public static ItemStack setSkullTexture(ItemStack itemStack, String value) {
    ItemStack newStack = itemStack;
    if (!MinecraftReflection.isCraftItemStack(itemStack)) {
        newStack = MinecraftReflection.getBukkitItemStack(itemStack);
    }

    NbtCompound tag = (NbtCompound) NbtFactory.fromItemTag(newStack);
    NbtCompound skullOwner = NbtFactory.ofCompound("SkullOwner");
    NbtCompound properties = NbtFactory.ofCompound("Properties");

    NbtCompound compound = NbtFactory.ofCompound("");
    compound.put("Value", value);

    NbtList<NbtCompound> textures = NbtFactory.ofList("textures", compound);
    properties.put(textures);
    skullOwner.put("Id", UUID.randomUUID().toString());
    skullOwner.put(properties);
    tag.put(skullOwner);

    NbtFactory.setItemTag(newStack, tag);
    return newStack;
}
 
开发者ID:elsiff,项目名称:MoreFish,代码行数:23,代码来源:SkullUtils.java

示例2: removeAttributes

import com.comphenix.protocol.utility.MinecraftReflection; //导入方法依赖的package包/类
private static ItemStack removeAttributes(ItemStack item) {
	if (!MinecraftReflection.isCraftItemStack(item)) {
		item = MinecraftReflection.getBukkitItemStack(item);
	}
	try {
		NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(item);
		compound.put(NbtFactory.ofList("AttributeModifiers"));
	} catch (IllegalArgumentException e) {
		return item;
	}
	return item;
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:13,代码来源:ItemStackGenerator.java

示例3: wrap

import com.comphenix.protocol.utility.MinecraftReflection; //导入方法依赖的package包/类
@SneakyThrows( {InvocationTargetException.class, IllegalAccessException.class} )
public static ItemWrapper wrap(@NonNull ItemStack source) {
	if(!MinecraftReflection.isCraftItemStack(source)) {
		return new ItemWrapper((ItemStack) Reflect.getMethod(MinecraftReflection.getCraftItemStackClass(), "asCraftCopy", ItemStack.class).invoke(Reflect.STATIC, source));
	}

	return new ItemWrapper(source);
}
 
开发者ID:FastFelix771,项目名称:TownyWands,代码行数:9,代码来源:ItemWrapper.java

示例4: removeAttributes

import com.comphenix.protocol.utility.MinecraftReflection; //导入方法依赖的package包/类
public static ItemStack removeAttributes(ItemStack item) {
    if (!MinecraftReflection.isCraftItemStack(item)) {
        item = MinecraftReflection.getBukkitItemStack(item);
    }
    NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(item);
    compound.put(NbtFactory.ofList("AttributeModifiers"));
    return item;
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:9,代码来源:RPProtocolLib.java

示例5: assureCraftItemStack

import com.comphenix.protocol.utility.MinecraftReflection; //导入方法依赖的package包/类
@Override
public ItemStack assureCraftItemStack(ItemStack stack){
	if(!MinecraftReflection.isCraftItemStack(stack)){
		return MinecraftReflection.getBukkitItemStack(stack);
	}
	return stack;
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:8,代码来源:ProtocolLibUtilImplementation.java

示例6: setGlowing

import com.comphenix.protocol.utility.MinecraftReflection; //导入方法依赖的package包/类
@Override
public ProtocolOperationReturn<ItemStack> setGlowing(ItemStack stack, boolean glowing) {

	if(!MinecraftReflection.isCraftItemStack(stack)){
		return new ProtocolOperationReturn<ItemStack>(ProtocolOperationResult.FAILURE_INCORRECT_ARGUMENT_TYPE);
	}
	
	try{
		ItemMeta m = stack.getItemMeta();
		if(glowing){	
			if(m.hasEnchants()){
				return new ProtocolOperationReturn<ItemStack>(ProtocolOperationResult.FAILURE);
			}
			m.addEnchant(GLOW_ENCHANT_INDICATOR, GLOW_ENCHANT_LEVEL, true);
		}else{
			if(stack.containsEnchantment(GLOW_ENCHANT_INDICATOR) && stack.getEnchantmentLevel(GLOW_ENCHANT_INDICATOR) == GLOW_ENCHANT_LEVEL){
				m.removeEnchant(GLOW_ENCHANT_INDICATOR);
			}else{
				return new ProtocolOperationReturn<ItemStack>(ProtocolOperationResult.NOT_NEEDED);
			}
		}
		stack.setItemMeta(m);
		return new ProtocolOperationReturn<ItemStack>(ProtocolOperationResult.SUCCESS_QUEUED, stack);
	}catch(Exception ex){
		ex.printStackTrace();
		return new ProtocolOperationReturn<ItemStack>(ProtocolOperationResult.FAILURE, ex);
	}
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:29,代码来源:ProtocolLibUtilImplementation.java


注:本文中的com.comphenix.protocol.utility.MinecraftReflection.isCraftItemStack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。