-
Notifications
You must be signed in to change notification settings - Fork 41
/
BlockRedstoneInterface.java
53 lines (45 loc) · 1.46 KB
/
BlockRedstoneInterface.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
package lumien.randomthings.block;
import java.util.HashSet;
import lumien.randomthings.tileentity.redstoneinterface.TileEntityRedstoneInterface;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class BlockRedstoneInterface extends BlockContainerBase
{
protected BlockRedstoneInterface(String name, Material materialIn)
{
super(name, materialIn);
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
static HashSet<BlockPos> notifiedPositions = new HashSet<BlockPos>();
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block neighborBlock)
{
if (notifiedPositions.contains(pos))
{
return;
}
TileEntity te;
if ((te = worldIn.getTileEntity(pos)) instanceof TileEntityRedstoneInterface)
{
notifiedPositions.add(pos);
TileEntityRedstoneInterface teInterface = (TileEntityRedstoneInterface) te;
teInterface.neighborChanged(state, worldIn, pos, neighborBlock);
notifiedPositions.remove(pos);
}
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
((TileEntityRedstoneInterface) worldIn.getTileEntity(pos)).broken();
super.breakBlock(worldIn, pos, state);
}
}