diff --git a/src/main/resources/assets/ae2stuff/lang/en_US.lang b/src/main/resources/assets/ae2stuff/lang/en_US.lang index e6b0faf..0fa1e9c 100644 --- a/src/main/resources/assets/ae2stuff/lang/en_US.lang +++ b/src/main/resources/assets/ae2stuff/lang/en_US.lang @@ -2,6 +2,7 @@ tile.ae2stuff.Encoder.name=Pattern Encoder tile.ae2stuff.Grower.name=Crystal Growth Chamber tile.ae2stuff.Inscriber.name=Advanced Inscriber tile.ae2stuff.Wireless.name=Wireless Connector +tile.ae2stuff.WirelessHub.name=Hub item.ae2stuff.WirelessKit.name=Wireless Setup Kit item.ae2stuff.AdvWirelessKit.name=Advanced Wireless Setup Kit @@ -33,6 +34,7 @@ ae2stuff.wireless.advtool.binding=§aBinding Mode ae2stuff.wireless.advtool.queueing.activated=Queuing mode activated ae2stuff.wireless.advtool.binding.activated=Binding mode activated ae2stuff.wireless.advtool.queued=Added connector at %s,%s,%s to queue +ae2stuff.wireless.advtool.queuederror=Connector already in queue! ae2stuff.wireless.advtool.queueing.empty=Click Wireless Connectors to add to binding queue ae2stuff.wireless.advtool.binding.empty=Switch to Queuing Mode to add connectors to queue ae2stuff.wireless.advtool.queueing.notempty=Current wireless connectors in queue: diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off.png deleted file mode 100644 index 39f40ab..0000000 Binary files a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off.png and /dev/null differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off17.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off17.png index 34d4141..39f40ab 100644 Binary files a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off17.png and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off17.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off18.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off18.png new file mode 100644 index 0000000..efec65d Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off18.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off19.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off19.png new file mode 100644 index 0000000..df8add2 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off19.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off20.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off20.png new file mode 100644 index 0000000..c4b9f95 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off20.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off21.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off21.png new file mode 100644 index 0000000..fc72ae1 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off21.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off22.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off22.png new file mode 100644 index 0000000..b9b206b Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off22.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off23.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off23.png new file mode 100644 index 0000000..c885d49 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off23.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off24.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off24.png new file mode 100644 index 0000000..2ea3e6d Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off24.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off25.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off25.png new file mode 100644 index 0000000..2bfc5b7 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off25.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off26.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off26.png new file mode 100644 index 0000000..ad00136 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off26.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off27.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off27.png new file mode 100644 index 0000000..8aa790f Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off27.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off28.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off28.png new file mode 100644 index 0000000..5b4cbf0 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off28.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off29.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off29.png new file mode 100644 index 0000000..0aa0ae6 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off29.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off30.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off30.png new file mode 100644 index 0000000..d33819a Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off30.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off31.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off31.png new file mode 100644 index 0000000..389055b Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off31.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off32.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off32.png new file mode 100644 index 0000000..a8369c2 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off32.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off33.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off33.png new file mode 100644 index 0000000..997ee04 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off33.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off34.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off34.png new file mode 100644 index 0000000..7bf3b7d Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_off34.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on18.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on18.png new file mode 100644 index 0000000..5816e00 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on18.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on19.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on19.png new file mode 100644 index 0000000..5a14e4e Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on19.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on20.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on20.png new file mode 100644 index 0000000..220b2df Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on20.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on21.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on21.png new file mode 100644 index 0000000..13ae4db Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on21.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on22.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on22.png new file mode 100644 index 0000000..7543bce Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on22.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on23.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on23.png new file mode 100644 index 0000000..e3ee74b Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on23.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on24.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on24.png new file mode 100644 index 0000000..cd59e62 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on24.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on25.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on25.png new file mode 100644 index 0000000..c0a76a2 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on25.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on26.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on26.png new file mode 100644 index 0000000..063221f Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on26.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on27.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on27.png new file mode 100644 index 0000000..2720056 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on27.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on28.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on28.png new file mode 100644 index 0000000..1667802 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on28.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on29.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on29.png new file mode 100644 index 0000000..b131ad1 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on29.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on30.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on30.png new file mode 100644 index 0000000..b95f4b1 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on30.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on31.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on31.png new file mode 100644 index 0000000..bc302b4 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on31.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on32.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on32.png new file mode 100644 index 0000000..30378d9 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on32.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on33.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on33.png new file mode 100644 index 0000000..faaf615 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on33.png differ diff --git a/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on34.png b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on34.png new file mode 100644 index 0000000..6526740 Binary files /dev/null and b/src/main/resources/assets/ae2stuff/textures/blocks/wireless/side_on34.png differ diff --git a/src/main/scala/net/bdew/ae2stuff/Recipes.scala b/src/main/scala/net/bdew/ae2stuff/Recipes.scala index b890eb9..d2ed49f 100644 --- a/src/main/scala/net/bdew/ae2stuff/Recipes.scala +++ b/src/main/scala/net/bdew/ae2stuff/Recipes.scala @@ -19,7 +19,143 @@ object Recipes { ) GameRegistry.addShapelessRecipe( new ItemStack(BlockWireless), - new ItemStack(BlockWireless, 1, OreDictionary.WILDCARD_VALUE) + new ItemStack(BlockWireless, 1, 1) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 2) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 3) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 4) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 5) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 6) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 7) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 8) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 9) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 10) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 11) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 12) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 13) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 14) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 15) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless), + new ItemStack(BlockWireless, 1, 16) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless), + new ItemStack(BlockWireless) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 18) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 19) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 20) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 21) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 22) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 23) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 24) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 25) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 26) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 27) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 28) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 29) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 30) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 31) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 32) + ) + GameRegistry.addShapelessRecipe( + new ItemStack(BlockWireless, 1, 17), + new ItemStack(BlockWireless, 1, 33) ) } } diff --git a/src/main/scala/net/bdew/ae2stuff/items/AdvWirelessKit.scala b/src/main/scala/net/bdew/ae2stuff/items/AdvWirelessKit.scala index 6037788..b0dc217 100644 --- a/src/main/scala/net/bdew/ae2stuff/items/AdvWirelessKit.scala +++ b/src/main/scala/net/bdew/ae2stuff/items/AdvWirelessKit.scala @@ -116,15 +116,26 @@ object AdvWirelessKit L("ae2stuff.wireless.tool.security.player").setColor(Color.RED) ) } else if (getMode(stack) == MODE_QUEUING) { - addLocation(stack, pos, world.provider.dimensionId) - player.addChatMessage( - L( - "ae2stuff.wireless.advtool.queued", - pos.x.toString, - pos.y.toString, - pos.z.toString - ).setColor(Color.GREEN) - ) + var isHub = false; + val tempTE = + world.getTileEntity(pos.x, pos.y, pos.z).asInstanceOf[TileWireless] + if (tempTE != null) { + isHub = tempTE.isHub + } + if (addLocation(stack, pos, world.provider.dimensionId, isHub)) { + player.addChatMessage( + L( + "ae2stuff.wireless.advtool.queued", + pos.x.toString, + pos.y.toString, + pos.z.toString + ).setColor(Color.GREEN) + ) + } else { + player.addChatMessage( + L("ae2stuff.wireless.advtool.queuederror").setColor(Color.RED) + ) + } } else if (getMode(stack) == MODE_BINDING) { if (hasLocation(stack)) { // Have other location - start connecting @@ -155,10 +166,14 @@ object AdvWirelessKit Color.RED ) ) + } else if (tile.isHub && other.isHub) { + player.addChatMessage( + L("ae2stuff.wireless.tool.failed").setColor(Color.RED) + ) } else { // Player can modify both sides - unlink current connections if any - tile.doUnlink() - other.doUnlink() + if (!tile.isHub) tile.doUnlink() + if (!other.isHub) other.doUnlink() // Make player the owner of both blocks tile.getNode.setPlayerID(pid) diff --git a/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala b/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala index bedfc32..728f853 100644 --- a/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala +++ b/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala @@ -100,10 +100,14 @@ object ItemWirelessKit Color.RED ) ) + } else if (tile.isHub && other.isHub) { + player.addChatMessage( + L("ae2stuff.wireless.tool.failed").setColor(Color.RED) + ) } else { // Player can modify both sides - unlink current connections if any - tile.doUnlink() - other.doUnlink() + if (!tile.isHub) tile.doUnlink() + if (!other.isHub) other.doUnlink() // Make player the owner of both blocks tile.getNode.setPlayerID(pid) diff --git a/src/main/scala/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala b/src/main/scala/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala index 6cd09c4..b5b392a 100644 --- a/src/main/scala/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala +++ b/src/main/scala/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala @@ -17,7 +17,7 @@ import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.ae2stuff.misc.{BlockWrenchable, MachineMaterial} import net.bdew.lib.Misc import net.bdew.lib.block.{HasItemBlock, HasTE, ItemBlockTooltip, SimpleBlock} -import net.minecraft.block.Block +import net.minecraft.block.{Block, BlockContainer} import net.minecraft.client.renderer.texture.IIconRegister import net.minecraft.creativetab.CreativeTabs import net.minecraft.entity.EntityLivingBase @@ -39,6 +39,8 @@ object BlockWireless setHardness(1) + var isHub = false; + override def getDrops( world: World, x: Int, @@ -49,7 +51,16 @@ object BlockWireless ): util.ArrayList[ItemStack] = { val stack = new ItemStack(this) val te = getTE(world, x, y, z) - if (te.color != AEColor.Transparent) { + if (isHub) { + stack.setItemDamage(17); + } + if (te.isHub) { + if (te.color != AEColor.Transparent) { + stack.setItemDamage(te.color.ordinal() + 18) + } else { + stack.setItemDamage(17) + } + } else if (te.color != AEColor.Transparent) { stack.setItemDamage(te.color.ordinal() + 1) } val drops = new util.ArrayList[ItemStack]() @@ -62,7 +73,7 @@ object BlockWireless tab: CreativeTabs, list: util.List[_] ): Unit = { - for (meta <- 0 to 16) { + for (meta <- 0 to 33) { list .asInstanceOf[util.List[ItemStack]] .add(new ItemStack(itemIn, 1, meta)) @@ -79,7 +90,13 @@ object BlockWireless ): ItemStack = { val stack = new ItemStack(this) val te = getTE(world, x, y, z) - if (te.color != AEColor.Transparent) { + if (te.isHub) { + if (te.color != AEColor.Transparent) { + stack.setItemDamage(te.color.ordinal() + 18) + } else { + stack.setItemDamage(17) + } + } else if (te.color != AEColor.Transparent) { stack.setItemDamage(te.color.ordinal() + 1) } stack @@ -93,7 +110,9 @@ object BlockWireless block: Block, meta: Int ): Unit = { - getTE(world, x, y, z).doUnlink() + val te = getTE(world, x, y, z); + te.doUnlink() + isHub = te.isHub; super.breakBlock(world, x, y, z, block, meta) } @@ -110,11 +129,19 @@ object BlockWireless te.placingPlayer = player.asInstanceOf[EntityPlayer] } if (stack != null) { + val itemDamage = stack.getItemDamage if (stack.hasDisplayName) { te.customName = stack.getDisplayName } - if (stack.getItemDamage > 0) { - te.color = AEColor.values().apply(stack.getItemDamage - 1) + if (itemDamage > 16) { + te.isHub = true; + if (itemDamage == 17) { + te.color = AEColor.values().apply(16) + } else { + te.color = AEColor.values().apply(itemDamage - 18) + } + } else if (itemDamage > 0) { + te.color = AEColor.values().apply(itemDamage - 1) } } } @@ -161,10 +188,18 @@ object BlockWireless ): IIcon = { val te = getTE(worldIn, x, y, z) val meta = worldIn.getBlockMetadata(x, y, z) - if (meta > 0) { - icon_on.apply(te.color.ordinal()) + if (te.isHub) { + if (meta > 0) { + icon_on.apply(te.color.ordinal() + 17) + } else { + icon_off.apply(te.color.ordinal() + 17) + } } else { - icon_off.apply(te.color.ordinal()) + if (meta > 0) { + icon_on.apply(te.color.ordinal()) + } else { + icon_off.apply(te.color.ordinal()) + } } } @@ -172,6 +207,8 @@ object BlockWireless override def getIcon(side: Int, meta: Int): IIcon = { if (meta == 0) { icon_on.apply(AEColor.Transparent.ordinal()) + } else if (meta == 17) { + icon_on.apply(33) } else { icon_on.apply(meta - 1) } @@ -179,7 +216,7 @@ object BlockWireless @SideOnly(Side.CLIENT) override def registerBlockIcons(reg: IIconRegister): Unit = { - val index = 1.to(17) + val index = 1.to(34) icon_on = index .map(index => reg.registerIcon(Misc.iconName(modId, name, "side_on" + index)) @@ -204,12 +241,29 @@ class ItemBlockWireless(b: Block) extends ItemBlockTooltip(b) { advanced: Boolean ): Unit = { super.addInformation(stack, player, list, advanced) - if (stack.getItemDamage > 0) { + val itemDamage = stack.getItemDamage + if (itemDamage == 17) { + list + .asInstanceOf[util.List[String]] + .add(Misc.toLocal("tile.ae2stuff.WirelessHub.name")) + list + .asInstanceOf[util.List[String]] + .add(Misc.toLocal(AEColor.values().apply(16).unlocalizedName)) + } else if (itemDamage > 16) { + list + .asInstanceOf[util.List[String]] + .add(Misc.toLocal("tile.ae2stuff.WirelessHub.name")) + list + .asInstanceOf[util.List[String]] + .add( + Misc.toLocal(AEColor.values().apply(itemDamage - 18).unlocalizedName) + ) + } else if (itemDamage > 0) { list .asInstanceOf[util.List[String]] .add( Misc.toLocal( - AEColor.values().apply(stack.getItemDamage - 1).unlocalizedName + AEColor.values().apply(itemDamage - 1).unlocalizedName ) ) } diff --git a/src/main/scala/net/bdew/ae2stuff/machines/wireless/TileWireless.scala b/src/main/scala/net/bdew/ae2stuff/machines/wireless/TileWireless.scala index ed9500f..d55b930 100644 --- a/src/main/scala/net/bdew/ae2stuff/machines/wireless/TileWireless.scala +++ b/src/main/scala/net/bdew/ae2stuff/machines/wireless/TileWireless.scala @@ -21,7 +21,6 @@ import net.bdew.ae2stuff.grid.{GridTile, VariableIdlePower} import net.bdew.lib.block.BlockRef import net.bdew.lib.data.base.{TileDataSlots, UpdateKind} import net.bdew.lib.multiblock.data.DataSlotPos -import net.bdew.lib.nbt.NBT import net.minecraft.block.Block import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack @@ -47,6 +46,9 @@ class TileWireless var customName: String = null var color: AEColor = AEColor.Transparent + var isHub = false + var connectionsList = Array[TileWireless]() + var hubPowerUsage = 0d; def isLinked = link.isDefined def getLink = link flatMap (_.getTile[TileWireless](worldObj)) @@ -71,19 +73,36 @@ class TileWireless }) def doLink(other: TileWireless): Boolean = { - if (other.link.isEmpty) { + if (other.link.isEmpty && !(isHub || other.isHub)) { other.link.set(myPos) this.customName = other.customName link.set(other.myPos) setupConnection() + true + } else if (isHub) { + other.link.set(myPos) + other.customName = this.customName + other.setupConnection() + true + } else if (other.isHub) { + link.set(other.myPos) + customName = other.customName + setupConnection() + true } else false } def doUnlink(): Unit = { - breakConnection() - getLink foreach { that => - this.link := None - that.link := None + if (isHub) { + connectionsList foreach { that => + that.doUnlink() + } + } else { + breakConnection() + getLink foreach { that => + this.link := None + that.link := None + } } } @@ -91,7 +110,11 @@ class TileWireless getLink foreach { that => connection = AEApi.instance().createGridConnection(this.getNode, that.getNode) - that.connection = connection + if (that.isHub) { + that.connectionsList = that.connectionsList :+ this + } else { + that.connection = connection + } val dx = this.xCoord - that.xCoord val dy = this.yCoord - that.yCoord val dz = this.zCoord - that.zCoord @@ -101,7 +124,11 @@ class TileWireless dist * dist + 3 ) this.setIdlePowerUse(power) - that.setIdlePowerUse(power) + if (!that.isHub) { + that.setIdlePowerUse(power) + } else { + that.setHubPowerUse(power) + } if (worldObj.blockExists(xCoord, yCoord, zCoord)) worldObj.setBlockMetadataWithNotify( this.xCoord, @@ -123,23 +150,55 @@ class TileWireless false } + def setHubPowerUse(power: Double): Unit = { + hubPowerUsage += power + this.setIdlePowerUse(hubPowerUsage) + } + + def getHubChannels: Int = { + var channels = 0 + connectionsList foreach { that => + channels += that.connection.getUsedChannels + } + channels + } + def breakConnection(): Unit = { if (connection != null) connection.destroy() connection = null - setIdlePowerUse(0d) getLink foreach { other => - other.connection = null - other.setIdlePowerUse(0d) - if (worldObj.blockExists(other.xCoord, other.yCoord, other.zCoord)) - worldObj.setBlockMetadataWithNotify( - other.xCoord, - other.yCoord, - other.zCoord, - 0, - 3 + if (other.isHub) { + other.connectionsList = other.connectionsList.filterNot(_ == this) + other.setHubPowerUse(-getIdlePowerUsage) + if ( + other.connectionsList.isEmpty && worldObj.blockExists( + other.xCoord, + other.yCoord, + other.zCoord + ) ) + worldObj.setBlockMetadataWithNotify( + other.xCoord, + other.yCoord, + other.zCoord, + 0, + 3 + ) + } else { + other.connection = null + other.setIdlePowerUse(0d) + if (worldObj.blockExists(other.xCoord, other.yCoord, other.zCoord)) + worldObj.setBlockMetadataWithNotify( + other.xCoord, + other.yCoord, + other.zCoord, + 0, + 3 + ) + } } + setIdlePowerUse(0d) if (worldObj.blockExists(xCoord, yCoord, zCoord)) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3) } @@ -166,6 +225,7 @@ class TileWireless t.setString("CustomName", customName) } t.setShort("Color", color.ordinal().toShort) + t.setBoolean("isHub", isHub) } override def doLoad(kind: UpdateKind.Value, t: NBTTagCompound): Unit = { @@ -176,7 +236,11 @@ class TileWireless if (!t.hasKey("Color")) { t.setShort("Color", AEColor.Transparent.ordinal().toShort) } + if (!t.hasKey("isHub")) { + t.setBoolean("isHub", isHub) + } val colorIdx = t.getShort("Color").toInt + this.isHub = t.getBoolean("isHub") this.color = AEColor.values().apply(colorIdx) if (hasWorldObj) { worldObj.markBlockRangeForRenderUpdate( diff --git a/src/main/scala/net/bdew/ae2stuff/misc/AdvItemLocationStore.scala b/src/main/scala/net/bdew/ae2stuff/misc/AdvItemLocationStore.scala index 1d5683a..f914954 100644 --- a/src/main/scala/net/bdew/ae2stuff/misc/AdvItemLocationStore.scala +++ b/src/main/scala/net/bdew/ae2stuff/misc/AdvItemLocationStore.scala @@ -20,7 +20,12 @@ trait AdvItemLocationStore extends Item { private val COMPOUND_TAG = NBTBase.NBTTypes.indexOf("COMPOUND") - def addLocation(stack: ItemStack, loc: BlockRef, dimension: Int): Boolean = { + def addLocation( + stack: ItemStack, + loc: BlockRef, + dimension: Int, + isHub: Boolean + ): Boolean = { if (!stack.hasTagCompound) stack.setTagCompound(new NBTTagCompound) val tag = stack.getTagCompound if (tag.hasKey("dim") && tag.getInteger("dim") != dimension) { @@ -30,7 +35,7 @@ trait AdvItemLocationStore extends Item { for (i <- 0 until locList.tagCount()) { val tag = locList.getCompoundTagAt(i) val pos = BlockRef.fromNBT(tag) - if (pos == loc) { + if (pos == loc && !isHub) { return false } } diff --git a/src/main/scala/net/bdew/ae2stuff/waila/WailaWirelessDataProvider.scala b/src/main/scala/net/bdew/ae2stuff/waila/WailaWirelessDataProvider.scala index 30c517b..60b25c0 100644 --- a/src/main/scala/net/bdew/ae2stuff/waila/WailaWirelessDataProvider.scala +++ b/src/main/scala/net/bdew/ae2stuff/waila/WailaWirelessDataProvider.scala @@ -49,6 +49,16 @@ object WailaWirelessDataProvider data.setString("name", te.customName) } tag.setTag("wireless_waila", data) + } else if (te.isHub) { + val data = NBT( + "channels" -> te.getHubChannels, + "color" -> te.color.ordinal(), + "power" -> PowerMultiplier.CONFIG.multiply(te.getIdlePowerUsage) + ) + if (te.hasCustomName) { + data.setString("name", te.customName) + } + tag.setTag("wirelesshub_waila", data) } else { val data = NBT( "connected" -> false, @@ -101,6 +111,27 @@ object WailaWirelessDataProvider Misc.toLocal(AEColor.values().apply(color).unlocalizedName) :: Nil } else Nil) } + } else if (acc.getNBTData.hasKey("wirelesshub_waila")) { + val data = acc.getNBTData.getCompoundTag("wirelesshub_waila") + val name = if (data.hasKey("name")) data.getString("name") else null + val color = data.getInteger("color") + List( + Misc.toLocalF("tile.ae2stuff.WirelessHub.name"), + Misc.toLocalF( + "ae2stuff.waila.wireless.channels", + data.getInteger("channels") + ), + Misc.toLocalF( + "ae2stuff.waila.wireless.power", + DecFormat.short(data.getDouble("power")) + ) + ) + .++(if (name != null) { + Misc.toLocalF("ae2stuff.waila.wireless.name", name) :: Nil + } else Nil) + .++(if (color != AEColor.Transparent.ordinal()) { + Misc.toLocal(AEColor.values().apply(color).unlocalizedName) :: Nil + } else Nil) } else List.empty } }