aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/blocks/BlockGlass1.java
blob: 6081b79d64ed8add0be0d78998fac8c485c0c100 (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
package gregtech.common.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.util.GTLanguageManager;

/**
 * The glass is split into separate files because they are registered as regular blocks, and a regular block can have
 * 16 subtypes at most.
 * <p>
 * This class hosts various special types of tiered glass with not many tiers.
 */
public class BlockGlass1 extends BlockCasingsAbstract {

    public BlockGlass1() {
        super(ItemGlass1.class, "gt.blockglass1", Material.glass, 4);
        this.opaque = false;

        GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemical Grade Glass");
        GTLanguageManager
            .addStringLocalization(getUnlocalizedName() + ".1.name", "Electron-Permeable Neutronium Coated Glass");
        GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Omni-Purpose Infinity Fused Glass");
        GTLanguageManager
            .addStringLocalization(getUnlocalizedName() + ".3.name", "Non-Photonic Matter Exclusion Glass");
        GTLanguageManager
            .addStringLocalization(getUnlocalizedName() + ".4.name", "Hawking Radiation Realignment Focus");

        ItemList.GlassPHResistant.set(new ItemStack(this, 1, 0));
        ItemList.GlassUVResistant.set(new ItemStack(this, 1, 1));
        ItemList.GlassOmniPurposeInfinityFused.set(new ItemStack(this, 1, 2));
        ItemList.GlassQuarkContainment.set(new ItemStack(this, 1, 3));
        ItemList.GlassQuarkContainment.set(new ItemStack(this, 1, 3));
        ItemList.Hawking_Glass.set(new ItemStack(this, 1, 4));
    }

    @Override
    public int getTextureIndex(int aMeta) {
        // Page 16, 0-16
        return (16 << 7) | (aMeta);
    }

    @Override
    public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) {
        return false;
    }

    @Override
    public boolean isOpaqueCube() {
        return false;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public int getRenderBlockPass() {
        return 1;
    }

    @Override
    public boolean renderAsNormalBlock() {
        return false;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int ordinalSide, int aMeta) {
        return switch (aMeta) {
            case 0 -> Textures.BlockIcons.GLASS_PH_RESISTANT.getIcon();
            case 1 -> Textures.BlockIcons.NEUTRONIUM_COATED_UV_RESISTANT_GLASS.getIcon();
            case 2 -> Textures.BlockIcons.OMNI_PURPOSE_INFINITY_FUSED_GLASS.getIcon();
            case 3 -> Textures.BlockIcons.GLASS_QUARK_CONTAINMENT.getIcon();
            case 4 -> Textures.BlockIcons.HAWKING_GLASS.getIcon();
            default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon();
        };
    }

    /**
     * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
     * coordinates. Args: blockAccess, x, y, z, side
     */
    @SideOnly(Side.CLIENT)
    @Override
    public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) {
        Block block = worldIn.getBlock(x, y, z);

        if (worldIn.getBlockMetadata(x, y, z) != worldIn.getBlockMetadata(
            x - Facing.offsetsXForSide[side],
            y - Facing.offsetsYForSide[side],
            z - Facing.offsetsZForSide[side])) {
            return true;
        }

        if (block == this) {
            return false;
        }

        return super.shouldSideBeRendered(worldIn, x, y, z, side);
    }
}