mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 11:57:01 -05:00
Fix LVTs (#167)
* Fix ServerGamePacketListenerImpl Closes #165, closes #166 * Fix MixinGameRenderer by giving it an explicit ordering The Fabric API mixin uses the default priority of 1000, so we use 1100 priority to apply before it. This results in this bytecode structure, where "F" is the Fabric API injections, "A" is the Architectury API injections, and "M" is the Minecraft function being injected pre/post: `FAMAF`. * Fix MixinPhantomSpawner captures * Fix MixinPatrolSpawner captures * Fix MixinChunkSerializer captures
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import dev.architectury.event.events.common.ChunkEvent;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -26,7 +27,14 @@ import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
@@ -40,9 +48,9 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
public class MixinChunkSerializer {
|
||||
@Inject(method = "read", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void load(ServerLevel serverLevel, PoiManager poiManager, ChunkPos chunkPos, CompoundTag compoundTag,
|
||||
CallbackInfoReturnable<ProtoChunk> cir, UpgradeData upgradeData,
|
||||
CallbackInfoReturnable<ProtoChunk> cir, ChunkPos chunkPos2, UpgradeData upgradeData,
|
||||
boolean bl, ListTag listTag, int i, LevelChunkSection levelChunkSections[], boolean bl2, ChunkSource chunkSource,
|
||||
LevelLightEngine levelLightEngine, Registry registry, long m, ChunkStatus.ChunkType chunkType,
|
||||
LevelLightEngine levelLightEngine, Registry registry, Codec<PalettedContainer<Biome>> codec, long m, ChunkStatus.ChunkType chunkType,
|
||||
BlendingData blendingData, ChunkAccess chunkAccess2) {
|
||||
ChunkEvent.LOAD_DATA.invoker().load(chunkAccess2, serverLevel, compoundTag);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.monster.PatrollingMonster;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.PatrolSpawner;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -48,7 +49,7 @@ public abstract class MixinPatrolSpawner {
|
||||
cancellable = true,
|
||||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void checkPatrolSpawn(ServerLevel level, BlockPos pos, Random r, boolean b, CallbackInfoReturnable<Boolean> cir, PatrollingMonster entity) {
|
||||
private void checkPatrolSpawn(ServerLevel level, BlockPos pos, Random r, boolean b, CallbackInfoReturnable<Boolean> cir, BlockState blockState, PatrollingMonster entity) {
|
||||
var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.PATROL, null);
|
||||
if (result.value() != null) {
|
||||
cir.setReturnValue(result.value());
|
||||
|
||||
@@ -23,12 +23,15 @@ import dev.architectury.event.events.common.EntityEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.ServerStatsCounter;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.monster.Phantom;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.PhantomSpawner;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -53,8 +56,9 @@ public abstract class MixinPhantomSpawner {
|
||||
locals = LocalCapture.CAPTURE_FAILSOFT // SOFT, because this will break in 2 seconds
|
||||
)
|
||||
private void checkPhantomSpawn(ServerLevel level, boolean bl, boolean bl2, CallbackInfoReturnable<Integer> cir,
|
||||
Random random, int i, Iterator<ServerPlayer> it, Player player, BlockPos pos, DifficultyInstance diff, BlockPos pos2,
|
||||
SpawnGroupData sgd, int l, int m, Phantom entity) {
|
||||
Random random, int i, Iterator<ServerPlayer> it, Player player, BlockPos pos, DifficultyInstance diff,
|
||||
ServerStatsCounter serverStatsCounter, int j, int k, BlockPos pos2,
|
||||
BlockState blockState, FluidState fluidState, SpawnGroupData sgd, int l, int m, Phantom entity) {
|
||||
if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.NATURAL, null).value() == Boolean.FALSE) {
|
||||
cir.setReturnValue(0);
|
||||
cir.cancel();
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class MixinServerGamePacketListenerImpl {
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/players/PlayerList;broadcastMessage(Lnet/minecraft/network/chat/Component;Ljava/util/function/Function;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V"),
|
||||
cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void handleChat(TextFilter.FilteredText message, CallbackInfo ci, String string, Component component, Component component2) {
|
||||
private void handleChat(TextFilter.FilteredText message, CallbackInfo ci, String string, String string2, Component component, Component component2) {
|
||||
var chatComponent = new ChatComponentImpl(component2, component);
|
||||
var process = ChatEvent.SERVER.invoker().process(this.player, message, chatComponent);
|
||||
if (process.isEmpty()) return;
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
@Mixin(value = GameRenderer.class, priority = 1100)
|
||||
public abstract class MixinGameRenderer {
|
||||
@Shadow
|
||||
@Final
|
||||
|
||||
Reference in New Issue
Block a user