BlockDragonEgg .java

net.minecraft.block.BlockDragonEgg (class): members: onBlockClicked, tickRate, shouldSideBeRendered, onBlockAdded, onBlockActivated, getItem, updateTick.

net.minecraft.blockclass150 linescommonextends Block5.0 KB

API Surface (10)

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)
boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
int tickRate(World worldIn)
boolean isOpaqueCube()
boolean isFullCube()
boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
Item getItem(World worldIn, BlockPos pos)

Full Source

BlockDragonEgg.java150 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.Random;
4
import net.minecraft.block.material.MapColor;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.state.IBlockState;
7
import net.minecraft.entity.item.EntityFallingBlock;
8
import net.minecraft.entity.player.EntityPlayer;
9
import net.minecraft.item.Item;
10
import net.minecraft.util.BlockPos;
11
import net.minecraft.util.EnumFacing;
12
import net.minecraft.util.EnumParticleTypes;
13
import net.minecraft.world.IBlockAccess;
14
import net.minecraft.world.World;
15
16
public class BlockDragonEgg extends Block
17
{
18
    public BlockDragonEgg()
19
    {
20
        super(Material.dragonEgg, MapColor.blackColor);
21
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
22
    }
23
24
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
25
    {
26
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
27
    }
28
29
    /**
30
     * Called when a neighboring block changes.
31
     */
32
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
33
    {
34
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
35
    }
36
37
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
38
    {
39
        this.checkFall(worldIn, pos);
40
    }
41
42
    private void checkFall(World worldIn, BlockPos pos)
43
    {
44
        if (BlockFalling.canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
45
        {
46
            int i = 32;
47
48
            if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
49
            {
50
                worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
51
            }
52
            else
53
            {
54
                worldIn.setBlockToAir(pos);
55
                BlockPos blockpos;
56
57
                for (blockpos = pos; BlockFalling.canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
58
                {
59
                    ;
60
                }
61
62
                if (blockpos.getY() > 0)
63
                {
64
                    worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
65
                }
66
            }
67
        }
68
    }
69
70
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
71
    {
72
        this.teleport(worldIn, pos);
73
        return true;
74
    }
75
76
    public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
77
    {
78
        this.teleport(worldIn, pos);
79
    }
80
81
    private void teleport(World worldIn, BlockPos pos)
82
    {
83
        IBlockState iblockstate = worldIn.getBlockState(pos);
84
85
        if (iblockstate.getBlock() == this)
86
        {
87
            for (int i = 0; i < 1000; ++i)
88
            {
89
                BlockPos blockpos = pos.add(worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16), worldIn.rand.nextInt(8) - worldIn.rand.nextInt(8), worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16));
90
91
                if (worldIn.getBlockState(blockpos).getBlock().blockMaterial == Material.air)
92
                {
93
                    if (worldIn.isRemote)
94
                    {
95
                        for (int j = 0; j < 128; ++j)
96
                        {
97
                            double d0 = worldIn.rand.nextDouble();
98
                            float f = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
99
                            float f1 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
100
                            float f2 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
101
                            double d1 = (double)blockpos.getX() + (double)(pos.getX() - blockpos.getX()) * d0 + (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
102
                            double d2 = (double)blockpos.getY() + (double)(pos.getY() - blockpos.getY()) * d0 + worldIn.rand.nextDouble() * 1.0D - 0.5D;
103
                            double d3 = (double)blockpos.getZ() + (double)(pos.getZ() - blockpos.getZ()) * d0 + (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
104
                            worldIn.spawnParticle(EnumParticleTypes.PORTAL, d1, d2, d3, (double)f, (double)f1, (double)f2, new int[0]);
105
                        }
106
                    }
107
                    else
108
                    {
109
                        worldIn.setBlockState(blockpos, iblockstate, 2);
110
                        worldIn.setBlockToAir(pos);
111
                    }
112
113
                    return;
114
                }
115
            }
116
        }
117
    }
118
119
    /**
120
     * How many world ticks before ticking
121
     */
122
    public int tickRate(World worldIn)
123
    {
124
        return 5;
125
    }
126
127
    /**
128
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
129
     */
130
    public boolean isOpaqueCube()
131
    {
132
        return false;
133
    }
134
135
    public boolean isFullCube()
136
    {
137
        return false;
138
    }
139
140
    public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
141
    {
142
        return true;
143
    }
144
145
    public Item getItem(World worldIn, BlockPos pos)
146
    {
147
        return null;
148
    }
149
}
150

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