本文整理匯總了Java中net.minecraft.block.state.IBlockState.getMaterial方法的典型用法代碼示例。如果您正苦於以下問題:Java IBlockState.getMaterial方法的具體用法?Java IBlockState.getMaterial怎麽用?Java IBlockState.getMaterial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.block.state.IBlockState
的用法示例。
在下文中一共展示了IBlockState.getMaterial方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fall
import net.minecraft.block.state.IBlockState; //導入方法依賴的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);
}
}
}
示例2: isFree
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
private PathNodeType isFree(int p_186327_1_, int p_186327_2_, int p_186327_3_)
{
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int i = p_186327_1_; i < p_186327_1_ + this.entitySizeX; ++i)
{
for (int j = p_186327_2_; j < p_186327_2_ + this.entitySizeY; ++j)
{
for (int k = p_186327_3_; k < p_186327_3_ + this.entitySizeZ; ++k)
{
IBlockState iblockstate = this.blockaccess.getBlockState(blockpos$mutableblockpos.setPos(i, j, k));
if (iblockstate.getMaterial() != Material.WATER)
{
return PathNodeType.BLOCKED;
}
}
}
}
return PathNodeType.WATER;
}
示例3: playMoodSoundAndCheckLight
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn)
{
super.playMoodSoundAndCheckLight(p_147467_1_, p_147467_2_, chunkIn);
if (this.ambienceTicks == 0)
{
this.updateLCG = this.updateLCG * 3 + 1013904223;
int i = this.updateLCG >> 2;
int j = i & 15;
int k = i >> 8 & 15;
int l = i >> 16 & 255;
BlockPos blockpos = new BlockPos(j + p_147467_1_, l, k + p_147467_2_);
IBlockState iblockstate = chunkIn.getBlockState(blockpos);
j = j + p_147467_1_;
k = k + p_147467_2_;
if (iblockstate.getMaterial() == Material.AIR && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0 && this.mc.thePlayer != null && this.mc.thePlayer.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D)
{
this.playSound((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, SoundEvents.AMBIENT_CAVE, SoundCategory.AMBIENT, 0.7F, 0.8F + this.rand.nextFloat() * 0.2F, false);
this.ambienceTicks = this.rand.nextInt(12000) + 6000;
}
}
}
示例4: breakBlock
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
/**
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
*/
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
int i = 1;
int j = 2;
int k = pos.getX();
int l = pos.getY();
int i1 = pos.getZ();
if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2)))
{
for (int j1 = -1; j1 <= 1; ++j1)
{
for (int k1 = -1; k1 <= 1; ++k1)
{
for (int l1 = -1; l1 <= 1; ++l1)
{
BlockPos blockpos = pos.add(j1, k1, l1);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getMaterial() == Material.LEAVES && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
{
worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
}
}
}
}
}
}
示例5: addBlockDestroyEffects
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
public void addBlockDestroyEffects(BlockPos pos, IBlockState state)
{
boolean flag;
if (Reflector.ForgeBlock_addDestroyEffects.exists() && Reflector.ForgeBlock_isAir.exists())
{
Block block = state.getBlock();
flag = !Reflector.callBoolean(block, Reflector.ForgeBlock_isAir, new Object[] {state, this.worldObj, pos}) && !Reflector.callBoolean(block, Reflector.ForgeBlock_addDestroyEffects, new Object[] {this.worldObj, pos, this});
}
else
{
flag = state.getMaterial() != Material.AIR;
}
if (flag)
{
state = state.getActualState(this.worldObj, pos);
int l = 4;
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
for (int k = 0; k < 4; ++k)
{
double d0 = ((double)i + 0.5D) / 4.0D;
double d1 = ((double)j + 0.5D) / 4.0D;
double d2 = ((double)k + 0.5D) / 4.0D;
this.addEffect((new ParticleDigging(this.worldObj, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, state)).setBlockPos(pos));
}
}
}
}
}
示例6: checkBlockCollision
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
/**
* Returns true if there are any blocks in the region constrained by an AxisAlignedBB
*/
public boolean checkBlockCollision(AxisAlignedBB bb)
{
int i = MathHelper.floor_double(bb.minX);
int j = MathHelper.ceiling_double_int(bb.maxX);
int k = MathHelper.floor_double(bb.minY);
int l = MathHelper.ceiling_double_int(bb.maxY);
int i1 = MathHelper.floor_double(bb.minZ);
int j1 = MathHelper.ceiling_double_int(bb.maxZ);
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();
for (int k1 = i; k1 < j; ++k1)
{
for (int l1 = k; l1 < l; ++l1)
{
for (int i2 = i1; i2 < j1; ++i2)
{
IBlockState iblockstate = this.getBlockState(blockpos$pooledmutableblockpos.setPos(k1, l1, i2));
if (iblockstate.getMaterial() != Material.AIR)
{
blockpos$pooledmutableblockpos.release();
return true;
}
}
}
}
blockpos$pooledmutableblockpos.release();
return false;
}
示例7: getPossibleFlowDirections
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
private Set<EnumFacing> getPossibleFlowDirections(World worldIn, BlockPos pos)
{
int i = 1000;
Set<EnumFacing> set = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (!this.isBlocked(worldIn, blockpos, iblockstate) && (iblockstate.getMaterial() != this.blockMaterial || ((Integer)iblockstate.getValue(LEVEL)).intValue() > 0))
{
int j;
if (this.isBlocked(worldIn, blockpos.down(), worldIn.getBlockState(blockpos.down())))
{
j = this.getSlopeDistance(worldIn, blockpos, 1, enumfacing.getOpposite());
}
else
{
j = 0;
}
if (j < i)
{
set.clear();
}
if (j <= i)
{
set.add(enumfacing);
i = j;
}
}
}
return set;
}
示例8: canBlockStay
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
if (pos.getY() >= 0 && pos.getY() < 256)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
Material material = iblockstate.getMaterial();
return material == Material.WATER && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 || material == Material.ICE;
}
else
{
return false;
}
}
示例9: displaceIfPossible
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
/**
* Attempt to displace the block at (pos), return true if it was displaced.
*/
public boolean displaceIfPossible(World world, BlockPos pos)
{
if (world.isAirBlock(pos))
{
return true;
}
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == this)
{
return false;
}
if (displacements.containsKey(block))
{
if (displacements.get(block))
{
if (state.getBlock() != Blocks.SNOW_LAYER) //Forge: Vanilla has a 'bug' where snowballs don't drop like every other block. So special case because ewww...
block.dropBlockAsItem(world, pos, state, 0);
return true;
}
return false;
}
Material material = state.getMaterial();
if (material.blocksMovement() || material == Material.PORTAL)
{
return false;
}
int density = getDensity(world, pos);
if (density == Integer.MAX_VALUE)
{
block.dropBlockAsItem(world, pos, state, 0);
return true;
}
if (this.density > density)
{
return true;
}
else
{
return false;
}
}
示例10: canHarvestBlock
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
/**
* Check whether this Item can harvest the given Block
*/
public boolean canHarvestBlock(IBlockState blockIn)
{
Block block = blockIn.getBlock();
if (block == Blocks.OBSIDIAN)
{
return this.toolMaterial.getHarvestLevel() == 3;
}
else if (block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE)
{
if (block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK)
{
if (block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE)
{
if (block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE)
{
if (block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE)
{
if (block != Blocks.REDSTONE_ORE && block != Blocks.LIT_REDSTONE_ORE)
{
Material material = blockIn.getMaterial();
return material == Material.ROCK ? true : (material == Material.IRON ? true : material == Material.ANVIL);
}
else
{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
else
{
return this.toolMaterial.getHarvestLevel() >= 1;
}
}
else
{
return this.toolMaterial.getHarvestLevel() >= 1;
}
}
else
{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
else
{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
else
{
return this.toolMaterial.getHarvestLevel() >= 2;
}
}
示例11: handleMaterialAcceleration
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
/**
* handles the acceleration of an object whilst in water. Not sure if it is used elsewhere.
*/
public boolean handleMaterialAcceleration(AxisAlignedBB bb, Material materialIn, Entity entityIn)
{
int i = MathHelper.floor(bb.minX);
int j = MathHelper.ceil(bb.maxX);
int k = MathHelper.floor(bb.minY);
int l = MathHelper.ceil(bb.maxY);
int i1 = MathHelper.floor(bb.minZ);
int j1 = MathHelper.ceil(bb.maxZ);
if (!this.isAreaLoaded(i, k, i1, j, l, j1, true))
{
return false;
}
else
{
boolean flag = false;
Vec3d vec3d = Vec3d.ZERO;
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();
for (int k1 = i; k1 < j; ++k1)
{
for (int l1 = k; l1 < l; ++l1)
{
for (int i2 = i1; i2 < j1; ++i2)
{
blockpos$pooledmutableblockpos.setPos(k1, l1, i2);
IBlockState iblockstate = this.getBlockState(blockpos$pooledmutableblockpos);
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() == materialIn)
{
double d0 = (double)((float)(l1 + 1) - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
if ((double)l >= d0)
{
flag = true;
vec3d = block.modifyAcceleration(this, blockpos$pooledmutableblockpos, entityIn, vec3d);
}
}
}
}
}
blockpos$pooledmutableblockpos.release();
if (vec3d.lengthVector() > 0.0D && entityIn.isPushedByWater())
{
vec3d = vec3d.normalize();
double d1 = 0.014D;
entityIn.motionX += vec3d.xCoord * 0.014D;
entityIn.motionY += vec3d.yCoord * 0.014D;
entityIn.motionZ += vec3d.zCoord * 0.014D;
}
return flag;
}
}
示例12: getFluidHeight
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
private float getFluidHeight(IBlockAccess blockAccess, BlockPos blockPosIn, Material blockMaterial)
{
int i = 0;
float f = 0.0F;
for (int j = 0; j < 4; ++j)
{
BlockPos blockpos = blockPosIn.add(-(j & 1), 0, -(j >> 1 & 1));
if (blockAccess.getBlockState(blockpos.up()).getMaterial() == blockMaterial)
{
return 1.0F;
}
IBlockState iblockstate = blockAccess.getBlockState(blockpos);
Material material = iblockstate.getMaterial();
if (material != blockMaterial)
{
if (!material.isSolid())
{
++f;
++i;
}
}
else
{
int k = ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue();
if (k >= 8 || k == 0)
{
f += BlockLiquid.getLiquidHeightPercent(k) * 10.0F;
i += 10;
}
f += BlockLiquid.getLiquidHeightPercent(k);
++i;
}
}
return 1.0F - f / (float)i;
}
示例13: isWoodDoor
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
private boolean isWoodDoor(BlockPos pos)
{
IBlockState iblockstate = this.worldObj.getBlockState(pos);
Block block = iblockstate.getBlock();
return block instanceof BlockDoor ? iblockstate.getMaterial() == Material.WOOD : false;
}
示例14: generate
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position) {
int i = 2 + rand.nextInt(1) + this.minTreeHeight;
boolean flag = true;
if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
int k = 1;
if (j == position.getY()) {
k = 0;
}
if (j >= position.getY() + 1 + i - 2) {
k = 2;
}
BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos();
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
if (j >= 0 && j < worldIn.getHeight()) {
if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) {
flag = false;
}
} else {
flag = false;
}
}
}
}
if (!flag) {
return false;
} else {
IBlockState state = worldIn.getBlockState(position.down());
if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
this.setDirtAt(worldIn, position.down());
for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) {
int i4 = i3 - (position.getY() + i);
int j1 = 1 - i4 / 2;
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) {
int l1 = k1 - position.getX();
for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) {
int j2 = i2 - position.getZ();
if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) {
BlockPos blockpos = new BlockPos(k1, i3, i2);
state = worldIn.getBlockState(blockpos);
if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
}
}
}
}
}
for (int j3 = 0; j3 < i; ++j3) {
BlockPos upN = position.up(j3);
state = worldIn.getBlockState(upN);
if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
}
}
return true;
} else {
return false;
}
}
} else {
return false;
}
}
示例15: getStrVsBlock
import net.minecraft.block.state.IBlockState; //導入方法依賴的package包/類
@Override
public float getStrVsBlock(ItemStack stack, IBlockState state)
{
Material material = state.getMaterial();
return material != Material.GRASS && material != Material.GROUND && material != Material.CRAFTED_SNOW && material != Material.SNOW && material != Material.SAND && material != Material.CLAY && material != Material.GOURD ? super.getStrVsBlock(stack, state) : this.getStats(stack).getEfficiency();
}