Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-08 17:40:04 +01:00
Fix skylight & add Poi support
Dieser Commit ist enthalten in:
Ursprung
5001765e4b
Commit
f6cbe97890
@ -35,6 +35,8 @@ import net.minecraft.resources.ResourceKey;
|
||||
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 @@ public class SetBlockBufferPacketListener {
|
||||
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<Holder<PoiType>> newPoi = PoiTypes.forState(blockState);
|
||||
Optional<Holder<PoiType>> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,14 @@ import com.moulberry.axiom.AxiomPaper;
|
||||
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 xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
||||
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 class SetBlockPacketListener implements PluginMessageListener {
|
||||
|
||||
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<Holder<PoiType>> newPoi = PoiTypes.forState(blockState);
|
||||
Optional<Holder<PoiType>> 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();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren