diff --git a/gradle.properties b/gradle.properties index dccd25c..c41d749 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.4 loader_version=0.14.23 # Mod Properties -mod_version=1.2.1 +mod_version=1.2.2 maven_group=me.shurik.better-suggestions archives_base_name=better-suggestions diff --git a/src/main/java/me/shurik/bettersuggestions/client/render/SpecialRenderer.java b/src/main/java/me/shurik/bettersuggestions/client/render/SpecialRenderer.java index 45a8388..de56652 100644 --- a/src/main/java/me/shurik/bettersuggestions/client/render/SpecialRenderer.java +++ b/src/main/java/me/shurik/bettersuggestions/client/render/SpecialRenderer.java @@ -8,6 +8,7 @@ import net.minecraft.entity.decoration.DisplayEntity; import net.minecraft.entity.decoration.InteractionEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; import org.joml.Vector4f; import org.lwjgl.opengl.GL11; @@ -76,12 +77,14 @@ public static void renderPositionHighlight(Vec3d pos, Vector4f color, WorldRende public static void interactionHighlight(InteractionEntity interaction, Vector4f color, WorldRenderContext worldContext) { FullContext context = setupContext(worldContext, interaction); + Box box = interaction.getBoundingBox(); - double halfX = interaction.getBoundingBox().getLengthX() / 2; - double halfZ = interaction.getBoundingBox().getLengthZ() / 2; - // Box box = new Box(-halfX, 0, -halfZ, halfX, interaction.getBoundingBox().getYLength(), halfZ); + // getLengthX + double halfX = (box.maxX - box.minX) / 2; + // getLengthZ + double halfZ = (box.maxZ - box.minZ) / 2; - WorldRenderer.renderFilledBox(context.matrices, context.bufferBuilder, -halfX, 0, -halfZ, halfX, interaction.getBoundingBox().getLengthY(), halfZ, color.x, color.y, color.z, color.w); + WorldRenderer.renderFilledBox(context.matrices, context.bufferBuilder, -halfX, 0, -halfZ, halfX, box.maxY - box.minY, halfZ, color.x, color.y, color.z, color.w); finishRendering(context); } diff --git a/src/main/java/me/shurik/bettersuggestions/mixin/EntityTrackerAccessor.java b/src/main/java/me/shurik/bettersuggestions/mixin/EntityTrackerAccessor.java deleted file mode 100644 index 50338c5..0000000 --- a/src/main/java/me/shurik/bettersuggestions/mixin/EntityTrackerAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.shurik.bettersuggestions.mixin; - -import net.minecraft.server.network.PlayerAssociatedNetworkHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Set; - -@Mixin(targets = "net/minecraft/server/world/ThreadedAnvilChunkStorage$EntityTracker") -public interface EntityTrackerAccessor { - @Accessor("listeners") - Set getPlayersTracking(); -} \ No newline at end of file diff --git a/src/main/java/me/shurik/bettersuggestions/mixin/ThreadedAnvilChunkStorageAccessor.java b/src/main/java/me/shurik/bettersuggestions/mixin/ThreadedAnvilChunkStorageAccessor.java deleted file mode 100644 index 00eef36..0000000 --- a/src/main/java/me/shurik/bettersuggestions/mixin/ThreadedAnvilChunkStorageAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package me.shurik.bettersuggestions.mixin; - -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import net.minecraft.server.world.ThreadedAnvilChunkStorage; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ThreadedAnvilChunkStorage.class) -public interface ThreadedAnvilChunkStorageAccessor { - @Accessor - Int2ObjectMap getEntityTrackers(); -} \ No newline at end of file diff --git a/src/main/java/me/shurik/bettersuggestions/network/ServerNetworking.java b/src/main/java/me/shurik/bettersuggestions/network/ServerNetworking.java index 05232ca..13fb4e2 100644 --- a/src/main/java/me/shurik/bettersuggestions/network/ServerNetworking.java +++ b/src/main/java/me/shurik/bettersuggestions/network/ServerNetworking.java @@ -1,24 +1,16 @@ package me.shurik.bettersuggestions.network; import me.shurik.bettersuggestions.utils.ByteBufUtils; +import net.fabricmc.fabric.api.networking.v1.PlayerLookup; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import me.shurik.bettersuggestions.mixin.EntityTrackerAccessor; -import me.shurik.bettersuggestions.mixin.ThreadedAnvilChunkStorageAccessor; import net.minecraft.entity.Entity; import net.minecraft.network.PacketByteBuf; import net.minecraft.scoreboard.ScoreboardPlayerScore; -import net.minecraft.server.network.PlayerAssociatedNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerChunkManager; -import net.minecraft.server.world.ThreadedAnvilChunkStorage; import net.minecraft.util.Identifier; -import net.minecraft.world.chunk.ChunkManager; import java.util.Collection; -import java.util.Collections; -import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; public class ServerNetworking { public static PacketByteBuf createEntityCommandTagsBuffer(int entityId, Set commandTags) { @@ -31,23 +23,7 @@ public static PacketByteBuf createEntityScoresBuffer(int entityId, Collection tracking(Entity entity) { - Objects.requireNonNull(entity, "Entity cannot be null"); - ChunkManager manager = entity.getWorld().getChunkManager(); - - if (manager instanceof ServerChunkManager) { - ThreadedAnvilChunkStorage storage = ((ServerChunkManager) manager).threadedAnvilChunkStorage; - EntityTrackerAccessor tracker = ((ThreadedAnvilChunkStorageAccessor) storage).getEntityTrackers().get(entity.getId()); - - // return an immutable collection to guard against accidental removals. - if (tracker != null) { - return tracker.getPlayersTracking() - .stream().map(PlayerAssociatedNetworkHandler::getPlayer).collect(Collectors.toUnmodifiableSet()); - } - - return Collections.emptySet(); - } - - throw new IllegalArgumentException("Only supported on server worlds!"); + return PlayerLookup.tracking(entity); } public static void broadcastFromEntity(Entity entity, Identifier packetId, PacketByteBuf buf) { diff --git a/src/main/resources/better-suggestions.mixins.json b/src/main/resources/better-suggestions.mixins.json index 622af0d..89b66c3 100644 --- a/src/main/resources/better-suggestions.mixins.json +++ b/src/main/resources/better-suggestions.mixins.json @@ -4,11 +4,9 @@ "compatibilityLevel": "JAVA_17", "mixins": [ "CommandSourceMixin", - "EntityTrackerAccessor", "EntityTypeBuilderMixin", "MarkerEntityMixin", - "MinecraftServerMixin", - "ThreadedAnvilChunkStorageAccessor" + "MinecraftServerMixin" ], "injectors": { "defaultRequire": 1