use of net.minecraft.block.BlockLiquid in project Engine by VoltzEngine-Project.
the class FluidUtility method isFillableFluid.
/**
* Checks to see if a fluid related block is able to be filled
*/
public static boolean isFillableFluid(World world, Pos node) {
if (world == null || node == null) {
return false;
}
Block block = node.getBlock(world);
int meta = node.getBlockMetadata(world);
// TODO when added change this to call canFill and fill
if (drainBlock(world, node, false) != null) {
return false;
} else if (block instanceof IFluidBlock || block instanceof BlockLiquid) {
return meta != 0;
}
return false;
}
use of net.minecraft.block.BlockLiquid in project Railcraft by Railcraft.
the class BlockTrackOutfitted method clearBlock.
@Override
public boolean clearBlock(IBlockState state, World world, BlockPos pos, @Nullable EntityPlayer player) {
TrackType trackType = getTrackType(world, pos);
IBlockState newState = TrackToolsAPI.makeTrackState(trackType.getBaseBlock(), TrackTools.getTrackDirectionRaw(state));
Charge.distribution.network(world).removeNode(pos);
boolean b = WorldPlugin.setBlockState(world, pos, newState);
world.notifyNeighborsOfStateChange(pos, this, true);
// Below is ugly workaround for fluids!
if (Arrays.stream(EnumFacing.VALUES).map(face -> WorldPlugin.getBlock(world, pos.offset(face))).anyMatch(block -> block instanceof IFluidBlock || block instanceof BlockLiquid)) {
newState.getBlock().dropBlockAsItem(world, pos, newState, 0);
}
return b;
}
use of net.minecraft.block.BlockLiquid in project ICBM-Classic by BuiltBrokenModding.
the class BlastAntiGravitational method doExplode.
@Override
public // TODO rewrite entire method
boolean doExplode(// TODO rewrite entire method
int callCount) {
int r = this.callCount;
if (world() != null && !this.world().isRemote) {
try {
if (// TODO replace thread check with callback triggered by thread and delayed into main thread
this.thread != null) {
if (this.thread.isComplete) {
// Copy as concurrent list is not fast to sort
List<BlockPos> results = new ArrayList();
results.addAll(getThreadResults());
if (r == 0) {
Collections.sort(results, new PosDistanceSorter(location, true));
}
int blocksToTake = 20;
for (BlockPos targetPosition : results) {
final IBlockState blockState = world.getBlockState(targetPosition);
if (// don't pick up air
!blockState.getBlock().isAir(blockState, world, targetPosition) && // don't pick up replacable blocks like fire, grass, or snow (this does not include crops)
!blockState.getBlock().isReplaceable(world, targetPosition) && !(blockState.getBlock() instanceof IFluidBlock) && // don't pick up liquids
!(blockState.getBlock() instanceof BlockLiquid)) {
float hardness = blockState.getBlockHardness(world, targetPosition);
if (hardness >= 0 && hardness < 1000) {
if (world().rand.nextInt(3) > 0) {
// Remove block
world.setBlockToAir(targetPosition);
// Mark blocks taken
blocksToTake--;
if (blocksToTake <= 0) {
break;
}
// Create flying block
EntityFlyingBlock entity = new EntityFlyingBlock(world(), targetPosition, blockState, 0);
entity.yawChange = 50 * world().rand.nextFloat();
entity.pitchChange = 100 * world().rand.nextFloat();
entity.motionY += Math.max(0.15 * world().rand.nextFloat(), 0.1);
entity.noClip = true;
world().spawnEntity(entity);
// Track flying block
flyingBlocks.add(entity);
}
}
}
}
}
} else {
String msg = String.format("BlastAntiGravitational#doPostExplode() -> Failed to run due to null thread" + "\nWorld = %s " + "\nThread = %s" + "\nSize = %s" + "\nPos = ", world, thread, size, location);
ICBMClassic.logger().error(msg);
}
} catch (Exception e) {
String msg = String.format("BlastAntiGravitational#doPostExplode() -> Unexpected error while running post detonation code " + "\nWorld = %s " + "\nThread = %s" + "\nSize = %s" + "\nPos = ", world, thread, size, location);
ICBMClassic.logger().error(msg, e);
}
}
int radius = (int) this.getBlastRadius();
AxisAlignedBB bounds = new AxisAlignedBB(location.x() - radius, location.y() - radius, location.z() - radius, location.y() + radius, 100, location.z() + radius);
List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : allEntities) {
if (!(entity instanceof EntityFlyingBlock) && entity.posY < 100 + location.y()) {
if (entity.motionY < 0.4) {
entity.motionY += 0.15;
}
}
}
return this.callCount > 20 * 120;
}
use of net.minecraft.block.BlockLiquid in project MorePlanets by SteveKunG.
the class ChunkGeneratorBaseMP method checkBlock.
private static boolean checkBlock(World world, BlockPos pos, IBlockState pocket) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (state.getMaterial() == Material.AIR) {
return true;
}
return block instanceof BlockLiquid && block != pocket.getBlock();
}
use of net.minecraft.block.BlockLiquid in project MorePlanets by SteveKunG.
the class ParticleLiquidDrip method onUpdate.
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= this.particleGravity;
if (this.bobTimer-- > 0) {
this.motionX *= 0.02D;
this.motionY *= 0.02D;
this.motionZ *= 0.02D;
this.setParticleTextureIndex(113);
} else {
this.setParticleTextureIndex(112);
}
this.move(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (this.particleMaxAge-- <= 0) {
this.setExpired();
}
if (this.onGround) {
if (!this.isLavaDrip) {
this.setExpired();
} else {
this.setParticleTextureIndex(114);
}
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
BlockPos pos = new BlockPos(this.posX, this.posY, this.posZ);
IBlockState state = this.world.getBlockState(pos);
Material material = state.getMaterial();
if (material.isLiquid() || material.isSolid()) {
double percent = 0.0D;
if (state.getBlock() instanceof BlockLiquid) {
percent = BlockLiquid.getLiquidHeightPercent(state.getValue(BlockLiquid.LEVEL));
}
double posUnder = MathHelper.floor(this.posY) + 1 - percent;
if (this.posY < posUnder) {
this.setExpired();
}
}
}
Aggregations