From 2563a85a58370ff5e0555922101667baef5f5714 Mon Sep 17 00:00:00 2001 From: Magic_Sweepy Date: Wed, 25 Mar 2026 11:59:08 +0800 Subject: [PATCH 1/2] render water when ore washer structure formed --- .../advanced/MultiblockOreWasher.kt | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt b/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt index 3f68b04fa..20a1857c4 100644 --- a/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt +++ b/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt @@ -20,6 +20,7 @@ import gregtech.api.recipes.properties.RecipePropertyStorage import gregtech.api.util.GTUtility.getTierByVoltage import gregtech.client.renderer.ICubeRenderer import gregtechlite.gtlitecore.api.GTLiteAPI.PUMP_CASING_TIER +import gregtechlite.gtlitecore.api.GTLiteLog import gregtechlite.gtlitecore.api.metatileentity.multiblock.MultiblockTooltipBuilder.Companion.addTooltip import gregtechlite.gtlitecore.api.metatileentity.multiblock.OverclockMode import gregtechlite.gtlitecore.api.metatileentity.multiblock.UpgradeMode @@ -29,8 +30,11 @@ import gregtechlite.gtlitecore.api.recipe.GTLiteRecipeMaps.CATALYTIC_REFORMER_RE import gregtechlite.gtlitecore.client.renderer.texture.GTLiteOverlays import gregtechlite.gtlitecore.common.block.adapter.GTBoilerCasing import gregtechlite.gtlitecore.common.block.variant.MetalCasing +import net.minecraft.init.Blocks import net.minecraft.item.ItemStack +import net.minecraft.util.EnumFacing import net.minecraft.util.ResourceLocation +import net.minecraft.util.math.BlockPos import net.minecraft.world.World import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly @@ -108,6 +112,84 @@ class MultiblockOreWasher(id: ResourceLocation) : MultiMapMultiblockController(i override fun canBeDistinct() = true + override fun update() + { + super.update() + + var backFacing = frontFacing.opposite + + // We disable rotation of the controller by override allowsExtendedFacing, + // this is a fallback for some edge case. + if (!backFacing.axis.isHorizontal) + backFacing = EnumFacing.NORTH + + val offsets = arrayListOf() + + // y = 0 | x = 2, z ∈ [1, 5] + for (z in 1..5) + { + offsets.add(BlockPos(0, 0, z)) + } + + // y = 1 | x ∈ [1, 3], z ∈ [1, 5] + for (z in 1..5) + { + for (x in 1..3) + { + offsets.add(BlockPos(x - 2, 1, z)) + } + } + + val forward = backFacing.directionVec + val rightVec = backFacing.rotateY() + + var waterCount = 0 + val countToFill = offsets.size + + for (relPos in offsets) + { + val dx = relPos.x + val dy = relPos.y + val dz = relPos.z + + val relX = dx * rightVec.xOffset + dz * forward.x + val relY = dy + val relZ = dx * rightVec.zOffset + dz * forward.z + + val checkPos = pos.add(relX, relY, relZ) + val checkBlock = world.getBlockState(checkPos).block + + if (isStructureFormed) + { + if (block == Blocks.WATER) + { + waterCount++ + continue + } + + if (checkBlock == Blocks.AIR || checkBlock == Blocks.FLOWING_WATER) + { + world.setBlockState(checkPos, Blocks.WATER.defaultState) + waterCount++ + } + } + else + { + if (checkBlock == Blocks.WATER || checkBlock == Blocks.AIR || checkBlock == Blocks.FLOWING_WATER) + { + world.setBlockState(checkPos, Blocks.AIR.defaultState) + } + } + } + + if (waterCount < countToFill) + { + GTLiteLog.logger.debug("Actual fill water count: $waterCount, require fill water count: $countToFill") + } + } + + override fun allowsExtendedFacing(): Boolean = false + private inner class LargeOreWasherRecipeLogic(mte: RecipeMapMultiblockController) : MultiblockRecipeLogic(mte) { From 0f35067d14807b673172c9b629adfe8fec9314e2 Mon Sep 17 00:00:00 2001 From: Magic_Sweepy Date: Wed, 25 Mar 2026 12:11:52 +0800 Subject: [PATCH 2/2] some syntax overhaul and check block fix --- .../multiblock/MultiblockSpaceElevator.kt | 2 +- .../advanced/MultiblockOreWasher.kt | 39 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/MultiblockSpaceElevator.kt b/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/MultiblockSpaceElevator.kt index 937ce8374..0346d6cbd 100644 --- a/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/MultiblockSpaceElevator.kt +++ b/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/MultiblockSpaceElevator.kt @@ -56,7 +56,7 @@ import net.minecraft.util.text.TextFormatting import net.minecraft.world.World import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly -import java.util.Collections +import java.util.* import java.util.concurrent.ConcurrentHashMap class MultiblockSpaceElevator(id: ResourceLocation) : MultiblockWithDisplayBase(id), ModuleProvider diff --git a/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt b/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt index 20a1857c4..4f91cb698 100644 --- a/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt +++ b/src/main/kotlin/gregtechlite/gtlitecore/common/metatileentity/multiblock/advanced/MultiblockOreWasher.kt @@ -115,28 +115,24 @@ class MultiblockOreWasher(id: ResourceLocation) : MultiMapMultiblockController(i override fun update() { super.update() - - var backFacing = frontFacing.opposite - // We disable rotation of the controller by override allowsExtendedFacing, // this is a fallback for some edge case. - if (!backFacing.axis.isHorizontal) - backFacing = EnumFacing.NORTH - - val offsets = arrayListOf() + val backFacing = frontFacing.opposite.takeIf { it.axis.isHorizontal } ?: EnumFacing.NORTH - // y = 0 | x = 2, z ∈ [1, 5] - for (z in 1..5) - { - offsets.add(BlockPos(0, 0, z)) - } + val offsets = buildList { + // y = 0 | x = 2, z ∈ [1, 5] + for (z in 1..5) + { + add(BlockPos(0, 0, z)) + } - // y = 1 | x ∈ [1, 3], z ∈ [1, 5] - for (z in 1..5) - { - for (x in 1..3) + // y = 1 | x ∈ [1, 3], z ∈ [1, 5] + for (z in 1..5) { - offsets.add(BlockPos(x - 2, 1, z)) + for (x in 1..3) + { + add(BlockPos(x - 2, 1, z)) + } } } @@ -159,15 +155,18 @@ class MultiblockOreWasher(id: ResourceLocation) : MultiMapMultiblockController(i val checkPos = pos.add(relX, relY, relZ) val checkBlock = world.getBlockState(checkPos).block + val isWater = checkBlock == Blocks.WATER + val isAirOrFlowingWater = checkBlock == Blocks.AIR || checkBlock == Blocks.FLOWING_WATER + if (isStructureFormed) { - if (block == Blocks.WATER) + if (isWater) { waterCount++ continue } - if (checkBlock == Blocks.AIR || checkBlock == Blocks.FLOWING_WATER) + if (isAirOrFlowingWater) { world.setBlockState(checkPos, Blocks.WATER.defaultState) waterCount++ @@ -175,7 +174,7 @@ class MultiblockOreWasher(id: ResourceLocation) : MultiMapMultiblockController(i } else { - if (checkBlock == Blocks.WATER || checkBlock == Blocks.AIR || checkBlock == Blocks.FLOWING_WATER) + if (isWater || isAirOrFlowingWater) { world.setBlockState(checkPos, Blocks.AIR.defaultState) }