From b70735f5d6ce6dc2d1f7c8e879a2eb85266c62df Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 10 May 2018 13:32:59 +0200 Subject: [PATCH] Fixed regression in video channels reported status --- src/main/java/cr0s/warpdrive/Commons.java | 7 +++++++ .../block/BlockAbstractContainer.java | 21 ++++++++++++------- .../block/TileEntityAbstractBase.java | 15 +++++++++---- .../assets/warpdrive/lang/de_DE.lang | 4 ++-- .../assets/warpdrive/lang/en_US.lang | 4 ++-- .../assets/warpdrive/lang/fr_FR.lang | 4 ++-- .../assets/warpdrive/lang/nl_NL.lang | 4 ++-- .../assets/warpdrive/lang/ru_RU.lang | 4 ++-- .../assets/warpdrive/lang/zh_CN.lang | 4 ++-- .../assets/warpdrive/lang/zh_TW.lang | 2 +- 10 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index dfa3b33c..f689a32c 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -101,10 +101,17 @@ public class Commons { } public static void addChatMessage(final ICommandSender commandSender, final String message) { + // validate context if (commandSender == null) { WarpDrive.logger.error("Unable to send message to NULL commandSender: " + message); return; } + + // skip empty messages + if (message.isEmpty()) { + return; + } + final String[] lines = updateEscapeCodes(message).split("\n"); String format = ""; getFormatFromString(lines[0]); diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index 4269a828..9c8be18c 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -4,6 +4,7 @@ import cr0s.warpdrive.Commons; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IBlockBase; import cr0s.warpdrive.api.IBlockUpdateDetector; +import cr0s.warpdrive.api.IVideoChannel; import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.data.EnumComponentType; import cr0s.warpdrive.item.ItemComponent; @@ -208,18 +209,21 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int side, final float hitX, final float hitY, final float hitZ) { - if (world.isRemote) { - return false; - } - // get context final TileEntity tileEntity = world.getTileEntity(x, y, z); if (!(tileEntity instanceof TileEntityAbstractBase)) { return false; } final TileEntityAbstractBase tileEntityAbstractBase = (TileEntityAbstractBase) tileEntity; + final boolean hasVideoChannel = tileEntity instanceof IVideoChannel; final ItemStack itemStackHeld = entityPlayer.getHeldItem(); + // video channel is reported client side, everything else is reported server side + if ( world.isRemote + && !hasVideoChannel ) { + return false; + } + EnumComponentType enumComponentType = null; if ( itemStackHeld != null && itemStackHeld.getItem() instanceof ItemComponent ) { @@ -227,7 +231,8 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I } // sneaking with an empty hand or an upgrade item in hand to dismount current upgrade - if (entityPlayer.isSneaking()) { + if ( !world.isRemote + && entityPlayer.isSneaking() ) { // using an upgrade item or an empty hand means dismount upgrade if ( tileEntityAbstractBase.isUpgradeable() && ( itemStackHeld == null @@ -258,11 +263,13 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I return false; } - } else if (itemStackHeld == null) {// no sneaking and no item in hand => show status + } else if ( !entityPlayer.isSneaking() + && itemStackHeld == null ) {// no sneaking and no item in hand => show status Commons.addChatMessage(entityPlayer, tileEntityAbstractBase.getStatus()); return true; - } else if ( tileEntityAbstractBase.isUpgradeable() + } else if ( !world.isRemote + && tileEntityAbstractBase.isUpgradeable() && enumComponentType != null ) {// no sneaking and an upgrade in hand => mounting an upgrade // validate type if (tileEntityAbstractBase.getUpgradeMaxCount(enumComponentType) <= 0) { diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java index 6df00b03..36d7fbe8 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java @@ -6,6 +6,8 @@ import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IBeamFrequency; import cr0s.warpdrive.api.IBlockUpdateDetector; import cr0s.warpdrive.api.IVideoChannel; +import cr0s.warpdrive.block.detection.TileEntityCamera; +import cr0s.warpdrive.block.weapon.TileEntityLaserCamera; import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.data.CameraRegistryItem; @@ -264,12 +266,17 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc } else { final CameraRegistryItem camera = WarpDrive.cameras.getCameraByVideoChannel(worldObj, videoChannel); if (camera == null) { - WarpDrive.cameras.printRegistry(worldObj); - return StatCollector.translateToLocalFormatted("warpdrive.video_channel.status_line.invalid", videoChannel); + if (WarpDrive.isDev) { + if ( this instanceof TileEntityCamera + || this instanceof TileEntityLaserCamera) { + WarpDrive.cameras.printRegistry(worldObj); + } + } + return StatCollector.translateToLocalFormatted("warpdrive.video_channel.status_line.not_loaded", videoChannel); } else if (camera.isTileEntity(this)) { - return StatCollector.translateToLocalFormatted("warpdrive.video_channel.status_line.valid", videoChannel); + return StatCollector.translateToLocalFormatted("warpdrive.video_channel.status_line.valid_camera", videoChannel); } else { - return StatCollector.translateToLocalFormatted("warpdrive.video_channel.status_line.validCamera", + return StatCollector.translateToLocalFormatted("warpdrive.video_channel.status_line.valid_monitor", videoChannel, camera.position.chunkPosX, camera.position.chunkPosY, diff --git a/src/main/resources/assets/warpdrive/lang/de_DE.lang b/src/main/resources/assets/warpdrive/lang/de_DE.lang index b8d5a5c1..03f3107b 100644 --- a/src/main/resources/assets/warpdrive/lang/de_DE.lang +++ b/src/main/resources/assets/warpdrive/lang/de_DE.lang @@ -669,8 +669,8 @@ warpdrive.upgrade.status_line.valid=%1$s Upgrade installiert. warpdrive.video_channel.tooltip=Videokanal auf %1$d gestellt warpdrive.video_channel.get=Videokanal %2$d wurde von %1$s abgerufen warpdrive.video_channel.set=%1$s ist jetzt auf Videokanal %2$d gestellt -warpdrive.video_channel.status_line.valid=Videokanal %1$d ist gültig. -warpdrive.video_channel.status_line.validCamera=Videokanal %1$d ist gültig für die Kamera bei %2$d, %3$d, %4$d. +warpdrive.video_channel.status_line.valid_camera=Videokanal %1$d ist gültig. +warpdrive.video_channel.status_line.valid_monitor=Videokanal %1$d ist gültig für die Kamera bei %2$d, %3$d, %4$d. warpdrive.video_channel.status_line.invalid=§cVideokanal %1$d ist ungültig. warpdrive.video_channel.status_line.not_loaded=§cVideokanal %1$d ist ungültig oder die Kamera ist zu weit weg! warpdrive.video_channel.status_line.undefined=§7Nicht definierter Videokanal.\n§bNutze eine Stimmgabel§r um ihn einzustellen. diff --git a/src/main/resources/assets/warpdrive/lang/en_US.lang b/src/main/resources/assets/warpdrive/lang/en_US.lang index 480fc3bc..7c50a187 100644 --- a/src/main/resources/assets/warpdrive/lang/en_US.lang +++ b/src/main/resources/assets/warpdrive/lang/en_US.lang @@ -666,8 +666,8 @@ warpdrive.upgrade.status_line.valid=Upgraded with %1$s. warpdrive.video_channel.tooltip=Video channel is set to %1$d warpdrive.video_channel.get=Video channel %2$d has been retrieved from %1$s warpdrive.video_channel.set=%1$s is now tuned to Video channel %2$d -warpdrive.video_channel.status_line.valid=Video channel %1$d is valid. -warpdrive.video_channel.status_line.validCamera=Video channel %1$d is valid for camera at %2$d, %3$d, %4$d. +warpdrive.video_channel.status_line.valid_camera=Video channel %1$d is valid. +warpdrive.video_channel.status_line.valid_monitor=Video channel %1$d is valid for camera at %2$d, %3$d, %4$d. warpdrive.video_channel.status_line.invalid=§cVideo channel %1$d is invalid. warpdrive.video_channel.status_line.not_loaded=§cVideo channel %1$d is invalid or camera is too far away! warpdrive.video_channel.status_line.undefined=§7Undefined Video channel.\n§bUse a Tuning fork§r to set it. diff --git a/src/main/resources/assets/warpdrive/lang/fr_FR.lang b/src/main/resources/assets/warpdrive/lang/fr_FR.lang index 0e83205b..efeea351 100644 --- a/src/main/resources/assets/warpdrive/lang/fr_FR.lang +++ b/src/main/resources/assets/warpdrive/lang/fr_FR.lang @@ -666,8 +666,8 @@ warpdrive.upgrade.status_line.valid=Augmenté avec %1$s. warpdrive.video_channel.tooltip=Canal vidéo ajusté à %1$d warpdrive.video_channel.get=Le canal vidéo %2$d a été recupéré depuis %1$s warpdrive.video_channel.set=%1$s est désormais accordé au Canal vidéo %2$d -warpdrive.video_channel.status_line.valid=Le canal vidéo %1$d est valide. -warpdrive.video_channel.status_line.validCamera=Le canal vidéo %1$d est valide pour la caméra à %2$d %3$d %4$d. +warpdrive.video_channel.status_line.valid_camera=Le canal vidéo %1$d est valide. +warpdrive.video_channel.status_line.valid_monitor=Le canal vidéo %1$d est valide pour la caméra à %2$d %3$d %4$d. warpdrive.video_channel.status_line.invalid=§cLe canal vidéo %1$d est invalide. warpdrive.video_channel.status_line.not_loaded=§cLe canal vidéo %1$d est invalide ou la caméra est trop loin! warpdrive.video_channel.status_line.undefined=§7Le canal vidéo est non défini.\n§bUtilises un Diapason§r pour l'ajuster. diff --git a/src/main/resources/assets/warpdrive/lang/nl_NL.lang b/src/main/resources/assets/warpdrive/lang/nl_NL.lang index c6c8c5f7..e915b6c8 100644 --- a/src/main/resources/assets/warpdrive/lang/nl_NL.lang +++ b/src/main/resources/assets/warpdrive/lang/nl_NL.lang @@ -666,8 +666,8 @@ warpdrive.upgrade.status_line.valid=Geupgrade met1$s. warpdrive.video_channel.tooltip=Videokanaal is gezet naar %1$d warpdrive.video_channel.get=Videokanaal %2$d is achterhaald door %1$s warpdrive.video_channel.set=%1$s is nu afgestemd op videokanaal %2$d -warpdrive.video_channel.status_line.valid=Videokanaal %1$d is geldig. -warpdrive.video_channel.status_line.validCamera=Videokanaal %1$d is geldig voor camera op %2$d, %3$d, %4$d. +warpdrive.video_channel.status_line.valid_camera=Videokanaal %1$d is geldig. +warpdrive.video_channel.status_line.valid_monitor=Videokanaal %1$d is geldig voor camera op %2$d, %3$d, %4$d. warpdrive.video_channel.status_line.invalid=§cVideokanaal %1$d is ongeldig. warpdrive.video_channel.status_line.not_loaded=§cVideokanaal %1$d is ongeldig of camera is te ver weg! warpdrive.video_channel.status_line.undefined=§7niet gedefinieerd videokanaal.\n§bGebruik een Afstemmingsvork§r om het te zetten. diff --git a/src/main/resources/assets/warpdrive/lang/ru_RU.lang b/src/main/resources/assets/warpdrive/lang/ru_RU.lang index d38514f9..263966b1 100644 --- a/src/main/resources/assets/warpdrive/lang/ru_RU.lang +++ b/src/main/resources/assets/warpdrive/lang/ru_RU.lang @@ -666,8 +666,8 @@ warpdrive.upgrade.status_line.valid=Upgraded with %1$s. warpdrive.video_channel.tooltip=Видеоканал установлен на %1$d warpdrive.video_channel.get=Video channel %2$d has been retrieved from %1$s warpdrive.video_channel.set=%1$s настроен на видеоканал %2$d -warpdrive.video_channel.status_line.valid=Видеоканал %1$d действителен. -warpdrive.video_channel.status_line.validCamera=Видеоканал %1$d действителен для камеры на %2$d, %3$d, %4$d. +warpdrive.video_channel.status_line.valid_camera=Видеоканал %1$d действителен. +warpdrive.video_channel.status_line.valid_monitor=Видеоканал %1$d действителен для камеры на %2$d, %3$d, %4$d. warpdrive.video_channel.status_line.invalid=§cВидеоканал %1$d недействителен. warpdrive.video_channel.status_line.not_loaded=§cВидеоканал %1$d недействителен или камера слишком далеко. warpdrive.video_channel.status_line.undefined=§7Undefined Video channel.\n§bUse a Tuning fork§r to set it. diff --git a/src/main/resources/assets/warpdrive/lang/zh_CN.lang b/src/main/resources/assets/warpdrive/lang/zh_CN.lang index 2254f184..cc2c3dcb 100644 --- a/src/main/resources/assets/warpdrive/lang/zh_CN.lang +++ b/src/main/resources/assets/warpdrive/lang/zh_CN.lang @@ -666,8 +666,8 @@ warpdrive.upgrade.status_line.valid=用升级%1$s. warpdrive.video_channel.tooltip-tbc=频道设置为%1$d warpdrive.video_channel.get=视频频道 %2$d 已从频道 %1$s 断开 warpdrive.video_channel.set=%1$s正在切换至频道%2$d -warpdrive.video_channel.status_line.valid=视频通道%1$d有效 -warpdrive.video_channel.status_line.validCamera=相机的视频通道 %1$d有效,位于%2$d, %3$d, %4$d. +warpdrive.video_channel.status_line.valid_camera=视频通道%1$d有效 +warpdrive.video_channel.status_line.valid_monitor=相机的视频通道 %1$d有效,位于%2$d, %3$d, %4$d. warpdrive.video_channel.status_line.invalid=§c视频通道 %1$d 无效. warpdrive.video_channel.status_line.not_loaded=§c视频通道 %1$d 无效或者是相机的距离太远! warpdrive.video_channel.status_line.undefined=§7未定义的视频通道.\n§b使用一个音叉§r 去设置它. diff --git a/src/main/resources/assets/warpdrive/lang/zh_TW.lang b/src/main/resources/assets/warpdrive/lang/zh_TW.lang index fba1f2b5..33743b2b 100644 --- a/src/main/resources/assets/warpdrive/lang/zh_TW.lang +++ b/src/main/resources/assets/warpdrive/lang/zh_TW.lang @@ -664,7 +664,7 @@ warpdrive.upgrade.status_line.valid=已升級 %1$s. warpdrive.video_channel.tooltip=視頻頻道設置為 %1$d warpdrive.video_channel.get=Video channel %2$d has been retrieved from %1$s warpdrive.video_channel.set=%1$s 現在調整為視頻頻道 %2$d -warpdrive.video_channel.status_line.valid=視頻頻道 %1$d 有效。 +warpdrive.video_channel.status_line.valid_camera=視頻頻道 %1$d 有效。 warpdrive.video_channel.status_line.validCamera視頻頻道 %1$d 對於攝像機 %2$d, %3$d, %4$d 有效 warpdrive.video_channel.status_line.invalid=§c視頻頻道 %1$d 是無效的。 warpdrive.video_channel.status_line.not_loaded=§c視頻頻道 %1$d 是無效的或者錄像機太過遙遠。