diff --git a/src/main/resources/assets/ae2stuff/lang/en_US.lang b/src/main/resources/assets/ae2stuff/lang/en_US.lang index e6b0faf..81a16a3 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=Wireless 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: @@ -41,11 +43,17 @@ ae2stuff.wireless.advtool.connector.next=Next connector in queue: %s,%s,%s ae2stuff.wireless.advtool.extra=§oSneak right click to change mode between queuing and binding mode ae2stuff.wireless.advtool.noconnectors=No connectors found in queue. Try putting the tool into queueing mode and adding some ae2stuff.wireless.advtool.pop=Removed %s,%s,%s from queue +ae2stuff.wireless.advtool.hub.queued=%s hub slots added to queue +ae2stuff.wireless.advtool.queueing.clear=Queue is cleared +ae2stuff.wireless.tooltips.advtool.queueing.clear=Shift + Ctrl + R-click for clear queue +ae2stuff.wireless.tooltips.advtool.hubqols.binding=Ctrl + R-click for connect to all free hub slots +ae2stuff.wireless.tooltips.advtool.hubqols.queueing=Ctrl + R-click for add all free hub slots to queue ae2stuff.wireless.tool.connected=Connected to %s,%s,%s ae2stuff.wireless.tool.failed=Connection failed ae2stuff.wireless.tool.dimension=Both connectors must be in the same dimension ae2stuff.wireless.tool.noexist=Bound connector does not exist ae2stuff.wireless.tool.security.player=Security violation - you are not allowed to modify this network +ae2stuff.wireless.tool.targethubfull=Target Hub is Full ae2stuff.visualiser.bound=Visualising network at %s,%s,%s ae2stuff.visualiser.mode=Mode: 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..add9750 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..004f13f 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..f33d20d 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..f5ea6ad 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..7d2003e 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..9fba6ed 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..d43b0d7 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..d78d587 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..1aeb313 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..7ac505b 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..8bcb4a5 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..732fa88 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..ef16121 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..886b684 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..1093d06 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..f594d00 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..e27ad32 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..e16bfb7 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..1a35dad 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..b58a5c7 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..ad1692e 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..03c1d70 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..5c61ea7 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..acdbf1f 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..6ef5d3d 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..af1bff8 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..5a98df4 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..b29855d 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..13a3679 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..f860a79 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..67fb9b5 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..df47ff1 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..58adb33 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..570e723 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..f9f3764 100644 --- a/src/main/scala/net/bdew/ae2stuff/Recipes.scala +++ b/src/main/scala/net/bdew/ae2stuff/Recipes.scala @@ -4,7 +4,6 @@ import cpw.mods.fml.common.registry.GameRegistry import net.bdew.ae2stuff.items.{AdvWirelessKit, ItemWirelessKit} import net.bdew.ae2stuff.machines.wireless.BlockWireless import net.minecraft.item.ItemStack -import net.minecraftforge.oredict.OreDictionary object Recipes { def load(): Unit = { @@ -19,7 +18,131 @@ 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, 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..b7a23f0 100644 --- a/src/main/scala/net/bdew/ae2stuff/items/AdvWirelessKit.scala +++ b/src/main/scala/net/bdew/ae2stuff/items/AdvWirelessKit.scala @@ -17,10 +17,10 @@ import net.bdew.ae2stuff.misc.AdvItemLocationStore import net.bdew.lib.Misc import net.bdew.lib.block.BlockRef import net.bdew.lib.items.SimpleItem -import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.world.World +import org.lwjgl.input.Keyboard import java.util @@ -53,6 +53,17 @@ object AdvWirelessKit ): ItemStack = { import net.bdew.lib.helpers.ChatHelper._ if (!world.isRemote && player.isSneaking) { + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + while (hasLocation(stack)) { + popLocation(stack) + } + player.addChatMessage( + L("ae2stuff.wireless.advtool.queueing.clear").setColor( + Color.GREEN + ) + ) + return stack + } toggleMode(stack) if (getMode(stack) == MODE_QUEUING) { player.addChatMessage( @@ -86,6 +97,17 @@ object AdvWirelessKit if (!pos.blockIs(world, BlockWireless)) return false if (!world.isRemote) { if (player.isSneaking) { + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + while (hasLocation(stack)) { + popLocation(stack) + } + player.addChatMessage( + L("ae2stuff.wireless.advtool.queueing.clear").setColor( + Color.GREEN + ) + ) + return true + } toggleMode(stack) if (getMode(stack) == MODE_QUEUING) { player.addChatMessage( @@ -116,93 +138,149 @@ 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) - ) - } else if (getMode(stack) == MODE_BINDING) { - if (hasLocation(stack)) { - // Have other location - start connecting - val otherPos = getNextLocation(stack) - - if (getDimension(stack) != world.provider.dimensionId) { - // Different dimensions - error out + var isHub = false; + val tempTE = + world.getTileEntity(pos.x, pos.y, pos.z).asInstanceOf[TileWireless] + if (tempTE != null) { + if (tempTE.connectionsList.length >= 32) { + player.addChatMessage( + L("ae2stuff.wireless.tool.targethubfull").setColor(Color.RED) + ) + return true + } + isHub = tempTE.isHub + if (isHub && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + val t = 32 - tempTE.connectionsList.length + var i = 0 + while (i < t) { + addLocation(stack, pos, world.provider.dimensionId, isHub) + i = i + 1 + } player.addChatMessage( - L("ae2stuff.wireless.tool.dimension").setColor(Color.RED) + L( + "ae2stuff.wireless.advtool.hub.queued", + i.toString + ).setColor(Color.GREEN) ) - } else if (pos == otherPos) { - // Same block - clear the location - popLocation(stack) } else { - otherPos.getTile[TileWireless](world) match { - // Check that the other tile is still around - case Some(other: TileWireless) => - // And check that the player can modify it too - if ( - !Security.playerHasPermission( - other.getNode.getGrid, - pid, - SecurityPermissions.BUILD - ) - ) { - player.addChatMessage( - L("ae2stuff.wireless.tool.security.player").setColor( - Color.RED - ) + 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) { + var doLoop = true + while (doLoop) { + doLoop = false + if (hasLocation(stack)) { + if (tile.isHub && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + if ( + tile.connectionsList.length < 31 && getLocations(stack) + .tagCount() > 1 + ) { + doLoop = true + } else if (tile.connectionsList.length == 32) { + player.addChatMessage( + L("ae2stuff.wireless.tool.targethubfull").setColor( + Color.RED ) - } else { - // Player can modify both sides - unlink current connections if any - tile.doUnlink() - other.doUnlink() + ) + return true + } + } + // Have other location - start connecting + val otherPos = getNextLocation(stack) - // Make player the owner of both blocks - tile.getNode.setPlayerID(pid) - other.getNode.setPlayerID(pid) - try { - if (tile.doLink(other)) { - player.addChatMessage( - L( - "ae2stuff.wireless.tool.connected", - pos.x.toString, - pos.y.toString, - pos.z.toString - ).setColor(Color.GREEN) - ) - } else { - player.addChatMessage( - L("ae2stuff.wireless.tool.failed").setColor(Color.RED) + if (getDimension(stack) != world.provider.dimensionId) { + // Different dimensions - error out + player.addChatMessage( + L("ae2stuff.wireless.tool.dimension").setColor(Color.RED) + ) + } else if (pos == otherPos) { + // Same block - clear the location + popLocation(stack) + } else { + otherPos.getTile[TileWireless](world) match { + // Check that the other tile is still around + case Some(other: TileWireless) => + // And check that the player can modify it too + if ( + !Security.playerHasPermission( + other.getNode.getGrid, + pid, + SecurityPermissions.BUILD + ) + ) { + player.addChatMessage( + L("ae2stuff.wireless.tool.security.player").setColor( + 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 + if (!tile.isHub) tile.doUnlink() + if (!other.isHub) other.doUnlink() + + // Make player the owner of both blocks + tile.getNode.setPlayerID(pid) + other.getNode.setPlayerID(pid) + try { + if (tile.doLink(other)) { + player.addChatMessage( + L( + "ae2stuff.wireless.tool.connected", + pos.x.toString, + pos.y.toString, + pos.z.toString + ).setColor(Color.GREEN) + ) + } else { + player.addChatMessage( + L("ae2stuff.wireless.tool.failed").setColor( + Color.RED + ) + ) + } + } catch { + case e: FailedConnection => + player.addChatComponentMessage( + (L( + "ae2stuff.wireless.tool.failed" + ) & ": " & e.getMessage).setColor(Color.RED) + ) + tile.doUnlink() + print("Failed to link wireless connector: " + e) } - } catch { - case e: FailedConnection => - player.addChatComponentMessage( - (L( - "ae2stuff.wireless.tool.failed" - ) & ": " & e.getMessage).setColor(Color.RED) - ) - tile.doUnlink() - print("Failed to link wireless connector: " + e) } - } - popLocation(stack) - case _ => - // The other block is gone - error out - player.addChatMessage( - L("ae2stuff.wireless.tool.noexist").setColor(Color.RED) - ) - popLocation(stack) + popLocation(stack) + case _ => + // The other block is gone - error out + player.addChatMessage( + L("ae2stuff.wireless.tool.noexist").setColor(Color.RED) + ) + popLocation(stack) + } } + } else { + player.addChatMessage( + L("ae2stuff.wireless.advtool.noconnectors").setColor(Color.RED) + ) } - true - } else { - player.addChatMessage( - L("ae2stuff.wireless.advtool.noconnectors").setColor(Color.RED) - ) } } } @@ -239,6 +317,9 @@ object AdvWirelessKit list.add(loc.x + "," + loc.y + "," + loc.z) } } + list.add( + Misc.toLocal("ae2stuff.wireless.tooltips.advtool.hubqols.queueing") + ) } else if (getMode(stack) == MODE_BINDING) { list.add(Misc.toLocal("ae2stuff.wireless.advtool.binding")) if (getLocations(stack).tagCount() == 0) { @@ -250,7 +331,11 @@ object AdvWirelessKit list.add(loc.x + "," + loc.y + "," + loc.z) } } + list.add( + Misc.toLocal("ae2stuff.wireless.tooltips.advtool.hubqols.binding") + ) } - list.add(Misc.toLocal("ae2stuff.wireless.advtool.extra")); + list.add(Misc.toLocal("ae2stuff.wireless.tooltips.advtool.queueing.clear")) + list.add(Misc.toLocal("ae2stuff.wireless.advtool.extra")) } } diff --git a/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala b/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala index bedfc32..2c0e8a1 100644 --- a/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala +++ b/src/main/scala/net/bdew/ae2stuff/items/ItemWirelessKit.scala @@ -71,6 +71,10 @@ object ItemWirelessKit player.addChatMessage( L("ae2stuff.wireless.tool.security.player").setColor(Color.RED) ) + } else if (tile.isHub && tile.connectionsList.length == 32) { + player.addChatMessage( + L("ae2stuff.wireless.tool.targethubfull").setColor(Color.RED) + ) } else if (hasLocation(stack)) { // Have other location - start connecting val otherPos = getLocation(stack) @@ -100,10 +104,22 @@ object ItemWirelessKit Color.RED ) ) + } else if (tile.isHub && other.isHub) { + player.addChatMessage( + L("ae2stuff.wireless.tool.failed").setColor(Color.RED) + ) + } else if ( + tile.connectionsList.length == 32 || other.connectionsList.length == 32 + ) { + player.addChatMessage( + L("ae2stuff.wireless.tool.targethubfull").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 779f8f5..5680549 100644 --- a/src/main/scala/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala +++ b/src/main/scala/net/bdew/ae2stuff/machines/wireless/BlockWireless.scala @@ -39,6 +39,8 @@ object BlockWireless setHardness(1) + var isHub = false; + override def getDrops( world: World, x: Int, @@ -49,8 +51,18 @@ object BlockWireless ): util.ArrayList[ItemStack] = { val stack = new ItemStack(this) val te = world.getTileEntity(x, y, z).asInstanceOf[TileWireless] - if (te != null && te.color != AEColor.Transparent) { - stack.setItemDamage(te.color.ordinal() + 1) + if (te != null) { + 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) + } + } else if (isHub) { + stack.setItemDamage(17); } val drops = new util.ArrayList[ItemStack]() drops.add(stack) @@ -62,7 +74,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 +91,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 +111,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 +130,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 +189,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 +208,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 +217,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 +242,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..99a90f8 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 } }