示例#1
0
 public IBlockData getPlacedState(
     World world,
     BlockPosition blockposition,
     EnumDirection enumdirection,
     float f,
     float f1,
     float f2,
     int i,
     EntityLiving entityliving) {
   IBlockData iblockdata = getBlockData().set(POWERED, Boolean.valueOf(false));
   if (a(world, blockposition, enumdirection.opposite())) {
     return iblockdata.set(
         FACING, EnumLeverPosition.a(enumdirection, entityliving.getDirection()));
   }
   Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
   EnumDirection enumdirection1;
   do {
     if (!iterator.hasNext()) {
       if (World.a(world, blockposition.down())) {
         return iblockdata.set(
             FACING, EnumLeverPosition.a(EnumDirection.UP, entityliving.getDirection()));
       }
       return iblockdata;
     }
     enumdirection1 = (EnumDirection) iterator.next();
   } while ((enumdirection1 == enumdirection)
       || (!a(world, blockposition, enumdirection1.opposite())));
   return iblockdata.set(FACING, EnumLeverPosition.a(enumdirection1, entityliving.getDirection()));
 }
示例#2
0
 private Set<EnumDirection> f(World world, BlockPosition blockposition) {
   int i = 1000;
   EnumSet enumset = EnumSet.noneOf(EnumDirection.class);
   Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
   while (iterator.hasNext()) {
     EnumDirection enumdirection = (EnumDirection) iterator.next();
     BlockPosition blockposition1 = blockposition.shift(enumdirection);
     IBlockData iblockdata = world.getType(blockposition1);
     if ((!g(world, blockposition1, iblockdata))
         && ((iblockdata.getBlock().getMaterial() != this.material)
             || (((Integer) iblockdata.get(LEVEL)).intValue() > 0))) {
       int j;
       int j;
       if (g(world, blockposition1.down(), world.getType(blockposition1.down()))) {
         j = a(world, blockposition1, 1, enumdirection.opposite());
       } else {
         j = 0;
       }
       if (j < i) {
         enumset.clear();
       }
       if (j <= i) {
         enumset.add(enumdirection);
         i = j;
       }
     }
   }
   return enumset;
 }
示例#3
0
 private int a(World world, BlockPosition blockposition, int i, EnumDirection enumdirection) {
   int j = 1000;
   Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
   while (iterator.hasNext()) {
     EnumDirection enumdirection1 = (EnumDirection) iterator.next();
     if (enumdirection1 != enumdirection) {
       BlockPosition blockposition1 = blockposition.shift(enumdirection1);
       IBlockData iblockdata = world.getType(blockposition1);
       if ((!g(world, blockposition1, iblockdata))
           && ((iblockdata.getBlock().getMaterial() != this.material)
               || (((Integer) iblockdata.get(LEVEL)).intValue() > 0))) {
         if (!g(world, blockposition1.down(), iblockdata)) {
           return i;
         }
         if (i < 4) {
           int k = a(world, blockposition1, i + 1, enumdirection1.opposite());
           if (k < j) {
             j = k;
           }
         }
       }
     }
   }
   return j;
 }
示例#4
0
  public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (((Boolean) iblockdata.get(POWERED)).booleanValue()) {
      world.applyPhysics(blockposition, this);
      EnumDirection enumdirection = ((EnumLeverPosition) iblockdata.get(FACING)).c();

      world.applyPhysics(blockposition.shift(enumdirection.opposite()), this);
    }
    super.remove(world, blockposition, iblockdata);
  }
  public void doPhysics(World var1, BlockPosition var2, IBlockData var3, Block var4) {
    EnumDirection var5 = (EnumDirection) var3.get(a);
    if (!var1.getType(var2.shift(var5.opposite())).getBlock().getMaterial().isBuildable()) {
      this.dropNaturallyForSure(var1, var2, var3, 0);
      var1.setAir(var2);
    }

    super.doPhysics(var1, var2, var3, var4);
  }
示例#6
0
  protected TileEntityIronChest a(EnumDirection enumdirection) {
    BlockPosition blockposition = this.position.shift(enumdirection);

    if (this.b(blockposition)) {
      TileEntity tileentity = this.world.getTileEntity(blockposition);

      if (tileentity instanceof TileEntityIronChest) {
        TileEntityIronChest tileentitychest = (TileEntityIronChest) tileentity;

        tileentitychest.a(this, enumdirection.opposite());
        return tileentitychest;
      }
    }

    return null;
  }
示例#7
0
  public boolean interact(
      World world,
      BlockPosition blockposition,
      IBlockData iblockdata,
      EntityHuman entityhuman,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    if (world.isClientSide) {
      return true;
    }
    boolean powered = ((Boolean) iblockdata.get(POWERED)).booleanValue();
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    int old = powered ? 15 : 0;
    int current = !powered ? 15 : 0;

    BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
    world.getServer().getPluginManager().callEvent(eventRedstone);
    if ((eventRedstone.getNewCurrent() > 0 ? 1 : 0) != (powered ? 0 : 1)) {
      return true;
    }
    iblockdata = iblockdata.a(POWERED);
    world.setTypeAndData(blockposition, iblockdata, 3);
    world.makeSound(
        blockposition.getX() + 0.5D,
        blockposition.getY() + 0.5D,
        blockposition.getZ() + 0.5D,
        "random.click",
        0.3F,
        ((Boolean) iblockdata.get(POWERED)).booleanValue() ? 0.6F : 0.5F);
    world.applyPhysics(blockposition, this);
    EnumDirection enumdirection1 = ((EnumLeverPosition) iblockdata.get(FACING)).c();

    world.applyPhysics(blockposition.shift(enumdirection1.opposite()), this);
    return true;
  }
示例#8
0
 public boolean canPlace(World world, BlockPosition blockposition, EnumDirection enumdirection) {
   return a(world, blockposition, enumdirection.opposite());
 }