mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-10 14:26:10 +01:00
31 lines
815 B
Java
31 lines
815 B
Java
|
package com.jozufozu.flywheel.light;
|
||
|
|
||
|
import java.util.Map;
|
||
|
import java.util.WeakHashMap;
|
||
|
|
||
|
import net.minecraft.util.math.BlockPos;
|
||
|
import net.minecraft.world.IBlockDisplayReader;
|
||
|
import net.minecraft.world.LightType;
|
||
|
|
||
|
public class BasicProvider implements LightProvider {
|
||
|
|
||
|
private static final Map<IBlockDisplayReader, BasicProvider> wrappers = new WeakHashMap<>();
|
||
|
|
||
|
public static BasicProvider get(IBlockDisplayReader world) {
|
||
|
return wrappers.computeIfAbsent(world, BasicProvider::new);
|
||
|
}
|
||
|
|
||
|
private final BlockPos.Mutable pos = new BlockPos.Mutable();
|
||
|
|
||
|
private final IBlockDisplayReader reader;
|
||
|
|
||
|
public BasicProvider(IBlockDisplayReader reader) {
|
||
|
this.reader = reader;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public int getLight(LightType type, int x, int y, int z) {
|
||
|
return reader.getBrightness(type, pos.set(x, y, z));
|
||
|
}
|
||
|
}
|