-
Notifications
You must be signed in to change notification settings - Fork 497
/
BlockBuildCraft.java
49 lines (40 loc) · 1.5 KB
/
BlockBuildCraft.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
package buildcraft.core;
import buildcraft.core.utils.Utils;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class BlockBuildCraft extends BlockContainer {
protected static boolean keepInventory = false;
protected final Random rand = new Random();
protected BlockBuildCraft(Material material) {
super(material);
setCreativeTab(CreativeTabBuildCraft.MACHINES.get());
setHardness(5F);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, entity, stack);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileBuildCraft) {
((TileBuildCraft) tile).onBlockPlacedBy(entity, stack);
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
Utils.preDestroyBlock(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IMachine && ((IMachine) tile).isActive())
return super.getLightValue(world, x, y, z) + 8;
return super.getLightValue(world, x, y, z);
}
}