Java Code Examples for net.minecraft.item.ItemBlock
The following examples show how to use
net.minecraft.item.ItemBlock. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Sakura_mod Source File: BlockKitunebi.java License: MIT License | 6 votes |
private void setVisibleFlg(World world, BlockPos pos,IBlockState state) { world.setBlockState(pos, state.withProperty(ISVISIBLE, false)); EntityPlayer player = world.getClosestPlayer(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, 5.0D, false); if(player ==null){ world.setBlockState(pos, state.withProperty(ISVISIBLE, false)); return; } ItemStack is = player.getHeldItemMainhand(); ItemStack offis =player.getHeldItemOffhand(); if (!is.isEmpty()||!offis.isEmpty()) { Item mainItem = is.getItem(),offItem=offis.getItem(); if (mainItem instanceof ItemBlock||offItem instanceof ItemBlock) { if (Block.getBlockFromItem(mainItem) == this||Block.getBlockFromItem(offItem) == this) { world.setBlockState(pos, state.withProperty(ISVISIBLE, true)); } } } }
Example 2
Source Project: enderutilities Source File: BlockDrawbridge.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public ItemBlock createItemBlock() { ItemBlockPlacementProperty item = new ItemBlockPlacementProperty(this); String[] names = new String[] { "extend", "retract", "toggle" }; item.addPlacementProperty(0, "drawbridge.delay", Constants.NBT.TAG_BYTE, 1, 255); item.addPlacementProperty(0, "drawbridge.length", Constants.NBT.TAG_BYTE, 1, TileEntityDrawbridge.MAX_LENGTH_NORMAL); item.addPlacementProperty(0, "drawbridge.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2); item.addPlacementPropertyValueNames(0, "drawbridge.redstone_mode", names); item.addPlacementProperty(1, "drawbridge.delay", Constants.NBT.TAG_BYTE, 1, 255); item.addPlacementProperty(1, "drawbridge.length", Constants.NBT.TAG_BYTE, 1, TileEntityDrawbridge.MAX_LENGTH_ADVANCED); item.addPlacementProperty(1, "drawbridge.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2); item.addPlacementPropertyValueNames(1, "drawbridge.redstone_mode", names); return item; }
Example 3
Source Project: AdvancedMod Source File: TileEntityTreeFarm.java License: GNU General Public License v3.0 | 6 votes |
private void placeSapling(){ if(worldObj.isAirBlock(xCoord, yCoord + 2, zCoord)) { if(inventory != null) { for(int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); if(stack != null && stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock)stack.getItem()).field_150939_a; if(block == Blocks.sapling) { worldObj.setBlock(xCoord, yCoord + 2, zCoord, block, stack.getItemDamage(), 3); inventory.decrStackSize(i, 1); } } } } } }
Example 4
Source Project: LiquidBounce Source File: Scaffold.java License: GNU General Public License v3.0 | 6 votes |
/** * @return hotbar blocks amount */ private int getBlocksAmount() { int amount = 0; for (int i = 36; i < 45; i++) { final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack(); if (itemStack != null && itemStack.getItem() instanceof ItemBlock) { final Block block = ((ItemBlock) itemStack.getItem()).getBlock(); if (mc.thePlayer.getHeldItem() == itemStack || !InventoryUtils.BLOCK_BLACKLIST.contains(block)) amount += itemStack.stackSize; } } return amount; }
Example 5
Source Project: PneumaticCraft Source File: ModelPneumaticDoorBase.java License: GNU General Public License v3.0 | 6 votes |
@Override public void renderDynamic(float size, TileEntity tile, float partialTicks){ if(tile instanceof TileEntityPneumaticDoorBase) { TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase)tile; ItemStack camoStack = door.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT); boolean renderBase = true; if(camoStack != null && camoStack.getItem() instanceof ItemBlock) { Block block = Block.getBlockFromItem(camoStack.getItem()); renderBase = !PneumaticCraftUtils.isRenderIDCamo(block.getRenderType()); } PneumaticCraftUtils.rotateMatrixByMetadata(door.orientation.ordinal()); renderModel(size, door.oldProgress + (door.progress - door.oldProgress) * partialTicks, renderBase, ((TileEntityPneumaticDoorBase)tile).rightGoing); } else { renderModel(size, 1, true, false); } }
Example 6
Source Project: Wizardry Source File: ModuleInstance.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Gets all of the itemstacks in the player's inventory that match a given itemstack */ public final List<ItemStack> getAllOfStackFromInventory(@Nonnull EntityPlayer player, @Nonnull ItemStack search) { List<ItemStack> stacks = new ArrayList<>(); if (search.isEmpty()) return stacks; for (ItemStack stack : player.inventory.mainInventory) { if (stack == null || stack.isEmpty()) continue; if (!(stack.getItem() instanceof ItemBlock)) continue; if (!ItemStack.areItemsEqual(stack, search)) continue; stacks.add(stack); } return stacks; }
Example 7
Source Project: Cyberware Source File: BlockBlueprintArchive.java License: MIT License | 6 votes |
public BlockBlueprintArchive() { super(Material.IRON); setHardness(5.0F); setResistance(10.0F); setSoundType(SoundType.METAL); String name = "blueprintArchive"; this.setRegistryName(name); GameRegistry.register(this); ItemBlock ib = new ItemBlockCyberware(this, "cyberware.tooltip.blueprintArchive"); ib.setRegistryName(name); GameRegistry.register(ib); this.setUnlocalizedName(Cyberware.MODID + "." + name); this.setCreativeTab(Cyberware.creativeTab); GameRegistry.registerTileEntity(TileEntityBlueprintArchive.class, Cyberware.MODID + ":" + name); CyberwareContent.blocks.add(this); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); }
Example 8
Source Project: Cyberware Source File: BlockBeacon.java License: MIT License | 6 votes |
public BlockBeacon() { super(Material.IRON); setHardness(5.0F); setResistance(10.0F); setSoundType(SoundType.METAL); String name = "beacon"; this.setRegistryName(name); GameRegistry.register(this); ItemBlock ib = new ItemBlockCyberware(this, "cyberware.tooltip.beacon"); ib.setRegistryName(name); GameRegistry.register(ib); this.setUnlocalizedName(Cyberware.MODID + "." + name); this.setCreativeTab(Cyberware.creativeTab); GameRegistry.registerTileEntity(TileEntityBeacon.class, Cyberware.MODID + ":" + name); CyberwareContent.blocks.add(this); }
Example 9
Source Project: Cyberware Source File: BlockSurgery.java License: MIT License | 6 votes |
public BlockSurgery() { super(Material.IRON); setHardness(5.0F); setResistance(10.0F); setSoundType(SoundType.METAL); String name = "surgery"; this.setRegistryName(name); GameRegistry.register(this); ItemBlock ib = new ItemBlockCyberware(this); ib.setRegistryName(name); GameRegistry.register(ib); this.setUnlocalizedName(Cyberware.MODID + "." + name); this.setCreativeTab(Cyberware.creativeTab); GameRegistry.registerTileEntity(TileEntitySurgery.class, Cyberware.MODID + ":" + name); CyberwareContent.blocks.add(this); }
Example 10
Source Project: Cyberware Source File: BlockCharger.java License: MIT License | 6 votes |
public BlockCharger() { super(Material.IRON); setHardness(5.0F); setResistance(10.0F); setSoundType(SoundType.METAL); String name = "charger"; this.setRegistryName(name); GameRegistry.register(this); ItemBlock ib = new ItemBlockCyberware(this); ib.setRegistryName(name); GameRegistry.register(ib); this.setUnlocalizedName(Cyberware.MODID + "." + name); this.setCreativeTab(Cyberware.creativeTab); GameRegistry.registerTileEntity(TileEntityCharger.class, Cyberware.MODID + ":" + name); CyberwareContent.blocks.add(this); }
Example 11
Source Project: Valkyrien-Skies Source File: WorldEventsCommon.java License: Apache License 2.0 | 6 votes |
@SubscribeEvent public void onAttachCapabilityEventItem(AttachCapabilitiesEvent event) { if (event.getObject() instanceof ItemStack) { ItemStack stack = (ItemStack) event.getObject(); Item item = stack.getItem(); if (item instanceof ItemValkyriumCrystal) { event.addCapability( new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"), new AntiGravityCapabilityProvider(VSConfig.valkyriumCrystalForce)); } if (stack.getItem() instanceof ItemBlock) { ItemBlock blockItem = (ItemBlock) stack.getItem(); if (blockItem.getBlock() instanceof BlockValkyriumOre) { event.addCapability( new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"), new AntiGravityCapabilityProvider(VSConfig.valkyriumOreForce)); } } } }
Example 12
Source Project: TFC2 Source File: BlockTerra.java License: GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list) { if(showInCreative) { if(hasMeta()) { if(itemIn instanceof ItemBlock && ((ItemBlock)itemIn).block instanceof INeedOffset) { for(int l = 0; l < META_PROP.getAllowedValues().size(); l++) list.add(new ItemStack(itemIn, 1, ((INeedOffset)(((ItemBlock)itemIn).block)).convertMetaToItem(l))); } else { for(int l = 0; l < META_PROP.getAllowedValues().size(); l++) list.add(new ItemStack(itemIn, 1, l)); } } else super.getSubBlocks(itemIn, tab, list); } }
Example 13
Source Project: malmo Source File: MinecraftTypeHelper.java License: MIT License | 6 votes |
/** 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 : bs.getProperties().keySet()) { Comparable<?> comp = bs.getValue(prop); Variation var = attemptToGetAsVariant(comp.toString()); if (var != null) return var; } return null; } else return attemptToGetAsVariant(part); }
Example 14
Source Project: Logistics-Pipes-2 Source File: BlockRegistry.java License: MIT License | 6 votes |
/** * Registers all registered Blocks on Startup. * Call this in preInit on the Common Proxy */ public static void init() { //init Blocks registry.add(new BlockOreRutile()); for(LPBlockBase block : registry) { //Register Block GameRegistry.register(block); //Register Item of Block GameRegistry.register(new ItemBlock(block), block.getRegistryName()); //Register Ores if(!StringUtil.isNullOrWhitespace(block.getOreName()) && !StringUtil.isNullOrEmpty(block.getOreName())) OreDictionary.registerOre(block.getOreName(), block); if(block instanceof BlockOreRutile) { addConfiguredWorldgen(block.getDefaultState(), References.RN_ORE_RUTILE, Config.oreRutile); } } }
Example 15
Source Project: Signals Source File: SignalsConfig.java License: GNU General Public License v3.0 | 6 votes |
public void initDefaults(){ if(validItems.length == 0) { List<Item> items = new ArrayList<>(); items.add(ModItems.RAIL_CONFIGURATOR); items.add(Item.getItemFromBlock(ModBlocks.RAIL_LINK)); for(Item item : Item.REGISTRY) { if(item instanceof ItemBlock) { Block block = ((ItemBlock)item).getBlock(); if(block instanceof BlockSignalBase || block instanceof BlockRailBase) { items.add(item); } } } validItems = new String[items.size()]; for(int i = 0; i < items.size(); i++) { validItems[i] = Item.REGISTRY.getNameForObject(items.get(i)).toString(); } } }
Example 16
Source Project: Chisel-2 Source File: RenderChiselSnowman.java License: GNU General Public License v2.0 | 6 votes |
protected void renderEquippedItems(EntityChiselSnowman snowman, float size){ super.renderEquippedItems(snowman, size); ItemStack itemStack = snowman.getEquipmentInSlot(2); if(itemStack.getItem() instanceof ItemBlock){ GL11.glPushMatrix(); this.snowMan.head.postRender(0.0625F); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemStack, EQUIPPED); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemStack, BLOCK_3D)); if(is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType())){ float f1 = 0.625F; GL11.glTranslatef(0.0F, -0.34375F, 0.0F); GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(f1, -f1, f1); } this.renderManager.itemRenderer.renderItem(snowman, itemStack, 0); GL11.glPopMatrix(); } }
Example 17
Source Project: AgriCraft Source File: CustomWoodTypeRegistry.java License: MIT License | 6 votes |
private static void init(Function<ItemBlock, IntStream> getItemDamages) { if (!WOOD_TYPES.isEmpty()) { return; } OreDictionary.getOres("plankWood").stream() .filter(plank -> plank.getItem() instanceof ItemBlock) .flatMap(plank -> { ItemBlock block = ((ItemBlock) plank.getItem()); if (plank.getItemDamage() == OreDictionary.WILDCARD_VALUE) { return getItemDamages.apply(block).mapToObj(meta -> new CustomWoodType(block.getBlock(), meta)); } else { return Stream.of(new CustomWoodType(block.getBlock(), plank.getItemDamage())); } }) .forEach(type -> WOOD_TYPES.put(type.toString(), type)); }
Example 18
Source Project: Gadomancy Source File: ModSubstitutions.java License: GNU Lesser General Public License v3.0 | 6 votes |
public static void preInit() { if(ModConfig.enableAdditionalNodeTypes) { try { ItemBlock item = (ItemBlock) Item.getItemFromBlock(ConfigBlocks.blockAiry); item.field_150939_a = RegisteredBlocks.blockNode; //Hacky way FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry(); registry.underlyingIntegerMap.field_148749_a.put(RegisteredBlocks.blockNode, Block.getIdFromBlock(ConfigBlocks.blockAiry)); registry.underlyingIntegerMap.field_148748_b.set(Block.getIdFromBlock(ConfigBlocks.blockAiry), RegisteredBlocks.blockNode); ((BiMap)registry.field_148758_b).forcePut(RegisteredBlocks.blockNode, registry.field_148758_b.get(ConfigBlocks.blockAiry)); registry.underlyingIntegerMap.field_148749_a.remove(ConfigBlocks.blockAiry); ConfigBlocks.blockAiry = RegisteredBlocks.blockNode; } catch (Exception e) { e.printStackTrace(); } } }
Example 19
Source Project: qcraft-mod Source File: BlockQBlock.java License: Apache License 2.0 | 6 votes |
public IIcon getIconForType( int side, int type, Appearance appearance ) { if( appearance == Appearance.Swirl ) { return s_swirlIcon; } else if( appearance == Appearance.Fuzz ) { return s_fuzzIcon; } else //if( appearance == Appearance.Block ) { ItemStack[] blockList = getImpostorBlockList(); if( type >= 0 && type < blockList.length ) { ItemStack item = blockList[ type ]; if( item != null ) { Block block = ((ItemBlock)item.getItem()).field_150939_a; int damage = item.getItemDamage(); return block.getIcon( side, damage ); } } return s_transparentIcon; } }
Example 20
Source Project: Production-Line Source File: MixinTileEntityFurnace.java License: MIT License | 6 votes |
@Inject(method = "update", at = @At("RETURN")) private void onUpdate(CallbackInfo callbackInfo) { if (!this.world.isRemote) { if (this.isBurning()) { ItemStack itemStack = this.furnaceItemStacks[0]; if (itemStack != null) { if (itemStack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) itemStack.getItem()).block; if (block.getMaterial(block.getStateFromMeta(itemStack.getMetadata())) == Material.TNT) { this.doExplosion(); } } else if (itemStack.getItem() == Items.GUNPOWDER) { this.doExplosion(); } else if (itemStack.getItem() instanceof ItemFirework || itemStack.getItem() instanceof ItemFireworkCharge) { this.doExplosion(); } } } } }
Example 21
Source Project: seppuku Source File: NoCrystalModule.java License: GNU General Public License v3.0 | 5 votes |
private int findStackHotbar(Block type) { for (int i = 0; i < 9; i++) { final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i); if (stack.getItem() instanceof ItemBlock) { final ItemBlock block = (ItemBlock) stack.getItem(); if (block.getBlock() == type) { return i; } } } return -1; }
Example 22
Source Project: TFC2 Source File: TFCBlocks.java License: GNU General Public License v3.0 | 5 votes |
private static Block register(Block b, Class<? extends ItemBlock> i) { try { GameRegistry.register(b); ItemBlock ib = i.getDeclaredConstructor(Block.class).newInstance(b); GameRegistry.register(ib, b.getRegistryName()); } catch (Exception e) { e.printStackTrace(); } return b; }
Example 23
Source Project: seppuku Source File: ScaffoldModule.java License: GNU General Public License v3.0 | 5 votes |
private int getBlockCount() { int count = 0; for (int i = 0; i < 36; i++) { final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i); if (canPlace(stack) && stack.getItem() instanceof ItemBlock) { count += stack.getCount(); } } return count; }
Example 24
Source Project: enderutilities Source File: InventoryUtils.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static void sortInventoryWithinRange(IItemHandlerModifiable inv, SlotRange range) { List<ItemTypeByName> blocks = new ArrayList<ItemTypeByName>(); List<ItemTypeByName> items = new ArrayList<ItemTypeByName>(); final int lastSlot = Math.min(range.lastInc, inv.getSlots() - 1); // Get the different items that are present in the inventory for (int i = range.first; i <= lastSlot; i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.isEmpty() == false) { ItemTypeByName type = new ItemTypeByName(stack); if (stack.getItem() instanceof ItemBlock) { if (blocks.contains(type) == false) { blocks.add(type); } } else if (items.contains(type) == false) { items.add(type); } } } Collections.sort(blocks); Collections.sort(items); int slots = sortInventoryWithinRangeByTypes(inv, blocks, range); sortInventoryWithinRangeByTypes(inv, items, new SlotRange(range.first + slots, range.lastExc - (range.first + slots))); }
Example 25
Source Project: mocreaturesdev Source File: ItemBuilderHammer.java License: GNU General Public License v3.0 | 5 votes |
/** * Finds a block from the belt inventory of player, passes the block ID and Metadata and reduces the stack by 1 if not on Creative mode * @param entityplayer * @return */ private int[] obtainBlockAndMetadataFromBelt(EntityPlayer entityplayer, boolean remove) { for (int y = 0; y < 9 ; y++) { ItemStack slotStack = entityplayer.inventory.getStackInSlot(y); if (slotStack == null) { continue; } Item itemTemp = slotStack.getItem();//new EntityItem(entityplayer.inventory.getStackInSlot(y).itemID); int metadata = slotStack.getItemDamage(); if (itemTemp instanceof ItemBlock) { if (remove && !entityplayer.capabilities.isCreativeMode) { if (--slotStack.stackSize <= 0) { entityplayer.inventory.setInventorySlotContents(y, null); //System.out.println("setting inv slot " + y + " as null on Server? = " + MoCreatures.isServer()); } else { entityplayer.inventory.setInventorySlotContents(y, slotStack); //System.out.println("setting inv slot " + y + " as " + slotStack.stackSize + " on Server? = " + MoCreatures.isServer()); } } return new int[] {itemTemp.itemID, metadata}; } } return new int[] {0,0}; }
Example 26
Source Project: AgriCraft Source File: CustomWoodTypeRegistry.java License: MIT License | 5 votes |
public static final Optional<CustomWoodType> getFromStack(ItemStack stack) { if (StackHelper.hasKey(stack, AgriNBT.MATERIAL, AgriNBT.MATERIAL_META)) { return getFromNbt(stack.getTagCompound()); } else if (StackHelper.isValid(stack, ItemBlock.class)) { final ItemBlock itemBlock = (ItemBlock) stack.getItem(); return getFromBlockAndMeta(itemBlock.getBlock(), itemBlock.getMetadata(stack)); } else { return Optional.empty(); } }
Example 27
Source Project: CommunityMod Source File: ExtraRandomness.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void registerItems(IForgeRegistry<Item> event) { altarItems = new ArrayList<AltarItem>(); itemBlockAltar = RegUtil.registerItemBlock(event, new ItemBlock(blockAltar)); altarItems.add(RegUtil.<AltarItem>registerItem(event, new LexWand(), "lex_wand")); altarItems.add(RegUtil.<AltarItem>registerItem(event, new GoldenEgg(), "golden_egg")); altarItems.add(RegUtil.<AltarItem>registerItem(event, new Shocker(), "shocker")); }
Example 28
Source Project: CommunityMod Source File: NeatNetherBlocks.java License: GNU Lesser General Public License v2.1 | 5 votes |
public static ItemBlock registerItemBlock(Block block, IForgeRegistry<Item> r) { ItemBlock ib = new ItemBlock(block); ib.setRegistryName(block.getRegistryName()); r.register(ib); return ib; }
Example 29
Source Project: PneumaticCraft Source File: TileEntityElevatorCaller.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onDescUpdate(){ Block newCamo = camoStack != null && camoStack.getItem() instanceof ItemBlock ? ((ItemBlock)camoStack.getItem()).field_150939_a : null; if(newCamo != camoBlock) { camoBlock = newCamo; rerenderChunk(); } }
Example 30
Source Project: PneumaticCraft Source File: BlockPneumaticDoorBase.java License: GNU General Public License v3.0 | 5 votes |
@Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase)world.getTileEntity(x, y, z); ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT); if(camoStack != null && camoStack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock)camoStack.getItem()).field_150939_a; if(PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) { return block.getIcon(side, camoStack.getItemDamage()); } } return this.getIcon(side, world.getBlockMetadata(x, y, z)); }