use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class InvSysConGuiProvider method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
LogisticsTileGenericPipe pipe = getTileAs(player.world, LogisticsTileGenericPipe.class);
if (!(pipe.pipe instanceof PipeItemsInvSysConnector)) {
return null;
}
DummyContainer dummy = new DummyContainer(player, null, (PipeItemsInvSysConnector) pipe.pipe);
dummy.addNormalSlotsForPlayerInventory(0, 50);
return dummy;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class ModuleCoordinatesGuiProvider method getLogisticsModule.
@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(World world, Class<T> clazz) {
LogisticsTileGenericPipe pipe = getTileAs(world, LogisticsTileGenericPipe.class);
if (!(pipe.pipe instanceof CoreRoutedPipe)) {
if (LogisticsPipes.isDEBUG() && pipe.isInitialized()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", pipe didn't exsist").printStackTrace();
}
return null;
}
LogisticsModule module;
if (slot == ModulePositionType.IN_PIPE) {
module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
} else if (slot == ModulePositionType.IN_HAND) {
throw new UnsupportedOperationException("NO IN_HAND FOR THIS PACKET TYPE");
} else {
if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
if (LogisticsPipes.isDEBUG()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe").printStackTrace();
}
return null;
}
module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
}
if (module != null) {
if (!(clazz.isAssignableFrom(module.getClass()))) {
if (LogisticsPipes.isDEBUG()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", found " + module.getClass()).printStackTrace();
}
return null;
}
} else {
if (LogisticsPipes.isDEBUG()) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName()).printStackTrace();
}
}
return (T) module;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class SneakyUpgradeConfigGuiProvider method getClientGui.
@Override
public Object getClientGui(EntityPlayer player) {
LogisticsTileGenericPipe bPipe = getTileAs(player.world, LogisticsTileGenericPipe.class);
if (!(bPipe.pipe instanceof CoreRoutedPipe)) {
return null;
}
List<DoubleCoordinates> list = new WorldCoordinatesWrapper(bPipe).connectedTileEntities().stream().filter(in -> SimpleServiceLocator.pipeInformationManager.isNotAPipe(in.getTileEntity())).map(in -> new DoubleCoordinates(in.getTileEntity())).collect(Collectors.toList());
if (list.isEmpty()) {
list = new WorldCoordinatesWrapper(bPipe).connectedTileEntities().stream().map(in -> new DoubleCoordinates(in.getTileEntity())).collect(Collectors.toList());
}
return new SneakyConfigurationPopup(list, getSlot(player, UpgradeSlot.class));
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class DiskMacroRequestPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
if (pipe == null) {
return;
}
if (pipe.pipe instanceof PipeItemsRequestLogisticsMk2) {
if (((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk() == null) {
return;
}
if (!((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().getItem().equals(LPItems.disk)) {
return;
}
if (!((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().hasTagCompound()) {
return;
}
NBTTagCompound nbt = ((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().getTagCompound();
if (!nbt.hasKey("macroList")) {
NBTTagList list = new NBTTagList();
nbt.setTag("macroList", list);
}
NBTTagList list = nbt.getTagList("macroList", 10);
for (int i = 0; i < list.tagCount(); i++) {
if (i == getInteger()) {
NBTTagCompound itemlist = list.getCompoundTagAt(i);
RequestHandler.requestMacrolist(itemlist, (PipeItemsRequestLogisticsMk2) pipe.pipe, player);
break;
}
}
}
if (pipe.pipe instanceof PipeBlockRequestTable) {
if (((PipeBlockRequestTable) pipe.pipe).getDisk() == null) {
return;
}
if (!((PipeBlockRequestTable) pipe.pipe).getDisk().getItem().equals(LPItems.disk)) {
return;
}
if (!((PipeBlockRequestTable) pipe.pipe).getDisk().hasTagCompound()) {
return;
}
NBTTagCompound nbt = ((PipeBlockRequestTable) pipe.pipe).getDisk().getTagCompound();
if (!nbt.hasKey("macroList")) {
NBTTagList list = new NBTTagList();
nbt.setTag("macroList", list);
}
NBTTagList list = nbt.getTagList("macroList", 10);
for (int i = 0; i < list.tagCount(); i++) {
if (i == getInteger()) {
NBTTagCompound itemlist = list.getCompoundTagAt(i);
RequestHandler.requestMacrolist(itemlist, (PipeBlockRequestTable) pipe.pipe, player);
break;
}
}
}
}
Aggregations