Skip to content

Commit

Permalink
minor allocation optimization for GTUtility#canSeeSunClearly (GregTec…
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 authored Apr 4, 2024
1 parent 323d93a commit 1e98892
Showing 1 changed file with 11 additions and 7 deletions.
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

0 comments on commit 1e98892

Please sign in to comment.