feat: kick projected people from bed

https://todo.projectsegfau.lt/tasks/748
This commit is contained in:
xtex 2023-07-03 09:49:47 +08:00
parent e7ed8f44de
commit f451a4b868
Signed by: xtex
GPG Key ID: B918086ED8045B91
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package quaedam.mixin;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BedBlock;
import net.minecraft.world.phys.AABB;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import quaedam.projection.swarm.ProjectedPersonEntity;
import java.util.List;
@Mixin(BedBlock.class)
public class MixinBedBlock {
@Inject(at = @At("RETURN"), method = "kickVillagerOutOfBed(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Z", cancellable = true)
private void kickVillagerOutOfBed(Level level, BlockPos blockPos, CallbackInfoReturnable<Boolean> cir) {
if (!cir.getReturnValueZ()) {
List<ProjectedPersonEntity> list = level.getEntitiesOfClass(ProjectedPersonEntity.class, new AABB(blockPos), LivingEntity::isSleeping);
if (!list.isEmpty()) {
list.get(0).stopSleeping();
cir.setReturnValue(true);
}
}
}
}

View File

@ -7,6 +7,7 @@
"MixinClientLevel"
],
"mixins": [
"MixinBedBlock",
"MixinBuiltInRegistries"
],
"injectors": {