Skip to content

Commit

Permalink
Merge dev (#9) back into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shurik204 authored Nov 21, 2023
2 parents 68c740f + 209c99b commit 98505dc
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 21 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.21
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.23

# Mod Properties
mod_version=1.2.0
mod_version=1.2.1
maven_group=me.shurik.better-suggestions
archives_base_name=better-suggestions

# Dependencies
fabric_version=0.87.0+1.20.1
cloth_config_version=11.0.98
modmenu_version=7.0.0-beta.2
fabric_version=0.90.0+1.20.2
cloth_config_version=12.0.109
modmenu_version=8.0.0-beta.2
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public static void renderPositionHighlight(Vec3d pos, Vector4f color, WorldRende
public static void interactionHighlight(InteractionEntity interaction, Vector4f color, WorldRenderContext worldContext) {
FullContext context = setupContext(worldContext, interaction);

double halfX = interaction.getBoundingBox().getXLength() / 2;
double halfZ = interaction.getBoundingBox().getZLength() / 2;
double halfX = interaction.getBoundingBox().getLengthX() / 2;
double halfZ = interaction.getBoundingBox().getLengthZ() / 2;
// Box box = new Box(-halfX, 0, -halfZ, halfX, interaction.getBoundingBox().getYLength(), halfZ);

WorldRenderer.renderFilledBox(context.matrices, context.bufferBuilder, -halfX, 0, -halfZ, halfX, interaction.getBoundingBox().getYLength(), halfZ, color.x, color.y, color.z, color.w);
WorldRenderer.renderFilledBox(context.matrices, context.bufferBuilder, -halfX, 0, -halfZ, halfX, interaction.getBoundingBox().getLengthY(), halfZ, color.x, color.y, color.z, color.w);
finishRendering(context);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.shurik.bettersuggestions.mixin;

import net.minecraft.server.world.EntityTrackingListener;
import net.minecraft.server.network.PlayerAssociatedNetworkHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

Expand All @@ -9,5 +9,5 @@
@Mixin(targets = "net/minecraft/server/world/ThreadedAnvilChunkStorage$EntityTracker")
public interface EntityTrackerAccessor {
@Accessor("listeners")
Set<EntityTrackingListener> getPlayersTracking();
Set<PlayerAssociatedNetworkHandler> getPlayersTracking();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Mixin(ThreadedAnvilChunkStorage.class)
public interface ThreadedAnvilChunkStorageAccessor {
@Accessor("entityTrackers")
@Accessor
Int2ObjectMap<EntityTrackerAccessor> getEntityTrackers();
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package me.shurik.bettersuggestions.network;

import me.shurik.bettersuggestions.mixin.EntityTrackerAccessor;
import me.shurik.bettersuggestions.mixin.ThreadedAnvilChunkStorageAccessor;
import me.shurik.bettersuggestions.utils.ByteBufUtils;
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.EntityTrackingListener;
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;

Expand All @@ -30,6 +31,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) {
Expand All @@ -38,11 +40,14 @@ public static Collection<ServerPlayerEntity> tracking(Entity entity) {

// return an immutable collection to guard against accidental removals.
if (tracker != null) {
return tracker.getPlayersTracking().stream().map(EntityTrackingListener::getPlayer).collect(Collectors.toUnmodifiableSet());
return tracker.getPlayersTracking()
.stream().map(PlayerAssociatedNetworkHandler::getPlayer).collect(Collectors.toUnmodifiableSet());
}

return Collections.emptySet();
}

return Collections.emptySet();
throw new IllegalArgumentException("Only supported on server worlds!");
}

public static void broadcastFromEntity(Entity entity, Identifier packetId, PacketByteBuf buf) {
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/me/shurik/bettersuggestions/utils/Scoreboards.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,32 @@
import net.minecraft.scoreboard.ScoreboardObjective;
import net.minecraft.scoreboard.ScoreboardPlayerScore;
import net.minecraft.scoreboard.ServerScoreboard;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

public class Scoreboards {
// Base methods
public static ServerScoreboard getInstance() { return Server.INSTANCE.getScoreboard(); }
public static Collection<ScoreboardObjective> getObjectives() { return getInstance().getObjectives(); }
public static ScoreboardObjective getObjective(String name) { return getInstance().getObjective(name); }
@Nullable
public static ScoreboardObjective getObjective(String name) { return getObjectives().stream().filter(objective -> objective.getName().equals(name)).findFirst().orElse(null); }
public static ScoreboardPlayerScore getScore(String name, ScoreboardObjective objective) { return getInstance().getPlayerScore(name, objective); }
public static Collection<ScoreboardPlayerScore> getScores(ScoreboardObjective objective) { return getInstance().getAllPlayerScores(objective); }
public static Collection<ScoreboardPlayerScore> getScores(String name) { return getInstance().getPlayerObjectives(name).values(); }
public static void setScore(String name, ScoreboardObjective objective, int value) { getScore(name, objective).setScore(value); }
//

public static ScoreboardPlayerScore getScore(String name, String objective) { return getScore(name, getObjective(objective)); }
public static void setScore(String name, String objective, int value) { setScore(name, getObjective(objective), value); };
@Nullable
public static ScoreboardPlayerScore getScore(String name, String objectiveName) {
ScoreboardObjective objective = getObjective(objectiveName);
if (objective == null) return null;
return getScore(name, objective);
}
public static boolean setScore(String name, String objectiveName, int value) {
ScoreboardObjective scoreboardObjective = getObjective(objectiveName);
if (scoreboardObjective == null) return false;
setScore(name, scoreboardObjective, value);
return true;
}
}
60 changes: 60 additions & 0 deletions src/main/resources/assets/better-suggestions/lang/uk_ua.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"text.suggestion.tooltip.uuid": "UUID",
"text.suggestion.tooltip.uuid.layout": "%s: %s",
"text.suggestion.tooltip.pos": "Позиція",
"text.suggestion.tooltip.pos.layout": "%s: %s",
"text.suggestion.tooltip.entity_tags": "Теги",
"text.suggestion.tooltip.entity_tags.layout": "%s (%s): %s",
"text.suggestion.tooltip.entity_tags.loading": "Отримання тегів з сервера...",
"text.suggestion.tooltip.vehicle": "Сидить на",
"text.suggestion.tooltip.vehicle.layout": "%s: %s",
"text.suggestion.tooltip.passengers": "Пасажири",
"text.suggestion.tooltip.passengers.layout": "%s (%s): %s",
"text.suggestion.tooltip.team": "Команда",
"text.suggestion.tooltip.team.layout": "%s: %s",
"text.suggestion.tooltip.health": "Здоров'я",
"text.suggestion.tooltip.health.layout": "%s: %s/%s",
"text.suggestion.tooltip.entity_scores": "Задачі",
"text.suggestion.tooltip.entity_scores.first_layout": "%s:",
"text.suggestion.tooltip.entity_scores.layout": " - %s: %s",
"text.suggestion.tooltip.entity_scores.loading": "Отримання задач з сервера...",
"text.suggestion.tooltip.entity_scores.no_server_side": "Неможливо отримати задачі з сервера",

"text.autoconfig.better-suggestions.title": "Налаштування Better Suggestions",
"text.autoconfig.better-suggestions.category.default": "Загальні",
"text.autoconfig.better-suggestions.category.entitySuggestions": "Підказки сутностей",
"text.autoconfig.better-suggestions.category.functionSuggestions": "Підказки функцій",
"text.autoconfig.better-suggestions.category.server": "Дозволи",
"text.autoconfig.better-suggestions.option.maxSuggestionsShown": "Скільки підказок показувати",
"text.autoconfig.better-suggestions.option.highlightCoordinates": "Показувати координати в світі",
"text.autoconfig.better-suggestions.option.highlightCoordinates.@Tooltip[0]": "Підсвічувати блоки та координати з команд",
"text.autoconfig.better-suggestions.option.rememberCommandOnEscape": "Запам'ятовувати команду",
"text.autoconfig.better-suggestions.option.rememberCommandOnEscape.@Tooltip[0]": "Відновлювати команду після закриття чату",
"text.autoconfig.better-suggestions.option.rememberCommandOnEscape.@Tooltip[1]": "(Використовуйте Shift + Escape щоб тимчасово вимкнути)",
"text.autoconfig.better-suggestions.option.prioritizedSuggestions": "Пріоритетні пропозиції",

"text.autoconfig.better-suggestions.option.entitySuggestions.suggestEntitySelector": "Пропонувати селектор сутності коли дивишся на сутність",
"text.autoconfig.better-suggestions.option.entitySuggestions.suggestEntitySelector.@Tooltip[0]": "Пропонувати селектор @e[type=ENTITY_TYPE,limit=1,sort=nearest] сутності",
"text.autoconfig.better-suggestions.option.entitySuggestions.suggestEntitySelector.@Tooltip[1]": "коли дивишся на сутність",
"text.autoconfig.better-suggestions.option.entitySuggestions.entitySuggestionRadius": "Радіус пошуку сутностей",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityId.@PrefixText": "Налаштування спливаючих підказкок",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityId": "Показувати тип",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityUuid": "Показувати UUID",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityPos": "Показувати позицію",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityTags": "Показувати теги",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityVehicle": "Показувати транспорт",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityPassengers": "Показувати пасажирів",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityTeam": "Показувати команду",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityHealth": "Показувати здоров'я",
"text.autoconfig.better-suggestions.option.entitySuggestions.showEntityScores": "Показувати задачі",


"text.autoconfig.better-suggestions.option.functionSuggestions.hideUnderscoreFunctions": "Приховувати \"приватні\" функції",
"text.autoconfig.better-suggestions.option.functionSuggestions.hideUnderscoreFunctions.@Tooltip[0]": "Приховувати функції, назва яких починається з \"_\".",
"text.autoconfig.better-suggestions.option.functionSuggestions.hideUnderscoreFunctions.@Tooltip[1]": "Це зазвичай функції, які ви не повинні",
"text.autoconfig.better-suggestions.option.functionSuggestions.hideUnderscoreFunctions.@Tooltip[2]": "викликати самі.",

"text.autoconfig.better-suggestions.option.server.requireOpToRequestData": "Дозволити запити даних лише для адміністраторів",
"text.autoconfig.better-suggestions.option.server.requireOpToRequestData.@Tooltip[0]": "(Якщо включено, гравці без OP не зможуть",
"text.autoconfig.better-suggestions.option.server.requireOpToRequestData.@Tooltip[1]": "запитувати теги, задачі сутностей, тощо з сервера)"
}

0 comments on commit 98505dc

Please sign in to comment.