@Override
 public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
   if (side != null) return ImmutableList.of();
   IExtendedBlockState exState = (IExtendedBlockState) state;
   int len = cubeSize * 5 + 1;
   List<BakedQuad> ret = new ArrayList<BakedQuad>();
   for (EnumFacing f : EnumFacing.values()) {
     ret.add(createSidedBakedQuad(0, 1, 0, 1, 1, base, f));
     if (state != null) {
       for (int i = 0; i < cubeSize; i++) {
         for (int j = 0; j < cubeSize; j++) {
           Integer value = exState.getValue(properties[f.ordinal()]);
           if (value != null && (value & (1 << (i * cubeSize + j))) != 0) {
             ret.add(
                 createSidedBakedQuad(
                     (float) (1 + i * 5) / len,
                     (float) (5 + i * 5) / len,
                     (float) (1 + j * 5) / len,
                     (float) (5 + j * 5) / len,
                     1.0001f,
                     overlay,
                     f));
           }
         }
       }
     }
   }
   return ret;
 }
Example #2
0
 private static int[] getCorners(Optional<IExtendedBlockState> stateOption) {
   int[] cornerRound = new int[] {0, 0, 0, 0};
   if (stateOption.isPresent()) {
     IExtendedBlockState state = stateOption.get();
     for (int i = 0; i < 4; i++) {
       Float level = state.getValue(BlockFluidBase.LEVEL_CORNERS[i]);
       cornerRound[i] = Math.round((level == null ? 7f / 8 : level) * 768);
     }
   }
   return cornerRound;
 }
Example #3
0
  @Override
  public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos) {
    if (stateIn.getBlock() == null || stateIn.getBlock().getMaterial() == Material.air) {
      return stateIn;
    }
    IExtendedBlockState state = (IExtendedBlockState) stateIn;
    Variation v =
        ((BlockCarvable) state.getBlock())
            .getType()
            .getVariants()[state.getBlock().getMetaFromState(state)];
    IBlockResources res = SubBlockUtil.getResources(state.getBlock(), v);
    if (res.getType() == IBlockResources.V4 || res.getType() == IBlockResources.V9) {
      int variationSize = BlockResources.getVariationWidth(res.getType());
      int xModulus = Math.abs(pos.getX() % variationSize);
      int zModulus = Math.abs(pos.getZ() % variationSize);
      int yModules = Math.abs(pos.getY() % variationSize);
      return state
          .withProperty(XMODULES, xModulus)
          .withProperty(YMODULES, yModules)
          .withProperty(ZMODULES, zModulus);
    } else if (res.getType() == IBlockResources.NORMAL
        || res.getType() == IBlockResources.R9
        || res.getType() == IBlockResources.R4
        || res.getType() == IBlockResources.R16) {
      return stateIn;
    }

    boolean up = false;
    boolean down = false;
    boolean north = false;
    boolean south = false;
    boolean east = false;
    boolean west = false;
    boolean north_east = false;
    boolean north_west = false;
    boolean north_up = false;
    boolean north_down = false;
    boolean south_east = false;
    boolean south_west = false;
    boolean south_up = false;
    boolean south_down = false;
    boolean east_up = false;
    boolean east_down = false;
    boolean west_up = false;
    boolean west_down = false;

    if (areBlocksEqual(state, w.getBlockState(pos.up()))) {
      up = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.down()))) {
      down = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.north()))) {
      north = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.south()))) {
      south = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.east()))) {
      east = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.west()))) {
      west = true;
    }

    if (areBlocksEqual(state, w.getBlockState(pos.north().east()))) {
      north_east = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.north().west()))) {
      north_west = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.north().up()))) {
      north_up = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.north().down()))) {
      north_down = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.south().east()))) {
      south_east = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.south().west()))) {
      south_west = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.south().up()))) {
      south_up = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.south().down()))) {
      south_down = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.east().up()))) {
      east_up = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.east().down()))) {
      east_down = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.west().up()))) {
      west_up = true;
    }
    if (areBlocksEqual(state, w.getBlockState(pos.west().down()))) {
      west_down = true;
    }

    return state
        .withProperty(CONNECTED_UP, up)
        .withProperty(CONNECTED_DOWN, down)
        .withProperty(CONNECTED_NORTH, north)
        .withProperty(CONNECTED_SOUTH, south)
        .withProperty(CONNECTED_EAST, east)
        .withProperty(CONNECTED_WEST, west)
        .withProperty(CONNECTED_NORTH_EAST, north_east)
        .withProperty(CONNECTED_NORTH_WEST, north_west)
        .withProperty(CONNECTED_NORTH_UP, north_up)
        .withProperty(CONNECTED_NORTH_DOWN, north_down)
        .withProperty(CONNECTED_SOUTH_EAST, south_east)
        .withProperty(CONNECTED_SOUTH_WEST, south_west)
        .withProperty(CONNECTED_SOUTH_UP, south_up)
        .withProperty(CONNECTED_SOUTH_DOWN, south_down)
        .withProperty(CONNECTED_EAST_UP, east_up)
        .withProperty(CONNECTED_EAST_DOWN, east_down)
        .withProperty(CONNECTED_WEST_UP, west_up)
        .withProperty(CONNECTED_WEST_DOWN, west_down);
  }