Пример #1
0
  public BlockPattern.PatternHelper func_177681_a(World p_177681_1_, BlockPos p_177681_2_) {
    LoadingCache var3 = CacheBuilder.newBuilder().build(new BlockPattern.CacheLoader(p_177681_1_));
    int var4 = Math.max(Math.max(this.field_177686_d, this.field_177688_c), this.field_177687_b);
    Iterator var5 =
        BlockPos.func_177980_a(p_177681_2_, p_177681_2_.func_177982_a(var4 - 1, var4 - 1, var4 - 1))
            .iterator();

    while (var5.hasNext()) {
      BlockPos var6 = (BlockPos) var5.next();
      EnumFacing[] var7 = EnumFacing.values();
      int var8 = var7.length;

      for (int var9 = 0; var9 < var8; ++var9) {
        EnumFacing var10 = var7[var9];
        EnumFacing[] var11 = EnumFacing.values();
        int var12 = var11.length;

        for (int var13 = 0; var13 < var12; ++var13) {
          EnumFacing var14 = var11[var13];
          if (var14 != var10 && var14 != var10.func_176734_d()) {
            BlockPattern.PatternHelper var15 = this.func_177682_a(var6, var10, var14, var3);
            if (var15 != null) {
              return var15;
            }
          }
        }
      }
    }

    return null;
  }
 public IBlockState getStateFromMeta(int meta) {
   if (meta <= 5) {
     return this.getDefaultState()
         .withProperty(
             FACING,
             EnumFacing.values()[meta].getAxis() == EnumFacing.Axis.Y
                 ? EnumFacing.NORTH
                 : EnumFacing.values()[meta])
         .withProperty(OPEN, false);
   } else {
     return this.getDefaultState()
         .withProperty(FACING, EnumFacing.values()[meta - 6])
         .withProperty(OPEN, true);
   }
 }
Пример #3
0
  public int findPathOptions(
      PathPoint[] pathOptions,
      Entity entityIn,
      PathPoint currentPoint,
      PathPoint targetPoint,
      float maxDistance) {
    int i = 0;

    for (EnumFacing enumfacing : EnumFacing.values()) {
      PathPoint pathpoint =
          this.getSafePoint(
              entityIn,
              currentPoint.xCoord + enumfacing.getFrontOffsetX(),
              currentPoint.yCoord + enumfacing.getFrontOffsetY(),
              currentPoint.zCoord + enumfacing.getFrontOffsetZ());

      if (pathpoint != null
          && !pathpoint.visited
          && pathpoint.distanceTo(targetPoint) < maxDistance) {
        pathOptions[i++] = pathpoint;
      }
    }

    return i;
  }
 static {
   for (EnumFacing f : EnumFacing.values()) {
     properties[f.ordinal()] =
         Properties.toUnlisted(
             PropertyInteger.create(f.getName(), 0, (1 << (cubeSize * cubeSize)) - 1));
   }
 }
 @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;
 }
Пример #6
0
  private int func_175629_a(EnumSkyBlock p_175629_1_, BlockPos p_175629_2_) {
    if (p_175629_1_ == EnumSkyBlock.SKY && this.worldObj.provider.getHasNoSky()) {
      return 0;
    } else if (p_175629_2_.getY() >= 0 && p_175629_2_.getY() < 256) {
      int var3;

      if (this.getBlockState(p_175629_2_).getBlock().getUseNeighborBrightness()) {
        var3 = 0;
        EnumFacing[] var9 = EnumFacing.values();
        int var5 = var9.length;

        for (int var6 = 0; var6 < var5; ++var6) {
          EnumFacing var7 = var9[var6];
          int var8 = this.func_175628_b(p_175629_1_, p_175629_2_.offset(var7));

          if (var8 > var3) {
            var3 = var8;
          }

          if (var3 >= 15) {
            return var3;
          }
        }

        return var3;
      } else {
        var3 = (p_175629_2_.getX() >> 4) - this.chunkX;
        int var4 = (p_175629_2_.getZ() >> 4) - this.chunkZ;
        return this.chunkArray[var3][var4].getLightFor(p_175629_1_, p_175629_2_);
      }
    } else {
      return p_175629_1_.defaultLightValue;
    }
  }
Пример #7
0
 private void runThroughNetwork(BlockPos pos) {
   for (EnumFacing facing : EnumFacing.values()) {
     BlockPos searchPos = pos.offset(facing);
     if (worldObj.getTileEntity(pos) instanceof INetworkPart
         && !((INetworkPart) worldObj.getTileEntity(pos)).getNeighborFaces().contains(facing))
       continue;
     if (worldObj.getTileEntity(searchPos) instanceof INetworkPart
         && !((INetworkPart) worldObj.getTileEntity(searchPos))
             .getNeighborFaces()
             .contains(facing.getOpposite())) continue;
     if (!getWorld().isAirBlock(searchPos)) {
       TileEntity tile = getWorld().getTileEntity(searchPos);
       if (tile != null) {
         if (tile instanceof TileNetworkCore && !tile.getPos().equals(this.pos)) {
           worldObj.setBlockToAir(searchPos);
           worldObj.playEvent(2001, searchPos, Block.getIdFromBlock(Registry.networkCore));
           StackHelper.spawnItemStack(worldObj, searchPos, new ItemStack(Registry.networkCore));
           markForNetworkInit();
         } else if (tile instanceof INetworkPart && !network.networkParts.contains(tile)) {
           network.addPart((INetworkPart) tile);
         } else if (InvHelper.hasItemHandler(tile, facing.getOpposite())
             && !network.networkParts.contains(
                 InvHelper.getItemHandler(tile, facing.getOpposite()))) {
           network.addPart(
               new InventoryNetworkPart(
                   tile.getWorld(),
                   searchPos,
                   InvHelper.getItemHandler(tile, facing.getOpposite())));
         } else continue;
         runThroughNetwork(searchPos);
       }
     }
   }
 }
Пример #8
0
  public static int getBlacklistBiomeIDWithinRange(World world, int x, int z, int radius) {
    FRLog.debug("Checking Biomes...");
    float reciprocalRootOf2 = 0.70710678f;
    int adjRadius = Math.round(radius * reciprocalRootOf2);
    BlockPos pos = new BlockPos(x, 64, z);
    EnumFacing[] NSEW = EnumFacing.values();

    int biomeID = world.getBiomeGenForCoords(pos).biomeID;
    if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID;

    for (EnumFacing fd : NSEW) {
      for (int i = radius; i > 0; i = i - 2) {
        biomeID = world.getBiomeGenForCoords(pos.offset(fd, i)).biomeID;
        if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID;
      }
    }

    for (int ns = 0; ns < 2; ns++)
      for (int ew = 2; ew < 4; ew++)
        for (int r = adjRadius; r > 0; r = r - 2) {
          biomeID = world.getBiomeGenForCoords(pos.offset(NSEW[ns], r).offset(NSEW[ew], r)).biomeID;
          if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID;
        }

    return -1;
  }
Пример #9
0
  public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
    for (EnumFacing enumfacing : EnumFacing.values()) {
      if (func_181088_a(worldIn, pos, enumfacing)) {
        return true;
      }
    }

    return false;
  }
  public void func_180663_b(World p_180663_1_, BlockPos p_180663_2_, IBlockState p_180663_3_) {
    if (this.field_150113_a) {
      EnumFacing[] var4 = EnumFacing.values();
      int var5 = var4.length;

      for (int var6 = 0; var6 < var5; ++var6) {
        EnumFacing var7 = var4[var6];
        p_180663_1_.func_175685_c(p_180663_2_.func_177972_a(var7), this);
      }
    }
  }
  public void func_176206_d(World p_176206_1_, BlockPos p_176206_2_, IBlockState p_176206_3_) {
    if (this.field_149914_a) {
      EnumFacing[] var4 = EnumFacing.values();
      int var5 = var4.length;

      for (int var6 = 0; var6 < var5; ++var6) {
        EnumFacing var7 = var4[var6];
        p_176206_1_.func_175685_c(p_176206_2_.func_177972_a(var7), this);
      }
    }

    super.func_176206_d(p_176206_1_, p_176206_2_, p_176206_3_);
  }
Пример #12
0
  private boolean shouldBeExtended(World worldIn, BlockPos pos, EnumFacing facing) {
    for (EnumFacing enumfacing : EnumFacing.values()) {
      if (enumfacing != facing && worldIn.isSidePowered(pos.offset(enumfacing), enumfacing)) {
        return true;
      }
    }

    if (worldIn.isSidePowered(pos, EnumFacing.DOWN)) {
      return true;
    } else {
      BlockPos blockpos = pos.up();

      for (EnumFacing enumfacing1 : EnumFacing.values()) {
        if (enumfacing1 != EnumFacing.DOWN
            && worldIn.isSidePowered(blockpos.offset(enumfacing1), enumfacing1)) {
          return true;
        }
      }

      return false;
    }
  }
Пример #13
0
  protected boolean isSurroundingBlockFlammable(World worldIn, BlockPos p_176369_2_) {
    EnumFacing[] var3 = EnumFacing.values();
    int var4 = var3.length;

    for (int var5 = 0; var5 < var4; ++var5) {
      EnumFacing var6 = var3[var5];

      if (this.getCanBlockBurn(worldIn, p_176369_2_.offset(var6))) {
        return true;
      }
    }

    return false;
  }
Пример #14
0
  /**
   * Gets a list of all capabilities that touch a BlockPos. This will search for tile entities
   * touching the BlockPos and then query them for access to their capabilities.
   *
   * @param capability The capability you want to retrieve.
   * @param world The world that this is happening in.
   * @param pos The position to search around.
   * @return A list of all capabilities that are being held by connected blocks.
   */
  public static <T> List<T> getConnectedCapabilities(
      Capability<T> capability, World world, BlockPos pos) {

    final List<T> capabilities = new ArrayList<T>();

    for (final EnumFacing side : EnumFacing.values()) {

      final TileEntity tile = world.getTileEntity(pos.offset(side));

      if (tile != null && !tile.isInvalid() && tile.hasCapability(capability, side.getOpposite()))
        capabilities.add(tile.getCapability(capability, side.getOpposite()));
    }

    return capabilities;
  }
  public void func_176204_a(
      World p_176204_1_, BlockPos p_176204_2_, IBlockState p_176204_3_, Block p_176204_4_) {
    if (this.func_176409_d(p_176204_1_, p_176204_2_)) {
      this.func_176398_g(p_176204_1_, p_176204_2_, p_176204_3_);
    } else {
      this.func_176226_b(p_176204_1_, p_176204_2_, p_176204_3_, 0);
      p_176204_1_.func_175698_g(p_176204_2_);
      EnumFacing[] var5 = EnumFacing.values();
      int var6 = var5.length;

      for (int var7 = 0; var7 < var6; ++var7) {
        EnumFacing var8 = var5[var7];
        p_176204_1_.func_175685_c(p_176204_2_.func_177972_a(var8), this);
      }
    }
  }
  private int getNeighborEncouragement(World worldIn, BlockPos pos) {
    if (!worldIn.isAirBlock(pos)) return 0;
    else {
      int i = 0;

      for (EnumFacing enumfacing : EnumFacing.values())
        i =
            Math.max(
                worldIn
                    .getBlockState(pos.offset(enumfacing))
                    .getBlock()
                    .getFlammability(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()),
                i);

      return i;
    }
  }
Пример #17
0
    @Override
    public List<BakedQuad> getFaceQuads(EnumFacing side) {
      if (faces == null) {
        // Create map of each face's quads.
        EnumMap<EnumFacing, ImmutableList<BakedQuad>> faces = Maps.newEnumMap(EnumFacing.class);

        for (EnumFacing face : EnumFacing.values()) {
          ImmutableList.Builder<BakedQuad> faceQuads = ImmutableList.builder();
          if (base != null) faceQuads.addAll(base.getFaceQuads(face));
          for (IFlexibleBakedModel bakedPart : parts.values())
            faceQuads.addAll(bakedPart.getFaceQuads(face));
          faces.put(face, faceQuads.build());
        }
        this.faces = Maps.immutableEnumMap(faces);
      }
      return faces.get(side);
    }
Пример #18
0
  private boolean absorbWater(World worldIn, BlockPos p_176312_2_) {
    LinkedList var3 = Lists.newLinkedList();
    ArrayList var4 = Lists.newArrayList();
    var3.add(new Tuple(p_176312_2_, Integer.valueOf(0)));
    int var5 = 0;
    BlockPos var7;

    while (!var3.isEmpty()) {
      Tuple var6 = (Tuple) var3.poll();
      var7 = (BlockPos) var6.getFirst();
      int var8 = ((Integer) var6.getSecond()).intValue();
      EnumFacing[] var9 = EnumFacing.values();
      int var10 = var9.length;

      for (int var11 = 0; var11 < var10; ++var11) {
        EnumFacing var12 = var9[var11];
        BlockPos var13 = var7.offset(var12);

        if (worldIn.getBlockState(var13).getBlock().getMaterial() == Material.water) {
          worldIn.setBlockState(var13, Blocks.air.getDefaultState(), 2);
          var4.add(var13);
          ++var5;

          if (var8 < 6) {
            var3.add(new Tuple(var13, Integer.valueOf(var8 + 1)));
          }
        }
      }

      if (var5 > 64) {
        break;
      }
    }

    Iterator var14 = var4.iterator();

    while (var14.hasNext()) {
      var7 = (BlockPos) var14.next();
      worldIn.notifyNeighborsOfStateChange(var7, Blocks.air);
    }

    return var5 > 0;
  }
Пример #19
0
 public static EnumFacing getFacingHoriz(int meta) {
   return EnumFacing.values()[meta + 2];
 }
Пример #20
0
    public BakedFluid(
        Optional<TRSRTransformation> transformation,
        ImmutableMap<TransformType, TRSRTransformation> transforms,
        VertexFormat format,
        int color,
        TextureAtlasSprite still,
        TextureAtlasSprite flowing,
        boolean gas,
        boolean statePresent,
        int[] cornerRound,
        int flowRound) {
      this.transformation = transformation;
      this.transforms = transforms;
      this.format = format;
      this.color = color;
      this.still = still;
      this.flowing = flowing;
      this.gas = gas;

      faceQuads = Maps.newEnumMap(EnumFacing.class);
      for (EnumFacing side : EnumFacing.values()) {
        faceQuads.put(side, ImmutableList.<BakedQuad>of());
      }

      if (statePresent) {
        float[] y = new float[4];
        for (int i = 0; i < 4; i++) {
          if (gas) {
            y[i] = 1 - cornerRound[i] / 768f;
          } else {
            y[i] = cornerRound[i] / 768f;
          }
        }

        float flow = (float) Math.toRadians(flowRound);

        // top

        TextureAtlasSprite topSprite = flowing;
        float scale = 4;
        if (flow < -17F) {
          flow = 0;
          scale = 8;
          topSprite = still;
        }

        float c = MathHelper.cos(flow) * scale;
        float s = MathHelper.sin(flow) * scale;

        EnumFacing side = gas ? EnumFacing.DOWN : EnumFacing.UP;
        UnpackedBakedQuad.Builder builder;
        ImmutableList.Builder<BakedQuad> topFaceBuilder = ImmutableList.builder();
        for (int k = 0; k < 2; k++) {
          builder = new UnpackedBakedQuad.Builder(format);
          builder.setQuadOrientation(side);
          builder.setTexture(topSprite);
          for (int i = gas ? 3 : 0; i != (gas ? -1 : 4); i += (gas ? -1 : 1)) {
            int l = (k * 3) + (1 - 2 * k) * i;
            putVertex(
                builder,
                side,
                x[l],
                y[l],
                z[l],
                topSprite.getInterpolatedU(8 + c * (x[l] * 2 - 1) + s * (z[l] * 2 - 1)),
                topSprite.getInterpolatedV(
                    8 + c * (x[(l + 1) % 4] * 2 - 1) + s * (z[(l + 1) % 4] * 2 - 1)));
          }
          topFaceBuilder.add(builder.build());
        }
        faceQuads.put(side, topFaceBuilder.build());

        // bottom

        side = side.getOpposite();
        builder = new UnpackedBakedQuad.Builder(format);
        builder.setQuadOrientation(side);
        builder.setTexture(still);
        for (int i = gas ? 3 : 0; i != (gas ? -1 : 4); i += (gas ? -1 : 1)) {
          putVertex(
              builder,
              side,
              z[i],
              gas ? 1 : 0,
              x[i],
              still.getInterpolatedU(z[i] * 16),
              still.getInterpolatedV(x[i] * 16));
        }
        faceQuads.put(side, ImmutableList.<BakedQuad>of(builder.build()));

        // sides

        for (int i = 0; i < 4; i++) {
          side = EnumFacing.getHorizontal((5 - i) % 4);
          BakedQuad q[] = new BakedQuad[2];

          for (int k = 0; k < 2; k++) {
            builder = new UnpackedBakedQuad.Builder(format);
            builder.setQuadOrientation(side);
            builder.setTexture(flowing);
            for (int j = 0; j < 4; j++) {
              int l = (k * 3) + (1 - 2 * k) * j;
              float yl = z[l] * y[(i + x[l]) % 4];
              if (gas && z[l] == 0) yl = 1;
              putVertex(
                  builder,
                  side,
                  x[(i + x[l]) % 4],
                  yl,
                  z[(i + x[l]) % 4],
                  flowing.getInterpolatedU(x[l] * 8),
                  flowing.getInterpolatedV((gas ? yl : 1 - yl) * 8));
            }
            q[k] = builder.build();
          }
          faceQuads.put(side, ImmutableList.of(q[0], q[1]));
        }
      } else {
        // 1 quad for inventory
        UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
        builder.setQuadOrientation(EnumFacing.UP);
        builder.setTexture(still);
        for (int i = 0; i < 4; i++) {
          putVertex(
              builder,
              EnumFacing.UP,
              z[i],
              x[i],
              0,
              still.getInterpolatedU(z[i] * 16),
              still.getInterpolatedV(x[i] * 16));
        }
        faceQuads.put(EnumFacing.SOUTH, ImmutableList.<BakedQuad>of(builder.build()));
      }
    }
  private boolean canNeighborCatchFire(World worldIn, BlockPos pos) {
    for (EnumFacing enumfacing : EnumFacing.values())
      if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite())) return true;

    return false;
  }
Пример #22
0
 public static EnumFacing getFacing(int meta) {
   return EnumFacing.values()[meta & 7];
 }
Пример #23
0
  @Override
  public void propagate(int color) {
    if (DEBUG) {
      System.out.println(
          "--- PROPAGATE "
              + getPos().toString()
              + " "
              + location.name()
              + " ("
              + getWorld().getTotalWorldTime()
              + ") ---");
    }

    int maxSignal = 0;
    int oldSignal = signalLevel;
    int[] neighborLevel = new int[7];
    boolean[] isWire = new boolean[7];
    boolean hasRedstoneWire = false;

    if (type == WireKind.NORMAL) {
      if (location != WireFace.CENTER) {
        EnumFacing facing = location.facing;

        BlockPos pos = getPos().offset(facing);
        IBlockState state = getWorld().getBlockState(pos);

        int power = WireUtils.getRedstoneLevel(getWorld(), pos, state, facing, location, false);

        if (power > 0) {
          neighborLevel[facing.ordinal()] = Math.min(15, power) << 8 | 0xFF;
        }
      }
    }

    if (internalConnections > 0) {
      for (WireFace location : WireFace.VALUES) {
        if (connectsInternal(location)) {
          isWire[location.ordinal()] = true;
          neighborLevel[location.ordinal()] = getRedstoneLevel(getContainer(), location);
        }
      }
    }

    for (EnumFacing facing : EnumFacing.VALUES) {
      int facidx = facing.ordinal();

      if (facing == location.facing && type == WireKind.NORMAL) {
        BlockPos pos = getPos().offset(facing);
        int i = 0;

        for (EnumFacing enumfacing : EnumFacing.values()) {
          if (enumfacing == facing.getOpposite()) {
            continue;
          }

          IBlockState state = getWorld().getBlockState(pos.offset(enumfacing));
          Block block = state.getBlock();

          if (!(block instanceof BlockRedstoneWire)) {
            int power =
                WireUtils.getRedstoneLevel(
                    getWorld(), pos.offset(enumfacing), state, enumfacing, location, true);

            if (power >= 15) {
              i = 15;
              break;
            }

            if (power > i) {
              i = power;
            }
          }
        }

        if (i > 0) {
          neighborLevel[facidx] = (i << 8) | 0xFF;
        }
      } else if (connectsExternal(facing)) {
        BlockPos pos = getPos().offset(facing);
        IMultipartContainer container = MultipartHelper.getPartContainer(getWorld(), pos);

        if (WireUtils.getWire(container, location) != null) {
          isWire[facidx] = true;
          neighborLevel[facidx] = getRedstoneLevel(container, location);
        } else {
          IBlockState state = getWorld().getBlockState(pos);

          int power = WireUtils.getRedstoneLevel(getWorld(), pos, state, facing, location, true);

          if (state.getBlock() instanceof BlockRedstoneWire) {
            isWire[facidx] = true;
            hasRedstoneWire = true;
            power--;
          }

          if (power > 0) {
            neighborLevel[facidx] = (Math.min(power, 15) << 8) | 0xFF;
          }
        }
      } else if (connectsCorner(facing)) {
        IMultipartContainer container =
            MultipartHelper.getPartContainer(
                getWorld(), getPos().offset(facing).offset(location.facing));
        if (container != null) {
          isWire[facidx] = true;
          neighborLevel[facidx] = getRedstoneLevel(container, WireFace.get(facing.getOpposite()));
        }
      }
    }

    int maxSignalNonWire = 0;

    for (int i = 0; i < 7; i++) {
      if (neighborLevel[i] > maxSignal) {
        maxSignal = neighborLevel[i];
      }
      if (!isWire[i] && neighborLevel[i] > maxSignalNonWire) {
        maxSignalNonWire = neighborLevel[i];
      }
    }

    if (DEBUG) {
      System.out.println(
          "ConnectionCache: "
              + Integer.toBinaryString(internalConnections)
              + " "
              + Integer.toBinaryString(externalConnections)
              + " "
              + Integer.toBinaryString(cornerConnections));
      System.out.println("Levels: " + Arrays.toString(neighborLevel));
    }

    if (maxSignal > signalLevel) {
      signalLevel = maxSignal - 1;
      if ((signalLevel & 0xFF) == 0 || (signalLevel & 0xFF) == 0xFF) {
        signalLevel = 0;
      }
    } else {
      signalLevel = maxSignalNonWire;
    }

    if (oldSignal == signalLevel) {
      return;
    }

    if (DEBUG) {
      System.out.println("Switch: " + oldSignal + " -> " + signalLevel);
    }

    if (signalLevel == 0) {
      for (WireFace nLoc : WireFace.VALUES) {
        if (connectsInternal(nLoc)) {
          if (neighborLevel[nLoc.ordinal()] > 0) {
            WireUtils.getWire(getContainer(), nLoc).onSignalChanged(type.color());
          }
        } else if (nLoc != WireFace.CENTER) {
          EnumFacing facing = nLoc.facing;

          if (connectsExternal(facing)) {
            IMultipartContainer container =
                MultipartHelper.getPartContainer(getWorld(), getPos().offset(facing));
            if (container == null
                || WireUtils.getWire(container, location) == null
                || neighborLevel[facing.ordinal()] > 0) {
              propagateNotify(facing, type.color());
            }
          } else if (connectsCorner(facing)) {
            if (neighborLevel[nLoc.ordinal()] > 0) {
              propagateNotifyCorner(location.facing, facing, type.color());
            }
          } else if (type == WireKind.NORMAL && facing.getOpposite() != location.facing) {
            TileEntity nt = getWorld().getTileEntity(getPos().offset(facing));
            if (!(nt instanceof IRedstoneReceiver)) {
              getWorld()
                  .notifyBlockOfStateChange(getPos().offset(facing), MCMultiPartMod.multipart);
            }
          }
        }
      }
    } else {
      for (WireFace nLoc : WireFace.VALUES) {
        if (neighborLevel[nLoc.ordinal()] < signalLevel - 1
            || neighborLevel[nLoc.ordinal()] > (signalLevel + 1)) {
          if (connectsInternal(nLoc)) {
            WireUtils.getWire(getContainer(), nLoc).onSignalChanged(type.color());
          } else if (nLoc != WireFace.CENTER) {
            EnumFacing facing = nLoc.facing;

            if (connectsExternal(facing)) {
              propagateNotify(facing, type.color());
            } else if (connectsCorner(facing)) {
              propagateNotifyCorner(location.facing, facing, type.color());
            } else if (type == WireKind.NORMAL && facing.getOpposite() != location.facing) {
              TileEntity nt = getWorld().getTileEntity(getPos().offset(facing));
              if (!(nt instanceof IRedstoneReceiver)) {
                getWorld()
                    .notifyBlockOfStateChange(getPos().offset(facing), MCMultiPartMod.multipart);
              }
            }
          }
        }
      }
    }

    if (type == WireKind.NORMAL) {
      if ((oldSignal & 0xF00) != (signalLevel & 0xF00)) {
        scheduleRenderUpdate();

        if (location != WireFace.CENTER) {
          BlockPos uPos = getPos().offset(location.facing);
          getWorld()
              .notifyNeighborsOfStateExcept(
                  uPos, MCMultiPartMod.multipart, location.facing.getOpposite());
        }
      }
    } else {
      if ((oldSignal & 0xF00) != (signalLevel & 0xF00)) {
        if (location != WireFace.CENTER) {
          getWorld()
              .notifyBlockOfStateChange(getPos().offset(location.facing), MCMultiPartMod.multipart);
        }
      }
    }

    finishPropagation();
  }
Пример #24
0
 @SideOnly(Side.CLIENT)
 @SubscribeEvent
 public void textureStitch(TextureStitchEvent.Pre event) {
   blockIconInfoList.clear();
   blockIconList.clear();
   fluidIcons.clear();
   itemIcons.clear();
   TextureMap textureMap = event.map;
   for (Object object : jsonDestroyer.objectsToDestroy) {
     if (object instanceof Block && object instanceof ITexturedBlock) {
       ITexturedBlock blockTextureProvider = (ITexturedBlock) object;
       Block block = (Block) object;
       for (int i = 0; i < blockTextureProvider.amountOfStates(); i++) {
         for (EnumFacing side : EnumFacing.values()) {
           String name;
           name = blockTextureProvider.getTextureNameFromState(block.getStateFromMeta(i), side);
           TextureAtlasSprite texture = textureMap.getTextureExtry(name);
           if (texture == null) {
             texture = new CustomTexture(name);
             textureMap.setTextureEntry(name, texture);
           }
           BlockIconInfo iconInfo = new BlockIconInfo(block, i, side);
           blockIconList.put(iconInfo, texture);
           blockIconInfoList.add(iconInfo);
         }
       }
     } else if (object instanceof BlockFluidBase && object instanceof ITexturedFluid) {
       ITexturedFluid fluidTextureProvider = (ITexturedFluid) object;
       String name = fluidTextureProvider.getTextureName();
       TextureAtlasSprite texture = textureMap.getTextureExtry(name);
       if (texture == null) {
         texture = new CustomTexture(name);
         textureMap.setTextureEntry(name, texture);
       }
       fluidIcons.put((BlockFluidBase) object, texture);
     } else if (object instanceof Item && object instanceof ITexturedItem) {
       ITexturedItem itemTexture = (ITexturedItem) object;
       Item item = (Item) object;
       for (int i = 0; i < itemTexture.getMaxMeta(); i++) {
         String name = itemTexture.getTextureName(i);
         TextureAtlasSprite texture = textureMap.getTextureExtry(name);
         if (texture == null) {
           texture = new CustomTexture(name);
           textureMap.setTextureEntry(name, texture);
         }
         ItemIconInfo info = new ItemIconInfo((Item) object, i, texture, name);
         itemIcons.add(info);
       }
     } else if (object instanceof Item && object instanceof ITexturedBucket) {
       ITexturedBucket itemTexture = (ITexturedBucket) object;
       for (int i = 0; i < itemTexture.getMaxMeta(); i++) {
         String name = itemTexture.getFluid(i).getStill().toString();
         TextureAtlasSprite texture = textureMap.getTextureExtry(name);
         if (texture == null) {
           texture = new CustomTexture(name);
           textureMap.setTextureEntry(name, texture);
         }
         ItemIconInfo info = new ItemIconInfo((Item) object, i, texture, name);
         info.isBucket = true;
         itemIcons.add(info);
       }
     }
   }
 }