diff --git a/TODO b/TODO
index c833230..c0516a2 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,10 @@
-* identify and pair portals by type/color
+* automatically open the door of a portal that is freshly activated
* save portal pairs to disk and reload them on restarting the server
-* deactivate most recently placed portal and replace with newly placed one when 3+ portals are created
* teleport from one to the other a set time after entering a teleportation chamber and closing the door
* automatically open the door after effects wear off
* close the door on the other side when someone shuts the door
* teleport everyone inside the portal, not just the person who closed the door
* interrupt teleportation if portal is destroyed mid-teleportation
+* cancel teleportation if someone moves out of the teleporter during teleportation (maybe prevent them from starting?)
* save any effects that would be overwritten by teleportation (including to disk!), and put them back when the player opens the door or arrives
* add portal particles and ambient sounds to the teleporter when portals are paired
\ No newline at end of file
diff --git a/minecraftportal.iml b/minecraftportal.iml
new file mode 100644
index 0000000..0ad4884
--- /dev/null
+++ b/minecraftportal.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt b/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt
index 4c9379e..0a40b41 100644
--- a/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt
+++ b/src/main/kotlin/net/deliciousreya/minecraftportal/MinecraftPortalPlugin.kt
@@ -25,7 +25,6 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener
override fun onEnable() {
super.onEnable()
- logger.info("Loaded the portal plugin!")
server.pluginManager.registerEvents(this, this)
}
@@ -37,12 +36,9 @@ class MinecraftPortalPlugin() : JavaPlugin(), Listener
PortalFrame.State.INACTIVE
)
if (newPortal != null) {
- logger.info("found portal frame, creating portal")
val replacedPortal = portals.activateAndReplacePortal(newPortal)
newPortal.activate()
replacedPortal?.deactivate()
- } else {
- logger.info("no portal frame found matching placed block, ignoring")
}
}
}
diff --git a/src/main/kotlin/net/deliciousreya/minecraftportal/extensions/Vector.kt b/src/main/kotlin/net/deliciousreya/minecraftportal/extensions/Vector.kt
index d5ac17a..2a47e13 100644
--- a/src/main/kotlin/net/deliciousreya/minecraftportal/extensions/Vector.kt
+++ b/src/main/kotlin/net/deliciousreya/minecraftportal/extensions/Vector.kt
@@ -4,6 +4,7 @@ import org.bukkit.util.Vector
val ZERO = Vector(0, 0, 0)
val UP = Vector(0, 1, 0)
+val MID_BLOCK = Vector(0.5, 0.5, 0.5)
operator fun Vector.plus(v:Vector):Vector {
return this.clone().add(v)
diff --git a/src/main/kotlin/net/deliciousreya/minecraftportal/model/PortalFrame.kt b/src/main/kotlin/net/deliciousreya/minecraftportal/model/PortalFrame.kt
index 0a4e28d..2b2750e 100644
--- a/src/main/kotlin/net/deliciousreya/minecraftportal/model/PortalFrame.kt
+++ b/src/main/kotlin/net/deliciousreya/minecraftportal/model/PortalFrame.kt
@@ -13,7 +13,9 @@ import org.bukkit.Material.*
import org.bukkit.Particle
import org.bukkit.Sound
import org.bukkit.block.BlockFace
-import org.bukkit.material.Directional
+import org.bukkit.block.data.Directional
+import org.bukkit.block.data.Openable
+import org.bukkit.block.data.type.Door
val MINERAL_TYPES: ImmutableMap = ImmutableMap.Builder()
.put(COAL_BLOCK, BLACK_STAINED_GLASS)
@@ -82,7 +84,8 @@ fun checkPortalFrameAt(location:Location, direction: PortalFrame.EntranceDirecti
}
for (vector in direction.doorOffsets) {
val block = (location + vector).block
- if (block.type !in state.doorBlocks || (block.blockData is Directional && (block.blockData as Directional).facing != direction.doorDirection)) {
+ val door = block.blockData
+ if (block.type !in state.doorBlocks || (door is Directional && door.facing != direction.doorDirection)) {
return null
}
}
@@ -110,10 +113,10 @@ data class PortalFrame(val lowerLeftFrontCorner: Location, val direction: Entran
}
/** The direction along which a portal frame extends. */
enum class EntranceDirection(toRight: Vector, toBack: Vector, val doorDirection: BlockFace, val protoEnum: PortalSaveDataProtos.Portal.Direction) {
- NORTH(Vector(1, 0, 0), Vector(0, 0, 1), BlockFace.NORTH, PortalSaveDataProtos.Portal.Direction.NORTH),
- SOUTH(Vector(1, 0, 0), Vector(0, 0, -1), BlockFace.SOUTH, PortalSaveDataProtos.Portal.Direction.SOUTH),
- EAST(Vector(0, 0, 1), Vector(-1, 0, 0), BlockFace.EAST, PortalSaveDataProtos.Portal.Direction.EAST),
- WEST(Vector(0, 0, 1), Vector(1, 0, 0), BlockFace.WEST, PortalSaveDataProtos.Portal.Direction.WEST);
+ NORTH(Vector(1, 0, 0), Vector(0, 0, 1), BlockFace.SOUTH, PortalSaveDataProtos.Portal.Direction.NORTH),
+ SOUTH(Vector(1, 0, 0), Vector(0, 0, -1), BlockFace.NORTH, PortalSaveDataProtos.Portal.Direction.SOUTH),
+ EAST(Vector(0, 0, 1), Vector(-1, 0, 0), BlockFace.WEST, PortalSaveDataProtos.Portal.Direction.EAST),
+ WEST(Vector(0, 0, 1), Vector(1, 0, 0), BlockFace.EAST, PortalSaveDataProtos.Portal.Direction.WEST);
val glassOffsets: ImmutableList = ImmutableList.of(
// check corners first:
@@ -178,20 +181,41 @@ data class PortalFrame(val lowerLeftFrontCorner: Location, val direction: Entran
val mineral = (lowerLeftFrontCorner + direction.mineralOffset).block.type
+ fun open() {
+ val block = portalCenter.block
+ val data = block.blockData
+ if (data is Openable) {
+ data.isOpen = true
+ block.blockData = data
+ }
+ }
+
+ fun close() {
+ val block = portalCenter.block
+ val data = block.blockData
+ if (data is Openable) {
+ data.isOpen = false
+ block.blockData = data
+ }
+ }
+
fun activate() {
val mineral = (lowerLeftFrontCorner + direction.mineralOffset).block
for (offset in direction.glassOffsets) {
(lowerLeftFrontCorner + offset).block.type = MINERAL_TYPES.getOrDefault(mineral.type, BROWN_STAINED_GLASS)
}
- portalCenter.world?.playSound(portalCenter, Sound.BLOCK_BEACON_ACTIVATE, 20f, 1f)
- portalCenter.world?.spawnParticle(Particle.SPELL, portalCenter, 40)
+ val midCenter = portalCenter + MID_BLOCK
+ portalCenter.world?.playSound(midCenter, Sound.BLOCK_BEACON_ACTIVATE, 20f, 1f)
+ portalCenter.world?.spawnParticle(Particle.SPELL, midCenter, 75)
+ open()
}
fun deactivate() {
for (offset in direction.glassOffsets) {
(lowerLeftFrontCorner + offset).block.type = GLASS
}
- portalCenter.world?.playSound(portalCenter, Sound.BLOCK_BEACON_DEACTIVATE, 20f, 1f)
- portalCenter.world?.spawnParticle(Particle.SMOKE_NORMAL, portalCenter, 40)
+ val midCenter = portalCenter + MID_BLOCK
+ portalCenter.world?.playSound(midCenter, Sound.BLOCK_BEACON_DEACTIVATE, 20f, 1f)
+ portalCenter.world?.spawnParticle(Particle.SMOKE_NORMAL, midCenter, 75)
}
}
\ No newline at end of file