@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(EntityPlayer player, Class<T> clazz) {
LogisticsModule module = null;
if(this.type == ModulePositionType.IN_PIPE) {
moduleBased = true;
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld());
moduleBased = false;
if(pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
targetNotFound("Couldn't find " + clazz.getName() + ", pipe didn't exsist");
return null;
}
module = ((CoreRoutedPipe)pipe.pipe).getLogisticsModule();
} else if (this.type == ModulePositionType.IN_HAND) {
if(MainProxy.isServer(player.getEntityWorld())) {
if(player.openContainer instanceof DummyModuleContainer) {
DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
module = dummy.getModule();
} else {
targetNotFound("Couldn't find " + clazz.getName() + ", container wasn't a DummyModule Container");
return null;
}
} else {
module = MainProxy.proxy.getModuleFromGui();
if(module == null) {
targetNotFound("Couldn't find " + clazz.getName() + ", GUI didn't provide the module");
return null;
}
}
} else {
moduleBased = true;
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld());
moduleBased = false;
if(pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
targetNotFound("Couldn't find " + clazz.getName() + ", pipe didn't exsist");
return null;
}