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


Java Block.getBlockFromItem方法代码示例

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


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

示例1: onBlockActivated

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack stack = player.getHeldItem(hand);
	boolean isBlock = stack.getItem() instanceof ItemBlock && stack.getItem() != ModItems.ANGSTROM;
	if(!world.isRemote && isBlock) {
		//Replace
		ItemBlock item = (ItemBlock) stack.getItem();
		Block block = Block.getBlockFromItem(item);
		int meta = item.getMetadata(stack);
		IBlockState inState = block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, player, hand);
		world.setBlockState(pos, inState);
		block.onBlockPlacedBy(world, pos, inState, player, stack);
		SoundType sound = block.getSoundType(inState, world, pos, player);
		world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), sound.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
		//Exchange
		ItemStack drop = new ItemStack(Item.getItemFromBlock(this));
		ItemHandlerHelper.giveItemToPlayer(player, drop);
		if(!player.capabilities.isCreativeMode) {
			stack.shrink(1);
		}
	}
	return isBlock;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:24,代码来源:BlockAngstrom.java

示例2: renderItem

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	
	RenderBlocks renderblocks = (RenderBlocks) data[0];
	Block block = Block.getBlockFromItem(item.getItem());
	if (item.hasTagCompound()) {
		NBTTagCompound tag = item.stackTagCompound;
		if (tag.hasKey("Fluid")) {
			FluidStack liquid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("Fluid"));
			if (liquid != null) {
				GL11.glEnable(GL11.GL_BLEND);
				float height = ((float) liquid.amount / (float) 8000 * (float) 0.99);
				renderblocks.setRenderBounds(0.01, 0.01, 0.01, 0.99, height, 0.99);
				Utils.renderInventoryBlock(renderblocks, GrandFluidTank.renderblocks, liquid.getFluid());
				GL11.glDisable(GL11.GL_BLEND);
			}
		}

		GL11.glEnable(GL11.GL_ALPHA_TEST);
		renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1);
		Utils.renderInventoryBlock(renderblocks, block, GrandFluidTank.glassfluidtank.getIcon(0, 0));
		GL11.glDisable(GL11.GL_ALPHA_TEST);

	}
}
 
开发者ID:grand-mine-inc,项目名称:Steam-and-Steel,代码行数:26,代码来源:RenderItemBlockGlassTank.java

示例3: doVoidFogParticles

import net.minecraft.block.Block; //导入方法依赖的package包/类
public void doVoidFogParticles(int posX, int posY, int posZ)
{
    int i = 32;
    Random random = new Random();
    ItemStack itemstack = this.mc.player.getHeldItemMainhand();

    if (itemstack == null || Block.getBlockFromItem(itemstack.getItem()) != Blocks.BARRIER)
    {
        itemstack = this.mc.player.getHeldItemOffhand();
    }

    boolean flag = this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && !itemstack.func_190926_b() && itemstack.getItem() == Item.getItemFromBlock(Blocks.BARRIER);
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int j = 0; j < 667; ++j)
    {
        this.showBarrierParticles(posX, posY, posZ, 16, random, flag, blockpos$mutableblockpos);
        this.showBarrierParticles(posX, posY, posZ, 32, random, flag, blockpos$mutableblockpos);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:WorldClient.java

示例4: getItemBurnTime

import net.minecraft.block.Block; //导入方法依赖的package包/类
public static int getItemBurnTime (@Nonnull ItemStack stack) {
    if (stack.isEmpty())
        return 0;

    Item item = stack.getItem();

    if (item instanceof ItemBlock) {
        Block block = Block.getBlockFromItem(item);
        if (block == ModBlocks.stoneMaterial && BlockStoneMaterial.StoneType.byMetadata(stack.getItemDamage()) == BlockStoneMaterial.StoneType.CHARCOAL_BLOCK)
            return ModBlocks.stoneMaterial.getBurnTime(stack);
    }

    if (item == Items.COAL && stack.getItemDamage() == 1)
        return 1600;

    return 0;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:18,代码来源:TileBloomeryFurnace.java

示例5: getItemBurnTimeElectrical

import net.minecraft.block.Block; //导入方法依赖的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

示例6: onBlockActivated

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,	EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	ItemStack itm = playerIn.getHeldItemMainhand();
	if (!itm.isEmpty() && itm.getItem() instanceof ItemBlock && Block.getBlockFromItem(itm.getItem()) == this && state.getValue(LAYERS) < 8)
	{
		if (!playerIn.capabilities.isCreativeMode)
		{
			itm.shrink(1);
		}
		
		worldIn.setBlockState(pos, state.cycleProperty(LAYERS));
		return true;
	}
	
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:18,代码来源:BlockSnow.java

示例7: keyTyped

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
	if(keyCode == Keyboard.KEY_TAB)
	{			this.textInput.setMaxStringLength(60);
	
		ArrayList<String> stringList = new ArrayList<>();
		if(dictonaryList.isEmpty())
		{
			stringList.addAll(CommandBase.getListOfStringsMatchingLastWord(HarshenUtils.listOf(this.textInput.getText()), Block.REGISTRY.getKeys()));
			for(String s : HarshenUtils.getAllOreDictionaryList())
				for(ItemStack stack : OreDictionary.getOres(s))
					if(Block.getBlockFromItem(stack.getItem()) != Blocks.AIR)
						stringList.add(s);
			dictonaryList = CommandBase.getListOfStringsMatchingLastWord(HarshenUtils.listOf(this.textInput.getText()), stringList);
		}
		if(!dictonaryList.isEmpty())
			this.textInput.setText(dictonaryList.get(timeOver++%dictonaryList.size()));
	}
	else
	{
		timeOver = 0;
		dictonaryList.clear();
	}
	
	if(keyCode == Keyboard.KEY_RETURN)
		closeGui();
	this.textInput.textboxKeyTyped(typedChar, keyCode);
	super.keyTyped(typedChar, keyCode);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:30,代码来源:GuiXrayPendantScreen.java

示例8: getAustraliumCount

import net.minecraft.block.Block; //导入方法依赖的package包/类
public static int getAustraliumCount(EntityPlayer player){
	int count=0;
	for(int i=0;i<player.inventory.getSizeInventory();i++){
		ItemStack stack=player.inventory.getStackInSlot(i);
		if(!stack.isEmpty()){
			if(stack.getItem()==TF2weapons.itemTF2 && stack.getItemDamage()==6)
				count++;
			else if(stack.getItem()==TF2weapons.itemTF2 && stack.getItemDamage()==2)
				count+=9;
			else if(Block.getBlockFromItem(stack.getItem())==TF2weapons.blockAustralium)
				count+=81;
		}
	}
	return count;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:16,代码来源:ContainerRecover.java

示例9: getBurnTime

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public int getBurnTime (@Nonnull ItemStack fuel) {
    if (!fuel.isEmpty() && Block.getBlockFromItem(fuel.getItem()) == this && StoneType.byMetadata(fuel.getItemDamage()) == StoneType.CHARCOAL_BLOCK)
        return 16000;

    return 0;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:8,代码来源:BlockStoneMaterial.java

示例10: matches

import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean matches(InventoryCrafting inv, World worldIn)
{
    int i = 0;
    int j = 0;

    for (int k = 0; k < inv.getSizeInventory(); ++k)
    {
        ItemStack itemstack = inv.getStackInSlot(k);

        if (!itemstack.func_190926_b())
        {
            if (Block.getBlockFromItem(itemstack.getItem()) instanceof BlockShulkerBox)
            {
                ++i;
            }
            else
            {
                if (itemstack.getItem() != Items.DYE)
                {
                    return false;
                }

                ++j;
            }

            if (j > 1 || i > 1)
            {
                return false;
            }
        }
    }

    return i == 1 && j == 1;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:35,代码来源:ShulkerBoxRecipes.java

示例11: renderItem

import net.minecraft.block.Block; //导入方法依赖的package包/类
public void renderItem(EntityLivingBase entityIn, ItemStack heldStack, ItemCameraTransforms.TransformType transform)
{
    if (heldStack != null)
    {
        Item item = heldStack.getItem();
        Block block = Block.getBlockFromItem(item);
        GlStateManager.pushMatrix();

        if (this.itemRenderer.shouldRenderItemIn3D(heldStack))
        {
            GlStateManager.scale(2.0F, 2.0F, 2.0F);

            if (this.isBlockTranslucent(block))
            {
                GlStateManager.depthMask(false);
            }
        }

        this.itemRenderer.renderItemModelForEntity(heldStack, entityIn, transform);

        if (this.isBlockTranslucent(block))
        {
            GlStateManager.depthMask(true);
        }

        GlStateManager.popMatrix();
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:29,代码来源:ItemRenderer.java

示例12: getItemBurnTime

import net.minecraft.block.Block; //导入方法依赖的package包/类
/**
 * Returns the number of ticks that the supplied fuel item will keep the
 * furnace burning, or 0 if the item isn't fuel
 */
public static int getItemBurnTime(ItemStack stack) {
	if (stack.isEmpty())
		return 0;
	else {
		Item item = stack.getItem();

		if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) {
			Block block = Block.getBlockFromItem(item);

			if (block == Blocks.WOODEN_SLAB)
				return 150;

			if (block.getDefaultState().getMaterial() == Material.WOOD)
				return 300;

			if (block == Blocks.COAL_BLOCK)
				return 16000;
		}

		if (item instanceof ItemTool && "WOOD".equals(((ItemTool) item).getToolMaterialName()))
			return 200;
		if (item instanceof ItemSword && "WOOD".equals(((ItemSword) item).getToolMaterialName()))
			return 200;
		if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe) item).getMaterialName()))
			return 200;
		if (item == Items.STICK)
			return 100;
		if (item == Items.COAL)
			return 1600;
		if (item == Items.LAVA_BUCKET)
			return 20000;
		if (item == Item.getItemFromBlock(Blocks.SAPLING))
			return 100;
		if (item == Items.BLAZE_ROD)
			return 2400;
		return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(stack);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:43,代码来源:TileEntityAmmoFurnace.java

示例13: placeMobSpawner

import net.minecraft.block.Block; //导入方法依赖的package包/类
@SubscribeEvent
public void placeMobSpawner(BlockEvent.PlaceEvent event) {
	
	if (event.getState().getBlock() != Blocks.MOB_SPAWNER) return;
	
	ItemStack spawner = event.getItemInHand();
	if (spawner.hasTagCompound() && spawner.getTagCompound().hasKey("Spawner") && Block.getBlockFromItem(spawner.getItem()) == Blocks.MOB_SPAWNER) {
		TileEntity tile = TileEntity.func_190200_a(event.getWorld(), spawner.getTagCompound().getCompoundTag("Spawner"));
		event.getWorld().setTileEntity(event.getPos(), tile);
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:12,代码来源:UCEventHandlerServer.java

示例14: onPlayerItemCrafted

import net.minecraft.block.Block; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerItemCrafted(ItemCraftedEvent event) {
	if(Block.getBlockFromItem(event.crafting.getItem()) instanceof BlockPhotoProcessor &&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftprocessor)){
		event.player.addStat(AchievementLoader.craftprocessor);
	}
	if(Block.getBlockFromItem(event.crafting.getItem()) instanceof BlockPictureFrame &&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftpictureframe)){
		event.player.addStat(AchievementLoader.craftpictureframe);
	}
	if(Block.getBlockFromItem(event.crafting.getItem()) instanceof BlockPictureFrameMultiple &&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftpictureframe_multiple)){
		event.player.addStat(AchievementLoader.craftpictureframe_multiple);
	}
	if(event.crafting.getItem() instanceof ItemPhotoPaper&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftphoto_paper)){
		event.player.addStat(AchievementLoader.craftphoto_paper);
	}
	if(event.crafting.getItem() instanceof ItemGlassesHelmet&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftglasses)){
		event.player.addStat(AchievementLoader.craftglasses);
	}
	if(event.crafting.getItem() instanceof ItemFilm&&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftfilm)){
		event.player.addStat(AchievementLoader.craftfilm);
	}
	if(event.crafting.getItem() instanceof ItemTripod&&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.crafttripod)){
		event.player.addStat(AchievementLoader.crafttripod);
	}
	if(event.crafting.getItem() instanceof ItemPictureBook&&!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftpicture_book)){
		event.player.addStat(AchievementLoader.craftpicture_book);
	}
	if (event.crafting.getItem() instanceof ItemCamera) {
		if(!event.player.getEntityWorld().isRemote&&!event.player.hasAchievement(AchievementLoader.craftcamera)){
			System.out.println("has no stat");
			event.player.addStat(AchievementLoader.craftcamera);
		}
		for (int i = 0; i < 9; i++) {
			if (event.craftMatrix.getStackInSlot(i) != null
					&& event.craftMatrix.getStackInSlot(i).getItem() instanceof ItemTripod) {
				if (!event.player.inventory.addItemStackToInventory(new ItemStack(ItemLoader.itemCamera))) {
					if (!event.player.getEntityWorld().isRemote) {
						Block.spawnAsEntity(event.player.getEntityWorld(), event.player.getPosition(),
								new ItemStack(ItemLoader.itemCamera));
					}
				}
				if (!event.player.inventory.addItemStackToInventory(new ItemStack(Blocks.IRON_BLOCK, 3))) {
					if (!event.player.getEntityWorld().isRemote) {
						Block.spawnAsEntity(event.player.getEntityWorld(), event.player.getPosition(),
								new ItemStack(Blocks.IRON_BLOCK, 3));
					}
				}
				if (!event.player.inventory.addItemStackToInventory(new ItemStack(Items.ENDER_EYE))) {
					if (!event.player.getEntityWorld().isRemote) {
						Block.spawnAsEntity(event.player.getEntityWorld(), event.player.getPosition(),
								new ItemStack(Items.ENDER_EYE));
					}
				}
				break;
			}
		}
	}
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:58,代码来源:EventLoader.java

示例15: getHeldBlockMainhand

import net.minecraft.block.Block; //导入方法依赖的package包/类
public Block getHeldBlockMainhand() {
    Item heldItem = player.getHeldItemMainhand().getItem();
    return Block.getBlockFromItem(heldItem);
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:5,代码来源:FstPlayer.java


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