Java Code Examples for net.minecraft.block.Block

The following are top voted examples for showing how to use net.minecraft.block.Block. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: connor41-etfuturum2   File: ChorusFlower.java   Source Code and License 6 votes vote down vote up
public static boolean canPlantStay(World world, int x, int y, int z) {
	Block block = world.getBlock(x, y - 1, z);
	if (block != ModBlocks.chorus_plant && block != Blocks.end_stone) {
		if (block.isAir(world, x, y - 1, z)) {
			int adjecentCount = 0;
			for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
				Block adjecentBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
				if (adjecentBlock == ModBlocks.chorus_plant)
					adjecentCount++;
				else if (!adjecentBlock.isAir(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
					return false;
			}
			return adjecentCount == 1;
		} else
			return false;
	} else
		return true;
}
 
Example 2
Project: Technical   File: TileEntityMachine.java   Source Code and License 6 votes vote down vote up
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;
	}
}
 
Example 3
Project: CustomWorldGen   File: EntityLivingBase.java   Source Code and License 6 votes vote down vote up
/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder()
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
    int k = MathHelper.floor_double(this.posZ);

    if (this instanceof EntityPlayer && ((EntityPlayer)this).isSpectator())
    {
        return false;
    }
    else
    {
        BlockPos blockpos = new BlockPos(i, j, k);
        IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
        Block block = iblockstate.getBlock();
        return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(iblockstate, worldObj, new BlockPos(i, j, k), this);
    }
}
 
Example 4
Project: Backmemed   File: SVertexBuilder.java   Source Code and License 6 votes vote down vote up
public static void pushEntity(IBlockState blockState, BlockPos blockPos, IBlockAccess blockAccess, VertexBuffer wrr)
{
    Block block = blockState.getBlock();
    int i;
    int j;

    if (blockState instanceof BlockStateBase)
    {
        BlockStateBase blockstatebase = (BlockStateBase)blockState;
        i = blockstatebase.getBlockId();
        j = blockstatebase.getMetadata();
    }
    else
    {
        i = Block.getIdFromBlock(block);
        j = block.getMetaFromState(blockState);
    }

    i = BlockAliases.getMappedBlockId(i, j);
    int i1 = block.getRenderType(blockState).ordinal();
    int k = ((i1 & 65535) << 16) + (i & 65535);
    int l = j & 65535;
    wrr.sVertexBuilder.pushEntity(((long)l << 32) + (long)k);
}
 
Example 5
Project: uniquecrops   File: ItemGeneric.java   Source Code and License 6 votes vote down vote up
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	
	if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
		Block crops = world.getBlockState(pos).getBlock();
		if (crops != null && crops instanceof BlockCrops) {
			if (crops != UCBlocks.cropMerlinia)
				world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
			else if (crops == UCBlocks.cropMerlinia)
				((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
			else if (crops instanceof BlockNetherWart)
				((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
			if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
				stack.stackSize--;
			UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
			return EnumActionResult.SUCCESS;
		}
	}
	return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
 
Example 6
Project: BaseClient   File: StatList.java   Source Code and License 6 votes vote down vote up
/**
 * Merge {@link StatBase} object references for similar blocks
 */
private static void mergeStatBases(StatBase[] statBaseIn, Block p_151180_1_, Block p_151180_2_)
{
    int i = Block.getIdFromBlock(p_151180_1_);
    int j = Block.getIdFromBlock(p_151180_2_);

    if (statBaseIn[i] != null && statBaseIn[j] == null)
    {
        statBaseIn[j] = statBaseIn[i];
    }
    else
    {
        allStats.remove(statBaseIn[i]);
        objectMineStats.remove(statBaseIn[i]);
        generalStats.remove(statBaseIn[i]);
        statBaseIn[i] = statBaseIn[j];
    }
}
 
Example 7
Project: Technical   File: BlockBaryteOre.java   Source Code and License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
	Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_);
	if (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) != p_149646_1_.getBlockMetadata(p_149646_2_ - Facing.offsetsXForSide[p_149646_5_], p_149646_3_ - Facing.offsetsYForSide[p_149646_5_], p_149646_4_ - Facing.offsetsZForSide[p_149646_5_])) {
		return true;
	}

	if (block == this) {
		return false;
	}
	return true;
}
 
Example 8
Project: customstuff4   File: StateMetaMapper.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
static <T extends Block> StateMetaMapper<T> create(Collection<IProperty<?>> properties)
{
    if (properties.size() == 0)
        return new EmptyStateMetaMapper<>();
    else if (properties.size() == 1)
        return new SimpleStateMetaMapper(properties.iterator().next());
    else
        return new BitStateMetaMapper<>(properties);
}
 
Example 9
Project: CustomWorldGen   File: ExtendedBlockStorage.java   Source Code and License 5 votes vote down vote up
public void set(int x, int y, int z, IBlockState state)
{
    if (state instanceof net.minecraftforge.common.property.IExtendedBlockState)
        state = ((net.minecraftforge.common.property.IExtendedBlockState) state).getClean();
    IBlockState iblockstate = this.get(x, y, z);
    Block block = iblockstate.getBlock();
    Block block1 = state.getBlock();

    if (block != Blocks.AIR)
    {
        --this.blockRefCount;

        if (block.getTickRandomly())
        {
            --this.tickRefCount;
        }
    }

    if (block1 != Blocks.AIR)
    {
        ++this.blockRefCount;

        if (block1.getTickRandomly())
        {
            ++this.tickRefCount;
        }
    }

    this.data.set(x, y, z, state);
}
 
Example 10
Project: Backmemed   File: World.java   Source Code and License 5 votes vote down vote up
public void notifyNeighborsRespectDebug(BlockPos pos, Block blockType, boolean p_175722_3_)
{
    if (this.worldInfo.getTerrainType() != WorldType.DEBUG_WORLD)
    {
        this.notifyNeighborsOfStateChange(pos, blockType, p_175722_3_);
    }
}
 
Example 11
Project: Backmemed   File: ItemTool.java   Source Code and License 5 votes vote down vote up
protected ItemTool(float attackDamageIn, float attackSpeedIn, Item.ToolMaterial materialIn, Set<Block> effectiveBlocksIn)
{
    this.efficiencyOnProperMaterial = 4.0F;
    this.toolMaterial = materialIn;
    this.effectiveBlocks = effectiveBlocksIn;
    this.maxStackSize = 1;
    this.setMaxDamage(materialIn.getMaxUses());
    this.efficiencyOnProperMaterial = materialIn.getEfficiencyOnProperMaterial();
    this.damageVsEntity = attackDamageIn + materialIn.getDamageVsEntity();
    this.attackSpeed = attackSpeedIn;
    this.setCreativeTab(CreativeTabs.TOOLS);
}
 
Example 12
Project: CustomWorldGen   File: NBTUtil.java   Source Code and License 5 votes vote down vote up
/**
 * Writes the given blockstate to the given tag.
 *  
 * @param tag The tag to write to
 * @param state The blockstate to be written
 */
public static NBTTagCompound writeBlockState(NBTTagCompound tag, IBlockState state)
{
    tag.setString("Name", ((ResourceLocation)Block.REGISTRY.getNameForObject(state.getBlock())).toString());

    if (!state.getProperties().isEmpty())
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();

        for (Entry < IProperty<?>, Comparable<? >> entry : state.getProperties().entrySet())
        {
            IProperty<?> iproperty = (IProperty)entry.getKey();
            nbttagcompound.setString(iproperty.getName(), getName(iproperty, (Comparable)entry.getValue()));
        }

        tag.setTag("Properties", nbttagcompound);
    }

    return tag;
}
 
Example 13
Project: CustomWorldGen   File: TileEntity.java   Source Code and License 5 votes vote down vote up
/**
 * Gets the block type at the location of this entity (client-only).
 */
public Block getBlockType()
{
    if (this.blockType == null && this.worldObj != null)
    {
        this.blockType = this.worldObj.getBlockState(this.pos).getBlock();
    }

    return this.blockType;
}
 
Example 14
Project: IceMod   File: IceLands.java   Source Code and License 5 votes vote down vote up
public IceLands(int par1)
{
    super(par1);
    
    this.setBiomeName("Icelands");
    
    this.topBlock = (byte)IceMod.IcyOre.blockID;
    this.fillerBlock = (byte)Block.ice.blockID;
    
    this.theBiomeDecorator.bigMushroomsPerChunk = 10;
    this.theBiomeDecorator.treesPerChunk = 5;
    this.theBiomeDecorator.clayPerChunk  = 3;
    this.theBiomeDecorator.reedsPerChunk = 1;

    this.spawnableMonsterList.add(new SpawnListEntry(EntitySnowman.class, 25, 4, 8));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 25, 4, 8));
    this.spawnableMonsterList.add(new SpawnListEntry(EntityDragon.class, 1, 1, 1));
    this.spawnableMonsterList.add(new SpawnListEntry(EntityIronGolem.class, 1, 1, 1));
    
    this.setMinMaxHeight(0.1F, 0.5F);
    //mnmx
    this.setTemperatureRainfall(0.7F, 0.2F);
   
}
 
Example 15
Project: UniversalRemote   File: UniversalRemoteConfiguration.java   Source Code and License 5 votes vote down vote up
public static boolean isBlockBlacklisted(Block block)
{
	ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
	String[] blackList = UniversalRemoteConfiguration.blacklist.blacklist.split(",");

	for (String entry : blackList)
	{
		String[] parts = entry.split(":");

		if (loc.toString().equals(entry))
		{
			return true;
		}

		// bad entry?
		if (parts.length != 2) continue;

		if (parts[1].equals("*") && loc.getResourceDomain().equals(parts[0]))
		{
			return true;
		}
	}

	return false;
}
 
Example 16
Project: CustomWorldGen   File: BlockColors.java   Source Code and License 5 votes vote down vote up
public void registerBlockColorHandler(IBlockColor blockColor, Block... blocksIn)
{
    for (Block block : blocksIn)
    {
        if (block == null) throw new IllegalArgumentException("Block registered to block color handler cannot be null!");
        if (block.getRegistryName() == null) throw new IllegalArgumentException("Block must be registered before assigning color handler.");
        this.blockColorMap.put(block.delegate, blockColor);
    }
}
 
Example 17
Project: BaseClient   File: EntityAIOcelotSit.java   Source Code and License 5 votes vote down vote up
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    if (!worldIn.isAirBlock(pos.up()))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.chest)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest && ((TileEntityChest)tileentity).numPlayersUsing < 1)
            {
                return true;
            }
        }
        else
        {
            if (block == Blocks.lit_furnace)
            {
                return true;
            }

            if (block == Blocks.bed && iblockstate.getValue(BlockBed.PART) != BlockBed.EnumPartType.HEAD)
            {
                return true;
            }
        }

        return false;
    }
}
 
Example 18
Project: ExPetrum   File: BlockCoralPlant.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
	super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
	this.onNeighborChange(worldIn, pos, fromPos);
}
 
Example 19
Project: BaseClient   File: ExtendedBlockStorage.java   Source Code and License 5 votes vote down vote up
public void set(int x, int y, int z, IBlockState state)
{
    IBlockState iblockstate = this.get(x, y, z);
    Block block = iblockstate.getBlock();
    Block block1 = state.getBlock();

    if (block != Blocks.air)
    {
        --this.blockRefCount;

        if (block.getTickRandomly())
        {
            --this.tickRefCount;
        }
    }

    if (block1 != Blocks.air)
    {
        ++this.blockRefCount;

        if (block1.getTickRandomly())
        {
            ++this.tickRefCount;
        }
    }

    this.data[y << 8 | z << 4 | x] = (char)Block.BLOCK_STATE_IDS.get(state);
}
 
Example 20
Project: modName   File: ModRegistry.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void onItemRegistry(RegistryEvent.Register<Item> e) 
{
	e.getRegistry().registerAll(Ref.ITEMS.toArray(new Item[0]));
	for (Block block : Ref.BLOCKS)
		e.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
 
Example 21
Project: BaseClient   File: StructureVillagePieces.java   Source Code and License 5 votes vote down vote up
protected void writeStructureToNBT(NBTTagCompound tagCompound)
{
    super.writeStructureToNBT(tagCompound);
    tagCompound.setInteger("CA", Block.blockRegistry.getIDForObject(this.cropTypeA));
    tagCompound.setInteger("CB", Block.blockRegistry.getIDForObject(this.cropTypeB));
    tagCompound.setInteger("CC", Block.blockRegistry.getIDForObject(this.cropTypeC));
    tagCompound.setInteger("CD", Block.blockRegistry.getIDForObject(this.cropTypeD));
}
 
Example 22
Project: AdvancedCombat   File: RegistryHelper.java   Source Code and License 5 votes vote down vote up
/** Register the block correctly */
public static void registerBlock(IBlockAdvanced regBlock) {
	Block block = (Block)regBlock;
	ItemBlock item;
	
	// register the block by itself first
       BLOCKS_TO_REGISTER.add(block.setUnlocalizedName(block.getRegistryName().toString()));
       
	// try to get the ItemBlock
       if(regBlock.getItemClass() != null) {
        try {
			Class<?>[] ctorArgClasses = new Class[regBlock.getItemClassArgs().length + 1];
	        ctorArgClasses[0] = Block.class; // start with the block
	        for (int idx = 1; idx < ctorArgClasses.length; idx++) {
	            ctorArgClasses[idx] = regBlock.getItemClassArgs()[idx - 1].getClass();
	        }
	        Constructor<? extends ItemBlock> itemCtor = regBlock.getItemClass().getConstructor(ctorArgClasses);
	        item = itemCtor.newInstance(ObjectArrays.concat(regBlock, regBlock.getItemClassArgs()));
        } catch (Exception e) {
        	Log.logger.error("Unable to register block " + block.getRegistryName());
        	return;
        }
        
        // register the ItemBlock if there are no errors
        ITEMS_TO_REGISTER.add(item.setRegistryName(block.getRegistryName()));
       }
}
 
Example 23
Project: MeeCreeps   File: HarvestActionFactory.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isPossibleSecondary(World world, BlockPos pos, EnumFacing side) {
    if (!InventoryTools.isInventory(world, pos)) {
        return false;
    }

    // @todo config for harvest area
    AxisAlignedBB box = new AxisAlignedBB(pos.add(-10, -5, -10), pos.add(10, 5, 10));

    for (double x = box.minX ; x <= box.maxX ; x++) {
        for (double y = box.minY ; y <= box.maxY ; y++) {
            for (double z = box.minZ ; z <= box.maxZ ; z++) {
                BlockPos p = new BlockPos(x, y, z);
                IBlockState state = world.getBlockState(p);
                if (state.getBlock() == Blocks.FARMLAND) {
                    IBlockState cropState = world.getBlockState(p.up());
                    Block cropBlock = cropState.getBlock();
                    boolean hasCrops = cropBlock instanceof IPlantable && state.getBlock().canSustainPlant(world.getBlockState(p), world, p, EnumFacing.UP, (IPlantable) cropBlock);
                    if (hasCrops) {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
Example 24
Project: harshencastle   File: BasePontusResourceBiome.java   Source Code and License 5 votes vote down vote up
public Block getMergerBlock(boolean isLevelDown)
{
	if(isLevelDown)
		return getMergerBlockDownLevel();
	else
		return getMergerBlockUpLevel();
}
 
Example 25
Project: ExSartagine   File: BlockSmelter.java   Source Code and License 5 votes vote down vote up
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
	Block blockDown = world.getBlockState(pos.down()).getBlock();
	if(blockDown == Blocks.LIT_FURNACE ||blockDown == Blocks.FURNACE || blockDown == ExSartagineBlock.range_extension){
				return true;
	}
	return false;
}
 
Example 26
Project: Adventurers-Toolbox   File: ItemATMace.java   Source Code and License 5 votes vote down vote up
@Override
public float getDestroySpeed(ItemStack stack, IBlockState state) {
	Block block = state.getBlock();

	if (block == Blocks.WEB) {
		return 15.0F;
	} else {
		Material material = state.getMaterial();
		return material != Material.PLANTS && material != Material.VINE && material != Material.CORAL
				&& material != Material.LEAVES && material != Material.GOURD ? 1.0F : 1.5F;
	}
}
 
Example 27
Project: customstuff4   File: ItemSlab.java   Source Code and License 5 votes vote down vote up
public ItemSlab(Block block, ContentBlockSlab content)
{
    super(block, content);
    singleSlab = block;
    singleSlabCS = (CSBlock) block;

    this.content = content;
}
 
Example 28
Project: minecraft-territorialdealings   File: ValueTable.java   Source Code and License 5 votes vote down vote up
static int getValueFromBlock(Block block)
{
	if (block == null) { return 0; }

	if (block == Blocks.EMERALD_BLOCK) { return emeraldValue * 9; }
	else if (block == Blocks.DIAMOND_BLOCK) { return diamondValue * 9; }
	else if (block == Blocks.GOLD_BLOCK) { return goldValue * 9; }

	return 0;
}
 
Example 29
Project: Backmemed   File: Shaders.java   Source Code and License 5 votes vote down vote up
public static void setBlockEntityId(TileEntity tileEntity)
{
    if (isRenderingWorld && !isShadowPass && uniformBlockEntityId.isDefined())
    {
        Block block = tileEntity.getBlockType();
        int i = Block.getIdFromBlock(block);
        uniformBlockEntityId.setValue(i);
    }
}
 
Example 30
Project: pnc-repressurized   File: DroneAIDig.java   Source Code and License 5 votes vote down vote up
@Nonnull
private static ItemStack getSilkTouchBlock(Block block, IBlockState state) {
    Item item = Item.getItemFromBlock(block);
    if (item == Items.AIR) {
        return ItemStack.EMPTY;
    } else {
        return new ItemStack(item, 1, block.getMetaFromState(state));
    }
}
 
Example 31
Project: Bewitchment   File: FlawlessRecipe.java   Source Code and License 5 votes vote down vote up
public FlawlessRecipe(ItemStack result, Object... inputs) {
	this.result = result;

	final List<Object> stackedList = Arrays.stream(inputs).map(obj -> {
		if (obj instanceof Item) return new ItemStack((Item) obj);
		else if (obj instanceof Block) return new ItemStack((Block) obj);
		else return obj;
	}).collect(Collectors.toList());

	neededItems = ImmutableList.copyOf(stackedList);
}
 
Example 32
Project: interactionwheel   File: DefaultWheelActionProvider.java   Source Code and License 5 votes vote down vote up
@Override
    public void updateWheelActions(@Nonnull Set<String> actions, @Nonnull EntityPlayer player, World world, @Nullable BlockPos pos) {
        ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
        if (ItemStackTools.isValid(heldItem)) {
            actions.add(StandardWheelActions.ID_SEARCH);
        }
        if (pos != null) {
            actions.add(StandardWheelActions.ID_ROTATE);
            Block block = world.getBlockState(pos).getBlock();
            TileEntity te = world.getTileEntity(pos);
            if (te instanceof IInventory || (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))) {
                actions.add(StandardWheelActions.ID_DUMP);
                actions.add(StandardWheelActions.ID_EXTRACT);
                actions.add(StandardWheelActions.ID_DUMPORES);
                actions.add(StandardWheelActions.ID_DUMPBLOCKS);
                actions.add(StandardWheelActions.ID_DUMPSIMILARINV);
                if (ItemStackTools.isValid(heldItem)) {
                    actions.add(StandardWheelActions.ID_DUMP1);
                    actions.add(StandardWheelActions.ID_DUMPSIMILAR);
                }
            }
            actions.add(StandardWheelActions.ID_PICKTOOL);

            if (block instanceof IWheelBlockSupport) {
                ((IWheelBlockSupport) block).updateWheelActions(actions);
            }
        }
//        actions.add("std.dummy0");
//        actions.add("std.dummy1");
//        actions.add("std.dummy2");
//        actions.add("std.dummy3");
//        actions.add("std.dummy4");
//        actions.add("std.dummy5");
//        actions.add("std.dummy7");
//        actions.add("std.dummy8");
//        actions.add("std.dummy9");
//        actions.add("std.dummy10");
    }
 
Example 33
Project: Backmemed   File: CommandBase.java   Source Code and License 5 votes vote down vote up
/**
 * Gets the Block specified by the given text string.  First checks the block registry, then tries by parsing the
 * string as an integer ID (deprecated).  Warns the sender if we matched by parsing the ID.  Throws if the block
 * wasn't found.  Returns the block if it was found.
 */
public static Block getBlockByText(ICommandSender sender, String id) throws NumberInvalidException
{
    ResourceLocation resourcelocation = new ResourceLocation(id);

    if (!Block.REGISTRY.containsKey(resourcelocation))
    {
        throw new NumberInvalidException("commands.give.block.notFound", new Object[] {resourcelocation});
    }
    else
    {
        return (Block)Block.REGISTRY.getObject(resourcelocation);
    }
}
 
Example 34
Project: BaseClient   File: ItemRenderer.java   Source Code and License 5 votes vote down vote up
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();
    }
}
 
Example 35
Project: pnc-repressurized   File: BlockPneumaticDoorBase.java   Source Code and License 5 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof TileEntityPneumaticDoorBase) {
        updateDoorSide((TileEntityPneumaticDoorBase) te);
        EnumFacing dir = ((TileEntityPneumaticDoorBase) te).getRotation();
        if (world.getBlockState(pos.offset(dir)).getBlock() == Blockss.PNEUMATIC_DOOR) {
            Blockss.PNEUMATIC_DOOR.neighborChanged(world.getBlockState(pos.offset(dir)), world, pos, block, pos.offset(dir));
        }
    }
}
 
Example 36
Project: CustomWorldGen   File: EntityArrow.java   Source Code and License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    compound.setInteger("xTile", this.xTile);
    compound.setInteger("yTile", this.yTile);
    compound.setInteger("zTile", this.zTile);
    compound.setShort("life", (short)this.ticksInGround);
    ResourceLocation resourcelocation = (ResourceLocation)Block.REGISTRY.getNameForObject(this.inTile);
    compound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
    compound.setByte("inData", (byte)this.inData);
    compound.setByte("shake", (byte)this.arrowShake);
    compound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
    compound.setByte("pickup", (byte)this.pickupStatus.ordinal());
    compound.setDouble("damage", this.damage);
}
 
Example 37
Project: PurificatiMagicae   File: ItemBlockBase.java   Source Code and License 4 votes vote down vote up
public ItemBlockBase(Block block)
{
    super(block);
}
 
Example 38
Project: morefurnaces   File: MoreFurnaces.java   Source Code and License 4 votes vote down vote up
@SubscribeEvent
public void registerBlocks(RegistryEvent.Register<Block> event)
{
    event.getRegistry().register(blockFurnaces);
}
 
Example 39
Project: connor41-etfuturum2   File: GrassPath.java   Source Code and License 4 votes vote down vote up
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
	if (world.getBlock(x, y + 1, z).getMaterial().isSolid())
		world.setBlock(x, y, z, Blocks.dirt);
}
 
Example 40
Project: MTTM   File: ModBlocks.java   Source Code and License 4 votes vote down vote up
private static void registerBlock(Block block){
    GameRegistry.register(block);
    ItemBlock item = new ItemBlock(block);
    item.setRegistryName(block.getRegistryName());
    GameRegistry.register(item);
}
 
Example 41
Project: Technical   File: BlastFurnaceItemBlock.java   Source Code and License 4 votes vote down vote up
public BlastFurnaceItemBlock(Block block) {
	super(block);
}
 
Example 42
Project: FoodCraft-Reloaded   File: BlockQuery.java   Source Code and License 4 votes vote down vote up
public BlockQueryBlock(Block... blocks) {
    this.blocks = Sets.newHashSet(blocks);
}
 
Example 43
Project: Genesis   File: GenesisBlocks.java   Source Code and License 4 votes vote down vote up
private static void registerBlock(final IForgeRegistry<Block> registry, final Block block, final String name) {
    block.setRegistryName(GenesisMod.MOD_ID, name);
    block.setUnlocalizedName(GenesisMod.MOD_ID + "." + name);
    registry.register(block);
    BLOCKS.add(block);
}
 
Example 44
Project: ShoopCraft   File: ModBlocks.java   Source Code and License 4 votes vote down vote up
private static void registerRender(Block block) {
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
 
Example 45
Project: BaseClient   File: Achievement.java   Source Code and License 4 votes vote down vote up
public Achievement(String p_i45301_1_, String p_i45301_2_, int column, int row, Block p_i45301_5_, Achievement parent)
{
    this(p_i45301_1_, p_i45301_2_, column, row, new ItemStack(p_i45301_5_), parent);
}
 
Example 46
Project: BaseClient   File: ItemSeedFood.java   Source Code and License 4 votes vote down vote up
public ItemSeedFood(int healAmount, float saturation, Block crops, Block soil)
{
    super(healAmount, saturation, false);
    this.crops = crops;
    this.soilId = soil;
}
 
Example 47
Project: CustomWorldGen   File: FlatLayerInfo.java   Source Code and License 4 votes vote down vote up
private Block getLayerMaterialBlock()
{
    return this.layerMaterial.getBlock();
}
 
Example 48
Project: EasyCraft   File: BlockLoader.java   Source Code and License 4 votes vote down vote up
private static void register(Block Block,String name) {
	GameRegistry.registerBlock(Block.setRegistryName(name));
}
 
Example 49
Project: Zombe-Modpack   File: ZWrapper.java   Source Code and License 4 votes vote down vote up
@Deprecated
public static int getBlockOpacity(Block block) {
    return block == null ? 0 : block.getLightOpacity(null);
}
 
Example 50
Project: Backmemed   File: ItemSnow.java   Source Code and License 4 votes vote down vote up
public ItemSnow(Block block)
{
    super(block);
    this.setMaxDamage(0);
}
 
Example 51
Project: TechReborn3   File: TechRebornClient.java   Source Code and License 4 votes vote down vote up
private static void register(Block block, String name) {
	register(Item.getItemFromBlock(block), 0, name);
}
 
Example 52
Project: Bewitchment   File: CropKenaf.java   Source Code and License 4 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
	this.checkForDrop(worldIn, pos, state);
}
 
Example 53
Project: Firma   File: Util.java   Source Code and License 4 votes vote down vote up
public static boolean isWoodEnum1(Block b) {
	return b == FirmaMod.log || b== FirmaMod.leaf || b==FirmaMod.plank || b==FirmaMod.sapling;
}
 
Example 54
Project: BaseClient   File: EntityHorse.java   Source Code and License 4 votes vote down vote up
protected void playStepSound(BlockPos pos, Block blockIn)
{
    Block.SoundType block$soundtype = blockIn.stepSound;

    if (this.worldObj.getBlockState(pos.up()).getBlock() == Blocks.snow_layer)
    {
        block$soundtype = Blocks.snow_layer.stepSound;
    }

    if (!blockIn.getMaterial().isLiquid())
    {
        int i = this.getHorseType();

        if (this.riddenByEntity != null && i != 1 && i != 2)
        {
            ++this.gallopTime;

            if (this.gallopTime > 5 && this.gallopTime % 3 == 0)
            {
                this.playSound("mob.horse.gallop", block$soundtype.getVolume() * 0.15F, block$soundtype.getFrequency());

                if (i == 0 && this.rand.nextInt(10) == 0)
                {
                    this.playSound("mob.horse.breathe", block$soundtype.getVolume() * 0.6F, block$soundtype.getFrequency());
                }
            }
            else if (this.gallopTime <= 5)
            {
                this.playSound("mob.horse.wood", block$soundtype.getVolume() * 0.15F, block$soundtype.getFrequency());
            }
        }
        else if (block$soundtype == Block.soundTypeWood)
        {
            this.playSound("mob.horse.wood", block$soundtype.getVolume() * 0.15F, block$soundtype.getFrequency());
        }
        else
        {
            this.playSound("mob.horse.soft", block$soundtype.getVolume() * 0.15F, block$soundtype.getFrequency());
        }
    }
}
 
Example 55
Project: BaseClient   File: World.java   Source Code and License 4 votes vote down vote up
public void forceBlockUpdateTick(Block blockType, BlockPos pos, Random random)
{
    this.scheduledUpdatesAreImmediate = true;
    blockType.updateTick(this, pos, this.getBlockState(pos), random);
    this.scheduledUpdatesAreImmediate = false;
}
 
Example 56
Project: CustomWorldGen   File: ParticleBlockDust.java   Source Code and License 4 votes vote down vote up
public Particle createParticle(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
{
    IBlockState iblockstate = Block.getStateById(p_178902_15_[0]);
    return iblockstate.getRenderType() == EnumBlockRenderType.INVISIBLE ? null : (new ParticleBlockDust(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, iblockstate)).init();
}
 
Example 57
Project: pnc-repressurized   File: Fluids.java   Source Code and License 4 votes vote down vote up
public static Block getBlock(Fluid fluid) {
    return fluidToBlockMap.get(fluid.getName());
}
 
Example 58
Project: Machines-and-Stuff   File: MBlocks.java   Source Code and License 4 votes vote down vote up
private static void registerBlock(Block block, String key, Class tile, CreativeTabs tab) {
    registerBlock(block, key, key, tile, TAB);
}
 
Example 59
Project: BaseClient   File: BlockModelRenderer.java   Source Code and License 4 votes vote down vote up
public boolean renderModelAmbientOcclusion(IBlockAccess blockAccessIn, IBakedModel modelIn, Block blockIn, BlockPos blockPosIn, WorldRenderer worldRendererIn, boolean checkSides)
{
    return this.renderModelAmbientOcclusion(blockAccessIn, modelIn, blockIn, blockAccessIn.getBlockState(blockPosIn), blockPosIn, worldRendererIn, checkSides);
}
 
Example 60
Project: CustomWorldGen   File: TileEntityFurnace.java   Source Code and License 4 votes vote down vote up
/**
 * 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 == null)
    {
        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);
    }
}