Java Code Examples for net.minecraft.client.particle.EffectRenderer#addEffect()

The following examples show how to use net.minecraft.client.particle.EffectRenderer#addEffect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityDigIconFX.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void addBlockHitEffects(World world, Cuboid6 bounds, int side, TextureAtlasSprite icon, EffectRenderer effectRenderer)
{
    float border = 0.1F;
    Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2*border);
    diff.x*=world.rand.nextDouble();
    diff.y*=world.rand.nextDouble();
    diff.z*=world.rand.nextDouble();
    Vector3 pos = diff.add(bounds.min).add(border);
    
    if (side == 0)
        diff.y = bounds.min.y - border;
    if (side == 1)
        diff.y = bounds.max.y + border;
    if (side == 2)
        diff.z = bounds.min.z - border;
    if (side == 3)
        diff.z = bounds.max.z + border;
    if (side == 4)
        diff.x = bounds.min.x - border;
    if (side == 5)
        diff.x = bounds.max.x + border;
    
    effectRenderer.addEffect(
            new EntityDigIconFX(world, pos.x, pos.y, pos.z, 0, 0, 0, icon)
                .multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
}
 
Example 2
Source File: BlockThinLog.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(world, x, y, z);
    BlockThinLog block = getBlock(world, x, y, z);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = world.getBlockMetadata(x, y, z);
    }

    try {
        byte count = 4;
        for (int ix = 0; ix < count; ++ix) {
            for (int iy = 0; iy < count; ++iy) {
                for (int iz = 0; iz < count; ++iz) {
                    double xOff = (double)x + ((double)ix + 0.5D) / (double)count;
                    double yOff = (double)y + ((double)iy + 0.5D) / (double)count;
                    double zOff = (double)z + ((double)iz + 0.5D) / (double)count;

                    EntityDiggingFX fx = new EntityDiggingFX(world, xOff, yOff, zOff, xOff - (double) x - 0.5D, yOff - (double) y - 0.5D, zOff - (double) z - 0.5D, this, meta);
                    fx.setParticleIcon(block.getIcon(world.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

                    effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                }
            }
        }
    }
    catch (Exception e) { }

    return true;
}
 
Example 3
Source File: BlockThinLogFence.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(world, x, y, z);
    BlockThinLogFence block = getBlock(world, x, y, z);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = world.getBlockMetadata(x, y, z);
    }

    try {
        byte count = 4;
        for (int ix = 0; ix < count; ++ix) {
            for (int iy = 0; iy < count; ++iy) {
                for (int iz = 0; iz < count; ++iz) {
                    double xOff = (double)x + ((double)ix + 0.5D) / (double)count;
                    double yOff = (double)y + ((double)iy + 0.5D) / (double)count;
                    double zOff = (double)z + ((double)iz + 0.5D) / (double)count;

                    EntityDiggingFX fx = new EntityDiggingFX(world, xOff, yOff, zOff, xOff - (double) x - 0.5D, yOff - (double) y - 0.5D, zOff - (double) z - 0.5D, this, meta);
                    fx.setParticleIcon(block.getIcon(world.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

                    effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                }
            }
        }
    }
    catch (Exception e) { }

    return true;
}
 
Example 4
Source File: GeneralChiselClient.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) {
	Block block = world.getBlock(x, y, z);
	if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
		return null;

	EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;

	float f = 0.1F;
	double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
	double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
	double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();

	switch (side) {
	case 0:
		d1 = y + block.getBlockBoundsMinY() - f;
		break;
	case 1:
		d1 = y + block.getBlockBoundsMaxY() + f;
		break;
	case 2:
		d2 = z + block.getBlockBoundsMinZ() - f;
		break;
	case 3:
		d2 = z + block.getBlockBoundsMaxZ() + f;
		break;
	case 4:
		d0 = x + block.getBlockBoundsMinX() - f;
		break;
	case 5:
		d0 = x + block.getBlockBoundsMaxX() + f;
		break;
	}

	EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side);
	res.motionX = d0 - (x + 0.5);
	res.motionY = d1 - (y + 0.5);
	res.motionZ = d2 - (z + 0.5);

	renderer.addEffect(res);

	return res;
}
 
Example 5
Source File: BlockThinLog.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects (World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(worldObj, target.blockX, target.blockY, target.blockZ);
    BlockThinLog block = getBlock(worldObj, target.blockX, target.blockY, target.blockZ);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
    }

    float f = 0.1F;
    double xPos = target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (f * 2.0F)) + f + block.getBlockBoundsMinX();
    double yPos = target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (f * 2.0F)) + f + block.getBlockBoundsMinY();
    double zPos = target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (f * 2.0F)) + f + block.getBlockBoundsMinZ();

    if (target.sideHit == 0)
        yPos = target.blockY + block.getBlockBoundsMinY() - f;
    if (target.sideHit == 1)
        yPos = target.blockY + block.getBlockBoundsMaxY() + f;
    if (target.sideHit == 2)
        zPos = target.blockZ + block.getBlockBoundsMinZ() - f;
    if (target.sideHit == 3)
        zPos = target.blockZ + block.getBlockBoundsMaxZ() + f;
    if (target.sideHit == 4)
        xPos = target.blockX + block.getBlockBoundsMinX() - f;
    if (target.sideHit == 5)
        xPos = target.blockX + block.getBlockBoundsMaxX() + f;

    EntityDiggingFX fx = new EntityDiggingFX(worldObj, xPos, yPos, zPos, 0.0D, 0.0D, 0.0D, block, worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ));
    fx.applyColourMultiplier(target.blockX, target.blockY, target.blockZ);
    fx.multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
    fx.setParticleIcon(block.getIcon(worldObj.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

    effectRenderer.addEffect(fx);

    return true;
}
 
Example 6
Source File: BlockThinLogFence.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects (World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
    TileEntityWoodProxy te = getTileEntity(worldObj, target.blockX, target.blockY, target.blockZ);
    BlockThinLogFence block = getBlock(worldObj, target.blockX, target.blockY, target.blockZ);

    if (te == null || block == null)
        return false;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null) {
        protoBlock = Blocks.log;
        protoMeta = worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
    }

    float f = 0.1F;
    double xPos = target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (f * 2.0F)) + f + block.getBlockBoundsMinX();
    double yPos = target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (f * 2.0F)) + f + block.getBlockBoundsMinY();
    double zPos = target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (f * 2.0F)) + f + block.getBlockBoundsMinZ();

    if (target.sideHit == 0)
        yPos = target.blockY + block.getBlockBoundsMinY() - f;
    if (target.sideHit == 1)
        yPos = target.blockY + block.getBlockBoundsMaxY() + f;
    if (target.sideHit == 2)
        zPos = target.blockZ + block.getBlockBoundsMinZ() - f;
    if (target.sideHit == 3)
        zPos = target.blockZ + block.getBlockBoundsMaxZ() + f;
    if (target.sideHit == 4)
        xPos = target.blockX + block.getBlockBoundsMinX() - f;
    if (target.sideHit == 5)
        xPos = target.blockX + block.getBlockBoundsMaxX() + f;

    EntityDiggingFX fx = new EntityDiggingFX(worldObj, xPos, yPos, zPos, 0.0D, 0.0D, 0.0D, block, worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ));
    fx.applyColourMultiplier(target.blockX, target.blockY, target.blockZ);
    fx.multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
    fx.setParticleIcon(block.getIcon(worldObj.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta)));

    effectRenderer.addEffect(fx);

    return true;
}
 
Example 7
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    TileEntityGarden te = getGardenEntity(world, x, y, z);
    BlockGarden garden = getGardenBlock(world, x, y, z);
    if (te == null || garden == null)
        return true;

    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block block = getPlantBlock(te, slot);
        int blockData = getPlantData(te, slot);
        if (block == null)
            continue;

        bindSlot(world, x, y, z, te, slot);
        try {
            byte count = 4;
            for (int ix = 0; ix < count; ++ix) {
                for (int iy = 0; iy < count; ++iy) {
                    for (int iz = 0; iz < count; ++iz) {
                        double xOff = (double)x + ((double)ix + 0.5D) / (double)count;
                        double yOff = (double)y + ((double)iy + 0.5D) / (double)count;
                        double zOff = (double)z + ((double)iz + 0.5D) / (double)count;

                        EntityDiggingFX fx = new EntityDiggingFX(world, xOff, yOff, zOff, xOff - (double) x - 0.5D, yOff - (double) y - 0.5D, zOff - (double) z - 0.5D, this, meta);
                        fx.setParticleIcon(block.getIcon(world.rand.nextInt(6), blockData));

                        effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                    }
                }
            }
        }
        catch (Exception e) {
            continue;
        }
        finally {
            unbindSlot(world, x, y, z, te);
        }
    }

    return true;
}
 
Example 8
Source File: GeneralChiselClient.java    From Chisel with GNU General Public License v2.0 4 votes vote down vote up
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side)
    {
        Block block = world.getBlock(x, y, z);
        if(block.isAir(world, x, y, z))
            return null;

        EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;

        float f = 0.1F;
        double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
        double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY();
        double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ();

        switch(side)
        {
            case 0:
                d1 = y + block.getBlockBoundsMinY() - f;
                break;
            case 1:
                d1 = y + block.getBlockBoundsMaxY() + f;
                break;
            case 2:
                d2 = z + block.getBlockBoundsMinZ() - f;
                break;
            case 3:
                d2 = z + block.getBlockBoundsMaxZ() + f;
                break;
            case 4:
                d0 = x + block.getBlockBoundsMinX() - f;
                break;
            case 5:
                d0 = x + block.getBlockBoundsMaxX() + f;
                break;
        }

        EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side);
//		res.func_70596_a(x, y, z);
        res.motionX = d0 - (x + 0.5);
        res.motionY = d1 - (y + 0.5);
        res.motionZ = d2 - (z + 0.5);

        renderer.addEffect(res);

        return res;
    }