本文整理了Java中net.minecraft.block.Block.getBlockHardness()
方法的一些代码示例,展示了Block.getBlockHardness()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getBlockHardness()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getBlockHardness
暂无
代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft
@SuppressWarnings("deprecation")
@Override
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos)
{
return modelBlock.getBlockHardness(blockState, worldIn, pos);
}
代码示例来源:origin: DimensionalDevelopment/VanillaFix
@Override
public float getBlockHardness(World world, BlockPos pos) {
return block.getBlockHardness(this, world, pos);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private BlockSlabCommon( Block block )
{
super( block.getMaterial( block.getDefaultState() ) );
this.setHardness( block.getBlockHardness( block.getDefaultState(), null, null ) );
this.setResistance( block.getExplosionResistance( null ) * 5.0F / 3.0F );
IBlockState iblockstate = this.blockState.getBaseState();
if( !this.isDouble() )
{
iblockstate = iblockstate.withProperty( HALF, BlockSlab.EnumBlockHalf.BOTTOM );
}
this.setDefaultState( iblockstate.withProperty( VARIANT, Variant.DEFAULT ) );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.useNeighborBrightness = true;
}
代码示例来源:origin: DimensionalDevelopment/VanillaFix
@Override
public float getBlockHardness(World worldIn, BlockPos pos) {
return normalState.getBlock().getBlockHardness(this, worldIn, pos);
}
代码示例来源:origin: CyclopsMC/EvilCraft
@Override
public float getBlockHardness(IBlockState blockState, World world, BlockPos blockPos) {
try {
return getTile(world, blockPos).getInnerBlockState().getBlock().getBlockHardness(blockState, world, blockPos);
} catch (InvalidInnerBlocksTileException e) {
return Blocks.COBBLESTONE.getBlockHardness(blockState, world, blockPos);
} catch (IllegalArgumentException e) {
return Blocks.COBBLESTONE.getBlockHardness(blockState, world, blockPos);
}
}
代码示例来源:origin: PrinceOfAmber/Cyclic
@SuppressWarnings("deprecation")
public static float getBlockHardness(IBlockState state, World worldIn, BlockPos pos) {
//no way the forge hooks one has a stupid thing where <0 returns 0
return state.getBlock().getBlockHardness(state, worldIn, pos);
// return b.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
}
代码示例来源:origin: CyclopsMC/EvilCraft
@Override
public float getBlockHardness(IBlockState blockState, World world, BlockPos blockPos) {
return getBlockFromState(blockState).getBlock().getBlockHardness(blockState, world, blockPos);
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Gets the hardness of a block without risk of a crash due to unsupported use.
*
* @param state The block state to check.
* @param world The world object.
* @param pos The position of the block.
* @return The hardness of the block. If an exception occurs this will be 99999f.
*/
public static float getHardnessSafely (IBlockState state, World world, BlockPos pos) {
try {
return state.getBlock().getBlockHardness(state, world, pos);
}
catch (final Exception e) {
Constants.LOG.trace("Error checking hardness for " + state.toString(), e);
// TODO better fallback code
return 99999f;
}
}
代码示例来源:origin: AlgorithmX2/Chisels-and-Bits
@Override
@Deprecated
public float getBlockHardness(
final IBlockState state,
final World worldIn,
final BlockPos pos )
{
try
{
return getTileEntity( worldIn, pos ).getBlockInfo( this ).hardness;
}
catch ( final ExceptionNoTileEntity e )
{
Log.noTileError( e );
return super.getBlockHardness( state, worldIn, pos );
}
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
@Override
@Deprecated
@SuppressWarnings("deprecation")
public float getBlockHardness(IBlockState blockState, World world, BlockPos pos) {
TileEntityBoundingBox te = getTileEntity(world, pos);
return te.getOwnerBlock().getBlockHardness(world.getBlockState(te.getOwnerPos()), world, te.getOwnerPos());
}
代码示例来源:origin: Vazkii/Quark
public void fill(World world, BlockPos pos, UndergroundBiomeGenerationContext context) {
IBlockState state = world.getBlockState(pos);
if(state.getBlock().getBlockHardness(state, world, pos) == -1 || world.canBlockSeeSky(pos))
return;
if(isFloor(world, pos, state)) {
context.floorList.add(pos);
fillFloor(world, pos, state);
} else if(isCeiling(world, pos, state)) {
context.ceilingList.add(pos);
fillCeiling(world, pos, state);
} else if(isWall(world, pos, state)) {
context.wallMap.put(pos, getBorderSide(world, pos));
fillWall(world, pos, state);
} else if(isInside(world, pos, state)) {
context.insideList.add(pos);
fillInside(world, pos, state);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public boolean canDestroyBlock(BlockPos pos){
float hardness = world.getBlockState(pos).getBlock().getBlockHardness(world.getBlockState(pos), world, pos);
return world.getBlockState(pos).getBlock().canEntityDestroy(world.getBlockState(pos), world, pos, this) && hardness >= 0;
}
代码示例来源:origin: McJtyMods/DeepResonance
private static void explodeHelper(World world, BlockPos location, float radius) {
Explosion boom = new Explosion(world, null, location.getX(), location.getY(), location.getZ(), radius, false, true);
for(int x = (int)(-radius); x < radius; ++x) {
for(int y = (int)(-radius); y < radius; ++y) {
for(int z = (int)(-radius); z < radius; ++z) {
BlockPos targetPosition = location.add(x, y, z);
double dist = Math.sqrt(location.distanceSq(targetPosition));
if(dist < radius) {
Block block = world.getBlockState(targetPosition).getBlock();
IBlockState state = world.getBlockState(targetPosition);
if(block != null && !block.isAir(state, world, targetPosition) && block.getBlockHardness(state, world, targetPosition) > 0 && (dist < (radius - 1.0F) || world.rand.nextFloat() > 0.7D)) {
block.onBlockExploded(world, targetPosition, boom);
}
}
}
}
}
}
代码示例来源:origin: Vazkii/Quark
IBlockState stateAt = world.getBlockState(pos);
Block block = stateAt.getBlock();
if(block.getBlockHardness(stateAt, world, pos) == -1)
break;
代码示例来源:origin: McJtyMods/TheOneProbe
private void showDebugInfo(IProbeInfo probeInfo, World world, IBlockState blockState, BlockPos pos, Block block, EnumFacing side) {
String simpleName = block.getClass().getSimpleName();
IProbeInfo vertical = probeInfo.vertical(new LayoutStyle().borderColor(0xffff4444).spacing(2))
.text(LABEL + "Reg Name: " + INFO + block.getRegistryName().toString())
.text(LABEL + "Unlocname: " + INFO + block.getUnlocalizedName())
.text(LABEL + "Meta: " + INFO + blockState.getBlock().getMetaFromState(blockState))
.text(LABEL + "Class: " + INFO + simpleName)
.text(LABEL + "Hardness: " + INFO + block.getBlockHardness(blockState, world, pos))
.text(LABEL + "Power W: " + INFO + block.getWeakPower(blockState, world, pos, side.getOpposite())
+ LABEL + ", S: " + INFO + block.getStrongPower(blockState, world, pos, side.getOpposite()))
.text(LABEL + "Light: " + INFO + block.getLightValue(blockState, world, pos));
TileEntity te = world.getTileEntity(pos);
if (te != null) {
vertical.text(LABEL + "TE: " + INFO + te.getClass().getSimpleName());
}
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public static void setOres(World world, BlockPos pos) {
float hardness = world.getBlockState(pos).getBlock().getBlockHardness(world.getBlockState(pos), world, pos);
if(hardness == -1.0F || world.isAirBlock(pos)){
return;
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
public AncientSlabBlock(TreeType type, IBlockState referenceState) {
super(referenceState.getBlock().getMaterial(referenceState));
this.type = type;
IBlockState state = this.blockState.getBaseState();
if (!this.isDouble()) {
state = state.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
}
Block block = state.getBlock();
this.setHardness(block.getBlockHardness(state, null, null));
this.setResistance((block.getExplosionResistance(null) * 5.0F) / 3.0F);
this.setSoundType(SoundType.WOOD);
this.setHarvestLevel(block.getHarvestTool(state), block.getHarvestLevel(state));
this.setUnlocalizedName(type.name().toLowerCase(Locale.ENGLISH) + "_slab");
this.setDefaultState(state);
}
代码示例来源:origin: CoFH/ThermalFoundation
protected void interactWithBlock(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
if (state.getBlock().isAir(state, world, pos) || state.getBlock() == this) {
return;
}
if (extreme && state.getMaterial() == Material.ROCK && state.getBlock().getBlockHardness(state, world, pos) > 0) {
state.getBlock().dropBlockAsItem(world, pos, state, 0);
world.setBlockToAir(pos);
triggerInteractionEffects(world, pos);
} else if (hasInteraction(state)) {
world.setBlockState(pos, getInteraction(state), 3);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
if (blockpos.distanceSq(position) <= (double) (f * f)) {
IBlockState state = world.getBlockState(blockpos);
float hardness = state.getBlock().getBlockHardness(state, world, blockpos);
if(hardness != -1.0F) {
if (state.getMaterial() == Material.GRASS || state.getMaterial() == Material.CRAFTED_SNOW && world.canBlockSeeSky(blockpos)) {
代码示例来源:origin: Vazkii/Quark
private void pickupDefense(EntityEnderman entity, EntityLivingBase target, BlockPos pos) {
if(entity.ticksExisted % delay != 0 && (ignoreMobGriefing || !entity.world.getGameRules().getBoolean("mobGriefing")))
return;
Vec3d look = entity.getLookVec();
pos = pos.add((int) (look.x * 1.2), 0, (int) (look.z * 1.2));
entity.swingArm(EnumHand.MAIN_HAND);
IBlockState state = entity.world.getBlockState(pos);
Block block = state.getBlock();
boolean unbreakable = block.getBlockHardness(state, entity.world, pos) == -1 || !block.canEntityDestroy(state, entity.world, pos, entity);
if(!unbreakable && block.getCollisionBoundingBox(state, entity.getEntityWorld(), pos) != null) {
List<ItemStack> drops = block.getDrops(entity.world, pos, state, 0);
entity.world.setBlockToAir(pos);
entity.world.playEvent(2001, pos, Block.getStateId(state));
if(!target.world.isRemote)
for(ItemStack drop : drops)
entity.world.spawnEntity(new EntityItem(entity.world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop));
}
}
内容来源于网络,如有侵权,请联系作者删除!