forked from MightyPirates/OpenComputers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added waypoint block, can be queried using navigation upgrades.
Fixed drones losing their name when changing their EEPROM.
- Loading branch information
Showing
36 changed files
with
402 additions
and
35 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions
9
src/main/resources/assets/opencomputers/doc/en_US/block/waypoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Waypoint | ||
|
||
!["This way!" - "No, that way!"](oredict:oc:waypoint) | ||
|
||
The waypoint's use lies not in itself, but in how it can be used. [Navigation upgrades](../item/navigationUpgrade.md) can detect waypoints, so devices with a navigation upgrade can use these waypoints to navigate the world. This is particularly useful for writing easily reusable programs for devices such as [robots](robot.md) and [drones](../item/drone.md). | ||
|
||
Note that the actual position reported when queried by a navigation upgrade is *the block in front of the waypoint* (indicated by the particle effects). This way you can place it next to and above a chest, and can refer to the waypoint's position as "above the chest", without having to take the waypoint's rotation into account in your program. | ||
|
||
A waypoint has two properties that can be used when querying it via a navigation upgrade: the current level of redstone signal it is receiving, and an editable label. The label is a 32-character long string that can be edited either via a GUI or via the component exposed by the waypoint block. These two properties can then be used on the device to determine what to do with the waypoint. For example, a sorting program can be set to treat all blocks with a high redstone signal as inputs and those with a low signal as outputs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+523 Bytes
src/main/resources/assets/opencomputers/textures/blocks/WaypointBack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+444 Bytes
src/main/resources/assets/opencomputers/textures/blocks/WaypointFront.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+529 Bytes
src/main/resources/assets/opencomputers/textures/blocks/WaypointSide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+364 Bytes
src/main/resources/assets/opencomputers/textures/blocks/WaypointTop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-20 Bytes
(97%)
src/main/resources/assets/opencomputers/textures/items/UpgradeHover0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2 Bytes
(100%)
src/main/resources/assets/opencomputers/textures/items/UpgradeHover1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package li.cil.oc.client.gui | ||
|
||
import li.cil.oc.client.PacketSender | ||
import li.cil.oc.client.Textures | ||
import li.cil.oc.common.tileentity | ||
import net.minecraft.client.gui.GuiScreen | ||
import net.minecraft.client.gui.GuiTextField | ||
import net.minecraft.client.gui.ScaledResolution | ||
import org.lwjgl.input.Keyboard | ||
import org.lwjgl.opengl.GL11 | ||
|
||
class Waypoint(val waypoint: tileentity.Waypoint) extends GuiScreen { | ||
var guiLeft = 0 | ||
var guiTop = 0 | ||
var xSize = 0 | ||
var ySize = 0 | ||
|
||
var textField: GuiTextField = _ | ||
|
||
override def updateScreen(): Unit = { | ||
super.updateScreen() | ||
if (mc.thePlayer.getDistanceSq(waypoint.x + 0.5, waypoint.y + 0.5, waypoint.z + 0.5) > 64) { | ||
mc.thePlayer.closeScreen() | ||
} | ||
} | ||
|
||
override def doesGuiPauseGame(): Boolean = false | ||
|
||
override def initGui(): Unit = { | ||
super.initGui() | ||
|
||
val screenSize = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight) | ||
val guiSize = new ScaledResolution(mc, 176, 24) | ||
val (midX, midY) = (screenSize.getScaledWidth / 2, screenSize.getScaledHeight / 2) | ||
guiLeft = midX - guiSize.getScaledWidth / 2 | ||
guiTop = midY - guiSize.getScaledHeight / 2 | ||
xSize = guiSize.getScaledWidth | ||
ySize = guiSize.getScaledHeight | ||
|
||
textField = new GuiTextField(fontRendererObj, guiLeft + 7, guiTop + 8, 164 - 12, 12) | ||
textField.setMaxStringLength(32) | ||
textField.setEnableBackgroundDrawing(false) | ||
textField.setCanLoseFocus(false) | ||
textField.setFocused(true) | ||
textField.setTextColor(0xFFFFFF) | ||
textField.setText(waypoint.label) | ||
|
||
Keyboard.enableRepeatEvents(true) | ||
} | ||
|
||
override def onGuiClosed(): Unit = { | ||
super.onGuiClosed() | ||
Keyboard.enableRepeatEvents(false) | ||
} | ||
|
||
override def keyTyped(char: Char, code: Int): Unit = { | ||
if (!textField.textboxKeyTyped(char, code)) { | ||
if (code == Keyboard.KEY_RETURN) { | ||
val label = textField.getText.take(32) | ||
if (label != waypoint.label) { | ||
waypoint.label = label | ||
PacketSender.sendWaypointLabel(waypoint) | ||
} | ||
} | ||
else super.keyTyped(char, code) | ||
} | ||
} | ||
|
||
override def drawScreen(mouseX: Int, mouseY: Int, dt: Float): Unit = { | ||
super.drawScreen(mouseX, mouseY, dt) | ||
GL11.glColor3f(1, 1, 1) // Required under Linux. | ||
mc.renderEngine.bindTexture(Textures.guiWaypoint) | ||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) | ||
textField.drawTextBox() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package li.cil.oc.common.block | ||
|
||
import li.cil.oc.OpenComputers | ||
import li.cil.oc.common.GuiType | ||
import li.cil.oc.common.tileentity | ||
import net.minecraft.entity.player.EntityPlayer | ||
import net.minecraft.world.World | ||
import net.minecraftforge.common.util.ForgeDirection | ||
|
||
class Waypoint extends RedstoneAware { | ||
override protected def customTextures = Array( | ||
None, | ||
Some("WaypointTop"), | ||
Some("WaypointBack"), | ||
Some("WaypointFront"), | ||
Some("WaypointSide"), | ||
Some("WaypointSide") | ||
) | ||
|
||
// ----------------------------------------------------------------------- // | ||
|
||
override def createTileEntity(world: World, metadata: Int) = new tileentity.Waypoint() | ||
|
||
// ----------------------------------------------------------------------- // | ||
|
||
override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = { | ||
if (!player.isSneaking) { | ||
if (world.isRemote) { | ||
player.openGui(OpenComputers, GuiType.Waypoint.id, world, x, y, z) | ||
} | ||
true | ||
} | ||
else super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ) | ||
} | ||
|
||
override def getValidRotations(world: World, x: Int, y: Int, z: Int) = | ||
world.getTileEntity(x, y, z) match { | ||
case waypoint: tileentity.Waypoint => | ||
ForgeDirection.VALID_DIRECTIONS.filter { | ||
d => d != waypoint.facing && d != waypoint.facing.getOpposite | ||
} | ||
case _ => super.getValidRotations(world, x, y, z) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.