-
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.
- Loading branch information
1 parent
e2ea001
commit 3269f93
Showing
9 changed files
with
104 additions
and
40 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
src/main/kotlin/com/fardragi/nyaruko/core/events/PlayerMoveEvent.kt
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.fardragi.nyaruko.core.events | ||
|
||
import com.fardragi.nyaruko.shared.NyarukoEvent | ||
import com.fardragi.nyaruko.viewmodels.PlayerPositionViewModel | ||
import com.fardragi.nyaruko.viewmodels.PositionViewModel | ||
import cpw.mods.fml.common.eventhandler.Cancelable | ||
import net.minecraft.entity.player.EntityPlayerMP | ||
|
||
@Cancelable | ||
data class PlayerMoveEvent( | ||
val player: EntityPlayerMP, | ||
val old: PlayerPositionViewModel, | ||
val new: PlayerPositionViewModel | ||
val old: PositionViewModel, | ||
val new: PositionViewModel | ||
) : NyarukoEvent() { | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/com/fardragi/nyaruko/extensions/EntityPlayer.kt
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 com.fardragi.nyaruko.extensions | ||
|
||
import com.fardragi.nyaruko.utils.NyarukoTeleporter | ||
import com.fardragi.nyaruko.viewmodels.PositionViewModel | ||
import net.minecraft.entity.player.EntityPlayer | ||
import net.minecraft.entity.player.EntityPlayerMP | ||
import net.minecraft.server.MinecraftServer | ||
|
||
fun EntityPlayer.teleport(position: PositionViewModel) { | ||
val server = MinecraftServer.getServer() | ||
|
||
if (dimension == position.dimension) { | ||
setLocationAndAngles( | ||
position.positionX, | ||
position.positionY, | ||
position.positionZ, | ||
position.rotationYaw, | ||
position.rotationPitch | ||
) | ||
setPositionAndUpdate( | ||
position.positionX, | ||
position.positionY, | ||
position.positionZ, | ||
) | ||
return | ||
} | ||
|
||
if (isRiding) { | ||
dismountEntity(ridingEntity) | ||
} | ||
|
||
val newWorld = server.worldServerForDimension(position.dimension) | ||
|
||
server.configurationManager.transferPlayerToDimension( | ||
this as EntityPlayerMP, position.dimension, NyarukoTeleporter( | ||
newWorld, | ||
position.positionX, | ||
position.positionY, | ||
position.positionZ, | ||
position.rotationYaw, | ||
position.rotationPitch | ||
) | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -29,5 +29,3 @@ class User(id: EntityID<UUID>) : Entity<UUID>(id) { | |
) | ||
} | ||
} | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/com/fardragi/nyaruko/utils/NyarukoTeleporter.kt
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,29 @@ | ||
package com.fardragi.nyaruko.utils | ||
|
||
import net.minecraft.entity.Entity | ||
import net.minecraft.world.Teleporter | ||
import net.minecraft.world.WorldServer | ||
|
||
class NyarukoTeleporter( | ||
worldIn: WorldServer, | ||
private val positionX: Double, | ||
private val positionY: Double, | ||
private val positionZ: Double, | ||
private val yaw: Float, | ||
private val pitch: Float | ||
) : | ||
Teleporter(worldIn) { | ||
override fun placeInPortal(entity: Entity, x: Double, y: Double, z: Double, r: Float) { | ||
entity.setLocationAndAngles(positionX, positionY, positionZ, yaw, pitch) | ||
} | ||
|
||
override fun placeInExistingPortal( | ||
par1Entity: Entity?, | ||
par2: Double, | ||
par4: Double, | ||
par6: Double, | ||
par8: Float | ||
): Boolean { | ||
return false | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/fardragi/nyaruko/viewmodels/BlockViewModel.kt
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.fardragi.nyaruko.viewmodels | ||
|
||
data class BlockViewModel(val x: Int, val y: Int, val z: Int) { | ||
data class BlockViewModel(val dimension: Int, val x: Int, val y: Int, val z: Int) { | ||
} |
14 changes: 0 additions & 14 deletions
14
src/main/kotlin/com/fardragi/nyaruko/viewmodels/PlayerPositionViewModel.kt
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/fardragi/nyaruko/viewmodels/PositionViewModel.kt
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,21 @@ | ||
package com.fardragi.nyaruko.viewmodels | ||
|
||
import net.minecraft.entity.Entity | ||
import kotlin.math.floor | ||
|
||
data class PositionViewModel(val player: Entity) { | ||
val dimension = player.dimension | ||
val positionX = player.posX | ||
val positionY = player.posY | ||
val positionZ = player.posZ | ||
val rotationYaw = player.rotationYaw | ||
val rotationPitch = player.rotationPitch | ||
|
||
val block | ||
get() = BlockViewModel( | ||
dimension, | ||
floor(positionX).toInt(), | ||
floor(positionY).toInt(), | ||
floor(positionZ).toInt() | ||
) | ||
} |