@@ -35,6 +35,9 @@ import net.minecraft.entity.Entity
3535import net.minecraft.item.ItemPlacementContext
3636import net.minecraft.item.ItemStack
3737import net.minecraft.util.math.BlockPos
38+ import net.minecraft.util.math.Box
39+ import net.minecraft.util.math.Direction
40+ import net.minecraft.util.math.Vec3d
3841import java.awt.Color
3942
4043/* *
@@ -83,7 +86,13 @@ sealed class PlaceResult : BuildResult() {
8386 private val color = Color (252 , 3 , 3 , 100 )
8487
8588 override fun ShapeBuilder.buildRenderer () {
86- box(pos, expected, color, color)
89+ val box = with (simulated.hitPos) {
90+ Box (
91+ x - 0.05 , y - 0.05 , z - 0.05 ,
92+ x + 0.05 , y + 0.05 , z + 0.05 ,
93+ ).offset(simulated.side.doubleVector.multiply(0.05 ))
94+ }
95+ box(box, color, color)
8796 }
8897 }
8998
@@ -94,30 +103,33 @@ sealed class PlaceResult : BuildResult() {
94103 */
95104 data class BlockedBySelf (
96105 override val pos : BlockPos
97- ) : Drawable, Navigable, PlaceResult() {
106+ ) : Navigable, PlaceResult() {
98107 override val rank = Rank .PlaceBlockedByPlayer
99- private val color = Color (252 , 3 , 3 , 100 )
100108 override val goal = GoalInverted (GoalBlock (pos))
101-
102- override fun ShapeBuilder.buildRenderer () {
103- box(pos, color, color)
104- }
105109 }
106110
107111 /* *
108- * Represents a scenario where block placement is obstructed by an entity.
112+ * Represents a scenario where the block placement is obstructed by an entity.
109113 *
110114 * @property pos The position of the block that was attempted to be placed.
111115 */
112116 data class BlockedByEntity (
113117 override val pos : BlockPos ,
114- val entities : List <Entity >
118+ val entities : List <Entity >,
119+ val hitPos : Vec3d ,
120+ val side : Direction
115121 ) : Drawable, PlaceResult() {
116122 override val rank = Rank .PlaceBlockedByEntity
117123 private val color = Color (252 , 3 , 3 , 100 )
118124
119125 override fun ShapeBuilder.buildRenderer () {
120- entities.forEach { box(it, color) }
126+ val box = with (hitPos) {
127+ Box (
128+ x - 0.05 , y - 0.05 , z - 0.05 ,
129+ x + 0.05 , y + 0.05 , z + 0.05 ,
130+ ).offset(side.doubleVector.multiply(0.05 ))
131+ }
132+ box(box, color, color)
121133 }
122134 }
123135
@@ -141,7 +153,6 @@ sealed class PlaceResult : BuildResult() {
141153 * Represents a placement result indicating that the scaffolding placement has exceeded the allowed limits.
142154 *
143155 * @property pos The position of the block where the placement attempt occurred.
144- * @property simulated The context of the simulated item placement attempt.
145156 */
146157 data class ScaffoldExceeded (
147158 override val pos : BlockPos
0 commit comments