本文整理汇总了Java中net.minecraft.item.Item.getByNameOrId方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getByNameOrId方法的具体用法?Java Item.getByNameOrId怎么用?Java Item.getByNameOrId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.Item
的用法示例。
在下文中一共展示了Item.getByNameOrId方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItem
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static Item getItem(JsonElement json, String memberName)
{
if (json.isJsonPrimitive())
{
String s = json.getAsString();
Item item = Item.getByNameOrId(s);
if (item == null)
{
throw new JsonSyntaxException("Expected " + memberName + " to be an item, was unknown string \'" + s + "\'");
}
else
{
return item;
}
}
else
{
throw new JsonSyntaxException("Expected " + memberName + " to be an item, was " + toString(json));
}
}
示例2: canCombineItems
import net.minecraft.item.Item; //导入方法依赖的package包/类
private boolean canCombineItems(ItemStack stackA, ItemStack stackB)
{
if (ItemStack.areItemsEqual(stackA, stackB)) return true;
if (stackA.getItem() == Items.POTIONITEM && stackB.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackB.getMetadata() == 0) return true;
if (stackA.getItem() == Items.SPLASH_POTION && stackB.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackB.getMetadata() == 1) return true;
if (stackA.getItem() == Items.LINGERING_POTION && stackB.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackB.getMetadata() == 2) return true;
if (stackB.getItem() == Items.POTIONITEM && stackA.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackA.getMetadata() == 0) return true;
if (stackB.getItem() == Items.SPLASH_POTION && stackA.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackA.getMetadata() == 1) return true;
if (stackB.getItem() == Items.LINGERING_POTION && stackA.getItem() == Item.getByNameOrId("potioncore:custom_potion") && stackA.getMetadata() == 2) return true;
if (stackA.getItem() == Items.TIPPED_ARROW && stackB.getItem() == Item.getByNameOrId("potioncore:custom_arrow")) return true;
if (stackB.getItem() == Items.TIPPED_ARROW && stackA.getItem() == Item.getByNameOrId("potioncore:custom_arrow")) return true;
return false;
}
示例3: getOutputStack
import net.minecraft.item.Item; //导入方法依赖的package包/类
private ItemStack getOutputStack(ItemStack inputStack)
{
Item item = inputStack.getItem();
if (item == Items.POTIONITEM || (item == Item.getByNameOrId("potioncore:custom_potion") && inputStack.getMetadata() == 0))
{
return new ItemStack(Items.POTIONITEM, 1, 0);
}
else if (item == Items.SPLASH_POTION || (item == Item.getByNameOrId("potioncore:custom_potion") && inputStack.getMetadata() == 1))
{
return new ItemStack(Items.SPLASH_POTION, 1, 0);
}
else if (item == Items.LINGERING_POTION || (item == Item.getByNameOrId("potioncore:custom_potion") && inputStack.getMetadata() == 2))
{
return new ItemStack(Items.LINGERING_POTION, 1, 0);
}
else if (item == Items.TIPPED_ARROW || item == Item.getByNameOrId("potioncore:custom_arrow"))
{
return new ItemStack(Items.TIPPED_ARROW, 1, 0);
}
else return ItemStack.EMPTY;
}
示例4: readFromNBT
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
String id = compound.getString("shitid");
int meta = compound.getInteger("meta");
itemstack = new ItemStack(Item.getByNameOrId(id),1,meta);
}
示例5: onBlockPlacedBy
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
if (stack.hasTagCompound() && world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof BlackHoleUnitTile && Item.getByNameOrId(stack.getTagCompound().getString(BlackHoleUnitTile.NBT_ITEMSTACK)) != null) {
BlackHoleUnitTile tile = (BlackHoleUnitTile) world.getTileEntity(pos);
if (stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_ITEMSTACK) && stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_META)) {
ItemStack item = new ItemStack(Item.getByNameOrId(stack.getTagCompound().getString(BlackHoleUnitTile.NBT_ITEMSTACK)), 1, stack.getTagCompound().getInteger(BlackHoleUnitTile.NBT_META));
if (stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_ITEM_NBT))
item.setTagCompound(stack.getTagCompound().getCompoundTag(BlackHoleUnitTile.NBT_ITEM_NBT));
tile.setStack(item);
}
if (stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_AMOUNT))
tile.setAmount(stack.getTagCompound().getInteger(BlackHoleUnitTile.NBT_AMOUNT));
}
}
示例6: getTooltip
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
public List<String> getTooltip(ItemStack stack) {
List<String> tooltip = super.getTooltip(stack);
if (stack.hasTagCompound() && Item.getByNameOrId(stack.getTagCompound().getString(BlackHoleUnitTile.NBT_ITEMSTACK)) != null) {
if (stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_ITEMSTACK) && stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_META)) {
tooltip.add(new TextComponentTranslation("text.industrialforegoing.display.item").getUnformattedText() + " " + new TextComponentTranslation(new ItemStack(Item.getByNameOrId(stack.getTagCompound().getString(BlackHoleUnitTile.NBT_ITEMSTACK)), 1, stack.getTagCompound().getInteger(BlackHoleUnitTile.NBT_META)).getUnlocalizedName() + ".name").getUnformattedText());
}
if (stack.getTagCompound().hasKey(BlackHoleUnitTile.NBT_AMOUNT))
tooltip.add(new TextComponentTranslation("text.industrialforegoing.display.amount").getUnformattedText() + " " + stack.getTagCompound().getInteger(BlackHoleUnitTile.NBT_AMOUNT));
}
return tooltip;
}
示例7: init
import net.minecraft.item.Item; //导入方法依赖的package包/类
@EventHandler
public void init(FMLPostInitializationEvent event)
{
ReactorInterior.registerFluid("ic2coolant", 0.66F, 0.95F, 6F, IHeatEntity.conductivityDiamond);
ReactorInterior.registerFluid("ic2uu_matter", 0.9F, 0.99F, 18F, IHeatEntity.conductivityDiamond);
Reactants.registerReactant("uFuel", 0, 0x46c81a);
Reactants.registerReactant("plutonium", 1, 0xaaaaaa);
ReactorConversions.register("uFuel", "plutonium");
Reactants.registerSolid("uraniumFuel", "uFuel");
Reactants.registerSolid("tinyPlutonium", "plutonium");
Item uraniumFuel = Item.getByNameOrId("ic2:nuclear");
if(uraniumFuel != null)
{
OreDictionary.registerOre("uraniumFuel", uraniumFuel);
OreDictionary.registerOre("tinyPlutonium", new ItemStack(uraniumFuel, 1, 7));
}
else
{
OreDictionary.registerOre("tinyPlutonium", new ItemStack(Item.getByNameOrId("bigreactors:ingotMetals"), 0, 1));
}
Fluid fluidUranium = FluidRegistry.getFluid("uraniumfuel");
if(fluidUranium != null)
Reactants.registerFluid(fluidUranium, "uFuel");
}
示例8: readFromNBT
import net.minecraft.item.Item; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
if (compound.hasKey("Item", 8))
{
this.flowerPotItem = Item.getByNameOrId(compound.getString("Item"));
}
else
{
this.flowerPotItem = Item.getItemById(compound.getInteger("Item"));
}
this.flowerPotData = compound.getInteger("Data");
}
示例9: initCustomRecipes
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static void initCustomRecipes(String[] customRecipes){
if(customRecipes!=null){
for(int i=0;i<customRecipes.length;i++){
String[] customRecipe=customRecipes[i].split(" ");
if(customRecipe.length!=4)
continue;
Item input=Item.getByNameOrId(customRecipe[0]);
Item output=Item.getByNameOrId(customRecipe[2]);
if(input!=null&&output!=null){
recipes.add(new PotteryKilnRecipe(new ItemStack(input, 1, Integer.parseInt(customRecipe[1])), new ItemStack(output, 1, Integer.parseInt(customRecipe[3]))));
}
}
}
}
示例10: getItem
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static Item getItem(String name) {
return Item.getByNameOrId(name);
}
示例11: getStackFromString
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static ItemStack getStackFromString(String string) {
String[] values = string.split("#");
Item item = Item.getByNameOrId(values[0]);
int meta = Integer.parseInt(values[1]);
return new ItemStack(item, 1, meta);
}
示例12: IItem
import net.minecraft.item.Item; //导入方法依赖的package包/类
public IItem(String name) {
this.item = Item.getByNameOrId(name);
}
示例13: IItemStack
import net.minecraft.item.Item; //导入方法依赖的package包/类
public IItemStack(String name) {
this.stack = new ItemStack(Item.getByNameOrId(name));
}
示例14: validName
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean validName(String name) {
return Item.getByNameOrId(name) != null;
}