-
Notifications
You must be signed in to change notification settings - Fork 497
/
PipeTransportPower_BC8.java
66 lines (52 loc) · 2.04 KB
/
PipeTransportPower_BC8.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
package buildcraft.transport.pipes.bc8;
import net.minecraft.nbt.NBTBase;
import buildcraft.api.transport.pipe_bc8.BCPipeEventHandler;
import buildcraft.api.transport.pipe_bc8.IPipeListener;
import buildcraft.api.transport.pipe_bc8.IPipeListenerFactory;
import buildcraft.api.transport.pipe_bc8.IPipe_BC8;
import buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEventConnection_BC8;
import buildcraft.api.transport.pipe_bc8.event_bc8.IPipeEventConnection_BC8.AttemptCreate;
import buildcraft.transport.api.impl.EnumPipeType;
import io.netty.buffer.ByteBuf;
public class PipeTransportPower_BC8 implements IPipeListener {
public final IPipe_BC8 pipe;
public PipeTransportPower_BC8(IPipe_BC8 pipe) {
this.pipe = pipe;
}
// Pipe Event handling
@BCPipeEventHandler
public void attemptConnection(IPipeEventConnection_BC8.AttemptCreate event) {
Object other = event.getConnection().getOther();
if (event instanceof AttemptCreate.Pipe) {
AttemptCreate.Pipe pipe = (AttemptCreate.Pipe) event;
/* This isn't the best check but the alternative is going through all of the listener objects in the pipe
* and checking if it implements IPowerConnection. */
if (pipe.getPipe().getBehaviour().definition.type == EnumPipeType.POWER) {
event.couldAccept();
}
}
throw new RuntimeException("IMPLEMENT PipeTransportPower_BC8.attemptConnection");
}
// State read and writing
@Override
public PipeTransportPower_BC8 readFromNBT(NBTBase nbt) {
return this;
}
@Override
public NBTBase writeToNBT() {
return null;
}
@Override
public PipeTransportPower_BC8 readFromByteBuf(ByteBuf buf) {
return this;
}
@Override
public void writeToByteBuf(ByteBuf buf) {}
public enum Factory implements IPipeListenerFactory {
INSTANCE;
@Override
public IPipeListener createNewListener(IPipe_BC8 pipe) {
return new PipeTransportPower_BC8(pipe);
}
}
}