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


Java ItemBlock类代码示例

本文整理汇总了Java中net.minecraft.item.ItemBlock的典型用法代码示例。如果您正苦于以下问题:Java ItemBlock类的具体用法?Java ItemBlock怎么用?Java ItemBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: attemptToGetAsVariant

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
 * (eg blue_orchid vs orchidBlue etc.)
 * @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
 * @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
 * @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
 */
public static Variation attemptToGetAsVariant(String part, ItemStack is)
{
    if (is.getItem() instanceof ItemBlock)
    {
        // Unlocalised name doesn't always match the names we use in types.xsd
        // (which are the names displayed by Minecraft when using the F3 debug etc.)
        ItemBlock ib = (ItemBlock)(is.getItem());
        IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
        for (IProperty prop : (java.util.Set<IProperty>)bs.getProperties().keySet())
        { 
            Comparable<?> comp = bs.getValue(prop);
            Variation var = attemptToGetAsVariant(comp.toString());
            if (var != null)
                return var;
        }
        return null;
    }
    else
        return attemptToGetAsVariant(part);
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:27,代码来源:MinecraftTypeHelper.java

示例2: getSlotForUse

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public int getSlotForUse(EntityPlayer player, ItemStack stack) {
	ItemStack stackToUse = player.inventory.getStackInSlot(player.inventory.currentItem + 1);
	if (stackToUse != null && stackToUse.getItem() instanceof ItemBlock
			&& this.allowBlock(stack,
					Block.getBlockFromItem(stackToUse.getItem()).getStateFromMeta(stackToUse.getMetadata()),
					player.world))
		return player.inventory.currentItem + 1;
	else
		for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
			stackToUse = player.inventory.getStackInSlot(i);
			if (stackToUse != null && stackToUse.getItem() instanceof ItemBlock
					&& this.allowBlock(stack,
							Block.getBlockFromItem(stackToUse.getItem()).getStateFromMeta(stackToUse.getMetadata()),
							player.world))
				return i;
		}
	return -1;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:19,代码来源:TNTCannon.java

示例3: BaseLiquid

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public BaseLiquid(String fluidName, Consumer<Fluid> f, int col) {
	super(fluidName, new ResourceLocation(FirmaMod.MODID + ":blocks/water_still"), new ResourceLocation(FirmaMod.MODID + ":blocks/water_flow"));
	this.setUnlocalizedName(FirmaMod.MODID + ":fluid." + fluidName);
	FluidRegistry.registerFluid(this);
	f.accept(this);
	block = new BaseBlockLiquid(this, Material.WATER);
	block.setRegistryName(FirmaMod.MODID + ":fluid." + fluidName);
	block.setUnlocalizedName(FirmaMod.MODID + ":fluid." + fluidName);
	block.setCreativeTab(FirmaMod.blockTab);
	block.setLightOpacity(3);
	block.setLightLevel(0);
	
	GameRegistry.register(block);
	i = new ItemBlock(block);
	i.setRegistryName(FirmaMod.MODID+":fluid."+fluidName);
	i.setUnlocalizedName(FirmaMod.MODID+":fluid."+fluidName);
	GameRegistry.register(i);
	FirmaMod.allFluids.add(this);
	this.col = col;
}
 
开发者ID:trigg,项目名称:Firma,代码行数:21,代码来源:BaseLiquid.java

示例4: registerItemModel

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@Override
public void registerItemModel(Item item) {
    if(item instanceof IItemColored)
        COLOR_ITEMS.add((IItemColored) item);
    if(item instanceof ItemBlock)
    {
        ItemBlock itemBlock = (ItemBlock) item;
        Block block = itemBlock.getBlock();
        ResourceLocation resloc = block.getRegistryName();
        if(block instanceof IBlockVariants) {
            for (IBlockState state : ((IBlockVariants) block).getValidStates()) {
                ModelLoader.setCustomModelResourceLocation(item, block.getMetaFromState(state), new ModelResourceLocation(resloc, ((IBlockVariants) block).getBlockStateName(state)));
            }
        }
        else
            ModelLoader.setCustomModelResourceLocation(item,0,new ModelResourceLocation(resloc, "inventory"));
    }
    else
        ModelLoader.setCustomModelResourceLocation(item,0,new ModelResourceLocation(item.getRegistryName(), "inventory"));

}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:22,代码来源:ClientProxy.java

示例5: GameData

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public GameData()
{
    iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
    iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
    iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
    iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
    iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
    ResourceLocation WATER = new ResourceLocation("water");
    iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
    iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);

    try
    {
        blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
    }
    catch (Exception e)
    {
        FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
        throw Throwables.propagate(e);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:GameData.java

示例6: getBlocksFromString

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static ArrayList<Block> getBlocksFromString(String blockName)
{
	ArrayList<Block> blocks = new ArrayList<>();
	if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName)))
		blocks.add(Block.getBlockFromName(blockName));
	for(ItemStack oreStack : OreDictionary.getOres(blockName))
		if(oreStack.getItem() instanceof ItemBlock)
			blocks.add(((ItemBlock)oreStack.getItem()).getBlock());
	ArrayList<Block> finalBlocks = new ArrayList<>();
	for(Block b : blocks)
	{
		NonNullList<ItemStack> items = NonNullList.create();
		b.getSubBlocks(CreativeTabs.SEARCH, items);
		for(ItemStack stack : items)
			if(!stack.isEmpty())
				finalBlocks.add(Block.getBlockFromItem(stack.getItem()));
			else
				finalBlocks.add(b);
	}
	return finalBlocks;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:22,代码来源:HarshenUtils.java

示例7: register

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static void register() {
	for(Block block : HarshenConfigs.BLOCKS.allComponants)
		if(HarshenConfigs.BLOCKS.isEnabled(block))
		{
			ForgeRegistries.BLOCKS.register(block);
			if(blocksWithItems.contains(block))
			{
				ItemBlock item = block instanceof IMetaItemBlock ? add(block) : new ItemBlock(block);
				item.setRegistryName(block.getRegistryName());
				item.setMaxStackSize(blockStackSize.get(block));
				ForgeRegistries.ITEMS.register(item);
			}
				
		}
			
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenBlocks.java

示例8: renderHand0

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static void renderHand0(EntityRenderer er, float par1, int par2)
{
    if (!Shaders.isShadowPass)
    {
        Item item = Shaders.itemToRender != null ? Shaders.itemToRender.getItem() : null;
        Block block = item instanceof ItemBlock ? ((ItemBlock)item).getBlock() : null;

        if (!(item instanceof ItemBlock) || !(block instanceof Block) || block.getBlockLayer() == EnumWorldBlockLayer.SOLID)
        {
            Shaders.readCenterDepth();
            Shaders.beginHand();
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            er.renderHand(par1, par2);
            Shaders.endHand();
            Shaders.isHandRendered = true;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:ShadersRender.java

示例9: track

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@SubscribeEvent
public void track(PlayerTickEvent event) {
    EntityPlayer player = event.player;
    
    Item heldItem = player.getHeldItemMainhand().getItem();
    if (!(heldItem instanceof ItemBlock)) {
        return;
    }    
    
    IBlockState heldBlockState = Block.getBlockFromItem(heldItem).getDefaultState();
    BlockPos basePos = player.getPosition().add(0, -1, 0);
    IBlockState baseState = player.getEntityWorld().getBlockState(basePos);
    
    if (heldBlockState.equals(baseState)) {
        return;
    }

    player.getEntityWorld().setBlockState(basePos, heldBlockState);
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:20,代码来源:Turtle.java

示例10: initStats

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
private static void initStats()
{
    for (Item item : Item.itemRegistry)
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = func_180204_a(item);

            if (s != null)
            {
                objectUseStats[i] = (new StatCrafting("stat.useItem.", s, new ChatComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();

                if (!(item instanceof ItemBlock))
                {
                    itemStats.add((StatCrafting)objectUseStats[i]);
                }
            }
        }
    }

    replaceAllSimilarBlocks(objectUseStats);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:24,代码来源:StatList.java

示例11: onRegisterItem

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@SubscribeEvent
public void onRegisterItem(RegistryEvent.Register<Item> event)
{
    Clef.itemInstrument = (new ItemInstrument()).setFull3D().setRegistryName("clef", "instrument").setUnlocalizedName("clef.item.instrument");
    event.getRegistry().register(Clef.itemInstrument);

    Clef.creativeTabInstruments = new CreativeTabs("clef") {
        public final ItemStack iconItem = new ItemStack(Clef.itemInstrument);

        @Override
        public ItemStack getTabIconItem()
        {
            return iconItem;
        }
    };
    Clef.itemInstrument.setCreativeTab(Clef.creativeTabInstruments);
    Clef.blockInstrumentPlayer.setCreativeTab(Clef.creativeTabInstruments);

    event.getRegistry().register(new ItemBlock(Clef.blockInstrumentPlayer).setRegistryName(Clef.blockInstrumentPlayer.getRegistryName()));
}
 
开发者ID:iChun,项目名称:Clef,代码行数:21,代码来源:EventHandlerServer.java

示例12: colorMultiplier

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityFlowerPot)
    {
        Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem();

        if (item instanceof ItemBlock)
        {
            return Block.getBlockFromItem(item).colorMultiplier(worldIn, pos, renderPass);
        }
    }

    return 16777215;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:17,代码来源:BlockFlowerPot.java

示例13: getItemBurnTimeElectrical

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static int getItemBurnTimeElectrical(ItemStack itemStack) {
	if(itemStack == null) {
		return 0;
	} else {
		Item item = itemStack.getItem();

		if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {

			@SuppressWarnings("unused")
			Block block = Block.getBlockFromItem(item);

		}
		if(item == TechnicalItem.Battery1)
			return 2560;

		return 0;
	}
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:19,代码来源:TileEntityMachine.java

示例14: placeStair

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
private void placeStair(EnumFacing facing, BlockPos pos, EntityItem entityItem) {
    ItemStack blockStack = entityItem.getItem();
    ItemStack actual = blockStack.splitStack(32);
    numStairs += 32;
    if (blockStack.isEmpty()) {
        entityItem.setDead();
    }
    if (actual.isEmpty()) {
        return;
    }
    Item item = actual.getItem();
    if (!(item instanceof ItemBlock)) {
        // Safety
        return;
    }

    placeStair(facing, pos);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:19,代码来源:DigdownStairsActionWorker.java

示例15: displayAllRelevantItems

import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@Override
public void displayAllRelevantItems(NonNullList<ItemStack> items) {
	for (int i = 0; i < 6; i++) {
		items.add(new ItemStack(ModItems.DANK_NULL, 1, i));
	}
	for (Item item : ModItems.getList()) {
		if (!(item instanceof ItemDankNull) && !(item instanceof ItemDankNullHolder) && !(item instanceof ItemBlock) && !(item instanceof ItemDankNullPanel)) {
			items.add(new ItemStack(item));
		}
	}
	for (int i = 0; i < 6; i++) {
		items.add(new ItemStack(ModItems.DANK_NULL_PANEL, 1, i));
	}
	for (Block block : ModBlocks.getList()) {
		items.add(new ItemStack(block));
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:18,代码来源:ModCreativeTab.java


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