-
Notifications
You must be signed in to change notification settings - Fork 754
/
ConveyorBase.java
158 lines (138 loc) · 4.02 KB
/
ConveyorBase.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
package tconstruct.blocks;
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.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tconstruct.client.block.SlimeChannelRender;
import tconstruct.library.TConstructRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ConveyorBase extends MantleBlock
{
String texturename;
public ConveyorBase(Material material, String name)
{
super(material);
this.func_149647_a(TConstructRegistry.blockTab);
func_149676_a(0f, 0f, 0f, 1f, 0.5f, 1f);
texturename = name;
}
public boolean isBlockReplaceable (World world, int x, int y, int z)
{
return false;
}
@Override
public AxisAlignedBB func_149668_a (World world, int x, int y, int z)
{
return null;
}
@Override
public void func_149670_a (World world, int x, int y, int z, Entity entity)
{
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
{
double moveX = 0;
double moveZ = 0;
double speed = 0.01;
int meta = world.getBlockMetadata(x, y, z);
switch (meta % 8)
{
case 6:
moveX += speed;
break;
case 7:
moveX += speed;
moveZ += speed;
break;
case 0:
moveZ += speed;
break;
case 1:
moveZ += speed;
moveX -= speed;
break;
case 2:
moveX -= speed;
break;
case 3:
moveX -= speed;
moveZ -= speed;
break;
case 4:
moveZ -= speed;
break;
case 5:
moveZ -= speed;
moveX += speed;
break;
}
entity.addVelocity(moveX, 0, moveZ);
}
if (entity instanceof EntityItem)
{
((EntityItem) entity).age = 0;
}
}
@Override
public void func_149689_a (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
{
int face = MathHelper.floor_double((double) (entity.rotationYaw * 8.0F / 360.0F) + 0.5D) + (entity.isSneaking() ? 4 : 0) & 7;
int meta = world.getBlockMetadata(x, y, z) & 8;
world.setBlockMetadataWithNotify(x, y, z, face | meta, 2);
}
public boolean func_149646_a (IBlockAccess world, int x, int y, int z, int side)
{
if (side == 1)
return false;
return super. func_149646_a(world, x, y, z, side);
}
public IIcon[] icons;
/* Rendering */
@Override
public boolean func_149686_d ()
{
return false;
}
@Override
public boolean func_149662_c ()
{
return false;
}
@Override
public int func_149701_w ()
{
return 1;
}
@Override
public int func_149645_b ()
{
return SlimeChannelRender.model;
}
@Override
public void func_149651_a (IIconRegister iconRegister)
{
String[] textureNames = new String[] { texturename, texturename + "_flow" };
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon func_149691_a (int side, int meta)
{
if (meta >= 8)
return icons[0];
return side == 1 ? icons[1] : icons[0];
}
}