-
Notifications
You must be signed in to change notification settings - Fork 497
/
FacadeBlockAccess.java
99 lines (82 loc) · 2.54 KB
/
FacadeBlockAccess.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
88
89
90
91
92
93
94
95
96
97
98
99
package buildcraft.transport.render;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.pluggable.IFacadePluggable;
import buildcraft.api.transport.pluggable.PipePluggable;
import buildcraft.core.CompatHooks;
public class FacadeBlockAccess implements IBlockAccess {
private final IBlockAccess world;
private final ForgeDirection side;
public FacadeBlockAccess(IBlockAccess world, ForgeDirection side) {
this.world = world;
this.side = side;
}
@Override
public Block getBlock(int x, int y, int z) {
Block compatBlock = CompatHooks.INSTANCE.getVisualBlock(world, x, y, z, side);
if (compatBlock != null) {
return compatBlock;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IPipeTile) {
PipePluggable p = ((IPipeTile) tile).getPipePluggable(side);
if (p instanceof IFacadePluggable) {
return ((IFacadePluggable) p).getCurrentBlock();
}
}
return Blocks.air;
}
@Override
public TileEntity getTileEntity(int x, int y, int z) {
return null;
}
@Override
public int getLightBrightnessForSkyBlocks(int x, int y, int z, int a) {
return 0;
}
@Override
public int getBlockMetadata(int x, int y, int z) {
int compatMeta = CompatHooks.INSTANCE.getVisualMeta(world, x, y, z, side);
if (compatMeta >= 0) {
return compatMeta;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IPipeTile) {
PipePluggable p = ((IPipeTile) tile).getPipePluggable(side);
if (p instanceof IFacadePluggable) {
//System.out.println("Found facade " + ((FacadePluggable) p).getRenderingMeta());
return ((IFacadePluggable) p).getCurrentMetadata();
}
}
return 0;
}
@Override
public int isBlockProvidingPowerTo(int x, int y, int z, int side) {
return 0;
}
@Override
public boolean isAirBlock(int x, int y, int z) {
return !(world.getTileEntity(x, y, z) instanceof IPipeTile);
}
@Override
public BiomeGenBase getBiomeGenForCoords(int x, int z) {
return world.getBiomeGenForCoords(x, z);
}
@Override
public int getHeight() {
return world.getHeight();
}
@Override
public boolean extendedLevelsInChunkCache() {
return world.extendedLevelsInChunkCache();
}
@Override
public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean def) {
return world.isSideSolid(x, y, z, side, def);
}
}