Java Code Examples for net.minecraft.util.MathHelper.clamp_int()

The following are Jave code examples for showing how to use clamp_int() of the net.minecraft.util.MathHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DecompiledMinecraft   File: BlockDaylightDetector.java   Source Code and License Vote up 6 votes
public void updatePower(World worldIn, BlockPos pos)
{
    if (!worldIn.provider.getHasNoSky())
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
        float f = worldIn.getCelestialAngleRadians(1.0F);
        float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
        f = f + (f1 - f) * 0.2F;
        i = Math.round((float)i * MathHelper.cos(f));
        i = MathHelper.clamp_int(i, 0, 15);

        if (this.inverted)
        {
            i = 15 - i;
        }

        if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
        {
            worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: BlockChest.java   Source Code and License Vote up 6 votes
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
    if (!this.canProvidePower())
    {
        return 0;
    }
    else
    {
        int i = 0;
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityChest)
        {
            i = ((TileEntityChest)tileentity).numPlayersUsing;
        }

        return MathHelper.clamp_int(i, 0, 15);
    }
}
 
Example 3
Project: BaseClient   File: GuiChat.java   Source Code and License Vote up 6 votes
/**
 * input is relative and is applied directly to the sentHistoryCursor so -1 is the previous message, 1 is the next
 * message from the current cursor position
 */
public void getSentHistory(int msgPos)
{
    int i = this.sentHistoryCursor + msgPos;
    int j = this.mc.ingameGUI.getChatGUI().getSentMessages().size();
    i = MathHelper.clamp_int(i, 0, j);

    if (i != this.sentHistoryCursor)
    {
        if (i == j)
        {
            this.sentHistoryCursor = j;
            this.inputField.setText(this.historyBuffer);
        }
        else
        {
            if (this.sentHistoryCursor == j)
            {
                this.historyBuffer = this.inputField.getText();
            }

            this.inputField.setText((String)this.mc.ingameGUI.getChatGUI().getSentMessages().get(i));
            this.sentHistoryCursor = i;
        }
    }
}
 
Example 4
Project: BaseClient   File: GuiOverlayDebug.java   Source Code and License Vote up 6 votes
private int func_181553_a(int p_181553_1_, int p_181553_2_, float p_181553_3_)
{
    int i = p_181553_1_ >> 24 & 255;
    int j = p_181553_1_ >> 16 & 255;
    int k = p_181553_1_ >> 8 & 255;
    int l = p_181553_1_ & 255;
    int i1 = p_181553_2_ >> 24 & 255;
    int j1 = p_181553_2_ >> 16 & 255;
    int k1 = p_181553_2_ >> 8 & 255;
    int l1 = p_181553_2_ & 255;
    int i2 = MathHelper.clamp_int((int)((float)i + (float)(i1 - i) * p_181553_3_), 0, 255);
    int j2 = MathHelper.clamp_int((int)((float)j + (float)(j1 - j) * p_181553_3_), 0, 255);
    int k2 = MathHelper.clamp_int((int)((float)k + (float)(k1 - k) * p_181553_3_), 0, 255);
    int l2 = MathHelper.clamp_int((int)((float)l + (float)(l1 - l) * p_181553_3_), 0, 255);
    return i2 << 24 | j2 << 16 | k2 << 8 | l2;
}
 
Example 5
Project: DecompiledMinecraft   File: GuiOverlayDebug.java   Source Code and License Vote up 6 votes
private int func_181553_a(int p_181553_1_, int p_181553_2_, float p_181553_3_)
{
    int i = p_181553_1_ >> 24 & 255;
    int j = p_181553_1_ >> 16 & 255;
    int k = p_181553_1_ >> 8 & 255;
    int l = p_181553_1_ & 255;
    int i1 = p_181553_2_ >> 24 & 255;
    int j1 = p_181553_2_ >> 16 & 255;
    int k1 = p_181553_2_ >> 8 & 255;
    int l1 = p_181553_2_ & 255;
    int i2 = MathHelper.clamp_int((int)((float)i + (float)(i1 - i) * p_181553_3_), 0, 255);
    int j2 = MathHelper.clamp_int((int)((float)j + (float)(j1 - j) * p_181553_3_), 0, 255);
    int k2 = MathHelper.clamp_int((int)((float)k + (float)(k1 - k) * p_181553_3_), 0, 255);
    int l2 = MathHelper.clamp_int((int)((float)l + (float)(l1 - l) * p_181553_3_), 0, 255);
    return i2 << 24 | j2 << 16 | k2 << 8 | l2;
}
 
Example 6
Project: DecompiledMinecraft   File: Chunk.java   Source Code and License Vote up 5 votes
/**
 * Fills the given list of all entities that intersect within the given bounding box that aren't the passed entity.
 */
public void getEntitiesWithinAABBForEntity(Entity entityIn, AxisAlignedBB aabb, List<Entity> listToFill, Predicate <? super Entity > p_177414_4_)
{
    int i = MathHelper.floor_double((aabb.minY - 2.0D) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxY + 2.0D) / 16.0D);
    i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);

    for (int k = i; k <= j; ++k)
    {
        if (!this.entityLists[k].isEmpty())
        {
            for (Entity entity : this.entityLists[k])
            {
                if (entity.getEntityBoundingBox().intersectsWith(aabb) && entity != entityIn)
                {
                    if (p_177414_4_ == null || p_177414_4_.apply(entity))
                    {
                        listToFill.add(entity);
                    }

                    Entity[] aentity = entity.getParts();

                    if (aentity != null)
                    {
                        for (int l = 0; l < aentity.length; ++l)
                        {
                            entity = aentity[l];

                            if (entity != entityIn && entity.getEntityBoundingBox().intersectsWith(aabb) && (p_177414_4_ == null || p_177414_4_.apply(entity)))
                            {
                                listToFill.add(entity);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 7
Project: TextDisplayer   File: ModernTextBox.java   Source Code and License Vote up 5 votes
/**
 * Sets the position of the selection anchor (i.e. position the selection was started at)
 */
public void setSelectionPos(int pos) {
    int i = this.text.length();

    if (pos > i) {
        pos = i;
    }
    if (pos < 0) {
        pos = 0;
    }

    this.selectionEnd = pos;

    if (this.fontRendererInstance != null) {
        if (this.lineScrollOffset > i) {
            this.lineScrollOffset = i;
        }

        int j = this.getWidth();
        String s = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), j);
        int k = s.length() + this.lineScrollOffset;

        if (pos == this.lineScrollOffset) {
            this.lineScrollOffset -= this.fontRendererInstance.trimStringToWidth(this.text, j, true).length();
        }

        if (pos > k) {
            this.lineScrollOffset += pos - k;
        } else if (pos <= this.lineScrollOffset) {
            this.lineScrollOffset -= this.lineScrollOffset - pos;
        }
        this.lineScrollOffset = MathHelper.clamp_int(this.lineScrollOffset, 0, i);
    }
}
 
Example 8
Project: StructPro   File: Tiles.java   Source Code and License Vote up 5 votes
/**
 * Load note data from NBT tag
 * @param note Target note
 * @param tag tag to load
 * @param seed Loading seed
 */
private static void load(TileEntityNote note, NBTTagCompound tag, long seed) {
    if (tag == null) {
        return;
    }
    Random random = new Random(seed);
    note.note = (byte) MathHelper.clamp_int(tag.getByte("note"), 0, 24);
    note.previousRedstoneState = tag.getBoolean("powered");
}
 
Example 9
Project: DecompiledMinecraft   File: WorldRenderer.java   Source Code and License Vote up 5 votes
public void putColorRGB_F(float red, float green, float blue, int p_178994_4_)
{
    int i = this.getColorIndex(p_178994_4_);
    int j = MathHelper.clamp_int((int)(red * 255.0F), 0, 255);
    int k = MathHelper.clamp_int((int)(green * 255.0F), 0, 255);
    int l = MathHelper.clamp_int((int)(blue * 255.0F), 0, 255);
    this.putColorRGBA(i, j, k, l, 255);
}
 
Example 10
Project: BaseClient   File: ServerConfigurationManager.java   Source Code and License Vote up 4 votes
/**
 * 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 d0 = entityIn.posX;
    double d1 = entityIn.posZ;
    double d2 = 8.0D;
    float f = entityIn.rotationYaw;
    p_82448_3_.theProfiler.startSection("moving");

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

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

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

        if (p_82448_2_ == 1)
        {
            blockpos = p_82448_4_.getSpawnPoint();
        }
        else
        {
            blockpos = p_82448_4_.getSpawnCoordinate();
        }

        d0 = (double)blockpos.getX();
        entityIn.posY = (double)blockpos.getY();
        d1 = (double)blockpos.getZ();
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, 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");
        d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872);
        d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872);

        if (entityIn.isEntityAlive())
        {
            entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
            p_82448_4_.getDefaultTeleporter().placeInPortal(entityIn, f);
            p_82448_4_.spawnEntityInWorld(entityIn);
            p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
        }

        p_82448_3_.theProfiler.endSection();
    }

    entityIn.setWorld(p_82448_4_);
}
 
Example 11
Project: BaseClient   File: BlockGlowstone.java   Source Code and License Vote up 4 votes
/**
 * Get the quantity dropped based on the given fortune level
 */
public int quantityDroppedWithBonus(int fortune, Random random)
{
    return MathHelper.clamp_int(this.quantityDropped(random) + random.nextInt(fortune + 1), 1, 4);
}
 
Example 12
Project: BaseClient   File: TileEntityNote.java   Source Code and License Vote up 4 votes
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.note = compound.getByte("note");
    this.note = (byte)MathHelper.clamp_int(this.note, 0, 24);
}
 
Example 13
Project: BaseClient   File: GuiSimpleScrolledSelectionListProxy.java   Source Code and License Vote up 4 votes
public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_)
{
    if (this.field_178041_q)
    {
        this.mouseX = mouseXIn;
        this.mouseY = mouseYIn;
        this.drawBackground();
        int i = this.getScrollBarX();
        int j = i + 6;
        this.bindAmountScrolled();
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
        int l = this.top + 4 - (int)this.amountScrolled;

        if (this.hasListHeader)
        {
            this.drawListHeader(k, l, tessellator);
        }

        this.drawSelectionBox(k, l, mouseXIn, mouseYIn);
        GlStateManager.disableDepth();
        int i1 = 4;
        this.overlayBackground(0, this.top, 255, 255);
        this.overlayBackground(this.bottom, this.height, 255, 255);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
        GlStateManager.disableAlpha();
        GlStateManager.shadeModel(7425);
        GlStateManager.disableTexture2D();
        int j1 = this.func_148135_f();

        if (j1 > 0)
        {
            int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
            k1 = MathHelper.clamp_int(k1, 32, this.bottom - this.top - 8);
            int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;

            if (l1 < this.top)
            {
                l1 = this.top;
            }

            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            worldrenderer.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
            worldrenderer.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
            worldrenderer.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
            worldrenderer.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
            tessellator.draw();
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            worldrenderer.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
            worldrenderer.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
            worldrenderer.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
            worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
            tessellator.draw();
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            worldrenderer.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
            worldrenderer.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
            worldrenderer.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
            worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
            tessellator.draw();
        }

        this.func_148142_b(mouseXIn, mouseYIn);
        GlStateManager.enableTexture2D();
        GlStateManager.shadeModel(7424);
        GlStateManager.enableAlpha();
        GlStateManager.disableBlend();
    }
}
 
Example 14
Project: BaseClient   File: MapData.java   Source Code and License Vote up 4 votes
/**
 * reads in data from the NBTTagCompound into this MapDataBase
 */
public void readFromNBT(NBTTagCompound nbt)
{
    this.dimension = nbt.getByte("dimension");
    this.xCenter = nbt.getInteger("xCenter");
    this.zCenter = nbt.getInteger("zCenter");
    this.scale = nbt.getByte("scale");
    this.scale = (byte)MathHelper.clamp_int(this.scale, 0, 4);
    int i = nbt.getShort("width");
    int j = nbt.getShort("height");

    if (i == 128 && j == 128)
    {
        this.colors = nbt.getByteArray("colors");
    }
    else
    {
        byte[] abyte = nbt.getByteArray("colors");
        this.colors = new byte[16384];
        int k = (128 - i) / 2;
        int l = (128 - j) / 2;

        for (int i1 = 0; i1 < j; ++i1)
        {
            int j1 = i1 + l;

            if (j1 >= 0 || j1 < 128)
            {
                for (int k1 = 0; k1 < i; ++k1)
                {
                    int l1 = k1 + k;

                    if (l1 >= 0 || l1 < 128)
                    {
                        this.colors[l1 + j1 * 128] = abyte[k1 + i1 * i];
                    }
                }
            }
        }
    }
}
 
Example 15
Project: BaseClient   File: GuiTextField.java   Source Code and License Vote up 4 votes
/**
 * Sets the position of the selection anchor (i.e. position the selection was started at)
 */
public void setSelectionPos(int p_146199_1_)
{
    int i = this.text.length();

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

    if (p_146199_1_ < 0)
    {
        p_146199_1_ = 0;
    }

    this.selectionEnd = p_146199_1_;

    if (this.fontRendererInstance != null)
    {
        if (this.lineScrollOffset > i)
        {
            this.lineScrollOffset = i;
        }

        int j = this.getWidth();
        String s = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), j);
        int k = s.length() + this.lineScrollOffset;

        if (p_146199_1_ == this.lineScrollOffset)
        {
            this.lineScrollOffset -= this.fontRendererInstance.trimStringToWidth(this.text, j, true).length();
        }

        if (p_146199_1_ > k)
        {
            this.lineScrollOffset += p_146199_1_ - k;
        }
        else if (p_146199_1_ <= this.lineScrollOffset)
        {
            this.lineScrollOffset -= this.lineScrollOffset - p_146199_1_;
        }

        this.lineScrollOffset = MathHelper.clamp_int(this.lineScrollOffset, 0, i);
    }
}
 
Example 16
Project: DecompiledMinecraft   File: MapData.java   Source Code and License Vote up 4 votes
/**
 * reads in data from the NBTTagCompound into this MapDataBase
 */
public void readFromNBT(NBTTagCompound nbt)
{
    this.dimension = nbt.getByte("dimension");
    this.xCenter = nbt.getInteger("xCenter");
    this.zCenter = nbt.getInteger("zCenter");
    this.scale = nbt.getByte("scale");
    this.scale = (byte)MathHelper.clamp_int(this.scale, 0, 4);
    int i = nbt.getShort("width");
    int j = nbt.getShort("height");

    if (i == 128 && j == 128)
    {
        this.colors = nbt.getByteArray("colors");
    }
    else
    {
        byte[] abyte = nbt.getByteArray("colors");
        this.colors = new byte[16384];
        int k = (128 - i) / 2;
        int l = (128 - j) / 2;

        for (int i1 = 0; i1 < j; ++i1)
        {
            int j1 = i1 + l;

            if (j1 >= 0 || j1 < 128)
            {
                for (int k1 = 0; k1 < i; ++k1)
                {
                    int l1 = k1 + k;

                    if (l1 >= 0 || l1 < 128)
                    {
                        this.colors[l1 + j1 * 128] = abyte[k1 + i1 * i];
                    }
                }
            }
        }
    }
}
 
Example 17
Project: DecompiledMinecraft   File: GuiSimpleScrolledSelectionListProxy.java   Source Code and License Vote up 4 votes
public void drawScreen(int mouseXIn, int mouseYIn, float p_148128_3_)
{
    if (this.field_178041_q)
    {
        this.mouseX = mouseXIn;
        this.mouseY = mouseYIn;
        this.drawBackground();
        int i = this.getScrollBarX();
        int j = i + 6;
        this.bindAmountScrolled();
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
        int l = this.top + 4 - (int)this.amountScrolled;

        if (this.hasListHeader)
        {
            this.drawListHeader(k, l, tessellator);
        }

        this.drawSelectionBox(k, l, mouseXIn, mouseYIn);
        GlStateManager.disableDepth();
        int i1 = 4;
        this.overlayBackground(0, this.top, 255, 255);
        this.overlayBackground(this.bottom, this.height, 255, 255);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
        GlStateManager.disableAlpha();
        GlStateManager.shadeModel(7425);
        GlStateManager.disableTexture2D();
        int j1 = this.func_148135_f();

        if (j1 > 0)
        {
            int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
            k1 = MathHelper.clamp_int(k1, 32, this.bottom - this.top - 8);
            int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;

            if (l1 < this.top)
            {
                l1 = this.top;
            }

            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            worldrenderer.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
            worldrenderer.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
            worldrenderer.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
            worldrenderer.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
            tessellator.draw();
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            worldrenderer.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
            worldrenderer.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
            worldrenderer.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
            worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
            tessellator.draw();
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            worldrenderer.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
            worldrenderer.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
            worldrenderer.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
            worldrenderer.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
            tessellator.draw();
        }

        this.func_148142_b(mouseXIn, mouseYIn);
        GlStateManager.enableTexture2D();
        GlStateManager.shadeModel(7424);
        GlStateManager.enableAlpha();
        GlStateManager.disableBlend();
    }
}
 
Example 18
Project: DecompiledMinecraft   File: TileEntityFurnace.java   Source Code and License Vote up 4 votes
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    boolean flag = this.isBurning();
    boolean flag1 = false;

    if (this.isBurning())
    {
        --this.furnaceBurnTime;
    }

    if (!this.worldObj.isRemote)
    {
        if (this.isBurning() || this.furnaceItemStacks[1] != null && this.furnaceItemStacks[0] != null)
        {
            if (!this.isBurning() && this.canSmelt())
            {
                this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

                if (this.isBurning())
                {
                    flag1 = true;

                    if (this.furnaceItemStacks[1] != null)
                    {
                        --this.furnaceItemStacks[1].stackSize;

                        if (this.furnaceItemStacks[1].stackSize == 0)
                        {
                            Item item = this.furnaceItemStacks[1].getItem().getContainerItem();
                            this.furnaceItemStacks[1] = item != null ? new ItemStack(item) : null;
                        }
                    }
                }
            }

            if (this.isBurning() && this.canSmelt())
            {
                ++this.cookTime;

                if (this.cookTime == this.totalCookTime)
                {
                    this.cookTime = 0;
                    this.totalCookTime = this.getCookTime(this.furnaceItemStacks[0]);
                    this.smeltItem();
                    flag1 = true;
                }
            }
            else
            {
                this.cookTime = 0;
            }
        }
        else if (!this.isBurning() && this.cookTime > 0)
        {
            this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime);
        }

        if (flag != this.isBurning())
        {
            flag1 = true;
            BlockFurnace.setState(this.isBurning(), this.worldObj, this.pos);
        }
    }

    if (flag1)
    {
        this.markDirty();
    }
}
 
Example 19
Project: DecompiledMinecraft   File: PlayerManager.java   Source Code and License Vote up 4 votes
public void setPlayerViewRadius(int radius)
{
    radius = MathHelper.clamp_int(radius, 3, 32);

    if (radius != this.playerViewRadius)
    {
        int i = radius - this.playerViewRadius;

        for (EntityPlayerMP entityplayermp : Lists.newArrayList(this.players))
        {
            int j = (int)entityplayermp.posX >> 4;
            int k = (int)entityplayermp.posZ >> 4;

            if (i > 0)
            {
                for (int j1 = j - radius; j1 <= j + radius; ++j1)
                {
                    for (int k1 = k - radius; k1 <= k + radius; ++k1)
                    {
                        PlayerManager.PlayerInstance playermanager$playerinstance = this.getPlayerInstance(j1, k1, true);

                        if (!playermanager$playerinstance.playersWatchingChunk.contains(entityplayermp))
                        {
                            playermanager$playerinstance.addPlayer(entityplayermp);
                        }
                    }
                }
            }
            else
            {
                for (int l = j - this.playerViewRadius; l <= j + this.playerViewRadius; ++l)
                {
                    for (int i1 = k - this.playerViewRadius; i1 <= k + this.playerViewRadius; ++i1)
                    {
                        if (!this.overlaps(l, i1, j, k, radius))
                        {
                            this.getPlayerInstance(l, i1, true).removePlayer(entityplayermp);
                        }
                    }
                }
            }
        }

        this.playerViewRadius = radius;
    }
}
 
Example 20
Project: BaseClient   File: BlockSeaLantern.java   Source Code and License Vote up 4 votes
/**
 * Get the quantity dropped based on the given fortune level
 */
public int quantityDroppedWithBonus(int fortune, Random random)
{
    return MathHelper.clamp_int(this.quantityDropped(random) + random.nextInt(fortune + 1), 1, 5);
}