From 2bf9d66e4f9159e5828d4d4c800abd16e10f466f Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Sep 2022 02:44:34 -0500 Subject: [PATCH 1/2] initial +Fixes solars gaining power through tile entities --- src/main/java/gregtech/api/util/GTUtility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index 300d032c273..c72746519ad 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -1036,7 +1036,7 @@ public static MetaTileEntity getMetaTileEntity(ItemStack stack) { } public static boolean canSeeSunClearly(World world, BlockPos blockPos) { - if (!world.canSeeSky(blockPos.up())) { + if (!world.canSeeSky(blockPos.up()) || world.getTileEntity(blockPos.up()) != null) { return false; } Biome biome = world.getBiome(blockPos.up()); From 8ce606c557db1555a0520efd0ee1dc8f691ad5d8 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 16 Sep 2022 04:06:50 -0500 Subject: [PATCH 2/2] im a fk idiot code looks like some ass but works --- src/main/java/gregtech/api/util/GTUtility.java | 13 +++++++++++-- .../common/covers/CoverSolarPanel.java | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index c72746519ad..032fdae7b75 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -1036,9 +1036,9 @@ public static MetaTileEntity getMetaTileEntity(ItemStack stack) { } public static boolean canSeeSunClearly(World world, BlockPos blockPos) { - if (!world.canSeeSky(blockPos.up()) || world.getTileEntity(blockPos.up()) != null) { + if (!world.canSeeSky(blockPos.up()) || testTE(world,blockPos)) return false; - } + Biome biome = world.getBiome(blockPos.up()); if (world.isRaining()) { if (biome.canRain() || biome.getEnableSnow()) { @@ -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; + } } diff --git a/src/main/java/gregtech/common/covers/CoverSolarPanel.java b/src/main/java/gregtech/common/covers/CoverSolarPanel.java index bedc7303f6d..535633c603e 100644 --- a/src/main/java/gregtech/common/covers/CoverSolarPanel.java +++ b/src/main/java/gregtech/common/covers/CoverSolarPanel.java @@ -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); @@ -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); } } }