use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.
the class GuiChassisPipe method actionPerformed.
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.id >= 0 && guibutton.id <= _chassiPipe.getChassisSize()) {
LogisticsModule module = _chassiPipe.getSubModule(guibutton.id);
if (module != null) {
final ModernPacket packet = PacketHandler.getPacket(ChassisGUI.class).setButtonID(guibutton.id).setPosX(_chassiPipe.getX()).setPosY(_chassiPipe.getY()).setPosZ(_chassiPipe.getZ());
MainProxy.sendPacketToServer(packet);
}
}
for (int i = 0; i < upgradeConfig.length; i++) {
if (upgradeConfig[i] == guibutton) {
MainProxy.sendPacketToServer(PacketHandler.getPacket(OpenUpgradePacket.class).setSlot(upgradeslot[i]));
}
}
}
use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.
the class SneakyModuleInSlotGuiProvider method getClientGui.
@Override
public Object getClientGui(EntityPlayer player) {
LogisticsModule module = this.getLogisticsModule(player.getEntityWorld(), LogisticsModule.class);
if (!(module instanceof SneakyDirection && module instanceof Gui)) {
return null;
}
((SneakyDirection) module).setSneakyDirection(sneakyOrientation);
return new GuiSneakyConfigurator(player.inventory, module);
}
use of logisticspipes.modules.LogisticsModule 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.modules.LogisticsModule 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.modules.LogisticsModule in project LogisticsPipes by RS485.
the class ChassisTransportLayer method stillWantItem.
@Override
public boolean stillWantItem(IRoutedItem item) {
LogisticsModule module = _chassiPipe.getLogisticsModule();
if (module == null) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
if (!_chassiPipe.isEnabled()) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
final ItemIdentifierStack itemidStack = item.getItemIdentifierStack();
SinkReply reply = module.sinksItem(itemidStack.makeNormalStack(), itemidStack.getItem(), -1, 0, true, false, false);
if (reply == null || reply.maxNumberOfItems < 0) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
if (reply.maxNumberOfItems > 0 && itemidStack.getStackSize() > reply.maxNumberOfItems) {
EnumFacing o = _chassiPipe.getPointedOrientation();
if (o == null) {
o = EnumFacing.UP;
}
item.split(reply.maxNumberOfItems, o);
}
return true;
}
Aggregations