Commit bfb88a55 authored by SilverDavid's avatar SilverDavid
Browse files

Moved IBlockReader mixin

parent f253d4e7
......@@ -37,13 +37,13 @@ public class DynamicLightingManager
{
SOURCES.forEach((blockPos, data) -> data.shouldStay = false);
MC.level.getEntitiesOfClass(LivingEntity.class, MC.player.getBoundingBox().inflate(MiningHelmetConfig.maxVisibleDistance()), DynamicLightingManager::shouldGlow).forEach(e ->
{
SOURCES.put(e.blockPosition().above((int) e.getEyeHeight()), new LightData());
});
MC.level.getEntitiesOfClass(LivingEntity.class, MC.player.getBoundingBox().inflate(MiningHelmetConfig.maxVisibleDistance()), DynamicLightingManager::shouldGlow).forEach(e -> SOURCES.put(e.blockPosition().above((int) e.getEyeHeight()), new LightData()));
SOURCES.forEach((blockPos, data) -> MC.level.getChunkSource().getLightEngine().checkBlock(blockPos));
SOURCES.entrySet().removeIf(entry -> !entry.getValue().shouldStay);
if (!SOURCES.isEmpty())
{
SOURCES.forEach((blockPos, data) -> MC.level.getChunkSource().getLightEngine().checkBlock(blockPos));
SOURCES.entrySet().removeIf(entry -> !entry.getValue().shouldStay);
}
}
}
......
package com.legacy.mining_helmet.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.legacy.mining_helmet.MiningHelmetConfig;
import com.legacy.mining_helmet.client.DynamicLightingManager;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.lighting.BlockLightEngine;
@Mixin(IBlockReader.class)
public interface IBlockReaderMixin
@Mixin(BlockLightEngine.class)
public class BlockLightEngineMixin
{
@Overwrite
default int getLightEmission(BlockPos pos)
@Inject(at = @At(value = "RETURN"), method = "getLightEmission(J)I", cancellable = true)
private void modifyLightValue(long longPos, CallbackInfoReturnable<Integer> callback)
{
BlockPos pos = BlockPos.of(longPos);
if (DynamicLightingManager.SOURCES.containsKey(pos) && DynamicLightingManager.SOURCES.get(pos).shouldStay)
return MiningHelmetConfig.getHelmetLightLevel();
return this.getBlockState(pos).getLightValue((IBlockReader) (Object) this, pos);
callback.setReturnValue(MiningHelmetConfig.getHelmetLightLevel());
}
@Shadow
BlockState getBlockState(BlockPos pos);
}
\ No newline at end of file
}
......@@ -6,7 +6,7 @@
"mixins": [
],
"client": [
"IBlockReaderMixin",
"BlockLightEngineMixin",
"MinecraftMixin"
],
"injectors": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment