Skip to content

Commit e57a611

Browse files
committed
Simple jesus
1 parent 47929ff commit e57a611

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.lambda.mixin.world;
2+
3+
import com.google.common.collect.AbstractIterator;
4+
import com.lambda.event.EventFlow;
5+
import com.lambda.event.events.WorldEvent;
6+
import net.minecraft.block.BlockState;
7+
import net.minecraft.block.ShapeContext;
8+
import net.minecraft.util.math.BlockPos;
9+
import net.minecraft.util.shape.VoxelShape;
10+
import net.minecraft.world.BlockCollisionSpliterator;
11+
import net.minecraft.world.BlockView;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.injection.At;
14+
import org.spongepowered.asm.mixin.injection.Redirect;
15+
16+
@Mixin(BlockCollisionSpliterator.class)
17+
public abstract class BlockCollisionSpliteratorMixin <T extends AbstractIterator<T>> {
18+
@Redirect(method = "computeNext", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;"))
19+
private VoxelShape collisionShapeRedirect(BlockState instance, BlockView blockView, BlockPos blockPos, ShapeContext shapeContext) {
20+
VoxelShape collisionShape = instance.getCollisionShape(blockView, blockPos, shapeContext);
21+
WorldEvent.Collision event = EventFlow.post(new WorldEvent.Collision(blockPos, instance, collisionShape));
22+
return event.getShape();
23+
}
24+
}

common/src/main/kotlin/com/lambda/event/events/WorldEvent.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import net.minecraft.block.BlockState
77
import net.minecraft.client.world.ClientWorld
88
import net.minecraft.entity.Entity
99
import net.minecraft.util.math.BlockPos
10+
import net.minecraft.util.shape.VoxelShape
1011
import net.minecraft.world.chunk.WorldChunk
1112

1213
abstract class WorldEvent : Event {
@@ -34,4 +35,6 @@ abstract class WorldEvent : Event {
3435
class EntitySpawn(
3536
val entity: Entity
3637
) : WorldEvent(), ICancellable by Cancellable()
38+
39+
class Collision(val pos: BlockPos, val state: BlockState, var shape: VoxelShape) : WorldEvent()
3740
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.lambda.module.modules.movement
2+
3+
import com.lambda.event.events.WorldEvent
4+
import com.lambda.event.listener.SafeListener.Companion.listener
5+
import com.lambda.module.Module
6+
import com.lambda.module.tag.ModuleTag
7+
import net.minecraft.block.Blocks
8+
import net.minecraft.util.shape.VoxelShapes
9+
10+
object Jesus : Module(
11+
name = "Jesus",
12+
description = "Allows to walk on water",
13+
defaultTags = setOf(ModuleTag.MOVEMENT)
14+
) {
15+
private val waterState by lazy { Blocks.WATER.defaultState }
16+
private val fullShape = VoxelShapes.fullCube()
17+
18+
init {
19+
listener<WorldEvent.Collision> { event ->
20+
if (event.state == waterState) {
21+
event.shape = fullShape
22+
}
23+
}
24+
}
25+
}

common/src/main/resources/lambda.mixins.common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"render.ScreenHandlerMixin",
3434
"render.VertexBufferMixin",
3535
"render.WorldRendererMixin",
36+
"world.BlockCollisionSpliteratorMixin",
3637
"world.ClientChunkManagerMixin",
3738
"world.ClientWorldMixin"
3839
],

0 commit comments

Comments
 (0)