From 54f7dcc1d5cddb7581c84f84e2c01b9959fd78fc Mon Sep 17 00:00:00 2001 From: Skye Date: Mon, 19 Aug 2024 04:43:19 +0000 Subject: [PATCH 1/2] Allow for playerless block raycasts --- .../actions/raycast/OpBlockAxisRaycast.kt | 3 +-- .../casting/actions/raycast/OpBlockRaycast.kt | 4 ++-- .../hexcasting/mixin/MixinClipContext.java | 20 +++++++++++++++++++ Common/src/main/resources/hexplat.mixins.json | 1 + 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockAxisRaycast.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockAxisRaycast.kt index 6e066638d6..2aa68ecf28 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockAxisRaycast.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockAxisRaycast.kt @@ -8,12 +8,10 @@ import at.petrak.hexcasting.api.casting.getVec3 import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.casting.iota.NullIota import at.petrak.hexcasting.api.misc.MediaConstants -import net.minecraft.world.entity.Entity import net.minecraft.world.level.ClipContext import net.minecraft.world.phys.HitResult import net.minecraft.world.phys.Vec3 -@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") object OpBlockAxisRaycast : ConstMediaAction { override val argc = 2 override val mediaCost: Long = MediaConstants.DUST_UNIT / 100 @@ -29,6 +27,7 @@ object OpBlockAxisRaycast : ConstMediaAction { Action.raycastEnd(origin, look), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, + @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") env.castingEntity ) ) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockRaycast.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockRaycast.kt index 1fce74df5a..33a2e990eb 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockRaycast.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/raycast/OpBlockRaycast.kt @@ -8,7 +8,6 @@ import at.petrak.hexcasting.api.casting.getVec3 import at.petrak.hexcasting.api.casting.iota.Iota import at.petrak.hexcasting.api.casting.iota.NullIota import at.petrak.hexcasting.api.misc.MediaConstants -import net.minecraft.world.entity.Entity import net.minecraft.world.level.ClipContext import net.minecraft.world.phys.HitResult import net.minecraft.world.phys.Vec3 @@ -28,7 +27,8 @@ object OpBlockRaycast : ConstMediaAction { Action.raycastEnd(origin, look), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, - env.castingEntity as Entity + @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") + env.castingEntity ) ) diff --git a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java new file mode 100644 index 0000000000..22dadc7c9d --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java @@ -0,0 +1,20 @@ +package at.petrak.hexcasting.mixin; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.shapes.CollisionContext; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(ClipContext.class) +public class MixinClipContext { + @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/shapes/CollisionContext;of(Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/shapes/CollisionContext;")) + private CollisionContext allowNullEntity(Entity entity) { + if (entity == null) { + return CollisionContext.empty(); + } else { + return CollisionContext.of(entity); + } + } +} \ No newline at end of file diff --git a/Common/src/main/resources/hexplat.mixins.json b/Common/src/main/resources/hexplat.mixins.json index 1d2ac13000..3619793359 100644 --- a/Common/src/main/resources/hexplat.mixins.json +++ b/Common/src/main/resources/hexplat.mixins.json @@ -6,6 +6,7 @@ "package": "at.petrak.hexcasting.mixin", "mixins": [ "MixinAbstractVillager", + "MixinClipContext", "MixinMob", "MixinRaider", "MixinVillager", From 56859d8b245398ab5edd8be20a49267e78248484 Mon Sep 17 00:00:00 2001 From: object-Object Date: Tue, 20 Aug 2024 19:17:58 -0400 Subject: [PATCH 2/2] Remove unnecessary MixinClipContext mixin (see comments of #719) --- .../hexcasting/mixin/MixinClipContext.java | 20 ------------------- Common/src/main/resources/hexplat.mixins.json | 1 - 2 files changed, 21 deletions(-) delete mode 100644 Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java diff --git a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java deleted file mode 100644 index 22dadc7c9d..0000000000 --- a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinClipContext.java +++ /dev/null @@ -1,20 +0,0 @@ -package at.petrak.hexcasting.mixin; - -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.phys.shapes.CollisionContext; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ClipContext.class) -public class MixinClipContext { - @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/shapes/CollisionContext;of(Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/shapes/CollisionContext;")) - private CollisionContext allowNullEntity(Entity entity) { - if (entity == null) { - return CollisionContext.empty(); - } else { - return CollisionContext.of(entity); - } - } -} \ No newline at end of file diff --git a/Common/src/main/resources/hexplat.mixins.json b/Common/src/main/resources/hexplat.mixins.json index 3619793359..1d2ac13000 100644 --- a/Common/src/main/resources/hexplat.mixins.json +++ b/Common/src/main/resources/hexplat.mixins.json @@ -6,7 +6,6 @@ "package": "at.petrak.hexcasting.mixin", "mixins": [ "MixinAbstractVillager", - "MixinClipContext", "MixinMob", "MixinRaider", "MixinVillager",