aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/core/block/general/BlockLightGlass.java
blob: 097d5d8a5e7913101616fe1bbf8011765addb0a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package gtPlusPlus.core.block.general;

import static gregtech.api.enums.Mods.GTPlusPlus;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import codechicken.nei.api.API;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.core.creative.AddToCreativeTab;

/*
 * public class LightGlass extends BlockBreakable {
 */
public class BlockLightGlass extends BlockAir {

    private int state = 0;
    private int r = 255;
    private int g = 0;
    private int b = 0;
    private final int a = 255;

    public BlockLightGlass(final boolean bool) {
        super();
        this.setCreativeTab(AddToCreativeTab.tabBlock);
        this.setBlockName("blockMFEffect");
        this.setLightLevel(12F);
        setHardness(0.1F);
        setBlockTextureName(GTPlusPlus.ID + ":blockMFEffect");
        setStepSound(Block.soundTypeGlass);
        GameRegistry.registerBlock(this, "blockMFEffect");

        API.hideItem(new ItemStack(this));
    }

    /**
     * Returns the quantity of items to drop on block destruction.
     */
    @Override
    public int quantityDropped(final Random rand) {
        return 0;
    }

    /**
     * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
     */
    @Override
    @SideOnly(Side.CLIENT)
    public int getRenderBlockPass() {
        return 0;
    }

    /**
     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
     */
    @Override
    public boolean renderAsNormalBlock() {
        return false;
    }

    /**
     * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
     */
    @Override
    protected boolean canSilkHarvest() {
        return false;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(final IIconRegister iIcon) {
        this.blockIcon = iIcon.registerIcon(GTPlusPlus.ID + ":blockMFEffect");
    }

    @Override
    // http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java
    public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) {
        if (this.state == 0) {
            this.g++;
            if (this.g == 255) {
                this.state = 1;
            }
        }
        if (this.state == 1) {
            this.r--;
            if (this.r == 0) {
                this.state = 2;
            }
        }
        if (this.state == 2) {
            this.b++;
            if (this.b == 255) {
                this.state = 3;
            }
        }
        if (this.state == 3) {
            this.g--;
            if (this.g == 0) {
                this.state = 4;
            }
        }
        if (this.state == 4) {
            this.r++;
            if (this.r == 255) {
                this.state = 5;
            }
        }
        if (this.state == 5) {
            this.b--;
            if (this.b == 0) {
                this.state = 0;
            }
        }
        return (this.r << 16) + (this.g << 8) + (this.b) + (this.a << 24);
    }

    /**
     * A randomly called display update to be able to add particles or other items for display
     */
    @Override
    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(final World world, final int posX, final int posY, final int posZ,
        final Random random) {
        // Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud");

    }
}