Optimize villager bed chunk loads (#719)

This commit is contained in:
IzzelAliz 2022-09-11 21:41:14 +08:00
parent 44e5c725c0
commit 8f9d1b76cc
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
3 changed files with 25 additions and 1 deletions

View File

@ -7,7 +7,7 @@ A Bukkit server implementation utilizing Mixin.
| Minecraft | Forge | Status | Build |
|:---------:|:-------:| :---: |:------------------------------------------------------------------------------------------------------------------------------------------------------:|
| 1.19.x | 43.1.3 | ACTIVE | [![1.19 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-19?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-19) |
| 1.18.x | 40.1.76 | ACTIVE | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) |
| 1.18.x | 40.1.80 | ACTIVE | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) |
| 1.17.x | 37.1.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.17/1.0.2) | [![1.17 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-17?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-17) |
| 1.16.x | 36.2.39 | ACTIVE | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) |
| 1.15.x | 31.2.48 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.15/1.0.19) | [![1.15 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-15?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-15) |

View File

@ -0,0 +1,23 @@
package io.izzel.arclight.common.mixin.optimization.general.chunkload;
import net.minecraft.core.GlobalPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.behavior.SleepInBed;
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(SleepInBed.class)
public class SleepInBedMixin_Optimize {
@Inject(method = "checkExtraStartConditions",cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
private void arclight$returnIfNotLoaded(ServerLevel level, LivingEntity entity, CallbackInfoReturnable<Boolean> cir, Brain<?> brain, GlobalPos pos) {
if (!level.isLoaded(pos.pos())) {
cir.setReturnValue(false);
}
}
}

View File

@ -22,6 +22,7 @@
"activationrange.entity.ItemEntityMixin_ActivationRange",
"activationrange.entity.LivingEntityMixin_ActivationRange",
"activationrange.entity.VillagerEntityMixin_ActivationRange",
"chunkload.SleepInBedMixin_Optimize",
"network.ChunkMapMixin_Optimize",
"network.ChunkMapMixin_Optimize$TrackedEntityMixin",
"network.ConnectionMixin_Optimize",