Skip to content

Commit

Permalink
Allow for playerless block raycasts
Browse files Browse the repository at this point in the history
  • Loading branch information
vgskye authored and Master-Bw3 committed Aug 29, 2024
1 parent 0f2e7a3 commit aa46643
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "<init>", 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);
}
}
}
1 change: 1 addition & 0 deletions Common/src/main/resources/hexplat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"package": "at.petrak.hexcasting.mixin",
"mixins": [
"MixinAbstractVillager",
"MixinClipContext",
"MixinMob",
"MixinRaider",
"MixinVillager",
Expand Down

0 comments on commit aa46643

Please sign in to comment.