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
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=25w02a
|
||||
yarn_mappings=25w02a+build.9
|
||||
minecraft_version=25w06a
|
||||
yarn_mappings=25w06a+build.7
|
||||
loader_version=0.16.10
|
||||
# Mod Properties
|
||||
mod_version=1.9+1.21.5-SNAPSHOT.1
|
||||
@@ -11,7 +11,7 @@ maven_group=me.lukasabbe
|
||||
archives_base_name=Bookshelfinspector
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.114.1+1.21.5
|
||||
fabric_version=0.116.0+1.21.5
|
||||
cloth_config=17.0.144
|
||||
modmenu=13.0.0
|
||||
YAML_snake=2.3
|
||||
@@ -22,13 +22,13 @@ public class Bookshelfinspector implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
//Registers request types
|
||||
PayloadTypeRegistry.playC2S().register(BookShelfInventoryRequestPayload.ID,BookShelfInventoryRequestPayload.CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(LecternInventoryRequestPayload.ID, LecternInventoryRequestPayload.CODEC);
|
||||
PayloadTypeRegistry.playS2C().register(BookShelfInventoryPayload.ID,BookShelfInventoryPayload.CODEC);
|
||||
PayloadTypeRegistry.playS2C().register(ModCheckPayload.ID, ModCheckPayload.CODEC);
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(BookShelfInventoryRequestPayload.ID, new BookShelfInventoryRequestPayloadHandler());
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(LecternInventoryRequestPayload.ID, new LecternInventoryRequestPayloadHandler());
|
||||
|
||||
ServerPlayConnectionEvents.JOIN.register(((handler, sender, server) -> {
|
||||
|
||||
@@ -23,7 +23,9 @@ public class BookshelfinspectorClient implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
|
||||
config.loadConfig();
|
||||
|
||||
ClientPlayNetworking.registerGlobalReceiver(BookShelfInventoryPayload.ID, new BookShelfInventoryHandler());
|
||||
ClientPlayNetworking.registerGlobalReceiver(ModCheckPayload.ID,new ModPayloadHandler());
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@ public class BookshelfTools {
|
||||
final World world = Bookshelfinspector.serverInstance.getPlayerManager().getPlayer(player.getUuid()).getWorld();
|
||||
|
||||
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;
|
||||
|
||||
ChiseledBookshelfBlockEntity blockEntity = blockEntityOptional.get();
|
||||
|
||||
final ChiseledBookshelfBlockEntity blockEntity = blockEntityOptional.get();
|
||||
final ItemStack stack = blockEntity.getStack(slotNum);
|
||||
|
||||
if(stack.isEmpty()) return null;
|
||||
|
||||
return stack;
|
||||
|
||||
@@ -24,60 +24,60 @@ import net.minecraft.util.Formatting;
|
||||
public class HudRenderer {
|
||||
public static void hudRender(DrawContext context, MinecraftClient client){
|
||||
if(!BookshelfinspectorClient.modAvailable) return;
|
||||
|
||||
if(client.options.hudHidden) return;
|
||||
if(!BookshelfinspectorClient.bookShelfData.isCurrentBookDataToggled) return;
|
||||
|
||||
if(BookshelfinspectorClient.bookShelfData.isCurrentBookDataToggled){
|
||||
final BookData currentBookData = BookshelfinspectorClient.currentBookData;
|
||||
int screenWidth = client.getWindow().getScaledWidth();
|
||||
int screenHeight = client.getWindow().getScaledHeight();
|
||||
int x = screenWidth / 2;
|
||||
int y = screenHeight / 2;
|
||||
final ItemStack itemStack = currentBookData.itemStack;
|
||||
int color = 0xFFFFFFFF;
|
||||
final BookData currentBookData = BookshelfinspectorClient.currentBookData;
|
||||
final int screenWidth = client.getWindow().getScaledWidth();
|
||||
final int screenHeight = client.getWindow().getScaledHeight();
|
||||
final int x = screenWidth / 2;
|
||||
final int y = screenHeight / 2;
|
||||
final ItemStack itemStack = currentBookData.itemStack;
|
||||
|
||||
final Integer colorValue = itemStack.getRarity().getFormatting().getColorValue();
|
||||
if(colorValue != null){
|
||||
color = colorValue;
|
||||
}
|
||||
int color = 0xFFFFFFFF;
|
||||
|
||||
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);
|
||||
}
|
||||
final Integer colorValue = itemStack.getRarity().getFormatting().getColorValue();
|
||||
|
||||
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){
|
||||
MatrixStack stack = context.getMatrices();
|
||||
|
||||
Reference in New Issue
Block a user