当前位置: 首页>>代码示例>>Java>>正文


Java MathHelper.clamp方法代码示例

本文整理汇总了Java中net.minecraft.util.math.MathHelper.clamp方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.clamp方法的具体用法?Java MathHelper.clamp怎么用?Java MathHelper.clamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.math.MathHelper的用法示例。


在下文中一共展示了MathHelper.clamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: safeImpact

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, 1, box);
	BlockPos posF = pos.add(-box, -1, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	int chance = 10 + amplifier * 2;
	int fortune = MathHelper.clamp(amplifier, 0, 5);
	for (BlockPos spot : spots) {
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 1 || world.rand.nextBoolean();
		if (place && state.getBlock() instanceof BlockCrops) {
			BlockCrops crop = (BlockCrops) state.getBlock();
			if (crop.isMaxAge(state)) {
				crop.dropBlockAsItemWithChance(world, spot, state, chance, fortune);
				world.setBlockToAir(spot);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:23,代码来源:HarvestBrew.java

示例2: getBrightnessForRender

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public int getBrightnessForRender(float partialTicks)
{
    float f = 0.5F;
    f = MathHelper.clamp(f, 0.0F, 1.0F);
    int i = super.getBrightnessForRender(partialTicks);
    int j = i & 255;
    int k = i >> 16 & 255;
    j = j + (int)(f * 15.0F * 16.0F);

    if (j > 240)
    {
        j = 240;
    }

    return j | k << 16;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:EntityXPOrb.java

示例3: preRenderCallback

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
protected void preRenderCallback(EntityCreeperween entity, float partialTickTime)
{
	float f = entity.getCreeperFlashIntensity(partialTickTime);
	float f1 = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F;
	f = MathHelper.clamp(f, 0.0F, 1.0F);
	f = f * f;
	f = f * f;
	float width = (1.625F + f * 0.4F) * f1;
	float height = (1.625F + f * 0.1F) / f1;
	GlStateManager.scale(width, height, width);
}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:13,代码来源:RenderCreeperween.java

示例4: renderParticle

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Renders the particle
 */
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp(f, 0.0F, 1.0F);
    this.particleScale = this.smokeParticleScale * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:11,代码来源:ParticleSmokeNormal.java

示例5: onLivingUpdate

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    super.onLivingUpdate();
    this.oFlap = this.wingRotation;
    this.oFlapSpeed = this.destPos;
    this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D);
    this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F);

    if (!this.onGround && this.wingRotDelta < 1.0F)
    {
        this.wingRotDelta = 1.0F;
    }

    this.wingRotDelta = (float)((double)this.wingRotDelta * 0.9D);

    if (!this.onGround && this.motionY < 0.0D)
    {
        this.motionY *= 0.6D;
    }

    this.wingRotation += this.wingRotDelta * 2.0F;

    if (!this.world.isRemote && !this.isChild() && !this.isChickenJockey() && --this.timeUntilNextEgg <= 0)
    {
        this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        this.dropItem(Items.EGG, 1);
        this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:34,代码来源:EntityChicken.java

示例6: handleMouseInput

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void handleMouseInput() throws IOException {
    int i = Mouse.getEventDWheel();

    i = MathHelper.clamp(i, -1, 1);
    buttonListOffset -= i*10;

    if (buttonListOffset < 0) buttonListOffset = 0; // dont scroll up if its already at the top

    int lowestButtonY = (GuiButton.height+1) * buttonList.size() + windowY;
    int lowestAllowedOffset = lowestButtonY - height - windowY + 3;
    if (lowestButtonY - buttonListOffset < bottomY)
        buttonListOffset = lowestAllowedOffset;

}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:15,代码来源:GuiWindowMod.java

示例7: readFromNBT

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.note = compound.getByte("note");
    this.note = (byte)MathHelper.clamp(this.note, 0, 24);
    this.previousRedstoneState = compound.getBoolean("powered");
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:8,代码来源:TileEntityNote.java

示例8: renderParticle

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
	float scale = ((float) this.particleAge + partialTicks) / (float) this.particleMaxAge * 32.0F;
	scale = MathHelper.clamp(scale, 0.0F, 1.0F);
	this.particleScale = this.oSize * scale;
	super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
	GlStateManager.color(getRedColorF(), getGreenColorF(), getBlueColorF(), 1.0F);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:ParticleSpark.java

示例9: getMapAngleFromPitch

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Return the angle to render the Map
 */
private float getMapAngleFromPitch(float pitch)
{
    float f = 1.0F - pitch / 45.0F + 0.1F;
    f = MathHelper.clamp(f, 0.0F, 1.0F);
    f = -MathHelper.cos(f * (float)Math.PI) * 0.5F + 0.5F;
    return f;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:11,代码来源:ItemRenderer.java

示例10: setCursorPosition

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Sets the current position of the cursor.
 */
public void setCursorPosition(int pos)
{
    this.cursorPosition = pos;
    int i = this.text.length();
    this.cursorPosition = MathHelper.clamp(this.cursorPosition, 0, i);
    this.setSelectionPos(this.cursorPosition);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:11,代码来源:GuiPasswordField.java

示例11: setStability

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public StabilityData setStability(float amount) {
	this.stability = MathHelper.clamp(amount, MIN_STABILITY, MAX_STABILITY);
	return this;
}
 
开发者ID:the-realest-stu,项目名称:Etheric,代码行数:5,代码来源:StabilityData.java

示例12: quantityDroppedWithBonus

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public int quantityDroppedWithBonus(int fortune, @Nonnull Random random) {
    return MathHelper.clamp(this.quantityDropped(random) + random.nextInt(fortune + 1), 1, 4);
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:4,代码来源:BlockFruitLeaves.java

示例13: doLocalUpdate

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Gives the phase a chance to update its status.
 * Called by dragon's onLivingUpdate. Only used when !worldObj.isRemote.
 */
public void doLocalUpdate()
{
    ++this.scanningTime;
    EntityLivingBase entitylivingbase = this.dragon.world.getNearestAttackablePlayer(this.dragon, 20.0D, 10.0D);

    if (entitylivingbase != null)
    {
        if (this.scanningTime > 25)
        {
            this.dragon.getPhaseManager().setPhase(PhaseList.SITTING_ATTACKING);
        }
        else
        {
            Vec3d vec3d = (new Vec3d(entitylivingbase.posX - this.dragon.posX, 0.0D, entitylivingbase.posZ - this.dragon.posZ)).normalize();
            Vec3d vec3d1 = (new Vec3d((double)MathHelper.sin(this.dragon.rotationYaw * 0.017453292F), 0.0D, (double)(-MathHelper.cos(this.dragon.rotationYaw * 0.017453292F)))).normalize();
            float f = (float)vec3d1.dotProduct(vec3d);
            float f1 = (float)(Math.acos((double)f) * (180D / Math.PI)) + 0.5F;

            if (f1 < 0.0F || f1 > 10.0F)
            {
                double d0 = entitylivingbase.posX - this.dragon.dragonPartHead.posX;
                double d1 = entitylivingbase.posZ - this.dragon.dragonPartHead.posZ;
                double d2 = MathHelper.clamp(MathHelper.wrapDegrees(180.0D - MathHelper.atan2(d0, d1) * (180D / Math.PI) - (double)this.dragon.rotationYaw), -100.0D, 100.0D);
                this.dragon.randomYawVelocity *= 0.8F;
                float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1) + 1.0F;
                float f3 = f2;

                if (f2 > 40.0F)
                {
                    f2 = 40.0F;
                }

                this.dragon.randomYawVelocity = (float)((double)this.dragon.randomYawVelocity + d2 * (double)(0.7F / f2 / f3));
                this.dragon.rotationYaw += this.dragon.randomYawVelocity;
            }
        }
    }
    else if (this.scanningTime >= 100)
    {
        entitylivingbase = this.dragon.world.getNearestAttackablePlayer(this.dragon, 150.0D, 150.0D);
        this.dragon.getPhaseManager().setPhase(PhaseList.TAKEOFF);

        if (entitylivingbase != null)
        {
            this.dragon.getPhaseManager().setPhase(PhaseList.CHARGING_PLAYER);
            ((PhaseChargingPlayer)this.dragon.getPhaseManager().getPhase(PhaseList.CHARGING_PLAYER)).setTarget(new Vec3d(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ));
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:54,代码来源:PhaseSittingScanning.java

示例14: getDamageBeforeAbsorb

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static float getDamageBeforeAbsorb(float damage, float totalArmor, float toughnessAttribute)
{
    float f = 2.0F + toughnessAttribute / 4.0F;
    float f1 = MathHelper.clamp(totalArmor - damage / f, totalArmor * 0.2F, 20.0F);
    return damage * (1.0F - f1 / 25.0F);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:7,代码来源:TF2Util.java

示例15: setPlayerViewRadius

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void setPlayerViewRadius(int radius)
{
    radius = MathHelper.clamp(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)
                    {
                        PlayerChunkMapEntry playerchunkmapentry = this.getOrCreateEntry(j1, k1);

                        if (!playerchunkmapentry.containsPlayer(entityplayermp))
                        {
                            playerchunkmapentry.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.getOrCreateEntry(l, i1).removePlayer(entityplayermp);
                        }
                    }
                }
            }
        }

        this.playerViewRadius = radius;
        this.markSortPending();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:48,代码来源:PlayerChunkMap.java


注:本文中的net.minecraft.util.math.MathHelper.clamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。