本文整理匯總了Java中net.minecraft.init.Blocks.ice方法的典型用法代碼示例。如果您正苦於以下問題:Java Blocks.ice方法的具體用法?Java Blocks.ice怎麽用?Java Blocks.ice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.init.Blocks
的用法示例。
在下文中一共展示了Blocks.ice方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateTick
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if (world.isRemote)
return;
int surroundingBlockCount = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (block == this || block == Blocks.ice || block == Blocks.packed_ice)
if (++surroundingBlockCount >= 4)
break;
}
if (surroundingBlockCount < 4 || rand.nextInt(100) <= 33) {
int meta = world.getBlockMetadata(x, y, z);
if (meta < 3)
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
else
world.setBlock(x, y, z, Blocks.water);
}
world.scheduleBlockUpdate(x, y, z, this, 40 + rand.nextInt(40));
}
示例2: generate
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
while (worldIn.isAirBlock(position) && position.getY() > 2)
{
position = position.down();
}
if (worldIn.getBlockState(position).getBlock() != Blocks.snow)
{
return false;
}
else
{
int i = rand.nextInt(this.basePathWidth - 2) + 2;
int j = 1;
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
{
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
{
int i1 = k - position.getX();
int j1 = l - position.getZ();
if (i1 * i1 + j1 * j1 <= i * i)
{
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
{
BlockPos blockpos = new BlockPos(k, k1, l);
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
{
worldIn.setBlockState(blockpos, this.block.getDefaultState(), 2);
}
}
}
}
}
return true;
}
}
示例3: canPlaceBlockAt
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
Block block = iblockstate.getBlock();
return block != Blocks.ice && block != Blocks.packed_ice ? (block.getMaterial() == Material.leaves ? true : (block == this && ((Integer)iblockstate.getValue(LAYERS)).intValue() >= 7 ? true : block.isOpaqueCube() && block.blockMaterial.blocksMovement())) : false;
}
示例4: onImpact
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
@Override
public void onImpact(MovingObjectPosition target)
{
if (target.entityHit != null) // We hit a living thing!
{
// Damage
target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float)this.damage);
target.entityHit.hurtResistantTime = 0; // No immunity frames
// Fire
target.entityHit.setFire(fireDuration);
}
else
{
Block block = this.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
// Glass breaking
Helper.tryBlockBreak(this.worldObj, this, target, 2); // Strong
// Let's create fire here
if (block != Blocks.fire)
{
if (this.worldObj.getBlock(target.blockX, target.blockY + 1, target.blockZ).isAir(this.worldObj, target.blockX, target.blockY + 1, target.blockZ))
{
// the block above the block we hit is air, so let's set it on fire!
this.worldObj.setBlock(target.blockX, target.blockY + 1, target.blockZ, Blocks.fire, 0, 3);
}
// else, not an airblock above this
}
// Have we hit snow? Turning that into snow layer
else if (block == Blocks.snow)
{
this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.snow_layer, 7, 3);
}
// Have we hit snow layer? Melting that down into nothing
else if (block == Blocks.snow_layer)
{
int currentMeta = this.worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
// Is this taller than 0? Melting it down then
if (currentMeta > 0) { this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.snow_layer, currentMeta - 1, 3); }
// Is this 0 already? Turning it into air
else { this.worldObj.setBlockToAir(target.blockX, target.blockY, target.blockZ); }
}
// Have we hit ice? Turning that into water
else if (block == Blocks.ice)
{
this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.water, 0, 3);
}
// Have we hit (flowing) water? Evaporating that
else if (block == Blocks.water || block == Blocks.flowing_water)
{
this.worldObj.setBlockToAir(target.blockX, target.blockY, target.blockZ);
}
}
// SFX
NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 4, (byte) 2);
this.worldObj.playSoundAtEntity(this, "fireworks.largeBlast", 0.7F, 1.5F);
// Going through terrain until our time runs out, but don't damage anything
}
示例5: onImpact
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
@Override
public void onImpact(MovingObjectPosition hitPos) // Server-side
{
if (hitPos.entityHit != null)
{
// Setting fire to the target here ...except for endermen? First fire, then damage
if (!(hitPos.entityHit instanceof EntityEnderman)) { hitPos.entityHit.setFire(this.fireDuration); }
// Damage
hitPos.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.shootingEntity), this.damage);
hitPos.entityHit.hurtResistantTime = 0; // No rest for the wicked
// Knockback
double f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f3 > 0.0F)
{
hitPos.entityHit.addVelocity(
this.motionX * (double)this.knockbackStrength * 0.6D / (double)f3,
0.1D,
this.motionZ * (double)this.knockbackStrength * 0.6D / (double)f3
);
}
if (!(hitPos.entityHit instanceof EntityEnderman)) { this.setDead(); } // We've hit an entity (that's not an enderman), so begone with the projectile
this.playSound("random.fizz", 0.5F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); // Sizzling along...
}
else
{
Block block = this.worldObj.getBlock(hitPos.blockX, hitPos.blockY, hitPos.blockZ);
// Let's melt ice on contact
if (block == Blocks.ice)
{
this.worldObj.setBlock(hitPos.blockX, hitPos.blockY, hitPos.blockZ, Blocks.flowing_water, 0, 3);
this.targetsHit += 1;
}
// Glass breaking, through 4 layers
if (Helper.tryBlockBreak(this.worldObj, this, hitPos, 2) && this.targetsHit < 4) { this.targetsHit += 1; } // Going straight through most things
else // Either didn't manage to break that block or we already hit 4 things
{
this.stuckBlockX = hitPos.blockX;
this.stuckBlockY = hitPos.blockY;
this.stuckBlockZ = hitPos.blockZ;
this.stuckBlock = this.worldObj.getBlock(this.stuckBlockX, this.stuckBlockY, this.stuckBlockZ);
this.inData = this.worldObj.getBlockMetadata(this.stuckBlockX, this.stuckBlockY, this.stuckBlockZ);
this.motionX = (double)((float)(hitPos.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(hitPos.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(hitPos.hitVec.zCoord - this.posZ));
float distance = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)distance * 0.05000000074505806D;
this.posY -= this.motionY / (double)distance * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)distance * 0.05000000074505806D;
this.inGround = true;
this.arrowShake = 7;
if (this.stuckBlock.getMaterial() != Material.air)
{
this.stuckBlock.onEntityCollidedWithBlock(this.worldObj, this.stuckBlockX, this.stuckBlockY, this.stuckBlockZ, this);
}
}
}
}
示例6: onImpact
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
@Override
public void onImpact(MovingObjectPosition target)
{
if (target.entityHit != null) // We hit a living thing!
{
// Damage
target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
target.entityHit.hurtResistantTime = 0;
// Effect
target.entityHit.setFire(this.fireDuration);
}
else
{
Block block = this.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
// Glass breaking
Helper.tryBlockBreak(this.worldObj, this, target, 1); // Medium
// Let's create fire here (if we're allowed to)
if (this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && block != Blocks.fire)
{
if (this.worldObj.getBlock(target.blockX, target.blockY + 1, target.blockZ).isAir(this.worldObj, target.blockX, target.blockY + 1, target.blockZ))
{
// the block above the block we hit is air, so let's set it on fire!
this.worldObj.setBlock(target.blockX, target.blockY + 1, target.blockZ, Blocks.fire, 0, 3);
}
// else, not a airblock above this
}
// Have we hit snow? Turning that into snow layer
if (block == Blocks.snow)
{
this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.snow_layer, 7, 3);
}
// Have we hit snow layer? Melting that down into nothing
else if (block == Blocks.snow_layer)
{
int currentMeta = this.worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
// Is this taller than 0? Melting it down then
if (currentMeta > 0) { this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.snow_layer, currentMeta - 1, 3); }
// Is this 0 already? Turning it into air
else { this.worldObj.setBlockToAir(target.blockX, target.blockY, target.blockZ); }
}
// Have we hit ice? Turning that into water
else if (block == Blocks.ice)
{
this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.water, 0, 3);
}
Block topBlock = this.worldObj.getBlock(target.blockX, target.blockY + 1, target.blockZ);
// Did we hit grass? Burning it
if (topBlock.getMaterial() == Material.plants)
{
this.worldObj.setBlock(target.blockX, target.blockY + 1, target.blockZ, Blocks.fire, 0, 3);
}
if (block.getMaterial() == Material.plants)
{
this.worldObj.setBlock(target.blockX, target.blockY, target.blockZ, Blocks.fire, 0, 3);
}
}
// SFX
this.worldObj.playSoundAtEntity(this, "random.fizz", 0.7F, 1.5F);
this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
this.setDead(); // We've hit something, so begone with the projectile. hitting glass only once
}