-
Notifications
You must be signed in to change notification settings - Fork 754
/
EquipBlock.java
194 lines (163 loc) · 5.79 KB
/
EquipBlock.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
191
192
193
194
package tconstruct.blocks;
import tconstruct.blocks.logic.EquipLogic;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.util.*;
import cpw.mods.fml.relauncher.*;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.FrypanLogic;
import tconstruct.client.block.FrypanRender;
import mantle.blocks.abstracts.InventoryBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.world.*;
public class EquipBlock extends InventoryBlock
{
public EquipBlock(Material material)
{
super(material);
this.func_149711_c(0.3f);
this.func_149676_a(0, 0, 0, 1, 0.25f, 1);
//this.setCreativeTab(ToolConstruct.materialTab);
}
@Override
public String[] getTextureNames ()
{
return new String[] { "toolstation_top" };
}
public IIcon getIcon (int side, int meta)
{
return Blocks.iron_block.func_149691_a(side, meta);
}
@SideOnly(Side.CLIENT)
public void registerIcons (IIconRegister par1IconRegister)
{
//this.blockIcon = par1iconRegister.registerIcon(Block.blockIron.getUnlocalizedName());
}
@Override
public boolean func_149686_d ()
{
return false;
}
@Override
public boolean func_149662_c ()
{
return false;
}
@Override
public int func_149645_b ()
{
return FrypanRender.frypanModelID;
}
@Override
public int idDropped (int par1, Random par2Random, int par3)
{
return 0;
}
@Override
public TileEntity func_149915_a (World world, int metadata)
{
return new FrypanLogic();
}
public void randomDisplayTick (World world, int x, int y, int z, Random random)
{
if (isActive(world, x, y, z))
{
float f = (float) x + 0.5F;
float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F;
float f2 = (float) z + 0.5F;
float f4 = random.nextFloat() * 0.6F - 0.3F;
world.spawnParticle("smoke", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
}
public void func_149689_a (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
super.func_149689_a(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int newMeta = 0;
switch (i3)
{
case 3:
newMeta = 0;
break;
case 0:
newMeta = 3;
break;
case 1:
newMeta = 1;
break;
case 2:
newMeta = 2;
break;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
}
@Override
public void func_149749_a (World par1World, int x, int y, int z, Block par5, int meta)
{
TileEntity te = par1World.func_147438_o(x, y, z);
if (te != null && te instanceof EquipLogic)
{
EquipLogic logic = (EquipLogic) te;
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
{
ItemStack stack = iter == 0 ? logic.getEquipmentItem() : logic.getStackInSlot(iter);
if (stack != null && logic.canDropInventorySlot(iter))
{
float jumpX = rand.nextFloat() * 0.8F + 0.1F;
float jumpY = rand.nextFloat() * 0.8F + 0.1F;
float jumpZ = rand.nextFloat() * 0.8F + 0.1F;
while (stack.stackSize > 0)
{
int itemSize = rand.nextInt(21) + 10;
if (itemSize > stack.stackSize)
{
itemSize = stack.stackSize;
}
stack.stackSize -= itemSize;
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.getItem(),
itemSize, stack.getItemDamage()));
if (stack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
float offset = 0.05F;
entityitem.motionX = (double) ((float) rand.nextGaussian() * offset);
entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F);
entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset);
par1World.spawnEntityInWorld(entityitem);
}
}
}
}
super.func_149749_a(par1World, x, y, z, par5, meta);
}
public int getLightValue (IBlockAccess world, int x, int y, int z)
{
return !isActive(world, x, y, z) ? 0 : 9;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return TConstruct.proxy.frypanGuiID;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
return new FrypanLogic();
}
}