use of net.minecraft.block.material.Material in project MinecraftForge by MinecraftForge.
the class BlockFluidBase method canDisplace.
/**
* Returns true if the block at (pos) is displaceable. Does not displace the block.
*/
public boolean canDisplace(IBlockAccess world, BlockPos pos) {
if (world.isAirBlock(pos))
return true;
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == this) {
return false;
}
if (displacements.containsKey(state.getBlock())) {
return displacements.get(state.getBlock());
}
Material material = state.getMaterial();
if (material.blocksMovement() || material == Material.PORTAL) {
return false;
}
int density = getDensity(world, pos);
if (density == Integer.MAX_VALUE) {
return true;
}
if (this.density > density) {
return true;
} else {
return false;
}
}
use of net.minecraft.block.material.Material in project MineFactoryReloaded by powercrystals.
the class BlockVanillaIce method harvestBlock.
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
player.addStat(StatList.mineBlockStatArray[this.blockID], 1);
player.addExhaustion(0.025F);
if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player)) {
ItemStack droppedStack = this.createStackedBlock(meta);
if (droppedStack != null) {
this.dropBlockAsItem_do(world, x, y, z, droppedStack);
}
} else {
if (world.provider.isHellWorld) {
return;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
this.dropBlockAsItem(world, x, y, z, meta, fortune);
Material var8 = world.getBlockMaterial(x, y - 1, z);
if ((var8.blocksMovement() || var8.isLiquid()) && meta == 0) {
world.setBlock(x, y, z, Block.waterMoving.blockID);
}
}
}
use of net.minecraft.block.material.Material in project Overloaded by CJ-MC-Mods.
the class CompressedBlockHandler method CreateCompressedBlocks.
public static Map<Integer, Block> CreateCompressedBlocks(@Nonnull Block toCompress, int depth, boolean recipeEnabled) {
Map<Integer, Block> compressedBlocks = new HashMap<>();
Material material = toCompress.getDefaultState().getMaterial();
String registryName = toCompress.getRegistryName().getResourcePath();
String unlocalizedName = toCompress.getUnlocalizedName();
float baseHardness = toCompress.getDefaultState().getBlockHardness(null, null);
String harvestTool = toCompress.getHarvestTool(toCompress.getDefaultState());
int harvestLevel = toCompress.getHarvestLevel(toCompress.getDefaultState());
compressedBlocks.put(0, toCompress);
Block previousLevel = toCompress;
float currentHardness = baseHardness;
for (int i = 1; i <= depth; i++) {
String compRegistryName = String.format("compressed%s%d", registryName, i);
String compUnlocalizedName = String.format("%dxCompressed:%s", i, unlocalizedName);
currentHardness *= 9;
if (currentHardness < 0) {
currentHardness = Float.MAX_VALUE;
}
BlockCompressed block = new BlockCompressed(toCompress, previousLevel, i, material, compRegistryName, compUnlocalizedName, currentHardness, harvestTool, harvestLevel, recipeEnabled);
previousLevel = block;
compressedBlocks.put(i, block);
}
return compressedBlocks;
}
use of net.minecraft.block.material.Material in project ImmersiveEngineering by BluSunrize.
the class Utils method getFlowVector.
public static Vec3d getFlowVector(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockFluidBase)
return ((BlockFluidBase) state.getBlock()).getFlowVector(world, pos);
else if (!(state.getBlock() instanceof BlockLiquid))
return new Vec3d(0, 0, 0);
BlockLiquid block = (BlockLiquid) state.getBlock();
Vec3d vec3 = new Vec3d(0.0D, 0.0D, 0.0D);
Material mat = state.getMaterial();
int i = getEffectiveFlowDecay(world, pos, mat);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
BlockPos blockpos = pos.offset(enumfacing);
int j = getEffectiveFlowDecay(world, blockpos, mat);
if (j < 0) {
if (!world.getBlockState(blockpos).getMaterial().blocksMovement()) {
j = getEffectiveFlowDecay(world, blockpos.down(), mat);
if (j >= 0) {
int k = j - (i - 8);
vec3 = vec3.addVector((double) ((blockpos.getX() - pos.getX()) * k), (double) ((blockpos.getY() - pos.getY()) * k), (double) ((blockpos.getZ() - pos.getZ()) * k));
}
}
} else if (j >= 0) {
int l = j - i;
vec3 = vec3.addVector((double) ((blockpos.getX() - pos.getX()) * l), (double) ((blockpos.getY() - pos.getY()) * l), (double) ((blockpos.getZ() - pos.getZ()) * l));
}
}
if (state.getValue(BlockLiquid.LEVEL).intValue() >= 8) {
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL) {
BlockPos blockpos1 = pos.offset(enumfacing1);
if (block.isBlockSolid(world, blockpos1, enumfacing1) || block.isBlockSolid(world, blockpos1.up(), enumfacing1)) {
vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D);
break;
}
}
}
return vec3.normalize();
}
use of net.minecraft.block.material.Material in project NetherEx by LogicTechCorp.
the class WorldGenPit method generate.
@Override
public boolean generate(World world, Random rand, BlockPos pos) {
for (pos = pos.add(-8, 0, -8); pos.getY() > 33 && (world.isAirBlock(pos) || world.getBlockState(pos) == blockToIgnore); pos = pos.down()) {
}
if (pos.getY() < 33) {
return false;
} else {
boolean[] hasSpace = new boolean[2048];
int i = rand.nextInt(4) + 4;
pos = pos.down(4);
for (int j = 0; j < i; ++j) {
double d0 = rand.nextDouble() * 6.0D + 3.0D;
double d1 = rand.nextDouble() * 4.0D + 2.0D;
double d2 = rand.nextDouble() * 6.0D + 3.0D;
double d3 = rand.nextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
double d4 = rand.nextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
double d5 = rand.nextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;
for (int l = 1; l < 15; ++l) {
for (int i1 = 1; i1 < 15; ++i1) {
for (int j1 = 1; j1 < 7; ++j1) {
double d6 = ((double) l - d3) / (d0 / 2.0D);
double d7 = ((double) j1 - d4) / (d1 / 2.0D);
double d8 = ((double) i1 - d5) / (d2 / 2.0D);
double d9 = d6 * d6 + d7 * d7 + d8 * d8;
if (d9 < 1.0D) {
hasSpace[(l * 16 + i1) * 8 + j1] = true;
}
}
}
}
}
for (int k1 = 0; k1 < 16; ++k1) {
for (int l2 = 0; l2 < 16; ++l2) {
for (int k = 0; k < 8; ++k) {
boolean flag = !hasSpace[(k1 * 16 + l2) * 8 + k] && (k1 < 15 && hasSpace[((k1 + 1) * 16 + l2) * 8 + k] || k1 > 0 && hasSpace[((k1 - 1) * 16 + l2) * 8 + k] || l2 < 15 && hasSpace[(k1 * 16 + l2 + 1) * 8 + k] || l2 > 0 && hasSpace[(k1 * 16 + (l2 - 1)) * 8 + k] || k < 7 && hasSpace[(k1 * 16 + l2) * 8 + k + 1] || k > 0 && hasSpace[(k1 * 16 + l2) * 8 + (k - 1)]);
if (flag) {
Material material = world.getBlockState(pos.add(k1, k, l2)).getMaterial();
if (k >= 4 && material.isLiquid()) {
return false;
}
if (k < 4 && !material.isSolid() && world.getBlockState(pos.add(k1, k, l2)).getBlock() != block) {
return false;
}
}
}
}
}
for (int l1 = 0; l1 < 16; ++l1) {
for (int i3 = 0; i3 < 16; ++i3) {
for (int i4 = 0; i4 < 8; ++i4) {
if (hasSpace[(l1 * 16 + i3) * 8 + i4]) {
world.setBlockState(pos.add(l1, i4, i3), i4 >= 4 ? Blocks.AIR.getDefaultState() : block.getDefaultState(), 2);
}
}
}
}
for (int j2 = 0; j2 < 16; ++j2) {
for (int k3 = 0; k3 < 16; ++k3) {
for (int k4 = 0; k4 < 8; ++k4) {
boolean flag1 = !hasSpace[(j2 * 16 + k3) * 8 + k4] && (j2 < 15 && hasSpace[((j2 + 1) * 16 + k3) * 8 + k4] || j2 > 0 && hasSpace[((j2 - 1) * 16 + k3) * 8 + k4] || k3 < 15 && hasSpace[(j2 * 16 + k3 + 1) * 8 + k4] || k3 > 0 && hasSpace[(j2 * 16 + (k3 - 1)) * 8 + k4] || k4 < 7 && hasSpace[(j2 * 16 + k3) * 8 + k4 + 1] || k4 > 0 && hasSpace[(j2 * 16 + k3) * 8 + (k4 - 1)]);
if (flag1 && (k4 < 4 || rand.nextInt(2) != 0) && world.getBlockState(pos.add(j2, k4, k3)).getMaterial().isSolid()) {
world.setBlockState(pos.add(j2, k4, k3), surroundingBlock, 2);
}
}
}
}
return true;
}
}
Aggregations