-
Notifications
You must be signed in to change notification settings - Fork 754
/
SlabBase.java
109 lines (93 loc) · 2.89 KB
/
SlabBase.java
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
package tconstruct.blocks;
import java.util.List;
import mantle.blocks.MantleBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tconstruct.library.TConstructRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SlabBase extends MantleBlock
{
Block modelBlock;
int startingMeta;
int totalSize;
public SlabBase(Material material)
{
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
}
public SlabBase(Material material, Block model, int meta, int totalSize)
{
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.modelBlock = model;
this.startingMeta = meta;
this.totalSize = totalSize;
}
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
{
setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
public void setBlockBoundsForItemRender ()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z) / 8;
float minY = meta == 1 ? 0.5F : 0.0F;
float maxY = meta == 1 ? 1.0F : 0.5F;
setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
}
public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata)
{
if (side == 1)
return metadata;
if (side == 0 || clickY >= 0.5F)
return metadata | 8;
return metadata;
}
public boolean isOpaqueCube ()
{
return false;
}
public boolean renderAsNormalBlock ()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
meta = meta % 8 + startingMeta;
return modelBlock.getIcon(side, meta);
}
@Override
public void getSubBlocks (Item b, CreativeTabs tab, List list)
{
for (int iter = 0; iter < totalSize; iter++)
{
list.add(new ItemStack(b, 1, iter));
}
}
public int damageDropped (int meta)
{
return meta % 8;
}
}