-
Notifications
You must be signed in to change notification settings - Fork 497
/
PipeFluidsIron.java
95 lines (83 loc) · 2.63 KB
/
PipeFluidsIron.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
/**
* BuildCraft is open-source. It is distributed under the terms of the
* BuildCraft Open Source License. It grants rights to read, modify, compile or
* run the code. It does *NOT* grant the right to redistribute this software or
* its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
*/
package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportFluids;
import buildcraft.transport.TileGenericPipe;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
public class PipeFluidsIron extends Pipe {
protected int standardIconIndex = PipeIconProvider.TYPE.PipeFluidsIron_Standard.ordinal();
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllIron_Solid.ordinal();
private PipeLogicIron logic = new PipeLogicIron(this) {
@Override
protected boolean isValidFacing(ForgeDirection facing) {
TileEntity tile = pipe.container.getTile(facing);
if (tile instanceof TileGenericPipe) {
Pipe otherPipe = ((TileGenericPipe) tile).pipe;
if (otherPipe instanceof PipeFluidsWood || otherPipe instanceof PipeStructureCobblestone)
return false;
if (otherPipe.transport instanceof PipeTransportFluids)
return true;
return false;
}
if (tile instanceof IFluidHandler)
return true;
return false;
}
};
public PipeFluidsIron(int itemID) {
super(new PipeTransportFluids(), itemID);
}
@Override
public void onNeighborBlockChange(int blockId) {
logic.onNeighborBlockChange(blockId);
super.onNeighborBlockChange(blockId);
}
@Override
public void onBlockPlaced() {
logic.onBlockPlaced();
super.onBlockPlaced();
}
@Override
public void initialize() {
logic.initialize();
super.initialize();
}
@Override
public boolean outputOpen(ForgeDirection to) {
return super.outputOpen(to) && logic.outputOpen(to);
}
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return BuildCraftTransport.instance.pipeIconProvider;
}
@Override
public int getIconIndex(ForgeDirection direction) {
if (direction == ForgeDirection.UNKNOWN)
return standardIconIndex;
else {
int metadata = container.getBlockMetadata();
if (metadata == direction.ordinal())
return solidIconIndex;
else
return standardIconIndex;
}
}
@Override
public boolean canConnectRedstone() {
return true;
}
}