Skip to content

Commit 78c943f

Browse files
committed
Merge branch 'master' into add-pylon-guide
2 parents 013901b + 94005ce commit 78c943f

4 files changed

Lines changed: 7 additions & 26 deletions

File tree

pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockListener.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import io.papermc.paper.event.player.PlayerLecternPageChangeEvent
1616
import io.papermc.paper.event.player.PlayerOpenSignEvent
1717
import org.bukkit.GameMode
1818
import org.bukkit.Material
19-
import org.bukkit.block.BlockFace
2019
import org.bukkit.event.EventHandler
2120
import org.bukkit.event.EventPriority
2221
import org.bukkit.event.Listener
@@ -50,10 +49,7 @@ internal object BlockListener : Listener {
5049
val player = event.player
5150

5251
val pylonItem = PylonItem.fromStack(item)
53-
val relative = event.blockPlaced.position - event.blockAgainst.position
54-
val blockFace = BlockFace.entries.find { it.modX == relative.x && it.modY == relative.y && it.modZ == relative.z }
55-
?: BlockFace.SELF
56-
val pylonBlock = pylonItem?.place(BlockCreateContext.PlayerPlace(player, item, event.blockPlaced, blockFace))
52+
val pylonBlock = pylonItem?.place(BlockCreateContext.PlayerPlace(player, item, event))
5753

5854
if (pylonItem != null && pylonBlock == null) {
5955
event.isCancelled = true
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.github.pylonmc.pylon.core.block.context
22

33
import org.bukkit.block.Block
4-
import org.bukkit.block.BlockFace
54
import org.bukkit.entity.Player
5+
import org.bukkit.event.block.BlockPlaceEvent
66
import org.bukkit.inventory.ItemStack
77

88
interface BlockCreateContext {
@@ -12,9 +12,10 @@ interface BlockCreateContext {
1212
data class PlayerPlace(
1313
val player: Player,
1414
val item: ItemStack,
15-
override val block: Block,
16-
val clickedFace: BlockFace
17-
) : BlockCreateContext
15+
val event: BlockPlaceEvent
16+
) : BlockCreateContext {
17+
override val block = event.blockPlaced
18+
}
1819

1920
data class Default(override val block: Block) : BlockCreateContext
2021
}

pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/util/ItemUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ inline fun <reified T> ItemStack?.isPylonAndIsNot(): Boolean {
5555
return pylonItem != null && pylonItem !is T
5656
}
5757

58+
@JvmName("recipeChoiceFromItem")
5859
fun ItemStack.asRecipeChoice(): RecipeChoice {
5960
return if (PylonItem.isPylonItem(this)) {
6061
RecipeChoice.ExactChoice(this)

pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/util/PylonUtils.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ package io.github.pylonmc.pylon.core.util
44

55
import io.github.pylonmc.pylon.core.addon.PylonAddon
66
import io.github.pylonmc.pylon.core.entity.display.transform.TransformUtil.yawToCardinalDirection
7-
import net.kyori.adventure.text.Component
8-
import org.bukkit.Color
9-
import org.bukkit.Location
107
import org.bukkit.NamespacedKey
118
import org.bukkit.block.BlockFace
129
import org.bukkit.entity.Player
13-
import org.bukkit.entity.TextDisplay
1410
import org.bukkit.util.Vector
15-
import org.joml.Matrix4f
1611
import org.joml.RoundingMode
1712
import org.joml.Vector3f
1813
import org.joml.Vector3i
@@ -58,16 +53,4 @@ fun rotateToPlayerFacing(player: Player, face: BlockFace, allowVertical: Boolean
5853
vector = vector.rotateAroundNonUnitAxis(rightVector, -yawToCardinalDirection(player.eyeLocation.pitch).toDouble())
5954
}
6055
return vectorToBlockFace(vector)
61-
}
62-
63-
fun spawnUnitSquareTextDisplay(location: Location, color: Color): TextDisplay {
64-
val display = location.world!!.spawn(location, TextDisplay::class.java)
65-
display.setTransformationMatrix( // https://github.com/TheCymaera/minecraft-hologram/blob/d67eb43308df61bdfe7283c6821312cca5f9dea9/src/main/java/com/heledron/hologram/utilities/rendering/textDisplays.kt#L15
66-
Matrix4f()
67-
.translate(-0.1f + .5f, -0.5f + .5f, 0f)
68-
.scale(8.0f, 4.0f, 1f)
69-
)
70-
display.text(Component.text(" "))
71-
display.backgroundColor = color
72-
return display
7356
}

0 commit comments

Comments
 (0)