-
Notifications
You must be signed in to change notification settings - Fork 753
/
MeatBlock.java
190 lines (166 loc) · 4.97 KB
/
MeatBlock.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package tconstruct.blocks;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWood;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import tconstruct.library.TConstructRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class MeatBlock extends BlockWood
{
public IIcon[] icons;
public String[] textureNames = new String[] { "ham_skin", "ham_bone" };
public MeatBlock()
{
this.setHardness(1.0F);
this.setStepSound(Block.soundTypeWood);
//setBurnProperties(this.blockID, 5, 20);
this.setCreativeTab(TConstructRegistry.blockTab);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int metadata)
{
int tex = (metadata % 4) * 2;
int orientation = metadata / 4;
switch (orientation)
//Ends of logs
{
case 0:
if (side == 0 || side == 1)
return icons[tex + 1];
break;
case 1:
if (side == 4 || side == 5)
return icons[tex + 1];
break;
case 2:
if (side == 2 || side == 3)
return icons[tex + 1];
break;
}
return icons[tex];
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
public Item getItemDropped (int par1, Random par2Random, int par3)
{
return new ItemStack(this).getItem();
}
/**
* ejects contained items into the world, and notifies neighbours of an update, as appropriate
*/
public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6)
{
byte b0 = 4;
int j1 = b0 + 1;
if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
{
for (int k1 = -b0; k1 <= b0; ++k1)
{
for (int l1 = -b0; l1 <= b0; ++l1)
{
for (int i2 = -b0; i2 <= b0; ++i2)
{
Block j2 = par1World.getBlock(par2 + k1, par3 + l1, par4 + i2);
if (j2 != null)
{
j2.beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
}
}
}
}
}
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
int j1 = par9 & 3;
byte b0 = 0;
switch (par5)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped (int par1)
{
return par1 & 3;
}
/**
* returns a number between 0 and 3
*/
public static int limitToValidMetadata (int par0)
{
return par0 & 3;
}
protected ItemStack createStackedBlock (int par1)
{
return new ItemStack(this, 1, limitToValidMetadata(par1));
}
public boolean isBlockReplaceable (World world, int x, int y, int z)
{
return false;
}
/*public void onBlockHarvested (World world, int x, int y, int z, int meta, EntityPlayer player)
{
if (meta % 4 == 1)
{
if (world.difficultySetting > 2)
world.createExplosion(null, x, y, z, 1.75f, false);
else
world.createExplosion(null, x, y, z, 2f, false);
}
}*/
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks (Item b, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < icons.length / 2; i++)
par3List.add(new ItemStack(b, 1, i));
}
// @Override
// public boolean canSustainLeaves (World world, int x, int y, int z)
// {
// return true;
// }
//
// @Override
// public boolean isWood (World world, int x, int y, int z)
// {
// return true;
// }
public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
{
return true;
}
}