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
|
package common.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import gregtech.api.GregTech_API;
/**
* Any blocks that are used as structure parts for GregTech multi machines have to inherit from this class. Otherwise
* the checkMachine() method that verifies a machine's structure won't be called correctly.
*/
public abstract class BaseGTUpdateableBlock extends Block {
protected BaseGTUpdateableBlock(Material material) {
super(material);
GregTech_API.registerMachineBlock(this, -1);
super.setHarvestLevel("wrench", 2);
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
return false;
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
return false;
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;
}
@Override
public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
}
}
@Override
public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {
if (GregTech_API.isMachineBlock(this, aMetaData)) {
GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
}
}
}
|