From 42af4ed545c3d757db2cf966d58e206b158544fe Mon Sep 17 00:00:00 2001 From: piebot <164795032+piebotc@users.noreply.github.com> Date: Thu, 26 Mar 2026 20:21:36 +0300 Subject: [PATCH] Fix fence connect logic --- Minecraft.World/FenceTile.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Minecraft.World/FenceTile.cpp b/Minecraft.World/FenceTile.cpp index 1ccddb20..324d22ed 100644 --- a/Minecraft.World/FenceTile.cpp +++ b/Minecraft.World/FenceTile.cpp @@ -2,6 +2,7 @@ #include "net.minecraft.world.item.h" #include "net.minecraft.world.level.h" #include "net.minecraft.world.h" +#include "net.minecraft.world.level.tile.h" #include "FenceTile.h" FenceTile::FenceTile(int id, const wstring &texture, Material *material) : Tile( id, material, isSolidRender()) @@ -122,18 +123,24 @@ int FenceTile::getRenderShape() bool FenceTile::connectsTo(LevelSource *level, int x, int y, int z) { int tile = level->getTile(x, y, z); - if (isFence(tile) || tile == Tile::fenceGate_Id) - { + Tile* tileInstance = Tile::tiles[tile]; + + if (tileInstance == nullptr) + return false; + + FenceTile* asFence = dynamic_cast(tileInstance); + + // more reliable fence check + if (asFence && asFence->material == this->material) return true; - } - Tile *tileInstance = Tile::tiles[tile]; - if (tileInstance != nullptr) - { - if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped()) - { - return tileInstance->material != Material::vegetable; - } - } + + // check if its a fencegate + if (dynamic_cast(tileInstance)) + return true; + + if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped()) + return tileInstance->material != Material::vegetable; + return false; }