use of net.minecraft.block.BlockLiquid in project ICBM-Classic by BuiltBrokenModding.
the class BlastSonic method doPreExplode.
@Override
public void doPreExplode() {
if (!this.world().isRemote) {
if (this.hasShockWave) {
for (int x = (int) (-this.getRadius() * 2); x < this.getRadius() * 2; ++x) {
for (int y = (int) (-this.getRadius() * 2); y < this.getRadius() * 2; ++y) {
for (int z = (int) (-this.getRadius() * 2); z < this.getRadius() * 2; ++z) {
Location targetPosition = position.add(new Pos(x, y, z));
Block blockID = world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
if (blockID != Blocks.air) {
Material material = blockID.getMaterial();
if (blockID != Blocks.bedrock && !(material.isLiquid()) && (blockID.getExplosionResistance(this.exploder, world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), position.xi(), position.yi(), position.zi()) > this.nengLiang || material == Material.glass)) {
targetPosition.setBlock(world(), Blocks.air);
}
}
}
}
}
}
this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.nengLiang, this.exploder, new IThreadCallBack() {
@Override
public float getResistance(World world, IPos3D explosionPosition, IPos3D targetPosition, Entity source, Block block) {
float resistance = 0;
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
resistance = 1f;
} else {
resistance = block.getExplosionResistance(source, world, (int) targetPosition.x(), (int) targetPosition.y(), (int) targetPosition.z(), explosionPosition.x(), explosionPosition.y(), explosionPosition.z());
}
return resistance;
}
});
this.thread.start();
}
if (this.hasShockWave) {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "hypersonic", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
} else {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "sonicwave", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
}
use of net.minecraft.block.BlockLiquid in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method doDestroyBlocks.
protected void doDestroyBlocks() {
// Try to find and grab some blocks to orbit
int blocksDestroyed = 0;
for (int currentRadius = 1; currentRadius < getRadius(); currentRadius++) {
for (int xr = -currentRadius; xr < currentRadius; xr++) {
for (int yr = -currentRadius; yr < currentRadius; yr++) {
for (int zr = -currentRadius; zr < currentRadius; zr++) {
final Location currentPos = position.add(xr, yr, zr);
final double dist = position.distance(currentPos);
//We are looping in a shell orbit around the center
if (dist < currentRadius && dist > currentRadius - 2) {
final Block block = currentPos.getBlock();
//Null if call was made on an unloaded chunk
if (block != null) {
int meta = currentPos.getBlockMetadata();
//Ignore air blocks and unbreakable blocks
if (!block.isAir(world(), currentPos.xi(), currentPos.yi(), currentPos.zi()) && block.getBlockHardness(this.world(), currentPos.xi(), currentPos.yi(), currentPos.zi()) >= 0) {
//TODO handle multi-blocks
final boolean isFluid = block instanceof BlockLiquid || block instanceof IFluidBlock;
currentPos.setBlock(Blocks.air, 0, isFluid ? 0 : 3);
//TODO: render fluid streams moving into hole
if (!isFluid && doFlyingBlocks) {
//Convert a random amount of destroyed blocks into flying blocks for visuals
if (this.world().rand.nextFloat() > 0.8) {
EntityFlyingBlock entity = new EntityFlyingBlock(this.world(), currentPos.add(0.5D), block, meta);
entity.yawChange = 50 * this.world().rand.nextFloat();
entity.pitchChange = 50 * this.world().rand.nextFloat();
this.world().spawnEntityInWorld(entity);
}
}
//Keep track of blocks removed to keep from lagging the game
blocksDestroyed++;
if (blocksDestroyed > this.MAX_BLOCKS_REMOVED_PER_TICK) {
return;
}
}
}
}
}
}
}
}
}
use of net.minecraft.block.BlockLiquid in project SpongeCommon by SpongePowered.
the class MixinBlock method onConstruction.
@Inject(method = "<init>*", at = @At("RETURN"))
public void onConstruction(CallbackInfo ci) {
// Determine which blocks can avoid executing un-needed event logic
// This will allow us to avoid running event logic for blocks that do nothing such as grass collisions
// -- blood
this.hasCollideLogic = true;
this.hasCollideWithStateLogic = true;
// onEntityCollidedWithBlock
try {
String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityWalk" : "func_176199_a";
Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, Entity.class };
Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
if (clazz.equals(Block.class)) {
this.hasCollideLogic = false;
}
} catch (Throwable ex) {
// ignore
}
// onEntityCollidedWithBlock (IBlockState)
try {
String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityCollidedWithBlock" : "func_180634_a";
Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, IBlockState.class, Entity.class };
Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
if (clazz.equals(Block.class)) {
this.hasCollideWithStateLogic = false;
}
} catch (Throwable ex) {
// ignore
}
Block block = (Block) (Object) this;
if (block instanceof BlockLeaves || block instanceof BlockLog || block instanceof BlockGrass || block instanceof BlockLiquid) {
this.requiresBlockCapture = false;
}
}
use of net.minecraft.block.BlockLiquid in project TechReborn by TechReborn.
the class TileIndustrialGrinder method getMutliBlock.
public boolean getMutliBlock() {
if (multiblockChecker == null) {
return false;
}
final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
final boolean blade = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0));
final IBlockState centerBlock = this.multiblockChecker.getBlock(0, 1, 0);
final boolean center = ((centerBlock.getBlock() instanceof BlockLiquid || centerBlock.getBlock() instanceof IFluidBlock) && centerBlock.getMaterial() == Material.WATER);
return down && center && blade && up;
}
use of net.minecraft.block.BlockLiquid in project TechReborn by TechReborn.
the class TileIndustrialSawmill method getMutliBlock.
public boolean getMutliBlock() {
if (multiblockChecker == null) {
return false;
}
final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
final boolean blade = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0));
final IBlockState centerBlock = this.multiblockChecker.getBlock(0, 1, 0);
final boolean center = ((centerBlock.getBlock() instanceof BlockLiquid || centerBlock.getBlock() instanceof IFluidBlock) && centerBlock.getMaterial() == Material.WATER);
return down && center && blade && up;
}
Aggregations