BlockRedstoneLight .java

net.minecraft.block.BlockRedstoneLight (class): members: isOn, createStackedBlock, onBlockAdded, getItem, updateTick, onNeighborBlockChange. imports: Item.

net.minecraft.blockclass89 linescommonextends Block2.4 KB

API Surface (6)

void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
Item getItemDropped(IBlockState state, Random rand, int fortune)
Item getItem(World worldIn, BlockPos pos)
ItemStack createStackedBlock(IBlockState state)

Fields & Constants (1)

isOn

Code Graph: Dependencies (8)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

BlockRedstoneLight.java89 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.Random;
4
import net.minecraft.block.material.Material;
5
import net.minecraft.block.state.IBlockState;
6
import net.minecraft.init.Blocks;
7
import net.minecraft.item.Item;
8
import net.minecraft.item.ItemStack;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.world.World;
11
12
public class BlockRedstoneLight extends Block
13
{
14
    private final boolean isOn;
15
16
    public BlockRedstoneLight(boolean isOn)
17
    {
18
        super(Material.redstoneLight);
19
        this.isOn = isOn;
20
21
        if (isOn)
22
        {
23
            this.setLightLevel(1.0F);
24
        }
25
    }
26
27
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
28
    {
29
        if (!worldIn.isRemote)
30
        {
31
            if (this.isOn && !worldIn.isBlockPowered(pos))
32
            {
33
                worldIn.setBlockState(pos, Blocks.redstone_lamp.getDefaultState(), 2);
34
            }
35
            else if (!this.isOn && worldIn.isBlockPowered(pos))
36
            {
37
                worldIn.setBlockState(pos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
38
            }
39
        }
40
    }
41
42
    /**
43
     * Called when a neighboring block changes.
44
     */
45
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
46
    {
47
        if (!worldIn.isRemote)
48
        {
49
            if (this.isOn && !worldIn.isBlockPowered(pos))
50
            {
51
                worldIn.scheduleUpdate(pos, this, 4);
52
            }
53
            else if (!this.isOn && worldIn.isBlockPowered(pos))
54
            {
55
                worldIn.setBlockState(pos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
56
            }
57
        }
58
    }
59
60
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
61
    {
62
        if (!worldIn.isRemote)
63
        {
64
            if (this.isOn && !worldIn.isBlockPowered(pos))
65
            {
66
                worldIn.setBlockState(pos, Blocks.redstone_lamp.getDefaultState(), 2);
67
            }
68
        }
69
    }
70
71
    /**
72
     * Get the Item that this Block should drop when harvested.
73
     */
74
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
75
    {
76
        return Item.getItemFromBlock(Blocks.redstone_lamp);
77
    }
78
79
    public Item getItem(World worldIn, BlockPos pos)
80
    {
81
        return Item.getItemFromBlock(Blocks.redstone_lamp);
82
    }
83
84
    protected ItemStack createStackedBlock(IBlockState state)
85
    {
86
        return new ItemStack(Blocks.redstone_lamp);
87
    }
88
}
89

Deobfuscated MCP 1.8.9 source of BlockRedstoneLight from Marcelektro/MavenMCP-1.8.9 (net/minecraft/block/BlockRedstoneLight.java), stored verbatim.