1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
package ihl.enviroment;
import java.util.Random;
import cpw.mods.fml.common.registry.GameRegistry;
import ihl.IHLCreativeTab;
import ihl.items_blocks.IHLItemBlock;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class LightBulbBlock extends Block implements ITileEntityProvider
{
public static GlowningAirBlock glowningAir;
public LightBulbBlock(String unlocalizedName1)
{
super(Material.glass);
this.setStepSound(soundTypeGlass);
this.setBlockName(unlocalizedName1);
GameRegistry.registerBlock(this,IHLItemBlock.class, unlocalizedName1);
this.setHardness(0.3F);
this.setResistance(0.5F);
this.setCreativeTab(IHLCreativeTab.tab);
this.setBlockTextureName("glass");
}
@Override
public boolean hasTileEntity(int metadata)
{
return true;
}
public static void init()
{
glowningAir = new GlowningAirBlock();
new LightBulbBlock("lightBulb");
new SpotlightBlock("spotlight");
GameRegistry.registerBlock(glowningAir, "glowningAir");
GameRegistry.registerTileEntity(LightBulbTileEntity.class, "lightBulb");
GameRegistry.registerTileEntity(SpotlightTileEntity.class, "spotlight");
SpotlightTileEntity.createLightSphereVectors();
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random random)
{
return 0;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType()
{
return -2;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z)
{
TileEntity te = iBlockAccess.getTileEntity(x, y, z);
if(te!=null && te instanceof LightBulbTileEntity)
{
LightBulbTileEntity ate = (LightBulbTileEntity) te;
setBlockBoundsBasedOnFacing(ate.getFacing());
}
}
private void setBlockBoundsBasedOnFacing(int facing)
{
int var2 = facing & 7;
float var6 = 0.1875F;
float var7 = 0.5F;
if (var2 == 0)
{
this.setBlockBounds(0.5F - var6, 1.0F - var7, 0.5F - var6, 0.5F + var6, 1.0F, 0.5F + var6);
}
else if (var2 == 1)
{
this.setBlockBounds(0.5F - var6, 0.0F, 0.5F - var6, 0.5F + var6, var7, 0.5F + var6);
}
else if (var2 == 2)
{
this.setBlockBounds(0.5F - var6, 0.5F - var6, 1.0F - var7, 0.5F + var6, 0.5F + var6, 1.0F);
}
else if (var2 == 3)
{
this.setBlockBounds(0.5F - var6, 0.5F - var6, 0.0F, 0.5F + var6, 0.5F + var6, var7);
}
else if (var2 == 4)
{
this.setBlockBounds(1.0F - var7, 0.5F - var6, 0.5F - var6, 1.0F, 0.5F + var6, 0.5F + var6);
}
else if (var2 == 5)
{
this.setBlockBounds(0.0F, 0.5F - var6, 0.5F - var6, var7, 0.5F + var6, 0.5F + var6);
}
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isNormalCube()
{
return false;
}
@Override
public TileEntity createNewTileEntity(World arg0, int arg1)
{
return new LightBulbTileEntity();
}
}
|