-
Notifications
You must be signed in to change notification settings - Fork 497
/
FakePluggablesStateBlock.java
61 lines (49 loc) · 1.5 KB
/
FakePluggablesStateBlock.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
package buildcraft.transport.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;
/*
* This is fake block to render pluggables without altering host state
* May prove useful if we will make API for roboports, plugs and facades
*/
@SideOnly(Side.CLIENT)
public class FakePluggablesStateBlock extends Block implements ITextureStates {
private int renderMask = 0;
private TextureStateManager textureState;
protected FakePluggablesStateBlock() {
super(Material.glass);
textureState = new TextureStateManager(null); //Always Clientside
}
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 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;
}
}