Search in sources :

Example 6 with BlockLiquid

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);
    }
}
Also used : Entity(net.minecraft.entity.Entity) IThreadCallBack(icbm.classic.content.explosive.thread.ThreadLargeExplosion.IThreadCallBack) Material(net.minecraft.block.material.Material) World(net.minecraft.world.World) ThreadLargeExplosion(icbm.classic.content.explosive.thread.ThreadLargeExplosion) IPos3D(com.builtbroken.jlib.data.vector.IPos3D) BlockLiquid(net.minecraft.block.BlockLiquid) Pos(com.builtbroken.mc.imp.transform.vector.Pos) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 7 with BlockLiquid

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;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : BlockLiquid(net.minecraft.block.BlockLiquid) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 8 with BlockLiquid

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;
    }
}
Also used : BlockLeaves(net.minecraft.block.BlockLeaves) BlockLiquid(net.minecraft.block.BlockLiquid) BlockGrass(net.minecraft.block.BlockGrass) Block(net.minecraft.block.Block) IMixinBlock(org.spongepowered.common.interfaces.block.IMixinBlock) BlockLog(net.minecraft.block.BlockLog) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 9 with BlockLiquid

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BlockPos(net.minecraft.util.math.BlockPos)

Example 10 with BlockLiquid

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockLiquid (net.minecraft.block.BlockLiquid)57 IBlockState (net.minecraft.block.state.IBlockState)44 Block (net.minecraft.block.Block)27 BlockPos (net.minecraft.util.math.BlockPos)22 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)20 Material (net.minecraft.block.material.Material)11 ItemStack (net.minecraft.item.ItemStack)8 EnumFacing (net.minecraft.util.EnumFacing)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 BlockPos (net.minecraft.util.BlockPos)4 BlockFluidBase (net.minecraftforge.fluids.BlockFluidBase)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)4 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3 Entity (net.minecraft.entity.Entity)3 World (net.minecraft.world.World)3 IPlantable (net.minecraftforge.common.IPlantable)3 Location (com.builtbroken.mc.imp.transform.vector.Location)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2