Java 类net.minecraft.item.ItemBlock 实例源码

项目:Mods    文件:TNTCannon.java   
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;
}
项目:Firma    文件:BaseLiquid.java   
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;
}
项目:Soot    文件:ClientProxy.java   
@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"));

}
项目:Proyecto-DASI    文件:MinecraftTypeHelper.java   
/** 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);
}
项目:CustomWorldGen    文件:GameData.java   
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);
    }
}
项目:harshencastle    文件:HarshenUtils.java   
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;
}
项目:harshencastle    文件:HarshenBlocks.java   
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);
            }

        }

}
项目:Proyecto-DASI    文件:MinecraftTypeHelper.java   
/** 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);
}
项目:BaseClient    文件:ShadersRender.java   
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;
        }
    }
}
项目:craftsman    文件:Turtle.java   
@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);
}
项目:DecompiledMinecraft    文件:StatList.java   
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);
}
项目:Clef    文件:EventHandlerServer.java   
@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()));
}
项目:BaseClient    文件:BlockFlowerPot.java   
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;
}
项目:Technical    文件:TileEntityMachine.java   
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;
    }
}
项目:MeeCreeps    文件:DigdownStairsActionWorker.java   
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);
}
项目:DankNull    文件:ModCreativeTab.java   
@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));
    }
}
项目:BetterBeginningsReborn    文件:RegisterModels.java   
@SuppressWarnings("unchecked")
public static <BBBlock extends Block & IBBName, BBItem extends Item & IBBName> void register()
{
    // blocks
    for (Block b : RegisterBlocks.allBlocks)
    {
        registerBlock((BBBlock)b);
    }

    // items
    for (Item i : RegisterItems.allItems)
    {
        //Skip ItemBlocks as their models are registered during the block model registration
        if(i instanceof ItemBlock && RegisterBlocks.allBlocks.contains(Block.getBlockFromItem(i))) continue;
        registerItem((BBItem)i);
    }
}
项目:Randores2    文件:RandoresForgeUpgradeRecipe.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    double speed = 0;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) {
            speed += stack.getSubCompound("randores").getInteger("furnace_speed");
        } else {
            speed += this.upgrades.entrySet().stream().filter(e -> e.getKey().apply(stack)).map(Entry::getValue).findFirst().orElse(0d);
        }
    }

    int intSpeed = (int) speed;
    if(intSpeed > this.clamp) {
        intSpeed = this.clamp;
    }

    ItemStack res = new ItemStack(CraftingBlocks.forgeItem);
    res.getOrCreateSubCompound("randores").setInteger("furnace_speed", intSpeed);
    return res;
}
项目:Never-Enough-Currency    文件:ItemHandler.java   
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
    registry = event.getRegistry();

    wallet = register(new ItemWallet("wallet"));
    linkingCard = register(new ItemLinkingCard("linking_card"));

    penny = register(new ItemMoneyBase("penny", 0.01F));
    nickel = register(new ItemMoneyBase("nickel", 0.05F));
    dime = register(new ItemMoneyBase("dime", 0.10F));
    quarter = register(new ItemMoneyBase("quarter", 0.25F));

    dollarBill = register(new ItemMoneyBase("dollar_bill", 1F));
    fiveDollarBill = register(new ItemMoneyBase("five_dollar_bill", 5F));
    tenDollarBill = register(new ItemMoneyBase("ten_dollar_bill", 10F));
    twentyDollarBill = register(new ItemMoneyBase("twenty_dollar_bill", 20F));
    fiftyDollarBill = register(new ItemMoneyBase("fifty_dollar_bill", 50F));
    hundredDollarBill = register(new ItemMoneyBase("hundred_dollar_bill", 100F));

    for (ItemBlock ib : itemBlocks) {
        registry.register(ib);
        if (ib.getBlock() instanceof BlockBasic) {
            ((BlockBasic) ib.getBlock()).registerItemModel(ib);
        }
    }
}
项目:FoodCraft-Reloaded    文件:BlockLoader.java   
@Load
public void registerBlocks() {
    for (Field field : FCRBlocks.class.getFields()) {
        field.setAccessible(true);
        RegBlock anno = field.getAnnotation(RegBlock.class);
        if (anno==null) continue;

        try {
            Block block = (Block) field.get(null);
            ForgeRegistries.BLOCKS.register(block.setRegistryName(NameBuilder.buildRegistryName(anno.value())).setUnlocalizedName(NameBuilder.buildUnlocalizedName(anno.value())));

            //Register item block.
            Class<? extends ItemBlock> itemClass = anno.itemClass();
            Constructor<? extends ItemBlock> con = itemClass.getConstructor(Block.class);
            con.setAccessible(true);
            ForgeRegistries.ITEMS.register(con.newInstance(block).setRegistryName(block.getRegistryName()).setUnlocalizedName(block.getUnlocalizedName()));

            Arrays.asList(anno.oreDict()).forEach(s -> OreDictionary.registerOre(s, block));
        } catch (Exception e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register block " + field.toGenericString(), e);
        }
    }
}
项目:DecompiledMinecraft    文件:StatList.java   
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);
}
项目:rezolve    文件:RezolveMod.java   
public void registerItemBlock(BlockBase block) {
    this.registerBlock(block);

    ItemBlock item = new ItemBlock(block);
    item.setRegistryName(block.getRegistryName());
    GameRegistry.register(item);

    block.itemBlock = item;
}
项目:ThermionicsWorld    文件:BlockVarieties.java   
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
    if (tab!=this.getCreativeTabToDisplayOn()) return;

    for (int i=0; i<16; i++) {
        list.add(new ItemStack(ItemBlock.getItemFromBlock(this), 1, i));
    }
}
项目:Solar    文件:RenderHelper.java   
public static void renderItemStack(ItemStack stack) {
    //Fix stack 'y' center
    if(stack.getItem() instanceof ItemBlock) {
        GlStateManager.translate(0F, -0.1F, 0F);
    }
    RenderItem render = Minecraft.getMinecraft().getRenderItem();
    GlStateManager.pushAttrib();
    net.minecraft.client.renderer.RenderHelper.enableStandardItemLighting();
    render.renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
    net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
    GlStateManager.popAttrib();
}
项目:FoodCraft-Reloaded    文件:ItemVegetableCake.java   
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(vegetableType.toString(), "cake")));

    if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1)
        facing = EnumFacing.UP;
    else if (!block.isReplaceable(worldIn, pos))
        pos = pos.offset(facing);

    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) {
        IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand);

        if (!worldIn.setBlockState(pos, blockState, 11))
            return EnumActionResult.FAIL;
        else {
            blockState = worldIn.getBlockState(pos);

            if (blockState.getBlock() == cake) {
                ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack);
                blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack);
            }

            SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player);
            worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.shrink(1);
            return EnumActionResult.SUCCESS;
        }
    }
    else
        return EnumActionResult.FAIL;
}
项目:pnc-repressurized    文件:DroneAIPlace.java   
@Override
protected boolean doBlockInteraction(BlockPos pos, double distToBlock) {
    if (drone.getPathNavigator().hasNoPath()) {
        EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
        for (int i = 0; i < drone.getInv().getSlots(); i++) {
            ItemStack droneStack = drone.getInv().getStackInSlot(i);
            if (droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).getBlock().canPlaceBlockOnSide(drone.world(), pos, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()))) {
                if (widget.isItemValidForFilters(droneStack)) {
                    ItemBlock itemBlock = (ItemBlock) droneStack.getItem();
                    Block block = itemBlock.getBlock();
                    if (drone.world().mayPlace(block, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
                        int newMeta = itemBlock.getMetadata(droneStack.getMetadata());
                        setFakePlayerAccordingToDir();
                        IBlockState iblockstate1 = block.getStateForPlacement(drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), newMeta, drone.getFakePlayer(), EnumHand.MAIN_HAND);
                        if (itemBlock.placeBlockAt(droneStack, drone.getFakePlayer(), drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), iblockstate1)) {
                            drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
                            SoundType soundType = block.getSoundType(iblockstate1, drone.world(), pos, drone.getFakePlayer());
                            drone.world().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false);
                            droneStack.shrink(1);
                            if (droneStack.getCount() <= 0) {
                                drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
                            }
                        }
                        return false;
                    }
                }
            }
        }
        return false;
    } else {
        return true;
    }
}
项目:Mods    文件:TileEntityAmmoFurnace.java   
/**
 * 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);
    }
}
项目:pnc-repressurized    文件:Itemss.java   
public static void registerItem(IForgeRegistry<Item> registry, Item item) {
    registry.register(item);
    ThirdPartyManager.instance().onItemRegistry(item);
    if (item instanceof ItemBlock) {
        all_itemblocks.add((ItemBlock) item);
    } else {
        items.add(item);
    }
}
项目:uniquecrops    文件:BlockOldGrass.java   
public BlockOldGrass() {

    setRegistryName("oldgrass");
    setUnlocalizedName(UniqueCrops.MOD_ID + ".oldgrass");
    setCreativeTab(UniqueCrops.TAB);
    setSoundType(SoundType.PLANT);
    setHardness(0.6F);
    setTickRandomly(true);
    GameRegistry.register(this);
    GameRegistry.register(new ItemBlock(this), getRegistryName());
}
项目:HeroUtils    文件:DriverSidedBlock.java   
protected boolean worksWith(final Block referenceBlock, final int referenceMetadata) {
    for (ItemStack stack : blocks) {
        if (stack != null && stack.getItem() instanceof ItemBlock) {
            final ItemBlock item = (ItemBlock) stack.getItem();
            final Block supportedBlock = item.getBlock();
            final int supportedMetadata = item.getMetadata(stack.getItemDamage());
            if (referenceBlock == supportedBlock && (referenceMetadata == supportedMetadata || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
                return true;
            }
        }
    }
    return false;
}
项目:uniquecrops    文件:BlockDarkBlock.java   
public BlockDarkBlock() {

    super("darkblock", Material.ROCK);
    setSoundType(SoundType.STONE);
    setHardness(10.0F);
    setResistance(6000000.0F);
    EntityEnderman.setCarriable(this, true);
    GameRegistry.register(new ItemBlock(this), getRegistryName());
}
项目:rtap    文件:ModBlocks.java   
private static void registerBlock(Block block) {

    GameRegistry.register(block);
    ItemBlock item = new ItemBlock(block);
    item.setRegistryName(block.getRegistryName());
    GameRegistry.register(item);

}
项目:MobBlocker    文件:BlockChunkProtector.java   
/**
 * Constructor for the BlockChunkProtector class
 *
 * This method handles initializing the block and adding it to the GameRegistry.
 * This contructor is only called once per game launch.
 */
public BlockChunkProtector() {
    super(Material.ROCK);
    setUnlocalizedName(MobBlocker.MODID + ".chunkprotector");
    setRegistryName("chunkprotector");

    // If the Chunk Protector is configured to never decay, block is breakable so that it won't cause clutter.
    // Otherwise, it is unbreakable, because it shouldn't last in the world for all that long, and I can't figure out how to get it to drop with metadata intact.
    if (Config.ticksToLive != -1) setBlockUnbreakable();
    else {
        setHardness(1.5F);
        setResistance(18000000);
    }

    // Register block to GameRegistry
    GameRegistry.register(this);

    // Create anonymous class for the item form of this block
    // This allows the addition of custom tooltips that show how long the block will last in world once placed.
    GameRegistry.register(new ItemBlock(this) {
        @Override
        public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
            // Only add tooltips if decay is enabled
            if (Config.ticksToLive != -1) {
                BlockChunkProtector.addStringToTooltip("&5Good for: &4" + Config.ticksToLive + " &5ticks", list);
            }
            else {
                return;
            }
        }
    }.setRegistryName(this.getRegistryName()));
    // Registers TileEntity associated with this block
    GameRegistry.registerTileEntity(TileEntityChunkProtector.class, MobBlocker.MODID + "_chunkprotector");
}
项目:uniquecrops    文件:BlockOldGravel.java   
public BlockOldGravel() {

    setRegistryName("oldgravel");
    setUnlocalizedName(UniqueCrops.MOD_ID + ".oldgravel");
    setCreativeTab(UniqueCrops.TAB);
    setHardness(0.6F);
    setSoundType(SoundType.GROUND);
    GameRegistry.register(this);
    GameRegistry.register(new ItemBlock(this), getRegistryName());
}
项目:SimplyTea    文件:SimplyTea.java   
public BlockTeaSapling(String name, boolean addToTab) {
    super();
    this.setSoundType(SoundType.PLANT);
    setUnlocalizedName(name);
    setRegistryName(SimplyTea.MODID+":"+name);
    if (addToTab){
        setCreativeTab(SimplyTea.tab);
    }
       this.setTickRandomly(true);
       itemBlock = (new ItemBlock(this).setRegistryName(this.getRegistryName()));
}
项目:SimplyTea    文件:SimplyTea.java   
public BlockTeaTrunk(String name, boolean addToTab) {
super(Material.WOOD);
this.setSoundType(SoundType.WOOD);
setHarvestLevel("axe",-1);
setHardness(1.8f);
setUnlocalizedName(name);
setRegistryName(SimplyTea.MODID+":"+name);
if (addToTab){
    setCreativeTab(SimplyTea.tab);
}
this.setTickRandomly(true);
      itemBlock = (new ItemBlock(this).setRegistryName(this.getRegistryName()));
  }
项目:Machines-and-Stuff    文件:MBlocks.java   
private static void registerBlock(Block block, String key, String texture, Class tile, CreativeTabs tab) {
    block.setUnlocalizedName(key).setCreativeTab(TAB);
    if(DEVENV && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
        writeFile(key, texture);
    renderMap.put(texture, block);
    GameRegistry.register(block, new ResourceLocation(Reference.MODID + ":" + key));
    GameRegistry.register(new ItemBlock(block), new ResourceLocation(Reference.MODID + ":" + key));
    if(tile != null) {
        GameRegistry.registerTileEntity(tile, key);
    }
}
项目:Backmemed    文件:Shaders.java   
private static boolean isTranslucentBlock(ItemStack stack)
{
    if (stack == null)
    {
        return false;
    }
    else
    {
        Item item = stack.getItem();

        if (item == null)
        {
            return false;
        }
        else if (!(item instanceof ItemBlock))
        {
            return false;
        }
        else
        {
            ItemBlock itemblock = (ItemBlock)item;
            Block block = itemblock.getBlock();

            if (block == null)
            {
                return false;
            }
            else
            {
                BlockRenderLayer blockrenderlayer = block.getBlockLayer();
                return blockrenderlayer == BlockRenderLayer.TRANSLUCENT;
            }
        }
    }
}
项目:CustomWorldGen    文件:GameRegistry.java   
/**
 * Use {@link #register(IForgeRegistryEntry)} instead
 */
@Deprecated
public static Block registerBlock(Block block)
{
    register(block);
    register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    return block;
}
项目:ChatBomb    文件:ModBlocks.java   
private static void registerBlock(Block block, String registryName, ItemBlock itemBlock, boolean inCreativeTab) {
    // Set the registry name.
    block.setRegistryName(Reference.MOD_ID, registryName);
    block.setUnlocalizedName(Reference.MOD_ID + "." + registryName);
    // Add to the game registry.
    GameRegistry.register(block);
    GameRegistry.register(itemBlock, block.getRegistryName());

    if (inCreativeTab)
        block.setCreativeTab(ChatBomb.creativeTab);

    System.out.println("Registered block ~ "+block.getRegistryName());

}