Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor allocation optimization for GTUtility#canSeeSunClearly #2441

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/main/java/gregtech/api/util/GTUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -707,15 +707,19 @@ public static MetaTileEntity getMetaTileEntity(ItemStack stack) {
return GregTechAPI.MTE_REGISTRY.getObjectById(stack.getItemDamage());
}

public static boolean canSeeSunClearly(World world, BlockPos blockPos) {
if (!world.canSeeSky(blockPos.up())) {
/**
* @param world the world containing the block
* @param blockPos the position of the block to check
* @return if the block can see the sun clearly
*/
public static boolean canSeeSunClearly(@NotNull World world, @NotNull BlockPos blockPos) {
BlockPos up = blockPos.up();
if (!world.canSeeSky(up)) {
return false;
}
Biome biome = world.getBiome(blockPos.up());
if (world.isRaining()) {
if (biome.canRain() || biome.getEnableSnow()) {
return false;
}
Biome biome = world.getBiome(up);
if (world.isRaining() && (biome.canRain() || biome.getEnableSnow())) {
return false;
}
Set<BiomeDictionary.Type> biomeTypes = BiomeDictionary.getTypes(biome);
if (biomeTypes.contains(BiomeDictionary.Type.END)) {
Expand Down
Loading