diff --git a/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java b/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java index c1622d1..d75629b 100644 --- a/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java @@ -35,6 +35,8 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.ai.village.poi.PoiType; +import net.minecraft.world.entity.ai.village.poi.PoiTypes; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; @@ -246,8 +248,17 @@ private void applyBlockBuffer(ServerPlayer player, MinecraftServer server, Block world.getChunkSource().blockChanged(blockPos); // todo: maybe simply resend chunk instead of this? if (LightEngine.hasDifferentLightProperties(chunk, blockPos, old, blockState)) { + chunk.getSkyLightSources().update(chunk, x, by, z); lightEngine.checkBlock(blockPos); } + + // Update Poi + Optional> newPoi = PoiTypes.forState(blockState); + Optional> oldPoi = PoiTypes.forState(old); + if (!Objects.equals(oldPoi, newPoi)) { + if (oldPoi.isPresent()) world.getPoiManager().remove(blockPos); + if (newPoi.isPresent()) world.getPoiManager().add(blockPos, newPoi.get()); + } } } } diff --git a/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java b/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java index 787a039..e90576a 100644 --- a/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/SetBlockPacketListener.java @@ -4,11 +4,14 @@ import com.moulberry.axiom.event.AxiomModifyWorldEvent; import io.netty.buffer.Unpooled; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.core.SectionPos; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.ai.village.poi.PoiType; +import net.minecraft.world.entity.ai.village.poi.PoiTypes; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; @@ -33,6 +36,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.logging.Level; public class SetBlockPacketListener implements PluginMessageListener { @@ -184,8 +189,17 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player buk level.getChunkSource().blockChanged(blockPos); if (LightEngine.hasDifferentLightProperties(chunk, blockPos, old, blockState)) { + chunk.getSkyLightSources().update(chunk, x, by, z); level.getChunkSource().getLightEngine().checkBlock(blockPos); } + + // Update Poi + Optional> newPoi = PoiTypes.forState(blockState); + Optional> oldPoi = PoiTypes.forState(old); + if (!Objects.equals(oldPoi, newPoi)) { + if (oldPoi.isPresent()) level.getPoiManager().remove(blockPos); + if (newPoi.isPresent()) level.getPoiManager().add(blockPos, newPoi.get()); + } } boolean nowHasOnlyAir = section.hasOnlyAir();