本文整理汇总了Java中net.minecraft.util.math.MathHelper.ceiling_float_int方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.ceiling_float_int方法的具体用法?Java MathHelper.ceiling_float_int怎么用?Java MathHelper.ceiling_float_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.MathHelper
的用法示例。
在下文中一共展示了MathHelper.ceiling_float_int方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateFallState
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos) {
if (!this.isInWater())
{
this.handleWaterMovement();
}
if (!this.worldObj.isRemote && this.fallDistance > 3.0F && onGroundIn)
{
float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);
if (!state.getBlock().isAir(state, worldObj, pos))
{
double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
int i = (int)(150.0D * d0);
}
}
super.updateFallState(y, onGroundIn, state, pos);
}
示例2: fall
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public void fall(float distance, float damageMultiplier)
{
super.fall(distance, damageMultiplier);
int i = MathHelper.ceiling_float_int((distance - 3.0F) * damageMultiplier);
if (i > 0)
{
this.attackEntityFrom(DamageSource.fall, (float)i);
int j = MathHelper.floor_double(this.posX);
int k = MathHelper.floor_double(this.posY - 0.20000000298023224D);
int l = MathHelper.floor_double(this.posZ);
IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(j, k, l));
if (iblockstate.getMaterial() != Material.AIR)
{
SoundType soundtype = iblockstate.getBlock().getSoundType(iblockstate, worldObj, new BlockPos(j, k, l), this);
this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}
示例3: 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_float(-f); j <= MathHelper.ceiling_float_int(f); ++j)
{
for (int k = MathHelper.floor_float(-f); k <= MathHelper.ceiling_float_int(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;
}
示例4: 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.worldObj.isRemote && this.fallDistance > 3.0F && onGroundIn)
{
float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);
if (!state.getBlock().isAir(state, worldObj, pos))
{
double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
int i = (int)(150.0D * d0);
if (!state.getBlock().addLandingEffects(state, (WorldServer)this.worldObj, pos, state, this, i))
((WorldServer)this.worldObj).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);
}
示例5: fall
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, distance, damageMultiplier);
if (ret == null) return;
distance = ret[0]; damageMultiplier = ret[1];
super.fall(distance, damageMultiplier);
PotionEffect potioneffect = this.getActivePotionEffect(MobEffects.JUMP_BOOST);
float f = potioneffect == null ? 0.0F : (float)(potioneffect.getAmplifier() + 1);
int i = MathHelper.ceiling_float_int((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_double(this.posX);
int k = MathHelper.floor_double(this.posY - 0.20000000298023224D);
int l = MathHelper.floor_double(this.posZ);
IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(j, k, l));
if (iblockstate.getMaterial() != Material.AIR)
{
SoundType soundtype = iblockstate.getBlock().getSoundType(iblockstate, worldObj, new BlockPos(j, k, l), this);
this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}
示例6: fall
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
Block block = this.fallTile.getBlock();
if (this.hurtEntities)
{
int i = MathHelper.ceiling_float_int(distance - 1.0F);
if (i > 0)
{
List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
boolean flag = block == Blocks.ANVIL;
DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;
for (Entity entity : list)
{
entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
}
if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
{
int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
++j;
if (j > 2)
{
this.canSetAsBlock = true;
}
else
{
this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
}
}
}
}
}
示例7: 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.ceiling_float_int((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.worldObj.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(iblockstate, worldObj, new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ), this);
this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}
示例8: 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.ceiling_float_int(f * 15.0F);
}
else
{
return 0;
}
}
示例9: pathFollow
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void pathFollow()
{
Vec3d vec3d = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if ((double)this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3d.yCoord))
{
i = j;
break;
}
}
this.maxDistanceToWaypoint = this.theEntity.width > 0.75F ? this.theEntity.width / 2.0F : 0.75F - this.theEntity.width / 2.0F;
Vec3d vec3d1 = this.currentPath.getCurrentPos();
if (MathHelper.abs((float)(this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float)(this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D)
{
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
}
int k = MathHelper.ceiling_float_int(this.theEntity.width);
int l = MathHelper.ceiling_float_int(this.theEntity.height);
int i1 = k;
for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
{
if (this.isDirectPathBetweenPoints(vec3d, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1))
{
this.currentPath.setCurrentPathIndex(j1);
break;
}
}
this.checkForStuck(vec3d);
}
示例10: spawnDummyTracks
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Spawns dummy tracks based on flag linking.
*
* @return {@code null} if successful, otherwise the {@link net.minecraft.util.math.BlockPos BlockPos} of the first obstructing block.
*/
public BlockPos spawnDummyTracks() {
/*
* Make sure other tile entity is a flag.
*/
TileEntity tile = worldObj.getTileEntity(this.pos.add(linkedCurve.endPos));
if (!(tile instanceof TileEntitySurveyFlag)) {
return tile.getPos();
}
float width = getSleeperType().getDefaultWidth() - 1.0F;
if (width <= 0.0F) {
width = 0.0F;
}
final int ballast = MathHelper.ceiling_float_int( width / 2.0F );
final OFTCurve thisFlagCurve = linkedCurve;
final OFTCurve otherFlagCurve = ((TileEntitySurveyFlag) tile).linkedCurve;
final Map<BlockPos, Byte> blockMap = new HashMap<BlockPos, Byte>();
/*
* Need to see which end of the curve is higher.
* If we go top-down, the fake tracks are too high and ballast looks weird.
* On the other hand, if we went from the other direction we might miss ballast below the track.
* Steep hills tend to do this, so go in both directions just in case.
*/
BlockPos blockingBlock = addFakeTracksToMap(thisFlagCurve, this.pos, blockMap, ballast);
if(blockingBlock != null){
return blockingBlock;
}
blockingBlock = addFakeTracksToMap(otherFlagCurve, this.pos.add(linkedCurve.endPos), blockMap, ballast);
if(blockingBlock != null){
return blockingBlock;
}
/*
* Finally create fake tracks.
*/
BlockTrackFake.toggleMainTrackBreakage(false);
{
/* Set block states at selected positions. */
IBlockState defState = OFTRegistry.trackStructureFake.getDefaultState();
for (BlockPos placementPos : blockMap.keySet()) {
worldObj.setBlockState(placementPos, defState.withProperty(BlockTrackFake.height, (int) blockMap.get(placementPos)));
}
/* Set block states and tile entities at start and end. */
worldObj.setBlockState(this.pos, OFTRegistry.trackStructure.getDefaultState());
worldObj.setBlockState(this.pos.add(thisFlagCurve.endPos), OFTRegistry.trackStructure.getDefaultState());
TileEntityTrack startTile = new TileEntityTrack(thisFlagCurve);
TileEntityTrack endTile = new TileEntityTrack(otherFlagCurve);
startTile.setFakeTracks(new ArrayList<BlockPos>(blockMap.keySet()));
endTile.setFakeTracks(new ArrayList<BlockPos>(blockMap.keySet()));
worldObj.setTileEntity(this.pos, startTile);
worldObj.setTileEntity(this.pos.add(thisFlagCurve.endPos), endTile);
}
BlockTrackFake.toggleMainTrackBreakage(true);
return null;
}
示例11: ceil
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static int ceil(float p_ceil_0_)
{
return MathHelper.ceiling_float_int(p_ceil_0_);
}
示例12: 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.worldObj, this.thePlayer, this.removeCount);
if (!this.thePlayer.worldObj.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((float)i * f);
if (j < MathHelper.ceiling_float_int((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.worldObj.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, k));
}
}
this.removeCount = 0;
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(thePlayer, stack);
if (stack.getItem() == Items.IRON_INGOT)
{
this.thePlayer.addStat(AchievementList.ACQUIRE_IRON);
}
if (stack.getItem() == Items.COOKED_FISH)
{
this.thePlayer.addStat(AchievementList.COOK_FISH);
}
}