use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class LogisticsSolderingTileEntity method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (MainProxy.isClient(getWorldObj())) {
return;
}
hasWork = hasWork();
if (hasWork && heat < 100) {
boolean usedEnergy = false;
if (Configs.LOGISTICS_POWER_USAGE_DISABLED) {
if (heat < 100) {
heat += 5;
}
if (heat > 100) {
heat = 100;
}
usedEnergy = true;
} else {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = pos.getTileEntity(getWorldObj());
if (!(tile instanceof LogisticsTileGenericPipe)) {
continue;
}
LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
if (!(tPipe.pipe instanceof CoreRoutedPipe)) {
continue;
}
CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
if (pipe.useEnergy(50)) {
heat += 5;
if (heat > 100) {
heat = 100;
}
updateHeat();
usedEnergy = true;
break;
}
}
}
if (!usedEnergy && getWorldObj().getTotalWorldTime() % 5 == 0) {
heat--;
if (heat < 0) {
heat = 0;
}
updateHeat();
}
} else if (!hasWork && heat > 0) {
heat--;
updateHeat();
}
if (hasWork && heat >= 100) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = pos.getTileEntity(getWorldObj());
if (!(tile instanceof LogisticsTileGenericPipe)) {
continue;
}
LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
if (!(tPipe.pipe instanceof CoreRoutedPipe)) {
continue;
}
CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
if (pipe.useEnergy(30)) {
progress += 3;
} else if (pipe.useEnergy(20)) {
progress += 2;
} else if (pipe.useEnergy(10)) {
progress += 1;
}
if (progress >= 100) {
if (tryCraft()) {
progress = 0;
} else {
progress -= 50;
}
}
updateProgress();
}
} else if (!hasWork && progress != 0) {
progress = 0;
updateProgress();
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class LogisticsEventListener method onPlayerInteract.
@SubscribeEvent
public void onPlayerInteract(final PlayerInteractEvent event) {
if (MainProxy.isServer(event.entityPlayer.worldObj)) {
if (event.action == Action.LEFT_CLICK_BLOCK) {
final TileEntity tile = event.entityPlayer.worldObj.getTileEntity(event.x, event.y, event.z);
if (tile instanceof LogisticsTileGenericPipe) {
if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.entityPlayer)) {
event.setCanceled(true);
event.entityPlayer.addChatComponentMessage(new ChatComponentTranslation("lp.chat.permissiondenied"));
((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
event.entityPlayer.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
} else {
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
}
}
}
}
if (event.action == Action.RIGHT_CLICK_BLOCK) {
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.entityPlayer.worldObj, event.x, event.y, event.z);
TileEntity tileEntity = worldCoordinates.getTileEntity();
if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
//@formatter:off
List<WeakReference<ModuleQuickSort>> list = worldCoordinates.getAdjacentTileEntities().filter(adjacent -> adjacent.tileEntity instanceof LogisticsTileGenericPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe instanceof PipeLogisticsChassi).filter(adjacent -> ((PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).getPointedOrientation() == adjacent.direction.getOpposite()).map(adjacent -> (PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).flatMap(pipeLogisticsChassi -> Arrays.stream(pipeLogisticsChassi.getModules().getModules())).filter(logisticsModule -> logisticsModule instanceof ModuleQuickSort).map(logisticsModule -> new WeakReference<>((ModuleQuickSort) logisticsModule)).collect(Collectors.toList());
if (!list.isEmpty()) {
LogisticsEventListener.chestQuickSortConnection.put(event.entityPlayer, list);
}
}
}
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class ItemModule method onItemUse.
@Override
public boolean onItemUse(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if (MainProxy.isServer(par2EntityPlayer.worldObj)) {
TileEntity tile = par3World.getTileEntity(par4, par5, par6);
if (tile instanceof LogisticsTileGenericPipe) {
if (par2EntityPlayer.getDisplayName().equals("ComputerCraft")) {
//Allow turtle to place modules in pipes.
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(par3World, par4, par5, par6);
if (LogisticsBlockGenericPipe.isValid(pipe)) {
pipe.blockActivated(par2EntityPlayer);
}
}
return true;
}
openConfigGui(par1ItemStack, par2EntityPlayer, par3World);
}
return true;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class ItemPipeSignCreator method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideinput, float hitX, float hitY, float hitZ) {
if (MainProxy.isClient(world)) {
return false;
}
if (itemStack.getItemDamage() > this.getMaxDamage() || itemStack.stackSize == 0) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof LogisticsTileGenericPipe)) {
return false;
}
if (!itemStack.hasTagCompound()) {
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.getTagCompound().setInteger("PipeClicked", 0);
int mode = itemStack.getTagCompound().getInteger("CreatorMode");
ForgeDirection dir = ForgeDirection.getOrientation(sideinput);
if (dir == ForgeDirection.UNKNOWN) {
return false;
}
if (!(((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe)) {
return false;
}
CoreRoutedPipe pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe;
if (pipe == null) {
return false;
}
if (!player.isSneaking()) {
if (pipe.hasPipeSign(dir)) {
pipe.activatePipeSign(dir, player);
return true;
} else if (mode >= 0 && mode < ItemPipeSignCreator.signTypes.size()) {
Class<? extends IPipeSign> signClass = ItemPipeSignCreator.signTypes.get(mode);
try {
IPipeSign sign = signClass.newInstance();
if (sign.isAllowedFor(pipe)) {
itemStack.damageItem(1, player);
sign.addSignTo(pipe, dir, player);
return true;
} else {
return false;
}
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
} else {
return false;
}
} else {
if (pipe.hasPipeSign(dir)) {
pipe.removePipeSign(dir, player);
itemStack.damageItem(-1, player);
}
return true;
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class ChassiGuiProvider method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
LogisticsTileGenericPipe pipe = getPipe(player.getEntityWorld());
if (pipe == null || !(pipe.pipe instanceof PipeLogisticsChassi)) {
return null;
}
final PipeLogisticsChassi _chassiPipe = (PipeLogisticsChassi) pipe.pipe;
IInventory _moduleInventory = _chassiPipe.getModuleInventory();
DummyContainer dummy = new DummyContainer(player.inventory, _moduleInventory);
if (_chassiPipe.getChassiSize() < 5) {
dummy.addNormalSlotsForPlayerInventory(18, 97);
} else {
dummy.addNormalSlotsForPlayerInventory(18, 174);
}
if (_chassiPipe.getChassiSize() > 0) {
dummy.addModuleSlot(0, _moduleInventory, 19, 9, _chassiPipe);
}
if (_chassiPipe.getChassiSize() > 1) {
dummy.addModuleSlot(1, _moduleInventory, 19, 29, _chassiPipe);
}
if (_chassiPipe.getChassiSize() > 2) {
dummy.addModuleSlot(2, _moduleInventory, 19, 49, _chassiPipe);
}
if (_chassiPipe.getChassiSize() > 3) {
dummy.addModuleSlot(3, _moduleInventory, 19, 69, _chassiPipe);
}
if (_chassiPipe.getChassiSize() > 4) {
dummy.addModuleSlot(4, _moduleInventory, 19, 89, _chassiPipe);
dummy.addModuleSlot(5, _moduleInventory, 19, 109, _chassiPipe);
dummy.addModuleSlot(6, _moduleInventory, 19, 129, _chassiPipe);
dummy.addModuleSlot(7, _moduleInventory, 19, 149, _chassiPipe);
}
if (_chassiPipe.getUpgradeManager().hasUpgradeModuleUpgrade()) {
for (int i = 0; i < _chassiPipe.getChassiSize(); i++) {
final int fI = i;
ModuleUpgradeManager upgradeManager = _chassiPipe.getModuleUpgradeManager(i);
dummy.addUpgradeSlot(0, upgradeManager, 0, 145, 9 + i * 20, itemStack -> ChassiGuiProvider.checkStack(itemStack, _chassiPipe, fI));
dummy.addUpgradeSlot(1, upgradeManager, 1, 165, 9 + i * 20, itemStack -> ChassiGuiProvider.checkStack(itemStack, _chassiPipe, fI));
}
}
return dummy;
}
Aggregations