Guest User

Untitled

a guest
Jun 16th, 2017
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. public class BlockANDGate extends Block {
  2.     private boolean isOn;
  3.    
  4.     public BlockANDGate() {
  5.         super(Material.ROCK);
  6.         setUnlocalizedName(Reference.Blocks.ANDGATE.getUnlocalizedName());
  7.         setRegistryName(Reference.Blocks.ANDGATE.getRegistryName());
  8.         this.setCreativeTab(CreativeTabs.REDSTONE);
  9.     }
  10.    
  11.     @Override
  12.     public boolean canProvidePower(IBlockState state) {
  13.         return true;
  14.     }
  15.    
  16.     @Override
  17.     public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  18.         return this.isOn && side == EnumFacing.SOUTH ? 15 : 0;
  19.     }
  20.    
  21.     @Override
  22.     public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
  23.         IBlockState neighborstate = world.getBlockState(neighbor);
  24.         if (neighborstate.canProvidePower()) {
  25.             if (neighborstate.getWeakPower(world, pos, EnumFacing.WEST) > 0 || neighborstate.getWeakPower(world, pos, EnumFacing.EAST) > 0) {
  26.                 isOn = true;
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment