This commit is contained in:
paulevsGitch 2021-11-20 19:01:43 +03:00
parent 8ea432bc19
commit c0b7ccca72
3 changed files with 22 additions and 27 deletions

View file

@ -12,29 +12,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LayerLightSectionStorage.class)
public class LayerLightSectionStorageMixin {
@Shadow
protected DataLayer getDataLayer(long sectionPos, boolean cached) {
return null;
}
@Inject(method = "getStoredLevel", at = @At(value = "HEAD"), cancellable = true)
private void lightFix(long blockPos, CallbackInfoReturnable<Integer> info) {
try {
long m = SectionPos.blockToSection(blockPos);
DataLayer dataLayer = this.getDataLayer(m, true);
info.setReturnValue(
dataLayer.get(
SectionPos.sectionRelative(BlockPos.getX(blockPos)),
SectionPos.sectionRelative(BlockPos.getY(blockPos)),
SectionPos.sectionRelative(BlockPos.getZ(blockPos))
)
);
info.cancel();
} catch (Exception e) {
info.setReturnValue(0);
info.cancel();
}
}
@Shadow
protected DataLayer getDataLayer(long sectionPos, boolean cached) {
return null;
}
@Inject(method = "getStoredLevel", at = @At(value = "HEAD"), cancellable = true)
private void bclib_lightFix(long blockPos, CallbackInfoReturnable<Integer> info) {
try {
long pos = SectionPos.blockToSection(blockPos);
DataLayer dataLayer = this.getDataLayer(pos, true);
info.setReturnValue(dataLayer.get(
SectionPos.sectionRelative(BlockPos.getX(blockPos)),
SectionPos.sectionRelative(BlockPos.getY(blockPos)),
SectionPos.sectionRelative(BlockPos.getZ(blockPos))
));
}
catch (Exception e) {
info.setReturnValue(0);
}
}
}

View file

@ -26,7 +26,7 @@ public class SimpleReloadableResourceManagerMixin {
};
@Inject(method = "hasResource", at = @At("HEAD"), cancellable = true)
private void hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
if (resourceLocation.getNamespace().equals("minecraft")) {
for (String key: BCLIB_MISSING_RESOURCES) {
if (resourceLocation.getPath().equals(key)) {

View file

@ -6,6 +6,7 @@
"mixins": [
"SimpleReloadableResourceManagerMixin",
"shears.DiggingEnchantmentMixin",
"LayerLightSectionStorageMixin",
"shears.TripWireBlockMixin",
"ChunkBiomeContainerMixin",
"shears.BeehiveBlockMixin",
@ -20,7 +21,6 @@
"MinecraftServerMixin",
"PistonBaseBlockMixin",
"WorldGenRegionMixin",
"LayerLightSectionStorageMixin",
"DimensionTypeMixin",
"RecipeManagerMixin",
"CraftingMenuMixin",