Skip to content

Commit

Permalink
Make the mod compatible with 1.20.1, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
shurik204 committed Nov 21, 2023
1 parent 0a4f43f commit f51759c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 59 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<String> commandTags) {
Expand All @@ -31,23 +23,7 @@ public static PacketByteBuf createEntityScoresBuffer(int entityId, Collection<Sc

// Copy of Fabric PlayerLookup.tracking
public static Collection<ServerPlayerEntity> 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) {
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/better-suggestions.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"CommandSourceMixin",
"EntityTrackerAccessor",
"EntityTypeBuilderMixin",
"MarkerEntityMixin",
"MinecraftServerMixin",
"ThreadedAnvilChunkStorageAccessor"
"MinecraftServerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit f51759c

Please sign in to comment.