mirror of
https://github.com/lukasabbe/bookshelf-inspector.git
synced 2026-04-30 10:40:53 +00:00
25w06a
This commit is contained in:
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
org.gradle.jvmargs=-Xmx4G
|
org.gradle.jvmargs=-Xmx4G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=25w02a
|
minecraft_version=25w06a
|
||||||
yarn_mappings=25w02a+build.9
|
yarn_mappings=25w06a+build.7
|
||||||
loader_version=0.16.10
|
loader_version=0.16.10
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.9+1.21.5-SNAPSHOT.1
|
mod_version=1.9+1.21.5-SNAPSHOT.1
|
||||||
@@ -11,7 +11,7 @@ maven_group=me.lukasabbe
|
|||||||
archives_base_name=Bookshelfinspector
|
archives_base_name=Bookshelfinspector
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.114.1+1.21.5
|
fabric_version=0.116.0+1.21.5
|
||||||
cloth_config=17.0.144
|
cloth_config=17.0.144
|
||||||
modmenu=13.0.0
|
modmenu=13.0.0
|
||||||
YAML_snake=2.3
|
YAML_snake=2.3
|
||||||
@@ -22,13 +22,13 @@ public class Bookshelfinspector implements ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
//Registers request types
|
||||||
PayloadTypeRegistry.playC2S().register(BookShelfInventoryRequestPayload.ID,BookShelfInventoryRequestPayload.CODEC);
|
PayloadTypeRegistry.playC2S().register(BookShelfInventoryRequestPayload.ID,BookShelfInventoryRequestPayload.CODEC);
|
||||||
PayloadTypeRegistry.playC2S().register(LecternInventoryRequestPayload.ID, LecternInventoryRequestPayload.CODEC);
|
PayloadTypeRegistry.playC2S().register(LecternInventoryRequestPayload.ID, LecternInventoryRequestPayload.CODEC);
|
||||||
PayloadTypeRegistry.playS2C().register(BookShelfInventoryPayload.ID,BookShelfInventoryPayload.CODEC);
|
PayloadTypeRegistry.playS2C().register(BookShelfInventoryPayload.ID,BookShelfInventoryPayload.CODEC);
|
||||||
PayloadTypeRegistry.playS2C().register(ModCheckPayload.ID, ModCheckPayload.CODEC);
|
PayloadTypeRegistry.playS2C().register(ModCheckPayload.ID, ModCheckPayload.CODEC);
|
||||||
|
|
||||||
ServerPlayNetworking.registerGlobalReceiver(BookShelfInventoryRequestPayload.ID, new BookShelfInventoryRequestPayloadHandler());
|
ServerPlayNetworking.registerGlobalReceiver(BookShelfInventoryRequestPayload.ID, new BookShelfInventoryRequestPayloadHandler());
|
||||||
|
|
||||||
ServerPlayNetworking.registerGlobalReceiver(LecternInventoryRequestPayload.ID, new LecternInventoryRequestPayloadHandler());
|
ServerPlayNetworking.registerGlobalReceiver(LecternInventoryRequestPayload.ID, new LecternInventoryRequestPayloadHandler());
|
||||||
|
|
||||||
ServerPlayConnectionEvents.JOIN.register(((handler, sender, server) -> {
|
ServerPlayConnectionEvents.JOIN.register(((handler, sender, server) -> {
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ public class BookshelfinspectorClient implements ClientModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
|
|
||||||
config.loadConfig();
|
config.loadConfig();
|
||||||
|
|
||||||
ClientPlayNetworking.registerGlobalReceiver(BookShelfInventoryPayload.ID, new BookShelfInventoryHandler());
|
ClientPlayNetworking.registerGlobalReceiver(BookShelfInventoryPayload.ID, new BookShelfInventoryHandler());
|
||||||
ClientPlayNetworking.registerGlobalReceiver(ModCheckPayload.ID,new ModPayloadHandler());
|
ClientPlayNetworking.registerGlobalReceiver(ModCheckPayload.ID,new ModPayloadHandler());
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,14 @@ public class BookshelfTools {
|
|||||||
final World world = Bookshelfinspector.serverInstance.getPlayerManager().getPlayer(player.getUuid()).getWorld();
|
final World world = Bookshelfinspector.serverInstance.getPlayerManager().getPlayer(player.getUuid()).getWorld();
|
||||||
|
|
||||||
if(world == null) return null;
|
if(world == null) return null;
|
||||||
Optional<ChiseledBookshelfBlockEntity> blockEntityOptional = world.getBlockEntity(pos,BlockEntityType.CHISELED_BOOKSHELF);
|
|
||||||
|
final Optional<ChiseledBookshelfBlockEntity> blockEntityOptional = world.getBlockEntity(pos,BlockEntityType.CHISELED_BOOKSHELF);
|
||||||
|
|
||||||
if(blockEntityOptional.isEmpty()) return null;
|
if(blockEntityOptional.isEmpty()) return null;
|
||||||
|
|
||||||
ChiseledBookshelfBlockEntity blockEntity = blockEntityOptional.get();
|
final ChiseledBookshelfBlockEntity blockEntity = blockEntityOptional.get();
|
||||||
|
|
||||||
final ItemStack stack = blockEntity.getStack(slotNum);
|
final ItemStack stack = blockEntity.getStack(slotNum);
|
||||||
|
|
||||||
if(stack.isEmpty()) return null;
|
if(stack.isEmpty()) return null;
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
|
|||||||
@@ -24,60 +24,60 @@ import net.minecraft.util.Formatting;
|
|||||||
public class HudRenderer {
|
public class HudRenderer {
|
||||||
public static void hudRender(DrawContext context, MinecraftClient client){
|
public static void hudRender(DrawContext context, MinecraftClient client){
|
||||||
if(!BookshelfinspectorClient.modAvailable) return;
|
if(!BookshelfinspectorClient.modAvailable) return;
|
||||||
|
|
||||||
if(client.options.hudHidden) return;
|
if(client.options.hudHidden) return;
|
||||||
|
if(!BookshelfinspectorClient.bookShelfData.isCurrentBookDataToggled) return;
|
||||||
|
|
||||||
if(BookshelfinspectorClient.bookShelfData.isCurrentBookDataToggled){
|
final BookData currentBookData = BookshelfinspectorClient.currentBookData;
|
||||||
final BookData currentBookData = BookshelfinspectorClient.currentBookData;
|
final int screenWidth = client.getWindow().getScaledWidth();
|
||||||
int screenWidth = client.getWindow().getScaledWidth();
|
final int screenHeight = client.getWindow().getScaledHeight();
|
||||||
int screenHeight = client.getWindow().getScaledHeight();
|
final int x = screenWidth / 2;
|
||||||
int x = screenWidth / 2;
|
final int y = screenHeight / 2;
|
||||||
int y = screenHeight / 2;
|
final ItemStack itemStack = currentBookData.itemStack;
|
||||||
final ItemStack itemStack = currentBookData.itemStack;
|
|
||||||
int color = 0xFFFFFFFF;
|
|
||||||
|
|
||||||
final Integer colorValue = itemStack.getRarity().getFormatting().getColorValue();
|
int color = 0xFFFFFFFF;
|
||||||
if(colorValue != null){
|
|
||||||
color = colorValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float scaleFactor = ((float) BookshelfinspectorClient.config.scale /10);
|
final Integer colorValue = itemStack.getRarity().getFormatting().getColorValue();
|
||||||
drawScaledText(context, itemStack.getName(), x,y+((int)(10*scaleFactor)), color, client.textRenderer);
|
|
||||||
|
|
||||||
ItemEnchantmentsComponent storedComponents = itemStack.getComponents().get(DataComponentTypes.STORED_ENCHANTMENTS);
|
|
||||||
if(storedComponents != null){
|
|
||||||
int i = ((int)(20*scaleFactor));
|
|
||||||
for(RegistryEntry<Enchantment> enchantment : storedComponents.getEnchantments()){
|
|
||||||
String lvl = "";
|
|
||||||
final int level = storedComponents.getLevel(enchantment);
|
|
||||||
if(level != 1)
|
|
||||||
lvl = String.valueOf(level);
|
|
||||||
final MutableText enchantmentText;
|
|
||||||
|
|
||||||
if(!BookshelfinspectorClient.config.useRoman || level == -1)
|
|
||||||
enchantmentText = enchantment.value().description().copy().append(" " + lvl);
|
|
||||||
else if (level != 1)
|
|
||||||
enchantmentText = enchantment.value().description().copy().append(" " + RomanNumerals.toRoman(level));
|
|
||||||
else
|
|
||||||
enchantmentText = enchantment.value().description().copy();
|
|
||||||
|
|
||||||
if(enchantment.isIn(EnchantmentTags.CURSE)) {
|
|
||||||
Texts.setStyleIfAbsent(enchantmentText, Style.EMPTY.withColor(Formatting.RED));
|
|
||||||
}else {
|
|
||||||
Texts.setStyleIfAbsent(enchantmentText, Style.EMPTY.withColor(Formatting.GRAY));
|
|
||||||
}
|
|
||||||
drawScaledText(context, enchantmentText, x,y+i, 0xFFFFFFFF,client.textRenderer);
|
|
||||||
i+=(int)(10*scaleFactor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var writtenBookContentComponent = itemStack.getComponents().get(DataComponentTypes.WRITTEN_BOOK_CONTENT);
|
|
||||||
|
|
||||||
if(writtenBookContentComponent != null){
|
|
||||||
drawScaledText(context, Text.translatable("book.byAuthor",writtenBookContentComponent.author()), x,y+(int)(20*scaleFactor), 0xFFFFFFFF,client.textRenderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(colorValue != null){
|
||||||
|
color = colorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float scaleFactor = ((float) BookshelfinspectorClient.config.scale /10);
|
||||||
|
drawScaledText(context, itemStack.getName(), x,y+((int)(10*scaleFactor)), color, client.textRenderer);
|
||||||
|
|
||||||
|
ItemEnchantmentsComponent storedComponents = itemStack.getComponents().get(DataComponentTypes.STORED_ENCHANTMENTS);
|
||||||
|
if(storedComponents != null){
|
||||||
|
int i = ((int)(20*scaleFactor));
|
||||||
|
for(RegistryEntry<Enchantment> enchantment : storedComponents.getEnchantments()){
|
||||||
|
String lvl = "";
|
||||||
|
final int level = storedComponents.getLevel(enchantment);
|
||||||
|
if(level != 1)
|
||||||
|
lvl = String.valueOf(level);
|
||||||
|
final MutableText enchantmentText;
|
||||||
|
|
||||||
|
if(!BookshelfinspectorClient.config.useRoman || level == -1)
|
||||||
|
enchantmentText = enchantment.value().description().copy().append(" " + lvl);
|
||||||
|
else if (level != 1)
|
||||||
|
enchantmentText = enchantment.value().description().copy().append(" " + RomanNumerals.toRoman(level));
|
||||||
|
else
|
||||||
|
enchantmentText = enchantment.value().description().copy();
|
||||||
|
|
||||||
|
if(enchantment.isIn(EnchantmentTags.CURSE)) {
|
||||||
|
Texts.setStyleIfAbsent(enchantmentText, Style.EMPTY.withColor(Formatting.RED));
|
||||||
|
}else {
|
||||||
|
Texts.setStyleIfAbsent(enchantmentText, Style.EMPTY.withColor(Formatting.GRAY));
|
||||||
|
}
|
||||||
|
drawScaledText(context, enchantmentText, x,y+i, 0xFFFFFFFF,client.textRenderer);
|
||||||
|
i+=(int)(10*scaleFactor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var writtenBookContentComponent = itemStack.getComponents().get(DataComponentTypes.WRITTEN_BOOK_CONTENT);
|
||||||
|
|
||||||
|
if(writtenBookContentComponent != null){
|
||||||
|
drawScaledText(context, Text.translatable("book.byAuthor",writtenBookContentComponent.author()), x,y+(int)(20*scaleFactor), 0xFFFFFFFF,client.textRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private static void drawScaledText(DrawContext context, Text text, int centerX, int y, int color, TextRenderer textRenderer){
|
private static void drawScaledText(DrawContext context, Text text, int centerX, int y, int color, TextRenderer textRenderer){
|
||||||
MatrixStack stack = context.getMatrices();
|
MatrixStack stack = context.getMatrices();
|
||||||
|
|||||||
Reference in New Issue
Block a user