예제 #1
0
  private static EnumFacing getFlippedFacing(final EnumFacing axis, final EnumFacing side) {
    if (axis.getAxis() == side.getAxis()) {
      return side.getOpposite();
    }

    return side;
  }
예제 #2
0
 @Override
 public boolean canConnectRedstone(EnumFacing direction) {
   if (side.getAxis() != direction.getAxis()) {
     EnumFacing dir = realToGate(direction);
     if (isSideOpen(dir)) {
       return getType(dir).isRedstone();
     }
   }
   return false;
 }
예제 #3
0
 @Override
 public boolean rotatePart(EnumFacing axis) {
   if (axis.getAxis() == side.getAxis()) {
     if (axis.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE) {
       top = top.rotateY();
     } else {
       top = top.rotateYCCW();
     }
     return true;
   }
   return false;
 }
예제 #4
0
 @Override
 public boolean canConnect(WireType type, WireFace face, EnumFacing direction) {
   if (face.facing == side && direction.getAxis() != side.getAxis()) {
     EnumFacing dir = realToGate(direction);
     if (isSideOpen(dir)) {
       Connection conn = getType(dir);
       if (conn.isRedstone()) {
         return type != WireType.BUNDLED;
       } else if (conn.isBundled()) {
         return type == WireType.BUNDLED;
       }
     }
   }
   return false;
 }
예제 #5
0
  @SideOnly(Side.CLIENT)
  public void randomDisplayTick(World pos, BlockPos state, IBlockState worldIn, Random rand) {
    EnumFacing enumfacing = (EnumFacing) worldIn.getValue(FACING);
    double d0 = (double) state.getX() + 0.5D;
    double d1 = (double) state.getY() + 0.7D;
    double d2 = (double) state.getZ() + 0.5D;
    double d3 = 0.22D;
    double d4 = 0.27D;

    if (enumfacing.getAxis().isHorizontal()) {
      EnumFacing enumfacing1 = enumfacing.getOpposite();
      pos.spawnParticle(
          EnumParticleTypes.SPELL_MOB_AMBIENT,
          d0 + d4 * (double) enumfacing1.getFrontOffsetX(),
          d1 + d3,
          d2 + d4 * (double) enumfacing1.getFrontOffsetZ(),
          0.0D,
          5.0D,
          0.0D,
          new int[0]);
      pos.spawnParticle(
          EnumParticleTypes.REDSTONE,
          d0 + d4 * (double) enumfacing1.getFrontOffsetX(),
          d1 + d3,
          d2 + d4 * (double) enumfacing1.getFrontOffsetZ(),
          -9.0D,
          9.0D,
          -9.0D,
          new int[0]);
    } else {
      pos.spawnParticle(
          EnumParticleTypes.SPELL_MOB_AMBIENT, d0, d1, d2, 0.0D, 5.0D, 0.0D, new int[0]);
      pos.spawnParticle(EnumParticleTypes.REDSTONE, d0, d1, d2, -9.0D, 9.0D, -9.0D, new int[0]);
    }
  }
예제 #6
0
 protected void func_174859_a(EnumFacing p_174859_1_) {
   Validate.notNull(p_174859_1_);
   Validate.isTrue(p_174859_1_.getAxis().isHorizontal());
   this.field_174860_b = p_174859_1_;
   this.prevRotationYaw =
       this.rotationYaw = (float) (this.field_174860_b.getHorizontalIndex() * 90);
   this.func_174856_o();
 }
예제 #7
0
  public EnumFacing gateToReal(EnumFacing dir) {
    if (dir.getAxis() == EnumFacing.Axis.Y) {
      return null;
    }

    if (dir.getAxis() == EnumFacing.Axis.X && mirrored) {
      dir = dir.getOpposite();
    }

    EnumFacing itop = top;
    while (itop != EnumFacing.NORTH) {
      dir = dir.rotateY();
      itop = itop.rotateYCCW();
    }

    return CONNECTION_DIRS[side.ordinal()][dir.ordinal() - 2];
  }
예제 #8
0
  public int rotateVertex(EnumFacing facing, int vertexIndex) {
    int i = vertexIndex;

    if (facing.getAxis() == EnumFacing.Axis.X) {
      i = (vertexIndex + this.quartersX) % 4;
    }

    EnumFacing enumfacing = facing;

    for (int j = 0; j < this.quartersX; ++j) {
      enumfacing = enumfacing.rotateAround(EnumFacing.Axis.X);
    }

    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
      i = (i + this.quartersY) % 4;
    }

    return i;
  }
예제 #9
0
  /** Convert the given metadata into a BlockState for this Block */
  @Override
  public IBlockState getStateFromMeta(int meta) {
    EnumFacing enumfacing = EnumFacing.getFront(meta % 6);

    if (enumfacing.getAxis() == EnumFacing.Axis.Y) {
      enumfacing = EnumFacing.NORTH;
    }
    // System.out.println("getState");
    return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(ACTIVE, meta > 5);
  }
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    IBlockState iblockstate = world.getBlockState(pos);
    Block localBlock = iblockstate.getBlock();
    BlockPos posThere = pos;
    BlockPos posOffset = pos.offset(side);

    if (localBlock == Blocks.snow_layer && localBlock.isReplaceable(world, pos))
      side = EnumFacing.UP;
    else if (!localBlock.isReplaceable(world, pos)) pos = pos.offset(side);

    TileEntityIESlab stackSlab = null;
    if (side.getAxis().isVertical()
        && this.block.equals(world.getBlockState(posThere).getBlock())
        && world.getBlockState(posThere).getBlock().getMetaFromState(world.getBlockState(posThere))
            == stack.getItemDamage()) {
      TileEntity te = world.getTileEntity(posThere);
      if (te instanceof TileEntityIESlab && ((TileEntityIESlab) te).slabType + side.ordinal() == 1)
        stackSlab = ((TileEntityIESlab) te);
    } else if (this.block.equals(world.getBlockState(posOffset).getBlock())
        && world
                .getBlockState(posOffset)
                .getBlock()
                .getMetaFromState(world.getBlockState(posOffset))
            == stack.getItemDamage()) {
      TileEntity te = world.getTileEntity(posOffset);
      if (te instanceof TileEntityIESlab) {
        int type = ((TileEntityIESlab) te).slabType;
        if ((type == 0 && (side == EnumFacing.DOWN || hitY >= .5))
            || (type == 1 && (side == EnumFacing.UP || hitY <= .5)))
          stackSlab = ((TileEntityIESlab) te);
      }
    } else return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ);
    if (stackSlab != null) {
      stackSlab.slabType = 2;
      world.markBlockForUpdate(stackSlab.getPos());
      world.playSoundEffect(
          stackSlab.getPos().getX() + .5,
          stackSlab.getPos().getY() + .5,
          stackSlab.getPos().getZ() + .5,
          this.block.stepSound.getPlaceSound(),
          (this.block.stepSound.getVolume() + 1.0F) / 2.0F,
          this.block.stepSound.getFrequency() * 0.8F);
      --stack.stackSize;
      return true;
    } else return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ);
  }
예제 #11
0
  public EnumFacing realToGate(EnumFacing rdir) {
    if (rdir.getAxis() == side.getAxis()) {
      return null;
    }

    for (int i = 0; i < 4; i++) {
      if (CONNECTION_DIRS[side.ordinal()][i] == rdir) {
        EnumFacing dir = EnumFacing.getFront(i + 2);
        EnumFacing itop = top;
        while (itop != EnumFacing.NORTH) {
          dir = dir.rotateYCCW();
          itop = itop.rotateYCCW();
        }
        if (dir.getAxis() == EnumFacing.Axis.X && mirrored) {
          return dir.getOpposite();
        } else {
          return dir;
        }
      }
    }

    return null;
  }
예제 #12
0
  public EnumFacing rotateFace(EnumFacing p_177523_1_) {
    EnumFacing enumfacing = p_177523_1_;

    for (int i = 0; i < this.quartersX; ++i) {
      enumfacing = enumfacing.rotateAround(EnumFacing.Axis.X);
    }

    if (enumfacing.getAxis() != EnumFacing.Axis.Y) {
      for (int j = 0; j < this.quartersY; ++j) {
        enumfacing = enumfacing.rotateAround(EnumFacing.Axis.Y);
      }
    }

    return enumfacing;
  }
예제 #13
0
  private static BlockLever.EnumOrientation getFlippedLeverFacing(
      final EnumFacing source, final BlockLever.EnumOrientation side) {
    if (source.getAxis() != side.getFacing().getAxis()) {
      return side;
    }

    final EnumFacing facing;
    if (side == BlockLever.EnumOrientation.UP_Z || side == BlockLever.EnumOrientation.DOWN_Z) {
      facing = EnumFacing.NORTH;
    } else if (side == BlockLever.EnumOrientation.UP_X
        || side == BlockLever.EnumOrientation.DOWN_X) {
      facing = EnumFacing.WEST;
    } else {
      facing = side.getFacing();
    }

    final EnumFacing facingFlipped = getFlippedFacing(source, side.getFacing());
    return BlockLever.EnumOrientation.forFacings(facingFlipped, facing);
  }
  public static void doDispense(
      World worldIn, ItemStack stack, int speed, EnumFacing p_82486_3_, IPosition position) {
    double var5 = position.getX();
    double var7 = position.getY();
    double var9 = position.getZ();
    if (p_82486_3_.getAxis() == EnumFacing.Axis.Y) {
      var7 -= 0.125D;
    } else {
      var7 -= 0.15625D;
    }

    EntityItem var11 = new EntityItem(worldIn, var5, var7, var9, stack);
    double var12 = worldIn.rand.nextDouble() * 0.1D + 0.2D;
    var11.motionX = (double) p_82486_3_.getFrontOffsetX() * var12;
    var11.motionY = 0.20000000298023224D;
    var11.motionZ = (double) p_82486_3_.getFrontOffsetZ() * var12;
    var11.motionX += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double) speed;
    var11.motionY += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double) speed;
    var11.motionZ += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double) speed;
    worldIn.spawnEntityInWorld(var11);
  }
예제 #15
0
  public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    if (((Boolean) state.getValue(WET_PROP)).booleanValue()) {
      EnumFacing var5 = EnumFacing.random(rand);

      if (var5 != EnumFacing.UP && !World.doesBlockHaveSolidTopSurface(worldIn, pos.offset(var5))) {
        double var6 = (double) pos.getX();
        double var8 = (double) pos.getY();
        double var10 = (double) pos.getZ();

        if (var5 == EnumFacing.DOWN) {
          var8 -= 0.05D;
          var6 += rand.nextDouble();
          var10 += rand.nextDouble();
        } else {
          var8 += rand.nextDouble() * 0.8D;

          if (var5.getAxis() == EnumFacing.Axis.X) {
            var10 += rand.nextDouble();

            if (var5 == EnumFacing.EAST) {
              ++var6;
            } else {
              var6 += 0.05D;
            }
          } else {
            var6 += rand.nextDouble();

            if (var5 == EnumFacing.SOUTH) {
              ++var10;
            } else {
              var10 += 0.05D;
            }
          }
        }

        worldIn.spawnParticle(
            EnumParticleTypes.DRIP_WATER, var6, var8, var10, 0.0D, 0.0D, 0.0D, new int[0]);
      }
    }
  }