@Override
 public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
   if (modelID == id) {
     final Tessellator tes = Tessellator.instance;
     final int offset = MathHelper.clamp_int(metadata, 0, 5) * 4;
     final BlockBeeBox beeBox = (BlockBeeBox) block;
     final IIcon[] icons = {
       beeBox.getIcon(0, metadata),
       beeBox.getIcon(1, metadata),
       beeBox.getIcon(2, metadata),
       beeBox.getIcon(3, metadata),
       beeBox.getIcon(4, metadata),
       beeBox.getIcon(5, metadata)
     };
     final double d = 0.0625D;
     // LEGS
     renderer.setRenderBounds(3 * d, 0.0D, 3 * d, 5 * d, 3 * d, 5 * d);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
     renderer.setRenderBounds(11 * d, 0.0D, 3 * d, 13 * d, 3 * d, 5 * d);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
     renderer.setRenderBounds(3 * d, 0.0D, 11 * d, 5 * d, 3 * d, 13 * d);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
     renderer.setRenderBounds(11 * d, 0.0D, 11 * d, 13 * d, 3 * d, 13 * d);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
     // BODY
     renderer.setRenderBounds(1 * d, 3 * d, 1 * d, 15 * d, 10 * d, 15 * d);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
     // ROOF
     renderer.setRenderBounds(0.0D, 10 * d, 0.0D, 1.0D, 13 * d, 1.0D);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
     renderer.setRenderBounds(2 * d, 13 * d, 2 * d, 14 * d, 1.0D, 14 * d);
     RenderUtils.renderInventoryBlockOverride(block, renderer, icons, tes);
   }
 }
  @SideOnly(Side.CLIENT)

  /** Gets an icon index based on an item's damage value */
  public Icon getIconFromDamage(int par1) {
    int j = MathHelper.clamp_int(par1, 0, 15);
    return this.Colorstrings[j];
  }
Exemple #3
0
  @Override
  @SideOnly(Side.CLIENT)
  public Icon getIconFromDamage(int meta) {

    int j = MathHelper.clamp_int(meta, 0, ITEMS_NAMES.length - 1);
    return icons[j];
  }
  @Override
  public ArrayList<PotionEffect> effectOnEaten(EntityPlayer par1EntityPlayer, int meta) {
    PotionEffect potion = new PotionEffect(Potion.digSpeed.id, 2400, 2);
    int i = MathHelper.clamp_int(meta, 0, 2);
    int dur = DCsConfigCocktail.potionDur[i];
    int amp = DCsConfigCocktail.potionAmp[i];

    boolean flag = false;

    ArrayList<PotionEffect> ret = new ArrayList<PotionEffect>();
    ret.add(new PotionEffect(Potion.hunger.id, 300, 1));

    if (this.getCustomEffect(meta) != null) {
      if (par1EntityPlayer.isPotionActive(this.getCustomEffect(meta).id)) {
        dur =
            par1EntityPlayer.getActivePotionEffect(this.getCustomEffect(meta)).getDuration() + dur;
        potion = new PotionEffect(this.getCustomEffect(meta).id, dur, amp);
        flag = true;
      } else {
        potion = new PotionEffect(this.getCustomEffect(meta).id, dur, amp);
      }
    }

    if (potion != null) ret.add(potion);

    if (flag) {
      ret.add(new PotionEffect(Potion.confusion.id, 300, 1));
    }

    return ret;
  }
  /**
   * ■対象Entityに傷を指定数つける
   *
   * @param dwIn
   * @param countHit
   */
  public void setHitCount(DataWatcher dwIn, int countHit) {
    // ■確認用
    getHitCount(dwIn);

    // ■設定
    dwIn.updateObject(Hizume.getDWID(), MathHelper.clamp_int(countHit, 0, Integer.MAX_VALUE - 1));
  }
 @Override
 public String getUnlocalizedName(ItemStack itemstack) {
   int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1);
   if (pos == 0 || pos == 5) {
     return blockType[pos];
   }
   return (new StringBuilder()).append("ToolStation.").append(blockType[pos]).toString();
 }
 @Override
 public int isProvidingWeakPower(IBlockAccess iBlockAccess, int i, int j, int k, int side) {
   if (!this.canProvidePower()) {
     return 0;
   } else {
     return MathHelper.clamp_int(random.nextInt(10), 0, 20);
   }
 }
  /** Gets the cell's icon. */
  @Override
  public IIcon getIconFromDamage(final int dmg) {
    // Clamp the index
    int index = MathHelper.clamp_int(dmg, 0, EnumEssentiaStorageTypes.fromIndex.length - 1);

    // Return the icon
    return this.icons[index];
  }
 public int isProvidingWeakPower(IBlockAccess Access, int i, int j, int k, int l) {
   if (!this.canProvidePower()) {
     return 0;
   } else {
     int i1 = ((TileEntityBlueMateriaChest) Access.getTileEntity(i, j, k)).numPlayersUsing;
     return MathHelper.clamp_int(i1, 0, 15);
   }
 }
  @Override
  public EnumRarity getRarity(ItemStack itemStack) {
    // Get the index based off of the meta data
    int index =
        MathHelper.clamp_int(itemStack.getItemDamage(), 0, ItemEssentiaCell.RARITIES.length);

    // Return the rarity
    return ItemEssentiaCell.RARITIES[index];
  }
  private Potion getCustomEffect(int meta) {
    int i = MathHelper.clamp_int(meta, 0, 2);
    int id = DCsConfigCocktail.potionIds[i];

    if (id < Potion.potionTypes.length && Potion.potionTypes[id] != null) {
      return Potion.potionTypes[id];
    }

    return Potion.regeneration;
  }
 /**
  * Returns true if the block is emitting indirect/weak redstone power on the specified side. If
  * isBlockNormalCube returns true, standard redstone propagation rules will apply instead and this
  * will not be called. Args: World, X, Y, Z, side. Note that the side is reversed - eg it is 1
  * (up) when checking the bottom of the block.
  */
 public int isProvidingWeakPower(
     IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
   if (!this.canProvidePower()) {
     return 0;
   } else {
     int i1 =
         ((TileEntityBoundChest) par1IBlockAccess.getTileEntity(par2, par3, par4)).numUsingPlayers;
     return MathHelper.clamp_int(i1, 0, 15);
   }
 }
Exemple #13
0
 @Override
 public void updateScreen() {
   super.updateScreen();
   boolean isClosed = container.inventory().isLidClosed();
   if (isClosed != wasClosed) {
     wasClosed = isClosed;
     lidMovement = isClosed ? 1 : -1;
   }
   lidXSize = MathHelper.clamp_int(lidXSize + lidMovement, 0, 16);
 }
  /** Gets the rarity of the cell. */
  @Override
  public EnumRarity getRarity(final ItemStack itemStack) {
    // Get the index based off of the meta data
    int index =
        MathHelper.clamp_int(
            itemStack.getItemDamage(), 0, EnumEssentiaStorageTypes.fromIndex.length - 1);

    // Return the rarity
    return EnumEssentiaStorageTypes.fromIndex[index].rarity;
  }
Exemple #15
0
  @Override
  public String getUnlocalizedName(ItemStack itemStack) {

    StringBuilder unlocalizedName = new StringBuilder();
    int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ITEMS_NAMES.length - 1);

    unlocalizedName.append("item.");
    unlocalizedName.append(Strings.RESOURCE_PREFIX);
    unlocalizedName.append(ITEMS_NAMES[meta]);

    return unlocalizedName.toString();
  }
  @Override
  @SideOnly(Side.CLIENT)
  public IIcon getIcon(int side, int metaData) {
    metaData = MathHelper.clamp_int(metaData, 0, types.length - 1);

    if (ForgeDirection.getOrientation(side) == ForgeDirection.UP
        || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) {
      return textures[metaData];
    } else {
      return textures[metaData];
    }
  }
  @Override
  public double getDurabilityForDisplay(ItemStack stack) {
    NBTTagCompound nbt = stack.getTagCompound();
    int charge = 0;
    int max = this.getMaxAmount(stack);
    if (nbt != null && nbt.hasKey("charge")) {
      charge = nbt.getInteger("charge");
      charge = MathHelper.clamp_int(charge, 0, max);
    }

    int i = max - charge;
    return (double) i / (double) max;
  }
  protected void renderTitle(int width, int height, float partialTicks) {
    if (field_175195_w > 0) {
      mc.mcProfiler.startSection("titleAndSubtitle");
      float age = (float) this.field_175195_w - partialTicks;
      int opacity = 255;

      if (field_175195_w > field_175193_B + field_175192_A) {
        float f3 = (float) (field_175199_z + field_175192_A + field_175193_B) - age;
        opacity = (int) (f3 * 255.0F / (float) field_175199_z);
      }
      if (field_175195_w <= field_175193_B)
        opacity = (int) (age * 255.0F / (float) this.field_175193_B);

      opacity = MathHelper.clamp_int(opacity, 0, 255);

      if (opacity > 8) {
        GlStateManager.pushMatrix();
        GlStateManager.translate((float) (width / 2), (float) (height / 2), 0.0F);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.pushMatrix();
        GlStateManager.scale(4.0F, 4.0F, 4.0F);
        int l = opacity << 24 & -16777216;
        this.getFontRenderer()
            .drawString(
                this.field_175201_x,
                (float) (-this.getFontRenderer().getStringWidth(this.field_175201_x) / 2),
                -10.0F,
                16777215 | l,
                true);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        GlStateManager.scale(2.0F, 2.0F, 2.0F);
        this.getFontRenderer()
            .drawString(
                this.field_175200_y,
                (float) (-this.getFontRenderer().getStringWidth(this.field_175200_y) / 2),
                5.0F,
                16777215 | l,
                true);
        GlStateManager.popMatrix();
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
      }

      this.mc.mcProfiler.endSection();
    }
  }
  public int[] searchBlock(World world, int x, int y, int z, int area) {
    int targetX = world.rand.nextInt(area * 2 + 1);
    int targetZ = world.rand.nextInt(area * 2 + 1);
    int targetY = world.rand.nextInt(area + 1);

    targetX += x - area;
    targetZ += z - area;
    targetY += y - area / 2;
    MathHelper.clamp_int(targetY, 1, 255);

    int[] pos = new int[3];

    pos[0] = targetX;
    pos[1] = targetY;
    pos[2] = targetZ;

    return pos;
  }
  private void updateWidget() {
    String[] elements = getDropdownElements();
    selectedElement =
        elements[
            MathHelper.clamp_int(
                GlobalVariableManager.getInstance().getInteger(getVariableName()),
                0,
                elements.length - 1)];

    if (widget != null) {
      widget.xPosition = x;
      widget.yPosition = y;
      widget.width = width;
      widget.height = height;
      widget.setElements(getDropdownElements());
      widget.setText(selectedElement);
    }
  }
  @Override
  public void updateEntity() {
    if (worldObj.isRemote) {
      return;
    }

    if (airBuffer >= SC_Settings.machineUsage && this.getBlockMetadata() == 0) {
      if (this.getWorldObj().getTotalWorldTime() % 10
          == 0) // Culls a bit of the unnecessary processing
      {
        for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
          int dx = this.xCoord + dir.offsetX;
          int dy = this.yCoord + dir.offsetY;
          int dz = this.zCoord + dir.offsetZ;

          Block block = worldObj.getBlock(dx, dy, dz);

          int airOut = MathHelper.clamp_int(airBuffer / SC_Settings.machineUsage, 1, 16);

          if (block == Blocks.air) {
            worldObj.setBlock(dx, dy, dz, SolarCraft.spaceAir, airOut - 2, 3);
          } else if (block instanceof IAirProvider) {
            IAirProvider airTile = (IAirProvider) block;

            if (airTile.getAirSupply(this.worldObj, dx, dy, dz) != airOut - 1) {
              airTile.setAirSupply(this.worldObj, dx, dy, dz, airOut - 1);
            }
          }
        }
      }

      airBuffer -= SC_Settings.machineUsage;

      if (airBuffer < SC_Settings.machineUsage) {
        this.worldObj.notifyBlocksOfNeighborChange(
            this.xCoord, this.yCoord, this.zCoord, SolarCraft.airVent);
      }
    }
  }
 public String getUnlocalizedName(ItemStack stack) {
   int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length);
   return getUnlocalizedName() + "." + unlocalizedNames[arr];
 }
 @SideOnly(Side.CLIENT)
 public IIcon getIconFromDamage(int meta) {
   int arr = MathHelper.clamp_int(meta, 0, unlocalizedNames.length);
   return icons[arr];
 }
 /** ■緋爪のリソースを取得 */
 public ModelResourceLocation getHizumeModelRL(int nNo) {
   nNo = MathHelper.clamp_int(nNo, 0, this.arrNum - 1);
   return mrHizume[nNo];
 }
 public int increaseTemper(int p_110198_1_) {
   int j = MathHelper.clamp_int(this.getTemper() + p_110198_1_, 0, this.getMaxTemper());
   this.setTemper(j);
   return j;
 }
Exemple #26
0
 @Override
 public ICapacitor getCapacitor(ItemStack stack) {
   int damage = MathHelper.clamp_int(stack.getItemDamage(), 0, Capacitors.values().length - 1);
   return Capacitors.values()[damage].capacitor;
 }
  @Override
  public IIcon getIconFromDamage(int dmg) {
    int index = MathHelper.clamp_int(dmg, 0, ItemStorageBase.SUFFIXES.length);

    return this.icons[index];
  }
 public final void onMouseWheel(int dWheel) {
   if (needsScrollbar() && dWheel != 0) {
     dWheel = -Integer.signum(dWheel) * 5;
     newScrollIfInside = MathHelper.clamp_int(scrollbarY + dWheel, -1, height - scrollbarHeight);
   }
 }
 public final void onMouseMoved(int mouseX, int mouseY) {
   if (isDragging) {
     scrollbarY =
         MathHelper.clamp_int(mouseY - y - scrollbarClickOffset, 0, height - scrollbarHeight);
   }
 }
  /** Transfers an entity from a world to another world. */
  public void transferEntityToWorld(
      Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_) {
    double var5 = entityIn.posX;
    double var7 = entityIn.posZ;
    double var9 = 8.0D;
    float var11 = entityIn.rotationYaw;
    p_82448_3_.theProfiler.startSection("moving");

    if (entityIn.dimension == -1) {
      var5 =
          MathHelper.clamp_double(
              var5 / var9,
              p_82448_4_.getWorldBorder().minX() + 16.0D,
              p_82448_4_.getWorldBorder().maxX() - 16.0D);
      var7 =
          MathHelper.clamp_double(
              var7 / var9,
              p_82448_4_.getWorldBorder().minZ() + 16.0D,
              p_82448_4_.getWorldBorder().maxZ() - 16.0D);
      entityIn.setLocationAndAngles(
          var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    } else if (entityIn.dimension == 0) {
      var5 =
          MathHelper.clamp_double(
              var5 * var9,
              p_82448_4_.getWorldBorder().minX() + 16.0D,
              p_82448_4_.getWorldBorder().maxX() - 16.0D);
      var7 =
          MathHelper.clamp_double(
              var7 * var9,
              p_82448_4_.getWorldBorder().minZ() + 16.0D,
              p_82448_4_.getWorldBorder().maxZ() - 16.0D);
      entityIn.setLocationAndAngles(
          var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    } else {
      BlockPos var12;

      if (p_82448_2_ == 1) {
        var12 = p_82448_4_.getSpawnPoint();
      } else {
        var12 = p_82448_4_.func_180504_m();
      }

      var5 = (double) var12.getX();
      entityIn.posY = (double) var12.getY();
      var7 = (double) var12.getZ();
      entityIn.setLocationAndAngles(var5, entityIn.posY, var7, 90.0F, 0.0F);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    }

    p_82448_3_.theProfiler.endSection();

    if (p_82448_2_ != 1) {
      p_82448_3_.theProfiler.startSection("placing");
      var5 = (double) MathHelper.clamp_int((int) var5, -29999872, 29999872);
      var7 = (double) MathHelper.clamp_int((int) var7, -29999872, 29999872);

      if (entityIn.isEntityAlive()) {
        entityIn.setLocationAndAngles(
            var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);
        p_82448_4_.getDefaultTeleporter().func_180266_a(entityIn, var11);
        p_82448_4_.spawnEntityInWorld(entityIn);
        p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
      }

      p_82448_3_.theProfiler.endSection();
    }

    entityIn.setWorld(p_82448_4_);
  }