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


Java MathHelper.ceil方法代码示例

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


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

示例1: updateFallState

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos)
{
    if (!this.isInWater())
    {
        this.handleWaterMovement();
    }

    if (!this.world.isRemote && this.fallDistance > 3.0F && onGroundIn)
    {
        float f = (float)MathHelper.ceil(this.fallDistance - 3.0F);

        if (state.getMaterial() != Material.AIR)
        {
            double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
            int i = (int)(150.0D * d0);
            ((WorldServer)this.world).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(state)});
        }
    }

    super.updateFallState(y, onGroundIn, state, pos);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:EntityLivingBase.java

示例2: generate

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    float f = (float)(rand.nextInt(3) + 4);

    for (int i = 0; f > 0.5F; --i)
    {
        for (int j = MathHelper.floor(-f); j <= MathHelper.ceil(f); ++j)
        {
            for (int k = MathHelper.floor(-f); k <= MathHelper.ceil(f); ++k)
            {
                if ((float)(j * j + k * k) <= (f + 1.0F) * (f + 1.0F))
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(j, i, k), Blocks.END_STONE.getDefaultState());
                }
            }
        }

        f = (float)((double)f - ((double)rand.nextInt(2) + 0.5D));
    }

    return true;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:WorldGenEndIsland.java

示例3: fall

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
    super.fall(distance, damageMultiplier);
    PotionEffect potioneffect = this.getActivePotionEffect(MobEffects.JUMP_BOOST);
    float f = potioneffect == null ? 0.0F : (float)(potioneffect.getAmplifier() + 1);
    int i = MathHelper.ceil((distance - 3.0F - f) * damageMultiplier);

    if (i > 0)
    {
        this.playSound(this.getFallSound(i), 1.0F, 1.0F);
        this.attackEntityFrom(DamageSource.fall, (float)i);
        int j = MathHelper.floor(this.posX);
        int k = MathHelper.floor(this.posY - 0.20000000298023224D);
        int l = MathHelper.floor(this.posZ);
        IBlockState iblockstate = this.world.getBlockState(new BlockPos(j, k, l));

        if (iblockstate.getMaterial() != Material.AIR)
        {
            SoundType soundtype = iblockstate.getBlock().getSoundType();
            this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EntityLivingBase.java

示例4: drawMekGasContent

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Optional.Method(modid = "mekanism")
private void drawMekGasContent() {
    if(tank.getTank() instanceof HybridGasTank) {
        GasStack gasContent = ((HybridGasTank) tank.getTank()).getGas();
        if(gasContent != null && gasContent.amount > 0) {
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            float percFilled = ((float) gasContent.amount) / ((float) tank.getTank().getCapacity());
            percFilled = MathHelper.clamp(percFilled, 0F, 1F);
            int pxFilled = MathHelper.ceil(percFilled * 61F);
            TextureAtlasSprite tas = gasContent.getGas().getSprite();
            if(tas == null) {
                tas = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
            }
            this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            drawTexturedModalRect(15, 10 + 61 - pxFilled, tas, 20, pxFilled);
        }
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:19,代码来源:GuiContainerFluidHatch.java

示例5: getEntitiesWithinAABB

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public <T extends Entity> List<T> getEntitiesWithinAABB(Class <? extends T > clazz, AxisAlignedBB aabb, @Nullable Predicate <? super T > filter)
{
    int i = MathHelper.floor((aabb.minX - 2.0D) / 16.0D);
    int j = MathHelper.ceil((aabb.maxX + 2.0D) / 16.0D);
    int k = MathHelper.floor((aabb.minZ - 2.0D) / 16.0D);
    int l = MathHelper.ceil((aabb.maxZ + 2.0D) / 16.0D);
    List<T> list = Lists.<T>newArrayList();

    for (int i1 = i; i1 < j; ++i1)
    {
        for (int j1 = k; j1 < l; ++j1)
        {
            if (this.isChunkLoaded(i1, j1, true))
            {
                this.getChunkFromChunkCoords(i1, j1).getEntitiesOfTypeWithinAAAB(clazz, aabb, list, filter);
            }
        }
    }

    return list;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:World.java

示例6: fall

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound(SoundEvents.ENTITY_HORSE_LAND, 0.4F, 1.0F);
    }

    int i = MathHelper.ceil((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.isBeingRidden())
        {
            for (Entity entity : this.getRecursivePassengers())
            {
                entity.attackEntityFrom(DamageSource.fall, (float)i);
            }
        }

        IBlockState iblockstate = this.world.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ));
        Block block = iblockstate.getBlock();

        if (iblockstate.getMaterial() != Material.AIR && !this.isSilent())
        {
            SoundType soundtype = block.getSoundType();
            this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:32,代码来源:AbstractHorse.java

示例7: isAboveLand

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static boolean isAboveLand(Entity entity){
    if(entity == null) return false;

    double y = entity.posY - 0.01;

    for(int x = MathHelper.floor(entity.posX); x < MathHelper.ceil(entity.posX); x++)
        for (int z = MathHelper.floor(entity.posZ); z < MathHelper.ceil(entity.posZ); z++) {
            BlockPos pos = new BlockPos(x, MathHelper.floor(y), z);

            if (getWorld().getBlockState(pos).getBlock().isFullBlock(getWorld().getBlockState(pos))) return true;
        }

    return false;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:16,代码来源:Jesus.java

示例8: onCrafting

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
protected void onCrafting(ItemStack stack) {
    stack.onCrafting(this.player.world, this.player, this.removeCount);

    if (!this.player.world.isRemote) {
        int i = this.removeCount;
        CraftiniumSmelt smelt = CraftiniumSmeltRegistry.findMatchingXp(stack, this.player.world, this.forge);
        float f = smelt == null ? 0 : smelt.experience(stack, this.player.world, this.forge);

        if (f == 0.0F) {
            i = 0;
        } else if (f < 1.0F) {
            int j = MathHelper.floor((float) i * f);

            if (j < MathHelper.ceil((float) i * f) && Math.random() < (double) ((float) i * f - (float) j)) {
                ++j;
            }

            i = j;
        }

        while (i > 0) {
            int k = EntityXPOrb.getXPSplit(i);
            i -= k;
            this.player.world.spawnEntity(new EntityXPOrb(this.player.world, this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
        }
    }

    this.removeCount = 0;

    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:33,代码来源:CraftiniumForgeOutputSlot.java

示例9: generateTopLeaves

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void generateTopLeaves(World world, BlockPos genPos, BlockPos branchPos, int treeHeight, int leavesBase, Random rand, boolean alternate,
        int maxLeavesLength, boolean irregular, boolean inverted, IBlockState leaves) {
    boolean alt = false;
    float percent;
    int leavesLength;

    if (leavesBase > branchPos.getY()) {
        return;
    }

    generateBranchLeaves(world, branchPos, rand, true, 1, leaves);

    while (branchPos.getY() > leavesBase) {
        branchPos = branchPos.add(0, -1, 0);

        percent = ((branchPos.getY() - leavesBase) / (float) (genPos.getY() + treeHeight - leavesBase));

        if (!inverted) {
            percent = 1 - percent;
        }

        leavesLength = MathHelper.ceil(maxLeavesLength * percent);

        if (leavesLength > maxLeavesLength) {
            leavesLength = maxLeavesLength;
        }

        if (alt || !alternate || (irregular && rand.nextInt(5) == 0)) {
            generateBranchLeaves(world, branchPos, rand, false, leavesLength, irregular, leaves);
        }

        alt = !alt;
    }
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:35,代码来源:WorldGenAbstractGenesisTree.java

示例10: onCrafting

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
protected void onCrafting(ItemStack stack)
{
    stack.onCrafting(this.player.world, this.player, this.removeCount);

    if (!this.player.world.isRemote)
    {
        int i = this.removeCount;
        float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            int j = MathHelper.floor((float)i * f);

            if (j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
            {
                ++j;
            }

            i = j;
        }

        while (i > 0)
        {
            int k = EntityXPOrb.getXPSplit(i);
            i -= k;
            this.player.world.spawnEntity(new EntityXPOrb(this.player.world, this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
        }
    }

    this.removeCount = 0;
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:40,代码来源:SlotOutput.java

示例11: isInWater

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private static boolean isInWater(Entity entity) {
	if(entity == null) return false;

	double y = entity.posY + 0.01;

	for(int x = MathHelper.floor(entity.posX); x < MathHelper.ceil(entity.posX); x++)
		for (int z = MathHelper.floor(entity.posZ); z < MathHelper.ceil(entity.posZ); z++) {
			BlockPos pos = new BlockPos(x, (int) y, z);

			if (Wrapper.getWorld().getBlockState(pos).getBlock() instanceof BlockLiquid) return true;
		}

	return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:Jesus.java

示例12: fall

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
    int i = MathHelper.ceil((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        if (distance >= 6.0F)
        {
            this.attackEntityFrom(DamageSource.fall, (float)i);

            if (this.isBeingRidden())
            {
                for (Entity entity : this.getRecursivePassengers())
                {
                    entity.attackEntityFrom(DamageSource.fall, (float)i);
                }
            }
        }

        IBlockState iblockstate = this.world.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ));
        Block block = iblockstate.getBlock();

        if (iblockstate.getMaterial() != Material.AIR && !this.isSilent())
        {
            SoundType soundtype = block.getSoundType();
            this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:30,代码来源:EntityLlama.java

示例13: computeRedstoneStrength

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
{
    int i = Math.min(worldIn.getEntitiesWithinAABB(Entity.class, PRESSURE_AABB.offset(pos)).size(), this.maxWeight);

    if (i > 0)
    {
        float f = (float)Math.min(this.maxWeight, i) / (float)this.maxWeight;
        return MathHelper.ceil(f * 15.0F);
    }
    else
    {
        return 0;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:BlockPressurePlateWeighted.java

示例14: smeltItem

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Turn one item from the furnace source stack into the appropriate smelted
 * item in the furnace result stack
 */
@SuppressWarnings("unchecked")
public void smeltItem() {
	int ammoToConsume = MathHelper.ceil(
			TF2CraftingManager.AMMO_RECIPES[this.ammoSmeltType].getRecipeOutput().getCount() * 1.2f);
	for (int i = 0; i < 9; i++) {
		ItemStack base = this.furnaceItemStacks.get(i);
		if (base != null && base.getItem() instanceof ItemAmmo && base.getItemDamage() == this.ammoSmeltType) {

			ShapelessOreRecipe recipe = TF2CraftingManager.AMMO_RECIPES[base.getItemDamage()];
			int ammoConsumed = Math.min(base.getCount(), ammoToConsume);
			base.shrink(ammoConsumed);
			ammoToConsume -= ammoConsumed;
			if (base.getCount() <= 0)
				this.setInventorySlotContents(i, ItemStack.EMPTY);

			if (ammoToConsume <= 0) {
				for (Ingredient obj : recipe.getIngredients()) {

					ItemStack out=obj.getMatchingStacks()[0];
					for (int j = 10; j < 19; j++) {
						boolean handled = false;
						ItemStack inSlot = this.getStackInSlot(j);
						if (inSlot.isEmpty()) {
							this.setInventorySlotContents(j, out.copy());
							handled = true;
						} else if (out.isItemEqual(inSlot) && ItemStack.areItemStackTagsEqual(out, inSlot)) {
							int size = out.getCount() + inSlot.getCount();

							if (size <= out.getMaxStackSize()) {
								inSlot.setCount( size);
								handled = true;
							}
						}
						if (handled)
							break;
					}
				}
				return;
			}
		}
	}
	/*
	 * ItemStack itemstack =
	 * FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]
	 * );
	 * 
	 * if (this.furnaceItemStacks[2] == null) { this.furnaceItemStacks[2] =
	 * itemstack.copy(); } else if (this.furnaceItemStacks[2].getItem() ==
	 * itemstack.getItem()) { this.furnaceItemStacks[2].getCount() +=
	 * itemstack.getCount(); // Forge BugFix: Results may have multiple items
	 * }
	 * 
	 * if (this.furnaceItemStacks[0].getItem() ==
	 * Item.getItemFromBlock(Blocks.SPONGE) &&
	 * this.furnaceItemStacks[0].getMetadata() == 1 &&
	 * this.furnaceItemStacks[1] != null &&
	 * this.furnaceItemStacks[1].getItem() == Items.BUCKET) {
	 * this.furnaceItemStacks[1] = new ItemStack(Items.WATER_BUCKET); }
	 * 
	 * --this.furnaceItemStacks[0].getCount();
	 * 
	 * if (this.furnaceItemStacks[0].getCount() <= 0) {
	 * this.furnaceItemStacks[0] = null; }
	 */
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:70,代码来源:TileEntityAmmoFurnace.java

示例15: onCrafting

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
protected void onCrafting(ItemStack stack)
{
    stack.onCrafting(this.thePlayer.world, this.thePlayer, this.removeCount);

    if (!this.thePlayer.world.isRemote)
    {
        int i = this.removeCount;
        float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            int j = MathHelper.floor((float)i * f);

            if (j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
            {
                ++j;
            }

            i = j;
        }

        while (i > 0)
        {
            int k = EntityXPOrb.getXPSplit(i);
            i -= k;
            this.thePlayer.world.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.world, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, k));
        }
    }

    this.removeCount = 0;

    if (stack.getItem() == Items.IRON_INGOT)
    {
        this.thePlayer.addStat(AchievementList.ACQUIRE_IRON);
    }

    if (stack.getItem() == Items.COOKED_FISH)
    {
        this.thePlayer.addStat(AchievementList.COOK_FISH);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:49,代码来源:SlotFurnaceOutput.java


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