Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
1package net.lerariemann.infinity.mixin.fixes;
2
3import net.lerariemann.infinity.entity.custom.AntEntity;
4import net.minecraft.core.BlockPos;
5import net.minecraft.tags.FluidTags;
6import net.minecraft.world.level.BlockGetter;
7import net.minecraft.world.level.block.state.BlockBehaviour;
8import net.minecraft.world.level.material.FluidState;
9import net.minecraft.world.phys.shapes.CollisionContext;
10import net.minecraft.world.phys.shapes.Shapes;
11import net.minecraft.world.phys.shapes.VoxelShape;
12import org.spongepowered.asm.mixin.Mixin;
13import org.spongepowered.asm.mixin.injection.At;
14import org.spongepowered.asm.mixin.injection.Inject;
15import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
16
17@Mixin(BlockBehaviour.BlockStateBase.class)
18public class ColllisionShapeMixin {
19 @Inject(method = "getCollisionShape(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/shapes/CollisionContext;)Lnet/minecraft/world/phys/shapes/VoxelShape;",
20 at = @At("RETURN"), cancellable = true)
21 private void antsStandOnWater(BlockGetter world, BlockPos pos, CollisionContext context, CallbackInfoReturnable<VoxelShape> cir) {
22 //? if >1.21.3 {
23 try {
24 //?}
25 FluidState fluidState = world.getFluidState(pos);
26 if (!fluidState.is(FluidTags.WATER)) return;
27 int level = fluidState.getAmount();
28 if (level == 0) return;
29 int trueLevel = 2 * (level - 1) + 1;
30 if (context.isAbove(AntEntity.getWaterCollisionShape(trueLevel - 1), pos, true)
31 && context.canStandOnFluid(world.getFluidState(pos.above()), fluidState)) {
32 cir.setReturnValue(Shapes.or(cir.getReturnValue(), AntEntity.getWaterCollisionShape(trueLevel)));
33 }
34 //? if >1.21.3 {
35 } catch (Exception ignored) {}
36 //?}
37 }
38}