-
Notifications
You must be signed in to change notification settings - Fork 497
/
FakeBlock.java
87 lines (72 loc) · 2.2 KB
/
FakeBlock.java
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
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.lib.render;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.render.ITextureStates;
/*
* This is fake block to render pluggables and pipes without altering host state
* May prove useful if we will make API for roboports, pipes, plugs and facades
*/
@SideOnly(Side.CLIENT)
public final class FakeBlock extends Block implements ITextureStates {
public static final FakeBlock INSTANCE = new FakeBlock();
private int renderMask = 0;
private int colorMultiplier = 0xFFFFFF;
private TextureStateManager textureState;
private FakeBlock() {
super(Material.glass);
textureState = new TextureStateManager(null); //Always Clientside
}
@Override
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) {
return colorMultiplier;
}
public void setColor(int color) {
this.colorMultiplier = color;
}
@Override
public TextureStateManager getTextureState() {
return textureState;
}
@Override
public IIcon getIcon(int side, int meta) {
return textureState.isSided() ? textureState.getTextureArray()[side] : textureState.getTexture();
}
@Override
public void setRenderSide(ForgeDirection side, boolean render) {
if (render) {
renderMask |= 1 << side.ordinal();
} else {
renderMask &= ~(1 << side.ordinal());
}
}
@Override
public void setRenderAllSides() {
renderMask = 0x3f;
}
@Override
public void setRenderMask(int mask) {
renderMask = mask;
}
@Override
public Block getBlock() {
return this;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) {
return (renderMask & (1 << side)) != 0;
}
}