use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class ModuleCoordinatesPacket method getLogisticsModule.
@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(EntityPlayer player, Class<T> clazz) {
LogisticsModule module;
if (type == ModulePositionType.IN_PIPE) {
moduleBased = true;
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.NONE);
moduleBased = false;
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe didn't exsist", this);
}
module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
} else if (type == ModulePositionType.IN_HAND) {
if (MainProxy.isServer(player.getEntityWorld())) {
if (player.openContainer instanceof DummyModuleContainer) {
DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
module = dummy.getModule();
} else if (player.openContainer instanceof ContainerPlayer) {
module = ItemModule.getLogisticsModule(player, getPositionInt());
if (module == null) {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", module not found at slot " + getPositionInt(), this);
}
} else {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", no DummyModuleContainer open and the player is in another GUI", this);
}
} else {
module = MainProxy.proxy.getModuleFromGui();
if (module == null) {
module = ItemModule.getLogisticsModule(player, getPositionInt());
}
if (module == null) {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", GUI didn't provide the module and module not found at slot " + getPositionInt(), this);
}
}
} else {
moduleBased = true;
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.NONE);
moduleBased = false;
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe didn't exsist", this);
} else if (!pipe.isInitialized()) {
return null;
}
if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe", this);
}
module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
}
if (module != null) {
if (!(clazz.isAssignableFrom(module.getClass()))) {
throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", found " + module.getClass(), this);
}
} else {
throw new TargetNotFoundException("Couldn't find " + clazz.getName(), this);
}
return (T) module;
}
use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.
the class ChassisPipeModuleContent method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = this.getPipe(player.world, LTGPCompletionCheck.PIPE);
if (pipe.pipe instanceof PipeLogisticsChassis) {
PipeLogisticsChassis chassis = (PipeLogisticsChassis) pipe.pipe;
chassis.handleModuleItemIdentifierList(getIdentList());
}
}
Aggregations