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

Fix solar being able to power with tile entities blocking above #1201

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions src/main/java/gregtech/api/util/GTUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,9 @@ public static MetaTileEntity getMetaTileEntity(ItemStack stack) {
}

public static boolean canSeeSunClearly(World world, BlockPos blockPos) {
if (!world.canSeeSky(blockPos.up())) {
if (!world.canSeeSky(blockPos.up()) || testTE(world,blockPos))
return false;
}

Biome biome = world.getBiome(blockPos.up());
if (world.isRaining()) {
if (biome.canRain() || biome.getEnableSnow()) {
Expand All @@ -1051,4 +1051,13 @@ public static boolean canSeeSunClearly(World world, BlockPos blockPos) {
}
return world.isDaytime();
}

public static boolean testTE(World world, BlockPos blockPos) {
for(int y = blockPos.getY(); y < 255; y++) {
if (world.getTileEntity(blockPos.up()) != null)
return true;
blockPos = blockPos.add(0, 1, 0);
}
return false;
}
}
18 changes: 14 additions & 4 deletions src/main/java/gregtech/common/covers/CoverSolarPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class CoverSolarPanel extends CoverBehavior implements ITickable {

private final long EUt;
private boolean seeSky = false;

public CoverSolarPanel(ICoverable coverHolder, EnumFacing attachedSide, long EUt) {
super(coverHolder, attachedSide);
Expand All @@ -44,10 +45,19 @@ public void renderCover(CCRenderState renderState, Matrix4 translation, IVertexO
public void update() {
World world = coverHolder.getWorld();
BlockPos blockPos = coverHolder.getPos();
if (GTUtility.canSeeSunClearly(world, blockPos)) {
IEnergyContainer energyContainer = coverHolder.getCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, null);
if (energyContainer != null) {
energyContainer.acceptEnergyFromNetwork(null, EUt, 1);

IEnergyContainer energyContainer = coverHolder.getCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, null);

if (!this.seeSky && coverHolder.getOffsetTimer() % 100 == 0) {
this.seeSky = GTUtility.canSeeSunClearly(world, blockPos);
}

if (this.seeSky) {
if (coverHolder.getOffsetTimer() % 100 == 0)
this.seeSky = GTUtility.canSeeSunClearly(world, blockPos);
if (this.seeSky) {
if (energyContainer != null)
energyContainer.acceptEnergyFromNetwork(null, EUt, 1);
}
}
}
Expand Down