Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BlockANDGate extends Block {
- private boolean isOn;
- public BlockANDGate() {
- super(Material.ROCK);
- setUnlocalizedName(Reference.Blocks.ANDGATE.getUnlocalizedName());
- setRegistryName(Reference.Blocks.ANDGATE.getRegistryName());
- this.setCreativeTab(CreativeTabs.REDSTONE);
- }
- @Override
- public boolean canProvidePower(IBlockState state) {
- return true;
- }
- @Override
- public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
- return this.isOn && side == EnumFacing.SOUTH ? 15 : 0;
- }
- @Override
- public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
- IBlockState neighborstate = world.getBlockState(neighbor);
- if (neighborstate.canProvidePower()) {
- if (neighborstate.getWeakPower(world, pos, EnumFacing.WEST) > 0 || neighborstate.getWeakPower(world, pos, EnumFacing.EAST) > 0) {
- isOn = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment