From cc275b0965714e674ff115da5e8ac5206700965f Mon Sep 17 00:00:00 2001 From: maxanier Date: Thu, 5 Mar 2020 00:43:54 +0100 Subject: [PATCH 01/28] gradle and mapping updates --- build.gradle | 117 ++++++++++++++---- gradle.properties | 12 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../amerifrance/guideapi/api/BookEvent.java | 18 +-- .../amerifrance/guideapi/api/GuideAPI.java | 11 +- .../amerifrance/guideapi/api/GuideBook.java | 3 +- .../amerifrance/guideapi/api/IGuideBook.java | 7 +- .../amerifrance/guideapi/api/IGuideItem.java | 0 .../guideapi/api/IGuideLinked.java | 4 +- .../guideapi/api/IInfoRenderer.java | 8 +- .../java/amerifrance/guideapi/api/IPage.java | 26 ++-- .../guideapi/api/IRecipeRenderer.java | 9 +- .../amerifrance/guideapi/api/SubTexture.java | 11 +- .../guideapi/api/button/ButtonGuideAPI.java | 4 +- .../amerifrance/guideapi/api/impl/Book.java | 0 .../guideapi/api/impl/BookBinder.java | 0 .../guideapi/api/impl/Category.java | 10 +- .../amerifrance/guideapi/api/impl/Entry.java | 10 +- .../amerifrance/guideapi/api/impl/Page.java | 10 +- .../impl/abstraction/CategoryAbstract.java | 10 +- .../api/impl/abstraction/EntryAbstract.java | 10 +- .../guideapi/api/package-info.java | 0 .../guideapi/api/util/BookHelper.java | 0 .../guideapi/api/util/GuiHelper.java | 0 .../guideapi/api/util/NBTBookTags.java | 0 .../guideapi/api/util/PageHelper.java | 0 .../guideapi/api/util/TextHelper.java | 2 +- .../amerifrance/guideapi/gui/GuiBase.java | 10 +- .../amerifrance/guideapi/gui/GuiCategory.java | 8 +- .../amerifrance/guideapi/gui/GuiEntry.java | 8 +- .../amerifrance/guideapi/gui/GuiHome.java | 10 +- .../amerifrance/guideapi/gui/GuiSearch.java | 20 +-- .../info/InfoRendererDescription.java | 6 +- .../guideapi/info/InfoRendererImage.java | 10 +- .../guideapi/item/ItemGuideBook.java | 22 ++-- .../guideapi/network/PacketSyncCategory.java | 4 +- .../guideapi/network/PacketSyncEntry.java | 4 +- .../guideapi/network/PacketSyncHome.java | 4 +- .../guideapi/page/PageBrewingRecipe.java | 2 +- .../guideapi/page/PageFurnaceRecipe.java | 2 +- .../guideapi/page/PageIRecipe.java | 4 +- .../guideapi/page/PageItemStack.java | 2 +- .../amerifrance/guideapi/page/PageSound.java | 8 +- .../guideapi/proxy/ClientProxy.java | 4 +- .../guideapi/proxy/CommonProxy.java | 16 +-- .../amerifrance/guideapi/test/TestBook.java | 4 +- .../amerifrance/guideapi/test/TestBook2.java | 10 +- .../amerifrance/guideapi/test/TestBook3.java | 14 +-- .../guideapi/util/EventHandler.java | 38 +++--- .../guideapi/wrapper/CategoryWrapper.java | 6 +- .../guideapi/wrapper/EntryWrapper.java | 6 +- .../guideapi/wrapper/PageWrapper.java | 6 +- 52 files changed, 293 insertions(+), 219 deletions(-) rename src/{main => api}/java/amerifrance/guideapi/api/BookEvent.java (75%) rename src/{main => api}/java/amerifrance/guideapi/api/GuideAPI.java (93%) rename src/{main => api}/java/amerifrance/guideapi/api/GuideBook.java (86%) rename src/{main => api}/java/amerifrance/guideapi/api/IGuideBook.java (91%) rename src/{main => api}/java/amerifrance/guideapi/api/IGuideItem.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/IGuideLinked.java (79%) rename src/{main => api}/java/amerifrance/guideapi/api/IInfoRenderer.java (87%) rename src/{main => api}/java/amerifrance/guideapi/api/IPage.java (61%) rename src/{main => api}/java/amerifrance/guideapi/api/IRecipeRenderer.java (87%) rename src/{main => api}/java/amerifrance/guideapi/api/SubTexture.java (93%) rename src/{main => api}/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java (71%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/Book.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/BookBinder.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/Category.java (86%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/Entry.java (92%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/Page.java (85%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java (94%) rename src/{main => api}/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java (90%) rename src/{main => api}/java/amerifrance/guideapi/api/package-info.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/util/BookHelper.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/util/GuiHelper.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/util/NBTBookTags.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/util/PageHelper.java (100%) rename src/{main => api}/java/amerifrance/guideapi/api/util/TextHelper.java (96%) diff --git a/build.gradle b/build.gradle index 320aa9b2..7739d720 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,27 @@ buildscript { repositories { mavenCentral() - maven { url = "http://files.minecraftforge.net/maven" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } + jcenter() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } } + + dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } + plugins { - id 'com.matthewprenger.cursegradle' version '1.1.2' - id "net.minecraftforge.gradle.forge" version "2.0.2" + id 'com.matthewprenger.cursegradle' version '1.2.0' } +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'idea' +apply plugin: 'eclipse' apply plugin: 'maven-publish' def build_number = 'CUSTOM' @@ -23,46 +31,98 @@ if (System.getenv('BUILD_NUMBER') != null) group = package_group archivesBaseName = mod_name -version = "${mc_version}-${mod_version}-${build_number}" +version = "${minecraft_version}-${mod_version}-${build_number}" repositories { maven { url = "http://dvs1.progwml6.com/files/maven" } } dependencies { - deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}" + minecraft([ + group: "net.minecraftforge", + name: "forge", + version: "${project.minecraft_version}-${project.forge_version}" + ]) + compileOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}:${project.jei_version}:api") //API for compile + runtimeOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}:${project.jei_version}") //Full for runtime } +sourceSets { + api + main { + compileClasspath += sourceSets.api.output + runtimeClasspath += sourceSets.api.output + } +} + +configurations { + apiCompile.extendsFrom(compile) +} + + minecraft { - version = "${mc_version}-${forge_version}" - runDir = "run" + mappings channel: "${project.mcp_channel}".toString(), version: "${project.mcp_mappings}".toString() + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + runs { + client { + taskName 'runClient1' + main 'net.minecraftforge.userdev.LaunchTesting' + property 'forge.logging.console.level', 'debug' + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + workingDirectory project.file('run/client1').canonicalPath + + mods { + vampirism { + source sourceSets.main + source sourceSets.api + } + } + + } + server = { + property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.console.level', 'debug' + workingDirectory project.file('run/server').canonicalPath + + mods { + vampirism { + source sourceSets.main + source sourceSets.api + } - replace "@VERSION@", project.version - replaceIn "GuideMod.java" - replace "@API_VERSION@", "${api_version}" - replaceIn "package-info.java" - if (project.hasProperty('mappings_version')) - mappings = project.mappings_version + } + } + } + } + + processResources { - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version + inputs.property "version", project.mod_version from(sourceSets.main.resources.srcDirs) { - include '**/*.info' - include '**/*.properties' + include 'META-INF/mods.toml' - expand 'version': project.version, 'mcversion': project.minecraft.version + expand 'version': project.mod_version, 'mcversion': minecraft_version, 'forge_version': forge_version } + from(sourceSets.main.resources.srcDirs) { - exclude '**/*.info' - exclude '**/*.properties' + exclude 'META-INF/mods.toml' } } jar { + //Keep the jar as clean as possible + includeEmptyDirs = false + + from sourceSets.main.output.classesDirs + from sourceSets.api.output.classesDirs + from sourceSets.main.output.resourcesDir + from sourceSets.api.output.resourcesDir + classifier = '' manifest.mainAttributes( "Built-By": System.getProperty('user.name'), @@ -92,7 +152,7 @@ publishing { publications { mavenJava(MavenPublication) { artifact jar - artifact sourceJar + artifact apiJar } } repositories { @@ -140,6 +200,15 @@ curseforge { changelog = getChangelogText() releaseType = 'beta' - addArtifact sourceJar + addArtifact apiJar + } +} + +idea { + module { + for (String excludeDirName in ["run", "out", "logs", "gradle"]) { + File excludeDir = new File(projectDir, excludeDirName) + excludeDirs.add(excludeDir) + } } } diff --git a/gradle.properties b/gradle.properties index 4993b1f2..cd2ce77f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,16 @@ +org.gradle.daemon=false +org.gradle.jvmargs=-Xmx3G + mod_name=Guide-API package_group=info.amerifrance.guideapi -mc_version=1.12 -forge_version=14.21.1.2443 -mappings_version=snapshot_20170819 +minecraft_version=1.14.4 +forge_version=28.2.0 +mcp_mappings=58-1.14.4 +mcp_channel=stable mod_version=2.1.8 api_version=2.0.0 curse_id=228832 -jei_version=4.7.1.69 +jei_version=6.0.0.13 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1e9b8635..f5095af5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/src/main/java/amerifrance/guideapi/api/BookEvent.java b/src/api/java/amerifrance/guideapi/api/BookEvent.java similarity index 75% rename from src/main/java/amerifrance/guideapi/api/BookEvent.java rename to src/api/java/amerifrance/guideapi/api/BookEvent.java index afc73355..a92ad2ff 100644 --- a/src/main/java/amerifrance/guideapi/api/BookEvent.java +++ b/src/api/java/amerifrance/guideapi/api/BookEvent.java @@ -1,14 +1,14 @@ package amerifrance.guideapi.api; import amerifrance.guideapi.api.impl.Book; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; import javax.annotation.Nonnull; @@ -23,9 +23,9 @@ public class BookEvent extends Event { private final Book book; private final ItemStack stack; - private final EntityPlayer player; + private final PlayerEntity player; - protected BookEvent(Book book, ItemStack stack, EntityPlayer player) { + protected BookEvent(Book book, ItemStack stack, PlayerEntity player) { this.book = book; this.stack = stack; this.player = player; @@ -39,7 +39,7 @@ public ItemStack getStack() { return stack; } - public EntityPlayer getPlayer() { + public PlayerEntity getPlayer() { return player; } @@ -51,11 +51,11 @@ public EntityPlayer getPlayer() { @Cancelable public static class Open extends BookEvent { - private static final ITextComponent DEFAULT_CANCEL = new TextComponentTranslation("text.open.failed").setStyle(new Style().setColor(TextFormatting.RED)); + private static final ITextComponent DEFAULT_CANCEL = new TranslationTextComponent("text.open.failed").setStyle(new Style().setColor(TextFormatting.RED)); private ITextComponent canceledText = DEFAULT_CANCEL; - public Open(Book book, ItemStack stack, EntityPlayer player) { + public Open(Book book, ItemStack stack, PlayerEntity player) { super(book, stack, player); } diff --git a/src/main/java/amerifrance/guideapi/api/GuideAPI.java b/src/api/java/amerifrance/guideapi/api/GuideAPI.java similarity index 93% rename from src/main/java/amerifrance/guideapi/api/GuideAPI.java rename to src/api/java/amerifrance/guideapi/api/GuideAPI.java index 2022f87a..7eb5bf37 100644 --- a/src/main/java/amerifrance/guideapi/api/GuideAPI.java +++ b/src/api/java/amerifrance/guideapi/api/GuideAPI.java @@ -3,12 +3,13 @@ import amerifrance.guideapi.api.impl.Book; import com.google.common.collect.*; import net.minecraft.block.Block; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; + import java.util.List; import java.util.Map; @@ -55,7 +56,7 @@ public static void registerInfoRenderer(Book book, IInfoRenderer infoRenderer, C * @param modelLoc - Location of the model file * @param variantName - Variant to use */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public static void setModel(Book book, ResourceLocation modelLoc, String variantName) { ModelResourceLocation mrl = new ModelResourceLocation(modelLoc, variantName); ModelLoader.setCustomModelResourceLocation( @@ -74,7 +75,7 @@ public static void setModel(Book book, ResourceLocation modelLoc, String variant * * @param book - Book to set model for */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public static void setModel(Book book) { setModel(book, new ResourceLocation("guideapi", "ItemGuideBook"), "inventory"); } diff --git a/src/main/java/amerifrance/guideapi/api/GuideBook.java b/src/api/java/amerifrance/guideapi/api/GuideBook.java similarity index 86% rename from src/main/java/amerifrance/guideapi/api/GuideBook.java rename to src/api/java/amerifrance/guideapi/api/GuideBook.java index a2a12c29..97890413 100644 --- a/src/main/java/amerifrance/guideapi/api/GuideBook.java +++ b/src/api/java/amerifrance/guideapi/api/GuideBook.java @@ -1,6 +1,7 @@ package amerifrance.guideapi.api; -import net.minecraftforge.fml.common.eventhandler.EventPriority; + +import net.minecraftforge.eventbus.api.EventPriority; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/amerifrance/guideapi/api/IGuideBook.java b/src/api/java/amerifrance/guideapi/api/IGuideBook.java similarity index 91% rename from src/main/java/amerifrance/guideapi/api/IGuideBook.java rename to src/api/java/amerifrance/guideapi/api/IGuideBook.java index 21c6da38..d4b8e11d 100644 --- a/src/main/java/amerifrance/guideapi/api/IGuideBook.java +++ b/src/api/java/amerifrance/guideapi/api/IGuideBook.java @@ -3,9 +3,8 @@ import amerifrance.guideapi.api.impl.Book; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -25,7 +24,7 @@ public interface IGuideBook { * * @param bookStack - The ItemStack assigned to your book. */ - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) default void handleModel(@Nonnull ItemStack bookStack) { GuideAPI.setModel(((IGuideItem) bookStack.getItem()).getBook(bookStack)); } diff --git a/src/main/java/amerifrance/guideapi/api/IGuideItem.java b/src/api/java/amerifrance/guideapi/api/IGuideItem.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/IGuideItem.java rename to src/api/java/amerifrance/guideapi/api/IGuideItem.java diff --git a/src/main/java/amerifrance/guideapi/api/IGuideLinked.java b/src/api/java/amerifrance/guideapi/api/IGuideLinked.java similarity index 79% rename from src/main/java/amerifrance/guideapi/api/IGuideLinked.java rename to src/api/java/amerifrance/guideapi/api/IGuideLinked.java index 3d94d0a4..f1a3a772 100644 --- a/src/main/java/amerifrance/guideapi/api/IGuideLinked.java +++ b/src/api/java/amerifrance/guideapi/api/IGuideLinked.java @@ -1,6 +1,6 @@ package amerifrance.guideapi.api; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -18,5 +18,5 @@ public interface IGuideLinked { * @return the key of the entry to open or null if no entry should be opened */ @Nullable - ResourceLocation getLinkedEntry(World world, BlockPos pos, EntityPlayer player, ItemStack stack); + ResourceLocation getLinkedEntry(World world, BlockPos pos, PlayerEntity player, ItemStack stack); } diff --git a/src/main/java/amerifrance/guideapi/api/IInfoRenderer.java b/src/api/java/amerifrance/guideapi/api/IInfoRenderer.java similarity index 87% rename from src/main/java/amerifrance/guideapi/api/IInfoRenderer.java rename to src/api/java/amerifrance/guideapi/api/IInfoRenderer.java index 401ad6ed..55af3ab8 100644 --- a/src/main/java/amerifrance/guideapi/api/IInfoRenderer.java +++ b/src/api/java/amerifrance/guideapi/api/IInfoRenderer.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.api; import amerifrance.guideapi.api.impl.Book; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -33,7 +33,7 @@ public interface IInfoRenderer { * @param rayTrace - A RayTraceResult containing data about the block currently looked at * @param player - The player looking at the block */ - void drawInformation(Book book, World world, BlockPos pos, IBlockState state, RayTraceResult rayTrace, EntityPlayer player); + void drawInformation(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player); interface Block { @@ -49,7 +49,7 @@ interface Block { * @return an IInfoRenderer for this block. If no IInfoRenderer is needed, return null. */ @Nullable - IInfoRenderer getInfoRenderer(Book book, World world, BlockPos pos, IBlockState state, RayTraceResult rayTrace, EntityPlayer player); + IInfoRenderer getInfoRenderer(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player); /** * @return returns the book required to display information. diff --git a/src/main/java/amerifrance/guideapi/api/IPage.java b/src/api/java/amerifrance/guideapi/api/IPage.java similarity index 61% rename from src/main/java/amerifrance/guideapi/api/IPage.java rename to src/api/java/amerifrance/guideapi/api/IPage.java index 317433d9..f94d669d 100644 --- a/src/main/java/amerifrance/guideapi/api/IPage.java +++ b/src/api/java/amerifrance/guideapi/api/IPage.java @@ -3,30 +3,28 @@ import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IPage { - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); - boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack, GuiEntry guiEntry); + boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry); - @SideOnly(Side.CLIENT) - void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, EntityPlayer player, GuiEntry guiEntry); + @OnlyIn(Dist.CLIENT) + void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry); - @SideOnly(Side.CLIENT) - void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, EntityPlayer player, GuiEntry guiEntry); + @OnlyIn(Dist.CLIENT) + void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry); - @SideOnly(Side.CLIENT) - void onInit(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack, GuiEntry guiEntry); + @OnlyIn(Dist.CLIENT) + void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry); } diff --git a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java b/src/api/java/amerifrance/guideapi/api/IRecipeRenderer.java similarity index 87% rename from src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java rename to src/api/java/amerifrance/guideapi/api/IRecipeRenderer.java index 786bd66e..075ea8e1 100644 --- a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java +++ b/src/api/java/amerifrance/guideapi/api/IRecipeRenderer.java @@ -3,21 +3,20 @@ import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; public interface IRecipeRenderer { - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); abstract class RecipeRendererBase implements IRecipeRenderer { diff --git a/src/main/java/amerifrance/guideapi/api/SubTexture.java b/src/api/java/amerifrance/guideapi/api/SubTexture.java similarity index 93% rename from src/main/java/amerifrance/guideapi/api/SubTexture.java rename to src/api/java/amerifrance/guideapi/api/SubTexture.java index e40d2451..00ed6393 100644 --- a/src/main/java/amerifrance/guideapi/api/SubTexture.java +++ b/src/api/java/amerifrance/guideapi/api/SubTexture.java @@ -1,11 +1,14 @@ package amerifrance.guideapi.api; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -55,12 +58,12 @@ public SubTexture(ResourceLocation textureLocation, int xPos, int yPos, int widt this.height = height; } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void draw(int drawX, int drawY, double zLevel) { final float someMagicValueFromMojang = 0.00390625F; - Minecraft.getMinecraft().renderEngine.bindTexture(textureLocation); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getInstance().renderEngine.bindTexture(textureLocation); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); @@ -71,7 +74,7 @@ public void draw(int drawX, int drawY, double zLevel) { tessellator.draw(); } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void draw(int drawX, int drawY) { draw(drawX, drawY, 0.1D); } diff --git a/src/main/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java b/src/api/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java similarity index 71% rename from src/main/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java rename to src/api/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java index bf00f201..c17caddb 100644 --- a/src/main/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java +++ b/src/api/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.api.button; import amerifrance.guideapi.gui.GuiBase; -import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.widget.button.Button; -public class ButtonGuideAPI extends GuiButton { +public class ButtonGuideAPI extends Button { public GuiBase guiBase; diff --git a/src/main/java/amerifrance/guideapi/api/impl/Book.java b/src/api/java/amerifrance/guideapi/api/impl/Book.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/impl/Book.java rename to src/api/java/amerifrance/guideapi/api/impl/Book.java diff --git a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java b/src/api/java/amerifrance/guideapi/api/impl/BookBinder.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/impl/BookBinder.java rename to src/api/java/amerifrance/guideapi/api/impl/BookBinder.java diff --git a/src/main/java/amerifrance/guideapi/api/impl/Category.java b/src/api/java/amerifrance/guideapi/api/impl/Category.java similarity index 86% rename from src/main/java/amerifrance/guideapi/api/impl/Category.java rename to src/api/java/amerifrance/guideapi/api/impl/Category.java index 9544594e..14805991 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Category.java +++ b/src/api/java/amerifrance/guideapi/api/impl/Category.java @@ -7,7 +7,7 @@ import amerifrance.guideapi.gui.GuiHome; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderItem; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; @@ -36,23 +36,23 @@ public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidt } @Override - public boolean canSee(EntityPlayer player, ItemStack bookStack) { + public boolean canSee(PlayerEntity player, ItemStack bookStack) { return true; } @Override @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, int mouseX, int mouseY, EntityPlayer player, ItemStack bookStack) { + public void onLeftClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack) { Minecraft.getMinecraft().displayGuiScreen(new GuiCategory(book, this, player, bookStack, null)); } @Override @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, int mouseX, int mouseY, EntityPlayer player, ItemStack bookStack) { + public void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack) { } @Override @SideOnly(Side.CLIENT) - public void onInit(Book book, GuiHome guiHome, EntityPlayer player, ItemStack bookStack) { + public void onInit(Book book, GuiHome guiHome, PlayerEntity player, ItemStack bookStack) { } } diff --git a/src/main/java/amerifrance/guideapi/api/impl/Entry.java b/src/api/java/amerifrance/guideapi/api/impl/Entry.java similarity index 92% rename from src/main/java/amerifrance/guideapi/api/impl/Entry.java rename to src/api/java/amerifrance/guideapi/api/impl/Entry.java index 0cdc6ed0..558b774b 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Entry.java +++ b/src/api/java/amerifrance/guideapi/api/impl/Entry.java @@ -9,7 +9,7 @@ import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -87,23 +87,23 @@ public void drawExtras(Book book, CategoryAbstract category, int entryX, int ent } @Override - public boolean canSee(EntityPlayer player, ItemStack bookStack) { + public boolean canSee(PlayerEntity player, ItemStack bookStack) { return true; } @Override @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, EntityPlayer player, GuiCategory guiCategory) { + public void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory) { Minecraft.getMinecraft().displayGuiScreen(new GuiEntry(book, category, this, player, guiCategory.bookStack)); } @Override @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, EntityPlayer player, GuiCategory guiCategory) { + public void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory) { } @Override @SideOnly(Side.CLIENT) - public void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, EntityPlayer player, ItemStack bookStack) { + public void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, PlayerEntity player, ItemStack bookStack) { } } \ No newline at end of file diff --git a/src/main/java/amerifrance/guideapi/api/impl/Page.java b/src/api/java/amerifrance/guideapi/api/impl/Page.java similarity index 85% rename from src/main/java/amerifrance/guideapi/api/impl/Page.java rename to src/api/java/amerifrance/guideapi/api/impl/Page.java index 86b4ffdb..34a58251 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Page.java +++ b/src/api/java/amerifrance/guideapi/api/impl/Page.java @@ -6,7 +6,7 @@ import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -26,23 +26,23 @@ public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry } @Override - public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack, GuiEntry guiEntry) { + public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { return true; } @Override @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, EntityPlayer player, GuiEntry guiEntry) { + public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { } @Override @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, EntityPlayer player, GuiEntry guiEntry) { + public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { } @Override @SideOnly(Side.CLIENT) - public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack, GuiEntry guiEntry) { + public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { } public void setUnicodeFlag(boolean flag) { diff --git a/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java b/src/api/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java similarity index 94% rename from src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java rename to src/api/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java index 460774ba..c9577c4f 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java +++ b/src/api/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java @@ -8,7 +8,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.minecraft.client.renderer.RenderItem; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; @@ -139,16 +139,16 @@ public List getTooltip() { @SideOnly(Side.CLIENT) public abstract void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem); - public abstract boolean canSee(EntityPlayer player, ItemStack bookStack); + public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); @SideOnly(Side.CLIENT) - public abstract void onLeftClicked(Book book, int mouseX, int mouseY, EntityPlayer player, ItemStack bookStack); + public abstract void onLeftClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); @SideOnly(Side.CLIENT) - public abstract void onRightClicked(Book book, int mouseX, int mouseY, EntityPlayer player, ItemStack bookStack); + public abstract void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); @SideOnly(Side.CLIENT) - public abstract void onInit(Book book, GuiHome guiHome, EntityPlayer player, ItemStack bookStack); + public abstract void onInit(Book book, GuiHome guiHome, PlayerEntity player, ItemStack bookStack); @Override public boolean equals(Object o) { diff --git a/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java b/src/api/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java similarity index 90% rename from src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java rename to src/api/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java index c2a0827e..122bf408 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java +++ b/src/api/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java @@ -7,7 +7,7 @@ import amerifrance.guideapi.gui.GuiCategory; import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -64,16 +64,16 @@ public String getLocalizedName() { @SideOnly(Side.CLIENT) public abstract void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer renderer); - public abstract boolean canSee(EntityPlayer player, ItemStack bookStack); + public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); @SideOnly(Side.CLIENT) - public abstract void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, EntityPlayer player, GuiCategory guiCategory); + public abstract void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory); @SideOnly(Side.CLIENT) - public abstract void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, EntityPlayer player, GuiCategory guiCategory); + public abstract void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory); @SideOnly(Side.CLIENT) - public abstract void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, EntityPlayer player, ItemStack bookStack); + public abstract void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, PlayerEntity player, ItemStack bookStack); @Override public boolean equals(Object o) { diff --git a/src/main/java/amerifrance/guideapi/api/package-info.java b/src/api/java/amerifrance/guideapi/api/package-info.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/package-info.java rename to src/api/java/amerifrance/guideapi/api/package-info.java diff --git a/src/main/java/amerifrance/guideapi/api/util/BookHelper.java b/src/api/java/amerifrance/guideapi/api/util/BookHelper.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/util/BookHelper.java rename to src/api/java/amerifrance/guideapi/api/util/BookHelper.java diff --git a/src/main/java/amerifrance/guideapi/api/util/GuiHelper.java b/src/api/java/amerifrance/guideapi/api/util/GuiHelper.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/util/GuiHelper.java rename to src/api/java/amerifrance/guideapi/api/util/GuiHelper.java diff --git a/src/main/java/amerifrance/guideapi/api/util/NBTBookTags.java b/src/api/java/amerifrance/guideapi/api/util/NBTBookTags.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/util/NBTBookTags.java rename to src/api/java/amerifrance/guideapi/api/util/NBTBookTags.java diff --git a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java b/src/api/java/amerifrance/guideapi/api/util/PageHelper.java similarity index 100% rename from src/main/java/amerifrance/guideapi/api/util/PageHelper.java rename to src/api/java/amerifrance/guideapi/api/util/PageHelper.java diff --git a/src/main/java/amerifrance/guideapi/api/util/TextHelper.java b/src/api/java/amerifrance/guideapi/api/util/TextHelper.java similarity index 96% rename from src/main/java/amerifrance/guideapi/api/util/TextHelper.java rename to src/api/java/amerifrance/guideapi/api/util/TextHelper.java index 2f225549..01148018 100644 --- a/src/main/java/amerifrance/guideapi/api/util/TextHelper.java +++ b/src/api/java/amerifrance/guideapi/api/util/TextHelper.java @@ -13,7 +13,7 @@ public static String getFormattedText(String string) { } public static String localize(String input, Object... format) { - return I18n.translateToLocalFormatted(input, format); + return Il8n.translateToLocalFormatted(input, format); } public static String localizeEffect(String input, Object... format) { diff --git a/src/main/java/amerifrance/guideapi/gui/GuiBase.java b/src/main/java/amerifrance/guideapi/gui/GuiBase.java index d490b74b..f35c597c 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiBase.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiBase.java @@ -1,11 +1,11 @@ package amerifrance.guideapi.gui; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; @@ -15,16 +15,16 @@ import static net.minecraft.client.renderer.GlStateManager.*; -public class GuiBase extends GuiScreen { +public class GuiBase extends Screen { public int guiLeft, guiTop; public int xSize = 192; public int ySize = 192; - public EntityPlayer player; + public PlayerEntity player; public ItemStack bookStack; public float publicZLevel; - public GuiBase(EntityPlayer player, ItemStack bookStack) { + public GuiBase(PlayerEntity player, ItemStack bookStack) { this.player = player; this.bookStack = bookStack; this.publicZLevel = zLevel; diff --git a/src/main/java/amerifrance/guideapi/gui/GuiCategory.java b/src/main/java/amerifrance/guideapi/gui/GuiCategory.java index 7c73586c..0432cab4 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiCategory.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiCategory.java @@ -13,8 +13,8 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; @@ -41,7 +41,7 @@ public class GuiCategory extends GuiBase { public int entryPage; @Nullable public EntryAbstract startEntry; - public GuiCategory(Book book, CategoryAbstract category, EntityPlayer player, ItemStack bookStack, @Nullable EntryAbstract startEntry) { + public GuiCategory(Book book, CategoryAbstract category, PlayerEntity player, ItemStack bookStack, @Nullable EntryAbstract startEntry) { super(player, bookStack); this.book = book; this.category = category; @@ -155,7 +155,7 @@ public void keyTyped(char typedChar, int keyCode) { } @Override - public void actionPerformed(GuiButton button) { + public void actionPerformed(Button button) { if (button.id == 0) this.mc.displayGuiScreen(new GuiHome(book, player, bookStack)); else if (button.id == 1 && entryPage + 1 < entryWrapperMap.asMap().size()) diff --git a/src/main/java/amerifrance/guideapi/gui/GuiEntry.java b/src/main/java/amerifrance/guideapi/gui/GuiEntry.java index 886204f6..02dc5b9f 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiEntry.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiEntry.java @@ -12,8 +12,8 @@ import amerifrance.guideapi.network.PacketSyncEntry; import amerifrance.guideapi.wrapper.PageWrapper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; @@ -40,7 +40,7 @@ public class GuiEntry extends GuiBase { public ButtonSearch buttonSearch; public int pageNumber; - public GuiEntry(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack) { + public GuiEntry(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack) { super(player, bookStack); this.book = book; this.category = category; @@ -138,7 +138,7 @@ public void keyTyped(char typedChar, int keyCode) { } @Override - public void actionPerformed(GuiButton button) { + public void actionPerformed(Button button) { if (button.id == 0) this.mc.displayGuiScreen(new GuiCategory(book, category, player, bookStack, entry)); else if (button.id == 1 && pageNumber + 1 < pageWrapperList.size()) diff --git a/src/main/java/amerifrance/guideapi/gui/GuiHome.java b/src/main/java/amerifrance/guideapi/gui/GuiHome.java index 7de64895..e2bb436e 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiHome.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiHome.java @@ -10,9 +10,9 @@ import amerifrance.guideapi.wrapper.CategoryWrapper; import com.google.common.collect.HashMultimap; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; @@ -33,7 +33,7 @@ public class GuiHome extends GuiBase { public ButtonSearch buttonSearch; public int categoryPage; - public GuiHome(Book book, EntityPlayer player, ItemStack bookStack) { + public GuiHome(Book book, PlayerEntity player, ItemStack bookStack) { super(player, bookStack); this.book = book; this.pageTexture = book.getPageTexture(); @@ -126,7 +126,7 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { buttonPrev.visible = categoryPage != 0; buttonNext.visible = categoryPage != categoryWrapperMap.asMap().size() - 1 && !categoryWrapperMap.asMap().isEmpty(); - for (GuiButton button : this.buttonList) + for (Button button : this.buttonList) button.drawButton(this.mc, mouseX, mouseY, renderPartialTicks); } @@ -167,7 +167,7 @@ public void keyTyped(char typedChar, int keyCode) { } @Override - public void actionPerformed(GuiButton button) { + public void actionPerformed(Button button) { if (button.id == 0 && categoryPage + 1 < categoryWrapperMap.asMap().size()) nextPage(); else if (button.id == 1 && categoryPage > 0) diff --git a/src/main/java/amerifrance/guideapi/gui/GuiSearch.java b/src/main/java/amerifrance/guideapi/gui/GuiSearch.java index 6e578e1a..caad061a 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiSearch.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiSearch.java @@ -10,10 +10,10 @@ import amerifrance.guideapi.button.ButtonPrev; import com.google.common.base.Strings; import com.google.common.collect.Lists; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.config.GuiUtils; @@ -35,13 +35,13 @@ public class GuiSearch extends GuiBase { private ResourceLocation pageTexture; private ButtonNext buttonNext; private ButtonPrev buttonPrev; - private GuiTextField searchField; - private GuiScreen parent; + private TextFieldWidget searchField; + private Screen parent; private List>> searchResults; private int currentPage = 0; private String lastQuery = ""; - public GuiSearch(Book book, EntityPlayer player, ItemStack bookStack, GuiScreen parent) { + public GuiSearch(Book book, PlayerEntity player, ItemStack bookStack, Screen parent) { super(player, bookStack); this.book = book; @@ -62,7 +62,7 @@ public void initGui() { addButton(buttonNext = new ButtonNext(1, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this)); addButton(buttonPrev = new ButtonPrev(2, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this)); - searchField = new GuiTextField(3, fontRenderer, guiLeft + 43, guiTop + 12, 100, 10); + searchField = new TextFieldWidget(3, fontRenderer, guiLeft + 43, guiTop + 12, 100, 10); searchField.setEnableBackgroundDrawing(false); searchField.setFocused(true); searchResults = getMatches(book, null, player, bookStack); @@ -154,7 +154,7 @@ public void keyTyped(char typedChar, int keyCode) { } @Override - public void actionPerformed(GuiButton button) { + public void actionPerformed(Button button) { switch (button.id) { case 0: { mc.displayGuiScreen(parent); @@ -174,7 +174,7 @@ public void actionPerformed(GuiButton button) { } @Nonnull - static List>> getMatches(Book book, @Nullable String query, EntityPlayer player, ItemStack bookStack) { + static List>> getMatches(Book book, @Nullable String query, PlayerEntity player, ItemStack bookStack) { List> discovered = Lists.newArrayList(); for (CategoryAbstract category : book.getCategoryList()) { diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java index dd99c8db..8c9e840c 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java @@ -3,12 +3,12 @@ import amerifrance.guideapi.api.IInfoRenderer; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.util.GuiHelper; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -32,7 +32,7 @@ public InfoRendererDescription(ItemStack stack, ITextComponent description) { } @Override - public void drawInformation(Book book, World world, BlockPos pos, IBlockState state, RayTraceResult rayTrace, EntityPlayer player) { + public void drawInformation(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player) { if (tiny) { GlStateManager.pushMatrix(); GlStateManager.scale(0.5F, 0.5F, 0.5F); diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java index 23565b2c..7ec2ee4e 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java @@ -2,11 +2,11 @@ import amerifrance.guideapi.api.IInfoRenderer; import amerifrance.guideapi.api.impl.Book; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -29,9 +29,9 @@ public InfoRendererImage(ResourceLocation image, int imageX, int imageY, int ima } @Override - public void drawInformation(Book book, World world, BlockPos pos, IBlockState state, RayTraceResult rayTrace, EntityPlayer player) { + public void drawInformation(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player) { ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); Minecraft.getMinecraft().renderEngine.bindTexture(image); - Gui.drawModalRectWithCustomSizedTexture(resolution.getScaledWidth() / 2 + 20, resolution.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight); + AbstractGui.drawModalRectWithCustomSizedTexture(resolution.getScaledWidth() / 2 + 20, resolution.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight); } } diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 7bf6bf63..53a51caf 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -9,10 +9,10 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.util.TextHelper; import com.google.common.base.Strings; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag.TooltipFlags; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.*; @@ -39,42 +39,42 @@ public ItemGuideBook(@Nonnull Book book) { } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { ItemStack heldStack = player.getHeldItem(hand); BookEvent.Open event = new BookEvent.Open(book, heldStack, player); if (MinecraftForge.EVENT_BUS.post(event)) { player.sendStatusMessage(event.getCanceledText(), true); - return ActionResult.newResult(EnumActionResult.FAIL, heldStack); + return ActionResult.newResult(ActionResultType.FAIL, heldStack); } player.openGui(GuideMod.INSTANCE, GuideAPI.getIndexedBooks().indexOf(book), world, hand.ordinal(), 0, 0); - return ActionResult.newResult(EnumActionResult.SUCCESS, heldStack); + return ActionResult.newResult(ActionResultType.SUCCESS, heldStack); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + public ActionResultType onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) { if (!world.isRemote || !player.isSneaking()) - return EnumActionResult.PASS; + return ActionResultType.PASS; ItemStack stack = player.getHeldItem(hand); - IBlockState state = world.getBlockState(pos); + BlockState state = world.getBlockState(pos); if (state.getBlock() instanceof IGuideLinked) { IGuideLinked guideLinked = (IGuideLinked) state.getBlock(); ResourceLocation entryKey = guideLinked.getLinkedEntry(world, pos, player, stack); if (entryKey == null) - return EnumActionResult.FAIL; + return ActionResultType.FAIL; for (CategoryAbstract category : book.getCategoryList()) { if (category.entries.containsKey(entryKey)) { GuideMod.PROXY.openEntry(book, category, category.entries.get(entryKey), player, stack); - return EnumActionResult.SUCCESS; + return ActionResultType.SUCCESS; } } } - return EnumActionResult.PASS; + return ActionResultType.PASS; } @Override diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java index c1593e52..79607ec8 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java @@ -4,7 +4,7 @@ import amerifrance.guideapi.api.util.NBTBookTags; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; @@ -45,7 +45,7 @@ public IMessage onMessage(PacketSyncCategory message, MessageContext ctx) { if (!book.isEmpty() && book.getItem() instanceof IGuideItem) { if (message.category != -1 && message.page != -1) { if (!book.hasTagCompound()) - book.setTagCompound(new NBTTagCompound()); + book.setTagCompound(new CompoundNBT()); book.getTagCompound().setInteger(NBTBookTags.CATEGORY_TAG, message.category); book.getTagCompound().setInteger(NBTBookTags.ENTRY_PAGE_TAG, message.page); diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java index 69952189..4d2f9a77 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java @@ -4,7 +4,7 @@ import amerifrance.guideapi.api.util.NBTBookTags; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -52,7 +52,7 @@ public IMessage onMessage(PacketSyncEntry message, MessageContext ctx) { if (!book.isEmpty() && book.getItem() instanceof IGuideItem) { if (message.category != -1 && !message.entry.equals(new ResourceLocation("guideapi", "none")) && message.page != -1) { if (!book.hasTagCompound()) - book.setTagCompound(new NBTTagCompound()); + book.setTagCompound(new CompoundNBT()); book.getTagCompound().setInteger(NBTBookTags.CATEGORY_TAG, message.category); book.getTagCompound().setString(NBTBookTags.ENTRY_TAG, message.entry.toString()); diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java index 94ff2077..552fc3f3 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java @@ -4,7 +4,7 @@ import amerifrance.guideapi.api.util.NBTBookTags; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; @@ -39,7 +39,7 @@ public IMessage onMessage(PacketSyncHome message, MessageContext ctx) { if (!book.isEmpty() && book.getItem() instanceof IGuideItem && message.page != -1) { if (!book.hasTagCompound()) - book.setTagCompound(new NBTTagCompound()); + book.setTagCompound(new CompoundNBT()); book.getTagCompound().setInteger(NBTBookTags.CATEGORY_PAGE_TAG, message.page); book.getTagCompound().removeTag(NBTBookTags.CATEGORY_TAG); book.getTagCompound().removeTag(NBTBookTags.ENTRY_TAG); diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 50129454..c0ceca32 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -8,8 +8,8 @@ import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; +import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.brewing.BrewingRecipe; diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java index f37b2242..51715b59 100644 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java @@ -9,8 +9,8 @@ import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 60412c9d..9b934517 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -13,7 +13,7 @@ import amerifrance.guideapi.page.reciperenderer.ShapelessRecipesRenderer; import amerifrance.guideapi.util.LogHelper; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; @@ -74,7 +74,7 @@ public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry } @Override - public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack, GuiEntry guiEntry) { + public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { return isValid; } diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index a189bdf7..974c3f39 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -7,7 +7,7 @@ import amerifrance.guideapi.gui.GuiBase; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.init.Blocks; +import net.minecraft.block.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/main/java/amerifrance/guideapi/page/PageSound.java b/src/main/java/amerifrance/guideapi/page/PageSound.java index ff761a3e..3bfc9f11 100644 --- a/src/main/java/amerifrance/guideapi/page/PageSound.java +++ b/src/main/java/amerifrance/guideapi/page/PageSound.java @@ -9,7 +9,7 @@ import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundEvent; import net.minecraftforge.fml.relauncher.Side; @@ -42,20 +42,20 @@ public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry } @Override - public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, EntityPlayer player, ItemStack bookStack, GuiEntry guiEntry) { + public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { return pageToEmulate.canSee(book, category, entry, player, bookStack, guiEntry); } @Override @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, EntityPlayer player, GuiEntry guiEntry) { + public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { GuideMod.PROXY.playSound(sound); pageToEmulate.onLeftClicked(book, category, entry, mouseX, mouseY, player, guiEntry); } @Override @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, EntityPlayer player, GuiEntry guiEntry) { + public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { pageToEmulate.onRightClicked(book, category, entry, mouseX, mouseY, player, guiEntry); } diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index 2122c622..a47d7ef8 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -9,7 +9,7 @@ import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundEvent; import net.minecraftforge.common.MinecraftForge; @@ -22,7 +22,7 @@ public void playSound(SoundEvent sound) { } @Override - public void openEntry(Book book, CategoryAbstract categoryAbstract, EntryAbstract entryAbstract, EntityPlayer player, ItemStack stack) { + public void openEntry(Book book, CategoryAbstract categoryAbstract, EntryAbstract entryAbstract, PlayerEntity player, ItemStack stack) { BookEvent.Open event = new BookEvent.Open(book, stack, player); if (MinecraftForge.EVENT_BUS.post(event)) { player.sendStatusMessage(event.getCanceledText(), true); diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index 4d9c6c71..e78b6f32 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -9,10 +9,10 @@ import amerifrance.guideapi.gui.GuiCategory; import amerifrance.guideapi.gui.GuiEntry; import amerifrance.guideapi.gui.GuiHome; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumHand; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.world.World; @@ -21,19 +21,19 @@ public class CommonProxy implements IGuiHandler { @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + public Object getServerGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) { return null; } @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - ItemStack bookStack = player.getHeldItem(EnumHand.values()[x]); + public Object getClientGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) { + ItemStack bookStack = player.getHeldItem(Hand.values()[x]); if (!bookStack.isEmpty() && bookStack.getItem() instanceof IGuideItem) { Book book = GuideAPI.getIndexedBooks().get(ID); try { if (bookStack.hasTagCompound()) { - NBTTagCompound tagCompound = bookStack.getTagCompound(); + CompoundNBT tagCompound = bookStack.getTagCompound(); if (tagCompound.hasKey(NBTBookTags.ENTRY_TAG) && tagCompound.hasKey(NBTBookTags.CATEGORY_TAG)) { CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG)); EntryAbstract entry = category.entries.get(new ResourceLocation(tagCompound.getString(NBTBookTags.ENTRY_TAG))); @@ -67,7 +67,7 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int public void playSound(SoundEvent sound) { } - public void openEntry(Book book, CategoryAbstract categoryAbstract, EntryAbstract entryAbstract, EntityPlayer player, ItemStack stack) { + public void openEntry(Book book, CategoryAbstract categoryAbstract, EntryAbstract entryAbstract, PlayerEntity player, ItemStack stack) { } public void initColors() { diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 09650f02..92ea97fa 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -15,8 +15,8 @@ import amerifrance.guideapi.page.PageText; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.block.Blocks; +import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 1e9ffbce..12191e52 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -7,9 +7,9 @@ import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.init.PotionTypes; +import net.minecraft.block.Blocks; +import net.minecraft.item.Items; +import net.minecraft.potion.Potions; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.potion.PotionUtils; @@ -42,9 +42,9 @@ public Book buildBook() { testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.PLANKS, 1, 4))); testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe( - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), + PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.AWKWARD), new ItemStack(Items.SPECKLED_MELON), - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.HEALING))) + PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); book.addCategory(testCategory); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook3.java b/src/main/java/amerifrance/guideapi/test/TestBook3.java index 1f460fa3..62758d5f 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook3.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook3.java @@ -11,13 +11,13 @@ import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.init.PotionTypes; +import net.minecraft.block.Blocks; +import net.minecraft.item.Items; +import net.minecraft.potion.Potions; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionUtils; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.brewing.BrewingRecipe; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -48,9 +48,9 @@ public Book buildBook() { testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.PLANKS, 1, 4))); testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe( - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), + PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.AWKWARD), new ItemStack(Items.SPECKLED_MELON), - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.HEALING))) + PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); binder.addCategory(testCategory); @@ -61,7 +61,7 @@ public Book buildBook() { @SubscribeEvent public void onBookOpen(BookEvent.Open event) { if (event.getBook() == book && event.getPlayer().isSneaking()) { - event.setCanceledText(new TextComponentString("No snek allowed")); + event.setCanceledText(new StringTextComponent("No snek allowed")); event.setCanceled(true); } } diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index a7e3194e..428891c1 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -12,14 +12,14 @@ import com.google.common.base.Strings; import com.google.common.collect.Multimap; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumHand; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; @@ -39,9 +39,9 @@ public class EventHandler { @SubscribeEvent public static void onPlayerJoinWorld(EntityJoinWorldEvent event) { - if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.getEntity(); - NBTTagCompound tag = getModTag(player, GuideMod.ID); + if (!event.getEntity().world.isRemote && event.getEntity() instanceof PlayerEntity) { + PlayerEntity player = (PlayerEntity) event.getEntity(); + CompoundNBT tag = getModTag(player, GuideMod.ID); if (ConfigHandler.canSpawnWithBooks) { for (Book book : GuideAPI.getBooks().values()) { if (ConfigHandler.SPAWN_BOOKS.getOrDefault(book, false) && !tag.getBoolean("hasInitial" + book.getTitle())) { @@ -63,11 +63,11 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { if (rayTrace == null || rayTrace.typeOfHit != RayTraceResult.Type.BLOCK) return; - EntityPlayer player = Minecraft.getMinecraft().player; + PlayerEntity player = Minecraft.getMinecraft().player; World world = Minecraft.getMinecraft().world; ItemStack held = ItemStack.EMPTY; Book book = null; - for (EnumHand hand : EnumHand.values()) { + for (Hand hand : Hand.values()) { ItemStack heldStack = player.getHeldItem(hand); if (heldStack.getItem() instanceof IGuideItem) { held = heldStack; @@ -79,7 +79,7 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { if (book == null) return; - IBlockState state = world.getBlockState(rayTrace.getBlockPos()); + BlockState state = world.getBlockState(rayTrace.getBlockPos()); String linkedEntry = null; if (state.getBlock() instanceof IGuideLinked) { IGuideLinked linked = (IGuideLinked) state.getBlock(); @@ -123,22 +123,22 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { renderer.drawInformation(book, world, rayTrace.getBlockPos(), state, rayTrace, player); } - public static NBTTagCompound getModTag(EntityPlayer player, String modName) { - NBTTagCompound tag = player.getEntityData(); - NBTTagCompound persistTag; + public static CompoundNBT getModTag(PlayerEntity player, String modName) { + CompoundNBT tag = player.getEntityData(); + CompoundNBT persistTag; - if (tag.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) - persistTag = tag.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + if (tag.hasKey(PlayerEntity.PERSISTED_NBT_TAG)) + persistTag = tag.getCompoundTag(PlayerEntity.PERSISTED_NBT_TAG); else { - persistTag = new NBTTagCompound(); - tag.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag); + persistTag = new CompoundNBT(); + tag.setTag(PlayerEntity.PERSISTED_NBT_TAG, persistTag); } - NBTTagCompound modTag; + CompoundNBT modTag; if (persistTag.hasKey(modName)) { modTag = persistTag.getCompoundTag(modName); } else { - modTag = new NBTTagCompound(); + modTag = new CompoundNBT(); persistTag.setTag(modName, modTag); } return modTag; diff --git a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java index 745c3746..1ce8312b 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java @@ -6,7 +6,7 @@ import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.RenderItem; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; public class CategoryWrapper extends AbstractWrapper { @@ -14,13 +14,13 @@ public class CategoryWrapper extends AbstractWrapper { public Book book; public CategoryAbstract category; public int x, y, width, height; - public EntityPlayer player; + public PlayerEntity player; public FontRenderer renderer; public RenderItem renderItem; public boolean drawOnLeft; public ItemStack bookStack; - public CategoryWrapper(Book book, CategoryAbstract category, int x, int y, int width, int height, EntityPlayer player, FontRenderer renderer, RenderItem renderItem, boolean drawOnLeft, ItemStack bookStack) { + public CategoryWrapper(Book book, CategoryAbstract category, int x, int y, int width, int height, PlayerEntity player, FontRenderer renderer, RenderItem renderItem, boolean drawOnLeft, ItemStack bookStack) { this.book = book; this.category = category; this.x = x; diff --git a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java index 33cbe96f..5ef8dce2 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java @@ -8,7 +8,7 @@ import amerifrance.guideapi.gui.GuiCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; public class EntryWrapper extends AbstractWrapper { @@ -17,12 +17,12 @@ public class EntryWrapper extends AbstractWrapper { public CategoryAbstract category; public EntryAbstract entry; public int x, y, width, height; - public EntityPlayer player; + public PlayerEntity player; public FontRenderer renderer; public GuiCategory categoryGui; public ItemStack bookStack; - public EntryWrapper(GuiCategory categoryGui, Book book, CategoryAbstract category, EntryAbstract entry, int x, int y, int width, int height, EntityPlayer player, FontRenderer renderer, ItemStack bookStack) { + public EntryWrapper(GuiCategory categoryGui, Book book, CategoryAbstract category, EntryAbstract entry, int x, int y, int width, int height, PlayerEntity player, FontRenderer renderer, ItemStack bookStack) { this.book = book; this.category = category; this.entry = entry; diff --git a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java index 3aaef696..5a68ec6b 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java @@ -8,7 +8,7 @@ import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; public class PageWrapper extends AbstractWrapper { @@ -19,11 +19,11 @@ public class PageWrapper extends AbstractWrapper { public EntryAbstract entry; public IPage page; public int guiLeft, guiTop; - public EntityPlayer player; + public PlayerEntity player; public FontRenderer renderer; public ItemStack bookStack; - public PageWrapper(GuiEntry guiEntry, Book book, CategoryAbstract category, EntryAbstract entry, IPage page, int guiLeft, int guiTop, EntityPlayer player, FontRenderer renderer, ItemStack bookStack) { + public PageWrapper(GuiEntry guiEntry, Book book, CategoryAbstract category, EntryAbstract entry, IPage page, int guiLeft, int guiTop, PlayerEntity player, FontRenderer renderer, ItemStack bookStack) { this.guiEntry = guiEntry; this.book = book; this.category = category; From 9dafec7d8613a6c1b5704005a263244586b99a7b Mon Sep 17 00:00:00 2001 From: Maxanier Date: Fri, 20 Mar 2020 23:41:24 +0100 Subject: [PATCH 02/28] Changes --- build.gradle | 29 ++----------------- .../amerifrance/guideapi/ConfigHandler.java | 4 +-- .../java/amerifrance/guideapi/GuideMod.java | 6 ++-- .../guideapi/RegistrarGuideAPI.java | 12 ++++---- .../guideapi/button/ButtonBack.java | 7 ++--- .../guideapi/button/ButtonNext.java | 7 ++--- .../guideapi/button/ButtonPrev.java | 7 ++--- .../guideapi/button/ButtonSearch.java | 9 +++--- .../guideapi/category/CategoryItemStack.java | 10 +++---- .../category/CategoryResourceLocation.java | 10 +++---- .../guideapi/entry/EntryItemStack.java | 10 +++---- .../guideapi/entry/EntryResourceLocation.java | 10 +++---- .../amerifrance/guideapi/gui/GuiBase.java | 2 -- .../amerifrance/guideapi/gui/GuiCategory.java | 8 ++--- .../amerifrance/guideapi/gui/GuiEntry.java | 10 +++---- .../amerifrance/guideapi/gui/GuiHome.java | 6 ++-- .../amerifrance/guideapi/gui/GuiSearch.java | 10 +++---- .../info/InfoRendererDescription.java | 7 ++--- .../guideapi/info/InfoRendererImage.java | 4 +-- .../guideapi/item/ItemGuideBook.java | 14 ++++----- .../guideapi/network/PacketSyncCategory.java | 4 +-- .../guideapi/network/PacketSyncEntry.java | 4 +-- .../guideapi/network/PacketSyncHome.java | 4 +-- .../guideapi/page/PageBrewingRecipe.java | 16 +++++----- .../guideapi/page/PageFurnaceRecipe.java | 14 ++++----- .../guideapi/page/PageIRecipe.java | 10 +++---- .../amerifrance/guideapi/page/PageImage.java | 12 ++++---- .../guideapi/page/PageItemStack.java | 8 ++--- .../amerifrance/guideapi/page/PageSound.java | 12 ++++---- .../amerifrance/guideapi/page/PageText.java | 10 +++---- .../guideapi/page/PageTextImage.java | 10 +++---- .../reciperenderer/BasicRecipeRenderer.java | 14 ++++----- .../reciperenderer/ShapedRecipesRenderer.java | 8 ++--- .../ShapelessRecipesRenderer.java | 10 +++---- .../guideapi/proxy/ClientProxy.java | 12 ++++---- .../guideapi/proxy/CommonProxy.java | 12 ++++---- .../amerifrance/guideapi/test/TestBook.java | 14 ++++----- .../amerifrance/guideapi/test/TestBook2.java | 8 ++--- .../amerifrance/guideapi/test/TestBook3.java | 12 ++++---- .../amerifrance/guideapi/util/APISetter.java | 4 +-- .../guideapi/util/AnnotationHandler.java | 8 ++--- .../guideapi/util/EventHandler.java | 14 ++++----- .../guideapi/wrapper/CategoryWrapper.java | 6 ++-- .../guideapi/wrapper/EntryWrapper.java | 8 ++--- .../guideapi/wrapper/PageWrapper.java | 8 ++--- .../guideapi => main/java}/api/BookEvent.java | 4 +-- .../guideapi => main/java}/api/GuideAPI.java | 4 +-- .../guideapi => main/java}/api/GuideBook.java | 2 +- .../java}/api/IGuideBook.java | 4 +-- .../java}/api/IGuideItem.java | 4 +-- .../java}/api/IGuideLinked.java | 2 +- .../java}/api/IInfoRenderer.java | 6 ++-- .../guideapi => main/java}/api/IPage.java | 8 ++--- .../java}/api/IRecipeRenderer.java | 8 ++--- .../java}/api/SubTexture.java | 2 +- .../java}/api/button/ButtonGuideAPI.java | 2 +- .../guideapi => main/java}/api/impl/Book.java | 6 ++-- .../java}/api/impl/BookBinder.java | 4 +-- .../java}/api/impl/Category.java | 8 ++--- .../java}/api/impl/Entry.java | 10 +++---- .../guideapi => main/java}/api/impl/Page.java | 10 +++---- .../impl/abstraction/CategoryAbstract.java | 18 +++++------- .../api/impl/abstraction/EntryAbstract.java | 20 ++++++------- .../java}/api/package-info.java | 2 +- .../java}/api/util/BookHelper.java | 8 ++--- .../java}/api/util/GuiHelper.java | 2 +- .../java}/api/util/NBTBookTags.java | 2 +- .../java}/api/util/PageHelper.java | 6 ++-- .../java}/api/util/TextHelper.java | 2 +- 69 files changed, 255 insertions(+), 313 deletions(-) rename src/{api/java/amerifrance/guideapi => main/java}/api/BookEvent.java (96%) rename src/{api/java/amerifrance/guideapi => main/java}/api/GuideAPI.java (97%) rename src/{api/java/amerifrance/guideapi => main/java}/api/GuideBook.java (92%) rename src/{api/java/amerifrance/guideapi => main/java}/api/IGuideBook.java (94%) rename src/{api/java/amerifrance/guideapi => main/java}/api/IGuideItem.java (58%) rename src/{api/java/amerifrance/guideapi => main/java}/api/IGuideLinked.java (95%) rename src/{api/java/amerifrance/guideapi => main/java}/api/IInfoRenderer.java (91%) rename src/{api/java/amerifrance/guideapi => main/java}/api/IPage.java (86%) rename src/{api/java/amerifrance/guideapi => main/java}/api/IRecipeRenderer.java (85%) rename src/{api/java/amerifrance/guideapi => main/java}/api/SubTexture.java (99%) rename src/{api/java/amerifrance/guideapi => main/java}/api/button/ButtonGuideAPI.java (88%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/Book.java (98%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/BookBinder.java (98%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/Category.java (86%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/Entry.java (93%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/Page.java (85%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/abstraction/CategoryAbstract.java (93%) rename src/{api/java/amerifrance/guideapi => main/java}/api/impl/abstraction/EntryAbstract.java (87%) rename src/{api/java/amerifrance/guideapi => main/java}/api/package-info.java (78%) rename src/{api/java/amerifrance/guideapi => main/java}/api/util/BookHelper.java (73%) rename src/{api/java/amerifrance/guideapi => main/java}/api/util/GuiHelper.java (99%) rename src/{api/java/amerifrance/guideapi => main/java}/api/util/NBTBookTags.java (91%) rename src/{api/java/amerifrance/guideapi => main/java}/api/util/PageHelper.java (96%) rename src/{api/java/amerifrance/guideapi => main/java}/api/util/TextHelper.java (98%) diff --git a/build.gradle b/build.gradle index 7739d720..0d8d1a37 100644 --- a/build.gradle +++ b/build.gradle @@ -47,17 +47,7 @@ dependencies { runtimeOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}:${project.jei_version}") //Full for runtime } -sourceSets { - api - main { - compileClasspath += sourceSets.api.output - runtimeClasspath += sourceSets.api.output - } -} -configurations { - apiCompile.extendsFrom(compile) -} minecraft { @@ -73,9 +63,8 @@ minecraft { workingDirectory project.file('run/client1').canonicalPath mods { - vampirism { + guideapi { source sourceSets.main - source sourceSets.api } } @@ -86,12 +75,10 @@ minecraft { workingDirectory project.file('run/server').canonicalPath mods { - vampirism { + guideapi { source sourceSets.main - source sourceSets.api } - } } } @@ -119,9 +106,7 @@ jar { includeEmptyDirs = false from sourceSets.main.output.classesDirs - from sourceSets.api.output.classesDirs from sourceSets.main.output.resourcesDir - from sourceSets.api.output.resourcesDir classifier = '' manifest.mainAttributes( @@ -133,15 +118,7 @@ jar { exclude 'amerifrance/guideapi/test/**/*' } -// API jar -task apiJar(type: Jar) { - from sourceSets.main.allSource - from sourceSets.main.output - include 'amerifrance/guideapi/api/**/*' - classifier = 'api' -} -tasks.build.dependsOn apiJar tasks.withType(JavaCompile) { task -> task.options.encoding = 'UTF-8' @@ -152,7 +129,6 @@ publishing { publications { mavenJava(MavenPublication) { artifact jar - artifact apiJar } } repositories { @@ -200,7 +176,6 @@ curseforge { changelog = getChangelogText() releaseType = 'beta' - addArtifact apiJar } } diff --git a/src/main/java/amerifrance/guideapi/ConfigHandler.java b/src/main/java/amerifrance/guideapi/ConfigHandler.java index e2e6c16e..c70f8176 100644 --- a/src/main/java/amerifrance/guideapi/ConfigHandler.java +++ b/src/main/java/amerifrance/guideapi/ConfigHandler.java @@ -1,7 +1,7 @@ package amerifrance.guideapi; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.impl.Book; +import api.GuideAPI; +import api.impl.Book; import com.google.common.collect.Maps; import net.minecraftforge.common.config.Configuration; diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index ce707df2..152d3336 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -1,8 +1,8 @@ package amerifrance.guideapi; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.IGuideBook; -import amerifrance.guideapi.api.impl.Book; +import api.GuideAPI; +import api.IGuideBook; +import api.impl.Book; import amerifrance.guideapi.network.PacketHandler; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index 3e035056..27f17a8d 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -1,11 +1,11 @@ package amerifrance.guideapi; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.IGuideBook; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.GuideAPI; +import api.IGuideBook; +import api.IPage; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.item.ItemGuideBook; import amerifrance.guideapi.page.PageJsonRecipe; import amerifrance.guideapi.util.APISetter; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonBack.java b/src/main/java/amerifrance/guideapi/button/ButtonBack.java index d08f1114..89fd5ec6 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonBack.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonBack.java @@ -1,12 +1,11 @@ package amerifrance.guideapi.button; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.button.ButtonGuideAPI; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.button.ButtonGuideAPI; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonNext.java b/src/main/java/amerifrance/guideapi/button/ButtonNext.java index ca9f2244..46f57233 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonNext.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonNext.java @@ -1,12 +1,11 @@ package amerifrance.guideapi.button; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.button.ButtonGuideAPI; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.button.ButtonGuideAPI; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java index 50e9f738..8df20e93 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java @@ -1,12 +1,11 @@ package amerifrance.guideapi.button; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.button.ButtonGuideAPI; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.button.ButtonGuideAPI; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java index 2183af1f..ac8b82a3 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java @@ -1,12 +1,11 @@ package amerifrance.guideapi.button; -import amerifrance.guideapi.api.SubTexture; -import amerifrance.guideapi.api.button.ButtonGuideAPI; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.SubTexture; +import api.button.ButtonGuideAPI; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import java.util.ArrayList; diff --git a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java index 9d6aba3e..92ca541f 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java @@ -1,16 +1,14 @@ package amerifrance.guideapi.category; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Category; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.Category; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Map; diff --git a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java index 79ef78b8..09435e61 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java @@ -1,15 +1,13 @@ package amerifrance.guideapi.category; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Category; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.Category; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderItem; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Map; diff --git a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java index a401355f..20ce0c07 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.entry; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Entry; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.IPage; +import api.impl.Book; +import api.impl.Entry; +import api.impl.abstraction.CategoryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java index 7d5ade2b..bff3496e 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.entry; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Entry; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.IPage; +import api.impl.Book; +import api.impl.Entry; +import api.impl.abstraction.CategoryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/gui/GuiBase.java b/src/main/java/amerifrance/guideapi/gui/GuiBase.java index f35c597c..4f93e3ba 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiBase.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiBase.java @@ -7,13 +7,11 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import java.awt.Color; import java.util.List; -import static net.minecraft.client.renderer.GlStateManager.*; public class GuiBase extends Screen { diff --git a/src/main/java/amerifrance/guideapi/gui/GuiCategory.java b/src/main/java/amerifrance/guideapi/gui/GuiCategory.java index 0432cab4..44018810 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiCategory.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiCategory.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.gui; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.button.ButtonBack; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; @@ -18,8 +18,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import java.awt.Color; import java.io.IOException; diff --git a/src/main/java/amerifrance/guideapi/gui/GuiEntry.java b/src/main/java/amerifrance/guideapi/gui/GuiEntry.java index 02dc5b9f..54523e86 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiEntry.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiEntry.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.gui; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.IPage; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.button.ButtonBack; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; @@ -17,8 +17,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import java.awt.Color; import java.io.IOException; diff --git a/src/main/java/amerifrance/guideapi/gui/GuiHome.java b/src/main/java/amerifrance/guideapi/gui/GuiHome.java index e2bb436e..e1a21940 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiHome.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiHome.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.gui; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; import amerifrance.guideapi.button.ButtonSearch; @@ -16,8 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import java.awt.Color; import java.io.IOException; diff --git a/src/main/java/amerifrance/guideapi/gui/GuiSearch.java b/src/main/java/amerifrance/guideapi/gui/GuiSearch.java index caad061a..29bde351 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiSearch.java +++ b/src/main/java/amerifrance/guideapi/gui/GuiSearch.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.gui; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.button.ButtonBack; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; @@ -18,8 +18,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.config.GuiUtils; import org.apache.commons.lang3.tuple.Pair; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java index 8c9e840c..a0b26004 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java @@ -1,13 +1,12 @@ package amerifrance.guideapi.info; -import amerifrance.guideapi.api.IInfoRenderer; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.util.GuiHelper; +import api.IInfoRenderer; +import api.impl.Book; +import api.util.GuiHelper; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java index 7ec2ee4e..b34d03f7 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.info; -import amerifrance.guideapi.api.IInfoRenderer; -import amerifrance.guideapi.api.impl.Book; +import api.IInfoRenderer; +import api.impl.Book; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 53a51caf..bb89f323 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -1,13 +1,13 @@ package amerifrance.guideapi.item; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.BookEvent; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.IGuideLinked; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.util.TextHelper; +import api.BookEvent; +import api.GuideAPI; +import api.IGuideItem; +import api.IGuideLinked; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.util.TextHelper; import com.google.common.base.Strings; import net.minecraft.block.BlockState; import net.minecraft.client.util.ITooltipFlag; diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java index 79607ec8..9be201d6 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.network; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.util.NBTBookTags; +import api.IGuideItem; +import api.util.NBTBookTags; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java index 4d2f9a77..d84e6444 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.network; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.util.NBTBookTags; +import api.IGuideItem; +import api.util.NBTBookTags; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java index 552fc3f3..9e2a4070 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.network; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.util.NBTBookTags; +import api.IGuideItem; +import api.util.NBTBookTags; import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index c0ceca32..af8a889b 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -1,20 +1,18 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.SubTexture; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.SubTexture; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.brewing.BrewingRecipe; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java index 51715b59..82f4d410 100644 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java @@ -1,12 +1,12 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.SubTexture; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.SubTexture; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.block.Block; import net.minecraft.block.Blocks; diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 9b934517..c78e7650 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.IRecipeRenderer; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.IRecipeRenderer; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiEntry; import amerifrance.guideapi.page.reciperenderer.ShapedOreRecipeRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/PageImage.java b/src/main/java/amerifrance/guideapi/page/PageImage.java index e133b1c9..f1ddacde 100644 --- a/src/main/java/amerifrance/guideapi/page/PageImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageImage.java @@ -1,16 +1,14 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public class PageImage extends Page { diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index 974c3f39..417d7c74 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/PageSound.java b/src/main/java/amerifrance/guideapi/page/PageSound.java index 3bfc9f11..b040649f 100644 --- a/src/main/java/amerifrance/guideapi/page/PageSound.java +++ b/src/main/java/amerifrance/guideapi/page/PageSound.java @@ -1,19 +1,17 @@ package amerifrance.guideapi.page; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.IPage; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public class PageSound extends Page { diff --git a/src/main/java/amerifrance/guideapi/page/PageText.java b/src/main/java/amerifrance/guideapi/page/PageText.java index 078fb600..7982e202 100644 --- a/src/main/java/amerifrance/guideapi/page/PageText.java +++ b/src/main/java/amerifrance/guideapi/page/PageText.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.PageHelper; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.PageHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/amerifrance/guideapi/page/PageTextImage.java b/src/main/java/amerifrance/guideapi/page/PageTextImage.java index a8f51927..fcf141c7 100644 --- a/src/main/java/amerifrance/guideapi/page/PageTextImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageTextImage.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.Page; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java index ddf74344..23be4441 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java @@ -1,12 +1,12 @@ package amerifrance.guideapi.page.reciperenderer; -import amerifrance.guideapi.api.IRecipeRenderer.RecipeRendererBase; -import amerifrance.guideapi.api.SubTexture; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.IRecipeRenderer.RecipeRendererBase; +import api.SubTexture; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import com.google.common.base.Strings; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index 36e5591b..b3c3781e 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.page.reciperenderer; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index 10733a3b..a99a78c0 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page.reciperenderer; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index a47d7ef8..0989ba40 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -1,11 +1,11 @@ package amerifrance.guideapi.proxy; -import amerifrance.guideapi.api.BookEvent; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.BookEvent; +import api.GuideAPI; +import api.IGuideItem; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index e78b6f32..73c31602 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -1,11 +1,11 @@ package amerifrance.guideapi.proxy; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.NBTBookTags; +import api.GuideAPI; +import api.IGuideItem; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.NBTBookTags; import amerifrance.guideapi.gui.GuiCategory; import amerifrance.guideapi.gui.GuiEntry; import amerifrance.guideapi.gui.GuiHome; diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 92ea97fa..78df4bd0 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -1,12 +1,12 @@ package amerifrance.guideapi.test; -import amerifrance.guideapi.api.GuideBook; -import amerifrance.guideapi.api.IGuideBook; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Entry; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.GuideBook; +import api.IGuideBook; +import api.IPage; +import api.impl.Book; +import api.impl.Entry; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.PageFurnaceRecipe; diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 12191e52..f1dd8863 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.test; -import amerifrance.guideapi.api.GuideBook; -import amerifrance.guideapi.api.IGuideBook; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import api.GuideBook; +import api.IGuideBook; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; diff --git a/src/main/java/amerifrance/guideapi/test/TestBook3.java b/src/main/java/amerifrance/guideapi/test/TestBook3.java index 62758d5f..5adcb6f5 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook3.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook3.java @@ -1,12 +1,12 @@ package amerifrance.guideapi.test; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.BookEvent; -import amerifrance.guideapi.api.GuideBook; -import amerifrance.guideapi.api.IGuideBook; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.BookBinder; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import api.BookEvent; +import api.GuideBook; +import api.IGuideBook; +import api.impl.Book; +import api.impl.BookBinder; +import api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; diff --git a/src/main/java/amerifrance/guideapi/util/APISetter.java b/src/main/java/amerifrance/guideapi/util/APISetter.java index 86b53c95..c8f06786 100644 --- a/src/main/java/amerifrance/guideapi/util/APISetter.java +++ b/src/main/java/amerifrance/guideapi/util/APISetter.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.util; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.impl.Book; +import api.GuideAPI; +import api.impl.Book; import com.google.common.base.Throwables; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java index 93b12dfd..e2203d15 100644 --- a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java +++ b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.util; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.GuideBook; -import amerifrance.guideapi.api.IGuideBook; -import amerifrance.guideapi.api.impl.Book; +import api.GuideAPI; +import api.GuideBook; +import api.IGuideBook; +import api.impl.Book; import com.google.common.collect.Lists; import net.minecraftforge.fml.common.discovery.ASMDataTable; import net.minecraftforge.fml.common.discovery.asm.ModAnnotation; diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index 428891c1..5de2071f 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -2,13 +2,13 @@ import amerifrance.guideapi.ConfigHandler; import amerifrance.guideapi.GuideMod; -import amerifrance.guideapi.api.GuideAPI; -import amerifrance.guideapi.api.IGuideItem; -import amerifrance.guideapi.api.IGuideLinked; -import amerifrance.guideapi.api.IInfoRenderer; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.util.TextHelper; +import api.GuideAPI; +import api.IGuideItem; +import api.IGuideLinked; +import api.IInfoRenderer; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.util.TextHelper; import com.google.common.base.Strings; import com.google.common.collect.Multimap; import net.minecraft.block.Block; diff --git a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java index 1ce8312b..d61b501b 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.wrapper; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.RenderItem; diff --git a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java index 5ef8dce2..9a8d2b6d 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.wrapper; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiCategory; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java index 5a68ec6b..e19843da 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.wrapper; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.IPage; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.Minecraft; diff --git a/src/api/java/amerifrance/guideapi/api/BookEvent.java b/src/main/java/api/BookEvent.java similarity index 96% rename from src/api/java/amerifrance/guideapi/api/BookEvent.java rename to src/main/java/api/BookEvent.java index a92ad2ff..07d0db15 100644 --- a/src/api/java/amerifrance/guideapi/api/BookEvent.java +++ b/src/main/java/api/BookEvent.java @@ -1,6 +1,6 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; +import api.impl.Book; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; diff --git a/src/api/java/amerifrance/guideapi/api/GuideAPI.java b/src/main/java/api/GuideAPI.java similarity index 97% rename from src/api/java/amerifrance/guideapi/api/GuideAPI.java rename to src/main/java/api/GuideAPI.java index 7eb5bf37..fa9ee88e 100644 --- a/src/api/java/amerifrance/guideapi/api/GuideAPI.java +++ b/src/main/java/api/GuideAPI.java @@ -1,6 +1,6 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; +import api.impl.Book; import com.google.common.collect.*; import net.minecraft.block.Block; import net.minecraft.client.renderer.model.ModelResourceLocation; diff --git a/src/api/java/amerifrance/guideapi/api/GuideBook.java b/src/main/java/api/GuideBook.java similarity index 92% rename from src/api/java/amerifrance/guideapi/api/GuideBook.java rename to src/main/java/api/GuideBook.java index 97890413..a88959bd 100644 --- a/src/api/java/amerifrance/guideapi/api/GuideBook.java +++ b/src/main/java/api/GuideBook.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api; +package api; import net.minecraftforge.eventbus.api.EventPriority; diff --git a/src/api/java/amerifrance/guideapi/api/IGuideBook.java b/src/main/java/api/IGuideBook.java similarity index 94% rename from src/api/java/amerifrance/guideapi/api/IGuideBook.java rename to src/main/java/api/IGuideBook.java index d4b8e11d..401c6b90 100644 --- a/src/api/java/amerifrance/guideapi/api/IGuideBook.java +++ b/src/main/java/api/IGuideBook.java @@ -1,6 +1,6 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; +import api.impl.Book; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.api.distmarker.Dist; diff --git a/src/api/java/amerifrance/guideapi/api/IGuideItem.java b/src/main/java/api/IGuideItem.java similarity index 58% rename from src/api/java/amerifrance/guideapi/api/IGuideItem.java rename to src/main/java/api/IGuideItem.java index 60c55150..1ed345e7 100644 --- a/src/api/java/amerifrance/guideapi/api/IGuideItem.java +++ b/src/main/java/api/IGuideItem.java @@ -1,6 +1,6 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; +import api.impl.Book; import net.minecraft.item.ItemStack; public interface IGuideItem { diff --git a/src/api/java/amerifrance/guideapi/api/IGuideLinked.java b/src/main/java/api/IGuideLinked.java similarity index 95% rename from src/api/java/amerifrance/guideapi/api/IGuideLinked.java rename to src/main/java/api/IGuideLinked.java index f1a3a772..b7850284 100644 --- a/src/api/java/amerifrance/guideapi/api/IGuideLinked.java +++ b/src/main/java/api/IGuideLinked.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api; +package api; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; diff --git a/src/api/java/amerifrance/guideapi/api/IInfoRenderer.java b/src/main/java/api/IInfoRenderer.java similarity index 91% rename from src/api/java/amerifrance/guideapi/api/IInfoRenderer.java rename to src/main/java/api/IInfoRenderer.java index 55af3ab8..fbb5dc8b 100644 --- a/src/api/java/amerifrance/guideapi/api/IInfoRenderer.java +++ b/src/main/java/api/IInfoRenderer.java @@ -1,6 +1,6 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; +import api.impl.Book; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; @@ -14,7 +14,7 @@ * Used to render information on screen about a block while a player is looking at and holding the guide. This is only * called on the client. *

- * Use {@link GuideAPI#registerInfoRenderer(amerifrance.guideapi.api.impl.Book, IInfoRenderer, Class...)} to register your + * Use {@link GuideAPI#registerInfoRenderer(Book, IInfoRenderer, Class...)} to register your * handler. You can also implement {@link Block} on a block. *

* Some example usages can be found in {@link amerifrance.guideapi.info} diff --git a/src/api/java/amerifrance/guideapi/api/IPage.java b/src/main/java/api/IPage.java similarity index 86% rename from src/api/java/amerifrance/guideapi/api/IPage.java rename to src/main/java/api/IPage.java index f94d669d..d869b193 100644 --- a/src/api/java/amerifrance/guideapi/api/IPage.java +++ b/src/main/java/api/IPage.java @@ -1,8 +1,8 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; diff --git a/src/api/java/amerifrance/guideapi/api/IRecipeRenderer.java b/src/main/java/api/IRecipeRenderer.java similarity index 85% rename from src/api/java/amerifrance/guideapi/api/IRecipeRenderer.java rename to src/main/java/api/IRecipeRenderer.java index 075ea8e1..b9de4f17 100644 --- a/src/api/java/amerifrance/guideapi/api/IRecipeRenderer.java +++ b/src/main/java/api/IRecipeRenderer.java @@ -1,8 +1,8 @@ -package amerifrance.guideapi.api; +package api; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.crafting.IRecipe; diff --git a/src/api/java/amerifrance/guideapi/api/SubTexture.java b/src/main/java/api/SubTexture.java similarity index 99% rename from src/api/java/amerifrance/guideapi/api/SubTexture.java rename to src/main/java/api/SubTexture.java index 00ed6393..03fa136a 100644 --- a/src/api/java/amerifrance/guideapi/api/SubTexture.java +++ b/src/main/java/api/SubTexture.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api; +package api; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; diff --git a/src/api/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java b/src/main/java/api/button/ButtonGuideAPI.java similarity index 88% rename from src/api/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java rename to src/main/java/api/button/ButtonGuideAPI.java index c17caddb..fa9d775d 100644 --- a/src/api/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java +++ b/src/main/java/api/button/ButtonGuideAPI.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api.button; +package api.button; import amerifrance.guideapi.gui.GuiBase; import net.minecraft.client.gui.widget.button.Button; diff --git a/src/api/java/amerifrance/guideapi/api/impl/Book.java b/src/main/java/api/impl/Book.java similarity index 98% rename from src/api/java/amerifrance/guideapi/api/impl/Book.java rename to src/main/java/api/impl/Book.java index a7b12e24..24715a29 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/Book.java +++ b/src/main/java/api/impl/Book.java @@ -1,7 +1,7 @@ -package amerifrance.guideapi.api.impl; +package api.impl; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.util.TextHelper; +import api.impl.abstraction.CategoryAbstract; +import api.util.TextHelper; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/api/java/amerifrance/guideapi/api/impl/BookBinder.java b/src/main/java/api/impl/BookBinder.java similarity index 98% rename from src/api/java/amerifrance/guideapi/api/impl/BookBinder.java rename to src/main/java/api/impl/BookBinder.java index 288469c6..58ed5523 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/BookBinder.java +++ b/src/main/java/api/impl/BookBinder.java @@ -1,6 +1,6 @@ -package amerifrance.guideapi.api.impl; +package api.impl; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.CategoryAbstract; import com.google.common.base.Strings; import com.google.common.collect.Lists; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/api/java/amerifrance/guideapi/api/impl/Category.java b/src/main/java/api/impl/Category.java similarity index 86% rename from src/api/java/amerifrance/guideapi/api/impl/Category.java rename to src/main/java/api/impl/Category.java index 14805991..01094425 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/Category.java +++ b/src/main/java/api/impl/Category.java @@ -1,7 +1,7 @@ -package amerifrance.guideapi.api.impl; +package api.impl; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiCategory; import amerifrance.guideapi.gui.GuiHome; @@ -10,8 +10,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Map; diff --git a/src/api/java/amerifrance/guideapi/api/impl/Entry.java b/src/main/java/api/impl/Entry.java similarity index 93% rename from src/api/java/amerifrance/guideapi/api/impl/Entry.java rename to src/main/java/api/impl/Entry.java index 558b774b..1c79a34a 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/Entry.java +++ b/src/main/java/api/impl/Entry.java @@ -1,9 +1,9 @@ -package amerifrance.guideapi.api.impl; +package api.impl; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; +import api.IPage; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; +import api.util.GuiHelper; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiCategory; import amerifrance.guideapi.gui.GuiEntry; diff --git a/src/api/java/amerifrance/guideapi/api/impl/Page.java b/src/main/java/api/impl/Page.java similarity index 85% rename from src/api/java/amerifrance/guideapi/api/impl/Page.java rename to src/main/java/api/impl/Page.java index 34a58251..97f853c0 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/Page.java +++ b/src/main/java/api/impl/Page.java @@ -1,15 +1,13 @@ -package amerifrance.guideapi.api.impl; +package api.impl; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.IPage; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiEntry; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public class Page implements IPage { diff --git a/src/api/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java b/src/main/java/api/impl/abstraction/CategoryAbstract.java similarity index 93% rename from src/api/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java rename to src/main/java/api/impl/abstraction/CategoryAbstract.java index c9577c4f..96678e0c 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java +++ b/src/main/java/api/impl/abstraction/CategoryAbstract.java @@ -1,7 +1,7 @@ -package amerifrance.guideapi.api.impl.abstraction; +package api.impl.abstraction; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.util.TextHelper; +import api.impl.Book; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiHome; import com.google.common.base.Strings; @@ -11,8 +11,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; import java.util.Map; @@ -133,21 +131,21 @@ public List getTooltip() { return Lists.newArrayList(getLocalizedName()); } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem); public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void onLeftClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void onInit(Book book, GuiHome guiHome, PlayerEntity player, ItemStack bookStack); @Override diff --git a/src/api/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java b/src/main/java/api/impl/abstraction/EntryAbstract.java similarity index 87% rename from src/api/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java rename to src/main/java/api/impl/abstraction/EntryAbstract.java index 122bf408..71d8a66a 100644 --- a/src/api/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java +++ b/src/main/java/api/impl/abstraction/EntryAbstract.java @@ -1,16 +1,14 @@ -package amerifrance.guideapi.api.impl.abstraction; +package api.impl.abstraction; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.util.TextHelper; +import api.IPage; +import api.impl.Book; +import api.util.TextHelper; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.gui.GuiCategory; import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; @@ -58,21 +56,21 @@ public String getLocalizedName() { return TextHelper.localizeEffect(name); } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void draw(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer renderer); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer renderer); public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory); - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public abstract void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, PlayerEntity player, ItemStack bookStack); @Override diff --git a/src/api/java/amerifrance/guideapi/api/package-info.java b/src/main/java/api/package-info.java similarity index 78% rename from src/api/java/amerifrance/guideapi/api/package-info.java rename to src/main/java/api/package-info.java index 2eb9dd9b..aa8728bd 100644 --- a/src/api/java/amerifrance/guideapi/api/package-info.java +++ b/src/main/java/api/package-info.java @@ -1,4 +1,4 @@ @API(owner = "guideapi", apiVersion = "@API_VERSION@", provides = "Guide-API|API") -package amerifrance.guideapi.api; +package api; import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/api/java/amerifrance/guideapi/api/util/BookHelper.java b/src/main/java/api/util/BookHelper.java similarity index 73% rename from src/api/java/amerifrance/guideapi/api/util/BookHelper.java rename to src/main/java/api/util/BookHelper.java index 86bd5a0e..44d6b183 100644 --- a/src/api/java/amerifrance/guideapi/api/util/BookHelper.java +++ b/src/main/java/api/util/BookHelper.java @@ -1,8 +1,8 @@ -package amerifrance.guideapi.api.util; +package api.util; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; public class BookHelper { diff --git a/src/api/java/amerifrance/guideapi/api/util/GuiHelper.java b/src/main/java/api/util/GuiHelper.java similarity index 99% rename from src/api/java/amerifrance/guideapi/api/util/GuiHelper.java rename to src/main/java/api/util/GuiHelper.java index 8e863192..fcf6b150 100644 --- a/src/api/java/amerifrance/guideapi/api/util/GuiHelper.java +++ b/src/main/java/api/util/GuiHelper.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api.util; +package api.util; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; diff --git a/src/api/java/amerifrance/guideapi/api/util/NBTBookTags.java b/src/main/java/api/util/NBTBookTags.java similarity index 91% rename from src/api/java/amerifrance/guideapi/api/util/NBTBookTags.java rename to src/main/java/api/util/NBTBookTags.java index cfacf8e2..a44a61c7 100644 --- a/src/api/java/amerifrance/guideapi/api/util/NBTBookTags.java +++ b/src/main/java/api/util/NBTBookTags.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api.util; +package api.util; public class NBTBookTags { diff --git a/src/api/java/amerifrance/guideapi/api/util/PageHelper.java b/src/main/java/api/util/PageHelper.java similarity index 96% rename from src/api/java/amerifrance/guideapi/api/util/PageHelper.java rename to src/main/java/api/util/PageHelper.java index f4cf31ea..a57f9425 100644 --- a/src/api/java/amerifrance/guideapi/api/util/PageHelper.java +++ b/src/main/java/api/util/PageHelper.java @@ -1,7 +1,7 @@ -package amerifrance.guideapi.api.util; +package api.util; -import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Page; +import api.IPage; +import api.impl.Page; import amerifrance.guideapi.gui.GuiBase; import amerifrance.guideapi.page.PageItemStack; import amerifrance.guideapi.page.PageText; diff --git a/src/api/java/amerifrance/guideapi/api/util/TextHelper.java b/src/main/java/api/util/TextHelper.java similarity index 98% rename from src/api/java/amerifrance/guideapi/api/util/TextHelper.java rename to src/main/java/api/util/TextHelper.java index 01148018..70c06a1d 100644 --- a/src/api/java/amerifrance/guideapi/api/util/TextHelper.java +++ b/src/main/java/api/util/TextHelper.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.api.util; +package api.util; import net.minecraft.util.text.translation.I18n; import org.apache.commons.lang3.text.WordUtils; From a05d2c2a5a0977e5d5b317f50aa396a8e4683056 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 21 Mar 2020 00:52:51 +0100 Subject: [PATCH 03/28] More updates. Still very much in progress --- .../guideapi/RegistrarGuideAPI.java | 7 +- .../guideapi/button/ButtonBack.java | 4 +- .../guideapi/button/ButtonNext.java | 4 +- .../guideapi/button/ButtonPrev.java | 4 +- .../guideapi/button/ButtonSearch.java | 4 +- .../guideapi/category/CategoryItemStack.java | 16 +++-- .../category/CategoryResourceLocation.java | 18 ++--- .../guideapi/entry/EntryItemStack.java | 10 +-- .../guideapi/entry/EntryResourceLocation.java | 12 ++-- .../gui/{GuiBase.java => BaseScreen.java} | 28 ++++---- .../{GuiCategory.java => CategoryScreen.java} | 22 +++--- .../gui/{GuiEntry.java => EntryScreen.java} | 18 ++--- .../gui/{GuiHome.java => HomeScreen.java} | 25 ++++--- .../gui/{GuiSearch.java => SearchScreen.java} | 16 ++--- .../info/InfoRendererDescription.java | 11 ++- .../guideapi/info/InfoRendererImage.java | 6 +- .../guideapi/item/ItemGuideBook.java | 4 +- .../guideapi/network/IMessage.java | 9 +++ .../guideapi/network/PacketHandler.java | 19 ++++-- .../guideapi/network/PacketSyncEntry.java | 67 +++++++++++-------- .../guideapi/page/PageBrewingRecipe.java | 4 +- .../guideapi/page/PageFurnaceRecipe.java | 16 ++--- .../guideapi/page/PageIRecipe.java | 33 +++++---- .../amerifrance/guideapi/page/PageImage.java | 10 +-- .../guideapi/page/PageItemStack.java | 11 ++- .../guideapi/page/PageJsonRecipe.java | 2 +- .../amerifrance/guideapi/page/PageSound.java | 24 ++++--- .../amerifrance/guideapi/page/PageText.java | 16 ++--- .../guideapi/page/PageTextImage.java | 12 ++-- .../reciperenderer/BasicRecipeRenderer.java | 8 +-- .../ShapedOreRecipeRenderer.java | 4 +- .../reciperenderer/ShapedRecipesRenderer.java | 17 +++-- .../ShapelessOreRecipeRenderer.java | 3 +- .../ShapelessRecipesRenderer.java | 11 ++- .../guideapi/proxy/ClientProxy.java | 10 +-- .../guideapi/proxy/CommonProxy.java | 14 ++-- .../amerifrance/guideapi/test/TestBook3.java | 17 +++-- .../amerifrance/guideapi/util/APISetter.java | 9 ++- .../guideapi/util/EventHandler.java | 57 ++++++++-------- .../guideapi/wrapper/AbstractWrapper.java | 6 +- .../guideapi/wrapper/CategoryWrapper.java | 12 ++-- .../guideapi/wrapper/EntryWrapper.java | 12 ++-- .../guideapi/wrapper/PageWrapper.java | 12 ++-- src/main/java/api/IPage.java | 14 ++-- src/main/java/api/IRecipeRenderer.java | 7 +- src/main/java/api/SubTexture.java | 5 +- src/main/java/api/button/ButtonGuideAPI.java | 6 +- src/main/java/api/impl/Book.java | 12 ++-- src/main/java/api/impl/BookBinder.java | 16 +++-- src/main/java/api/impl/Category.java | 28 ++++---- src/main/java/api/impl/Entry.java | 32 ++++----- src/main/java/api/impl/Page.java | 28 ++++---- .../impl/abstraction/CategoryAbstract.java | 14 ++-- .../api/impl/abstraction/EntryAbstract.java | 16 +++-- src/main/java/api/package-info.java | 2 - src/main/java/api/util/GuiHelper.java | 49 +++++++------- src/main/java/api/util/PageHelper.java | 4 +- src/main/java/api/util/TextHelper.java | 4 +- 58 files changed, 452 insertions(+), 409 deletions(-) rename src/main/java/amerifrance/guideapi/gui/{GuiBase.java => BaseScreen.java} (73%) rename src/main/java/amerifrance/guideapi/gui/{GuiCategory.java => CategoryScreen.java} (86%) rename src/main/java/amerifrance/guideapi/gui/{GuiEntry.java => EntryScreen.java} (86%) rename src/main/java/amerifrance/guideapi/gui/{GuiHome.java => HomeScreen.java} (83%) rename src/main/java/amerifrance/guideapi/gui/{GuiSearch.java => SearchScreen.java} (92%) create mode 100644 src/main/java/amerifrance/guideapi/network/IMessage.java diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index 27f17a8d..42d18cd0 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -16,10 +16,11 @@ import net.minecraft.world.biome.Biome; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.ForgeRegistries; + +import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; @Mod.EventBusSubscriber diff --git a/src/main/java/amerifrance/guideapi/button/ButtonBack.java b/src/main/java/amerifrance/guideapi/button/ButtonBack.java index 89fd5ec6..ff4a67db 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonBack.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonBack.java @@ -4,7 +4,7 @@ import api.button.ButtonGuideAPI; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; @@ -14,7 +14,7 @@ public class ButtonBack extends ButtonGuideAPI { - public ButtonBack(int id, int x, int y, GuiBase guiBase) { + public ButtonBack(int id, int x, int y, BaseScreen guiBase) { super(id, x, y, guiBase); width = 18; height = 10; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonNext.java b/src/main/java/amerifrance/guideapi/button/ButtonNext.java index 46f57233..a808c176 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonNext.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonNext.java @@ -4,7 +4,7 @@ import api.button.ButtonGuideAPI; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; @@ -14,7 +14,7 @@ public class ButtonNext extends ButtonGuideAPI { - public ButtonNext(int id, int x, int y, GuiBase guiBase) { + public ButtonNext(int id, int x, int y, BaseScreen guiBase) { super(id, x, y, guiBase); width = 18; height = 10; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java index 8df20e93..e1204756 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java @@ -4,7 +4,7 @@ import api.button.ButtonGuideAPI; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; @@ -14,7 +14,7 @@ public class ButtonPrev extends ButtonGuideAPI { - public ButtonPrev(int id, int x, int y, GuiBase guiBase) { + public ButtonPrev(int id, int x, int y, BaseScreen guiBase) { super(id, x, y, guiBase); width = 18; height = 10; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java index ac8b82a3..3f2c262d 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java @@ -4,7 +4,7 @@ import api.button.ButtonGuideAPI; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderHelper; @@ -13,7 +13,7 @@ public class ButtonSearch extends ButtonGuideAPI { - public ButtonSearch(int id, int x, int y, GuiBase guiBase) { + public ButtonSearch(int id, int x, int y, BaseScreen guiBase) { super(id, x, y, guiBase); width = 15; height = 15; diff --git a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java index 92ca541f..2844edec 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java @@ -4,11 +4,13 @@ import api.impl.Category; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.Map; @@ -27,16 +29,16 @@ public CategoryItemStack(String name, ItemStack stack) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem) { + @OnlyIn(Dist.CLIENT) + public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { GuiHelper.drawScaledItemStack(this.stack, categoryX, categoryY, 1.5F); } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - guiBase.drawHoveringText(this.getTooltip(), mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); + guiBase.drawHoveringText(this.getTooltip(), mouseX, mouseY, Minecraft.getInstance().fontRenderer); } @Override diff --git a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java index 09435e61..dbc4a723 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java @@ -4,10 +4,12 @@ import api.impl.Category; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.Map; @@ -26,17 +28,17 @@ public CategoryResourceLocation(String name, ResourceLocation resourceLocation) } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem) { - Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation); + @OnlyIn(Dist.CLIENT) + public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { + Minecraft.getInstance().getTextureManager().bindTexture(resourceLocation); GuiHelper.drawSizedIconWithoutColor(categoryX, categoryY, 48, 48, 0); } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - guiBase.drawHoveringText(this.getTooltip(), mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); + guiBase.drawHoveringText(this.getTooltip(), mouseX, mouseY, Minecraft.getInstance().fontRenderer); } @Override diff --git a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java index 20ce0c07..78c83520 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java @@ -5,11 +5,11 @@ import api.impl.Entry; import api.impl.abstraction.CategoryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; @@ -37,8 +37,8 @@ public EntryItemStack(String name, ItemStack stack) { } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { if (stack != null) GuiHelper.drawScaledItemStack(stack, entryX + 2, entryY, 0.5F); diff --git a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java index bff3496e..7a651436 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java @@ -5,12 +5,12 @@ import api.impl.Entry; import api.impl.abstraction.CategoryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; @@ -38,9 +38,9 @@ public EntryResourceLocation(String name, ResourceLocation image) { } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { - Minecraft.getMinecraft().getTextureManager().bindTexture(image); + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { + Minecraft.getInstance().getTextureManager().bindTexture(image); GuiHelper.drawSizedIconWithoutColor(entryX + 2, entryY, 16, 16, 1F); super.drawExtras(book, category, entryX, entryY, entryWidth, entryHeight, mouseX, mouseY, guiBase, fontRendererObj); diff --git a/src/main/java/amerifrance/guideapi/gui/GuiBase.java b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java similarity index 73% rename from src/main/java/amerifrance/guideapi/gui/GuiBase.java rename to src/main/java/amerifrance/guideapi/gui/BaseScreen.java index 4f93e3ba..bbf5b3e8 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiBase.java +++ b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java @@ -7,13 +7,16 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; import org.lwjgl.opengl.GL11; import java.awt.Color; import java.util.List; +import static com.mojang.blaze3d.platform.GlStateManager.*; -public class GuiBase extends Screen { + +public class BaseScreen extends Screen { public int guiLeft, guiTop; public int xSize = 192; @@ -22,10 +25,11 @@ public class GuiBase extends Screen { public ItemStack bookStack; public float publicZLevel; - public GuiBase(PlayerEntity player, ItemStack bookStack) { + public BaseScreen(ITextComponent title, PlayerEntity player, ItemStack bookStack) { + super(title); this.player = player; this.bookStack = bookStack; - this.publicZLevel = zLevel; + this.publicZLevel = blitOffset; } @Override @@ -35,9 +39,9 @@ public boolean doesGuiPauseGame() { @Override public void keyTyped(char typedChar, int keyCode) { - if (keyCode == Keyboard.KEY_ESCAPE || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) { - this.mc.displayGuiScreen(null); - this.mc.setIngameFocus(); + if (keyCode == Keyboard.KEY_ESCAPE || keyCode == this.minecraft.gameSettings.keyBindInventory.getKeyCode()) { + this.minecraft.displayGuiScreen(null); + this.minecraft.setIngameFocus(); } } @@ -48,13 +52,13 @@ public void drawTexturedModalRectWithColor(int x, int y, int textureX, int textu float f = 0.00390625F; float f1 = 0.00390625F; disableLighting(); - color((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F); + color3f((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX); - tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) this.zLevel).tex((double) ((float) (textureX) * f), (double) ((float) (textureY + height) * f1)).endVertex(); - tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((float) (textureX + width) * f), (double) ((float) (textureY + height) * f1)).endVertex(); - tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) this.zLevel).tex((double) ((float) (textureX + width) * f), (double) ((float) (textureY) * f1)).endVertex(); - tessellator.getBuffer().pos((double) (x), (double) (y), (double) this.zLevel).tex((double) ((float) (textureX) * f), (double) ((float) (textureY) * f1)).endVertex(); + tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) this.blitOffset).tex((double) ((float) (textureX) * f), (double) ((float) (textureY + height) * f1)).endVertex(); + tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.blitOffset).tex((double) ((float) (textureX + width) * f), (double) ((float) (textureY + height) * f1)).endVertex(); + tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) this.blitOffset).tex((double) ((float) (textureX + width) * f), (double) ((float) (textureY) * f1)).endVertex(); + tessellator.getBuffer().pos((double) (x), (double) (y), (double) this.blitOffset).tex((double) ((float) (textureX) * f), (double) ((float) (textureY) * f1)).endVertex(); tessellator.draw(); disableBlend(); popMatrix(); @@ -74,7 +78,7 @@ public void drawCenteredStringWithShadow(FontRenderer fontRendererObj, String st @Override public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { pushMatrix(); - color(1.0F, 1.0F, 1.0F, 1.0F); + color4f(1.0F, 1.0F, 1.0F, 1.0F); super.drawTexturedModalRect(x, y, textureX, textureY, width, height); popMatrix(); } diff --git a/src/main/java/amerifrance/guideapi/gui/GuiCategory.java b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java similarity index 86% rename from src/main/java/amerifrance/guideapi/gui/GuiCategory.java rename to src/main/java/amerifrance/guideapi/gui/CategoryScreen.java index 44018810..7eb84f0f 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiCategory.java +++ b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java @@ -25,7 +25,7 @@ import javax.annotation.Nullable; -public class GuiCategory extends GuiBase { +public class CategoryScreen extends BaseScreen { public ResourceLocation outlineTexture; public ResourceLocation pageTexture; @@ -39,7 +39,7 @@ public class GuiCategory extends GuiBase { public int entryPage; @Nullable public EntryAbstract startEntry; - public GuiCategory(Book book, CategoryAbstract category, PlayerEntity player, ItemStack bookStack, @Nullable EntryAbstract startEntry) { + public CategoryScreen(Book book, CategoryAbstract category, PlayerEntity player, ItemStack bookStack, @Nullable EntryAbstract startEntry) { super(player, bookStack); this.book = book; this.category = category; @@ -70,7 +70,7 @@ public void initGui() { List entries = Lists.newArrayList(category.entries.values()); for (EntryAbstract entry : entries) { entry.onInit(book, category, this, player, bookStack); - entryWrapperMap.put(pageNumber, new EntryWrapper(this, book, category, entry, eX, eY, 4 * xSize / 6, 10, player, this.fontRenderer, bookStack)); + entryWrapperMap.put(pageNumber, new EntryWrapper(this, book, category, entry, eX, eY, 4 * xSize / 6, 10, player, this.font, bookStack)); if (entry.equals(this.startEntry)) { this.startEntry = null; this.entryPage = pageNumber; @@ -88,9 +88,9 @@ public void initGui() { @Override public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { - Minecraft.getMinecraft().getTextureManager().bindTexture(pageTexture); + minecraft.getTextureManager().bindTexture(pageTexture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - Minecraft.getMinecraft().getTextureManager().bindTexture(outlineTexture); + minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); entryPage = MathHelper.clamp(entryPage, 0, entryWrapperMap.size() - 1); @@ -105,8 +105,8 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { } } - drawCenteredString(fontRenderer, String.format("%d/%d", entryPage + 1, entryWrapperMap.asMap().size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); - drawCenteredStringWithShadow(fontRenderer, category.getLocalizedName(), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); + drawCenteredString(font, String.format("%d/%d", entryPage + 1, entryWrapperMap.asMap().size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); + drawCenteredStringWithShadow(font, category.getLocalizedName(), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); buttonPrev.visible = entryPage != 0; buttonNext.visible = entryPage != entryWrapperMap.asMap().size() - 1 && !entryWrapperMap.asMap().isEmpty(); @@ -127,7 +127,7 @@ else if (typeofClick == 1) } if (typeofClick == 1) - this.mc.displayGuiScreen(new GuiHome(book, player, bookStack)); + this.mc.displayGuiScreen(new HomeScreen(book, player, bookStack)); } @Override @@ -145,7 +145,7 @@ else if (movement > 0) public void keyTyped(char typedChar, int keyCode) { super.keyTyped(typedChar, keyCode); if (keyCode == Keyboard.KEY_BACK || keyCode == this.mc.gameSettings.keyBindUseItem.getKeyCode()) - this.mc.displayGuiScreen(new GuiHome(book, player, bookStack)); + this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); if ((keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_RIGHT) && entryPage + 1 < entryWrapperMap.asMap().size()) nextPage(); if ((keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_LEFT) && entryPage > 0) @@ -155,13 +155,13 @@ public void keyTyped(char typedChar, int keyCode) { @Override public void actionPerformed(Button button) { if (button.id == 0) - this.mc.displayGuiScreen(new GuiHome(book, player, bookStack)); + this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); else if (button.id == 1 && entryPage + 1 < entryWrapperMap.asMap().size()) nextPage(); else if (button.id == 2 && entryPage > 0) prevPage(); else if (button.id == 3) - this.mc.displayGuiScreen(new GuiSearch(book, player, bookStack, this)); + this.minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); } @Override diff --git a/src/main/java/amerifrance/guideapi/gui/GuiEntry.java b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java similarity index 86% rename from src/main/java/amerifrance/guideapi/gui/GuiEntry.java rename to src/main/java/amerifrance/guideapi/gui/EntryScreen.java index 54523e86..6042a429 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiEntry.java +++ b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; -public class GuiEntry extends GuiBase { +public class EntryScreen extends BaseScreen { public ResourceLocation outlineTexture; public ResourceLocation pageTexture; @@ -38,7 +38,7 @@ public class GuiEntry extends GuiBase { public ButtonSearch buttonSearch; public int pageNumber; - public GuiEntry(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack) { + public EntryScreen(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack) { super(player, bookStack); this.book = book; this.category = category; @@ -65,7 +65,7 @@ public void initGui() { for (IPage page : this.entry.pageList) { page.onInit(book, category, entry, player, bookStack, this); - pageWrapperList.add(new PageWrapper(this, book, category, entry, page, guiLeft, guiTop, player, this.fontRenderer, bookStack)); + pageWrapperList.add(new PageWrapper(this, book, category, entry, page, guiLeft, guiTop, player, this.font, bookStack)); } } @@ -85,8 +85,8 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { } } - drawCenteredString(fontRenderer, String.format("%d/%d", pageNumber + 1, pageWrapperList.size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); - drawCenteredStringWithShadow(fontRenderer, entry.getLocalizedName(), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); + drawCenteredString(font, String.format("%d/%d", pageNumber + 1, pageWrapperList.size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); + drawCenteredStringWithShadow(font, entry.getLocalizedName(), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); buttonPrev.visible = pageNumber != 0; buttonNext.visible = pageNumber != pageWrapperList.size() - 1 && !pageWrapperList.isEmpty(); @@ -109,7 +109,7 @@ public void mouseClicked(int mouseX, int mouseY, int typeofClick) throws IOExcep } if (typeofClick == 1) { - this.mc.displayGuiScreen(new GuiCategory(book, category, player, bookStack, entry)); + this.mc.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); } } @@ -128,7 +128,7 @@ else if (movement > 0) public void keyTyped(char typedChar, int keyCode) { super.keyTyped(typedChar, keyCode); if (keyCode == Keyboard.KEY_BACK || keyCode == this.mc.gameSettings.keyBindUseItem.getKeyCode()) - this.mc.displayGuiScreen(new GuiCategory(book, category, player, bookStack, entry)); + this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); if ((keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_RIGHT) && pageNumber + 1 < pageWrapperList.size()) nextPage(); if ((keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_LEFT) && pageNumber > 0) @@ -138,13 +138,13 @@ public void keyTyped(char typedChar, int keyCode) { @Override public void actionPerformed(Button button) { if (button.id == 0) - this.mc.displayGuiScreen(new GuiCategory(book, category, player, bookStack, entry)); + this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); else if (button.id == 1 && pageNumber + 1 < pageWrapperList.size()) nextPage(); else if (button.id == 2 && pageNumber > 0) prevPage(); else if (button.id == 3) - this.mc.displayGuiScreen(new GuiSearch(book, player, bookStack, this)); + this.mc.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); } @Override diff --git a/src/main/java/amerifrance/guideapi/gui/GuiHome.java b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java similarity index 83% rename from src/main/java/amerifrance/guideapi/gui/GuiHome.java rename to src/main/java/amerifrance/guideapi/gui/HomeScreen.java index e1a21940..b4644113 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiHome.java +++ b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java @@ -9,7 +9,6 @@ import amerifrance.guideapi.network.PacketSyncHome; import amerifrance.guideapi.wrapper.CategoryWrapper; import com.google.common.collect.HashMultimap; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerEntity; @@ -20,7 +19,7 @@ import java.awt.Color; import java.io.IOException; -public class GuiHome extends GuiBase { +public class HomeScreen extends BaseScreen { public ResourceLocation outlineTexture; public ResourceLocation pageTexture; @@ -31,7 +30,7 @@ public class GuiHome extends GuiBase { public ButtonSearch buttonSearch; public int categoryPage; - public GuiHome(Book book, PlayerEntity player, ItemStack bookStack) { + public HomeScreen(Book book, PlayerEntity player, ItemStack bookStack) { super(player, bookStack); this.book = book; this.pageTexture = book.getPageTexture(); @@ -64,25 +63,25 @@ public void initGui() { category.onInit(book, this, player, bookStack); switch (drawLoc) { case 0: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack)); + categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); cX += 27; drawLoc = 1; break; } case 1: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack)); + categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); cX += 27; drawLoc = 2; break; } case 2: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack)); + categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); cX += 27; drawLoc = 3; break; } case 3: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.fontRenderer, itemRender, false, bookStack)); + categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); drawLoc = 0; cX = guiLeft + 45; cY += 30; @@ -102,11 +101,11 @@ public void initGui() { @Override public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { - Minecraft.getMinecraft().getTextureManager().bindTexture(pageTexture); + minecraft.getTextureManager().bindTexture(pageTexture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - Minecraft.getMinecraft().getTextureManager().bindTexture(outlineTexture); + minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); - drawCenteredString(fontRenderer, I18n.format(book.getHeader()).replace("\\n", "\n").replace("&", "\u00a7"), guiLeft + xSize / 2 + 1, guiTop + 15, 0); + drawCenteredString(font, I18n.format(book.getHeader()).replace("\\n", "\n").replace("&", "\u00a7"), guiLeft + xSize / 2 + 1, guiTop + 15, 0); categoryPage = MathHelper.clamp(categoryPage, 0, categoryWrapperMap.size() - 1); @@ -118,8 +117,8 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { if (wrapper.canPlayerSee()) wrapper.drawExtras(mouseX, mouseY, this); - drawCenteredString(fontRenderer, String.format("%d/%d", categoryPage + 1, categoryWrapperMap.asMap().size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); - drawCenteredStringWithShadow(fontRenderer, I18n.format(book.getTitle()), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); + drawCenteredString(font, String.format("%d/%d", categoryPage + 1, categoryWrapperMap.asMap().size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); + drawCenteredStringWithShadow(font, I18n.format(book.getTitle()), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); buttonPrev.visible = categoryPage != 0; buttonNext.visible = categoryPage != categoryWrapperMap.asMap().size() - 1 && !categoryWrapperMap.asMap().isEmpty(); @@ -183,7 +182,7 @@ else if (button.id == 1 && categoryPage > 0) break; } case 2: { - mc.displayGuiScreen(new GuiSearch(book, player, bookStack, this)); + minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); break; } } diff --git a/src/main/java/amerifrance/guideapi/gui/GuiSearch.java b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java similarity index 92% rename from src/main/java/amerifrance/guideapi/gui/GuiSearch.java rename to src/main/java/amerifrance/guideapi/gui/SearchScreen.java index 29bde351..16b78ed6 100644 --- a/src/main/java/amerifrance/guideapi/gui/GuiSearch.java +++ b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Locale; -public class GuiSearch extends GuiBase { +public class SearchScreen extends BaseScreen { private Book book; private ResourceLocation outlineTexture; @@ -39,7 +39,7 @@ public class GuiSearch extends GuiBase { private int currentPage = 0; private String lastQuery = ""; - public GuiSearch(Book book, PlayerEntity player, ItemStack bookStack, Screen parent) { + public SearchScreen(Book book, PlayerEntity player, ItemStack bookStack, Screen parent) { super(player, bookStack); this.book = book; @@ -60,7 +60,7 @@ public void initGui() { addButton(buttonNext = new ButtonNext(1, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this)); addButton(buttonPrev = new ButtonPrev(2, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this)); - searchField = new TextFieldWidget(3, fontRenderer, guiLeft + 43, guiTop + 12, 100, 10); + searchField = new TextFieldWidget(3, font, guiLeft + 43, guiTop + 12, 100, 10); searchField.setEnableBackgroundDrawing(false); searchField.setFocused(true); searchResults = getMatches(book, null, player, bookStack); @@ -68,9 +68,9 @@ public void initGui() { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - mc.getTextureManager().bindTexture(pageTexture); + minecraft.getTextureManager().bindTexture(pageTexture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - mc.getTextureManager().bindTexture(outlineTexture); + minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); drawRect(searchField.x - 1, searchField.y - 1, searchField.x + searchField.width + 1, searchField.y + searchField.height + 1, new Color(166, 166, 166, 128).getRGB()); @@ -111,13 +111,13 @@ public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOExcep super.mouseClicked(mouseX, mouseY, mouseButton); if (mouseButton == 1) { - if (GuiHelper.isMouseBetween(mouseX, mouseY, searchField.x, searchField.y, searchField.width, searchField.height)) { + if (GuiHelper.isMouseBetween(mouseX, mouseY, searchField.x, searchField.y, searchField.getAdjustedWidth(), searchField.getHeight())) { searchField.setText(""); lastQuery = ""; searchResults = getMatches(book, "", player, bookStack); return; } else - mc.displayGuiScreen(parent); + minecraft.displayGuiScreen(parent); } searchField.mouseClicked(mouseX, mouseY, mouseButton); @@ -155,7 +155,7 @@ public void keyTyped(char typedChar, int keyCode) { public void actionPerformed(Button button) { switch (button.id) { case 0: { - mc.displayGuiScreen(parent); + minecraft.displayGuiScreen(parent); break; } case 1: { diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java index a0b26004..b3930775 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java @@ -3,10 +3,10 @@ import api.IInfoRenderer; import api.impl.Book; import api.util.GuiHelper; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -34,13 +34,12 @@ public InfoRendererDescription(ItemStack stack, ITextComponent description) { public void drawInformation(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player) { if (tiny) { GlStateManager.pushMatrix(); - GlStateManager.scale(0.5F, 0.5F, 0.5F); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); } - ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; int scaleMulti = tiny ? 2 : 1; - GuiHelper.drawItemStack(stack, (resolution.getScaledWidth() / 2 + 55) * scaleMulti, ((resolution.getScaledHeight() / 2 - (tiny ? 20 : 30)) + yOffset) * scaleMulti); + GuiHelper.drawItemStack(stack, (Minecraft.getInstance().mainWindow.getScaledWidth() / 2 + 55) * scaleMulti, ((Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - (tiny ? 20 : 30)) + yOffset) * scaleMulti); int y = 0; String toDraw = StringEscapeUtils.unescapeJava(description.getFormattedText()).replaceAll("\\t", " "); @@ -48,7 +47,7 @@ public void drawInformation(Book book, World world, BlockPos pos, BlockState sta for (String line : lines) { List cutLines = fontRenderer.listFormattedStringToWidth(line, 100 * scaleMulti); for (String cut : cutLines) { - fontRenderer.drawStringWithShadow(cut, (resolution.getScaledWidth() / 2 + 20) * scaleMulti, (((resolution.getScaledHeight() / 2 - 10) - y) * scaleMulti) + yOffset, Color.WHITE.getRGB()); + fontRenderer.drawStringWithShadow(cut, (Minecraft.getInstance().mainWindow.getScaledWidth()/ 2 + 20) * scaleMulti, (((Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - 10) - y) * scaleMulti) + yOffset, Color.WHITE.getRGB()); y -= 10 / scaleMulti; } } diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java index b34d03f7..ebbf2897 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java @@ -5,7 +5,6 @@ import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -30,8 +29,7 @@ public InfoRendererImage(ResourceLocation image, int imageX, int imageY, int ima @Override public void drawInformation(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player) { - ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); - Minecraft.getMinecraft().renderEngine.bindTexture(image); - AbstractGui.drawModalRectWithCustomSizedTexture(resolution.getScaledWidth() / 2 + 20, resolution.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight); + Minecraft.getInstance().renderEngine.bindTexture(image); + AbstractGui.drawModalRectWithCustomSizedTexture(Minecraft.getInstance().mainWindow.getScaledWidth() / 2 + 20, Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight); } } diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index bb89f323..c98c1fad 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -10,6 +10,7 @@ import api.util.TextHelper; import com.google.common.base.Strings; import net.minecraft.block.BlockState; +import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag.TooltipFlags; import net.minecraft.entity.player.PlayerEntity; @@ -17,7 +18,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -79,7 +79,7 @@ public ActionResultType onItemUse(PlayerEntity player, World world, BlockPos pos @Override public String getItemStackDisplayName(ItemStack stack) { - return !Strings.isNullOrEmpty(book.getItemName()) ? I18n.translateToLocal(getBook(stack).getItemName()) : super.getItemStackDisplayName(stack); + return !Strings.isNullOrEmpty(book.getItemName()) ? I18n.format(getBook(stack).getItemName()) : super.getItemStackDisplayName(stack); } @Override diff --git a/src/main/java/amerifrance/guideapi/network/IMessage.java b/src/main/java/amerifrance/guideapi/network/IMessage.java new file mode 100644 index 00000000..170ae6f1 --- /dev/null +++ b/src/main/java/amerifrance/guideapi/network/IMessage.java @@ -0,0 +1,9 @@ +package amerifrance.guideapi.network; + +/** + * Guide-API + * + * @author maxanier + */ +public interface IMessage { +} diff --git a/src/main/java/amerifrance/guideapi/network/PacketHandler.java b/src/main/java/amerifrance/guideapi/network/PacketHandler.java index 97d2bd35..28eaa06f 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketHandler.java +++ b/src/main/java/amerifrance/guideapi/network/PacketHandler.java @@ -1,16 +1,27 @@ package amerifrance.guideapi.network; import amerifrance.guideapi.GuideMod; -import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import net.minecraftforge.fml.relauncher.Side; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.network.NetworkRegistry; +import net.minecraftforge.fml.network.simple.SimpleChannel; + public class PacketHandler { + private static final String PROTOCOL_VERSION = Integer.toString(1); + private static byte packetId = 0; + + + public static SimpleChannel INSTANCE = NetworkRegistry.ChannelBuilder.named(new ResourceLocation(GuideMod.ID,"main")).clientAcceptedVersions(PROTOCOL_VERSION::equals).serverAcceptedVersions(PROTOCOL_VERSION::equals).networkProtocolVersion(()->PROTOCOL_VERSION).simpleChannel(); + - public static SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(GuideMod.CHANNEL); public static void registerPackets() { + INSTANCE.registerMessage(nextID(),PacketSyncEntry.class,PacketSyncEntry::encode,PacketSyncEntry::decode,PacketSyncEntry::handle); INSTANCE.registerMessage(PacketSyncHome.class, PacketSyncHome.class, 0, Side.SERVER); INSTANCE.registerMessage(PacketSyncCategory.class, PacketSyncCategory.class, 1, Side.SERVER); - INSTANCE.registerMessage(PacketSyncEntry.class, PacketSyncEntry.class, 2, Side.SERVER); + } + + protected static int nextID() { + return packetId++; } } diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java index d84e6444..a45fad70 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java @@ -3,15 +3,18 @@ import api.IGuideItem; import api.util.NBTBookTags; import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.network.ByteBufUtils; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.network.NetworkEvent; +import org.apache.commons.lang3.Validate; -public class PacketSyncEntry implements IMessage, IMessageHandler { +import java.util.function.Supplier; + +public class PacketSyncEntry implements IMessage { public int category; public ResourceLocation entry; @@ -29,36 +32,44 @@ public PacketSyncEntry(int category, ResourceLocation entry, int page) { this.page = page; } - @Override - public void fromBytes(ByteBuf buf) { - this.category = buf.readInt(); - this.entry = new ResourceLocation(ByteBufUtils.readUTF8String(buf)); - this.page = buf.readInt(); + static void encode(PacketSyncEntry msg, PacketBuffer buf){ + buf.writeInt(msg.category); + buf.writeResourceLocation(msg.entry); + buf.writeInt(msg.page); } - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(category); - ByteBufUtils.writeUTF8String(buf, entry.toString()); - buf.writeInt(page); + static PacketSyncEntry decode(PacketBuffer buf){ + PacketSyncEntry msg=new PacketSyncEntry(); + msg.category=buf.readInt(); + msg.entry=buf.readResourceLocation(); + msg.page = buf.readInt(); + return msg; } - @Override - public IMessage onMessage(PacketSyncEntry message, MessageContext ctx) { - ItemStack book = ctx.getServerHandler().player.getHeldItemOffhand(); - if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) - book = ctx.getServerHandler().player.getHeldItemMainhand(); + public static void handle(final PacketSyncEntry msg, Supplier contextSupplier){ + final NetworkEvent.Context ctx=contextSupplier.get(); + ServerPlayerEntity player = ctx.getSender(); + Validate.notNull(player); + ctx.enqueueWork(()->{ + ItemStack book = player.getHeldItemOffhand(); + if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) + book = player.getHeldItemMainhand(); - if (!book.isEmpty() && book.getItem() instanceof IGuideItem) { - if (message.category != -1 && !message.entry.equals(new ResourceLocation("guideapi", "none")) && message.page != -1) { - if (!book.hasTagCompound()) - book.setTagCompound(new CompoundNBT()); + if (!book.isEmpty() && book.getItem() instanceof IGuideItem) { + if (msg.category != -1 && !msg.entry.equals(new ResourceLocation("guideapi", "none")) && msg.page != -1) { + if (!book.hasTag()) + book.setTag(new CompoundNBT()); - book.getTagCompound().setInteger(NBTBookTags.CATEGORY_TAG, message.category); - book.getTagCompound().setString(NBTBookTags.ENTRY_TAG, message.entry.toString()); - book.getTagCompound().setInteger(NBTBookTags.PAGE_TAG, message.page); + book.getTag().putInt(NBTBookTags.CATEGORY_TAG, msg.category); + book.getTag().putString(NBTBookTags.ENTRY_TAG, msg.entry.toString()); + book.getTag().putInt(NBTBookTags.PAGE_TAG, msg.page); + } } - } - return null; + }); + ctx.setPacketHandled(true); } + + + + } diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index af8a889b..47b67961 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -7,7 +7,7 @@ import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; @@ -49,7 +49,7 @@ public PageBrewingRecipe(ItemStack input, ItemStack ingredient, ItemStack output @Override @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { int xStart = guiLeft + 62; int yStart = guiTop + 52; diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java index 82f4d410..92b23c07 100644 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java @@ -7,16 +7,16 @@ import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; +import net.minecraft.item.crafting.FurnaceRecipe; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + import java.util.ArrayList; import java.util.List; @@ -31,7 +31,7 @@ public class PageFurnaceRecipe extends Page { */ public PageFurnaceRecipe(ItemStack input) { this.input = input; - this.output = FurnaceRecipes.instance().getSmeltingResult(input); + this.output = FurnaceRecipe.instance().getSmeltingResult(input); } /** @@ -67,9 +67,9 @@ public PageFurnaceRecipe(String input) { } @Override - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) @SuppressWarnings("unchecked") - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { SubTexture.FURNACE_GRID.draw(guiLeft + 64, guiTop + 71); List badTip = new ArrayList(); diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index c78e7650..e45ea187 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -5,8 +5,8 @@ import api.impl.Page; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiEntry; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.EntryScreen; import amerifrance.guideapi.page.reciperenderer.ShapedOreRecipeRenderer; import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; import amerifrance.guideapi.page.reciperenderer.ShapelessOreRecipeRenderer; @@ -16,12 +16,11 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.ShapedRecipes; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; +import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.item.crafting.ShapelessRecipe; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + public class PageIRecipe extends Page { @@ -56,8 +55,8 @@ public PageIRecipe(IRecipe recipe, IRecipeRenderer iRecipeRenderer) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { if(isValid) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); iRecipeRenderer.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); @@ -65,8 +64,8 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { if(isValid) { super.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); iRecipeRenderer.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); @@ -74,7 +73,7 @@ public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry } @Override - public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { + public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { return isValid; } @@ -90,10 +89,10 @@ static IRecipeRenderer getRenderer(IRecipe recipe) { if (recipe == null) { LogHelper.error("Cannot get renderer for null recipe."); return null; - } else if (recipe instanceof ShapedRecipes) { - return new ShapedRecipesRenderer((ShapedRecipes) recipe); - } else if (recipe instanceof ShapelessRecipes) { - return new ShapelessRecipesRenderer((ShapelessRecipes) recipe); + } else if (recipe instanceof ShapedRecipe) { + return new ShapedRecipesRenderer((ShapedRecipe) recipe); + } else if (recipe instanceof ShapelessRecipe) { + return new ShapelessRecipesRenderer((ShapelessRecipe) recipe); } else if (recipe instanceof ShapedOreRecipe) { return new ShapedOreRecipeRenderer((ShapedOreRecipe) recipe); } else if (recipe instanceof ShapelessOreRecipe) { diff --git a/src/main/java/amerifrance/guideapi/page/PageImage.java b/src/main/java/amerifrance/guideapi/page/PageImage.java index f1ddacde..5e76c7e4 100644 --- a/src/main/java/amerifrance/guideapi/page/PageImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageImage.java @@ -5,10 +5,12 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class PageImage extends Page { @@ -22,9 +24,9 @@ public PageImage(ResourceLocation image) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { - Minecraft.getMinecraft().getTextureManager().bindTexture(image); + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { + Minecraft.getInstance().getTextureManager().bindTexture(image); GuiHelper.drawSizedIconWithoutColor(guiLeft + 50, guiTop + 34, guiBase.xSize, guiBase.ySize, 1F); } diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index 417d7c74..7d9c8a76 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -4,15 +4,14 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; import net.minecraft.block.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class PageItemStack extends PageText { @@ -60,8 +59,8 @@ public PageItemStack(String draw, String entry) { } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { GuiHelper.drawScaledItemStack(stack, guiLeft + 75, guiTop + 20, 3); } diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index 6ad26f9a..ce4e1c32 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.page; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.registries.ForgeRegistries; public class PageJsonRecipe extends PageIRecipe { diff --git a/src/main/java/amerifrance/guideapi/page/PageSound.java b/src/main/java/amerifrance/guideapi/page/PageSound.java index b040649f..65d13500 100644 --- a/src/main/java/amerifrance/guideapi/page/PageSound.java +++ b/src/main/java/amerifrance/guideapi/page/PageSound.java @@ -6,12 +6,14 @@ import api.impl.Page; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiEntry; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundEvent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class PageSound extends Page { @@ -28,32 +30,32 @@ public PageSound(IPage pageToEmulate, SoundEvent sound) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { pageToEmulate.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { pageToEmulate.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); } @Override - public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { + public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { return pageToEmulate.canSee(book, category, entry, player, bookStack, guiEntry); } @Override - @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { + @OnlyIn(Dist.CLIENT) + public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { GuideMod.PROXY.playSound(sound); pageToEmulate.onLeftClicked(book, category, entry, mouseX, mouseY, player, guiEntry); } @Override - @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { + @OnlyIn(Dist.CLIENT) + public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { pageToEmulate.onRightClicked(book, category, entry, mouseX, mouseY, player, guiEntry); } diff --git a/src/main/java/amerifrance/guideapi/page/PageText.java b/src/main/java/amerifrance/guideapi/page/PageText.java index 7982e202..e1dd3ca9 100644 --- a/src/main/java/amerifrance/guideapi/page/PageText.java +++ b/src/main/java/amerifrance/guideapi/page/PageText.java @@ -5,11 +5,12 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.PageHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.resources.I18n; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + public class PageText extends Page { @@ -30,17 +31,12 @@ public PageText(String draw) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { - boolean startFlag = fontRendererObj.getUnicodeFlag(); + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - if (unicode) - fontRendererObj.setUnicodeFlag(true); PageHelper.drawFormattedText(guiLeft + 39, guiTop + 12 + yOffset, guiBase, I18n.format(draw)); - if (unicode && !startFlag) - fontRendererObj.setUnicodeFlag(false); } @Override diff --git a/src/main/java/amerifrance/guideapi/page/PageTextImage.java b/src/main/java/amerifrance/guideapi/page/PageTextImage.java index fcf141c7..2c3770b7 100644 --- a/src/main/java/amerifrance/guideapi/page/PageTextImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageTextImage.java @@ -5,12 +5,12 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class PageTextImage extends Page { @@ -30,9 +30,9 @@ public PageTextImage(String draw, ResourceLocation image, boolean drawAtTop) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { - Minecraft.getMinecraft().getTextureManager().bindTexture(image); + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { + Minecraft.getInstance().getTextureManager().bindTexture(image); GuiHelper.drawSizedIconWithoutColor(guiLeft + 50, guiTop + (drawAtTop ? 60 : 12), guiBase.xSize, guiBase.ySize, 0); pageText.setUnicodeFlag(unicode); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java index 23be4441..83dc4d0e 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java @@ -7,11 +7,11 @@ import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import com.google.common.base.Strings; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.NonNullList; @@ -31,7 +31,7 @@ public BasicRecipeRenderer(T recipe) { } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { Minecraft mc = Minecraft.getMinecraft(); long time = mc.world.getTotalWorldTime(); @@ -63,7 +63,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int protected ItemStack getNextItem(ItemStack stack, int position) { NonNullList subItems = NonNullList.create(); - stack.getItem().getSubItems(CreativeTabs.SEARCH, subItems); + stack.getItem().getSubItems(ItemGroup.SEARCH, subItems); return subItems.get(getRandomizedCycle(position, subItems.size())); } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java index 593f7400..787a1fc6 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java @@ -1,12 +1,12 @@ package amerifrance.guideapi.page.reciperenderer; -import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapedRecipe; import net.minecraftforge.oredict.ShapedOreRecipe; // TODO: Fix rendering of recipe public class ShapedOreRecipeRenderer extends ShapedRecipesRenderer { public ShapedOreRecipeRenderer(ShapedOreRecipe recipe) { - super(new ShapedRecipes(recipe.getGroup(), recipe.getWidth(), recipe.getHeight(), recipe.getIngredients(), recipe.getRecipeOutput())); + super(new ShapedRecipe(recipe.getGroup(), recipe.getWidth(), recipe.getHeight(), recipe.getIngredients(), recipe.getRecipeOutput())); } } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index b3c3781e..cf8b0a0b 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -4,31 +4,30 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipes; -import net.minecraftforge.oredict.OreDictionary; +import net.minecraft.item.crafting.ShapedRecipe; import java.util.Arrays; import java.util.List; -public class ShapedRecipesRenderer extends BasicRecipeRenderer { +public class ShapedRecipesRenderer extends BasicRecipeRenderer { - public ShapedRecipesRenderer(ShapedRecipes recipe) { + public ShapedRecipesRenderer(ShapedRecipe recipe) { super(recipe); } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); - for (int y = 0; y < recipe.recipeHeight; y++) { - for (int x = 0; x < recipe.recipeWidth; x++) { + for (int y = 0; y < recipe.getRecipeHeight(); y++) { + for (int x = 0; x < recipe.getRecipeHeight(); x++) { int stackX = (x + 1) * 17 + (guiLeft + 27) + x; int stackY = (y + 1) * 17 + (guiTop + 38) + y; - Ingredient ingredient = recipe.getIngredients().get(y * recipe.recipeWidth + x); + Ingredient ingredient = recipe.getIngredients().get(y * recipe.getRecipeWidth() + x); List list = Arrays.asList(ingredient.getMatchingStacks()); if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java index e4e25fce..e79243b9 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java @@ -1,7 +1,6 @@ package amerifrance.guideapi.page.reciperenderer; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraftforge.oredict.ShapelessOreRecipe; +import net.minecraft.item.crafting.ShapelessRecipe; public class ShapelessOreRecipeRenderer extends ShapelessRecipesRenderer { diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index a99a78c0..6103c778 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -5,24 +5,23 @@ import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraftforge.oredict.OreDictionary; +import net.minecraft.item.crafting.ShapelessRecipe; import java.util.Arrays; import java.util.List; -public class ShapelessRecipesRenderer extends BasicRecipeRenderer { +public class ShapelessRecipesRenderer extends BasicRecipeRenderer { - public ShapelessRecipesRenderer(ShapelessRecipes recipe) { + public ShapelessRecipesRenderer(ShapelessRecipe recipe) { super(recipe); } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index 0989ba40..d55c8147 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -6,9 +6,9 @@ import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiEntry; +import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SimpleSound; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.SoundEvent; @@ -18,7 +18,7 @@ public class ClientProxy extends CommonProxy { @Override public void playSound(SoundEvent sound) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(sound, 1.0F)); + Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(sound,1)); } @Override @@ -29,13 +29,13 @@ public void openEntry(Book book, CategoryAbstract categoryAbstract, EntryAbstrac return; } - Minecraft.getMinecraft().displayGuiScreen(new GuiEntry(book, categoryAbstract, entryAbstract, player, stack)); + Minecraft.getInstance().displayGuiScreen(new EntryScreen(book, categoryAbstract, entryAbstract, player, stack)); } @Override public void initColors() { for (ItemStack bookStack : GuideAPI.getBookToStack().values()) { - Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> { + Minecraft.getInstance().getItemColors().registerItemColorHandler((stack, tintIndex) -> { IGuideItem guideItem = (IGuideItem) stack.getItem(); if (guideItem.getBook(stack) != null && tintIndex == 0) return guideItem.getBook(stack).getColor().getRGB(); diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index 73c31602..a8ada50d 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -6,9 +6,9 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.NBTBookTags; -import amerifrance.guideapi.gui.GuiCategory; -import amerifrance.guideapi.gui.GuiEntry; -import amerifrance.guideapi.gui.GuiHome; +import amerifrance.guideapi.gui.CategoryScreen; +import amerifrance.guideapi.gui.EntryScreen; +import amerifrance.guideapi.gui.HomeScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -38,18 +38,18 @@ public Object getClientGuiElement(int ID, PlayerEntity player, World world, int CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG)); EntryAbstract entry = category.entries.get(new ResourceLocation(tagCompound.getString(NBTBookTags.ENTRY_TAG))); int pageNumber = tagCompound.getInteger(NBTBookTags.PAGE_TAG); - GuiEntry guiEntry = new GuiEntry(book, category, entry, player, bookStack); + EntryScreen guiEntry = new EntryScreen(book, category, entry, player, bookStack); guiEntry.pageNumber = pageNumber; return guiEntry; } else if (tagCompound.hasKey(NBTBookTags.CATEGORY_TAG)) { CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG)); int entryPage = tagCompound.getInteger(NBTBookTags.ENTRY_PAGE_TAG); - GuiCategory guiCategory = new GuiCategory(book, category, player, bookStack, null); + CategoryScreen guiCategory = new CategoryScreen(book, category, player, bookStack, null); guiCategory.entryPage = entryPage; return guiCategory; } else { int categoryNumber = tagCompound.getInteger(NBTBookTags.CATEGORY_PAGE_TAG); - GuiHome guiHome = new GuiHome(book, player, bookStack); + HomeScreen guiHome = new HomeScreen(book, player, bookStack); guiHome.categoryPage = categoryNumber; return guiHome; } @@ -58,7 +58,7 @@ public Object getClientGuiElement(int ID, PlayerEntity player, World world, int // No-op: If the linked content doesn't exist anymore } - return new GuiHome(book, player, bookStack); + return new HomeScreen(book, player, bookStack); } return null; diff --git a/src/main/java/amerifrance/guideapi/test/TestBook3.java b/src/main/java/amerifrance/guideapi/test/TestBook3.java index 5adcb6f5..b6155085 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook3.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook3.java @@ -10,9 +10,10 @@ import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.block.Blocks; +import net.minecraft.item.ItemGroup; import net.minecraft.item.Items; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.potion.Potions; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionUtils; @@ -20,7 +21,7 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.brewing.BrewingRecipe; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import javax.annotation.Nullable; @@ -37,20 +38,18 @@ public Book buildBook() { BookBinder binder = new BookBinder(new ResourceLocation(GuideMod.ID, "test_book3")) .setAuthor("TunHet") .setColor(0x7EF67F) - .setCreativeTab(CreativeTabs.COMBAT) + .setCreativeTab(ItemGroup.COMBAT) .setGuideTitle("some.guide.title") .setHeader("some.header.text") .setSpawnWithBook(); - CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BANNER)).withKeyBase("guideapi"); + CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLACK_BANNER)).withKeyBase("guideapi"); testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); - testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.PLANKS, 1, 4))); - testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe( - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.AWKWARD), - new ItemStack(Items.SPECKLED_MELON), - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.HEALING))) + testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); + testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks( PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), + PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); binder.addCategory(testCategory); diff --git a/src/main/java/amerifrance/guideapi/util/APISetter.java b/src/main/java/amerifrance/guideapi/util/APISetter.java index c8f06786..8f2cad62 100644 --- a/src/main/java/amerifrance/guideapi/util/APISetter.java +++ b/src/main/java/amerifrance/guideapi/util/APISetter.java @@ -6,8 +6,7 @@ import com.google.common.base.Throwables; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.ModLoadingContext; import java.lang.reflect.Field; import java.util.List; @@ -73,8 +72,8 @@ public static void setIndexedBooks(List books) { } private static void sanityCheck() throws IllegalAccessException { - ModContainer activeMod = Loader.instance().activeModContainer(); - if (!activeMod.getModId().equals(GuideMod.ID)) - throw new IllegalAccessException("Mod " + activeMod.getModId() + " tried to access an internal-only method in GuideAPI. Please report this."); + String activeMod = ModLoadingContext.get().getActiveNamespace(); + if (!GuideMod.ID.equals(activeMod)) + throw new IllegalAccessException("Mod " + activeMod + " tried to access an internal-only method in GuideAPI. Please report this."); } } diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index 5de2071f..05729bf4 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -15,21 +15,22 @@ import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.ItemHandlerHelper; import java.util.Collection; @@ -46,25 +47,25 @@ public static void onPlayerJoinWorld(EntityJoinWorldEvent event) { for (Book book : GuideAPI.getBooks().values()) { if (ConfigHandler.SPAWN_BOOKS.getOrDefault(book, false) && !tag.getBoolean("hasInitial" + book.getTitle())) { ItemHandlerHelper.giveItemToPlayer(player, GuideAPI.getStackFromBook(book)); - tag.setBoolean("hasInitial" + book.getTitle(), true); + tag.putBoolean("hasInitial" + book.getTitle(), true); } } } } } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void renderOverlay(RenderGameOverlayEvent.Pre event) { if (event.getType() != RenderGameOverlayEvent.ElementType.CROSSHAIRS) return; - RayTraceResult rayTrace = Minecraft.getMinecraft().objectMouseOver; - if (rayTrace == null || rayTrace.typeOfHit != RayTraceResult.Type.BLOCK) + RayTraceResult rayTrace = Minecraft.getInstance().objectMouseOver; + if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK) return; - PlayerEntity player = Minecraft.getMinecraft().player; - World world = Minecraft.getMinecraft().world; + PlayerEntity player = Minecraft.getInstance().player; + World world = Minecraft.getInstance().world; ItemStack held = ItemStack.EMPTY; Book book = null; for (Hand hand : Hand.values()) { @@ -78,12 +79,12 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { if (book == null) return; - - BlockState state = world.getBlockState(rayTrace.getBlockPos()); + BlockPos rayTracePos=((BlockRayTraceResult)rayTrace).getPos(); + BlockState state = world.getBlockState(rayTracePos); String linkedEntry = null; if (state.getBlock() instanceof IGuideLinked) { IGuideLinked linked = (IGuideLinked) state.getBlock(); - ResourceLocation entryKey = linked.getLinkedEntry(world, rayTrace.getBlockPos(), player, held); + ResourceLocation entryKey = linked.getLinkedEntry(world, rayTracePos, player, held); if (entryKey != null) { for (CategoryAbstract category : book.getCategoryList()) { if (category.entries.containsKey(entryKey)) { @@ -95,12 +96,12 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { } if (!Strings.isNullOrEmpty(linkedEntry)) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int drawX = scaledResolution.getScaledWidth() / 2 + 10; - int drawY = scaledResolution.getScaledHeight() / 2 - 8; + FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; + + int drawX = Minecraft.getInstance().mainWindow.getScaledWidth() / 2 + 10; + int drawY = Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - 8; - Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(held, drawX, drawY); + Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(held, drawX, drawY); drawY -= 2; drawX += 20; @@ -109,9 +110,9 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { } if (state.getBlock() instanceof IInfoRenderer.Block) { - IInfoRenderer infoRenderer = ((IInfoRenderer.Block) state.getBlock()).getInfoRenderer(book, world, rayTrace.getBlockPos(), state, rayTrace, player); + IInfoRenderer infoRenderer = ((IInfoRenderer.Block) state.getBlock()).getInfoRenderer(book, world, rayTracePos, state, rayTrace, player); if (book == ((IInfoRenderer.Block) state.getBlock()).getBook() && infoRenderer != null) - infoRenderer.drawInformation(book, world, rayTrace.getBlockPos(), state, rayTrace, player); + infoRenderer.drawInformation(book, world, rayTracePos, state, rayTrace, player); } Multimap, IInfoRenderer> bookRenderers = GuideAPI.getInfoRenderers().get(book); @@ -120,26 +121,26 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { Collection renderers = bookRenderers.get(state.getBlock().getClass()); for (IInfoRenderer renderer : renderers) - renderer.drawInformation(book, world, rayTrace.getBlockPos(), state, rayTrace, player); + renderer.drawInformation(book, world, rayTracePos, state, rayTrace, player); } public static CompoundNBT getModTag(PlayerEntity player, String modName) { - CompoundNBT tag = player.getEntityData(); + CompoundNBT tag = player.getPersistentData(); CompoundNBT persistTag; - if (tag.hasKey(PlayerEntity.PERSISTED_NBT_TAG)) - persistTag = tag.getCompoundTag(PlayerEntity.PERSISTED_NBT_TAG); + if (tag.contains(PlayerEntity.PERSISTED_NBT_TAG)) + persistTag = tag.getCompound(PlayerEntity.PERSISTED_NBT_TAG); else { persistTag = new CompoundNBT(); - tag.setTag(PlayerEntity.PERSISTED_NBT_TAG, persistTag); + tag.put(PlayerEntity.PERSISTED_NBT_TAG, persistTag); } CompoundNBT modTag; - if (persistTag.hasKey(modName)) { - modTag = persistTag.getCompoundTag(modName); + if (persistTag.contains(modName)) { + modTag = persistTag.getCompound(modName); } else { modTag = new CompoundNBT(); - persistTag.setTag(modName, modTag); + persistTag.put(modName, modTag); } return modTag; } diff --git a/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java index c7f16578..059de800 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java @@ -1,6 +1,6 @@ package amerifrance.guideapi.wrapper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; public abstract class AbstractWrapper { @@ -8,9 +8,9 @@ public abstract class AbstractWrapper { public abstract boolean canPlayerSee(); - public abstract void draw(int mouseX, int mouseY, GuiBase gui); + public abstract void draw(int mouseX, int mouseY, BaseScreen gui); - public abstract void drawExtras(int mouseX, int mouseY, GuiBase gui); + public abstract void drawExtras(int mouseX, int mouseY, BaseScreen gui); public abstract boolean isMouseOnWrapper(int mouseX, int mouseY); } diff --git a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java index d61b501b..ed1a503d 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java @@ -3,9 +3,9 @@ import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -16,11 +16,11 @@ public class CategoryWrapper extends AbstractWrapper { public int x, y, width, height; public PlayerEntity player; public FontRenderer renderer; - public RenderItem renderItem; + public ItemRenderer renderItem; public boolean drawOnLeft; public ItemStack bookStack; - public CategoryWrapper(Book book, CategoryAbstract category, int x, int y, int width, int height, PlayerEntity player, FontRenderer renderer, RenderItem renderItem, boolean drawOnLeft, ItemStack bookStack) { + public CategoryWrapper(Book book, CategoryAbstract category, int x, int y, int width, int height, PlayerEntity player, FontRenderer renderer, ItemRenderer renderItem, boolean drawOnLeft, ItemStack bookStack) { this.book = book; this.category = category; this.x = x; @@ -44,12 +44,12 @@ public boolean canPlayerSee() { } @Override - public void draw(int mouseX, int mouseY, GuiBase gui) { + public void draw(int mouseX, int mouseY, BaseScreen gui) { category.draw(book, x, y, width, height, mouseX, mouseY, gui, drawOnLeft, renderItem); } @Override - public void drawExtras(int mouseX, int mouseY, GuiBase gui) { + public void drawExtras(int mouseX, int mouseY, BaseScreen gui) { category.drawExtras(book, x, y, width, height, mouseX, mouseY, gui, drawOnLeft, renderItem); } diff --git a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java index 9a8d2b6d..e574e179 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java @@ -4,8 +4,8 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiCategory; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.CategoryScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; @@ -19,10 +19,10 @@ public class EntryWrapper extends AbstractWrapper { public int x, y, width, height; public PlayerEntity player; public FontRenderer renderer; - public GuiCategory categoryGui; + public CategoryScreen categoryGui; public ItemStack bookStack; - public EntryWrapper(GuiCategory categoryGui, Book book, CategoryAbstract category, EntryAbstract entry, int x, int y, int width, int height, PlayerEntity player, FontRenderer renderer, ItemStack bookStack) { + public EntryWrapper(CategoryScreen categoryGui, Book book, CategoryAbstract category, EntryAbstract entry, int x, int y, int width, int height, PlayerEntity player, FontRenderer renderer, ItemStack bookStack) { this.book = book; this.category = category; this.entry = entry; @@ -46,12 +46,12 @@ public boolean canPlayerSee() { } @Override - public void draw(int mouseX, int mouseY, GuiBase gui) { + public void draw(int mouseX, int mouseY, BaseScreen gui) { entry.draw(book, category, x, y, width, height, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); } @Override - public void drawExtras(int mouseX, int mouseY, GuiBase gui) { + public void drawExtras(int mouseX, int mouseY, BaseScreen gui) { entry.drawExtras(book, category, x, y, width, height, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); } diff --git a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java index e19843da..7bd90e05 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java @@ -4,8 +4,8 @@ import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiEntry; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; @@ -13,7 +13,7 @@ public class PageWrapper extends AbstractWrapper { - public GuiEntry guiEntry; + public EntryScreen guiEntry; public Book book; public CategoryAbstract category; public EntryAbstract entry; @@ -23,7 +23,7 @@ public class PageWrapper extends AbstractWrapper { public FontRenderer renderer; public ItemStack bookStack; - public PageWrapper(GuiEntry guiEntry, Book book, CategoryAbstract category, EntryAbstract entry, IPage page, int guiLeft, int guiTop, PlayerEntity player, FontRenderer renderer, ItemStack bookStack) { + public PageWrapper(EntryScreen guiEntry, Book book, CategoryAbstract category, EntryAbstract entry, IPage page, int guiLeft, int guiTop, PlayerEntity player, FontRenderer renderer, ItemStack bookStack) { this.guiEntry = guiEntry; this.book = book; this.category = category; @@ -46,12 +46,12 @@ public boolean canPlayerSee() { } @Override - public void draw(int mouseX, int mouseY, GuiBase gui) { + public void draw(int mouseX, int mouseY, BaseScreen gui) { page.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); } @Override - public void drawExtras(int mouseX, int mouseY, GuiBase gui) { + public void drawExtras(int mouseX, int mouseY, BaseScreen gui) { page.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); } diff --git a/src/main/java/api/IPage.java b/src/main/java/api/IPage.java index d869b193..185462de 100644 --- a/src/main/java/api/IPage.java +++ b/src/main/java/api/IPage.java @@ -1,5 +1,7 @@ package api; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.EntryScreen; import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; @@ -12,19 +14,19 @@ public interface IPage { @OnlyIn(Dist.CLIENT) - void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); + void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); @OnlyIn(Dist.CLIENT) - void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); + void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); - boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry); + boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry); @OnlyIn(Dist.CLIENT) - void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry); + void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry); @OnlyIn(Dist.CLIENT) - void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry); + void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry); @OnlyIn(Dist.CLIENT) - void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry); + void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry); } diff --git a/src/main/java/api/IRecipeRenderer.java b/src/main/java/api/IRecipeRenderer.java index b9de4f17..f4fab7fd 100644 --- a/src/main/java/api/IRecipeRenderer.java +++ b/src/main/java/api/IRecipeRenderer.java @@ -1,5 +1,6 @@ package api; +import amerifrance.guideapi.gui.BaseScreen; import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; @@ -14,10 +15,10 @@ public interface IRecipeRenderer { @OnlyIn(Dist.CLIENT) - void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); + void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); @OnlyIn(Dist.CLIENT) - void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj); + void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); abstract class RecipeRendererBase implements IRecipeRenderer { @@ -29,7 +30,7 @@ public RecipeRendererBase(T recipe) { } @Override - public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { guiBase.drawHoveringText(tooltips, mouseX, mouseY); tooltips.clear(); } diff --git a/src/main/java/api/SubTexture.java b/src/main/java/api/SubTexture.java index 03fa136a..f576fa0e 100644 --- a/src/main/java/api/SubTexture.java +++ b/src/main/java/api/SubTexture.java @@ -3,14 +3,11 @@ import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public class SubTexture { @@ -62,7 +59,7 @@ public SubTexture(ResourceLocation textureLocation, int xPos, int yPos, int widt public void draw(int drawX, int drawY, double zLevel) { final float someMagicValueFromMojang = 0.00390625F; - Minecraft.getInstance().renderEngine.bindTexture(textureLocation); + Minecraft.getInstance().getTextureManager().bindTexture(textureLocation); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); diff --git a/src/main/java/api/button/ButtonGuideAPI.java b/src/main/java/api/button/ButtonGuideAPI.java index fa9d775d..de46bd99 100644 --- a/src/main/java/api/button/ButtonGuideAPI.java +++ b/src/main/java/api/button/ButtonGuideAPI.java @@ -1,13 +1,13 @@ package api.button; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.widget.button.Button; public class ButtonGuideAPI extends Button { - public GuiBase guiBase; + public BaseScreen guiBase; - public ButtonGuideAPI(int id, int x, int y, GuiBase guiBase) { + public ButtonGuideAPI(int id, int x, int y, BaseScreen guiBase) { super(id, x, y, ""); this.guiBase = guiBase; } diff --git a/src/main/java/api/impl/Book.java b/src/main/java/api/impl/Book.java index 24715a29..f95c3c97 100644 --- a/src/main/java/api/impl/Book.java +++ b/src/main/java/api/impl/Book.java @@ -4,7 +4,7 @@ import api.util.TextHelper; import com.google.common.base.Joiner; import com.google.common.collect.Lists; -import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -26,13 +26,13 @@ public class Book { private Color color = new Color(171, 70, 30); private boolean spawnWithBook; private ResourceLocation registryName; - private CreativeTabs creativeTab = CreativeTabs.MISC; + private ItemGroup creativeTab = ItemGroup.MISC; /** * @deprecated see {@link BookBinder}. To be made package private in 1.13. */ @Deprecated - public Book(List categoryList, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, boolean customModel, Color color, boolean spawnWithBook, ResourceLocation registryName, CreativeTabs creativeTab) { + public Book(List categoryList, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, boolean customModel, Color color, boolean spawnWithBook, ResourceLocation registryName, ItemGroup creativeTab) { this.categories = categoryList; this.title = title; this.header = header; @@ -98,7 +98,7 @@ public ResourceLocation getRegistryName() { return this.registryName; } - public CreativeTabs getCreativeTab() { + public ItemGroup getCreativeTab() { return this.creativeTab; } @@ -223,10 +223,10 @@ public void setRegistryName(ResourceLocation registryName) { } /** - * @deprecated see {@link BookBinder#setCreativeTab(CreativeTabs)}. To be removed in 1.13. + * @deprecated see {@link BookBinder#setCreativeTab(ItemGroup)}. To be removed in 1.13. */ @Deprecated - public void setCreativeTab(CreativeTabs creativeTab) { + public void setCreativeTab(ItemGroup creativeTab) { this.creativeTab = creativeTab; } diff --git a/src/main/java/api/impl/BookBinder.java b/src/main/java/api/impl/BookBinder.java index 58ed5523..4aa27e14 100644 --- a/src/main/java/api/impl/BookBinder.java +++ b/src/main/java/api/impl/BookBinder.java @@ -3,9 +3,13 @@ import api.impl.abstraction.CategoryAbstract; import com.google.common.base.Strings; import com.google.common.collect.Lists; -import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.forgespi.language.IModInfo; import java.awt.Color; import java.util.List; @@ -23,7 +27,7 @@ public class BookBinder { private boolean hasCustomModel; private Color color = new Color(171, 70, 30); private boolean spawnWithBook; - private CreativeTabs creativeTab = CreativeTabs.MISC; + private ItemGroup creativeTab = ItemGroup.MISC; /** * Creates a new {@link Book} builder which will provide a much more user-friendly interface for creating books. @@ -180,12 +184,12 @@ public BookBinder setSpawnWithBook() { /** * Sets the Creative Tab this book should appear in. * - * By default, all books will appear in {@link CreativeTabs#MISC}. + * By default, all books will appear in {@link ItemGroup#MISC}. * * @param creativeTab The creative tab this book should display in. * @return the builder instance for chaining. */ - public BookBinder setCreativeTab(CreativeTabs creativeTab) { + public BookBinder setCreativeTab(ItemGroup creativeTab) { this.creativeTab = creativeTab; return this; } @@ -196,7 +200,7 @@ public BookBinder setCreativeTab(CreativeTabs creativeTab) { */ public Book build() { if (Strings.isNullOrEmpty(author)) - this.author = Loader.instance().getIndexedModList().getOrDefault(registryName.getResourceDomain(), Loader.instance().getMinecraftModContainer()).getName(); + this.author = ModList.get().getModContainerById(registryName.getNamespace()).map(ModContainer::getModInfo).map(IModInfo::getDisplayName).orElse("Unknown"); if (header == null) this.header = guideTitle; diff --git a/src/main/java/api/impl/Category.java b/src/main/java/api/impl/Category.java index 01094425..014e379b 100644 --- a/src/main/java/api/impl/Category.java +++ b/src/main/java/api/impl/Category.java @@ -2,14 +2,16 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiCategory; -import amerifrance.guideapi.gui.GuiHome; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.CategoryScreen; +import amerifrance.guideapi.gui.HomeScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.Map; @@ -24,13 +26,13 @@ public Category(String name) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem) { + @OnlyIn(Dist.CLIENT) + public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { } @Override @@ -39,18 +41,18 @@ public boolean canSee(PlayerEntity player, ItemStack bookStack) { } @Override - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void onLeftClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack) { - Minecraft.getMinecraft().displayGuiScreen(new GuiCategory(book, this, player, bookStack, null)); + Minecraft.getInstance().displayGuiScreen(new CategoryScreen(book, this, player, bookStack, null)); } @Override - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack) { } @Override - @SideOnly(Side.CLIENT) - public void onInit(Book book, GuiHome guiHome, PlayerEntity player, ItemStack bookStack) { + @OnlyIn(Dist.CLIENT) + public void onInit(Book book, HomeScreen guiHome, PlayerEntity player, ItemStack bookStack) { } } diff --git a/src/main/java/api/impl/Entry.java b/src/main/java/api/impl/Entry.java index 1c79a34a..79832ec8 100644 --- a/src/main/java/api/impl/Entry.java +++ b/src/main/java/api/impl/Entry.java @@ -4,15 +4,15 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import api.util.GuiHelper; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiCategory; -import amerifrance.guideapi.gui.GuiEntry; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.CategoryScreen; +import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.awt.Color; import java.util.Collections; @@ -37,8 +37,8 @@ public Entry(String name) { } @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { boolean startFlag = fontRendererObj.getUnicodeFlag(); @@ -65,8 +65,8 @@ public void draw(Book book, CategoryAbstract category, int entryX, int entryY, i } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { boolean startFlag = fontRendererObj.getUnicodeFlag(); fontRendererObj.setUnicodeFlag(false); @@ -92,18 +92,18 @@ public boolean canSee(PlayerEntity player, ItemStack bookStack) { } @Override - @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory) { - Minecraft.getMinecraft().displayGuiScreen(new GuiEntry(book, category, this, player, guiCategory.bookStack)); + @OnlyIn(Dist.CLIENT) + public void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory) { + Minecraft.getInstance().displayGuiScreen(new EntryScreen(book, category, this, player, guiCategory.bookStack)); } @Override - @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory) { + @OnlyIn(Dist.CLIENT) + public void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory) { } @Override - @SideOnly(Side.CLIENT) - public void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, PlayerEntity player, ItemStack bookStack) { + @OnlyIn(Dist.CLIENT) + public void onInit(Book book, CategoryAbstract category, CategoryScreen guiCategory, PlayerEntity player, ItemStack bookStack) { } } \ No newline at end of file diff --git a/src/main/java/api/impl/Page.java b/src/main/java/api/impl/Page.java index 97f853c0..88a007c8 100644 --- a/src/main/java/api/impl/Page.java +++ b/src/main/java/api/impl/Page.java @@ -3,44 +3,46 @@ import api.IPage; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiEntry; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class Page implements IPage { protected boolean unicode; @Override - @SideOnly(Side.CLIENT) - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { } @Override - @SideOnly(Side.CLIENT) - public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRendererObj) { + @OnlyIn(Dist.CLIENT) + public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { } @Override - public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { + public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { return true; } @Override - @SideOnly(Side.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { + @OnlyIn(Dist.CLIENT) + public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { } @Override - @SideOnly(Side.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, GuiEntry guiEntry) { + @OnlyIn(Dist.CLIENT) + public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { } @Override - @SideOnly(Side.CLIENT) - public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, GuiEntry guiEntry) { + @OnlyIn(Dist.CLIENT) + public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { } public void setUnicodeFlag(boolean flag) { diff --git a/src/main/java/api/impl/abstraction/CategoryAbstract.java b/src/main/java/api/impl/abstraction/CategoryAbstract.java index 96678e0c..6700278d 100644 --- a/src/main/java/api/impl/abstraction/CategoryAbstract.java +++ b/src/main/java/api/impl/abstraction/CategoryAbstract.java @@ -2,15 +2,17 @@ import api.impl.Book; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiHome; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.HomeScreen; import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; import java.util.Map; @@ -132,10 +134,10 @@ public List getTooltip() { } @OnlyIn(Dist.CLIENT) - public abstract void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem); + public abstract void draw(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem); @OnlyIn(Dist.CLIENT) - public abstract void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, GuiBase guiBase, boolean drawOnLeft, RenderItem renderItem); + public abstract void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem); public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); @@ -146,7 +148,7 @@ public List getTooltip() { public abstract void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); @OnlyIn(Dist.CLIENT) - public abstract void onInit(Book book, GuiHome guiHome, PlayerEntity player, ItemStack bookStack); + public abstract void onInit(Book book, HomeScreen guiHome, PlayerEntity player, ItemStack bookStack); @Override public boolean equals(Object o) { diff --git a/src/main/java/api/impl/abstraction/EntryAbstract.java b/src/main/java/api/impl/abstraction/EntryAbstract.java index 71d8a66a..fcf47a58 100644 --- a/src/main/java/api/impl/abstraction/EntryAbstract.java +++ b/src/main/java/api/impl/abstraction/EntryAbstract.java @@ -3,12 +3,14 @@ import api.IPage; import api.impl.Book; import api.util.TextHelper; -import amerifrance.guideapi.gui.GuiBase; -import amerifrance.guideapi.gui.GuiCategory; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.CategoryScreen; import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; @@ -57,21 +59,21 @@ public String getLocalizedName() { } @OnlyIn(Dist.CLIENT) - public abstract void draw(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer renderer); + public abstract void draw(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer renderer); @OnlyIn(Dist.CLIENT) - public abstract void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, GuiBase guiBase, FontRenderer renderer); + public abstract void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer renderer); public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); @OnlyIn(Dist.CLIENT) - public abstract void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory); + public abstract void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory); @OnlyIn(Dist.CLIENT) - public abstract void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, GuiCategory guiCategory); + public abstract void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory); @OnlyIn(Dist.CLIENT) - public abstract void onInit(Book book, CategoryAbstract category, GuiCategory guiCategory, PlayerEntity player, ItemStack bookStack); + public abstract void onInit(Book book, CategoryAbstract category, CategoryScreen guiCategory, PlayerEntity player, ItemStack bookStack); @Override public boolean equals(Object o) { diff --git a/src/main/java/api/package-info.java b/src/main/java/api/package-info.java index aa8728bd..e165a207 100644 --- a/src/main/java/api/package-info.java +++ b/src/main/java/api/package-info.java @@ -1,4 +1,2 @@ -@API(owner = "guideapi", apiVersion = "@API_VERSION@", provides = "Guide-API|API") package api; -import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/api/util/GuiHelper.java b/src/main/java/api/util/GuiHelper.java index fcf6b150..db91361b 100644 --- a/src/main/java/api/util/GuiHelper.java +++ b/src/main/java/api/util/GuiHelper.java @@ -1,22 +1,25 @@ package api.util; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.util.ITooltipFlag.TooltipFlags; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import org.lwjgl.opengl.GL11; import java.awt.Color; import java.util.List; -import static net.minecraft.client.renderer.GlStateManager.*; +import static com.mojang.blaze3d.platform.GlStateManager.*; + public class GuiHelper { - private static final RenderItem render = Minecraft.getMinecraft().getRenderItem(); + private static final ItemRenderer render = Minecraft.getInstance().getItemRenderer(); /** * @param mouseX - Position of the mouse on the x-axiq @@ -46,7 +49,7 @@ public static void drawItemStack(ItemStack stack, int x, int y) { enableRescaleNormal(); enableDepth(); render.renderItemAndEffectIntoGUI(stack, x, y); - render.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, stack, x, y, null); + render.renderItemOverlayIntoGUI(Minecraft.getInstance().fontRenderer, stack, x, y, null); RenderHelper.disableStandardItemLighting(); popMatrix(); disableLighting(); @@ -62,10 +65,10 @@ public static void drawScaledItemStack(ItemStack stack, int x, int y, float scal pushMatrix(); enableBlend(); blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - scale(scale, scale, 1.0F); + scalef(scale, scale, 1.0F); RenderHelper.enableGUIStandardItemLighting(); enableRescaleNormal(); - enableDepth(); + enableDepthTest();//enableDepth? render.renderItemAndEffectIntoGUI(stack, (int) (x / scale), (int) (y / scale)); RenderHelper.disableStandardItemLighting(); popMatrix(); @@ -85,7 +88,7 @@ public static void drawIconWithoutColor(int x, int y, int width, int height, flo RenderHelper.enableGUIStandardItemLighting(); disableLighting(); enableRescaleNormal(); - enableDepth(); + enableDepthTest(); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos(x, y + height, zLevel).tex(0D, 1D).endVertex(); @@ -112,8 +115,8 @@ public static void drawIconWithColor(int x, int y, int width, int height, float RenderHelper.enableGUIStandardItemLighting(); disableLighting(); enableRescaleNormal(); - enableDepth(); - color((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F, (float) color.getAlpha() / 255F); + enableDepthTest(); + color4f((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F, (float) color.getAlpha() / 255F); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos(x, y + height, zLevel).tex(0D, 1D).endVertex(); @@ -122,7 +125,7 @@ public static void drawIconWithColor(int x, int y, int width, int height, float tessellator.getBuffer().pos(x, y, zLevel).tex(0D, 0D).endVertex(); tessellator.draw(); RenderHelper.disableStandardItemLighting(); - color(1.0F, 1.0F, 1.0F, 1.0F); + color4f(1.0F, 1.0F, 1.0F, 1.0F); popMatrix(); } @@ -137,13 +140,13 @@ public static void drawSizedIconWithoutColor(int x, int y, int width, int height pushMatrix(); enableBlend(); blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - color(1F, 1F, 1F, 1F); - scale(0.5D, 0.5D, 0.5D); - translate(x, y, zLevel); + color4f(1F, 1F, 1F, 1F); + scaled(0.5D, 0.5D, 0.5D); + translated(x, y, zLevel); RenderHelper.enableGUIStandardItemLighting(); disableLighting(); enableRescaleNormal(); - enableDepth(); + enableDepthTest(); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos(x, y + height, zLevel).tex(0D, 1D).endVertex(); @@ -166,13 +169,13 @@ public static void drawSizedIconWithColor(int x, int y, int width, int height, f pushMatrix(); enableBlend(); blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - scale(0.5D, 0.5D, 0.5D); - color((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F, (float) color.getAlpha() / 255F); - translate(x, y, zLevel); + scaled(0.5D, 0.5D, 0.5D); + color4f((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F, (float) color.getAlpha() / 255F); + translated(x, y, zLevel); RenderHelper.enableGUIStandardItemLighting(); disableLighting(); enableRescaleNormal(); - enableDepth(); + enableDepthTest(); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos(x, y + height, zLevel).tex(0D, 1D).endVertex(); @@ -185,14 +188,14 @@ public static void drawSizedIconWithColor(int x, int y, int width, int height, f } @SuppressWarnings("unchecked") - public static List getTooltip(ItemStack stack) { - Minecraft mc = Minecraft.getMinecraft(); - List list = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? TooltipFlags.ADVANCED : TooltipFlags.NORMAL); + public static List getTooltip(ItemStack stack) { + Minecraft mc = Minecraft.getInstance(); + List list = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? TooltipFlags.ADVANCED : TooltipFlags.NORMAL); for (int k = 0; k < list.size(); ++k) { if (k == 0) { - list.set(k, stack.getRarity().rarityColor + list.get(k)); + list.get(k).applyTextStyle(stack.getRarity().color); } else { - list.set(k, TextFormatting.GRAY + list.get(k)); + list.get(k).applyTextStyle(TextFormatting.GRAY); } } return list; diff --git a/src/main/java/api/util/PageHelper.java b/src/main/java/api/util/PageHelper.java index a57f9425..b7ff08ae 100644 --- a/src/main/java/api/util/PageHelper.java +++ b/src/main/java/api/util/PageHelper.java @@ -2,7 +2,7 @@ import api.IPage; import api.impl.Page; -import amerifrance.guideapi.gui.GuiBase; +import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.page.PageItemStack; import amerifrance.guideapi.page.PageText; import net.minecraft.block.Block; @@ -51,7 +51,7 @@ public static List pagesForLongText(String locText, ItemStack stack) { return pageList; } - public static void drawFormattedText(int x, int y, GuiBase guiBase, String toDraw) { + public static void drawFormattedText(int x, int y, BaseScreen guiBase, String toDraw) { FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; toDraw = StringEscapeUtils.unescapeJava(toDraw).replaceAll("\\t", " "); String[] lines = toDraw.split("\n"); diff --git a/src/main/java/api/util/TextHelper.java b/src/main/java/api/util/TextHelper.java index 70c06a1d..03c9ad1b 100644 --- a/src/main/java/api/util/TextHelper.java +++ b/src/main/java/api/util/TextHelper.java @@ -1,6 +1,6 @@ package api.util; -import net.minecraft.util.text.translation.I18n; +import net.minecraft.client.resources.I18n; import org.apache.commons.lang3.text.WordUtils; import java.util.ArrayList; @@ -13,7 +13,7 @@ public static String getFormattedText(String string) { } public static String localize(String input, Object... format) { - return Il8n.translateToLocalFormatted(input, format); + return I18n.format(input, format); } public static String localizeEffect(String input, Object... format) { From 15faf44a756a318f3f19a1b636eee71c6f781149 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 21 Mar 2020 13:25:41 +0100 Subject: [PATCH 04/28] More updates II Still very much in progress --- .../java/amerifrance/guideapi/GuideMod.java | 55 ++++++++-------- .../guideapi/network/IMessage.java | 9 --- .../guideapi/network/PacketHandler.java | 4 +- .../guideapi/network/PacketSyncCategory.java | 62 +++++++++++-------- .../guideapi/network/PacketSyncEntry.java | 2 +- .../guideapi/network/PacketSyncHome.java | 56 ++++++++++------- .../guideapi/page/PageBrewingRecipe.java | 12 ++-- .../guideapi/page/PageIRecipe.java | 27 ++------ .../guideapi/page/PageItemStack.java | 16 +---- .../reciperenderer/BasicRecipeRenderer.java | 22 +++---- .../ShapedOreRecipeRenderer.java | 12 ---- .../reciperenderer/ShapedRecipesRenderer.java | 2 - .../ShapelessOreRecipeRenderer.java | 10 --- .../ShapelessRecipesRenderer.java | 3 - .../guideapi/proxy/ClientProxy.java | 2 +- .../guideapi/proxy/CommonProxy.java | 18 +++--- .../amerifrance/guideapi/test/TestBook.java | 14 +++-- src/main/java/api/IGuideBook.java | 2 +- src/main/java/api/IRecipeRenderer.java | 3 +- src/main/java/api/util/GuiHelper.java | 2 +- src/main/java/api/util/PageHelper.java | 2 +- 21 files changed, 146 insertions(+), 189 deletions(-) delete mode 100644 src/main/java/amerifrance/guideapi/network/IMessage.java delete mode 100644 src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java delete mode 100644 src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 152d3336..097eb0cf 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -1,64 +1,63 @@ package amerifrance.guideapi; +import amerifrance.guideapi.proxy.ClientProxy; import api.GuideAPI; import api.IGuideBook; import api.impl.Book; import amerifrance.guideapi.network.PacketHandler; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; -import net.minecraft.launchwrapper.Launch; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; import java.io.File; -@Mod(modid = GuideMod.ID, name = GuideMod.NAME, version = GuideMod.VERSION) +@Mod(value = GuideMod.ID) public class GuideMod { public static final String NAME = "Guide-API"; public static final String ID = "guideapi"; public static final String CHANNEL = "GuideAPI"; public static final String VERSION = "@VERSION@"; - public static final boolean IS_DEV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + public static boolean inDev = false; - @Mod.Instance(ID) public static GuideMod INSTANCE; - @SidedProxy(clientSide = "amerifrance.guideapi.proxy.ClientProxy", serverSide = "amerifrance.guideapi.proxy.CommonProxy") - public static CommonProxy PROXY; + public static CommonProxy PROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new); - public static File configDir; - public static ASMDataTable dataTable; + public GuideMod(){ + INSTANCE=this; + checkDevEnv(); + GuideAPI.initialize(); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete); - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) { - configDir = new File(event.getModConfigurationDirectory(), NAME); - configDir.mkdirs(); - ConfigHandler.init(new File(configDir, NAME + ".cfg")); - GuideAPI.initialize(); - dataTable = event.getAsmData(); + } - NetworkRegistry.INSTANCE.registerGuiHandler(this, PROXY); + private void setup(final FMLCommonSetupEvent event){ PacketHandler.registerPackets(); } - @Mod.EventHandler - public void init(FMLInitializationEvent event) { + private void loadComplete(final FMLLoadCompleteEvent event){ PROXY.initColors(); - } - - @Mod.EventHandler - public void postInit(FMLPostInitializationEvent event) { ConfigHandler.handleBookConfigs(); for (Pair guide : AnnotationHandler.BOOK_CLASSES) guide.getRight().handlePost(GuideAPI.getStackFromBook(guide.getLeft())); } + + + + + private void checkDevEnv() { + String launchTarget = System.getenv().get("target"); + if (launchTarget != null && launchTarget.contains("dev")) { + inDev = true; + } + } } diff --git a/src/main/java/amerifrance/guideapi/network/IMessage.java b/src/main/java/amerifrance/guideapi/network/IMessage.java deleted file mode 100644 index 170ae6f1..00000000 --- a/src/main/java/amerifrance/guideapi/network/IMessage.java +++ /dev/null @@ -1,9 +0,0 @@ -package amerifrance.guideapi.network; - -/** - * Guide-API - * - * @author maxanier - */ -public interface IMessage { -} diff --git a/src/main/java/amerifrance/guideapi/network/PacketHandler.java b/src/main/java/amerifrance/guideapi/network/PacketHandler.java index 28eaa06f..7ca012f6 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketHandler.java +++ b/src/main/java/amerifrance/guideapi/network/PacketHandler.java @@ -17,8 +17,8 @@ public class PacketHandler { public static void registerPackets() { INSTANCE.registerMessage(nextID(),PacketSyncEntry.class,PacketSyncEntry::encode,PacketSyncEntry::decode,PacketSyncEntry::handle); - INSTANCE.registerMessage(PacketSyncHome.class, PacketSyncHome.class, 0, Side.SERVER); - INSTANCE.registerMessage(PacketSyncCategory.class, PacketSyncCategory.class, 1, Side.SERVER); + INSTANCE.registerMessage(nextID(),PacketSyncCategory.class,PacketSyncCategory::encode,PacketSyncCategory::decode,PacketSyncCategory::handle); + INSTANCE.registerMessage(nextID(),PacketSyncHome.class,PacketSyncHome::encode,PacketSyncHome::decode,PacketSyncHome::handle); } protected static int nextID() { diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java index 9be201d6..72cddf9f 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java @@ -3,13 +3,18 @@ import api.IGuideItem; import api.util.NBTBookTags; import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.ResourceLocation; -public class PacketSyncCategory implements IMessage, IMessageHandler { +import net.minecraftforge.fml.network.NetworkEvent; +import org.apache.commons.lang3.Validate; + +import java.util.function.Supplier; + +public class PacketSyncCategory { public int category; public int page; @@ -24,34 +29,39 @@ public PacketSyncCategory(int category, int page) { this.page = page; } - @Override - public void fromBytes(ByteBuf buf) { - this.category = buf.readInt(); - this.page = buf.readInt(); + static void encode(PacketSyncCategory msg, PacketBuffer buf){ + buf.writeInt(msg.category); + buf.writeInt(msg.page); } - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(category); - buf.writeInt(page); + static PacketSyncCategory decode(PacketBuffer buf){ + PacketSyncCategory msg=new PacketSyncCategory(); + msg.category=buf.readInt(); + msg.page = buf.readInt(); + return msg; } - @Override - public IMessage onMessage(PacketSyncCategory message, MessageContext ctx) { - ItemStack book = ctx.getServerHandler().player.getHeldItemOffhand(); - if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) - book = ctx.getServerHandler().player.getHeldItemMainhand(); + public static void handle(final PacketSyncCategory msg, Supplier contextSupplier){ + final NetworkEvent.Context ctx=contextSupplier.get(); + ServerPlayerEntity player = ctx.getSender(); + Validate.notNull(player); + ctx.enqueueWork(()->{ + ItemStack book = player.getHeldItemOffhand(); + if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) + book = player.getHeldItemMainhand(); - if (!book.isEmpty() && book.getItem() instanceof IGuideItem) { - if (message.category != -1 && message.page != -1) { - if (!book.hasTagCompound()) - book.setTagCompound(new CompoundNBT()); + if (!book.isEmpty() && book.getItem() instanceof IGuideItem) { + if (msg.category != -1 && msg.page != -1) { + if (!book.hasTag()) + book.setTag(new CompoundNBT()); - book.getTagCompound().setInteger(NBTBookTags.CATEGORY_TAG, message.category); - book.getTagCompound().setInteger(NBTBookTags.ENTRY_PAGE_TAG, message.page); - book.getTagCompound().removeTag(NBTBookTags.ENTRY_TAG); + book.getTag().putInt(NBTBookTags.CATEGORY_TAG, msg.category); + book.getTag().putInt(NBTBookTags.ENTRY_PAGE_TAG, msg.page); + book.getTag().remove(NBTBookTags.ENTRY_TAG); + } } - } - return null; + }); + ctx.setPacketHandled(true); } + } diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java index a45fad70..64b942fb 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java @@ -14,7 +14,7 @@ import java.util.function.Supplier; -public class PacketSyncEntry implements IMessage { +public class PacketSyncEntry{ public int category; public ResourceLocation entry; diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java index 9e2a4070..9635eff6 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java @@ -3,13 +3,17 @@ import api.IGuideItem; import api.util.NBTBookTags; import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.network.NetworkEvent; +import org.apache.commons.lang3.Validate; -public class PacketSyncHome implements IMessage, IMessageHandler { +import java.util.function.Supplier; + +public class PacketSyncHome { public int page; @@ -21,29 +25,33 @@ public PacketSyncHome(int page) { this.page = page; } - @Override - public void fromBytes(ByteBuf buf) { - this.page = buf.readInt(); + static void encode(PacketSyncHome msg, PacketBuffer buf){ + buf.writeInt(msg.page); } - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(page); + static PacketSyncHome decode(PacketBuffer buf){ + PacketSyncHome msg=new PacketSyncHome(); + msg.page = buf.readInt(); + return msg; } - @Override - public IMessage onMessage(PacketSyncHome message, MessageContext ctx) { - ItemStack book = ctx.getServerHandler().player.getHeldItemOffhand(); - if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) - book = ctx.getServerHandler().player.getHeldItemMainhand(); - - if (!book.isEmpty() && book.getItem() instanceof IGuideItem && message.page != -1) { - if (!book.hasTagCompound()) - book.setTagCompound(new CompoundNBT()); - book.getTagCompound().setInteger(NBTBookTags.CATEGORY_PAGE_TAG, message.page); - book.getTagCompound().removeTag(NBTBookTags.CATEGORY_TAG); - book.getTagCompound().removeTag(NBTBookTags.ENTRY_TAG); - } - return null; + public static void handle(final PacketSyncHome msg, Supplier contextSupplier){ + final NetworkEvent.Context ctx=contextSupplier.get(); + ServerPlayerEntity player = ctx.getSender(); + Validate.notNull(player); + ctx.enqueueWork(()->{ + ItemStack book = player.getHeldItemOffhand(); + if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) + book = player.getHeldItemMainhand(); + + if (!book.isEmpty() && book.getItem() instanceof IGuideItem && msg.page != -1) { + if (!book.hasTag()) + book.setTag(new CompoundNBT()); + book.getTag().putInt(NBTBookTags.CATEGORY_PAGE_TAG, msg.page); + book.getTag().remove(NBTBookTags.CATEGORY_TAG); + book.getTag().remove(NBTBookTags.ENTRY_TAG); + } + }); + ctx.setPacketHandled(true); } } diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 47b67961..17f7ba93 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -12,6 +12,10 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.brewing.BrewingRecipe; import java.util.ArrayList; @@ -20,8 +24,8 @@ public class PageBrewingRecipe extends Page { public BrewingRecipe recipe; - public ItemStack ingredient; - public ItemStack input; + public Ingredient ingredient; + public Ingredient input; public ItemStack output; /** @@ -48,7 +52,7 @@ public PageBrewingRecipe(ItemStack input, ItemStack ingredient, ItemStack output } @Override - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { int xStart = guiLeft + 62; @@ -67,7 +71,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int //start input GuiHelper.drawItemStack(ingredient, x, y); - List tooltip = null; + List tooltip = null; if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) tooltip = GuiHelper.getTooltip(ingredient); diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index e45ea187..94b36bee 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -7,9 +7,7 @@ import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; -import amerifrance.guideapi.page.reciperenderer.ShapedOreRecipeRenderer; import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; -import amerifrance.guideapi.page.reciperenderer.ShapelessOreRecipeRenderer; import amerifrance.guideapi.page.reciperenderer.ShapelessRecipesRenderer; import amerifrance.guideapi.util.LogHelper; import net.minecraft.client.gui.FontRenderer; @@ -24,7 +22,7 @@ public class PageIRecipe extends Page { - public IRecipe recipe; + public IRecipe recipe; public IRecipeRenderer iRecipeRenderer; protected boolean isValid; @@ -32,15 +30,13 @@ public class PageIRecipe extends Page { * Use this if you are creating a page for a standard recipe, one of: *

*

    - *
  • {@link ShapedRecipes}
  • - *
  • {@link ShapelessRecipes}
  • - *
  • {@link ShapedOreRecipe}
  • - *
  • {@link ShapelessOreRecipe}
  • + *
  • {@link ShapedRecipe}
  • + *
  • {@link ShapelessRecipe}
  • *
* * @param recipe - Recipe to draw */ - public PageIRecipe(IRecipe recipe) { + public PageIRecipe(IRecipe recipe) { this(recipe, getRenderer(recipe)); } @@ -48,7 +44,7 @@ public PageIRecipe(IRecipe recipe) { * @param recipe - Recipe to draw * @param iRecipeRenderer - Your custom Recipe drawer */ - public PageIRecipe(IRecipe recipe, IRecipeRenderer iRecipeRenderer) { + public PageIRecipe(IRecipe recipe, IRecipeRenderer iRecipeRenderer) { this.recipe = recipe; this.iRecipeRenderer = iRecipeRenderer; isValid = recipe != null && iRecipeRenderer != null; @@ -77,15 +73,8 @@ public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, return isValid; } - public static PageIRecipe newShaped(ItemStack output, Object... input) { - return new PageIRecipe(new ShapedOreRecipe(null, output, input)); - } - - public static PageIRecipe newShapeless(ItemStack output, Object... input) { - return new PageIRecipe(new ShapelessOreRecipe(null, output, input)); - } - static IRecipeRenderer getRenderer(IRecipe recipe) { + static IRecipeRenderer getRenderer(IRecipe recipe) { if (recipe == null) { LogHelper.error("Cannot get renderer for null recipe."); return null; @@ -93,10 +82,6 @@ static IRecipeRenderer getRenderer(IRecipe recipe) { return new ShapedRecipesRenderer((ShapedRecipe) recipe); } else if (recipe instanceof ShapelessRecipe) { return new ShapelessRecipesRenderer((ShapelessRecipe) recipe); - } else if (recipe instanceof ShapedOreRecipe) { - return new ShapedOreRecipeRenderer((ShapedOreRecipe) recipe); - } else if (recipe instanceof ShapelessOreRecipe) { - return new ShapelessOreRecipeRenderer((ShapelessOreRecipe) recipe); } else { LogHelper.error("Cannot get renderer for recipe type "+recipe.getClass().toString()); return null; diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index 7d9c8a76..4218463a 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -10,6 +10,7 @@ import net.minecraft.block.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -42,21 +43,6 @@ public PageItemStack(String draw, Block block) { this(draw, new ItemStack(block)); } - /** - * @param draw - Unlocalized text to draw - * @param entry - OreDict entry to render - */ - public PageItemStack(String draw, String entry) { - super(draw, 60); - this.stack = new ItemStack(Blocks.FIRE); - - if (!OreDictionary.getOres(entry).isEmpty()) { - for (int i = 0; i < OreDictionary.getOres(entry).size(); i++) { - ItemStack stack = OreDictionary.getOres(entry).get(i); - this.stack = stack; - } - } - } @Override @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java index 83dc4d0e..8ec2a1c1 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java @@ -15,11 +15,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.NonNullList; -import net.minecraftforge.oredict.OreDictionary; import java.util.Random; -public class BasicRecipeRenderer extends RecipeRendererBase { +public class BasicRecipeRenderer> extends RecipeRendererBase { private long lastCycle = -1; private int cycleIdx = 0; @@ -32,15 +31,15 @@ public BasicRecipeRenderer(T recipe) { @Override public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - Minecraft mc = Minecraft.getMinecraft(); + Minecraft mc = Minecraft.getInstance(); - long time = mc.world.getTotalWorldTime(); + long time = mc.world.getGameTime(); if (lastCycle < 0 || lastCycle < time - 20) { if (lastCycle > 0) { cycleIdx++; cycleIdx = Math.max(0, cycleIdx); } - lastCycle = mc.world.getTotalWorldTime(); + lastCycle = mc.world.getGameTime(); } SubTexture.CRAFTING_GRID.draw(guiLeft + 42, guiTop + 53); @@ -53,19 +52,16 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int ItemStack stack = recipe.getRecipeOutput(); - if (!stack.isEmpty() && stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) - stack = getNextItem(stack, 0); - GuiHelper.drawItemStack(stack, outputX, outputY); if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) tooltips = GuiHelper.getTooltip(recipe.getRecipeOutput()); } - protected ItemStack getNextItem(ItemStack stack, int position) { - NonNullList subItems = NonNullList.create(); - stack.getItem().getSubItems(ItemGroup.SEARCH, subItems); - return subItems.get(getRandomizedCycle(position, subItems.size())); - } +// protected ItemStack getNextItem(ItemStack stack, int position) { +// NonNullList subItems = NonNullList.create(); +// stack.getItem().fillItemGroup(ItemGroup.SEARCH, subItems); +// return subItems.get(getRandomizedCycle(position, subItems.size())); +// } protected int getRandomizedCycle(int index, int max) { rand.setSeed(index); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java deleted file mode 100644 index 787a1fc6..00000000 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedOreRecipeRenderer.java +++ /dev/null @@ -1,12 +0,0 @@ -package amerifrance.guideapi.page.reciperenderer; - -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraftforge.oredict.ShapedOreRecipe; - -// TODO: Fix rendering of recipe -public class ShapedOreRecipeRenderer extends ShapedRecipesRenderer { - - public ShapedOreRecipeRenderer(ShapedOreRecipe recipe) { - super(new ShapedRecipe(recipe.getGroup(), recipe.getWidth(), recipe.getHeight(), recipe.getIngredients(), recipe.getRecipeOutput())); - } -} diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index cf8b0a0b..850f0ac2 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -31,8 +31,6 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int List list = Arrays.asList(ingredient.getMatchingStacks()); if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); - if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) - stack = getNextItem(stack, x); GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java deleted file mode 100644 index e79243b9..00000000 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessOreRecipeRenderer.java +++ /dev/null @@ -1,10 +0,0 @@ -package amerifrance.guideapi.page.reciperenderer; - -import net.minecraft.item.crafting.ShapelessRecipe; - -public class ShapelessOreRecipeRenderer extends ShapelessRecipesRenderer { - - public ShapelessOreRecipeRenderer(ShapelessOreRecipe recipe) { - super(new ShapelessRecipes(recipe.getGroup(), recipe.getRecipeOutput(), recipe.getIngredients())); - } -} diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index 6103c778..860d80aa 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -33,9 +33,6 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int List list = Arrays.asList(ingredient.getMatchingStacks()); if (!list.isEmpty()) { ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); - if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) - stack = getNextItem(stack, x); - GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index d55c8147..a90c2f19 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -35,7 +35,7 @@ public void openEntry(Book book, CategoryAbstract categoryAbstract, EntryAbstrac @Override public void initColors() { for (ItemStack bookStack : GuideAPI.getBookToStack().values()) { - Minecraft.getInstance().getItemColors().registerItemColorHandler((stack, tintIndex) -> { + Minecraft.getInstance().getItemColors().register((stack, tintIndex) -> { IGuideItem guideItem = (IGuideItem) stack.getItem(); if (guideItem.getBook(stack) != null && tintIndex == 0) return guideItem.getBook(stack).getColor().getRGB(); diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index a8ada50d..cc0502c7 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -32,23 +32,23 @@ public Object getClientGuiElement(int ID, PlayerEntity player, World world, int if (!bookStack.isEmpty() && bookStack.getItem() instanceof IGuideItem) { Book book = GuideAPI.getIndexedBooks().get(ID); try { - if (bookStack.hasTagCompound()) { - CompoundNBT tagCompound = bookStack.getTagCompound(); - if (tagCompound.hasKey(NBTBookTags.ENTRY_TAG) && tagCompound.hasKey(NBTBookTags.CATEGORY_TAG)) { - CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG)); + if (bookStack.hasTag()) { + CompoundNBT tagCompound = bookStack.getTag(); + if (tagCompound.contains(NBTBookTags.ENTRY_TAG) && tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { + CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); EntryAbstract entry = category.entries.get(new ResourceLocation(tagCompound.getString(NBTBookTags.ENTRY_TAG))); - int pageNumber = tagCompound.getInteger(NBTBookTags.PAGE_TAG); + int pageNumber = tagCompound.getInt(NBTBookTags.PAGE_TAG); EntryScreen guiEntry = new EntryScreen(book, category, entry, player, bookStack); guiEntry.pageNumber = pageNumber; return guiEntry; - } else if (tagCompound.hasKey(NBTBookTags.CATEGORY_TAG)) { - CategoryAbstract category = book.getCategoryList().get(tagCompound.getInteger(NBTBookTags.CATEGORY_TAG)); - int entryPage = tagCompound.getInteger(NBTBookTags.ENTRY_PAGE_TAG); + } else if (tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { + CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); + int entryPage = tagCompound.getInt(NBTBookTags.ENTRY_PAGE_TAG); CategoryScreen guiCategory = new CategoryScreen(book, category, player, bookStack, null); guiCategory.entryPage = entryPage; return guiCategory; } else { - int categoryNumber = tagCompound.getInteger(NBTBookTags.CATEGORY_PAGE_TAG); + int categoryNumber = tagCompound.getInt(NBTBookTags.CATEGORY_PAGE_TAG); HomeScreen guiHome = new HomeScreen(book, player, bookStack); guiHome.categoryPage = categoryNumber; return guiHome; diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 78df4bd0..b5ddd9cd 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -16,11 +16,15 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.minecraft.block.Blocks; +import net.minecraft.item.ItemGroup; import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.common.Tags; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -55,16 +59,16 @@ public Book buildBook() { entries.put(new ResourceLocation("guideapi", "entry"), entry); pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.IRON_BLOCK), "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron")); - pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.PLANKS, 4), new ItemStack(Blocks.LOG))); + pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.OAK_PLANKS, 4), new ItemStack(Blocks.OAK_LOG))); - categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BANNER))); + categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BLUE_BANNER))); book.setCategoryList(categories); book.setRegistryName(new ResourceLocation("guideapi", "test_book")); return book; } @Override - public IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return new ShapedOreRecipe(null, bookStack, " X ", "X X", " X ", 'X', "ingotIron").setRegistryName(book.getRegistryName()); + public IRecipe getRecipe(@Nonnull ItemStack bookStack) { + return new ShapedRecipe(book.getRegistryName(), "", 3,1,NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_IRON),Ingredient.EMPTY),bookStack); } } diff --git a/src/main/java/api/IGuideBook.java b/src/main/java/api/IGuideBook.java index 401c6b90..ce205265 100644 --- a/src/main/java/api/IGuideBook.java +++ b/src/main/java/api/IGuideBook.java @@ -35,7 +35,7 @@ default void handleModel(@Nonnull ItemStack bookStack) { * @return an IRecipe to register for your book or null to not include one. */ @Nullable - default IRecipe getRecipe(@Nonnull ItemStack bookStack) { + default IRecipe getRecipe(@Nonnull ItemStack bookStack) { return null; } diff --git a/src/main/java/api/IRecipeRenderer.java b/src/main/java/api/IRecipeRenderer.java index f4fab7fd..3207b2ae 100644 --- a/src/main/java/api/IRecipeRenderer.java +++ b/src/main/java/api/IRecipeRenderer.java @@ -7,6 +7,7 @@ import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -23,7 +24,7 @@ public interface IRecipeRenderer { abstract class RecipeRendererBase implements IRecipeRenderer { protected T recipe; - protected List tooltips = Lists.newArrayList(); + protected List tooltips = Lists.newArrayList(); public RecipeRendererBase(T recipe) { this.recipe = recipe; diff --git a/src/main/java/api/util/GuiHelper.java b/src/main/java/api/util/GuiHelper.java index db91361b..e5caff1e 100644 --- a/src/main/java/api/util/GuiHelper.java +++ b/src/main/java/api/util/GuiHelper.java @@ -47,7 +47,7 @@ public static void drawItemStack(ItemStack stack, int x, int y) { blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.enableGUIStandardItemLighting(); enableRescaleNormal(); - enableDepth(); + enableDepthTest(); render.renderItemAndEffectIntoGUI(stack, x, y); render.renderItemOverlayIntoGUI(Minecraft.getInstance().fontRenderer, stack, x, y, null); RenderHelper.disableStandardItemLighting(); diff --git a/src/main/java/api/util/PageHelper.java b/src/main/java/api/util/PageHelper.java index b7ff08ae..753ffcab 100644 --- a/src/main/java/api/util/PageHelper.java +++ b/src/main/java/api/util/PageHelper.java @@ -52,7 +52,7 @@ public static List pagesForLongText(String locText, ItemStack stack) { } public static void drawFormattedText(int x, int y, BaseScreen guiBase, String toDraw) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; toDraw = StringEscapeUtils.unescapeJava(toDraw).replaceAll("\\t", " "); String[] lines = toDraw.split("\n"); for (String line : lines) { From 00fea41c48f71cb35f834bcd3fd17a039d2357c1 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sun, 22 Mar 2020 01:18:38 +0100 Subject: [PATCH 05/28] Almost ready to compile --- .../amerifrance/guideapi/ConfigHandler.java | 47 ------- .../amerifrance/guideapi/GuideConfig.java | 74 +++++++++++ .../java/amerifrance/guideapi/GuideMod.java | 1 - .../guideapi/RegistrarGuideAPI.java | 35 ++--- .../guideapi/button/ButtonBack.java | 21 +-- .../guideapi/button/ButtonNext.java | 24 ++-- .../guideapi/button/ButtonPrev.java | 21 +-- .../guideapi/button/ButtonSearch.java | 15 ++- .../guideapi/category/CategoryItemStack.java | 3 +- .../category/CategoryResourceLocation.java | 3 +- .../amerifrance/guideapi/gui/BaseScreen.java | 53 +++----- .../guideapi/gui/CategoryScreen.java | 83 ++++++------ .../amerifrance/guideapi/gui/EntryScreen.java | 113 +++++++++------- .../amerifrance/guideapi/gui/HomeScreen.java | 98 +++++++------- .../guideapi/gui/SearchScreen.java | 122 +++++++++--------- .../guideapi/info/InfoRendererImage.java | 4 +- .../guideapi/item/ItemGuideBook.java | 60 +++++---- .../guideapi/page/PageBrewingRecipe.java | 29 +++-- .../guideapi/page/PageFurnaceRecipe.java | 5 +- .../amerifrance/guideapi/page/PageSound.java | 4 +- .../guideapi/proxy/ClientProxy.java | 40 ++++++ .../guideapi/proxy/CommonProxy.java | 44 +------ .../amerifrance/guideapi/test/TestBook2.java | 12 +- .../guideapi/util/AnnotationHandler.java | 44 +++++-- .../guideapi/util/EventHandler.java | 8 +- .../amerifrance/guideapi/util/LogHelper.java | 8 +- .../guideapi/wrapper/AbstractWrapper.java | 2 +- .../guideapi/wrapper/CategoryWrapper.java | 2 +- .../guideapi/wrapper/EntryWrapper.java | 6 +- .../guideapi/wrapper/PageWrapper.java | 6 +- src/main/java/api/IPage.java | 4 +- src/main/java/api/IRecipeRenderer.java | 4 +- src/main/java/api/button/ButtonGuideAPI.java | 4 +- src/main/java/api/impl/Category.java | 4 +- src/main/java/api/impl/Entry.java | 20 +-- src/main/java/api/impl/Page.java | 4 +- .../impl/abstraction/CategoryAbstract.java | 4 +- .../api/impl/abstraction/EntryAbstract.java | 4 +- src/main/java/api/util/GuiHelper.java | 2 +- 39 files changed, 556 insertions(+), 481 deletions(-) delete mode 100644 src/main/java/amerifrance/guideapi/ConfigHandler.java create mode 100644 src/main/java/amerifrance/guideapi/GuideConfig.java diff --git a/src/main/java/amerifrance/guideapi/ConfigHandler.java b/src/main/java/amerifrance/guideapi/ConfigHandler.java deleted file mode 100644 index c70f8176..00000000 --- a/src/main/java/amerifrance/guideapi/ConfigHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -package amerifrance.guideapi; - -import api.GuideAPI; -import api.impl.Book; -import com.google.common.collect.Maps; -import net.minecraftforge.common.config.Configuration; - -import java.io.File; -import java.util.Map; - -public class ConfigHandler { - - public static final Map SPAWN_BOOKS = Maps.newHashMap(); - - public static Configuration config; - - // Settings - public static boolean enableLogging; - public static boolean canSpawnWithBooks; - - public static void init(File file) { - config = new Configuration(file); - syncConfig(); - } - - public static void syncConfig() { - String category; - - category = "Books"; - config.addCustomCategoryComment(category, "All settings related to Books."); - canSpawnWithBooks = config.getBoolean("canSpawnWithBooks", category, true, "Allows books to spawn with new players.\nThis is a global override for all books."); - - category = "General"; - config.addCustomCategoryComment(category, "Miscellaneous settings."); - enableLogging = config.getBoolean("enableLogging", category, true, "Enables extra information being printed to the console."); - - config.save(); - } - - public static void handleBookConfigs() { - for (Book book : GuideAPI.getBooks().values()) - SPAWN_BOOKS.put(book, config.getBoolean(book.getRegistryName().toString(), "Books.Spawn", book.shouldSpawnWithBook(), "")); - - config.setCategoryComment("Books.Spawn", "If true, the user will spawn with the book.\nThis defaults to the value the book owner has set and is overridden by this config."); - config.save(); - } -} diff --git a/src/main/java/amerifrance/guideapi/GuideConfig.java b/src/main/java/amerifrance/guideapi/GuideConfig.java new file mode 100644 index 00000000..13c84162 --- /dev/null +++ b/src/main/java/amerifrance/guideapi/GuideConfig.java @@ -0,0 +1,74 @@ +package amerifrance.guideapi; + + +import api.GuideAPI; +import api.impl.Book; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.config.ModConfig; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import org.apache.commons.lang3.tuple.Pair; + +public class GuideConfig { + /** + * Synced to clients. + * Only loaded on world load + */ + public static final Server SERVER; + /** + * For side independent configuration. Not synced. + * Loaded after registry events but before setup + */ + public static final Common COMMON; + + private static final ForgeConfigSpec serverSpec; + private static final ForgeConfigSpec commonSpec; + + + static { + final Pair specPair = new ForgeConfigSpec.Builder().configure(Server::new); + serverSpec = specPair.getRight(); + SERVER = specPair.getLeft(); + } + + static { + final Pair specPair = new ForgeConfigSpec.Builder().configure(Common::new); + commonSpec = specPair.getRight(); + COMMON = specPair.getLeft(); + } + + public static void registerConfigs() { + ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, commonSpec); + ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, serverSpec); + FMLJavaModLoadingContext.get().getModEventBus().register(GuideConfig.class); + } + + public static class Server { + + public final ForgeConfigSpec.BooleanValue canSpawnWithBook; + + Server(ForgeConfigSpec.Builder builder) { + builder.comment("Server configuration settings").push("server"); + canSpawnWithBook = builder.comment("Allows books to spawn with new players.\nThis is a global override for all books.").define("canSpawnWithBook",true); + builder.pop(); + } + +// for ( Book book : GuideAPI.getBooks().values()) TODO +// SPAWN_BOOKS.put(book, config.getBoolean(book.getRegistryName().toString(), "Books.Spawn", book.shouldSpawnWithBook(), "")); +// +// config.setCategoryComment("Books.Spawn", "If true, the user will spawn with the book.\nThis defaults to the value the book owner has set and is overridden by this config."); + } + + public static class Common { + + public final ForgeConfigSpec.BooleanValue enableLogging; + + + Common(ForgeConfigSpec.Builder builder) { + builder.comment("Common configurations settings").comment("common"); + enableLogging = builder.comment("Enables extra information being printed to the console.").define("enableLogging",true); + builder.pop(); + } + } + +} diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 097eb0cf..51175a53 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -45,7 +45,6 @@ private void setup(final FMLCommonSetupEvent event){ private void loadComplete(final FMLLoadCompleteEvent event){ PROXY.initColors(); - ConfigHandler.handleBookConfigs(); for (Pair guide : AnnotationHandler.BOOK_CLASSES) guide.getRight().handlePost(GuideAPI.getStackFromBook(guide.getLeft())); diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index 42d18cd0..bba0fa53 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -32,10 +32,11 @@ public class RegistrarGuideAPI { * using @ObjectHolder will not have their Item fields populated. Thus, we must use an event that fires *after* * Item object holders are populated, but *before* the recipe registry. Since the events are fired in alphabetical order, * we just pick one that starts with a letter before "r". + * TODO check */ @SubscribeEvent public static void registerItemsInADifferentRegistryEventBecauseLoadOrderingAndObjectHoldersAreImportant(RegistryEvent.Register event) { - AnnotationHandler.gatherBooks(GuideMod.dataTable); + AnnotationHandler.gatherBooks(); for (Book book : GuideAPI.getBooks().values()) { Item guideBook = new ItemGuideBook(book); @@ -44,22 +45,22 @@ public static void registerItemsInADifferentRegistryEventBecauseLoadOrderingAndO APISetter.setBookForStack(book, new ItemStack(guideBook)); } } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public static void registerRecipes(RegistryEvent.Register event) { - for (Pair guide : AnnotationHandler.BOOK_CLASSES) { - IRecipe recipe = guide.getRight().getRecipe(GuideAPI.getStackFromBook(guide.getLeft())); - if (recipe != null) - event.getRegistry().register(recipe); - } - - for (Book book : GuideAPI.getBooks().values()) - for (CategoryAbstract cat : book.getCategoryList()) - for (EntryAbstract entry : cat.entries.values()) - for (IPage page : entry.pageList) - if (page instanceof PageJsonRecipe) - ((PageJsonRecipe) page).init(); - } +// TODO +// @SubscribeEvent(priority = EventPriority.LOWEST) +// public static void registerRecipes(RegistryEvent.Register event) { +// for (Pair guide : AnnotationHandler.BOOK_CLASSES) { +// IRecipe recipe = guide.getRight().getRecipe(GuideAPI.getStackFromBook(guide.getLeft())); +// if (recipe != null) +// event.getRegistry().register(recipe); +// } +// +// for (Book book : GuideAPI.getBooks().values()) +// for (CategoryAbstract cat : book.getCategoryList()) +// for (EntryAbstract entry : cat.entries.values()) +// for (IPage page : entry.pageList) +// if (page instanceof PageJsonRecipe) +// ((PageJsonRecipe) page).init(); +// } @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { diff --git a/src/main/java/amerifrance/guideapi/button/ButtonBack.java b/src/main/java/amerifrance/guideapi/button/ButtonBack.java index ff4a67db..20682ddc 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonBack.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonBack.java @@ -5,34 +5,35 @@ import api.util.GuiHelper; import api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.ArrayList; import java.util.List; public class ButtonBack extends ButtonGuideAPI { - public ButtonBack(int id, int x, int y, BaseScreen guiBase) { - super(id, x, y, guiBase); - width = 18; - height = 10; + public ButtonBack(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { + super(widthIn, heightIn, 18, 10, onPress,guiBase); } @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks) { + public void renderButton(int mouseX, int mouseY, float partialTicks) { if (this.visible) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableBlend(); GlStateManager.disableLighting(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - minecraft.getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { - this.drawTexturedModalRect(x, y + 1, 70, 201, 18, 10); - guiBase.drawHoveringText(getHoveringText(), mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); + this.blit(x,y+1,70,201,18,10); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); } else { - this.drawTexturedModalRect(x, y, 94, 201, 18, 10); + this.blit(x,y,94,201,18,10); } GlStateManager.disableBlend(); RenderHelper.disableStandardItemLighting(); diff --git a/src/main/java/amerifrance/guideapi/button/ButtonNext.java b/src/main/java/amerifrance/guideapi/button/ButtonNext.java index a808c176..a07f79e9 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonNext.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonNext.java @@ -5,38 +5,38 @@ import api.util.GuiHelper; import api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.ArrayList; import java.util.List; public class ButtonNext extends ButtonGuideAPI { - public ButtonNext(int id, int x, int y, BaseScreen guiBase) { - super(id, x, y, guiBase); - width = 18; - height = 10; + public ButtonNext(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { + super(widthIn, heightIn, 18, 10, onPress,guiBase); } @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks) { - if (this.visible) { + public void renderButton( int mouseX, int mouseY, float partialTicks) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); - minecraft.getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); + Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { - this.drawTexturedModalRect(x, y + 1, 47, 201, 18, 10); - guiBase.drawHoveringText(getHoveringText(), mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); + this.blit(x,y+1,47,201,18,10); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); } else { - this.drawTexturedModalRect(x, y, 24, 201, 18, 10); + this.blit(x,y,24,201,18,10); } GlStateManager.disableBlend(); RenderHelper.disableStandardItemLighting(); - } + } public List getHoveringText() { diff --git a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java index e1204756..adbbf873 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java @@ -5,34 +5,35 @@ import api.util.GuiHelper; import api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.ArrayList; import java.util.List; public class ButtonPrev extends ButtonGuideAPI { - public ButtonPrev(int id, int x, int y, BaseScreen guiBase) { - super(id, x, y, guiBase); - width = 18; - height = 10; + public ButtonPrev(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { + super(widthIn, heightIn, 18, 10, onPress,guiBase); } @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks) { + public void renderButton(int mouseX, int mouseY, float partialTicks) { if (this.visible) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); - minecraft.getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); + Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { - this.drawTexturedModalRect(x, y + 1, 47, 214, 18, 10); - guiBase.drawHoveringText(getHoveringText(), mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); + this.blit(x,y+1,47,214,18,10); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); } else { - this.drawTexturedModalRect(x, y, 24, 214, 18, 10); + this.blit(x,y,24,214,18,10); } GlStateManager.disableBlend(); RenderHelper.disableStandardItemLighting(); diff --git a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java index 3f2c262d..912c9332 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java @@ -5,30 +5,31 @@ import api.util.GuiHelper; import api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.renderer.RenderHelper; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.ArrayList; import java.util.List; public class ButtonSearch extends ButtonGuideAPI { - public ButtonSearch(int id, int x, int y, BaseScreen guiBase) { - super(id, x, y, guiBase); - width = 15; - height = 15; + public ButtonSearch(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { + super(widthIn, heightIn, 15, 15, onPress,guiBase); } @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { + public void renderButton(int mouseX, int mouseY, float partialTicks) { if (this.visible) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableBlend(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { SubTexture.MAGNIFYING_GLASS.draw(x, y + 1); - guiBase.drawHoveringText(getHoveringText(), mouseX, mouseY, Minecraft.getMinecraft().fontRenderer); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); } else { SubTexture.MAGNIFYING_GLASS.draw(x, y); } diff --git a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java index 2844edec..6c58af3f 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java @@ -11,6 +11,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.Map; @@ -38,7 +39,7 @@ public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - guiBase.drawHoveringText(this.getTooltip(), mouseX, mouseY, Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(this.getTooltip(), mouseX, mouseY, categoryWidth,categoryHeight,-1,Minecraft.getInstance().fontRenderer); } @Override diff --git a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java index dbc4a723..a6b3d04b 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java @@ -10,6 +10,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.Map; @@ -38,7 +39,7 @@ public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - guiBase.drawHoveringText(this.getTooltip(), mouseX, mouseY, Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(this.getTooltip(), mouseX, mouseY, categoryWidth,categoryHeight,-1,Minecraft.getInstance().fontRenderer); } @Override diff --git a/src/main/java/amerifrance/guideapi/gui/BaseScreen.java b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java index bbf5b3e8..8783404e 100644 --- a/src/main/java/amerifrance/guideapi/gui/BaseScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java @@ -8,10 +8,13 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; +import net.minecraftforge.fml.client.config.GuiUtils; +import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.GL11; import java.awt.Color; import java.util.List; +import java.util.stream.Collectors; import static com.mojang.blaze3d.platform.GlStateManager.*; @@ -33,15 +36,19 @@ public BaseScreen(ITextComponent title, PlayerEntity player, ItemStack bookStack } @Override - public boolean doesGuiPauseGame() { + public boolean isPauseScreen() { return false; } @Override - public void keyTyped(char typedChar, int keyCode) { - if (keyCode == Keyboard.KEY_ESCAPE || keyCode == this.minecraft.gameSettings.keyBindInventory.getKeyCode()) { - this.minecraft.displayGuiScreen(null); - this.minecraft.setIngameFocus(); + public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) { + if (minecraft!=null&&(p_keyPressed_1_ == GLFW.GLFW_KEY_ESCAPE || p_keyPressed_1_==this.minecraft.gameSettings.keyBindInventory.getKey().getKeyCode())) { + this.onClose(); + this.minecraft.setGameFocused(true); + return true; + } + else{ + return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_); } } @@ -67,7 +74,7 @@ public void drawTexturedModalRectWithColor(int x, int y, int textureX, int textu @Override public void drawCenteredString(FontRenderer fontRendererObj, String string, int x, int y, int color) { RenderHelper.disableStandardItemLighting(); - fontRendererObj.drawString(string, x - fontRendererObj.getStringWidth(string) / 2, y, color); + fontRendererObj.drawString(string, x - fontRendererObj.getStringWidth(string) / 2f, y, color); RenderHelper.disableStandardItemLighting(); } @@ -75,39 +82,13 @@ public void drawCenteredStringWithShadow(FontRenderer fontRendererObj, String st super.drawCenteredString(fontRendererObj, string, x, y, color); } - @Override - public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) { - pushMatrix(); - color4f(1.0F, 1.0F, 1.0F, 1.0F); - super.drawTexturedModalRect(x, y, textureX, textureY, width, height); - popMatrix(); - } - - @Override - public void drawHoveringText(List list, int x, int y, FontRenderer font) { - disableLighting(); - RenderHelper.disableStandardItemLighting(); - super.drawHoveringText(list, x, y, font); - RenderHelper.enableStandardItemLighting(); - enableLighting(); + public void drawHoveringTextComponents(List tooltip , int mouseX, int mouseY){ + this.drawHoveringText(tooltip.stream().map(ITextComponent::getFormattedText).collect(Collectors.toList()), mouseX,mouseY); } - @Override - public void drawHoveringText(List list, int x, int y) { - disableLighting(); - RenderHelper.disableStandardItemLighting(); - super.drawHoveringText(list, x, y); - RenderHelper.enableStandardItemLighting(); - enableLighting(); + public void drawHoveringText(List tooltip , int mouseX, int mouseY){ + GuiUtils.drawHoveringText(tooltip,mouseX,mouseY,width,height,-1,font); } - @Override - public void renderToolTip(ItemStack stack, int x, int y) { - super.renderToolTip(stack, x, y); - } - @Override - public void onGuiClosed() { - super.onGuiClosed(); - } } diff --git a/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java index 7eb84f0f..ab4ecdd6 100644 --- a/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java @@ -18,6 +18,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; +import org.lwjgl.glfw.GLFW; import java.awt.Color; import java.io.IOException; @@ -40,7 +43,7 @@ public class CategoryScreen extends BaseScreen { @Nullable public EntryAbstract startEntry; public CategoryScreen(Book book, CategoryAbstract category, PlayerEntity player, ItemStack bookStack, @Nullable EntryAbstract startEntry) { - super(player, bookStack); + super(new TranslationTextComponent(category.name),player, bookStack); this.book = book; this.category = category; this.pageTexture = book.getPageTexture(); @@ -50,18 +53,28 @@ public CategoryScreen(Book book, CategoryAbstract category, PlayerEntity player, } @Override - public void initGui() { - super.initGui(); - this.buttonList.clear(); + public void init() { this.entryWrapperMap.clear(); guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - this.buttonList.add(buttonBack = new ButtonBack(0, guiLeft + xSize / 6, guiTop, this)); - this.buttonList.add(buttonNext = new ButtonNext(1, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this)); - this.buttonList.add(buttonPrev = new ButtonPrev(2, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this)); - this.buttonList.add(buttonSearch = new ButtonSearch(3, (guiLeft + xSize / 6) - 25, guiTop + 5, this)); + addButton(buttonBack = new ButtonBack( guiLeft + xSize / 6, guiTop, (btn) ->{ + this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); + },this)); + addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn) -> { + if(entryPage+1{ + if(entryPage>0){ + prevPage(); + } + },this)); + addButton(buttonSearch = new ButtonSearch( (guiLeft + xSize / 6) - 25, guiTop + 5, (btn) -> { + this.minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); + },this)); int eX = guiLeft + 37; int eY = guiTop + 15; @@ -87,9 +100,9 @@ public void initGui() { } @Override - public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { + public void render(int mouseX, int mouseY, float renderPartialTicks) { minecraft.getTextureManager().bindTexture(pageTexture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + blit(guiLeft, guiTop, 0, 0, xSize, ySize); minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); @@ -111,12 +124,12 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { buttonPrev.visible = entryPage != 0; buttonNext.visible = entryPage != entryWrapperMap.asMap().size() - 1 && !entryWrapperMap.asMap().isEmpty(); - super.drawScreen(mouseX, mouseY, renderPartialTicks); + super.render(mouseX, mouseY, renderPartialTicks); } @Override - public void mouseClicked(int mouseX, int mouseY, int typeofClick) throws IOException { - super.mouseClicked(mouseX, mouseY, typeofClick); + public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { + boolean ret = super.mouseClicked(mouseX, mouseY, typeofClick); for (EntryWrapper wrapper : this.entryWrapperMap.get(entryPage)) { if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { @@ -127,46 +140,44 @@ else if (typeofClick == 1) } if (typeofClick == 1) - this.mc.displayGuiScreen(new HomeScreen(book, player, bookStack)); + this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); + return ret; } @Override - public void handleMouseInput() throws IOException { - super.handleMouseInput(); - - int movement = Mouse.getEventDWheel(); + public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3_, double movement) { if (movement < 0) nextPage(); else if (movement > 0) prevPage(); - } - @Override - public void keyTyped(char typedChar, int keyCode) { - super.keyTyped(typedChar, keyCode); - if (keyCode == Keyboard.KEY_BACK || keyCode == this.mc.gameSettings.keyBindUseItem.getKeyCode()) - this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); - if ((keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_RIGHT) && entryPage + 1 < entryWrapperMap.asMap().size()) - nextPage(); - if ((keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_LEFT) && entryPage > 0) - prevPage(); + return movement!=0||super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); } @Override - public void actionPerformed(Button button) { - if (button.id == 0) + public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) { + if (keyCode == GLFW.GLFW_KEY_BACKSPACE || keyCode == this.minecraft.gameSettings.keyBindUseItem.getKey().getKeyCode()) { this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); - else if (button.id == 1 && entryPage + 1 < entryWrapperMap.asMap().size()) + return true; + } + else if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && entryPage + 1 < entryWrapperMap.asMap().size()) { + + nextPage(); - else if (button.id == 2 && entryPage > 0) + return true; + } + else if ((keyCode == GLFW.GLFW_KEY_DOWN|| keyCode == GLFW.GLFW_KEY_LEFT) && entryPage > 0){ prevPage(); - else if (button.id == 3) - this.minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); + return true; + } + return super.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); } + + @Override - public void onGuiClosed() { - super.onGuiClosed(); + public void onClose() { + super.onClose(); PacketHandler.INSTANCE.sendToServer(new PacketSyncCategory(book.getCategoryList().indexOf(category), entryPage)); } diff --git a/src/main/java/amerifrance/guideapi/gui/EntryScreen.java b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java index 6042a429..fabd9d28 100644 --- a/src/main/java/amerifrance/guideapi/gui/EntryScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java @@ -17,6 +17,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; +import org.lwjgl.glfw.GLFW; import java.awt.Color; import java.io.IOException; @@ -39,7 +42,7 @@ public class EntryScreen extends BaseScreen { public int pageNumber; public EntryScreen(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack) { - super(player, bookStack); + super(new TranslationTextComponent(entry.name),player, bookStack); this.book = book; this.category = category; this.entry = entry; @@ -47,21 +50,34 @@ public EntryScreen(Book book, CategoryAbstract category, EntryAbstract entry, Pl this.outlineTexture = book.getOutlineTexture(); this.pageNumber = 0; } + @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); entry.onInit(book, category, null, player, bookStack); - this.buttonList.clear(); this.pageWrapperList.clear(); guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - this.buttonList.add(buttonBack = new ButtonBack(0, guiLeft + xSize / 6, guiTop, this)); - this.buttonList.add(buttonNext = new ButtonNext(1, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this)); - this.buttonList.add(buttonPrev = new ButtonPrev(2, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this)); - this.buttonList.add(buttonSearch = new ButtonSearch(3, (guiLeft + xSize / 6) - 25, guiTop + 5, this)); + addButton(buttonBack = new ButtonBack( guiLeft + xSize / 6, guiTop, (btn)-> { + this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); + + },this)); + addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn)->{ + if(pageNumber+1 { + if(pageNumber>0){ + prevPage(); + } + },this)); + addButton(buttonSearch = new ButtonSearch( (guiLeft + xSize / 6) - 25, guiTop + 5, (btn)->{ + this.minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); + },this)); for (IPage page : this.entry.pageList) { page.onInit(book, category, entry, player, bookStack, this); @@ -70,10 +86,10 @@ public void initGui() { } @Override - public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { - Minecraft.getMinecraft().getTextureManager().bindTexture(pageTexture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - Minecraft.getMinecraft().getTextureManager().bindTexture(outlineTexture); + public void render(int mouseX, int mouseY, float renderPartialTicks) { + Minecraft.getInstance().getTextureManager().bindTexture(pageTexture); + blit(guiLeft, guiTop, 0, 0, xSize, ySize); + Minecraft.getInstance().getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); pageNumber = MathHelper.clamp(pageNumber, 0, pageWrapperList.size() - 1); @@ -91,65 +107,70 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { buttonPrev.visible = pageNumber != 0; buttonNext.visible = pageNumber != pageWrapperList.size() - 1 && !pageWrapperList.isEmpty(); - super.drawScreen(mouseX, mouseY, renderPartialTicks); + super.render(mouseX, mouseY, renderPartialTicks); } @Override - public void mouseClicked(int mouseX, int mouseY, int typeofClick) throws IOException { - super.mouseClicked(mouseX, mouseY, typeofClick); - for (PageWrapper wrapper : this.pageWrapperList) { - if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { - if (typeofClick == 0) { - pageWrapperList.get(pageNumber).page.onLeftClicked(book, category, entry, mouseX, mouseY, player, this); - } - if (typeofClick == 1) { - pageWrapperList.get(pageNumber).page.onRightClicked(book, category, entry, mouseX, mouseY, player, this); + public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { + if(!super.mouseClicked(mouseX, mouseY, typeofClick)){ + for (PageWrapper wrapper : this.pageWrapperList) { + if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { + if (typeofClick == 0) { + pageWrapperList.get(pageNumber).page.onLeftClicked(book, category, entry, mouseX, mouseY, player, this); + return true; + } + if (typeofClick == 1) { + pageWrapperList.get(pageNumber).page.onRightClicked(book, category, entry, mouseX, mouseY, player, this); + return true; + } } } - } - if (typeofClick == 1) { - this.mc.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); + if (typeofClick == 1) { + this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); + return true; + } + return false; } + return true; + } @Override - public void handleMouseInput() throws IOException { - super.handleMouseInput(); + public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3_, double movement) { - int movement = Mouse.getEventDWheel(); if (movement < 0) nextPage(); else if (movement > 0) prevPage(); - } - @Override - public void keyTyped(char typedChar, int keyCode) { - super.keyTyped(typedChar, keyCode); - if (keyCode == Keyboard.KEY_BACK || keyCode == this.mc.gameSettings.keyBindUseItem.getKeyCode()) - this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); - if ((keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_RIGHT) && pageNumber + 1 < pageWrapperList.size()) - nextPage(); - if ((keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_LEFT) && pageNumber > 0) - prevPage(); + + return movement!=0||super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); + } @Override - public void actionPerformed(Button button) { - if (button.id == 0) + public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) { + if (keyCode == GLFW.GLFW_KEY_BACKSPACE || keyCode == this.minecraft.gameSettings.keyBindUseItem.getKey().getKeyCode()) { this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); - else if (button.id == 1 && pageNumber + 1 < pageWrapperList.size()) + return true; + } + else if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && pageNumber + 1 < pageWrapperList.size()){ nextPage(); - else if (button.id == 2 && pageNumber > 0) + return true; + } + else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && pageNumber > 0){ prevPage(); - else if (button.id == 3) - this.mc.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); + return true; + } + return super.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); + } + @Override - public void onGuiClosed() { - super.onGuiClosed(); + public void onClose() { + super.onClose(); ResourceLocation key = null; for (Map.Entry mapEntry : category.entries.entrySet()) diff --git a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java index b4644113..50718dfe 100644 --- a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java @@ -9,12 +9,15 @@ import amerifrance.guideapi.network.PacketSyncHome; import amerifrance.guideapi.wrapper.CategoryWrapper; import com.google.common.collect.HashMultimap; +import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.StringTextComponent; +import org.lwjgl.glfw.GLFW; import java.awt.Color; import java.io.IOException; @@ -31,7 +34,7 @@ public class HomeScreen extends BaseScreen { public int categoryPage; public HomeScreen(Book book, PlayerEntity player, ItemStack bookStack) { - super(player, bookStack); + super(new StringTextComponent(book.getTitle()),player, bookStack); this.book = book; this.pageTexture = book.getPageTexture(); this.outlineTexture = book.getOutlineTexture(); @@ -39,16 +42,25 @@ public HomeScreen(Book book, PlayerEntity player, ItemStack bookStack) { } @Override - public void initGui() { - this.buttonList.clear(); + public void init() { this.categoryWrapperMap.clear(); guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - addButton(buttonNext = new ButtonNext(0, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this)); - addButton(buttonPrev = new ButtonPrev(1, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this)); - addButton(buttonSearch = new ButtonSearch(2, (guiLeft + xSize / 6) - 25, guiTop + 5, this)); + addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn)->{ + if(categoryPage+1 < categoryWrapperMap.asMap().size()){ + nextPage(); + } + },this)); + addButton(buttonPrev = new ButtonPrev( guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn)->{ + if(categoryPage>0){ + prevPage(); + } + },this)); + addButton(buttonSearch = new ButtonSearch( (guiLeft + xSize / 6) - 25, guiTop + 5, (btn)->{ + minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); + },this)); int cX = guiLeft + 45; int cY = guiTop + 40; @@ -100,9 +112,9 @@ public void initGui() { } @Override - public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { + public void render(int mouseX, int mouseY, float renderPartialTicks) { minecraft.getTextureManager().bindTexture(pageTexture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + blit(guiLeft, guiTop, 0, 0, xSize, ySize); minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); drawCenteredString(font, I18n.format(book.getHeader()).replace("\\n", "\n").replace("&", "\u00a7"), guiLeft + xSize / 2 + 1, guiTop + 15, 0); @@ -123,74 +135,60 @@ public void drawScreen(int mouseX, int mouseY, float renderPartialTicks) { buttonPrev.visible = categoryPage != 0; buttonNext.visible = categoryPage != categoryWrapperMap.asMap().size() - 1 && !categoryWrapperMap.asMap().isEmpty(); - for (Button button : this.buttonList) - button.drawButton(this.mc, mouseX, mouseY, renderPartialTicks); + super.render(mouseX, mouseY, renderPartialTicks); } @Override - public void mouseClicked(int mouseX, int mouseY, int typeofClick) throws IOException { - super.mouseClicked(mouseX, mouseY, typeofClick); + public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { + if(!super.mouseClicked(mouseX, mouseY, typeofClick)){ + for (CategoryWrapper wrapper : this.categoryWrapperMap.get(categoryPage)) { + if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { + if (typeofClick == 0) + wrapper.category.onLeftClicked(book, mouseX, mouseY, player, bookStack); + - for (CategoryWrapper wrapper : this.categoryWrapperMap.get(categoryPage)) { - if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { - if (typeofClick == 0) - wrapper.category.onLeftClicked(book, mouseX, mouseY, player, bookStack); + else if (typeofClick == 1) + wrapper.category.onRightClicked(book, mouseX, mouseY, player, bookStack); - else if (typeofClick == 1) - wrapper.category.onRightClicked(book, mouseX, mouseY, player, bookStack); + return true; + } } + return false; } + return true; + } @Override - public void handleMouseInput() throws IOException { - super.handleMouseInput(); + public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3_, double movement) { - int movement = Mouse.getEventDWheel(); if (movement < 0) nextPage(); else if (movement > 0) prevPage(); + + return movement!=0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); } @Override - public void keyTyped(char typedChar, int keyCode) { - super.keyTyped(typedChar, keyCode); - if ((keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_RIGHT) && categoryPage + 1 < categoryWrapperMap.asMap().size()) + public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) { + if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && categoryPage + 1 < categoryWrapperMap.asMap().size()) + { nextPage(); + } - if ((keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_LEFT) && categoryPage > 0) + else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && categoryPage > 0){ prevPage(); + } + + return super.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); } - @Override - public void actionPerformed(Button button) { - if (button.id == 0 && categoryPage + 1 < categoryWrapperMap.asMap().size()) - nextPage(); - else if (button.id == 1 && categoryPage > 0) - prevPage(); - switch (button.id) { - case 0: { - if (categoryPage + 1 < categoryWrapperMap.asMap().size()) - nextPage(); - break; - } - case 1: { - if (categoryPage > 0) - nextPage(); - break; - } - case 2: { - minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); - break; - } - } - } @Override - public void onGuiClosed() { - super.onGuiClosed(); + public void onClose() { + super.onClose(); PacketHandler.INSTANCE.sendToServer(new PacketSyncHome(categoryPage)); } diff --git a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java index 16b78ed6..0b0e9ea2 100644 --- a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java @@ -10,14 +10,17 @@ import amerifrance.guideapi.button.ButtonPrev; import com.google.common.base.Strings; import com.google.common.collect.Lists; +import net.minecraft.client.MouseHelper; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.fml.client.config.GuiUtils; import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.glfw.GLFW; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -40,7 +43,7 @@ public class SearchScreen extends BaseScreen { private String lastQuery = ""; public SearchScreen(Book book, PlayerEntity player, ItemStack bookStack, Screen parent) { - super(player, bookStack); + super(new TranslationTextComponent(book.getTitle()),player, bookStack); this.book = book; this.pageTexture = book.getPageTexture(); @@ -49,33 +52,42 @@ public SearchScreen(Book book, PlayerEntity player, ItemStack bookStack, Screen this.searchResults = getMatches(book, null, player, bookStack); } + @Override - public void initGui() { - buttonList.clear(); + public void init() { guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - addButton(new ButtonBack(0, guiLeft + xSize / 6, guiTop, this)); - addButton(buttonNext = new ButtonNext(1, guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, this)); - addButton(buttonPrev = new ButtonPrev(2, guiLeft + xSize / 5, guiTop + 5 * ySize / 6, this)); + addButton(new ButtonBack( guiLeft + xSize / 6, guiTop, (btn)->{ + minecraft.displayGuiScreen(parent); + + },this)); + addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn)->{ + if (currentPage <= searchResults.size() - 1) + currentPage++; + },this)); + addButton(buttonPrev = new ButtonPrev( guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn)->{ + if (currentPage > 0) + currentPage--; + },this)); - searchField = new TextFieldWidget(3, font, guiLeft + 43, guiTop + 12, 100, 10); + searchField = new TextFieldWidget( font, guiLeft + 43, guiTop + 12, 100, 10,""); searchField.setEnableBackgroundDrawing(false); - searchField.setFocused(true); + searchField.changeFocus(true); searchResults = getMatches(book, null, player, bookStack); } @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { + public void render(int mouseX, int mouseY, float partialTicks) { minecraft.getTextureManager().bindTexture(pageTexture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + blit(guiLeft, guiTop, 0, 0, xSize, ySize); minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); - drawRect(searchField.x - 1, searchField.y - 1, searchField.x + searchField.width + 1, searchField.y + searchField.height + 1, new Color(166, 166, 166, 128).getRGB()); - drawRect(searchField.x, searchField.y, searchField.x + searchField.width, searchField.y + searchField.height, new Color(58, 58, 58, 128).getRGB()); - searchField.drawTextBox(); + fill(searchField.x - 1, searchField.y - 1, searchField.x + searchField.getAdjustedWidth() + 1, searchField.y + searchField.getHeight() + 1, new Color(166, 166, 166, 128).getRGB()); + fill(searchField.x, searchField.y, searchField.x + searchField.getAdjustedWidth(), searchField.y + searchField.getHeight(), new Color(58, 58, 58, 128).getRGB()); + searchField.render(mouseX, mouseY, partialTicks); int entryX = guiLeft + 37; int entryY = guiTop + 30; @@ -83,14 +95,14 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { if (searchResults.size() != 0 && currentPage >= 0 && currentPage < searchResults.size()) { List> pageResults = searchResults.get(currentPage); for (Pair entry : pageResults) { - entry.getLeft().draw(book, entry.getRight(), entryX, entryY, 4 * xSize / 6, 10, mouseX, mouseY, this, fontRenderer); - entry.getLeft().drawExtras(book, entry.getRight(), entryX, entryY, 4 * xSize / 6, 10, mouseX, mouseY, this, fontRenderer); + entry.getLeft().draw(book, entry.getRight(), entryX, entryY, 4 * xSize / 6, 10, mouseX, mouseY, this, font); + entry.getLeft().drawExtras(book, entry.getRight(), entryX, entryY, 4 * xSize / 6, 10, mouseX, mouseY, this, font); if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, 4 * xSize / 6, 10)) { - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - GuiUtils.drawHoveringText(Lists.newArrayList(entry.getRight().getLocalizedName()), mouseX, mouseY, width, height, 300, fontRenderer); + if (GLFW.glfwGetKey(minecraft.mainWindow.getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == GLFW.GLFW_PRESS) + GuiUtils.drawHoveringText(Lists.newArrayList(entry.getRight().getLocalizedName()), mouseX, mouseY, width, height, 300, font); - if (Mouse.isButtonDown(0)) { + if (minecraft.mouseHelper.isLeftDown()) { GuideMod.PROXY.openEntry(book, entry.getRight(), entry.getLeft(), player, bookStack); return; } @@ -103,73 +115,65 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) { buttonPrev.visible = currentPage != 0; buttonNext.visible = currentPage != searchResults.size() - 1 && !searchResults.isEmpty(); - super.drawScreen(mouseX, mouseY, partialTicks); + super.render(mouseX, mouseY, partialTicks); } @Override - public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - super.mouseClicked(mouseX, mouseY, mouseButton); - - if (mouseButton == 1) { - if (GuiHelper.isMouseBetween(mouseX, mouseY, searchField.x, searchField.y, searchField.getAdjustedWidth(), searchField.getHeight())) { - searchField.setText(""); - lastQuery = ""; - searchResults = getMatches(book, "", player, bookStack); - return; - } else - minecraft.displayGuiScreen(parent); + public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { + if(!super.mouseClicked(mouseX, mouseY, typeofClick)){ + if (typeofClick == 1) { + if (GuiHelper.isMouseBetween(mouseX, mouseY, searchField.x, searchField.y, searchField.getAdjustedWidth(), searchField.getHeight())) { + searchField.setText(""); + lastQuery = ""; + searchResults = getMatches(book, "", player, bookStack); + return true; + } else{ + minecraft.displayGuiScreen(parent); + return true; + } + } + + + return searchField.mouseClicked(mouseX, mouseY, typeofClick); } + return true; + - searchField.mouseClicked(mouseX, mouseY, mouseButton); } @Override - public void handleMouseInput() throws IOException { - super.handleMouseInput(); + public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3_, double movement) { + - int movement = Mouse.getEventDWheel(); if (movement < 0 && buttonNext.visible && currentPage <= searchResults.size()) currentPage++; else if (movement > 0 && buttonPrev.visible && currentPage > 0) currentPage--; + + return movement!=0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); + } @Override - public void keyTyped(char typedChar, int keyCode) { - if (!searchField.isFocused()) - super.keyTyped(typedChar, keyCode); + public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) { + if (!searchField.isFocused()){ + return super.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); + } - if (keyCode == Keyboard.KEY_ESCAPE) - searchField.setFocused(false); + if (keyCode == GLFW.GLFW_KEY_ESCAPE) + searchField.changeFocus(false); - searchField.textboxKeyTyped(typedChar, keyCode); + searchField.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); if (!searchField.getText().equalsIgnoreCase(lastQuery)) { lastQuery = searchField.getText(); searchResults = getMatches(book, searchField.getText(), player, bookStack); if (currentPage > searchResults.size()) currentPage = searchResults.size() - 1; } + return true; } - @Override - public void actionPerformed(Button button) { - switch (button.id) { - case 0: { - minecraft.displayGuiScreen(parent); - break; - } - case 1: { - if (currentPage <= searchResults.size() - 1) - currentPage++; - break; - } - case 2: { - if (currentPage > 0) - currentPage--; - break; - } - } - } + @Nonnull static List>> getMatches(Book book, @Nullable String query, PlayerEntity player, ItemStack bookStack) { diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java index ebbf2897..b4d9c429 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java @@ -29,7 +29,7 @@ public InfoRendererImage(ResourceLocation image, int imageX, int imageY, int ima @Override public void drawInformation(Book book, World world, BlockPos pos, BlockState state, RayTraceResult rayTrace, PlayerEntity player) { - Minecraft.getInstance().renderEngine.bindTexture(image); - AbstractGui.drawModalRectWithCustomSizedTexture(Minecraft.getInstance().mainWindow.getScaledWidth() / 2 + 20, Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight); + Minecraft.getInstance().textureManager.bindTexture(image); + AbstractGui.blit(Minecraft.getInstance().mainWindow.getScaledWidth() / 2 + 20, Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight); } } diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index c98c1fad..2694d80f 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -16,8 +16,13 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -29,13 +34,31 @@ public class ItemGuideBook extends Item implements IGuideItem { @Nonnull private final Book book; + private String translation_key; + public ItemGuideBook(@Nonnull Book book) { + super(new Item.Properties().maxStackSize(1).group(book.getCreativeTab())); this.book = book; - setMaxStackSize(1); - setCreativeTab(book.getCreativeTab()); - setUnlocalizedName(GuideMod.ID + ".book." + book.getRegistryName().getResourceDomain() + "." + book.getRegistryName().getResourcePath()); + + setTranslation_key(GuideMod.ID + ".book." + book.getRegistryName().getNamespace() + "." + book.getRegistryName().getPath()); + } + + @Override + protected String getDefaultTranslationKey() { + if (this.translation_key == null) { + this.translation_key = Util.makeTranslationKey("item", Registry.ITEM.getKey(this)); + } + + return this.translation_key; + } + + /** + * Set a custom translation key + */ + protected void setTranslation_key(String name) { + this.translation_key = Util.makeTranslationKey("item", new ResourceLocation(GuideMod.ID, name)); } @Override @@ -47,28 +70,27 @@ public ActionResult onItemRightClick(World world, PlayerEntity player player.sendStatusMessage(event.getCanceledText(), true); return ActionResult.newResult(ActionResultType.FAIL, heldStack); } - - player.openGui(GuideMod.INSTANCE, GuideAPI.getIndexedBooks().indexOf(book), world, hand.ordinal(), 0, 0); + GuideMod.PROXY.openGuidebook(player,world,book,heldStack); return ActionResult.newResult(ActionResultType.SUCCESS, heldStack); } @Override - public ActionResultType onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) { - if (!world.isRemote || !player.isSneaking()) + public ActionResultType onItemUse(ItemUseContext context) { + if (!context.getWorld().isRemote || !context.isPlacerSneaking()) return ActionResultType.PASS; - ItemStack stack = player.getHeldItem(hand); - BlockState state = world.getBlockState(pos); + ItemStack stack = context.getItem(); + BlockState state = context.getWorld().getBlockState(context.getPos()); if (state.getBlock() instanceof IGuideLinked) { IGuideLinked guideLinked = (IGuideLinked) state.getBlock(); - ResourceLocation entryKey = guideLinked.getLinkedEntry(world, pos, player, stack); + ResourceLocation entryKey = guideLinked.getLinkedEntry(context.getWorld(), context.getPos(),context.getPlayer(), stack); if (entryKey == null) return ActionResultType.FAIL; for (CategoryAbstract category : book.getCategoryList()) { if (category.entries.containsKey(entryKey)) { - GuideMod.PROXY.openEntry(book, category, category.entries.get(entryKey), player, stack); + GuideMod.PROXY.openEntry(book, category, category.entries.get(entryKey), context.getPlayer(), stack); return ActionResultType.SUCCESS; } } @@ -78,22 +100,16 @@ public ActionResultType onItemUse(PlayerEntity player, World world, BlockPos pos } @Override - public String getItemStackDisplayName(ItemStack stack) { - return !Strings.isNullOrEmpty(book.getItemName()) ? I18n.format(getBook(stack).getItemName()) : super.getItemStackDisplayName(stack); + public ITextComponent getDisplayName(ItemStack stack) { + return !Strings.isNullOrEmpty(book.getItemName()) ? new TranslationTextComponent(getBook(stack).getItemName()) : super.getDisplayName(stack); } @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { + public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { if (!Strings.isNullOrEmpty(book.getAuthor())) - tooltip.add(TextHelper.localizeEffect(book.getAuthor())); + tooltip.add(new StringTextComponent(TextHelper.localizeEffect(book.getAuthor()))); if (!Strings.isNullOrEmpty(book.getAuthor()) && (advanced == TooltipFlags.ADVANCED)) - tooltip.add(book.getRegistryName().toString()); - } - - @Nullable -// @Override TODO - Soft override because this hasn't been merged into Forge yet. https://github.com/MinecraftForge/MinecraftForge/pull/4330 - public String getCreatorModId(ItemStack stack) { - return book.getRegistryName().getResourceDomain(); + tooltip.add(new StringTextComponent(book.getRegistryName().toString())); } // IGuideItem diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 17f7ba93..2fd72a2d 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.brewing.BrewingRecipe; @@ -45,10 +46,10 @@ public PageBrewingRecipe(BrewingRecipe recipe) { * @param ingredient - What goes in the three bottle slots * @param output - Result of recipe */ - public PageBrewingRecipe(ItemStack input, ItemStack ingredient, ItemStack output) { + public PageBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack output) { this.input = input; - this.output = ingredient; - this.ingredient = output; + this.output = output; + this.ingredient = ingredient; } @Override @@ -60,8 +61,8 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int SubTexture.POTION_GRID.draw(xStart, yStart); - List badTip = new ArrayList(); - badTip.add(TextHelper.localizeEffect("text.brewing.error")); + List badTip = new ArrayList<>(); + badTip.add(new TranslationTextComponent("text.brewing.error")); guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.brewing.brew"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); @@ -69,27 +70,27 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int x = xStart + 25;//since item stack is approx 16 wide int y = yStart + 1; //start input - GuiHelper.drawItemStack(ingredient, x, y); + GuiHelper.drawItemStack(ingredient.getMatchingStacks()[0], x, y); //TODO do proper and safe ingredient cycling List tooltip = null; if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) - tooltip = GuiHelper.getTooltip(ingredient); + tooltip = GuiHelper.getTooltip(ingredient.getMatchingStacks()[0]); //the three bottles y += 39; - GuiHelper.drawItemStack(input, x, y); + GuiHelper.drawItemStack(input.getMatchingStacks()[0], x, y); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) - tooltip = GuiHelper.getTooltip(input); + tooltip = GuiHelper.getTooltip(input.getMatchingStacks()[0]); int hSpacing = 24; x -= hSpacing; y -= 8; - GuiHelper.drawItemStack(input, x, y); + GuiHelper.drawItemStack(input.getMatchingStacks()[0], x, y); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) - tooltip = GuiHelper.getTooltip(input); + tooltip = GuiHelper.getTooltip(input.getMatchingStacks()[0]); x += hSpacing * 2; - GuiHelper.drawItemStack(input, x, y); + GuiHelper.drawItemStack(input.getMatchingStacks()[0], x, y); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) - tooltip = GuiHelper.getTooltip(input); + tooltip = GuiHelper.getTooltip(input.getMatchingStacks()[0]); if (output.isEmpty()) output = new ItemStack(Blocks.BARRIER); @@ -105,7 +106,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.brewing.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); if (tooltip != null) - guiBase.drawHoveringText(tooltip, mouseX, mouseY); + guiBase.drawHoveringTextComponents(tooltip, mouseX, mouseY); } } diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java index 92b23c07..99bbb732 100644 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java @@ -14,6 +14,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipe; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -81,7 +82,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int y = guiTop + 77; GuiHelper.drawItemStack(input, x, y); - List tooltip = null; + List tooltip = null; if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) tooltip = GuiHelper.getTooltip(input); @@ -97,7 +98,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.furnace.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); if (tooltip != null) - guiBase.drawHoveringText(tooltip, mouseX, mouseY); + guiBase.drawHoveringTextComponents(tooltip, mouseX, mouseY); } @Override diff --git a/src/main/java/amerifrance/guideapi/page/PageSound.java b/src/main/java/amerifrance/guideapi/page/PageSound.java index 65d13500..c1c34005 100644 --- a/src/main/java/amerifrance/guideapi/page/PageSound.java +++ b/src/main/java/amerifrance/guideapi/page/PageSound.java @@ -48,14 +48,14 @@ public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, @Override @OnlyIn(Dist.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { + public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, double mouseX, double mouseY, PlayerEntity player, EntryScreen guiEntry) { GuideMod.PROXY.playSound(sound); pageToEmulate.onLeftClicked(book, category, entry, mouseX, mouseY, player, guiEntry); } @Override @OnlyIn(Dist.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { + public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, double mouseX, double mouseY, PlayerEntity player, EntryScreen guiEntry) { pageToEmulate.onRightClicked(book, category, entry, mouseX, mouseY, player, guiEntry); } diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index a90c2f19..d80d6764 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -1,5 +1,7 @@ package amerifrance.guideapi.proxy; +import amerifrance.guideapi.gui.CategoryScreen; +import amerifrance.guideapi.gui.HomeScreen; import api.BookEvent; import api.GuideAPI; import api.IGuideItem; @@ -7,11 +9,15 @@ import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.EntryScreen; +import api.util.NBTBookTags; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SimpleSound; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; +import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; public class ClientProxy extends CommonProxy { @@ -44,4 +50,38 @@ public void initColors() { }, bookStack.getItem()); } } + + @Override + public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack bookStack) { + if (!bookStack.isEmpty() && bookStack.getItem() instanceof IGuideItem) { + try { + if (bookStack.hasTag()) { + CompoundNBT tagCompound = bookStack.getTag(); + if (tagCompound.contains(NBTBookTags.ENTRY_TAG) && tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { + CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); + EntryAbstract entry = category.entries.get(new ResourceLocation(tagCompound.getString(NBTBookTags.ENTRY_TAG))); + int pageNumber = tagCompound.getInt(NBTBookTags.PAGE_TAG); + EntryScreen guiEntry = new EntryScreen(book, category, entry, player, bookStack); + guiEntry.pageNumber = pageNumber; + Minecraft.getInstance().displayGuiScreen( guiEntry); + } else if (tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { + CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); + int entryPage = tagCompound.getInt(NBTBookTags.ENTRY_PAGE_TAG); + CategoryScreen guiCategory = new CategoryScreen(book, category, player, bookStack, null); + guiCategory.entryPage = entryPage; + Minecraft.getInstance().displayGuiScreen( guiCategory); + } else { + int categoryNumber = tagCompound.getInt(NBTBookTags.CATEGORY_PAGE_TAG); + HomeScreen guiHome = new HomeScreen(book, player, bookStack); + guiHome.categoryPage = categoryNumber; + Minecraft.getInstance().displayGuiScreen( guiHome); + } + } + } catch (Exception e) { + // No-op: If the linked content doesn't exist anymore + } + + Minecraft.getInstance().displayGuiScreen(new HomeScreen(book, player, bookStack)); + } + } } diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index cc0502c7..caaf5b39 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -18,50 +18,10 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; -public class CommonProxy implements IGuiHandler { +public class CommonProxy { - @Override - public Object getServerGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) { - return null; - } - - @Override - public Object getClientGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) { - ItemStack bookStack = player.getHeldItem(Hand.values()[x]); - - if (!bookStack.isEmpty() && bookStack.getItem() instanceof IGuideItem) { - Book book = GuideAPI.getIndexedBooks().get(ID); - try { - if (bookStack.hasTag()) { - CompoundNBT tagCompound = bookStack.getTag(); - if (tagCompound.contains(NBTBookTags.ENTRY_TAG) && tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { - CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); - EntryAbstract entry = category.entries.get(new ResourceLocation(tagCompound.getString(NBTBookTags.ENTRY_TAG))); - int pageNumber = tagCompound.getInt(NBTBookTags.PAGE_TAG); - EntryScreen guiEntry = new EntryScreen(book, category, entry, player, bookStack); - guiEntry.pageNumber = pageNumber; - return guiEntry; - } else if (tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { - CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); - int entryPage = tagCompound.getInt(NBTBookTags.ENTRY_PAGE_TAG); - CategoryScreen guiCategory = new CategoryScreen(book, category, player, bookStack, null); - guiCategory.entryPage = entryPage; - return guiCategory; - } else { - int categoryNumber = tagCompound.getInt(NBTBookTags.CATEGORY_PAGE_TAG); - HomeScreen guiHome = new HomeScreen(book, player, bookStack); - guiHome.categoryPage = categoryNumber; - return guiHome; - } - } - } catch (Exception e) { - // No-op: If the linked content doesn't exist anymore - } - - return new HomeScreen(book, player, bookStack); - } - return null; + public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack bookStack){ } public void playSound(SoundEvent sound) { diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index f1dd8863..bea22529 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -9,13 +9,14 @@ import amerifrance.guideapi.page.*; import net.minecraft.block.Blocks; import net.minecraft.item.Items; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.potion.Potions; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.potion.PotionUtils; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.Tags; import net.minecraftforge.common.brewing.BrewingRecipe; -import net.minecraftforge.oredict.ShapedOreRecipe; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -36,15 +37,12 @@ public Book buildBook() { book.setTitle("Title message"); book.setWelcomeMessage("Is this still a thing?"); - CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BANNER)).withKeyBase("guideapi"); + CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLUE_BANNER)).withKeyBase("guideapi"); testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); - testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.PLANKS, 1, 4))); - testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe( - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.AWKWARD), - new ItemStack(Items.SPECKLED_MELON), - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.HEALING))) + testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); + testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); book.addCategory(testCategory); diff --git a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java index e2203d15..8be4e925 100644 --- a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java +++ b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java @@ -5,41 +5,57 @@ import api.IGuideBook; import api.impl.Book; import com.google.common.collect.Lists; -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import net.minecraftforge.fml.common.discovery.asm.ModAnnotation; -import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.fml.ModList; + +import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.commons.lang3.tuple.Pair; +import org.objectweb.asm.Type; +import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; public class AnnotationHandler { public static final List> BOOK_CLASSES = Lists.newArrayList(); - public static void gatherBooks(ASMDataTable dataTable) { + private static final Type GUIDE = Type.getType(GuideBook.class); + + + public static void gatherBooks() { + final List annotations = ModList.get().getAllScanData().stream() + .map(ModFileScanData::getAnnotations) + .flatMap(Collection::stream) + .filter(a -> GUIDE.equals(a.getAnnotationType())) + .collect(Collectors.toList()); + + + for (EventPriority priority : EventPriority.values()) - for (ASMDataTable.ASMData data : dataTable.getAll(GuideBook.class.getCanonicalName())) { - try { - Class genericClass = Class.forName(data.getClassName()); + for(ModFileScanData.AnnotationData data: annotations){ + try{ + + EventPriority priority1 = (EventPriority) data.getAnnotationData().getOrDefault("priority",EventPriority.NORMAL); + if(priority!=priority1)continue; + Class genericClass = Class.forName(data.getClassType().getClassName()); if (!IGuideBook.class.isAssignableFrom(genericClass)) continue; - IGuideBook guideBook = (IGuideBook) genericClass.newInstance(); - ModAnnotation.EnumHolder holder = (ModAnnotation.EnumHolder) data.getAnnotationInfo().get("priority"); - EventPriority bookPriority = holder == null ? EventPriority.NORMAL : EventPriority.valueOf(holder.getValue()); - if (priority != bookPriority) - continue; Book book = guideBook.buildBook(); if (book == null) continue; APISetter.registerBook(book); BOOK_CLASSES.add(Pair.of(book, guideBook)); - } catch (Exception e) { - LogHelper.error("Error registering book for class " + data.getClassName()); + + }catch (Exception e) { + LogHelper.error("Error registering book for class " + data.getClassType().getClassName()); e.printStackTrace(); } + } + APISetter.setIndexedBooks(Lists.newArrayList(GuideAPI.getBooks().values())); } } diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index 05729bf4..702f1ebf 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -1,6 +1,6 @@ package amerifrance.guideapi.util; -import amerifrance.guideapi.ConfigHandler; +import amerifrance.guideapi.GuideConfig; import amerifrance.guideapi.GuideMod; import api.GuideAPI; import api.IGuideItem; @@ -43,12 +43,12 @@ public static void onPlayerJoinWorld(EntityJoinWorldEvent event) { if (!event.getEntity().world.isRemote && event.getEntity() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntity(); CompoundNBT tag = getModTag(player, GuideMod.ID); - if (ConfigHandler.canSpawnWithBooks) { + if (GuideConfig.SERVER.canSpawnWithBook.get()) { for (Book book : GuideAPI.getBooks().values()) { - if (ConfigHandler.SPAWN_BOOKS.getOrDefault(book, false) && !tag.getBoolean("hasInitial" + book.getTitle())) { + //if (ConfigHandler.SPAWN_BOOKS.getOrDefault(book, false) && !tag.getBoolean("hasInitial" + book.getTitle())) { TODO ItemHandlerHelper.giveItemToPlayer(player, GuideAPI.getStackFromBook(book)); tag.putBoolean("hasInitial" + book.getTitle(), true); - } + //} } } } diff --git a/src/main/java/amerifrance/guideapi/util/LogHelper.java b/src/main/java/amerifrance/guideapi/util/LogHelper.java index d9704721..edd830a8 100644 --- a/src/main/java/amerifrance/guideapi/util/LogHelper.java +++ b/src/main/java/amerifrance/guideapi/util/LogHelper.java @@ -1,6 +1,6 @@ package amerifrance.guideapi.util; -import amerifrance.guideapi.ConfigHandler; +import amerifrance.guideapi.GuideConfig; import amerifrance.guideapi.GuideMod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,7 +14,7 @@ public class LogHelper { */ public static void info(Object info) { - if (ConfigHandler.enableLogging) + if (GuideConfig.COMMON.enableLogging.get()) logger.info(info); } @@ -23,7 +23,7 @@ public static void info(Object info) { */ public static void error(Object error) { - if (ConfigHandler.enableLogging) + if (GuideConfig.COMMON.enableLogging.get()) logger.error(error); } @@ -32,7 +32,7 @@ public static void error(Object error) { */ public static void debug(Object debug) { - if (ConfigHandler.enableLogging) + if (GuideConfig.COMMON.enableLogging.get()) logger.debug(debug); } } diff --git a/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java index 059de800..3f81ceb1 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/AbstractWrapper.java @@ -12,5 +12,5 @@ public abstract class AbstractWrapper { public abstract void drawExtras(int mouseX, int mouseY, BaseScreen gui); - public abstract boolean isMouseOnWrapper(int mouseX, int mouseY); + public abstract boolean isMouseOnWrapper(double mouseX, double mouseY); } diff --git a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java index ed1a503d..46878550 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java @@ -54,7 +54,7 @@ public void drawExtras(int mouseX, int mouseY, BaseScreen gui) { } @Override - public boolean isMouseOnWrapper(int mouseX, int mouseY) { + public boolean isMouseOnWrapper(double mouseX, double mouseY) { return GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height); } } diff --git a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java index e574e179..da06f728 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java @@ -47,16 +47,16 @@ public boolean canPlayerSee() { @Override public void draw(int mouseX, int mouseY, BaseScreen gui) { - entry.draw(book, category, x, y, width, height, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); + entry.draw(book, category, x, y, width, height, mouseX, mouseY, gui, Minecraft.getInstance().fontRenderer); } @Override public void drawExtras(int mouseX, int mouseY, BaseScreen gui) { - entry.drawExtras(book, category, x, y, width, height, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); + entry.drawExtras(book, category, x, y, width, height, mouseX, mouseY, gui, Minecraft.getInstance().fontRenderer); } @Override - public boolean isMouseOnWrapper(int mouseX, int mouseY) { + public boolean isMouseOnWrapper(double mouseX, double mouseY) { return GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height); } } diff --git a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java index 7bd90e05..63705593 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java @@ -47,16 +47,16 @@ public boolean canPlayerSee() { @Override public void draw(int mouseX, int mouseY, BaseScreen gui) { - page.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); + page.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, gui, Minecraft.getInstance().fontRenderer); } @Override public void drawExtras(int mouseX, int mouseY, BaseScreen gui) { - page.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, gui, Minecraft.getMinecraft().fontRenderer); + page.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, gui, Minecraft.getInstance().fontRenderer); } @Override - public boolean isMouseOnWrapper(int mouseX, int mouseY) { + public boolean isMouseOnWrapper(double mouseX, double mouseY) { return true; } } diff --git a/src/main/java/api/IPage.java b/src/main/java/api/IPage.java index 185462de..84021aa3 100644 --- a/src/main/java/api/IPage.java +++ b/src/main/java/api/IPage.java @@ -22,10 +22,10 @@ public interface IPage { boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry); @OnlyIn(Dist.CLIENT) - void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry); + void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, double mouseX, double mouseY, PlayerEntity player, EntryScreen guiEntry); @OnlyIn(Dist.CLIENT) - void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry); + void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, double mouseX, double mouseY, PlayerEntity player, EntryScreen guiEntry); @OnlyIn(Dist.CLIENT) void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry); diff --git a/src/main/java/api/IRecipeRenderer.java b/src/main/java/api/IRecipeRenderer.java index 3207b2ae..603616e3 100644 --- a/src/main/java/api/IRecipeRenderer.java +++ b/src/main/java/api/IRecipeRenderer.java @@ -10,8 +10,10 @@ import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.client.config.GuiUtils; import java.util.List; +import java.util.stream.Collectors; public interface IRecipeRenderer { @@ -32,7 +34,7 @@ public RecipeRendererBase(T recipe) { @Override public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - guiBase.drawHoveringText(tooltips, mouseX, mouseY); + guiBase.drawHoveringTextComponents(tooltips, mouseX, mouseY); tooltips.clear(); } } diff --git a/src/main/java/api/button/ButtonGuideAPI.java b/src/main/java/api/button/ButtonGuideAPI.java index de46bd99..962a917d 100644 --- a/src/main/java/api/button/ButtonGuideAPI.java +++ b/src/main/java/api/button/ButtonGuideAPI.java @@ -7,8 +7,8 @@ public class ButtonGuideAPI extends Button { public BaseScreen guiBase; - public ButtonGuideAPI(int id, int x, int y, BaseScreen guiBase) { - super(id, x, y, ""); + public ButtonGuideAPI(int widthIn, int heightIn, int width, int height, Button.IPressable onPress, BaseScreen guiBase) { + super(widthIn, heightIn, width, height, "", onPress); this.guiBase = guiBase; } } diff --git a/src/main/java/api/impl/Category.java b/src/main/java/api/impl/Category.java index 014e379b..c25f0d45 100644 --- a/src/main/java/api/impl/Category.java +++ b/src/main/java/api/impl/Category.java @@ -42,13 +42,13 @@ public boolean canSee(PlayerEntity player, ItemStack bookStack) { @Override @OnlyIn(Dist.CLIENT) - public void onLeftClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack) { + public void onLeftClicked(Book book, double mouseX, double mouseY, PlayerEntity player, ItemStack bookStack) { Minecraft.getInstance().displayGuiScreen(new CategoryScreen(book, this, player, bookStack, null)); } @Override @OnlyIn(Dist.CLIENT) - public void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack) { + public void onRightClicked(Book book, double mouseX, double mouseY, PlayerEntity player, ItemStack bookStack) { } @Override diff --git a/src/main/java/api/impl/Entry.java b/src/main/java/api/impl/Entry.java index 79832ec8..0292a4f2 100644 --- a/src/main/java/api/impl/Entry.java +++ b/src/main/java/api/impl/Entry.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.client.config.GuiUtils; import java.awt.Color; import java.util.Collections; @@ -40,10 +41,6 @@ public Entry(String name) { @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - boolean startFlag = fontRendererObj.getUnicodeFlag(); - - if (unicode) - fontRendererObj.setUnicodeFlag(true); // Cutting code ripped from GuiButtonExt#drawButton(...) String entryName = getLocalizedName(); @@ -60,15 +57,13 @@ public void draw(Book book, CategoryAbstract category, int entryX, int entryY, i fontRendererObj.drawString(entryName, entryX + 12, entryY, 0); } - if (unicode && !startFlag) - fontRendererObj.setUnicodeFlag(false); + } @Override @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, CategoryAbstract category, int entryX, int entryY, int entryWidth, int entryHeight, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - boolean startFlag = fontRendererObj.getUnicodeFlag(); - fontRendererObj.setUnicodeFlag(false); + // Cutting code ripped from GuiButtonExt#drawButton(...) int strWidth = fontRendererObj.getStringWidth(getLocalizedName()); @@ -79,11 +74,10 @@ public void drawExtras(Book book, CategoryAbstract category, int entryX, int ent if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, entryWidth, entryHeight) && cutString) { - guiBase.drawHoveringText(Collections.singletonList(getLocalizedName()), entryX, entryY + 12); - fontRendererObj.setUnicodeFlag(unicode); + GuiUtils.drawHoveringText(Collections.singletonList(getLocalizedName()), entryX, entryY + 12,entryWidth,entryHeight,-1,fontRendererObj); } - fontRendererObj.setUnicodeFlag(startFlag); + } @Override @@ -93,13 +87,13 @@ public boolean canSee(PlayerEntity player, ItemStack bookStack) { @Override @OnlyIn(Dist.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory) { + public void onLeftClicked(Book book, CategoryAbstract category, double mouseX, double mouseY, PlayerEntity player, CategoryScreen guiCategory) { Minecraft.getInstance().displayGuiScreen(new EntryScreen(book, category, this, player, guiCategory.bookStack)); } @Override @OnlyIn(Dist.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory) { + public void onRightClicked(Book book, CategoryAbstract category, double mouseX, double mouseY, PlayerEntity player, CategoryScreen guiCategory) { } @Override diff --git a/src/main/java/api/impl/Page.java b/src/main/java/api/impl/Page.java index 88a007c8..378c7b4c 100644 --- a/src/main/java/api/impl/Page.java +++ b/src/main/java/api/impl/Page.java @@ -32,12 +32,12 @@ public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, @Override @OnlyIn(Dist.CLIENT) - public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { + public void onLeftClicked(Book book, CategoryAbstract category, EntryAbstract entry, double mouseX, double mouseY, PlayerEntity player, EntryScreen guiEntry) { } @Override @OnlyIn(Dist.CLIENT) - public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, int mouseX, int mouseY, PlayerEntity player, EntryScreen guiEntry) { + public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract entry, double mouseX, double mouseY, PlayerEntity player, EntryScreen guiEntry) { } @Override diff --git a/src/main/java/api/impl/abstraction/CategoryAbstract.java b/src/main/java/api/impl/abstraction/CategoryAbstract.java index 6700278d..9c6b8f53 100644 --- a/src/main/java/api/impl/abstraction/CategoryAbstract.java +++ b/src/main/java/api/impl/abstraction/CategoryAbstract.java @@ -142,10 +142,10 @@ public List getTooltip() { public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); @OnlyIn(Dist.CLIENT) - public abstract void onLeftClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); + public abstract void onLeftClicked(Book book, double mouseX, double mouseY, PlayerEntity player, ItemStack bookStack); @OnlyIn(Dist.CLIENT) - public abstract void onRightClicked(Book book, int mouseX, int mouseY, PlayerEntity player, ItemStack bookStack); + public abstract void onRightClicked(Book book, double mouseX, double mouseY, PlayerEntity player, ItemStack bookStack); @OnlyIn(Dist.CLIENT) public abstract void onInit(Book book, HomeScreen guiHome, PlayerEntity player, ItemStack bookStack); diff --git a/src/main/java/api/impl/abstraction/EntryAbstract.java b/src/main/java/api/impl/abstraction/EntryAbstract.java index fcf47a58..2b885793 100644 --- a/src/main/java/api/impl/abstraction/EntryAbstract.java +++ b/src/main/java/api/impl/abstraction/EntryAbstract.java @@ -67,10 +67,10 @@ public String getLocalizedName() { public abstract boolean canSee(PlayerEntity player, ItemStack bookStack); @OnlyIn(Dist.CLIENT) - public abstract void onLeftClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory); + public abstract void onLeftClicked(Book book, CategoryAbstract category, double mouseX, double mouseY, PlayerEntity player, CategoryScreen guiCategory); @OnlyIn(Dist.CLIENT) - public abstract void onRightClicked(Book book, CategoryAbstract category, int mouseX, int mouseY, PlayerEntity player, CategoryScreen guiCategory); + public abstract void onRightClicked(Book book, CategoryAbstract category, double mouseX, double mouseY, PlayerEntity player, CategoryScreen guiCategory); @OnlyIn(Dist.CLIENT) public abstract void onInit(Book book, CategoryAbstract category, CategoryScreen guiCategory, PlayerEntity player, ItemStack bookStack); diff --git a/src/main/java/api/util/GuiHelper.java b/src/main/java/api/util/GuiHelper.java index e5caff1e..400970c0 100644 --- a/src/main/java/api/util/GuiHelper.java +++ b/src/main/java/api/util/GuiHelper.java @@ -30,7 +30,7 @@ public class GuiHelper { * @param height - Height of the rectangle * @return whether or not the mouse is in the rectangle */ - public static boolean isMouseBetween(int mouseX, int mouseY, int x, int y, int width, int height) { + public static boolean isMouseBetween(double mouseX, double mouseY, int x, int y, int width, int height) { int xSize = x + width; int ySize = y + height; return (mouseX >= x && mouseX <= xSize && mouseY >= y && mouseY <= ySize); From 901d67d51a4d5e84afd64ba55ece250c117fff24 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sun, 22 Mar 2020 12:29:44 +0100 Subject: [PATCH 06/28] It compiles --- build.gradle | 12 +++ .../amerifrance/guideapi/GuideConfig.java | 2 +- .../java/amerifrance/guideapi/GuideMod.java | 1 + .../guideapi/RegistrarGuideAPI.java | 2 +- .../guideapi/page/PageFurnaceRecipe.java | 78 ++++++++++--------- .../guideapi/page/PageJsonRecipe.java | 3 +- src/main/java/api/GuideAPI.java | 10 +-- .../guideapi => }/test/TestBook.java | 13 ++-- .../guideapi => }/test/TestBook2.java | 11 +-- .../guideapi => }/test/TestBook3.java | 7 +- src/main/resources/META-INF/mods.toml | 19 +++++ src/main/resources/mcmod.info | 16 ---- src/main/resources/pack.mcmeta | 6 ++ 13 files changed, 102 insertions(+), 78 deletions(-) rename src/main/java/{amerifrance/guideapi => }/test/TestBook.java (77%) rename src/main/java/{amerifrance/guideapi => }/test/TestBook2.java (79%) rename src/main/java/{amerifrance/guideapi => }/test/TestBook3.java (88%) create mode 100644 src/main/resources/META-INF/mods.toml delete mode 100644 src/main/resources/mcmod.info create mode 100644 src/main/resources/pack.mcmeta diff --git a/build.gradle b/build.gradle index 0d8d1a37..592630b1 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,19 @@ dependencies { runtimeOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}:${project.jei_version}") //Full for runtime } +sourceSets { + main { + java { + srcDirs = ["$rootDir/src/main/java"] + } + resources { + srcDirs = [ + "$rootDir/src/main/resources" + ] + } + } +} minecraft { diff --git a/src/main/java/amerifrance/guideapi/GuideConfig.java b/src/main/java/amerifrance/guideapi/GuideConfig.java index 13c84162..6a442f1b 100644 --- a/src/main/java/amerifrance/guideapi/GuideConfig.java +++ b/src/main/java/amerifrance/guideapi/GuideConfig.java @@ -65,7 +65,7 @@ public static class Common { Common(ForgeConfigSpec.Builder builder) { - builder.comment("Common configurations settings").comment("common"); + builder.comment("Common configurations settings").push("common"); enableLogging = builder.comment("Enables extra information being printed to the console.").define("enableLogging",true); builder.pop(); } diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 51175a53..9c577a3c 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -7,6 +7,7 @@ import amerifrance.guideapi.network.PacketHandler; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index bba0fa53..a529b475 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -23,7 +23,7 @@ import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; -@Mod.EventBusSubscriber +@Mod.EventBusSubscriber(modid = "guideapi",bus = Mod.EventBusSubscriber.Bus.MOD) public class RegistrarGuideAPI { /* diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java index 99bbb732..e7913f1c 100644 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java @@ -26,46 +26,48 @@ public class PageFurnaceRecipe extends Page { public ItemStack input; public ItemStack output; +// +// /** +// * @param input - Input ItemStack to draw smelting result of +// */ +// public PageFurnaceRecipe(ItemStack input) { +// this.input = input; +// this.output = FurnaceRecipe.instance().getSmeltingResult(input); +// } +// +// /** +// * @param input - Input Item to draw smelting result of +// */ +// public PageFurnaceRecipe(Item input) { +// this.input = new ItemStack(input); +// this.output = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(input)); +// } +// +// /** +// * @param input - Input Block to draw smelting result of +// */ +// public PageFurnaceRecipe(Block input) { +// this.input = new ItemStack(input); +// this.output = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(input)); +// } +// +// /** +// * @param input - Input OreDict entry to draw smelting result of +// */ +// public PageFurnaceRecipe(String input) { +// +// this.input = new ItemStack(Blocks.FIRE); +// +// if (!OreDictionary.getOres(input).isEmpty()) +// for (int i = 0; i < OreDictionary.getOres(input).size(); i++) { +// ItemStack stack = OreDictionary.getOres(input).get(i); +// +// this.input = stack; +// this.output = FurnaceRecipes.instance().getSmeltingResult(stack); +// } +// } - /** - * @param input - Input ItemStack to draw smelting result of - */ - public PageFurnaceRecipe(ItemStack input) { - this.input = input; - this.output = FurnaceRecipe.instance().getSmeltingResult(input); - } - - /** - * @param input - Input Item to draw smelting result of - */ - public PageFurnaceRecipe(Item input) { - this.input = new ItemStack(input); - this.output = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(input)); - } - - /** - * @param input - Input Block to draw smelting result of - */ - public PageFurnaceRecipe(Block input) { - this.input = new ItemStack(input); - this.output = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(input)); - } - /** - * @param input - Input OreDict entry to draw smelting result of - */ - public PageFurnaceRecipe(String input) { - - this.input = new ItemStack(Blocks.FIRE); - - if (!OreDictionary.getOres(input).isEmpty()) - for (int i = 0; i < OreDictionary.getOres(input).size(); i++) { - ItemStack stack = OreDictionary.getOres(input).get(i); - - this.input = stack; - this.output = FurnaceRecipes.instance().getSmeltingResult(stack); - } - } @Override @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index ce4e1c32..67dea3c7 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -1,5 +1,6 @@ package amerifrance.guideapi.page; +import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; @@ -14,7 +15,7 @@ public PageJsonRecipe(ResourceLocation recipeId) { } public void init() { - this.recipe = ForgeRegistries.RECIPES.getValue(recipeId); + this.recipe = Minecraft.getInstance().getConnection().getRecipeManager().getRecipe(recipeId).get(); //TODO this.iRecipeRenderer = getRenderer(recipe); this.isValid = recipe != null && iRecipeRenderer != null; } diff --git a/src/main/java/api/GuideAPI.java b/src/main/java/api/GuideAPI.java index fa9ee88e..daf96681 100644 --- a/src/main/java/api/GuideAPI.java +++ b/src/main/java/api/GuideAPI.java @@ -59,11 +59,11 @@ public static void registerInfoRenderer(Book book, IInfoRenderer infoRenderer, C @OnlyIn(Dist.CLIENT) public static void setModel(Book book, ResourceLocation modelLoc, String variantName) { ModelResourceLocation mrl = new ModelResourceLocation(modelLoc, variantName); - ModelLoader.setCustomModelResourceLocation( - getStackFromBook(book).getItem(), - 0, - mrl - ); +// ModelLoader.setCustomModelResourceLocation( +// getStackFromBook(book).getItem(), +// 0, +// mrl +// ); TODO } /** diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/test/TestBook.java similarity index 77% rename from src/main/java/amerifrance/guideapi/test/TestBook.java rename to src/main/java/test/TestBook.java index b5ddd9cd..febb52e6 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/test/TestBook.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.test; +package test; import api.GuideBook; import api.IGuideBook; @@ -9,14 +9,12 @@ import api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; -import amerifrance.guideapi.page.PageFurnaceRecipe; import amerifrance.guideapi.page.PageIRecipe; import amerifrance.guideapi.page.PageJsonRecipe; import amerifrance.guideapi.page.PageText; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.minecraft.block.Blocks; -import net.minecraft.item.ItemGroup; import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -52,14 +50,15 @@ public Book buildBook() { List pages = Lists.newArrayList(); pages.add(new PageText("Hello, this is\nsome text")); - pages.add(new PageFurnaceRecipe(Blocks.COBBLESTONE)); - pages.add(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', "plankWood")); + //pages.add(new PageFurnaceRecipe(Blocks.COBBLESTONE)); + pages.add(new PageIRecipe(new ShapedRecipe(new ResourceLocation("guideapi","test11"), "test",1,1,NonNullList.from(Ingredient.EMPTY,Ingredient.fromStacks(new ItemStack(Items.PUMPKIN))),new ItemStack(Blocks.OAK_LOG)))); + //pages.add(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', "plankWood")); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "acacia_fence"))); Entry entry = new EntryItemStack(pages, "test.entry.name", new ItemStack(Items.POTATO)); entries.put(new ResourceLocation("guideapi", "entry"), entry); - pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.IRON_BLOCK), "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron")); - pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.OAK_PLANKS, 4), new ItemStack(Blocks.OAK_LOG))); + //pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.IRON_BLOCK), "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron")); + //pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.OAK_PLANKS, 4), new ItemStack(Blocks.OAK_LOG))); categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BLUE_BANNER))); book.setCategoryList(categories); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/test/TestBook2.java similarity index 79% rename from src/main/java/amerifrance/guideapi/test/TestBook2.java rename to src/main/java/test/TestBook2.java index bea22529..f336f078 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/test/TestBook2.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.test; +package test; import api.GuideBook; import api.IGuideBook; @@ -7,13 +7,14 @@ import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; -import net.minecraft.block.Blocks; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.potion.Potions; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.potion.PotionUtils; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; import net.minecraftforge.common.brewing.BrewingRecipe; @@ -40,8 +41,8 @@ public Book buildBook() { CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLUE_BANNER)).withKeyBase("guideapi"); testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); - testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); - testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); + //testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); + //testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); @@ -54,6 +55,6 @@ public Book buildBook() { @Nullable @Override public IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return new ShapedOreRecipe(null, bookStack, "X X", " X ", "X X", 'X', "ingotIron").setRegistryName(book.getRegistryName()); + return new ShapedRecipe(book.getRegistryName(), "", 3,1, NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_GOLD),Ingredient.EMPTY),bookStack); } } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook3.java b/src/main/java/test/TestBook3.java similarity index 88% rename from src/main/java/amerifrance/guideapi/test/TestBook3.java rename to src/main/java/test/TestBook3.java index b6155085..afdf3f95 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook3.java +++ b/src/main/java/test/TestBook3.java @@ -1,4 +1,4 @@ -package amerifrance.guideapi.test; +package test; import amerifrance.guideapi.GuideMod; import api.BookEvent; @@ -10,7 +10,6 @@ import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; -import net.minecraft.block.Blocks; import net.minecraft.item.ItemGroup; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; @@ -46,8 +45,8 @@ public Book buildBook() { CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLACK_BANNER)).withKeyBase("guideapi"); testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); - testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); - testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); + //testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); + //testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks( PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml new file mode 100644 index 00000000..4ff03cbd --- /dev/null +++ b/src/main/resources/META-INF/mods.toml @@ -0,0 +1,19 @@ +modLoader="javafml" +loaderVersion="[27,)" +issueTrackerURL="https://github.com/TeamAmeriFrance/Guide-API/issues" + +[[mods]] + modId="guideapi" + namespace="guideapi" + version="${version}" + displayName="Guide-API" + authors="Tombenpotter, TehNut, Maxanier" + credits="" + description="Simple mod guide creation" + updateJSONURL="https://maxanier.de/projects/vampirism/versions.json" + [[dependencies.guideeapi]] + modId="forge" + mandatory=true + versionRange="[${forge_version},)" + ordering="NONE" + side="BOTH" diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info deleted file mode 100644 index 56a344a7..00000000 --- a/src/main/resources/mcmod.info +++ /dev/null @@ -1,16 +0,0 @@ -[ -{ - "modid": "guideapi", - "name": "Guide-API", - "description": "Simple mod guide creation.", - "version": "${version}", - "mcversion": "${mcversion}", - "url": "", - "updateUrl": "http://tehnut.info/jenkins/", - "authorList": [ "Tombenpotter", "TehNut" ], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] -} -] diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 00000000..6df7ca86 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Guide-API Resources", + "pack_format": 4 + } +} \ No newline at end of file From 81360c11f085b87e7a87df49c2b84f11777717ef Mon Sep 17 00:00:00 2001 From: maxanier Date: Tue, 24 Mar 2020 00:49:09 +0100 Subject: [PATCH 07/28] Modified book registration and content creation. Removed deprecated book creation --- .../java/amerifrance/guideapi/GuideMod.java | 8 +- .../guideapi/RegistrarGuideAPI.java | 11 +- .../guideapi/item/ItemGuideBook.java | 4 +- src/main/java/api/impl/Book.java | 244 ++---------------- src/main/java/api/impl/BookBinder.java | 28 +- src/main/java/test/TestBook.java | 29 +-- src/main/java/test/TestBook2.java | 33 +-- src/main/java/test/TestBook3.java | 66 ----- 8 files changed, 80 insertions(+), 343 deletions(-) delete mode 100644 src/main/java/test/TestBook3.java diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 9c577a3c..ea6b7435 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; @@ -36,8 +37,7 @@ public GuideMod(){ GuideAPI.initialize(); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete); - - + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::interModMsg); } private void setup(final FMLCommonSetupEvent event){ @@ -51,6 +51,10 @@ private void loadComplete(final FMLLoadCompleteEvent event){ guide.getRight().handlePost(GuideAPI.getStackFromBook(guide.getLeft())); } + private void interModMsg(final InterModProcessEvent event){ + GuideAPI.getBooks().values().parallelStream().forEach(Book::initializeContent); + } + diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index a529b475..9745f801 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -26,16 +26,9 @@ @Mod.EventBusSubscriber(modid = "guideapi",bus = Mod.EventBusSubscriber.Bus.MOD) public class RegistrarGuideAPI { - /* - * Why Register? Well, that's an easy one. We need to register our items during the registry event phase so they - * can be properly used during init and beyond. However, we cannot handle it during Register because any mods - * using @ObjectHolder will not have their Item fields populated. Thus, we must use an event that fires *after* - * Item object holders are populated, but *before* the recipe registry. Since the events are fired in alphabetical order, - * we just pick one that starts with a letter before "r". - * TODO check - */ + @SubscribeEvent - public static void registerItemsInADifferentRegistryEventBecauseLoadOrderingAndObjectHoldersAreImportant(RegistryEvent.Register event) { + public static void registerItems(RegistryEvent.Register event) { AnnotationHandler.gatherBooks(); for (Book book : GuideAPI.getBooks().values()) { diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 2694d80f..0fc48625 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -25,10 +25,12 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.List; +import java.util.Optional; public class ItemGuideBook extends Item implements IGuideItem { @@ -37,7 +39,7 @@ public class ItemGuideBook extends Item implements IGuideItem { private String translation_key; - public ItemGuideBook(@Nonnull Book book) { + public ItemGuideBook(Book book) { super(new Item.Properties().maxStackSize(1).group(book.getCreativeTab())); this.book = book; diff --git a/src/main/java/api/impl/Book.java b/src/main/java/api/impl/Book.java index f95c3c97..669a7442 100644 --- a/src/main/java/api/impl/Book.java +++ b/src/main/java/api/impl/Book.java @@ -6,34 +6,36 @@ import com.google.common.collect.Lists; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.NonNullSupplier; import org.apache.commons.lang3.builder.ToStringBuilder; import java.awt.Color; +import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; public class Book { private static final String GUITEXLOC = "guideapi:textures/gui/"; - private List categories = Lists.newArrayList(); - private String title = "item.GuideBook.name"; - private String header = title; - private String itemName = title; - private String author; - private ResourceLocation pageTexture = new ResourceLocation(GUITEXLOC + "book_colored.png"); - private ResourceLocation outlineTexture = new ResourceLocation(GUITEXLOC + "book_greyscale.png"); - private boolean customModel; - private Color color = new Color(171, 70, 30); - private boolean spawnWithBook; - private ResourceLocation registryName; - private ItemGroup creativeTab = ItemGroup.MISC; - - /** - * @deprecated see {@link BookBinder}. To be made package private in 1.13. - */ - @Deprecated - public Book(List categoryList, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, boolean customModel, Color color, boolean spawnWithBook, ResourceLocation registryName, ItemGroup creativeTab) { - this.categories = categoryList; + private final List categories = new ArrayList<>(); + private final Consumer> contentProvider; + private final String title; + private final String header; + private final String itemName; + private final String author; + private final ResourceLocation pageTexture; + private final ResourceLocation outlineTexture; + private final boolean customModel; + private final Color color; + private final boolean spawnWithBook; + private final ResourceLocation registryName; + private final ItemGroup creativeTab; + + + protected Book(Consumer> contentProvider, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, boolean customModel, Color color, boolean spawnWithBook, ResourceLocation registryName, ItemGroup creativeTab) { + this.contentProvider = contentProvider; this.title = title; this.header = header; this.itemName = displayName; @@ -47,11 +49,8 @@ public Book(List categoryList, String title, String header, St this.creativeTab = creativeTab; } - /** - * @deprecated see {@link BookBinder}. To be removed in 1.13. - */ - @Deprecated - public Book() { + public void initializeContent(){ + contentProvider.accept(categories); } public List getCategoryList() { @@ -102,203 +101,6 @@ public ItemGroup getCreativeTab() { return this.creativeTab; } - /** - * @deprecated see {@link #getItemName()}. To be removed in 1.13. - */ - @Deprecated - public String getDisplayName() { - return this.itemName; - } - - /** - * @deprecated see {@link #getHeader()}. To be removed in 1.13. - */ - @Deprecated - public String getWelcomeMessage() { - return this.header; - } - - /** - * @deprecated see {@link #hasCustomModel()}. To be removed in 1.13. - */ - @Deprecated - public boolean isCustomModel() { - return this.customModel; - } - - /** - * @deprecated see {@link #shouldSpawnWithBook()}. To be removed in 1.13. - */ - @Deprecated - public boolean isSpawnWithBook() { - return this.spawnWithBook; - } - - /** - * @deprecated see {@link BookBinder#addCategory(CategoryAbstract)}. To be removed in 1.13. - */ - @Deprecated - public void setCategoryList(List categoryList) { - this.categories = categoryList; - } - - /** - * @deprecated see {@link BookBinder#setGuideTitle(String)}. To be removed in 1.13. - */ - @Deprecated - public void setTitle(String title) { - this.title = title; - } - - /** - * @deprecated see {@link BookBinder#setHeader(String)}. To be removed in 1.13. - */ - @Deprecated - public void setWelcomeMessage(String header) { - this.header = header; - } - - /** - * @deprecated see {@link BookBinder#setItemName(String)}. To be removed in 1.13. - */ - @Deprecated - public void setDisplayName(String displayName) { - this.itemName = displayName; - } - - /** - * @deprecated see {@link BookBinder#setAuthor(String)}. To be removed in 1.13. - */ - @Deprecated - public void setAuthor(String author) { - this.author = author; - } - - /** - * @deprecated see {@link BookBinder#setSpawnWithBook()}. To be removed in 1.13. - */ - @Deprecated - public void setSpawnWithBook(boolean spawnWithBook) { - this.spawnWithBook = spawnWithBook; - } - - /** - * @deprecated see {@link BookBinder#setPageTexture(ResourceLocation)}. To be removed in 1.13. - */ - @Deprecated - public void setPageTexture(ResourceLocation pageTexture) { - this.pageTexture = pageTexture; - } - - /** - * @deprecated see {@link BookBinder#setOutlineTexture(ResourceLocation)}. To be removed in 1.13. - */ - @Deprecated - public void setOutlineTexture(ResourceLocation outlineTexture) { - this.outlineTexture = outlineTexture; - } - - /** - * @deprecated see {@link BookBinder#setHasCustomModel()}. To be removed in 1.13. - */ - @Deprecated - public void setCustomModel(boolean customModel) { - this.customModel = customModel; - } - - /** - * @deprecated see {@link BookBinder#setColor(int)}. To be removed in 1.13. - */ - @Deprecated - public void setColor(Color color) { - this.color = color; - } - - /** - * @deprecated see {@link BookBinder#BookBinder(ResourceLocation)}. To be removed in 1.13. - */ - @Deprecated - public void setRegistryName(ResourceLocation registryName) { - this.registryName = registryName; - } - - /** - * @deprecated see {@link BookBinder#setCreativeTab(ItemGroup)}. To be removed in 1.13. - */ - @Deprecated - public void setCreativeTab(ItemGroup creativeTab) { - this.creativeTab = creativeTab; - } - - /** - * @deprecated see {@link BookBinder#addCategory(CategoryAbstract)}. To be removed in 1.13. - * - * @param category - Add this category - */ - @Deprecated - public void addCategory(CategoryAbstract category) { - this.categories.add(category); - } - - /** - * @deprecated see {@link BookBinder}. To be removed in 1.13. - * - * @param category - Remove this category - */ - @Deprecated - public void removeCategory(CategoryAbstract category) { - this.categories.remove(category); - } - - /** - * @deprecated see {@link BookBinder#addCategory(CategoryAbstract)}. To be removed in 1.13. - * - * @param categories - Add these categories - */ - @Deprecated - public void addCategoryList(List categories) { - this.categories.addAll(categories); - } - - /** - * @deprecated see {@link BookBinder}. To be removed in 1.13. - * - * @param categories - Remove these categories - */ - @Deprecated - public void removeCategoryList(List categories) { - this.categories.removeAll(categories); - } - - /** - * @deprecated localize yourself with {@link #getTitle()}. To be removed in 1.13. - * - * @return - Localized book title - */ - @Deprecated - public String getLocalizedBookTitle() { - return TextHelper.localizeEffect(getTitle()); - } - - /** - * @deprecated localize yourself with {@link #getHeader()}. To be removed in 1.13. - * - * @return - Localized welcome message - */ - @Deprecated - public String getLocalizedWelcomeMessage() { - return TextHelper.localizeEffect(getHeader()); - } - - /** - * @deprecated localize yourself with {@link #getDisplayName()}. To be removed in 1.13. - * - * @return - Localized item display name - */ - @Deprecated - public String getLocalizedDisplayName() { - return TextHelper.localize(getDisplayName()); - } @Override public String toString() { diff --git a/src/main/java/api/impl/BookBinder.java b/src/main/java/api/impl/BookBinder.java index 4aa27e14..b1c47ff9 100644 --- a/src/main/java/api/impl/BookBinder.java +++ b/src/main/java/api/impl/BookBinder.java @@ -1,23 +1,24 @@ package api.impl; import api.impl.abstraction.CategoryAbstract; +import com.google.common.base.Function; import com.google.common.base.Strings; -import com.google.common.collect.Lists; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.NonNullSupplier; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.loading.moddiscovery.ModInfo; +import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.forgespi.language.IModInfo; import java.awt.Color; import java.util.List; +import java.util.function.Consumer; public class BookBinder { private final ResourceLocation registryName; - private final List categories = Lists.newArrayList(); + private Consumer> contentProvider; private String guideTitle = "item.guideapi.book.name"; private String header; private String itemName; @@ -38,17 +39,16 @@ public BookBinder(ResourceLocation registryName) { this.registryName = registryName; } + /** - * Adds a new {@link CategoryAbstract} to this book. You should either pre-build or keep a reference of this category - * so you may populate it with entries. - * - * Categories are displayed in the order they are added. + * Set a consumer (method) that will generate the content for your book and add it to the provided list + * It will be called during GuideAPI's {@link InterModProcessEvent} (so it might execute in parallel with your mod) * - * @param category The category to add to this book. + * @param contentProvider The consumer. Categories are displayed in which they are added to the provided list * @return the builder instance for chaining. */ - public BookBinder addCategory(CategoryAbstract category) { - this.categories.add(category); + public BookBinder setContentProvider(Consumer> contentProvider){ + this.contentProvider = contentProvider; return this; } @@ -208,6 +208,10 @@ public Book build() { if (this.itemName == null) this.itemName = guideTitle.substring(5); - return new Book(categories, guideTitle, header, itemName, author, pageTexture, outlineTexture, hasCustomModel, color, spawnWithBook, registryName, creativeTab); + if(contentProvider ==null){ + throw new IllegalStateException("Content supplier of book "+registryName.toString()+" must be provided"); + } + + return new Book(contentProvider, guideTitle, header, itemName, author, pageTexture, outlineTexture, hasCustomModel, color, spawnWithBook, registryName, creativeTab); } } diff --git a/src/main/java/test/TestBook.java b/src/main/java/test/TestBook.java index febb52e6..c93b8f05 100644 --- a/src/main/java/test/TestBook.java +++ b/src/main/java/test/TestBook.java @@ -4,6 +4,7 @@ import api.IGuideBook; import api.IPage; import api.impl.Book; +import api.impl.BookBinder; import api.impl.Entry; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; @@ -27,6 +28,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.awt.Color; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -38,14 +40,18 @@ public class TestBook implements IGuideBook { @Nullable @Override public Book buildBook() { - book = new Book(); - book.setAuthor("TehNut"); - book.setColor(Color.GRAY); - book.setDisplayName("Display Name"); - book.setTitle("Title message"); - book.setWelcomeMessage("Is this still a thing?"); + BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book")); + binder.setAuthor("TehNut").setColor(Color.GRAY).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); + return (book = binder.build()); + } + + @Override + public IRecipe getRecipe(@Nonnull ItemStack bookStack) { + return new ShapedRecipe(book.getRegistryName(), "", 3,1,NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_IRON),Ingredient.EMPTY),bookStack); + } + + private void buildContent(List categories){ - List categories = Lists.newArrayList(); Map entries = Maps.newHashMap(); List pages = Lists.newArrayList(); @@ -59,15 +65,6 @@ public Book buildBook() { //pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.IRON_BLOCK), "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron")); //pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.OAK_PLANKS, 4), new ItemStack(Blocks.OAK_LOG))); - categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BLUE_BANNER))); - book.setCategoryList(categories); - book.setRegistryName(new ResourceLocation("guideapi", "test_book")); - return book; - } - - @Override - public IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return new ShapedRecipe(book.getRegistryName(), "", 3,1,NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_IRON),Ingredient.EMPTY),bookStack); } } diff --git a/src/main/java/test/TestBook2.java b/src/main/java/test/TestBook2.java index f336f078..270eea2d 100644 --- a/src/main/java/test/TestBook2.java +++ b/src/main/java/test/TestBook2.java @@ -3,6 +3,7 @@ import api.GuideBook; import api.IGuideBook; import api.impl.Book; +import api.impl.BookBinder; import api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; @@ -22,6 +23,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.awt.Color; +import java.util.List; @GuideBook public class TestBook2 implements IGuideBook { @@ -31,13 +33,21 @@ public class TestBook2 implements IGuideBook { @Nullable @Override public Book buildBook() { - book = new Book(); - book.setAuthor("TehNut"); - book.setColor(Color.GREEN); - book.setDisplayName("Display Name"); - book.setTitle("Title message"); - book.setWelcomeMessage("Is this still a thing?"); + BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book2")); + binder.setAuthor("TehNut").setColor(Color.GRAY).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); + + + return (book = binder.build()); + } + + @Nullable + @Override + public IRecipe getRecipe(@Nonnull ItemStack bookStack) { + return new ShapedRecipe(book.getRegistryName(), "", 3,1, NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_GOLD),Ingredient.EMPTY),bookStack); + } + + private void buildContent(List categories) { CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLUE_BANNER)).withKeyBase("guideapi"); testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); @@ -46,15 +56,6 @@ public Book buildBook() { testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); - book.addCategory(testCategory); - - book.setRegistryName(new ResourceLocation("guideapi", "test_book2")); - return book; - } - - @Nullable - @Override - public IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return new ShapedRecipe(book.getRegistryName(), "", 3,1, NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_GOLD),Ingredient.EMPTY),bookStack); + categories.add(testCategory); } } diff --git a/src/main/java/test/TestBook3.java b/src/main/java/test/TestBook3.java deleted file mode 100644 index afdf3f95..00000000 --- a/src/main/java/test/TestBook3.java +++ /dev/null @@ -1,66 +0,0 @@ -package test; - -import amerifrance.guideapi.GuideMod; -import api.BookEvent; -import api.GuideBook; -import api.IGuideBook; -import api.impl.Book; -import api.impl.BookBinder; -import api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.category.CategoryItemStack; -import amerifrance.guideapi.entry.EntryItemStack; -import amerifrance.guideapi.page.*; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.potion.Potions; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.StringTextComponent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.brewing.BrewingRecipe; -import net.minecraftforge.eventbus.api.SubscribeEvent; - -import javax.annotation.Nullable; - -@GuideBook -public class TestBook3 implements IGuideBook { - - public static Book book; - - @Nullable - @Override - public Book buildBook() { - MinecraftForge.EVENT_BUS.register(this); - - BookBinder binder = new BookBinder(new ResourceLocation(GuideMod.ID, "test_book3")) - .setAuthor("TunHet") - .setColor(0x7EF67F) - .setCreativeTab(ItemGroup.COMBAT) - .setGuideTitle("some.guide.title") - .setHeader("some.header.text") - .setSpawnWithBook(); - - CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLACK_BANNER)).withKeyBase("guideapi"); - testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); - testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); - //testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); - //testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); - testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks( PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), - PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) - ); - testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); - binder.addCategory(testCategory); - - return book = binder.build(); - } - - @SubscribeEvent - public void onBookOpen(BookEvent.Open event) { - if (event.getBook() == book && event.getPlayer().isSneaking()) { - event.setCanceledText(new StringTextComponent("No snek allowed")); - event.setCanceled(true); - } - } -} From ac91743c118b7a637499181a5ac7626ac60c5fb8 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 28 Mar 2020 17:35:06 +0100 Subject: [PATCH 08/28] WIP recipe rework (all recipes can now be json recipes) --- .../guideapi/page/PageIRecipe.java | 10 +++++- .../guideapi/page/PageJsonRecipe.java | 35 +++++++++++++++++-- .../reciperenderer/FurnaceRecipeRenderer.java | 10 ++++++ .../guideapi/proxy/ClientProxy.java | 4 +++ .../guideapi/proxy/CommonProxy.java | 2 ++ 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 94b36bee..f035d6e6 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -1,5 +1,6 @@ package amerifrance.guideapi.page; +import amerifrance.guideapi.page.reciperenderer.FurnaceRecipeRenderer; import api.IRecipeRenderer; import api.impl.Book; import api.impl.Page; @@ -13,12 +14,15 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipe; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.item.crafting.ShapelessRecipe; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; + public class PageIRecipe extends Page { @@ -32,6 +36,7 @@ public class PageIRecipe extends Page { *
    *
  • {@link ShapedRecipe}
  • *
  • {@link ShapelessRecipe}
  • + *
  • {@link FurnaceRecipe}
  • *
* * @param recipe - Recipe to draw @@ -82,7 +87,10 @@ static IRecipeRenderer getRenderer(IRecipe recipe) { return new ShapedRecipesRenderer((ShapedRecipe) recipe); } else if (recipe instanceof ShapelessRecipe) { return new ShapelessRecipesRenderer((ShapelessRecipe) recipe); - } else { + } else if(recipe instanceof FurnaceRecipe){ + return new FurnaceRecipeRenderer((FurnaceRecipe)recipe); + } + else { LogHelper.error("Cannot get renderer for recipe type "+recipe.getClass().toString()); return null; } diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index 67dea3c7..60b63d7b 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -1,7 +1,20 @@ package amerifrance.guideapi.page; +import amerifrance.guideapi.gui.EntryScreen; +import amerifrance.guideapi.util.LogHelper; +import api.IRecipeRenderer; +import api.impl.Book; +import api.impl.abstraction.CategoryAbstract; +import api.impl.abstraction.EntryAbstract; import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.registries.ForgeRegistries; public class PageJsonRecipe extends PageIRecipe { @@ -10,13 +23,29 @@ public class PageJsonRecipe extends PageIRecipe { public PageJsonRecipe(ResourceLocation recipeId) { super(null, null); + this.recipeId = recipeId; + } + public PageJsonRecipe(ResourceLocation recipeId, IRecipeRenderer render){ + super(null,render); this.recipeId = recipeId; } - public void init() { - this.recipe = Minecraft.getInstance().getConnection().getRecipeManager().getRecipe(recipeId).get(); //TODO - this.iRecipeRenderer = getRenderer(recipe); + @OnlyIn(Dist.CLIENT) + @Override + public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { + super.onInit(book, category, entry, player, bookStack, guiEntry); + if(recipe==null){ + this.recipe = Minecraft.getInstance().getConnection() ==null ? null : Minecraft.getInstance().getConnection().getRecipeManager().getRecipe(recipeId).orElse(null); + if(recipe==null){ + LogHelper.error("Cannot find recipe "+recipeId.toString()); + } + else{ + if(iRecipeRenderer!=null){ + iRecipeRenderer = getRenderer(recipe); + } + } + } this.isValid = recipe != null && iRecipeRenderer != null; } } \ No newline at end of file diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java new file mode 100644 index 00000000..5ee3618e --- /dev/null +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java @@ -0,0 +1,10 @@ +package amerifrance.guideapi.page.reciperenderer; + +import net.minecraft.item.crafting.FurnaceRecipe; + + +public class FurnaceRecipeRenderer extends BasicRecipeRenderer { + public FurnaceRecipeRenderer(FurnaceRecipe recipe) { + super(recipe); + } +} diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index d80d6764..e50bb43a 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -5,6 +5,7 @@ import api.BookEvent; import api.GuideAPI; import api.IGuideItem; +import api.IRecipeRenderer; import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; @@ -14,12 +15,15 @@ import net.minecraft.client.audio.SimpleSound; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeType; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; +import java.util.Map; + public class ClientProxy extends CommonProxy { @Override diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index caaf5b39..c2a7e73e 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -2,6 +2,7 @@ import api.GuideAPI; import api.IGuideItem; +import api.IRecipeRenderer; import api.impl.Book; import api.impl.abstraction.CategoryAbstract; import api.impl.abstraction.EntryAbstract; @@ -11,6 +12,7 @@ import amerifrance.guideapi.gui.HomeScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeType; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; From 1001aa9956eb3a13ee465fca1f81d7899fb7f5fb Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 28 Mar 2020 17:52:34 +0100 Subject: [PATCH 09/28] Fix api and test package --- .../amerifrance/guideapi/GuideConfig.java | 2 -- .../java/amerifrance/guideapi/GuideMod.java | 9 +++------ .../guideapi/RegistrarGuideAPI.java | 13 +++---------- .../guideapi}/api/BookEvent.java | 4 ++-- .../guideapi}/api/GuideAPI.java | 5 ++--- .../guideapi}/api/GuideBook.java | 2 +- .../guideapi}/api/IGuideBook.java | 4 ++-- .../guideapi}/api/IGuideItem.java | 4 ++-- .../guideapi}/api/IGuideLinked.java | 2 +- .../guideapi}/api/IInfoRenderer.java | 4 ++-- .../{ => amerifrance/guideapi}/api/IPage.java | 8 ++++---- .../guideapi}/api/IRecipeRenderer.java | 10 ++++------ .../guideapi}/api/SubTexture.java | 2 +- .../guideapi}/api/button/ButtonGuideAPI.java | 2 +- .../guideapi}/api/impl/Book.java | 8 ++------ .../guideapi}/api/impl/BookBinder.java | 6 ++---- .../guideapi}/api/impl/Category.java | 6 +++--- .../guideapi}/api/impl/Entry.java | 10 +++++----- .../guideapi}/api/impl/Page.java | 8 ++++---- .../impl/abstraction/CategoryAbstract.java | 6 +++--- .../api/impl/abstraction/EntryAbstract.java | 8 ++++---- .../guideapi/api/package-info.java | 2 ++ .../guideapi}/api/util/BookHelper.java | 8 ++++---- .../guideapi}/api/util/GuiHelper.java | 3 +-- .../guideapi}/api/util/NBTBookTags.java | 2 +- .../guideapi}/api/util/PageHelper.java | 6 +++--- .../guideapi}/api/util/TextHelper.java | 2 +- .../guideapi/button/ButtonBack.java | 6 +++--- .../guideapi/button/ButtonNext.java | 6 +++--- .../guideapi/button/ButtonPrev.java | 6 +++--- .../guideapi/button/ButtonSearch.java | 8 ++++---- .../guideapi/category/CategoryItemStack.java | 8 ++++---- .../category/CategoryResourceLocation.java | 8 ++++---- .../guideapi/entry/EntryItemStack.java | 10 +++++----- .../guideapi/entry/EntryResourceLocation.java | 10 +++++----- .../guideapi/gui/CategoryScreen.java | 10 +++------- .../amerifrance/guideapi/gui/EntryScreen.java | 11 ++++------- .../amerifrance/guideapi/gui/HomeScreen.java | 7 ++----- .../guideapi/gui/SearchScreen.java | 11 ++++------- .../info/InfoRendererDescription.java | 6 +++--- .../guideapi/info/InfoRendererImage.java | 4 ++-- .../guideapi/item/ItemGuideBook.java | 18 ++++++------------ .../guideapi/network/PacketSyncCategory.java | 6 ++---- .../guideapi/network/PacketSyncEntry.java | 6 ++---- .../guideapi/network/PacketSyncHome.java | 6 ++---- .../guideapi/page/PageBrewingRecipe.java | 14 +++++++------- .../guideapi/page/PageFurnaceRecipe.java | 16 +++++++--------- .../guideapi/page/PageIRecipe.java | 12 +++++------- .../amerifrance/guideapi/page/PageImage.java | 10 +++++----- .../guideapi/page/PageItemStack.java | 10 ++++------ .../guideapi/page/PageJsonRecipe.java | 12 ++++-------- .../amerifrance/guideapi/page/PageSound.java | 10 +++++----- .../amerifrance/guideapi/page/PageText.java | 10 +++++----- .../guideapi/page/PageTextImage.java | 10 +++++----- .../reciperenderer/BasicRecipeRenderer.java | 16 +++++++--------- .../reciperenderer/ShapedRecipesRenderer.java | 8 ++++---- .../ShapelessRecipesRenderer.java | 10 +++++----- .../guideapi/proxy/ClientProxy.java | 18 +++++++----------- .../guideapi/proxy/CommonProxy.java | 18 +++--------------- .../guideapi}/test/TestBook.java | 19 +++++++++---------- .../guideapi}/test/TestBook2.java | 12 ++++++------ .../amerifrance/guideapi/util/APISetter.java | 4 ++-- .../guideapi/util/AnnotationHandler.java | 8 ++++---- .../guideapi/util/EventHandler.java | 14 +++++++------- .../guideapi/wrapper/CategoryWrapper.java | 6 +++--- .../guideapi/wrapper/EntryWrapper.java | 8 ++++---- .../guideapi/wrapper/PageWrapper.java | 8 ++++---- src/main/java/api/package-info.java | 2 -- 68 files changed, 236 insertions(+), 312 deletions(-) rename src/main/java/{ => amerifrance/guideapi}/api/BookEvent.java (96%) rename src/main/java/{ => amerifrance/guideapi}/api/GuideAPI.java (97%) rename src/main/java/{ => amerifrance/guideapi}/api/GuideBook.java (92%) rename src/main/java/{ => amerifrance/guideapi}/api/IGuideBook.java (94%) rename src/main/java/{ => amerifrance/guideapi}/api/IGuideItem.java (58%) rename src/main/java/{ => amerifrance/guideapi}/api/IGuideLinked.java (95%) rename src/main/java/{ => amerifrance/guideapi}/api/IInfoRenderer.java (96%) rename src/main/java/{ => amerifrance/guideapi}/api/IPage.java (87%) rename src/main/java/{ => amerifrance/guideapi}/api/IRecipeRenderer.java (86%) rename src/main/java/{ => amerifrance/guideapi}/api/SubTexture.java (99%) rename src/main/java/{ => amerifrance/guideapi}/api/button/ButtonGuideAPI.java (90%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/Book.java (94%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/BookBinder.java (97%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/Category.java (91%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/Entry.java (93%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/Page.java (90%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/abstraction/CategoryAbstract.java (97%) rename src/main/java/{ => amerifrance/guideapi}/api/impl/abstraction/EntryAbstract.java (94%) create mode 100644 src/main/java/amerifrance/guideapi/api/package-info.java rename src/main/java/{ => amerifrance/guideapi}/api/util/BookHelper.java (73%) rename src/main/java/{ => amerifrance/guideapi}/api/util/GuiHelper.java (99%) rename src/main/java/{ => amerifrance/guideapi}/api/util/NBTBookTags.java (91%) rename src/main/java/{ => amerifrance/guideapi}/api/util/PageHelper.java (96%) rename src/main/java/{ => amerifrance/guideapi}/api/util/TextHelper.java (98%) rename src/main/java/{ => amerifrance/guideapi}/test/TestBook.java (87%) rename src/main/java/{ => amerifrance/guideapi}/test/TestBook2.java (90%) delete mode 100644 src/main/java/api/package-info.java diff --git a/src/main/java/amerifrance/guideapi/GuideConfig.java b/src/main/java/amerifrance/guideapi/GuideConfig.java index 6a442f1b..0e6c941c 100644 --- a/src/main/java/amerifrance/guideapi/GuideConfig.java +++ b/src/main/java/amerifrance/guideapi/GuideConfig.java @@ -1,8 +1,6 @@ package amerifrance.guideapi; -import api.GuideAPI; -import api.impl.Book; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.config.ModConfig; diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index ea6b7435..2793e097 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -1,13 +1,12 @@ package amerifrance.guideapi; import amerifrance.guideapi.proxy.ClientProxy; -import api.GuideAPI; -import api.IGuideBook; -import api.impl.Book; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.IGuideBook; +import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.network.PacketHandler; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @@ -16,8 +15,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; -import java.io.File; - @Mod(value = GuideMod.ID) public class GuideMod { diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index 9745f801..476eaab7 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -1,22 +1,15 @@ package amerifrance.guideapi; -import api.GuideAPI; -import api.IGuideBook; -import api.IPage; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.IGuideBook; +import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.item.ItemGuideBook; -import amerifrance.guideapi.page.PageJsonRecipe; import amerifrance.guideapi.util.APISetter; import amerifrance.guideapi.util.AnnotationHandler; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.biome.Biome; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; diff --git a/src/main/java/api/BookEvent.java b/src/main/java/amerifrance/guideapi/api/BookEvent.java similarity index 96% rename from src/main/java/api/BookEvent.java rename to src/main/java/amerifrance/guideapi/api/BookEvent.java index 07d0db15..a92ad2ff 100644 --- a/src/main/java/api/BookEvent.java +++ b/src/main/java/amerifrance/guideapi/api/BookEvent.java @@ -1,6 +1,6 @@ -package api; +package amerifrance.guideapi.api; -import api.impl.Book; +import amerifrance.guideapi.api.impl.Book; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; diff --git a/src/main/java/api/GuideAPI.java b/src/main/java/amerifrance/guideapi/api/GuideAPI.java similarity index 97% rename from src/main/java/api/GuideAPI.java rename to src/main/java/amerifrance/guideapi/api/GuideAPI.java index daf96681..8f6e0413 100644 --- a/src/main/java/api/GuideAPI.java +++ b/src/main/java/amerifrance/guideapi/api/GuideAPI.java @@ -1,6 +1,6 @@ -package api; +package amerifrance.guideapi.api; -import api.impl.Book; +import amerifrance.guideapi.api.impl.Book; import com.google.common.collect.*; import net.minecraft.block.Block; import net.minecraft.client.renderer.model.ModelResourceLocation; @@ -8,7 +8,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.model.ModelLoader; import java.util.List; diff --git a/src/main/java/api/GuideBook.java b/src/main/java/amerifrance/guideapi/api/GuideBook.java similarity index 92% rename from src/main/java/api/GuideBook.java rename to src/main/java/amerifrance/guideapi/api/GuideBook.java index a88959bd..97890413 100644 --- a/src/main/java/api/GuideBook.java +++ b/src/main/java/amerifrance/guideapi/api/GuideBook.java @@ -1,4 +1,4 @@ -package api; +package amerifrance.guideapi.api; import net.minecraftforge.eventbus.api.EventPriority; diff --git a/src/main/java/api/IGuideBook.java b/src/main/java/amerifrance/guideapi/api/IGuideBook.java similarity index 94% rename from src/main/java/api/IGuideBook.java rename to src/main/java/amerifrance/guideapi/api/IGuideBook.java index ce205265..40449854 100644 --- a/src/main/java/api/IGuideBook.java +++ b/src/main/java/amerifrance/guideapi/api/IGuideBook.java @@ -1,6 +1,6 @@ -package api; +package amerifrance.guideapi.api; -import api.impl.Book; +import amerifrance.guideapi.api.impl.Book; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.api.distmarker.Dist; diff --git a/src/main/java/api/IGuideItem.java b/src/main/java/amerifrance/guideapi/api/IGuideItem.java similarity index 58% rename from src/main/java/api/IGuideItem.java rename to src/main/java/amerifrance/guideapi/api/IGuideItem.java index 1ed345e7..60c55150 100644 --- a/src/main/java/api/IGuideItem.java +++ b/src/main/java/amerifrance/guideapi/api/IGuideItem.java @@ -1,6 +1,6 @@ -package api; +package amerifrance.guideapi.api; -import api.impl.Book; +import amerifrance.guideapi.api.impl.Book; import net.minecraft.item.ItemStack; public interface IGuideItem { diff --git a/src/main/java/api/IGuideLinked.java b/src/main/java/amerifrance/guideapi/api/IGuideLinked.java similarity index 95% rename from src/main/java/api/IGuideLinked.java rename to src/main/java/amerifrance/guideapi/api/IGuideLinked.java index b7850284..f1a3a772 100644 --- a/src/main/java/api/IGuideLinked.java +++ b/src/main/java/amerifrance/guideapi/api/IGuideLinked.java @@ -1,4 +1,4 @@ -package api; +package amerifrance.guideapi.api; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/api/IInfoRenderer.java b/src/main/java/amerifrance/guideapi/api/IInfoRenderer.java similarity index 96% rename from src/main/java/api/IInfoRenderer.java rename to src/main/java/amerifrance/guideapi/api/IInfoRenderer.java index fbb5dc8b..fb7137ce 100644 --- a/src/main/java/api/IInfoRenderer.java +++ b/src/main/java/amerifrance/guideapi/api/IInfoRenderer.java @@ -1,6 +1,6 @@ -package api; +package amerifrance.guideapi.api; -import api.impl.Book; +import amerifrance.guideapi.api.impl.Book; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/api/IPage.java b/src/main/java/amerifrance/guideapi/api/IPage.java similarity index 87% rename from src/main/java/api/IPage.java rename to src/main/java/amerifrance/guideapi/api/IPage.java index 84021aa3..a28d5426 100644 --- a/src/main/java/api/IPage.java +++ b/src/main/java/amerifrance/guideapi/api/IPage.java @@ -1,10 +1,10 @@ -package api; +package amerifrance.guideapi.api; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/api/IRecipeRenderer.java b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java similarity index 86% rename from src/main/java/api/IRecipeRenderer.java rename to src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java index 603616e3..68462989 100644 --- a/src/main/java/api/IRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java @@ -1,19 +1,17 @@ -package api; +package amerifrance.guideapi.api; import amerifrance.guideapi.gui.BaseScreen; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import com.google.common.collect.Lists; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.config.GuiUtils; import java.util.List; -import java.util.stream.Collectors; public interface IRecipeRenderer { diff --git a/src/main/java/api/SubTexture.java b/src/main/java/amerifrance/guideapi/api/SubTexture.java similarity index 99% rename from src/main/java/api/SubTexture.java rename to src/main/java/amerifrance/guideapi/api/SubTexture.java index f576fa0e..0cccb97b 100644 --- a/src/main/java/api/SubTexture.java +++ b/src/main/java/amerifrance/guideapi/api/SubTexture.java @@ -1,4 +1,4 @@ -package api; +package amerifrance.guideapi.api; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; diff --git a/src/main/java/api/button/ButtonGuideAPI.java b/src/main/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java similarity index 90% rename from src/main/java/api/button/ButtonGuideAPI.java rename to src/main/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java index 962a917d..62787bc6 100644 --- a/src/main/java/api/button/ButtonGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/api/button/ButtonGuideAPI.java @@ -1,4 +1,4 @@ -package api.button; +package amerifrance.guideapi.api.button; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.widget.button.Button; diff --git a/src/main/java/api/impl/Book.java b/src/main/java/amerifrance/guideapi/api/impl/Book.java similarity index 94% rename from src/main/java/api/impl/Book.java rename to src/main/java/amerifrance/guideapi/api/impl/Book.java index 669a7442..0011c3ae 100644 --- a/src/main/java/api/impl/Book.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Book.java @@ -1,19 +1,15 @@ -package api.impl; +package amerifrance.guideapi.api.impl; -import api.impl.abstraction.CategoryAbstract; -import api.util.TextHelper; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import com.google.common.base.Joiner; -import com.google.common.collect.Lists; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.NonNullSupplier; import org.apache.commons.lang3.builder.ToStringBuilder; import java.awt.Color; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import java.util.function.Supplier; public class Book { diff --git a/src/main/java/api/impl/BookBinder.java b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java similarity index 97% rename from src/main/java/api/impl/BookBinder.java rename to src/main/java/amerifrance/guideapi/api/impl/BookBinder.java index b1c47ff9..cc7a17f6 100644 --- a/src/main/java/api/impl/BookBinder.java +++ b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java @@ -1,11 +1,9 @@ -package api.impl; +package amerifrance.guideapi.api.impl; -import api.impl.abstraction.CategoryAbstract; -import com.google.common.base.Function; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import com.google.common.base.Strings; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.NonNullSupplier; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; diff --git a/src/main/java/api/impl/Category.java b/src/main/java/amerifrance/guideapi/api/impl/Category.java similarity index 91% rename from src/main/java/api/impl/Category.java rename to src/main/java/amerifrance/guideapi/api/impl/Category.java index c25f0d45..d3166a2c 100644 --- a/src/main/java/api/impl/Category.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Category.java @@ -1,7 +1,7 @@ -package api.impl; +package amerifrance.guideapi.api.impl; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.CategoryScreen; import amerifrance.guideapi.gui.HomeScreen; diff --git a/src/main/java/api/impl/Entry.java b/src/main/java/amerifrance/guideapi/api/impl/Entry.java similarity index 93% rename from src/main/java/api/impl/Entry.java rename to src/main/java/amerifrance/guideapi/api/impl/Entry.java index 0292a4f2..df96c081 100644 --- a/src/main/java/api/impl/Entry.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Entry.java @@ -1,9 +1,9 @@ -package api.impl; +package amerifrance.guideapi.api.impl; -import api.IPage; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.CategoryScreen; import amerifrance.guideapi.gui.EntryScreen; diff --git a/src/main/java/api/impl/Page.java b/src/main/java/amerifrance/guideapi/api/impl/Page.java similarity index 90% rename from src/main/java/api/impl/Page.java rename to src/main/java/amerifrance/guideapi/api/impl/Page.java index 378c7b4c..20a601d9 100644 --- a/src/main/java/api/impl/Page.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Page.java @@ -1,8 +1,8 @@ -package api.impl; +package amerifrance.guideapi.api.impl; -import api.IPage; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/api/impl/abstraction/CategoryAbstract.java b/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java similarity index 97% rename from src/main/java/api/impl/abstraction/CategoryAbstract.java rename to src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java index 9c6b8f53..2560b668 100644 --- a/src/main/java/api/impl/abstraction/CategoryAbstract.java +++ b/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java @@ -1,7 +1,7 @@ -package api.impl.abstraction; +package amerifrance.guideapi.api.impl.abstraction; -import api.impl.Book; -import api.util.TextHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.HomeScreen; import com.google.common.base.Strings; diff --git a/src/main/java/api/impl/abstraction/EntryAbstract.java b/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java similarity index 94% rename from src/main/java/api/impl/abstraction/EntryAbstract.java rename to src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java index 2b885793..a12cc752 100644 --- a/src/main/java/api/impl/abstraction/EntryAbstract.java +++ b/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java @@ -1,8 +1,8 @@ -package api.impl.abstraction; +package amerifrance.guideapi.api.impl.abstraction; -import api.IPage; -import api.impl.Book; -import api.util.TextHelper; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.CategoryScreen; import com.google.common.collect.Lists; diff --git a/src/main/java/amerifrance/guideapi/api/package-info.java b/src/main/java/amerifrance/guideapi/api/package-info.java new file mode 100644 index 00000000..e757efb4 --- /dev/null +++ b/src/main/java/amerifrance/guideapi/api/package-info.java @@ -0,0 +1,2 @@ +package amerifrance.guideapi.api; + diff --git a/src/main/java/api/util/BookHelper.java b/src/main/java/amerifrance/guideapi/api/util/BookHelper.java similarity index 73% rename from src/main/java/api/util/BookHelper.java rename to src/main/java/amerifrance/guideapi/api/util/BookHelper.java index 44d6b183..86bd5a0e 100644 --- a/src/main/java/api/util/BookHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/BookHelper.java @@ -1,8 +1,8 @@ -package api.util; +package amerifrance.guideapi.api.util; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; public class BookHelper { diff --git a/src/main/java/api/util/GuiHelper.java b/src/main/java/amerifrance/guideapi/api/util/GuiHelper.java similarity index 99% rename from src/main/java/api/util/GuiHelper.java rename to src/main/java/amerifrance/guideapi/api/util/GuiHelper.java index 400970c0..8b719c0d 100644 --- a/src/main/java/api/util/GuiHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/GuiHelper.java @@ -1,9 +1,8 @@ -package api.util; +package amerifrance.guideapi.api.util; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.util.ITooltipFlag.TooltipFlags; diff --git a/src/main/java/api/util/NBTBookTags.java b/src/main/java/amerifrance/guideapi/api/util/NBTBookTags.java similarity index 91% rename from src/main/java/api/util/NBTBookTags.java rename to src/main/java/amerifrance/guideapi/api/util/NBTBookTags.java index a44a61c7..cfacf8e2 100644 --- a/src/main/java/api/util/NBTBookTags.java +++ b/src/main/java/amerifrance/guideapi/api/util/NBTBookTags.java @@ -1,4 +1,4 @@ -package api.util; +package amerifrance.guideapi.api.util; public class NBTBookTags { diff --git a/src/main/java/api/util/PageHelper.java b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java similarity index 96% rename from src/main/java/api/util/PageHelper.java rename to src/main/java/amerifrance/guideapi/api/util/PageHelper.java index 753ffcab..127f6025 100644 --- a/src/main/java/api/util/PageHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java @@ -1,7 +1,7 @@ -package api.util; +package amerifrance.guideapi.api.util; -import api.IPage; -import api.impl.Page; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Page; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.page.PageItemStack; import amerifrance.guideapi.page.PageText; diff --git a/src/main/java/api/util/TextHelper.java b/src/main/java/amerifrance/guideapi/api/util/TextHelper.java similarity index 98% rename from src/main/java/api/util/TextHelper.java rename to src/main/java/amerifrance/guideapi/api/util/TextHelper.java index 03c9ad1b..d50bdd5e 100644 --- a/src/main/java/api/util/TextHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/TextHelper.java @@ -1,4 +1,4 @@ -package api.util; +package amerifrance.guideapi.api.util; import net.minecraft.client.resources.I18n; import org.apache.commons.lang3.text.WordUtils; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonBack.java b/src/main/java/amerifrance/guideapi/button/ButtonBack.java index 20682ddc..0a381470 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonBack.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonBack.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.button; import amerifrance.guideapi.GuideMod; -import api.button.ButtonGuideAPI; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.button.ButtonGuideAPI; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonNext.java b/src/main/java/amerifrance/guideapi/button/ButtonNext.java index a07f79e9..32f4a699 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonNext.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonNext.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.button; import amerifrance.guideapi.GuideMod; -import api.button.ButtonGuideAPI; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.button.ButtonGuideAPI; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java index adbbf873..b78d598b 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.button; import amerifrance.guideapi.GuideMod; -import api.button.ButtonGuideAPI; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.button.ButtonGuideAPI; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java index 912c9332..f55f57ca 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.button; -import api.SubTexture; -import api.button.ButtonGuideAPI; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.SubTexture; +import amerifrance.guideapi.api.button.ButtonGuideAPI; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java index 6c58af3f..46219d7f 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.category; -import api.impl.Book; -import api.impl.Category; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Category; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; diff --git a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java index a6b3d04b..6cac89f8 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.category; -import api.impl.Book; -import api.impl.Category; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Category; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; diff --git a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java index 78c83520..73869273 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.entry; -import api.IPage; -import api.impl.Book; -import api.impl.Entry; -import api.impl.abstraction.CategoryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Entry; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java index 7a651436..d14f45e0 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.entry; -import api.IPage; -import api.impl.Book; -import api.impl.Entry; -import api.impl.abstraction.CategoryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Entry; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java index ab4ecdd6..6ba814fe 100644 --- a/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.gui; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.button.ButtonBack; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; @@ -12,18 +12,14 @@ import amerifrance.guideapi.wrapper.EntryWrapper; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; import org.lwjgl.glfw.GLFW; import java.awt.Color; -import java.io.IOException; import java.util.List; import javax.annotation.Nullable; diff --git a/src/main/java/amerifrance/guideapi/gui/EntryScreen.java b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java index fabd9d28..d4909fe2 100644 --- a/src/main/java/amerifrance/guideapi/gui/EntryScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.gui; -import api.IPage; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.button.ButtonBack; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; @@ -12,17 +12,14 @@ import amerifrance.guideapi.network.PacketSyncEntry; import amerifrance.guideapi.wrapper.PageWrapper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.widget.button.Button; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; import org.lwjgl.glfw.GLFW; import java.awt.Color; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java index 50718dfe..2330e6ab 100644 --- a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.gui; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; import amerifrance.guideapi.button.ButtonSearch; @@ -9,8 +9,6 @@ import amerifrance.guideapi.network.PacketSyncHome; import amerifrance.guideapi.wrapper.CategoryWrapper; import com.google.common.collect.HashMultimap; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -20,7 +18,6 @@ import org.lwjgl.glfw.GLFW; import java.awt.Color; -import java.io.IOException; public class HomeScreen extends BaseScreen { diff --git a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java index 0b0e9ea2..030b6782 100644 --- a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java @@ -1,17 +1,15 @@ package amerifrance.guideapi.gui; import amerifrance.guideapi.GuideMod; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.button.ButtonBack; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; import com.google.common.base.Strings; import com.google.common.collect.Lists; -import net.minecraft.client.MouseHelper; -import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.entity.player.PlayerEntity; @@ -25,7 +23,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.awt.Color; -import java.io.IOException; import java.util.List; import java.util.Locale; diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java index b3930775..c4052f3d 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.info; -import api.IInfoRenderer; -import api.impl.Book; -import api.util.GuiHelper; +import amerifrance.guideapi.api.IInfoRenderer; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.util.GuiHelper; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java index b4d9c429..d7942af2 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererImage.java @@ -1,7 +1,7 @@ package amerifrance.guideapi.info; -import api.IInfoRenderer; -import api.impl.Book; +import amerifrance.guideapi.api.IInfoRenderer; +import amerifrance.guideapi.api.impl.Book; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 0fc48625..46e91abb 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -1,16 +1,14 @@ package amerifrance.guideapi.item; import amerifrance.guideapi.GuideMod; -import api.BookEvent; -import api.GuideAPI; -import api.IGuideItem; -import api.IGuideLinked; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.util.TextHelper; +import amerifrance.guideapi.api.BookEvent; +import amerifrance.guideapi.api.IGuideItem; +import amerifrance.guideapi.api.IGuideLinked; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.TextHelper; import com.google.common.base.Strings; import net.minecraft.block.BlockState; -import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag.TooltipFlags; import net.minecraft.entity.player.PlayerEntity; @@ -18,19 +16,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.Registry; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.List; -import java.util.Optional; public class ItemGuideBook extends Item implements IGuideItem { diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java index 72cddf9f..822d0636 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java @@ -1,13 +1,11 @@ package amerifrance.guideapi.network; -import api.IGuideItem; -import api.util.NBTBookTags; -import io.netty.buffer.ByteBuf; +import amerifrance.guideapi.api.IGuideItem; +import amerifrance.guideapi.api.util.NBTBookTags; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkEvent; import org.apache.commons.lang3.Validate; diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java index 64b942fb..48ebfb7d 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java @@ -1,14 +1,12 @@ package amerifrance.guideapi.network; -import api.IGuideItem; -import api.util.NBTBookTags; -import io.netty.buffer.ByteBuf; +import amerifrance.guideapi.api.IGuideItem; +import amerifrance.guideapi.api.util.NBTBookTags; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.network.NetworkEvent; import org.apache.commons.lang3.Validate; diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java index 9635eff6..201343eb 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncHome.java @@ -1,13 +1,11 @@ package amerifrance.guideapi.network; -import api.IGuideItem; -import api.util.NBTBookTags; -import io.netty.buffer.ByteBuf; +import amerifrance.guideapi.api.IGuideItem; +import amerifrance.guideapi.api.util.NBTBookTags; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkEvent; import org.apache.commons.lang3.Validate; diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 2fd72a2d..f3705d62 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -1,12 +1,12 @@ package amerifrance.guideapi.page; -import api.SubTexture; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.SubTexture; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java index e7913f1c..cc6e1d79 100644 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java @@ -1,19 +1,17 @@ package amerifrance.guideapi.page; -import api.SubTexture; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.SubTexture; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; -import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipe; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index f035d6e6..2e4cf162 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -1,11 +1,11 @@ package amerifrance.guideapi.page; import amerifrance.guideapi.page.reciperenderer.FurnaceRecipeRenderer; -import api.IRecipeRenderer; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.IRecipeRenderer; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; @@ -21,8 +21,6 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import javax.annotation.Nullable; - public class PageIRecipe extends Page { diff --git a/src/main/java/amerifrance/guideapi/page/PageImage.java b/src/main/java/amerifrance/guideapi/page/PageImage.java index 5e76c7e4..dc3cce5d 100644 --- a/src/main/java/amerifrance/guideapi/page/PageImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageImage.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index 4218463a..cc6e859f 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -1,16 +1,14 @@ package amerifrance.guideapi.page; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.block.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index 60b63d7b..17c9b378 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -2,20 +2,16 @@ import amerifrance.guideapi.gui.EntryScreen; import amerifrance.guideapi.util.LogHelper; -import api.IRecipeRenderer; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.IRecipeRenderer; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.server.ServerLifecycleHooks; -import net.minecraftforge.registries.ForgeRegistries; public class PageJsonRecipe extends PageIRecipe { diff --git a/src/main/java/amerifrance/guideapi/page/PageSound.java b/src/main/java/amerifrance/guideapi/page/PageSound.java index c1c34005..783cfac4 100644 --- a/src/main/java/amerifrance/guideapi/page/PageSound.java +++ b/src/main/java/amerifrance/guideapi/page/PageSound.java @@ -1,11 +1,11 @@ package amerifrance.guideapi.page; import amerifrance.guideapi.GuideMod; -import api.IPage; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/PageText.java b/src/main/java/amerifrance/guideapi/page/PageText.java index e1dd3ca9..4b369864 100644 --- a/src/main/java/amerifrance/guideapi/page/PageText.java +++ b/src/main/java/amerifrance/guideapi/page/PageText.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.PageHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.resources.I18n; diff --git a/src/main/java/amerifrance/guideapi/page/PageTextImage.java b/src/main/java/amerifrance/guideapi/page/PageTextImage.java index 2c3770b7..7ae3ae33 100644 --- a/src/main/java/amerifrance/guideapi/page/PageTextImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageTextImage.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page; -import api.impl.Book; -import api.impl.Page; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.Page; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java index 8ec2a1c1..dd92e017 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java @@ -1,20 +1,18 @@ package amerifrance.guideapi.page.reciperenderer; -import api.IRecipeRenderer.RecipeRendererBase; -import api.SubTexture; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.IRecipeRenderer.RecipeRendererBase; +import amerifrance.guideapi.api.SubTexture; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.google.common.base.Strings; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.NonNullList; import java.util.Random; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index 850f0ac2..9169d2ba 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.page.reciperenderer; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index 860d80aa..a601555d 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.page.reciperenderer; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; -import api.util.TextHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index e50bb43a..0d42353e 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -2,28 +2,24 @@ import amerifrance.guideapi.gui.CategoryScreen; import amerifrance.guideapi.gui.HomeScreen; -import api.BookEvent; -import api.GuideAPI; -import api.IGuideItem; -import api.IRecipeRenderer; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.BookEvent; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.IGuideItem; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.EntryScreen; -import api.util.NBTBookTags; +import amerifrance.guideapi.api.util.NBTBookTags; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SimpleSound; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeType; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import java.util.Map; - public class ClientProxy extends CommonProxy { @Override diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index c2a7e73e..575b329d 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -1,24 +1,12 @@ package amerifrance.guideapi.proxy; -import api.GuideAPI; -import api.IGuideItem; -import api.IRecipeRenderer; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.NBTBookTags; -import amerifrance.guideapi.gui.CategoryScreen; -import amerifrance.guideapi.gui.EntryScreen; -import amerifrance.guideapi.gui.HomeScreen; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Hand; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.world.World; -import net.minecraftforge.fml.common.network.IGuiHandler; public class CommonProxy { diff --git a/src/main/java/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java similarity index 87% rename from src/main/java/test/TestBook.java rename to src/main/java/amerifrance/guideapi/test/TestBook.java index c93b8f05..01528413 100644 --- a/src/main/java/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -1,13 +1,13 @@ -package test; +package amerifrance.guideapi.test; -import api.GuideBook; -import api.IGuideBook; -import api.IPage; -import api.impl.Book; -import api.impl.BookBinder; -import api.impl.Entry; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.GuideBook; +import amerifrance.guideapi.api.IGuideBook; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.BookBinder; +import amerifrance.guideapi.api.impl.Entry; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.PageIRecipe; @@ -28,7 +28,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.awt.Color; -import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/src/main/java/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java similarity index 90% rename from src/main/java/test/TestBook2.java rename to src/main/java/amerifrance/guideapi/test/TestBook2.java index 270eea2d..7ebda1f8 100644 --- a/src/main/java/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -1,10 +1,10 @@ -package test; +package amerifrance.guideapi.test; -import api.GuideBook; -import api.IGuideBook; -import api.impl.Book; -import api.impl.BookBinder; -import api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.GuideBook; +import amerifrance.guideapi.api.IGuideBook; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.BookBinder; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; diff --git a/src/main/java/amerifrance/guideapi/util/APISetter.java b/src/main/java/amerifrance/guideapi/util/APISetter.java index 8f2cad62..39308ca7 100644 --- a/src/main/java/amerifrance/guideapi/util/APISetter.java +++ b/src/main/java/amerifrance/guideapi/util/APISetter.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.util; import amerifrance.guideapi.GuideMod; -import api.GuideAPI; -import api.impl.Book; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.impl.Book; import com.google.common.base.Throwables; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java index 8be4e925..f8abba35 100644 --- a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java +++ b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.util; -import api.GuideAPI; -import api.GuideBook; -import api.IGuideBook; -import api.impl.Book; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.GuideBook; +import amerifrance.guideapi.api.IGuideBook; +import amerifrance.guideapi.api.impl.Book; import com.google.common.collect.Lists; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.ModList; diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index 702f1ebf..1384bb2b 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -2,13 +2,13 @@ import amerifrance.guideapi.GuideConfig; import amerifrance.guideapi.GuideMod; -import api.GuideAPI; -import api.IGuideItem; -import api.IGuideLinked; -import api.IInfoRenderer; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.util.TextHelper; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.IGuideItem; +import amerifrance.guideapi.api.IGuideLinked; +import amerifrance.guideapi.api.IInfoRenderer; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.TextHelper; import com.google.common.base.Strings; import com.google.common.collect.Multimap; import net.minecraft.block.Block; diff --git a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java index 46878550..ea2d6c69 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/CategoryWrapper.java @@ -1,8 +1,8 @@ package amerifrance.guideapi.wrapper; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.ItemRenderer; diff --git a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java index da06f728..72564031 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/EntryWrapper.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.wrapper; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; -import api.util.GuiHelper; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.CategoryScreen; import net.minecraft.client.Minecraft; diff --git a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java index 63705593..24691fff 100644 --- a/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java +++ b/src/main/java/amerifrance/guideapi/wrapper/PageWrapper.java @@ -1,9 +1,9 @@ package amerifrance.guideapi.wrapper; -import api.IPage; -import api.impl.Book; -import api.impl.abstraction.CategoryAbstract; -import api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.IPage; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.Minecraft; diff --git a/src/main/java/api/package-info.java b/src/main/java/api/package-info.java deleted file mode 100644 index e165a207..00000000 --- a/src/main/java/api/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -package api; - From 55cd3c540db89bdcd877a2f56113aabcf02ac27b Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 28 Mar 2020 19:00:41 +0100 Subject: [PATCH 10/28] Finish recipe rework --- .../guideapi/api/IRecipeRenderer.java | 42 +++++- .../guideapi/page/PageBrewingRecipe.java | 41 +++++- .../guideapi/page/PageFurnaceRecipe.java | 122 ------------------ .../guideapi/page/PageIRecipe.java | 2 +- .../guideapi/page/PageJsonRecipe.java | 20 ++- ...derer.java => CraftingRecipeRenderer.java} | 26 ++-- .../reciperenderer/FurnaceRecipeRenderer.java | 47 ++++++- .../reciperenderer/ShapedRecipesRenderer.java | 13 +- .../ShapelessRecipesRenderer.java | 8 +- .../amerifrance/guideapi/test/TestBook.java | 9 +- 10 files changed, 163 insertions(+), 167 deletions(-) delete mode 100644 src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java rename src/main/java/amerifrance/guideapi/page/reciperenderer/{BasicRecipeRenderer.java => CraftingRecipeRenderer.java} (75%) diff --git a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java index 68462989..3dc7e448 100644 --- a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java @@ -5,13 +5,18 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import com.google.common.collect.Lists; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; +import java.util.Optional; +import java.util.Random; public interface IRecipeRenderer { @@ -21,15 +26,50 @@ public interface IRecipeRenderer { @OnlyIn(Dist.CLIENT) void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); - abstract class RecipeRendererBase implements IRecipeRenderer { + abstract class RecipeRendererBase> implements IRecipeRenderer { protected T recipe; protected List tooltips = Lists.newArrayList(); + private long lastCycle = -1; + private int cycleIdx = 0; + private Random rand = new Random(); + public RecipeRendererBase(T recipe) { this.recipe = recipe; } + @Override + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { + Minecraft mc = guiBase.getMinecraft(); + long time = mc.world.getGameTime(); + if (lastCycle < 0 || lastCycle < time - 20) { + if (lastCycle > 0) { + cycleIdx++; + cycleIdx = Math.max(0, cycleIdx); + } + lastCycle = mc.world.getGameTime(); + } + } + + /** + * Retrieves a itemstack that matches the ingredient. + * Cycles though all matching stacks. + * Must call {@link IRecipeRenderer#draw(Book, CategoryAbstract, EntryAbstract, int, int, int, int, BaseScreen, FontRenderer)} if you are overriding it. + * @param ingredient The ingredient + * @param index An "unique" id for this ingredient, so multiple ingredients can be cycled independently + * @return Optional. Can be empty if ingredient is invalid and has no matching stacks + */ + protected Optional getCycledIngredientStack(Ingredient ingredient, int index){ + ItemStack[] itemStacks = ingredient.getMatchingStacks(); + if(itemStacks.length>0){ + rand.setSeed(index); + int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) %itemStacks.length; + return Optional.of(itemStacks[id]); + } + return Optional.empty(); + } + @Override public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { guiBase.drawHoveringTextComponents(tooltips, mouseX, mouseY); diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index f3705d62..612dce3d 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -1,5 +1,6 @@ package amerifrance.guideapi.page; +import amerifrance.guideapi.api.IRecipeRenderer; import amerifrance.guideapi.api.SubTexture; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.Page; @@ -9,6 +10,7 @@ import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Blocks; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -21,6 +23,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.Random; public class PageBrewingRecipe extends Page { @@ -29,6 +33,11 @@ public class PageBrewingRecipe extends Page { public Ingredient input; public ItemStack output; + //Used for ingredient cycling + private long lastCycle = -1; + private int cycleIdx = 0; + private Random rand = new Random(); + /** * Your brewing recipe - what you pass to BrewingRecipeRegistry.addRecipe * @@ -55,6 +64,15 @@ public PageBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack outp @Override @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { + Minecraft mc = guiBase.getMinecraft(); + long time = mc.world.getGameTime(); + if (lastCycle < 0 || lastCycle < time - 20) { + if (lastCycle > 0) { + cycleIdx++; + cycleIdx = Math.max(0, cycleIdx); + } + lastCycle = mc.world.getGameTime(); + } int xStart = guiLeft + 62; int yStart = guiTop + 52; @@ -70,7 +88,11 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int x = xStart + 25;//since item stack is approx 16 wide int y = yStart + 1; //start input - GuiHelper.drawItemStack(ingredient.getMatchingStacks()[0], x, y); //TODO do proper and safe ingredient cycling + int finalX = x; + int finalY = y; + getCycledIngredientStack(ingredient,0).ifPresent(stack -> { + GuiHelper.drawItemStack(stack, finalX, finalY); + }); List tooltip = null; if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) @@ -109,4 +131,21 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiBase.drawHoveringTextComponents(tooltip, mouseX, mouseY); } + + /** + * Copied from {@link IRecipeRenderer} because brewing does not use real recipes + * @param ingredient + * @param index + * @return + */ + private Optional getCycledIngredientStack(Ingredient ingredient, int index){ + ItemStack[] itemStacks = ingredient.getMatchingStacks(); + if(itemStacks.length>0){ + rand.setSeed(index); + int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) %itemStacks.length; + return Optional.of(itemStacks[id]); + } + return Optional.empty(); + } + } diff --git a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java b/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java deleted file mode 100644 index cc6e1d79..00000000 --- a/src/main/java/amerifrance/guideapi/page/PageFurnaceRecipe.java +++ /dev/null @@ -1,122 +0,0 @@ -package amerifrance.guideapi.page; - -import amerifrance.guideapi.api.SubTexture; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.Page; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.api.util.GuiHelper; -import amerifrance.guideapi.api.util.TextHelper; -import amerifrance.guideapi.gui.BaseScreen; -import net.minecraft.block.Blocks; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - - -import java.util.ArrayList; -import java.util.List; - -public class PageFurnaceRecipe extends Page { - - public ItemStack input; - public ItemStack output; -// -// /** -// * @param input - Input ItemStack to draw smelting result of -// */ -// public PageFurnaceRecipe(ItemStack input) { -// this.input = input; -// this.output = FurnaceRecipe.instance().getSmeltingResult(input); -// } -// -// /** -// * @param input - Input Item to draw smelting result of -// */ -// public PageFurnaceRecipe(Item input) { -// this.input = new ItemStack(input); -// this.output = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(input)); -// } -// -// /** -// * @param input - Input Block to draw smelting result of -// */ -// public PageFurnaceRecipe(Block input) { -// this.input = new ItemStack(input); -// this.output = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(input)); -// } -// -// /** -// * @param input - Input OreDict entry to draw smelting result of -// */ -// public PageFurnaceRecipe(String input) { -// -// this.input = new ItemStack(Blocks.FIRE); -// -// if (!OreDictionary.getOres(input).isEmpty()) -// for (int i = 0; i < OreDictionary.getOres(input).size(); i++) { -// ItemStack stack = OreDictionary.getOres(input).get(i); -// -// this.input = stack; -// this.output = FurnaceRecipes.instance().getSmeltingResult(stack); -// } -// } - - - - @Override - @OnlyIn(Dist.CLIENT) - @SuppressWarnings("unchecked") - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - SubTexture.FURNACE_GRID.draw(guiLeft + 64, guiTop + 71); - - List badTip = new ArrayList(); - badTip.add(TextHelper.localizeEffect("text.furnace.error")); - - guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.furnace.smelting"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); - - int x = guiLeft + 66; - int y = guiTop + 77; - GuiHelper.drawItemStack(input, x, y); - - List tooltip = null; - if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) - tooltip = GuiHelper.getTooltip(input); - - if (output.isEmpty()) - output = new ItemStack(Blocks.BARRIER); - - x = guiLeft + 109; - GuiHelper.drawItemStack(output, x, y); - if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) - tooltip = output.getItem() == Item.getItemFromBlock(Blocks.BARRIER) ? badTip : GuiHelper.getTooltip(output); - - if (output.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) - guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.furnace.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); - - if (tooltip != null) - guiBase.drawHoveringTextComponents(tooltip, mouseX, mouseY); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof PageFurnaceRecipe)) return false; - if (!super.equals(o)) return false; - - PageFurnaceRecipe that = (PageFurnaceRecipe) o; - - if (input != null ? !input.equals(that.input) : that.input != null) return false; - return output != null ? output.equals(that.output) : that.output == null; - } - - @Override - public int hashCode() { - int result = input != null ? input.hashCode() : 0; - result = 31 * result + (output != null ? output.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 2e4cf162..7dbf78c4 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -77,7 +77,7 @@ public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, } - static IRecipeRenderer getRenderer(IRecipe recipe) { + protected static IRecipeRenderer getRenderer(IRecipe recipe) { if (recipe == null) { LogHelper.error("Cannot get renderer for null recipe."); return null; diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index 17c9b378..0851294d 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -9,22 +9,30 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nonnull; +import java.util.function.Function; +import java.util.function.Supplier; + public class PageJsonRecipe extends PageIRecipe { + @Nonnull private final ResourceLocation recipeId; + @Nonnull + private final Function,IRecipeRenderer> recipeRendererSupplier; public PageJsonRecipe(ResourceLocation recipeId) { - super(null, null); - this.recipeId = recipeId; + this(recipeId,PageIRecipe::getRenderer); } - public PageJsonRecipe(ResourceLocation recipeId, IRecipeRenderer render){ - super(null,render); + public PageJsonRecipe(ResourceLocation recipeId, Function,IRecipeRenderer> rendererSupplier){ + super(null,null); this.recipeId = recipeId; + this.recipeRendererSupplier=rendererSupplier; } @OnlyIn(Dist.CLIENT) @@ -37,8 +45,8 @@ public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, Pl LogHelper.error("Cannot find recipe "+recipeId.toString()); } else{ - if(iRecipeRenderer!=null){ - iRecipeRenderer = getRenderer(recipe); + if(iRecipeRenderer==null){ + iRecipeRenderer = recipeRendererSupplier.apply(recipe); } } } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java similarity index 75% rename from src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java rename to src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java index dd92e017..faa2753c 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/BasicRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java @@ -13,32 +13,24 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.Ingredient; +import java.util.Optional; import java.util.Random; -public class BasicRecipeRenderer> extends RecipeRendererBase { +public abstract class CraftingRecipeRenderer> extends RecipeRendererBase { + - private long lastCycle = -1; - private int cycleIdx = 0; - private Random rand = new Random(); private String customDisplay; - public BasicRecipeRenderer(T recipe) { + public CraftingRecipeRenderer(T recipe) { super(recipe); } @Override public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - Minecraft mc = Minecraft.getInstance(); + super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); - long time = mc.world.getGameTime(); - if (lastCycle < 0 || lastCycle < time - 20) { - if (lastCycle > 0) { - cycleIdx++; - cycleIdx = Math.max(0, cycleIdx); - } - lastCycle = mc.world.getGameTime(); - } SubTexture.CRAFTING_GRID.draw(guiLeft + 42, guiTop + 53); @@ -61,10 +53,6 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int // return subItems.get(getRandomizedCycle(position, subItems.size())); // } - protected int getRandomizedCycle(int index, int max) { - rand.setSeed(index); - return (index + rand.nextInt(max) + cycleIdx) % max; - } protected String getRecipeName() { return TextHelper.localizeEffect("text.shaped.crafting"); @@ -73,4 +61,6 @@ protected String getRecipeName() { public void setCustomTitle(String customDisplay) { this.customDisplay = customDisplay; } + + } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java index 5ee3618e..63cc9aa9 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java @@ -1,10 +1,55 @@ package amerifrance.guideapi.page.reciperenderer; +import amerifrance.guideapi.api.IRecipeRenderer; +import amerifrance.guideapi.api.SubTexture; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.TextHelper; +import amerifrance.guideapi.gui.BaseScreen; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipe; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.text.ITextComponent; +import java.util.ArrayList; +import java.util.List; -public class FurnaceRecipeRenderer extends BasicRecipeRenderer { + +public class FurnaceRecipeRenderer extends IRecipeRenderer.RecipeRendererBase { public FurnaceRecipeRenderer(FurnaceRecipe recipe) { super(recipe); } + + @Override + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { + super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); + SubTexture.FURNACE_GRID.draw(guiLeft + 64, guiTop + 71); + + guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.furnace.smelting"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); + + int x = guiLeft + 66; + int y = guiTop + 77; + + Ingredient input = recipe.getIngredients().get(0); + getCycledIngredientStack(input,0).ifPresent(stack -> { + GuiHelper.drawItemStack(stack, x, y); + + List tooltip = null; + if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, 15, 15)) + tooltips = GuiHelper.getTooltip(stack); + }); + + + + ItemStack output = recipe.getRecipeOutput(); + + int x2 = guiLeft + 109; + GuiHelper.drawItemStack(output, x2, y); + if (GuiHelper.isMouseBetween(mouseX, mouseY, x2, y, 15, 15)) + tooltips = GuiHelper.getTooltip(output); + + } } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index 9169d2ba..c7e99d3d 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -13,7 +13,7 @@ import java.util.Arrays; import java.util.List; -public class ShapedRecipesRenderer extends BasicRecipeRenderer { +public class ShapedRecipesRenderer extends CraftingRecipeRenderer { public ShapedRecipesRenderer(ShapedRecipe recipe) { super(recipe); @@ -23,18 +23,17 @@ public ShapedRecipesRenderer(ShapedRecipe recipe) { public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); for (int y = 0; y < recipe.getRecipeHeight(); y++) { - for (int x = 0; x < recipe.getRecipeHeight(); x++) { + for (int x = 0; x < recipe.getRecipeWidth(); x++) { + int i = y*recipe.getRecipeWidth()+x; int stackX = (x + 1) * 17 + (guiLeft + 27) + x; int stackY = (y + 1) * 17 + (guiTop + 38) + y; - Ingredient ingredient = recipe.getIngredients().get(y * recipe.getRecipeWidth() + x); - List list = Arrays.asList(ingredient.getMatchingStacks()); - if (!list.isEmpty()) { - ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); + Ingredient ingredient = recipe.getIngredients().get(i); + getCycledIngredientStack(ingredient,i).ifPresent(stack -> { GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); - } + }); } } } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index a601555d..ada2e547 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -14,7 +14,7 @@ import java.util.Arrays; import java.util.List; -public class ShapelessRecipesRenderer extends BasicRecipeRenderer { +public class ShapelessRecipesRenderer extends CraftingRecipeRenderer { public ShapelessRecipesRenderer(ShapelessRecipe recipe) { super(recipe); @@ -30,13 +30,11 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int stackY = (y + 1) * 17 + (guiTop + 38) + y; if (i < recipe.getIngredients().size()) { Ingredient ingredient = recipe.getIngredients().get(i); - List list = Arrays.asList(ingredient.getMatchingStacks()); - if (!list.isEmpty()) { - ItemStack stack = list.get(getRandomizedCycle(x + (y * 3), list.size())); + getCycledIngredientStack(ingredient,i).ifPresent(stack -> { GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); - } + }); } } } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 01528413..5eee7f39 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -13,6 +13,7 @@ import amerifrance.guideapi.page.PageIRecipe; import amerifrance.guideapi.page.PageJsonRecipe; import amerifrance.guideapi.page.PageText; +import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.minecraft.block.Blocks; @@ -55,15 +56,13 @@ private void buildContent(List categories){ List pages = Lists.newArrayList(); pages.add(new PageText("Hello, this is\nsome text")); - //pages.add(new PageFurnaceRecipe(Blocks.COBBLESTONE)); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stone"))); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stick"),recipe -> recipe instanceof ShapedRecipe ? new ShapedRecipesRenderer((ShapedRecipe) recipe) : null)); //Probably want to use your own method as render supplier and print proper logs + pages.add(new PageIRecipe(new ShapedRecipe(new ResourceLocation("guideapi","test11"), "test",1,1,NonNullList.from(Ingredient.EMPTY,Ingredient.fromStacks(new ItemStack(Items.PUMPKIN))),new ItemStack(Blocks.OAK_LOG)))); - //pages.add(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', "plankWood")); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "acacia_fence"))); Entry entry = new EntryItemStack(pages, "test.entry.name", new ItemStack(Items.POTATO)); entries.put(new ResourceLocation("guideapi", "entry"), entry); - - //pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.IRON_BLOCK), "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron", "ingotIron")); - //pages.add(PageIRecipe.newShapeless(new ItemStack(Blocks.OAK_PLANKS, 4), new ItemStack(Blocks.OAK_LOG))); categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BLUE_BANNER))); } } From 42c1d7f8ad6e1a225d6f7936bf6e5f64b6a9123d Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 28 Mar 2020 19:16:11 +0100 Subject: [PATCH 11/28] Extract ingredient cycling function for general purposes --- .../guideapi/api/IRecipeRenderer.java | 36 +----------- .../guideapi/api/util/IngredientCycler.java | 56 +++++++++++++++++++ .../guideapi/page/PageBrewingRecipe.java | 34 ++--------- .../guideapi/page/PageIRecipe.java | 6 +- .../guideapi/page/PageItemStack.java | 26 ++++++--- .../CraftingRecipeRenderer.java | 5 +- .../reciperenderer/FurnaceRecipeRenderer.java | 6 +- .../reciperenderer/ShapedRecipesRenderer.java | 7 ++- .../ShapelessRecipesRenderer.java | 7 ++- .../amerifrance/guideapi/test/TestBook.java | 7 +++ 10 files changed, 104 insertions(+), 86 deletions(-) create mode 100644 src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java diff --git a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java index 3dc7e448..05f16de5 100644 --- a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java @@ -1,5 +1,6 @@ package amerifrance.guideapi.api; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; @@ -21,7 +22,7 @@ public interface IRecipeRenderer { @OnlyIn(Dist.CLIENT) - void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); + void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler); @OnlyIn(Dist.CLIENT) void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj); @@ -31,44 +32,11 @@ abstract class RecipeRendererBase> implements IRecipeRender protected T recipe; protected List tooltips = Lists.newArrayList(); - private long lastCycle = -1; - private int cycleIdx = 0; - private Random rand = new Random(); public RecipeRendererBase(T recipe) { this.recipe = recipe; } - @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - Minecraft mc = guiBase.getMinecraft(); - long time = mc.world.getGameTime(); - if (lastCycle < 0 || lastCycle < time - 20) { - if (lastCycle > 0) { - cycleIdx++; - cycleIdx = Math.max(0, cycleIdx); - } - lastCycle = mc.world.getGameTime(); - } - } - - /** - * Retrieves a itemstack that matches the ingredient. - * Cycles though all matching stacks. - * Must call {@link IRecipeRenderer#draw(Book, CategoryAbstract, EntryAbstract, int, int, int, int, BaseScreen, FontRenderer)} if you are overriding it. - * @param ingredient The ingredient - * @param index An "unique" id for this ingredient, so multiple ingredients can be cycled independently - * @return Optional. Can be empty if ingredient is invalid and has no matching stacks - */ - protected Optional getCycledIngredientStack(Ingredient ingredient, int index){ - ItemStack[] itemStacks = ingredient.getMatchingStacks(); - if(itemStacks.length>0){ - rand.setSeed(index); - int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) %itemStacks.length; - return Optional.of(itemStacks[id]); - } - return Optional.empty(); - } @Override public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { diff --git a/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java b/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java new file mode 100644 index 00000000..f1a78e43 --- /dev/null +++ b/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java @@ -0,0 +1,56 @@ +package amerifrance.guideapi.api.util; + + +import amerifrance.guideapi.api.IRecipeRenderer; +import amerifrance.guideapi.api.impl.Book; +import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.gui.BaseScreen; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import javax.annotation.Nonnull; +import java.util.Optional; +import java.util.Random; + + +/** + * Allows convenient consistent cycling through all matching stacks of an ingredient + */ +public class IngredientCycler { + + private long lastCycle = -1; + private int cycleIdx = 0; + private Random rand = new Random(); + + public void tick(@Nonnull Minecraft mc){ + long time = mc.world!=null?mc.world.getGameTime():0; + if (lastCycle < 0 || lastCycle < time - 20) { + if (lastCycle > 0) { + cycleIdx++; + cycleIdx = Math.max(0, cycleIdx); + } + lastCycle = time; + } + } + + /** + * Retrieves a itemstack that matches the ingredient. + * Cycles though all matching stacks. + * Must call {@link IngredientCycler#tick(Minecraft)} before (e.g. once per onDraw) + * @param ingredient The ingredient + * @param index An "unique" id for this ingredient, so multiple ingredients can be cycled independently + * @return Optional. Can be empty if ingredient is invalid and has no matching stacks + */ + public Optional getCycledIngredientStack(@Nonnull Ingredient ingredient, int index){ + ItemStack[] itemStacks = ingredient.getMatchingStacks(); + if(itemStacks.length>0){ + rand.setSeed(index); + int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) %itemStacks.length; + return Optional.of(itemStacks[id]); + } + return Optional.empty(); + } +} diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 612dce3d..71ee1925 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -7,6 +7,7 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Blocks; @@ -33,10 +34,7 @@ public class PageBrewingRecipe extends Page { public Ingredient input; public ItemStack output; - //Used for ingredient cycling - private long lastCycle = -1; - private int cycleIdx = 0; - private Random rand = new Random(); + private IngredientCycler cycler = new IngredientCycler(); /** * Your brewing recipe - what you pass to BrewingRecipeRegistry.addRecipe @@ -64,15 +62,7 @@ public PageBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack outp @Override @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - Minecraft mc = guiBase.getMinecraft(); - long time = mc.world.getGameTime(); - if (lastCycle < 0 || lastCycle < time - 20) { - if (lastCycle > 0) { - cycleIdx++; - cycleIdx = Math.max(0, cycleIdx); - } - lastCycle = mc.world.getGameTime(); - } + cycler.tick(guiBase.getMinecraft()); int xStart = guiLeft + 62; int yStart = guiTop + 52; @@ -90,7 +80,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int //start input int finalX = x; int finalY = y; - getCycledIngredientStack(ingredient,0).ifPresent(stack -> { + cycler.getCycledIngredientStack(ingredient,0).ifPresent(stack -> { GuiHelper.drawItemStack(stack, finalX, finalY); }); @@ -132,20 +122,4 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int } - /** - * Copied from {@link IRecipeRenderer} because brewing does not use real recipes - * @param ingredient - * @param index - * @return - */ - private Optional getCycledIngredientStack(Ingredient ingredient, int index){ - ItemStack[] itemStacks = ingredient.getMatchingStacks(); - if(itemStacks.length>0){ - rand.setSeed(index); - int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) %itemStacks.length; - return Optional.of(itemStacks[id]); - } - return Optional.empty(); - } - } diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 7dbf78c4..07fbe584 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -1,5 +1,6 @@ package amerifrance.guideapi.page; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.page.reciperenderer.FurnaceRecipeRenderer; import amerifrance.guideapi.api.IRecipeRenderer; import amerifrance.guideapi.api.impl.Book; @@ -27,7 +28,7 @@ public class PageIRecipe extends Page { public IRecipe recipe; public IRecipeRenderer iRecipeRenderer; protected boolean isValid; - + private IngredientCycler ingredientCycler = new IngredientCycler(); /** * Use this if you are creating a page for a standard recipe, one of: *

@@ -58,7 +59,8 @@ public PageIRecipe(IRecipe recipe, IRecipeRenderer iRecipeRenderer) { public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { if(isValid) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); - iRecipeRenderer.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); + ingredientCycler.tick(guiBase.getMinecraft()); + iRecipeRenderer.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj,ingredientCycler); } } diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index cc6e859f..eb059165 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -4,25 +4,32 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class PageItemStack extends PageText { - public ItemStack stack; + public Ingredient ingredient; + private IngredientCycler ingredientCycler = new IngredientCycler(); + + public PageItemStack(String draw, Ingredient ingredient){ + super(draw,60); + this.ingredient=ingredient; + } /** * @param draw - Unlocalized text to draw - * @param stack - ItemStack to render + * @param ingredient - ItemStack to render */ - public PageItemStack(String draw, ItemStack stack) { - super(draw, 60); - this.stack = stack; + public PageItemStack(String draw, ItemStack ingredient) { + this(draw,Ingredient.fromStacks(ingredient)); } /** @@ -45,7 +52,10 @@ public PageItemStack(String draw, Block block) { @Override @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - GuiHelper.drawScaledItemStack(stack, guiLeft + 75, guiTop + 20, 3); + ingredientCycler.tick(guiBase.getMinecraft()); + ingredientCycler.getCycledIngredientStack(ingredient,0).ifPresent(stack -> { + GuiHelper.drawScaledItemStack(stack, guiLeft + 75, guiTop + 20, 3); + }); } @Override @@ -56,13 +66,13 @@ public boolean equals(Object o) { PageItemStack that = (PageItemStack) o; - return stack != null ? stack.equals(that.stack) : that.stack == null; + return ingredient != null ? ingredient.equals(that.ingredient) : that.ingredient == null; } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (stack != null ? stack.hashCode() : 0); + result = 31 * result + (ingredient != null ? ingredient.hashCode() : 0); return result; } } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java index faa2753c..5dc0fa1b 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java @@ -6,6 +6,7 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.google.common.base.Strings; @@ -28,9 +29,7 @@ public CraftingRecipeRenderer(T recipe) { } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); - + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { SubTexture.CRAFTING_GRID.draw(guiLeft + 42, guiTop + 53); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java index 63cc9aa9..d0121402 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java @@ -6,6 +6,7 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; @@ -24,8 +25,7 @@ public FurnaceRecipeRenderer(FurnaceRecipe recipe) { } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { SubTexture.FURNACE_GRID.draw(guiLeft + 64, guiTop + 71); guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.furnace.smelting"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); @@ -34,7 +34,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int y = guiTop + 77; Ingredient input = recipe.getIngredients().get(0); - getCycledIngredientStack(input,0).ifPresent(stack -> { + cycler.getCycledIngredientStack(input,0).ifPresent(stack -> { GuiHelper.drawItemStack(stack, x, y); List tooltip = null; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index c7e99d3d..9591bad7 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -4,6 +4,7 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; @@ -20,8 +21,8 @@ public ShapedRecipesRenderer(ShapedRecipe recipe) { } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { + super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj, cycler); for (int y = 0; y < recipe.getRecipeHeight(); y++) { for (int x = 0; x < recipe.getRecipeWidth(); x++) { int i = y*recipe.getRecipeWidth()+x; @@ -29,7 +30,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int stackY = (y + 1) * 17 + (guiTop + 38) + y; Ingredient ingredient = recipe.getIngredients().get(i); - getCycledIngredientStack(ingredient,i).ifPresent(stack -> { + cycler.getCycledIngredientStack(ingredient,i).ifPresent(stack -> { GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index ada2e547..a6541aaf 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -4,6 +4,7 @@ import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; @@ -21,8 +22,8 @@ public ShapelessRecipesRenderer(ShapelessRecipe recipe) { } @Override - public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); + public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { + super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj, cycler); for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { int i = 3 * y + x; @@ -30,7 +31,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int stackY = (y + 1) * 17 + (guiTop + 38) + y; if (i < recipe.getIngredients().size()) { Ingredient ingredient = recipe.getIngredients().get(i); - getCycledIngredientStack(ingredient,i).ifPresent(stack -> { + cycler.getCycledIngredientStack(ingredient,i).ifPresent(stack -> { GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 5eee7f39..2f175a36 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -11,6 +11,7 @@ import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.PageIRecipe; +import amerifrance.guideapi.page.PageItemStack; import amerifrance.guideapi.page.PageJsonRecipe; import amerifrance.guideapi.page.PageText; import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; @@ -22,6 +23,8 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.Tags; @@ -57,10 +60,14 @@ private void buildContent(List categories){ List pages = Lists.newArrayList(); pages.add(new PageText("Hello, this is\nsome text")); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stone"))); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","charcoal"))); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stick"),recipe -> recipe instanceof ShapedRecipe ? new ShapedRecipesRenderer((ShapedRecipe) recipe) : null)); //Probably want to use your own method as render supplier and print proper logs pages.add(new PageIRecipe(new ShapedRecipe(new ResourceLocation("guideapi","test11"), "test",1,1,NonNullList.from(Ingredient.EMPTY,Ingredient.fromStacks(new ItemStack(Items.PUMPKIN))),new ItemStack(Blocks.OAK_LOG)))); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "acacia_fence"))); + pages.add(new PageItemStack("These are all logs",Ingredient.fromTag(ItemTags.LOGS))); + Entry entry = new EntryItemStack(pages, "test.entry.name", new ItemStack(Items.POTATO)); entries.put(new ResourceLocation("guideapi", "entry"), entry); categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BLUE_BANNER))); From a0ba8deaadf696da3095a24365bb67927e6534e2 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 28 Mar 2020 19:18:58 +0100 Subject: [PATCH 12/28] Remove crafting recipe functions for books. They have to be added via json --- src/main/java/amerifrance/guideapi/api/IGuideBook.java | 10 ---------- src/main/java/amerifrance/guideapi/test/TestBook.java | 5 ----- src/main/java/amerifrance/guideapi/test/TestBook2.java | 6 ------ 3 files changed, 21 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/api/IGuideBook.java b/src/main/java/amerifrance/guideapi/api/IGuideBook.java index 40449854..4e962239 100644 --- a/src/main/java/amerifrance/guideapi/api/IGuideBook.java +++ b/src/main/java/amerifrance/guideapi/api/IGuideBook.java @@ -29,16 +29,6 @@ default void handleModel(@Nonnull ItemStack bookStack) { GuideAPI.setModel(((IGuideItem) bookStack.getItem()).getBook(bookStack)); } - /** - * An IRecipe to use for your book. Called from {@link net.minecraftforge.event.RegistryEvent.Register} - * - * @return an IRecipe to register for your book or null to not include one. - */ - @Nullable - default IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return null; - } - /** * Called during Post Initialization. */ diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 2f175a36..60af5c53 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -48,11 +48,6 @@ public Book buildBook() { return (book = binder.build()); } - @Override - public IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return new ShapedRecipe(book.getRegistryName(), "", 3,1,NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_IRON),Ingredient.EMPTY),bookStack); - } - private void buildContent(List categories){ Map entries = Maps.newHashMap(); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 7ebda1f8..a09348e2 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -41,12 +41,6 @@ public Book buildBook() { return (book = binder.build()); } - @Nullable - @Override - public IRecipe getRecipe(@Nonnull ItemStack bookStack) { - return new ShapedRecipe(book.getRegistryName(), "", 3,1, NonNullList.from(Ingredient.EMPTY,Ingredient.EMPTY,Ingredient.fromTag(Tags.Items.INGOTS_GOLD),Ingredient.EMPTY),bookStack); - } - private void buildContent(List categories) { CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLUE_BANNER)).withKeyBase("guideapi"); testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); From ebddbd3a856b1b16c9f076b6d0733bf636497128 Mon Sep 17 00:00:00 2001 From: maxanier Date: Tue, 31 Mar 2020 17:28:02 +0200 Subject: [PATCH 13/28] Fix search --- .../guideapi/gui/SearchScreen.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java index 030b6782..32e6b82a 100644 --- a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java @@ -140,8 +140,6 @@ public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { @Override public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3_, double movement) { - - if (movement < 0 && buttonNext.visible && currentPage <= searchResults.size()) currentPage++; else if (movement > 0 && buttonPrev.visible && currentPage > 0) @@ -160,17 +158,30 @@ public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) if (keyCode == GLFW.GLFW_KEY_ESCAPE) searchField.changeFocus(false); - searchField.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); + if(searchField.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_)) { + this.updateSearch(); + } + + return true; + } + + private void updateSearch(){ if (!searchField.getText().equalsIgnoreCase(lastQuery)) { lastQuery = searchField.getText(); searchResults = getMatches(book, searchField.getText(), player, bookStack); if (currentPage > searchResults.size()) currentPage = searchResults.size() - 1; } - return true; } - + @Override + public boolean charTyped(char p_charTyped_1_, int p_charTyped_2_) { + if (this.searchField.charTyped(p_charTyped_1_, p_charTyped_2_)) { + this.updateSearch(); + return true; + } + return super.charTyped(p_charTyped_1_, p_charTyped_2_); + } @Nonnull static List>> getMatches(Book book, @Nullable String query, PlayerEntity player, ItemStack bookStack) { From 8bcda6ecc9a1472011056535015a2cc7d4f1371e Mon Sep 17 00:00:00 2001 From: maxanier Date: Tue, 31 Mar 2020 17:38:26 +0200 Subject: [PATCH 14/28] Fix localization --- .../guideapi/api/impl/BookBinder.java | 2 +- .../guideapi/button/ButtonBack.java | 4 +-- .../guideapi/button/ButtonNext.java | 4 +-- .../guideapi/button/ButtonPrev.java | 4 +-- .../guideapi/button/ButtonSearch.java | 4 +-- .../guideapi/page/PageBrewingRecipe.java | 6 ++-- .../CraftingRecipeRenderer.java | 2 +- .../reciperenderer/FurnaceRecipeRenderer.java | 2 +- .../ShapelessRecipesRenderer.java | 2 +- .../amerifrance/guideapi/test/TestBook.java | 4 +-- .../amerifrance/guideapi/test/TestBook2.java | 7 ++-- .../guideapi/util/EventHandler.java | 2 +- .../resources/assets/guideapi/lang/de_de.json | 18 ++++++++++ .../resources/assets/guideapi/lang/en_US.lang | 32 ------------------ .../resources/assets/guideapi/lang/en_us.json | 33 +++++++++++++++++++ .../resources/assets/guideapi/lang/ru_RU.lang | 22 ------------- .../resources/assets/guideapi/lang/ru_ru.json | 21 ++++++++++++ .../resources/assets/guideapi/lang/zh_CN.lang | 22 ------------- .../resources/assets/guideapi/lang/zh_cn.json | 21 ++++++++++++ 19 files changed, 116 insertions(+), 96 deletions(-) create mode 100644 src/main/resources/assets/guideapi/lang/de_de.json delete mode 100644 src/main/resources/assets/guideapi/lang/en_US.lang create mode 100644 src/main/resources/assets/guideapi/lang/en_us.json delete mode 100644 src/main/resources/assets/guideapi/lang/ru_RU.lang create mode 100644 src/main/resources/assets/guideapi/lang/ru_ru.json delete mode 100644 src/main/resources/assets/guideapi/lang/zh_CN.lang create mode 100644 src/main/resources/assets/guideapi/lang/zh_cn.json diff --git a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java index cc7a17f6..15808f35 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java +++ b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java @@ -17,7 +17,7 @@ public class BookBinder { private final ResourceLocation registryName; private Consumer> contentProvider; - private String guideTitle = "item.guideapi.book.name"; + private String guideTitle = "item.guideapi.book"; private String header; private String itemName; private String author; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonBack.java b/src/main/java/amerifrance/guideapi/button/ButtonBack.java index 0a381470..8f71deb7 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonBack.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonBack.java @@ -31,7 +31,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { this.blit(x,y+1,70,201,18,10); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); } else { this.blit(x,y,94,201,18,10); } @@ -42,7 +42,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { public List getHoveringText() { ArrayList list = new ArrayList(); - String s = TextHelper.localizeEffect("button.back.name"); + String s = TextHelper.localizeEffect("guideapi.button.back"); list.add(s); return list; } diff --git a/src/main/java/amerifrance/guideapi/button/ButtonNext.java b/src/main/java/amerifrance/guideapi/button/ButtonNext.java index 32f4a699..df9917da 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonNext.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonNext.java @@ -30,7 +30,7 @@ public void renderButton( int mouseX, int mouseY, float partialTicks) { Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { this.blit(x,y+1,47,201,18,10); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); } else { this.blit(x,y,24,201,18,10); } @@ -41,7 +41,7 @@ public void renderButton( int mouseX, int mouseY, float partialTicks) { public List getHoveringText() { ArrayList list = new ArrayList(); - list.add(TextHelper.localizeEffect("button.next.name")); + list.add(TextHelper.localizeEffect("guideapi.button.next")); return list; } } diff --git a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java index b78d598b..2efd593e 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java @@ -31,7 +31,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { this.blit(x,y+1,47,214,18,10); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); } else { this.blit(x,y,24,214,18,10); } @@ -42,7 +42,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { public List getHoveringText() { ArrayList list = new ArrayList(); - list.add(TextHelper.localizeEffect("button.prev.name")); + list.add(TextHelper.localizeEffect("guideapi.button.prev")); return list; } } \ No newline at end of file diff --git a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java index f55f57ca..f75b06b2 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java @@ -29,7 +29,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { GlStateManager.disableLighting(); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { SubTexture.MAGNIFYING_GLASS.draw(x, y + 1); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,width,height,width,Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); } else { SubTexture.MAGNIFYING_GLASS.draw(x, y); } @@ -40,7 +40,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { public List getHoveringText() { ArrayList list = new ArrayList(); - list.add(TextHelper.localizeEffect("button.search.name")); + list.add(TextHelper.localizeEffect("guideapi.button.search")); return list; } } diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 71ee1925..2b8ab1ae 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -70,9 +70,9 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int SubTexture.POTION_GRID.draw(xStart, yStart); List badTip = new ArrayList<>(); - badTip.add(new TranslationTextComponent("text.brewing.error")); + badTip.add(new TranslationTextComponent("guideapi.text.brewing.error")); - guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.brewing.brew"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); + guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("guideapi.text.brewing.brew"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); //int xmiddle = guiLeft + guiBase.xSize / 2 - 6; int x = xStart + 25;//since item stack is approx 16 wide @@ -115,7 +115,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int tooltip = output.getItem() == Item.getItemFromBlock(Blocks.BARRIER) ? badTip : GuiHelper.getTooltip(output); if (output.getItem() == Item.getItemFromBlock(Blocks.BARRIER)) - guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.brewing.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); + guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("guideapi.text.brewing.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D); if (tooltip != null) guiBase.drawHoveringTextComponents(tooltip, mouseX, mouseY); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java index 5dc0fa1b..4bb34fc9 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java @@ -54,7 +54,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int protected String getRecipeName() { - return TextHelper.localizeEffect("text.shaped.crafting"); + return TextHelper.localizeEffect("guideapi.text.crafting.shaped"); } public void setCustomTitle(String customDisplay) { diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java index d0121402..1d4d3911 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java @@ -28,7 +28,7 @@ public FurnaceRecipeRenderer(FurnaceRecipe recipe) { public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { SubTexture.FURNACE_GRID.draw(guiLeft + 64, guiTop + 71); - guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("text.furnace.smelting"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); + guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("guideapi.text.furnace.smelting"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); int x = guiLeft + 66; int y = guiTop + 77; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index a6541aaf..e62a82c9 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -43,6 +43,6 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int @Override protected String getRecipeName() { - return TextHelper.localizeEffect("text.shapeless.crafting"); + return TextHelper.localizeEffect("guideapi.text.crafting.shapeless"); } } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 60af5c53..eb5f0283 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -63,8 +63,8 @@ private void buildContent(List categories){ pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "acacia_fence"))); pages.add(new PageItemStack("These are all logs",Ingredient.fromTag(ItemTags.LOGS))); - Entry entry = new EntryItemStack(pages, "test.entry.name", new ItemStack(Items.POTATO)); + Entry entry = new EntryItemStack(pages, "guideapi.test.entry", new ItemStack(Items.POTATO)); entries.put(new ResourceLocation("guideapi", "entry"), entry); - categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BLUE_BANNER))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.BLUE_BANNER))); } } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index a09348e2..007aa8c1 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -5,6 +5,7 @@ import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.BookBinder; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; import amerifrance.guideapi.page.*; @@ -42,14 +43,16 @@ public Book buildBook() { } private void buildContent(List categories) { - CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BLUE_BANNER)).withKeyBase("guideapi"); - testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO))); + CategoryAbstract testCategory = new CategoryItemStack("guideapi.test.category", new ItemStack(Items.BLUE_BANNER)).withKeyBase("guideapi"); + testCategory.addEntry("entry", new EntryItemStack("guideapi.test.entry", new ItemStack(Items.POTATO))); testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); //testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); //testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); + testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("redstone"))); + testCategory.getEntry("entry").addPageList(PageHelper.pagesForLongText("guideapi.test.format")); categories.add(testCategory); } } diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index 1384bb2b..e6362b31 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -106,7 +106,7 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { drawY -= 2; drawX += 20; fontRenderer.drawStringWithShadow(TextFormatting.WHITE + linkedEntry, drawX, drawY, 0); - fontRenderer.drawStringWithShadow(TextFormatting.WHITE.toString() + TextFormatting.ITALIC.toString() + TextHelper.localize("text.linked.open"), drawX, drawY + 12, 0); + fontRenderer.drawStringWithShadow(TextFormatting.WHITE.toString() + TextFormatting.ITALIC.toString() + TextHelper.localize("guideapi.text.linked.open"), drawX, drawY + 12, 0); } if (state.getBlock() instanceof IInfoRenderer.Block) { diff --git a/src/main/resources/assets/guideapi/lang/de_de.json b/src/main/resources/assets/guideapi/lang/de_de.json new file mode 100644 index 00000000..dd010fa2 --- /dev/null +++ b/src/main/resources/assets/guideapi/lang/de_de.json @@ -0,0 +1,18 @@ +{ + "_comment": "Item", + "item.guideapi.book": "Handbuch", + + "_comment": "Button hovering text", + "guideapi.button.back": "Zurück", + "guideapi.button.next": "Nächste", + "guideapi.button.prev": "Vorherige", + "guideapi.button.search": "Suche", + + "_comment": "Text to draw", + "guideapi.text.crafting.shaped": "Crafting", + "guideapi.text.crafting.shapeless": "Formloses Crafting", + "guideapi.text.furnace.smelting": "Schmelzen", + "guideapi.text.linked.open": "Schleiche + Nutze zum Öffnen", + "guideapi.text.brewing.brew": "Brauen", + "guidepai.text.brewing.error": "&cFehler in diesem Rezept" +} \ No newline at end of file diff --git a/src/main/resources/assets/guideapi/lang/en_US.lang b/src/main/resources/assets/guideapi/lang/en_US.lang deleted file mode 100644 index d940dcd4..00000000 --- a/src/main/resources/assets/guideapi/lang/en_US.lang +++ /dev/null @@ -1,32 +0,0 @@ -#Creative Tab -itemGroup.guideapi.creativeTab=Guide-API - -#Item -item.guideapi.book.name=Guide Book - -#Button hovering text -button.back.name=Back -button.next.name=Next -button.prev.name=Previous -button.search.name=Search - -#Text to draw -text.shaped.crafting=Shaped Crafting -text.shapeless.crafting=Shapeless Crafting -text.furnace.smelting=Smelting -text.furnace.error=&cError in the recipe -text.book.warning=&c[WARNING] Delete this item, it has no associated book! -text.book.creative=Creative Book -text.book=Book: %s -text.category=Category: %s -text.entry=Entry: %s -text.page=Page: %s -text.brewing.brew=Brewing -text.brewing.error=&cError in the recipe -text.linked.open=Sneak + Use to open -text.open.failed=Something stopped you from opening this book - -#Test -test.guide.format=This i\ns a formatting\n\ttest -test.category.name=Test Category -test.entry.name=Test Entry \ No newline at end of file diff --git a/src/main/resources/assets/guideapi/lang/en_us.json b/src/main/resources/assets/guideapi/lang/en_us.json new file mode 100644 index 00000000..de652506 --- /dev/null +++ b/src/main/resources/assets/guideapi/lang/en_us.json @@ -0,0 +1,33 @@ +{ + "_comment": "Item", + "item.guideapi.book": "Guide Book", + + "_comment": "Button hovering text", + "guideapi.button.back": "Back", + "guideapi.button.next": "Next", + "guideapi.button.prev": "Previous", + "guideapi.button.search": "Search", + + "_comment": "Text to draw", + "guideapi.text.crafting.shaped": "Shaped Crafting", + "guideapi.text.crafting.shapeless": "Shapeless Crafting", + "guideapi.text.furnace.smelting": "Smelting", + "guideapi.text.linked.open": "Sneak + Use to open", + "guideapi.text.brewing.brew": "Brewing", + "guidepai.text.brewing.error": "&cError in the recipe", + + "_comment": "Test", + "guideapi.test.format": "This i\\ns a formatting\\n\\ttest", + "guideapi.test.category": "Test Category", + "guideapi.test.entry": "Test Entry", + + "_comment": "Unused", + "text.furnace.error": "&cError in the recipe", + "text.book.warning": "&c[WARNING] Delete this item, it has no associated book!", + "text.book.creative": "Creative Book", + "text.book": "Book: %s", + "text.category": "Category: %s", + "text.entry": "Entry: %s", + "text.page": "Page: %s", + "text.open.failed": "Something stopped you from opening this book" +} \ No newline at end of file diff --git a/src/main/resources/assets/guideapi/lang/ru_RU.lang b/src/main/resources/assets/guideapi/lang/ru_RU.lang deleted file mode 100644 index c433f3f6..00000000 --- a/src/main/resources/assets/guideapi/lang/ru_RU.lang +++ /dev/null @@ -1,22 +0,0 @@ -#Creative Tab -itemGroup.guideapi.creativeTab=Guide-API - -#Item -item.GuideBook.name=Стандартная книга Guide-API - -#Button hovering text -button.back.name=Назад -button.next.name=След. -button.prev.name=Пред. - -#Text to draw -text.shaped.crafting=Форменное создание -text.shapeless.crafting=Бесформенное создание -text.furnace.smelting=Плавка -text.furnace.error=&cОшибка в рецепте -text.book.warning=&c[ВНИМАНИЕ] Выкиньте этот предмет, у него нет связанной книги! -text.book.creative=Творческая книга -text.book=Книга: %s -text.category=Категория: %s -text.entry=Запись: %s -text.page=Страница: %s diff --git a/src/main/resources/assets/guideapi/lang/ru_ru.json b/src/main/resources/assets/guideapi/lang/ru_ru.json new file mode 100644 index 00000000..7ec19e7b --- /dev/null +++ b/src/main/resources/assets/guideapi/lang/ru_ru.json @@ -0,0 +1,21 @@ +{ + "_comment": "Item", + "item.guideapi.book": "Стандартная книга Guide-API", + + "_comment": "Button hovering text", + "guideapi.button.back": "Назад", + "guideapi.button.next": "След.", + "guideapi.button.prev": "Пред.", + + "_comment": "Text to draw", + "guideapi.text.crafting.shaped": "Форменное создание", + "guideapi.text.crafting.shapeless": "Бесформенное создание", + "guideapi.text.furnace.smelting": "Плавка", + "text.furnace.error": "&cОшибка в рецепте", + "text.book.warning": "&c[ВНИМАНИЕ] Выкиньте этот предмет, у него нет связанной книги!", + "text.book.creative": "Творческая книга", + "text.book": "Книга: %s", + "text.category": "Категория: %s", + "text.entry": "Запись: %s", + "text.page": "Страница: %s" +} \ No newline at end of file diff --git a/src/main/resources/assets/guideapi/lang/zh_CN.lang b/src/main/resources/assets/guideapi/lang/zh_CN.lang deleted file mode 100644 index ee344656..00000000 --- a/src/main/resources/assets/guideapi/lang/zh_CN.lang +++ /dev/null @@ -1,22 +0,0 @@ -#Creative Tab -itemGroup.guideapi.creativeTab=Guide-API - -#Item -item.guideapi.book.name=Guide-API 默认书 - -#Button hovering text -button.back.name=返回 -button.next.name=下一页 -button.prev.name=上一页 - -#Text to draw -text.shaped.crafting=普通配方 -text.shapeless.crafting=无形配方 -text.furnace.smelting=冶炼 -text.furnace.error=&c合成配方出错 -text.book.warning=&c[警告] 删除这个物品, 它没有关联的书! -text.book.creative=创造模式书本 -text.book=书: %s -text.category=类别: %s -text.entry=条目: %s -text.page=页码: %s diff --git a/src/main/resources/assets/guideapi/lang/zh_cn.json b/src/main/resources/assets/guideapi/lang/zh_cn.json new file mode 100644 index 00000000..b53e2544 --- /dev/null +++ b/src/main/resources/assets/guideapi/lang/zh_cn.json @@ -0,0 +1,21 @@ +{ + "_comment": "Item", + "item.guideapi.book": "Guide-API 默认书", + + "_comment": "Button hovering text", + "guideapi.button.back": "返回", + "guideapi.button.next": "下一页", + "guideapi.button.prev": "上一页", + + "_comment": "Text to draw", + "guideapi.text.crafting.shaped": "普通配方", + "guideapi.text.crafting.shapeless": "无形配方", + "guideapi.text.furnace.smelting": "冶炼", + "text.furnace.error": "&c合成配方出错", + "text.book.warning": "&c[警告] 删除这个物品, 它没有关联的书!", + "text.book.creative": "创造模式书本", + "text.book": "书: %s", + "text.category": "类别: %s", + "text.entry": "条目: %s", + "text.page": "页码: %s" +} \ No newline at end of file From 1227fac7d4a6d53adb0b6e3d3804e28d2ab8a287 Mon Sep 17 00:00:00 2001 From: maxanier Date: Tue, 31 Mar 2020 18:50:54 +0200 Subject: [PATCH 15/28] Fix models. Still prints a missing model warning --- .../guideapi/RegistrarGuideAPI.java | 52 ++++++++++++------ .../amerifrance/guideapi/api/GuideAPI.java | 38 +------------ .../amerifrance/guideapi/api/IGuideBook.java | 10 ++-- .../guideapi/item/ItemGuideBook.java | 9 ++- .../amerifrance/guideapi/test/TestBook.java | 2 +- .../amerifrance/guideapi/test/TestBook2.java | 2 +- .../{itemguidebook.json => guidebook.json} | 0 .../guideapi/textures/items/book_base.png | Bin 16111 -> 7660 bytes 8 files changed, 51 insertions(+), 62 deletions(-) rename src/main/resources/assets/guideapi/models/item/{itemguidebook.json => guidebook.json} (100%) diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index 476eaab7..7f30de79 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -6,9 +6,17 @@ import amerifrance.guideapi.item.ItemGuideBook; import amerifrance.guideapi.util.APISetter; import amerifrance.guideapi.util.AnnotationHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -31,26 +39,34 @@ public static void registerItems(RegistryEvent.Register event) { APISetter.setBookForStack(book, new ItemStack(guideBook)); } } -// TODO -// @SubscribeEvent(priority = EventPriority.LOWEST) -// public static void registerRecipes(RegistryEvent.Register event) { -// for (Pair guide : AnnotationHandler.BOOK_CLASSES) { -// IRecipe recipe = guide.getRight().getRecipe(GuideAPI.getStackFromBook(guide.getLeft())); -// if (recipe != null) -// event.getRegistry().register(recipe); -// } -// -// for (Book book : GuideAPI.getBooks().values()) -// for (CategoryAbstract cat : book.getCategoryList()) -// for (EntryAbstract entry : cat.entries.values()) -// for (IPage page : entry.pageList) -// if (page instanceof PageJsonRecipe) -// ((PageJsonRecipe) page).init(); -// } + @SubscribeEvent + @OnlyIn(Dist.CLIENT) public static void registerModels(ModelRegistryEvent event) { - for (Pair guide : AnnotationHandler.BOOK_CLASSES) - guide.getRight().handleModel(GuideAPI.getStackFromBook(guide.getLeft())); + for (Pair guide : AnnotationHandler.BOOK_CLASSES){ + ResourceLocation loc=guide.getRight().getModel(); + if (loc!=null){ + ModelLoader.addSpecialModel(new ModelResourceLocation(loc,"inventory")); + } + } + } + + @SubscribeEvent + @OnlyIn(Dist.CLIENT) + public static void bakeModel(ModelBakeEvent event) { + for (Pair guide : AnnotationHandler.BOOK_CLASSES) { + ResourceLocation loc=guide.getRight().getModel(); + if (loc!=null){ + ModelResourceLocation newMrl = new ModelResourceLocation(loc,"inventory"); + Item bookItem = GuideAPI.getStackFromBook(guide.getLeft()).getItem(); + ModelResourceLocation oldMrl = new ModelResourceLocation(bookItem.getRegistryName(),"inventory"); + IBakedModel model= event.getModelRegistry().get(newMrl); + + event.getModelRegistry().put(oldMrl, model); + + } + } + } } diff --git a/src/main/java/amerifrance/guideapi/api/GuideAPI.java b/src/main/java/amerifrance/guideapi/api/GuideAPI.java index 8f6e0413..613fb3c2 100644 --- a/src/main/java/amerifrance/guideapi/api/GuideAPI.java +++ b/src/main/java/amerifrance/guideapi/api/GuideAPI.java @@ -3,7 +3,10 @@ import amerifrance.guideapi.api.impl.Book; import com.google.common.collect.*; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemModelMesher; import net.minecraft.client.renderer.model.ModelResourceLocation; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; @@ -44,41 +47,6 @@ public static void registerInfoRenderer(Book book, IInfoRenderer infoRenderer, C INFO_RENDERERS.get(book).put(blockClass, infoRenderer); } - /** - * Helper method for setting a model for your book. - *

- * Use if you wish to use a custom model. - *

- * Only call AFTER you have registered your book. - * - * @param book - Book to set model for - * @param modelLoc - Location of the model file - * @param variantName - Variant to use - */ - @OnlyIn(Dist.CLIENT) - public static void setModel(Book book, ResourceLocation modelLoc, String variantName) { - ModelResourceLocation mrl = new ModelResourceLocation(modelLoc, variantName); -// ModelLoader.setCustomModelResourceLocation( -// getStackFromBook(book).getItem(), -// 0, -// mrl -// ); TODO - } - - /** - * Helper method for setting a model for your book. - *

- * Use if you wish to use the default model with color. - *

- * Only call AFTER you have registered your book. - * - * @param book - Book to set model for - */ - @OnlyIn(Dist.CLIENT) - public static void setModel(Book book) { - setModel(book, new ResourceLocation("guideapi", "ItemGuideBook"), "inventory"); - } - public static void initialize() { // No-op. Just here to initialize fields. } diff --git a/src/main/java/amerifrance/guideapi/api/IGuideBook.java b/src/main/java/amerifrance/guideapi/api/IGuideBook.java index 4e962239..af81a475 100644 --- a/src/main/java/amerifrance/guideapi/api/IGuideBook.java +++ b/src/main/java/amerifrance/guideapi/api/IGuideBook.java @@ -3,6 +3,7 @@ import amerifrance.guideapi.api.impl.Book; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; @@ -20,13 +21,12 @@ public interface IGuideBook { Book buildBook(); /** - * Use this to handle setting the model of your book. Only exists on the client. - * - * @param bookStack - The ItemStack assigned to your book. + * @return The resource location of your own model or null if you want handle rendering yourself somehow */ + @Nullable @OnlyIn(Dist.CLIENT) - default void handleModel(@Nonnull ItemStack bookStack) { - GuideAPI.setModel(((IGuideItem) bookStack.getItem()).getBook(bookStack)); + default ResourceLocation getModel(){ + return new ResourceLocation("guideapi","guidebook"); } /** diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 46e91abb..1267e658 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -24,6 +24,7 @@ import net.minecraftforge.common.MinecraftForge; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; public class ItemGuideBook extends Item implements IGuideItem { @@ -36,11 +37,15 @@ public class ItemGuideBook extends Item implements IGuideItem { public ItemGuideBook(Book book) { super(new Item.Properties().maxStackSize(1).group(book.getCreativeTab())); this.book = book; - - setTranslation_key(GuideMod.ID + ".book." + book.getRegistryName().getNamespace() + "." + book.getRegistryName().getPath()); } + @Nullable + @Override + public String getCreatorModId(ItemStack itemStack) { + return book.getRegistryName().getNamespace(); + } + @Override protected String getDefaultTranslationKey() { if (this.translation_key == null) { diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index eb5f0283..42d5997f 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -44,7 +44,7 @@ public class TestBook implements IGuideBook { @Override public Book buildBook() { BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book")); - binder.setAuthor("TehNut").setColor(Color.GRAY).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); + binder.setAuthor("TehNut").setColor(Color.PINK).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); return (book = binder.build()); } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 007aa8c1..1360bb86 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -35,7 +35,7 @@ public class TestBook2 implements IGuideBook { @Override public Book buildBook() { BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book2")); - binder.setAuthor("TehNut").setColor(Color.GRAY).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); + binder.setAuthor("TehNut").setColor(new Color(80,50,5)).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); diff --git a/src/main/resources/assets/guideapi/models/item/itemguidebook.json b/src/main/resources/assets/guideapi/models/item/guidebook.json similarity index 100% rename from src/main/resources/assets/guideapi/models/item/itemguidebook.json rename to src/main/resources/assets/guideapi/models/item/guidebook.json diff --git a/src/main/resources/assets/guideapi/textures/items/book_base.png b/src/main/resources/assets/guideapi/textures/items/book_base.png index d66560bc717a3e99937541af6aaef7dad99703e2..2e6710aadbf5472e3db144bbe1b2931efae2ceac 100644 GIT binary patch literal 7660 zcmeHLdpuP6`=4|n%aSeWYMLlrX6DSzT-JSD5`$%miOQLC&M?fanZeMVe3L|_+bUbw zh(b%2FZE3qMJTqUw5d%O-6+ycw%?fzA}XN( zgHg5Q`v?BoW@YduWL)ux%__qBd(7fE-k)QwPyYM)gc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}dB;nC znVnrd5!%);litO(bU*d%*$;2}L(PGA`tMq?cxSNYVe?DV`eV1Bkoh<6_uk?kos?eb z{D#}(xx+usESkDH@W2COd-klXk*+*5^VX$Hm)M#mJ71_fckUd!`b*22Pp#bWZ2Rlb zbYkKmZ$rbudoAMQXTIyZeED+io;N=lS=0U09ZQ;A7vuxi`k_@?>pQgd-Po_XEPMX= z%Ox+rT{Si~_G0JDwYxXPPaL~?ZTsD~KlsRgVeb=vcTXNYy6}b5b9pSJEzr|q->vVF_9$Bj?Y{mpH@ KUu?MVNB;quL&&fI From 9cfa7fa62199ddb029fc70225d954b2030b308f8 Mon Sep 17 00:00:00 2001 From: maxanier Date: Tue, 31 Mar 2020 22:03:33 +0200 Subject: [PATCH 16/28] Remove unicode flag. I am not sure what this was required for, but both unicode and non unicode seems to be working fine in 1.14 --- gradle.properties | 4 ++-- .../java/amerifrance/guideapi/api/impl/Entry.java | 9 +-------- .../api/impl/abstraction/EntryAbstract.java | 15 +++------------ .../guideapi/entry/EntryItemStack.java | 12 ++---------- .../guideapi/entry/EntryResourceLocation.java | 13 ++----------- .../java/amerifrance/guideapi/test/TestBook2.java | 2 ++ 6 files changed, 12 insertions(+), 43 deletions(-) diff --git a/gradle.properties b/gradle.properties index cd2ce77f..78c79a4e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,8 +9,8 @@ forge_version=28.2.0 mcp_mappings=58-1.14.4 mcp_channel=stable -mod_version=2.1.8 -api_version=2.0.0 +mod_version=2.2.0 +api_version=2.2.0 curse_id=228832 jei_version=6.0.0.13 diff --git a/src/main/java/amerifrance/guideapi/api/impl/Entry.java b/src/main/java/amerifrance/guideapi/api/impl/Entry.java index df96c081..7f636a96 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Entry.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Entry.java @@ -21,16 +21,9 @@ public class Entry extends EntryAbstract { - public Entry(List pageList, String name, boolean unicode) { - super(pageList, name, unicode); - } public Entry(List pageList, String name) { - super(pageList, name, false); - } - - public Entry(String name, boolean unicode) { - super(name, unicode); + super(pageList, name); } public Entry(String name) { diff --git a/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java b/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java index a12cc752..1ccc490a 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java +++ b/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java @@ -18,26 +18,17 @@ public abstract class EntryAbstract { public final List pageList; public final String name; - public boolean unicode; - public EntryAbstract(List pageList, String name, boolean unicode) { + public EntryAbstract(List pageList, String name) { this.pageList = pageList; this.name = name; - this.unicode = unicode; - } - - public EntryAbstract(List pageList, String name) { - this(pageList, name, false); - } - - public EntryAbstract(String name, boolean unicode) { - this(Lists.newArrayList(), name, unicode); } public EntryAbstract(String name) { - this(name, false); + this(Lists.newArrayList(), name); } + public void addPage(IPage page) { this.pageList.add(page); } diff --git a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java index 73869273..448e610d 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryItemStack.java @@ -17,20 +17,12 @@ public class EntryItemStack extends Entry { public ItemStack stack; - public EntryItemStack(List pageList, String name, ItemStack stack, boolean unicode) { - super(pageList, name, unicode); - this.stack = stack; - } - public EntryItemStack(List pageList, String name, ItemStack stack) { - this(pageList, name, stack, false); - } - - public EntryItemStack(String name, boolean unicode, ItemStack stack) { - super(name, unicode); + super(pageList, name); this.stack = stack; } + public EntryItemStack(String name, ItemStack stack) { super(name); this.stack = stack; diff --git a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java index d14f45e0..677a8852 100644 --- a/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/entry/EntryResourceLocation.java @@ -18,18 +18,9 @@ public class EntryResourceLocation extends Entry { public ResourceLocation image; - public EntryResourceLocation(List pageList, String name, ResourceLocation resourceLocation, boolean unicode) { - super(pageList, name, unicode); - this.image = resourceLocation; - } - public EntryResourceLocation(List pageList, String name, ResourceLocation resourceLocation) { - this(pageList, name, resourceLocation, false); - } - - public EntryResourceLocation(String name, boolean unicode, ResourceLocation image) { - super(name, unicode); - this.image = image; + super(pageList, name); + this.image = resourceLocation; } public EntryResourceLocation(String name, ResourceLocation image) { diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 1360bb86..5571e45f 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -53,6 +53,8 @@ private void buildContent(List categories) { testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("redstone"))); testCategory.getEntry("entry").addPageList(PageHelper.pagesForLongText("guideapi.test.format")); + testCategory.addEntry("unicode",new EntryItemStack("Творческая книга",new ItemStack(Items.BEEF))); + testCategory.getEntry("unicode").addPage(new PageText("Творческая книга \u0F06")); categories.add(testCategory); } } From aeb6f232261f3d9584ab5f3c23b139d681dd2551 Mon Sep 17 00:00:00 2001 From: maxanier Date: Fri, 3 Apr 2020 12:30:42 +0200 Subject: [PATCH 17/28] Cleanup and fixes --- src/main/java/amerifrance/guideapi/api/impl/Entry.java | 3 +-- src/main/java/amerifrance/guideapi/api/impl/Page.java | 6 ------ .../java/amerifrance/guideapi/api/util/PageHelper.java | 10 +--------- .../java/amerifrance/guideapi/api/util/TextHelper.java | 3 ++- .../guideapi/category/CategoryItemStack.java | 2 +- .../guideapi/category/CategoryResourceLocation.java | 2 +- src/main/java/amerifrance/guideapi/gui/HomeScreen.java | 5 +++-- .../java/amerifrance/guideapi/page/PageIRecipe.java | 6 ++++-- .../java/amerifrance/guideapi/page/PageJsonRecipe.java | 3 +++ src/main/java/amerifrance/guideapi/page/PageText.java | 3 ++- .../java/amerifrance/guideapi/page/PageTextImage.java | 1 - src/main/resources/assets/guideapi/lang/en_us.json | 2 +- 12 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/api/impl/Entry.java b/src/main/java/amerifrance/guideapi/api/impl/Entry.java index 7f636a96..e225450b 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Entry.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Entry.java @@ -66,8 +66,7 @@ public void drawExtras(Book book, CategoryAbstract category, int entryX, int ent cutString = true; if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, entryWidth, entryHeight) && cutString) { - - GuiUtils.drawHoveringText(Collections.singletonList(getLocalizedName()), entryX, entryY + 12,entryWidth,entryHeight,-1,fontRendererObj); + guiBase.renderTooltip(getLocalizedName(),entryX,entryY+12); } diff --git a/src/main/java/amerifrance/guideapi/api/impl/Page.java b/src/main/java/amerifrance/guideapi/api/impl/Page.java index 20a601d9..9632dcd9 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Page.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Page.java @@ -13,8 +13,6 @@ public class Page implements IPage { - protected boolean unicode; - @Override @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { @@ -45,10 +43,6 @@ public void onRightClicked(Book book, CategoryAbstract category, EntryAbstract e public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { } - public void setUnicodeFlag(boolean flag) { - this.unicode = flag; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java index 127f6025..0d6d89ba 100644 --- a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java @@ -18,15 +18,7 @@ import java.util.List; public class PageHelper { - - public static List setPagesToUnicode(List pages) { - for (IPage page : pages) - if (page instanceof Page) - ((Page) page).setUnicodeFlag(true); - - return pages; - } - + public static List pagesForLongText(String locText, int maxLength) { List pageList = new ArrayList(); for (String s : WordUtils.wrap(locText, maxLength, "/cut", false).split("/cut")) pageList.add(new PageText(s)); diff --git a/src/main/java/amerifrance/guideapi/api/util/TextHelper.java b/src/main/java/amerifrance/guideapi/api/util/TextHelper.java index d50bdd5e..f135691b 100644 --- a/src/main/java/amerifrance/guideapi/api/util/TextHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/TextHelper.java @@ -1,6 +1,7 @@ package amerifrance.guideapi.api.util; import net.minecraft.client.resources.I18n; +import net.minecraftforge.fml.ForgeI18n; import org.apache.commons.lang3.text.WordUtils; import java.util.ArrayList; @@ -13,7 +14,7 @@ public static String getFormattedText(String string) { } public static String localize(String input, Object... format) { - return I18n.format(input, format); + return ForgeI18n.parseMessage(input, format); } public static String localizeEffect(String input, Object... format) { diff --git a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java index 46219d7f..64973a89 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java @@ -39,7 +39,7 @@ public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - GuiUtils.drawHoveringText(this.getTooltip(), mouseX, mouseY, categoryWidth,categoryHeight,-1,Minecraft.getInstance().fontRenderer); + guiBase.renderTooltip(this.getTooltip(),mouseX,mouseY); } @Override diff --git a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java index 6cac89f8..0e5dda90 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java @@ -39,7 +39,7 @@ public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - GuiUtils.drawHoveringText(this.getTooltip(), mouseX, mouseY, categoryWidth,categoryHeight,-1,Minecraft.getInstance().fontRenderer); + guiBase.renderTooltip(this.getTooltip(),mouseX,mouseY); } @Override diff --git a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java index 2330e6ab..7b309e3b 100644 --- a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java @@ -2,6 +2,7 @@ import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.button.ButtonNext; import amerifrance.guideapi.button.ButtonPrev; import amerifrance.guideapi.button.ButtonSearch; @@ -114,7 +115,7 @@ public void render(int mouseX, int mouseY, float renderPartialTicks) { blit(guiLeft, guiTop, 0, 0, xSize, ySize); minecraft.getTextureManager().bindTexture(outlineTexture); drawTexturedModalRectWithColor(guiLeft, guiTop, 0, 0, xSize, ySize, book.getColor()); - drawCenteredString(font, I18n.format(book.getHeader()).replace("\\n", "\n").replace("&", "\u00a7"), guiLeft + xSize / 2 + 1, guiTop + 15, 0); + drawCenteredString(font, TextHelper.localize(book.getHeader()).replace("\\n", "\n").replace("&", "\u00a7"), guiLeft + xSize / 2 + 1, guiTop + 15, 0); categoryPage = MathHelper.clamp(categoryPage, 0, categoryWrapperMap.size() - 1); @@ -127,7 +128,7 @@ public void render(int mouseX, int mouseY, float renderPartialTicks) { wrapper.drawExtras(mouseX, mouseY, this); drawCenteredString(font, String.format("%d/%d", categoryPage + 1, categoryWrapperMap.asMap().size()), guiLeft + xSize / 2, guiTop + 5 * ySize / 6, 0); - drawCenteredStringWithShadow(font, I18n.format(book.getTitle()), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); + drawCenteredStringWithShadow(font, TextHelper.localize(book.getTitle()), guiLeft + xSize / 2, guiTop - 10, Color.WHITE.getRGB()); buttonPrev.visible = categoryPage != 0; buttonNext.visible = categoryPage != categoryWrapperMap.asMap().size() - 1 && !categoryWrapperMap.asMap().isEmpty(); diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 07fbe584..321b009c 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -22,6 +22,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; + public class PageIRecipe extends Page { @@ -79,7 +81,8 @@ public boolean canSee(Book book, CategoryAbstract category, EntryAbstract entry, } - protected static IRecipeRenderer getRenderer(IRecipe recipe) { + @Nullable + public static IRecipeRenderer getRenderer(IRecipe recipe) { if (recipe == null) { LogHelper.error("Cannot get renderer for null recipe."); return null; @@ -91,7 +94,6 @@ protected static IRecipeRenderer getRenderer(IRecipe recipe) { return new FurnaceRecipeRenderer((FurnaceRecipe)recipe); } else { - LogHelper.error("Cannot get renderer for recipe type "+recipe.getClass().toString()); return null; } } diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index 0851294d..cc126ba2 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -47,6 +47,9 @@ public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, Pl else{ if(iRecipeRenderer==null){ iRecipeRenderer = recipeRendererSupplier.apply(recipe); + if(iRecipeRenderer==null){ + LogHelper.error("Did not get renderer for recipe type "+recipe.getClass().toString()+" for recipe "+recipeId.toString()); + } } } } diff --git a/src/main/java/amerifrance/guideapi/page/PageText.java b/src/main/java/amerifrance/guideapi/page/PageText.java index 4b369864..d9e968de 100644 --- a/src/main/java/amerifrance/guideapi/page/PageText.java +++ b/src/main/java/amerifrance/guideapi/page/PageText.java @@ -10,6 +10,7 @@ import net.minecraft.client.resources.I18n; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.ForgeI18n; public class PageText extends Page { @@ -35,7 +36,7 @@ public PageText(String draw) { public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - PageHelper.drawFormattedText(guiLeft + 39, guiTop + 12 + yOffset, guiBase, I18n.format(draw)); + PageHelper.drawFormattedText(guiLeft + 39, guiTop + 12 + yOffset, guiBase, ForgeI18n.getPattern(draw)); } diff --git a/src/main/java/amerifrance/guideapi/page/PageTextImage.java b/src/main/java/amerifrance/guideapi/page/PageTextImage.java index 7ae3ae33..a53722f4 100644 --- a/src/main/java/amerifrance/guideapi/page/PageTextImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageTextImage.java @@ -35,7 +35,6 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int Minecraft.getInstance().getTextureManager().bindTexture(image); GuiHelper.drawSizedIconWithoutColor(guiLeft + 50, guiTop + (drawAtTop ? 60 : 12), guiBase.xSize, guiBase.ySize, 0); - pageText.setUnicodeFlag(unicode); pageText.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); } diff --git a/src/main/resources/assets/guideapi/lang/en_us.json b/src/main/resources/assets/guideapi/lang/en_us.json index de652506..4ca35aff 100644 --- a/src/main/resources/assets/guideapi/lang/en_us.json +++ b/src/main/resources/assets/guideapi/lang/en_us.json @@ -19,7 +19,7 @@ "_comment": "Test", "guideapi.test.format": "This i\\ns a formatting\\n\\ttest", "guideapi.test.category": "Test Category", - "guideapi.test.entry": "Test Entry", + "guideapi.test.entry": "Test Entry which is very very very long", "_comment": "Unused", "text.furnace.error": "&cError in the recipe", From b756bb11def037b8df4ff651bf0a700fe9b54b28 Mon Sep 17 00:00:00 2001 From: maxanier Date: Fri, 3 Apr 2020 12:55:46 +0200 Subject: [PATCH 18/28] Open stored screen. Only initialize content client side --- src/main/java/amerifrance/guideapi/GuideMod.java | 3 ++- src/main/java/amerifrance/guideapi/proxy/ClientProxy.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 2793e097..70638007 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -7,6 +7,7 @@ import amerifrance.guideapi.network.PacketHandler; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @@ -49,7 +50,7 @@ private void loadComplete(final FMLLoadCompleteEvent event){ } private void interModMsg(final InterModProcessEvent event){ - GuideAPI.getBooks().values().parallelStream().forEach(Book::initializeContent); + DistExecutor.runWhenOn(Dist.CLIENT,()-> () -> GuideAPI.getBooks().values().parallelStream().forEach(Book::initializeContent)); } diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index 0d42353e..6c5ac148 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -64,17 +64,20 @@ public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack EntryScreen guiEntry = new EntryScreen(book, category, entry, player, bookStack); guiEntry.pageNumber = pageNumber; Minecraft.getInstance().displayGuiScreen( guiEntry); + return; } else if (tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); int entryPage = tagCompound.getInt(NBTBookTags.ENTRY_PAGE_TAG); CategoryScreen guiCategory = new CategoryScreen(book, category, player, bookStack, null); guiCategory.entryPage = entryPage; Minecraft.getInstance().displayGuiScreen( guiCategory); + return; } else { int categoryNumber = tagCompound.getInt(NBTBookTags.CATEGORY_PAGE_TAG); HomeScreen guiHome = new HomeScreen(book, player, bookStack); guiHome.categoryPage = categoryNumber; Minecraft.getInstance().displayGuiScreen( guiHome); + return; } } } catch (Exception e) { From 092376788518750600b11a030856dc6b344190e4 Mon Sep 17 00:00:00 2001 From: maxanier Date: Fri, 3 Apr 2020 13:21:29 +0200 Subject: [PATCH 19/28] Delay book content initialization until the book is first used. --- src/main/java/amerifrance/guideapi/GuideMod.java | 8 -------- src/main/java/amerifrance/guideapi/api/BookEvent.java | 2 +- src/main/java/amerifrance/guideapi/api/impl/Book.java | 8 +++++++- .../java/amerifrance/guideapi/api/impl/BookBinder.java | 2 +- .../java/amerifrance/guideapi/item/ItemGuideBook.java | 5 +++++ src/main/java/amerifrance/guideapi/proxy/ClientProxy.java | 1 + 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 70638007..7298ec54 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -35,7 +35,6 @@ public GuideMod(){ GuideAPI.initialize(); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::interModMsg); } private void setup(final FMLCommonSetupEvent event){ @@ -49,13 +48,6 @@ private void loadComplete(final FMLLoadCompleteEvent event){ guide.getRight().handlePost(GuideAPI.getStackFromBook(guide.getLeft())); } - private void interModMsg(final InterModProcessEvent event){ - DistExecutor.runWhenOn(Dist.CLIENT,()-> () -> GuideAPI.getBooks().values().parallelStream().forEach(Book::initializeContent)); - } - - - - private void checkDevEnv() { String launchTarget = System.getenv().get("target"); if (launchTarget != null && launchTarget.contains("dev")) { diff --git a/src/main/java/amerifrance/guideapi/api/BookEvent.java b/src/main/java/amerifrance/guideapi/api/BookEvent.java index a92ad2ff..6cdc7ec4 100644 --- a/src/main/java/amerifrance/guideapi/api/BookEvent.java +++ b/src/main/java/amerifrance/guideapi/api/BookEvent.java @@ -44,7 +44,7 @@ public PlayerEntity getPlayer() { } /** - * Called whenever a book is opened. + * Called client side whenever a book is opened. * * {@link #canceledText} is a status message sent to the player when the book fails to open. */ diff --git a/src/main/java/amerifrance/guideapi/api/impl/Book.java b/src/main/java/amerifrance/guideapi/api/impl/Book.java index 0011c3ae..e1578ff9 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Book.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Book.java @@ -1,6 +1,7 @@ package amerifrance.guideapi.api.impl; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; +import amerifrance.guideapi.util.LogHelper; import com.google.common.base.Joiner; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; @@ -28,6 +29,7 @@ public class Book { private final boolean spawnWithBook; private final ResourceLocation registryName; private final ItemGroup creativeTab; + private boolean isInitialized; protected Book(Consumer> contentProvider, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, boolean customModel, Color color, boolean spawnWithBook, ResourceLocation registryName, ItemGroup creativeTab) { @@ -46,7 +48,11 @@ protected Book(Consumer> contentProvider, String title, S } public void initializeContent(){ - contentProvider.accept(categories); + if(!isInitialized){ + LogHelper.debug("Opening book "+registryName.toString()+" for the first time -> Initializing content"); + contentProvider.accept(categories); + isInitialized=true; + } } public List getCategoryList() { diff --git a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java index 15808f35..cad5fde6 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java +++ b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java @@ -40,7 +40,7 @@ public BookBinder(ResourceLocation registryName) { /** * Set a consumer (method) that will generate the content for your book and add it to the provided list - * It will be called during GuideAPI's {@link InterModProcessEvent} (so it might execute in parallel with your mod) + * This will be called on client side when the book is opened for the first time. * * @param contentProvider The consumer. Categories are displayed in which they are added to the provided list * @return the builder instance for chaining. diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 1267e658..60a5e80e 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -64,8 +64,13 @@ protected void setTranslation_key(String name) { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + ItemStack heldStack = player.getHeldItem(hand); + //Only handle book client side + if(!world.isRemote())return ActionResult.newResult(ActionResultType.SUCCESS,heldStack); + + BookEvent.Open event = new BookEvent.Open(book, heldStack, player); if (MinecraftForge.EVENT_BUS.post(event)) { player.sendStatusMessage(event.getCanceledText(), true); diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index 6c5ac148..0c5f7a22 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -54,6 +54,7 @@ public void initColors() { @Override public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack bookStack) { if (!bookStack.isEmpty() && bookStack.getItem() instanceof IGuideItem) { + book.initializeContent(); try { if (bookStack.hasTag()) { CompoundNBT tagCompound = bookStack.getTag(); From c8575f1d6d3c0c4c4dddbf68347c2f42cd9cc421 Mon Sep 17 00:00:00 2001 From: maxanier Date: Fri, 3 Apr 2020 19:36:26 +0200 Subject: [PATCH 20/28] Add a debug way to reload a book without having to restart the game --- .../java/amerifrance/guideapi/GuideMod.java | 14 ++++++ .../amerifrance/guideapi/api/impl/Book.java | 11 +++++ .../guideapi/util/ReloadCommand.java | 48 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 src/main/java/amerifrance/guideapi/util/ReloadCommand.java diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 7298ec54..ece39fa0 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -7,12 +7,18 @@ import amerifrance.guideapi.network.PacketHandler; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; +import amerifrance.guideapi.util.ReloadCommand; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; +import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; @@ -35,6 +41,8 @@ public GuideMod(){ GuideAPI.initialize(); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete); + MinecraftForge.EVENT_BUS.addListener(this::onServerStarting); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onServerStarting); } private void setup(final FMLCommonSetupEvent event){ @@ -54,4 +62,10 @@ private void checkDevEnv() { inDev = true; } } + + private void onServerStarting(FMLServerStartingEvent event){ + if(inDev){ + event.getCommandDispatcher().register(LiteralArgumentBuilder.literal("guide-api").then(ReloadCommand.register())); + } + } } diff --git a/src/main/java/amerifrance/guideapi/api/impl/Book.java b/src/main/java/amerifrance/guideapi/api/impl/Book.java index e1578ff9..91f5c0ae 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Book.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Book.java @@ -55,6 +55,17 @@ public void initializeContent(){ } } + /** + * Can be used to force content initialisation independent of first use regardless of if it was initialized previously. + * Use at own risk. Might cause crashes if the book is currently open. + */ + public void forceInitializeContent(){ + LogHelper.info("Force initializing book content "+registryName.toString()); + categories.clear(); + isInitialized=false; + initializeContent(); + } + public List getCategoryList() { return this.categories; } diff --git a/src/main/java/amerifrance/guideapi/util/ReloadCommand.java b/src/main/java/amerifrance/guideapi/util/ReloadCommand.java new file mode 100644 index 00000000..a37d28b8 --- /dev/null +++ b/src/main/java/amerifrance/guideapi/util/ReloadCommand.java @@ -0,0 +1,48 @@ +package amerifrance.guideapi.util; + +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.impl.Book; +import com.mojang.brigadier.LiteralMessage; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; +import net.minecraft.command.ISuggestionProvider; +import net.minecraft.command.arguments.ResourceLocationArgument; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.common.thread.EffectiveSide; +import net.minecraftforge.fml.loading.FMLEnvironment; + +/** + * Command to be able to reload the book content ingame for debugging purposes. + * Only registered in dev environment and only works in single player + */ +public class ReloadCommand { + + private static final DynamicCommandExceptionType BOOK_NOT_FOUND = new DynamicCommandExceptionType((id) -> new StringTextComponent("Book with registry id "+ id+ " not found")); + private static final SimpleCommandExceptionType NOT_CLIENT = new SimpleCommandExceptionType(new LiteralMessage("This command can only be used in singleplayer")); + + public static ArgumentBuilder register() { + return Commands.literal("reload") + .then(Commands.argument("bookid", ResourceLocationArgument.resourceLocation()).executes((context) -> { + if(FMLEnvironment.dist != Dist.CLIENT){ + throw NOT_CLIENT.create(); + } + ResourceLocation id = ResourceLocationArgument.getResourceLocation(context,"bookid"); + Book b = GuideAPI.getBooks().get(id); + if(b == null){ + throw BOOK_NOT_FOUND.create(id.toString()); + } + b.forceInitializeContent(); + return 0; + })); + + } +} From 325afb71034ed44be5f89d124c7f7833b35aa08e Mon Sep 17 00:00:00 2001 From: maxanier Date: Wed, 8 Apr 2020 01:06:29 +0200 Subject: [PATCH 21/28] Increase book width. Provide proper line and page wrapping. Extend test book --- .../amerifrance/guideapi/api/impl/Book.java | 2 - .../guideapi/api/util/PageHelper.java | 74 ++++++++++++++---- .../amerifrance/guideapi/gui/BaseScreen.java | 2 +- .../guideapi/page/PageBrewingRecipe.java | 2 +- .../amerifrance/guideapi/page/PageImage.java | 2 +- .../guideapi/page/PageItemStack.java | 2 +- .../amerifrance/guideapi/page/PageText.java | 5 +- .../guideapi/page/PageTextImage.java | 2 +- .../CraftingRecipeRenderer.java | 6 +- .../reciperenderer/FurnaceRecipeRenderer.java | 6 +- .../reciperenderer/ShapedRecipesRenderer.java | 2 +- .../ShapelessRecipesRenderer.java | 2 +- .../amerifrance/guideapi/test/TestBook.java | 19 +++-- .../resources/assets/guideapi/lang/en_us.json | 1 + .../guideapi/textures/gui/book_colored.png | Bin 25477 -> 28515 bytes .../guideapi/textures/gui/book_greyscale.png | Bin 24461 -> 20396 bytes 16 files changed, 87 insertions(+), 40 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/api/impl/Book.java b/src/main/java/amerifrance/guideapi/api/impl/Book.java index 91f5c0ae..56765004 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Book.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Book.java @@ -14,8 +14,6 @@ public class Book { - private static final String GUITEXLOC = "guideapi:textures/gui/"; - private final List categories = new ArrayList<>(); private final Consumer> contentProvider; private final String title; diff --git a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java index 0d6d89ba..7a596136 100644 --- a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java @@ -11,7 +11,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.Ingredient; import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import java.util.ArrayList; @@ -19,36 +21,67 @@ public class PageHelper { - public static List pagesForLongText(String locText, int maxLength) { - List pageList = new ArrayList(); - for (String s : WordUtils.wrap(locText, maxLength, "/cut", false).split("/cut")) pageList.add(new PageText(s)); - return pageList; - } + /** - * @param locText - Text - * @return a list of IPages with the text cut to fit on page + * Split the given text into multiple section if it does not fit one page. + * The first page can have a different number of lines than the subsequent ones if desired + * Insert new line characters to wrap the text to the available line width. + * @param locText Text to process + * @param lineWidth Available width (pixel) + * @param firstHeight Available height on the first page (pixel) + * @param subsequentHeight Available height on subsequent pages (pixel) + * @return Each list element should be drawn on a individual page. Lines are wrapped using '\n' */ - public static List pagesForLongText(String locText) { - return pagesForLongText(locText, 450); + public static List prepareForLongText(String locText, int lineWidth, int firstHeight, int subsequentHeight){ + FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; + int firstCount = firstHeight/fontRenderer.FONT_HEIGHT; + int count = subsequentHeight/fontRenderer.FONT_HEIGHT; + List lines = new ArrayList<>(fontRenderer.listFormattedStringToWidth(locText,lineWidth)); //Create a new list from returned list so we can later remove items + List pages = new ArrayList<>(); + + List pageLines = lines.size()>firstCount ? lines.subList(0,firstCount):lines; + pages.add(StringUtils.join( pageLines, "\n")); + pageLines.clear(); + while(lines.size()>0){ + pageLines = lines.size()>count ? lines.subList(0,count):lines; + pages.add(StringUtils.join(pageLines,"\n")); + pageLines.clear(); + } + return pages; } - public static List pagesForLongText(String locText, ItemStack stack) { - List pageList = new ArrayList(); - String[] strings = WordUtils.wrap(locText, 450, "/cut", false).split("/cut"); - for (int i = 0; i < strings.length; i++) { - if (i == 0) pageList.add(new PageItemStack(strings[i], stack)); - else pageList.add(new PageText(strings[i])); + /** + * Spread the text over multiple pages if necessary. Display ingredient at first page + */ + public static List pagesForLongText(String locText, Ingredient ingredient){ + List pageText = prepareForLongText(locText,164,79,120); + List pageList = new ArrayList<>(); + for(int i=0;i pagesForLongText(String locText){ + List pageList = new ArrayList<>(); + prepareForLongText(locText,164,120,120).forEach(t->pageList.add(new PageText(t))); + return pageList; + } + + public static void drawFormattedText(int x, int y, BaseScreen guiBase, String toDraw) { FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; toDraw = StringEscapeUtils.unescapeJava(toDraw).replaceAll("\\t", " "); String[] lines = toDraw.split("\n"); for (String line : lines) { - List cutLines = fontRenderer.listFormattedStringToWidth(line, 3 * guiBase.xSize / 5); + List cutLines = fontRenderer.listFormattedStringToWidth(line, 2 * guiBase.xSize / 3); for (String cut : cutLines) { fontRenderer.drawString(cut, x, y, 0); y += 10; @@ -74,6 +107,15 @@ public static List pagesForLongText(String locText, Block block) { return pagesForLongText(locText, new ItemStack(block)); } + /** + * @param locText - Text + * @param item - The stack to put on the first page + * @return a list of IPages with the text cut to fit on page + */ + public static List pagesForLongText(String locText, ItemStack item) { + return pagesForLongText(locText, Ingredient.fromStacks(item)); + } + /** * @param recipe1 - The first IRecipe to compare * @param recipe2 - The second IRecipe to compare diff --git a/src/main/java/amerifrance/guideapi/gui/BaseScreen.java b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java index 8783404e..e8c13701 100644 --- a/src/main/java/amerifrance/guideapi/gui/BaseScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java @@ -22,7 +22,7 @@ public class BaseScreen extends Screen { public int guiLeft, guiTop; - public int xSize = 192; + public int xSize = 245; public int ySize = 192; public PlayerEntity player; public ItemStack bookStack; diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index 2b8ab1ae..d9e4d4b4 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -64,7 +64,7 @@ public PageBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack outp public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { cycler.tick(guiBase.getMinecraft()); - int xStart = guiLeft + 62; + int xStart = guiLeft + 88; int yStart = guiTop + 52; SubTexture.POTION_GRID.draw(xStart, yStart); diff --git a/src/main/java/amerifrance/guideapi/page/PageImage.java b/src/main/java/amerifrance/guideapi/page/PageImage.java index dc3cce5d..28305821 100644 --- a/src/main/java/amerifrance/guideapi/page/PageImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageImage.java @@ -27,7 +27,7 @@ public PageImage(ResourceLocation image) { @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { Minecraft.getInstance().getTextureManager().bindTexture(image); - GuiHelper.drawSizedIconWithoutColor(guiLeft + 50, guiTop + 34, guiBase.xSize, guiBase.ySize, 1F); + GuiHelper.drawSizedIconWithoutColor(guiLeft + 60, guiTop + 34, guiBase.xSize, guiBase.ySize, 1F); } @Override diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index eb059165..f7af0eaa 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -54,7 +54,7 @@ public PageItemStack(String draw, Block block) { public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { ingredientCycler.tick(guiBase.getMinecraft()); ingredientCycler.getCycledIngredientStack(ingredient,0).ifPresent(stack -> { - GuiHelper.drawScaledItemStack(stack, guiLeft + 75, guiTop + 20, 3); + GuiHelper.drawScaledItemStack(stack, guiLeft + 101, guiTop + 20, 3); }); } diff --git a/src/main/java/amerifrance/guideapi/page/PageText.java b/src/main/java/amerifrance/guideapi/page/PageText.java index d9e968de..18d1ce5c 100644 --- a/src/main/java/amerifrance/guideapi/page/PageText.java +++ b/src/main/java/amerifrance/guideapi/page/PageText.java @@ -28,15 +28,14 @@ public PageText(String draw, int yOffset) { } public PageText(String draw) { - this(draw, 0); + this(draw, 5); } @Override @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - - PageHelper.drawFormattedText(guiLeft + 39, guiTop + 12 + yOffset, guiBase, ForgeI18n.getPattern(draw)); + PageHelper.drawFormattedText(guiLeft + 44, guiTop + 12 + yOffset, guiBase, ForgeI18n.getPattern(draw)); } diff --git a/src/main/java/amerifrance/guideapi/page/PageTextImage.java b/src/main/java/amerifrance/guideapi/page/PageTextImage.java index a53722f4..ad2083aa 100644 --- a/src/main/java/amerifrance/guideapi/page/PageTextImage.java +++ b/src/main/java/amerifrance/guideapi/page/PageTextImage.java @@ -33,7 +33,7 @@ public PageTextImage(String draw, ResourceLocation image, boolean drawAtTop) { @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { Minecraft.getInstance().getTextureManager().bindTexture(image); - GuiHelper.drawSizedIconWithoutColor(guiLeft + 50, guiTop + (drawAtTop ? 60 : 12), guiBase.xSize, guiBase.ySize, 0); + GuiHelper.drawSizedIconWithoutColor(guiLeft + 60, guiTop + (drawAtTop ? 60 : 12), guiBase.xSize, guiBase.ySize, 0); pageText.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); } diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java index 4bb34fc9..915e8598 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java @@ -31,13 +31,13 @@ public CraftingRecipeRenderer(T recipe) { @Override public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { - SubTexture.CRAFTING_GRID.draw(guiLeft + 42, guiTop + 53); + SubTexture.CRAFTING_GRID.draw(guiLeft + 68, guiTop + 53); String recipeName = Strings.isNullOrEmpty(customDisplay) ? getRecipeName() : customDisplay; guiBase.drawCenteredString(fontRendererObj, recipeName, guiLeft + guiBase.xSize / 2, guiTop + 12, 0); - int outputX = (5 * 18) + (guiLeft + guiBase.xSize / 7) + 5; - int outputY = (2 * 18) + (guiTop + guiBase.xSize / 5); + int outputX = guiLeft + 148; + int outputY = guiTop + 73; ItemStack stack = recipe.getRecipeOutput(); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java index 1d4d3911..6f939a6a 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java @@ -26,11 +26,11 @@ public FurnaceRecipeRenderer(FurnaceRecipe recipe) { @Override public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj, IngredientCycler cycler) { - SubTexture.FURNACE_GRID.draw(guiLeft + 64, guiTop + 71); + SubTexture.FURNACE_GRID.draw(guiLeft + 90, guiTop + 71); guiBase.drawCenteredString(fontRendererObj, TextHelper.localizeEffect("guideapi.text.furnace.smelting"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0); - int x = guiLeft + 66; + int x = guiLeft + 92; int y = guiTop + 77; Ingredient input = recipe.getIngredients().get(0); @@ -46,7 +46,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int ItemStack output = recipe.getRecipeOutput(); - int x2 = guiLeft + 109; + int x2 = guiLeft + 135; GuiHelper.drawItemStack(output, x2, y); if (GuiHelper.isMouseBetween(mouseX, mouseY, x2, y, 15, 15)) tooltips = GuiHelper.getTooltip(output); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index 9591bad7..b9e9d614 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -26,7 +26,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int for (int y = 0; y < recipe.getRecipeHeight(); y++) { for (int x = 0; x < recipe.getRecipeWidth(); x++) { int i = y*recipe.getRecipeWidth()+x; - int stackX = (x + 1) * 17 + (guiLeft + 27) + x; + int stackX = (x + 1) * 17 + (guiLeft + 53) + x; int stackY = (y + 1) * 17 + (guiTop + 38) + y; Ingredient ingredient = recipe.getIngredients().get(i); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index e62a82c9..6903519a 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -27,7 +27,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { int i = 3 * y + x; - int stackX = (x + 1) * 17 + (guiLeft + 27) + x; + int stackX = (x + 1) * 17 + (guiLeft + 53) + x; int stackY = (y + 1) * 17 + (guiTop + 38) + y; if (i < recipe.getIngredients().size()) { Ingredient ingredient = recipe.getIngredients().get(i); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index 42d5997f..fab5c830 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -8,12 +8,10 @@ import amerifrance.guideapi.api.impl.Entry; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; -import amerifrance.guideapi.page.PageIRecipe; -import amerifrance.guideapi.page.PageItemStack; -import amerifrance.guideapi.page.PageJsonRecipe; -import amerifrance.guideapi.page.PageText; +import amerifrance.guideapi.page.*; import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -53,7 +51,11 @@ private void buildContent(List categories){ Map entries = Maps.newHashMap(); List pages = Lists.newArrayList(); - pages.add(new PageText("Hello, this is\nsome text")); + pages.add(new PageText("Hello, this is\nsome text with a new line.")); + pages.add(new PageText("Hello, this is some text without a new line. It is long so it should probably be automaticall wrapped")); + pages.addAll(PageHelper.pagesForLongText("Hello, this is some text. It is very long so it should be split across multiple pages. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.")); + pages.addAll(PageHelper.pagesForLongText("Hello, this is some text. It is very long so it should be split across multiple pages. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",Items.COAL_BLOCK)); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stone"))); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","charcoal"))); @@ -62,9 +64,14 @@ private void buildContent(List categories){ pages.add(new PageIRecipe(new ShapedRecipe(new ResourceLocation("guideapi","test11"), "test",1,1,NonNullList.from(Ingredient.EMPTY,Ingredient.fromStacks(new ItemStack(Items.PUMPKIN))),new ItemStack(Blocks.OAK_LOG)))); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "acacia_fence"))); pages.add(new PageItemStack("These are all logs",Ingredient.fromTag(ItemTags.LOGS))); + pages.add(new PageTextImage("guideapi.test.string",new ResourceLocation("guideapi","textures/gui/testimage.png"),true)); + pages.add(new PageTextImage("guideapi.test.string",new ResourceLocation("guideapi","textures/gui/testimage.png"),false)); + pages.add(new PageImage(new ResourceLocation("guideapi","textures/gui/testimage.png"))); + + Entry entry = new EntryItemStack(pages, "guideapi.test.entry", new ItemStack(Items.POTATO)); entries.put(new ResourceLocation("guideapi", "entry"), entry); - categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.BLUE_BANNER))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.ACACIA_DOOR))); } } diff --git a/src/main/resources/assets/guideapi/lang/en_us.json b/src/main/resources/assets/guideapi/lang/en_us.json index 4ca35aff..894e48a5 100644 --- a/src/main/resources/assets/guideapi/lang/en_us.json +++ b/src/main/resources/assets/guideapi/lang/en_us.json @@ -20,6 +20,7 @@ "guideapi.test.format": "This i\\ns a formatting\\n\\ttest", "guideapi.test.category": "Test Category", "guideapi.test.entry": "Test Entry which is very very very long", + "guideapi.test.string": "Some translated content string", "_comment": "Unused", "text.furnace.error": "&cError in the recipe", diff --git a/src/main/resources/assets/guideapi/textures/gui/book_colored.png b/src/main/resources/assets/guideapi/textures/gui/book_colored.png index 5aeee55ceaa4499dfcb9deec3003f09a344f6930..e37b9ccf7fadccbe596012397abfca188126e269 100644 GIT binary patch literal 28515 zcmeFZbyQs2vM=1YySrPk#@)4Xmjs6f8g1MO?iNC@;1C>=;0_5+u;3Ovgy00%e4Xrl z_SxsYbMJe1jQ763E`x5?npO2HnKf(HT4N4kwKSBl(8*)st(}H~=Frx2LV~(*qWoxR!&-Za=@H>_w zq+_et{x?Bf^dc3kl_PtN_W1pyL#T)=57^j51%MZUvwa)(VEAN$B`?lXBmN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5XY2hr-~kB-6T=PQnro`G^`sh{Tf&;@ zg}OZ8X95-bw=o#Fc8Iv9-gV&hTOY%kCmqX;Klocler!rPZXr}8~pOu^2cF) z4jH3UTeY;soIz|VE5ip^~w0Oa4%*?mzd!-Jn&1GF_xsu!wS G2LB(sH5pp~ diff --git a/src/main/resources/assets/guideapi/textures/gui/book_greyscale.png b/src/main/resources/assets/guideapi/textures/gui/book_greyscale.png index 768e6b31455c473f4efadd8f93431ef48e7a6fe8..50ab5cadbecb1741b0fc7673115f6215bc1d4e28 100644 GIT binary patch literal 20396 zcmeHvbyOT%)^9g7?he5k58k*04Nh=(cXxMBLeOAALvVKuo&?w61h)XegWGFz@7%eg z-8z>Z0nLy?^Iy-&IueQb|Dy4fzQ&002Ofkrr100D#a_AOH~_`b*EH$N~U( z3ieUca#Jz(1UtDnT3FkegWbHH%)#bf*3e0>`SJ{F4{E-cu!mDzf6&38b5lDHPwM)p zrCW+hiC#-d;fo~t{O+Di5HOSoF=FoFM!5HO&+x&8Tf@)~VF!Md!uQN2TkVijl*wu{?ePJ#P*>c+UJk&s<27D+V|c{xloK z*xLhNwFL$ouK9jw$R>9w-P}`(3~V30=zjM0Lh%0IaiHd)s#^0+JWnW|B_o09cyp?k~4=V!3~e$mLltYBCG4j+m{*T*$pOo z23emWbuQQGrCOMtOYSdbI>`;QMQuBn?2O>Pa=Ds^EXHi(Q#F&f;~nrLRJ`yD%~H=ZSc&Cr`350FX-#* zCTxqU3*Oll*Eh_kI|5PVm>VZ-Y|A|z`7w6CmAd+G^Yp|*)}*Oo*>|lzD1Nj2l4g-* zK0Rk)7!VF8SN3tBq_n&}a}NAD=Gp$o!HU-XfTMaG1%aInRRzKQpQGx&nrDTTfmJpK z`dopUvNK7e>g$aKZ)0_NyJRNbRhtO$YkahVbF!-Bs-61$z1~HKV?jVPULaIXhqyLF zBbp|9;mYmX_WYezb4R@c?G*HIzg(U%K5@sRF;e9wT)DuiVNX9g+-jnTJ5a!l>EHTh zztmWnUD5p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TY{spSA-w{a*;&rwubTz9F`&&vSSuP-DVNdyz3fFHzLkO+WS4)+Ot92{u! z_^K}Tb5b*}Eh!r^j5$zETsJJJ?ny6-ZAGio)vxrc7KUzpwB@{;a3o(Q+_)g>$QEU_ z;=#jdFF+_z!R{dHd&$B&*3l^Aq0Z}cEvbu&**|0=MOI|a)H7RJAy#I~_RDO4i2a-` bV;NXP7#3hFuYs@C0brNGUi}+-PLclw4qfkw From 7829beec83e4e0d6b0984a192ef98a7fe14c68b6 Mon Sep 17 00:00:00 2001 From: maxanier Date: Wed, 8 Apr 2020 23:27:34 +0200 Subject: [PATCH 22/28] Properly update config system to also handle per book configuration --- build.gradle | 1 + .../amerifrance/guideapi/GuideConfig.java | 70 +++++++------------ .../java/amerifrance/guideapi/GuideMod.java | 3 + .../guideapi/RegistrarGuideAPI.java | 2 +- .../amerifrance/guideapi/test/TestBook.java | 2 +- .../amerifrance/guideapi/test/TestBook2.java | 2 +- .../guideapi/util/EventHandler.java | 10 +-- 7 files changed, 40 insertions(+), 50 deletions(-) diff --git a/build.gradle b/build.gradle index 592630b1..2df87488 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,7 @@ dependencies { ]) compileOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}:${project.jei_version}:api") //API for compile runtimeOnly fg.deobf("mezz.jei:jei-${project.minecraft_version}:${project.jei_version}") //Full for runtime + //runtimeClasspath 'com.electronwill.night-config:hocon:3.6.2' } sourceSets { diff --git a/src/main/java/amerifrance/guideapi/GuideConfig.java b/src/main/java/amerifrance/guideapi/GuideConfig.java index 0e6c941c..7bda4277 100644 --- a/src/main/java/amerifrance/guideapi/GuideConfig.java +++ b/src/main/java/amerifrance/guideapi/GuideConfig.java @@ -1,72 +1,56 @@ package amerifrance.guideapi; +import amerifrance.guideapi.api.GuideAPI; +import amerifrance.guideapi.api.impl.Book; +import com.electronwill.nightconfig.core.CommentedConfig; +import com.google.common.collect.Maps; import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.config.ConfigFileTypeHandler; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; +import java.util.HashMap; +import java.util.Map; + public class GuideConfig { - /** - * Synced to clients. - * Only loaded on world load - */ - public static final Server SERVER; + /** * For side independent configuration. Not synced. * Loaded after registry events but before setup */ - public static final Common COMMON; - - private static final ForgeConfigSpec serverSpec; - private static final ForgeConfigSpec commonSpec; - - - static { - final Pair specPair = new ForgeConfigSpec.Builder().configure(Server::new); - serverSpec = specPair.getRight(); - SERVER = specPair.getLeft(); - } - - static { - final Pair specPair = new ForgeConfigSpec.Builder().configure(Common::new); - commonSpec = specPair.getRight(); - COMMON = specPair.getLeft(); - } - - public static void registerConfigs() { - ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, commonSpec); - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, serverSpec); - FMLJavaModLoadingContext.get().getModEventBus().register(GuideConfig.class); - } + public static Common COMMON; - public static class Server { + public static class Common { public final ForgeConfigSpec.BooleanValue canSpawnWithBook; - Server(ForgeConfigSpec.Builder builder) { - builder.comment("Server configuration settings").push("server"); - canSpawnWithBook = builder.comment("Allows books to spawn with new players.\nThis is a global override for all books.").define("canSpawnWithBook",true); - builder.pop(); - } - -// for ( Book book : GuideAPI.getBooks().values()) TODO -// SPAWN_BOOKS.put(book, config.getBoolean(book.getRegistryName().toString(), "Books.Spawn", book.shouldSpawnWithBook(), "")); -// -// config.setCategoryComment("Books.Spawn", "If true, the user will spawn with the book.\nThis defaults to the value the book owner has set and is overridden by this config."); - } - - public static class Common { - public final ForgeConfigSpec.BooleanValue enableLogging; + public final Map SPAWN_BOOKS = new HashMap<>(); Common(ForgeConfigSpec.Builder builder) { builder.comment("Common configurations settings").push("common"); enableLogging = builder.comment("Enables extra information being printed to the console.").define("enableLogging",true); + canSpawnWithBook = builder.comment("Allows books to spawn with new players.\nThis is a global override for all books if set to false.").define("canSpawnWithBook",true); + builder.comment("If the player should spawn with this book").push("spawnBook"); + for(Book book : GuideAPI.getBooks().values()){ + SPAWN_BOOKS.put(book,builder.define(book.getRegistryName().getNamespace()+"-"+book.getRegistryName().getPath(),book.shouldSpawnWithBook())); + } + builder.pop(); builder.pop(); } } + public static void buildConfiguration(){ + final Pair specPair = new ForgeConfigSpec.Builder().configure(Common::new); + ForgeConfigSpec commonSpec = specPair.getRight(); + COMMON = specPair.getLeft(); + ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, commonSpec); + FMLJavaModLoadingContext.get().getModEventBus().register(GuideConfig.class); + } + } diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index ece39fa0..3171c69e 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -46,6 +46,9 @@ public GuideMod(){ } private void setup(final FMLCommonSetupEvent event){ + if(GuideConfig.COMMON==null){ + throw new IllegalStateException("Did not build configuration, before configuration load. Make sure to call GuideConfig#buildConfiguration during one of the registry events"); + } PacketHandler.registerPackets(); } diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index 7f30de79..b70f8620 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -31,7 +31,7 @@ public class RegistrarGuideAPI { @SubscribeEvent public static void registerItems(RegistryEvent.Register event) { AnnotationHandler.gatherBooks(); - + GuideConfig.buildConfiguration();//Build configuration now that we know all added books for (Book book : GuideAPI.getBooks().values()) { Item guideBook = new ItemGuideBook(book); guideBook.setRegistryName(book.getRegistryName().toString().replace(":", "-")); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index fab5c830..bf6b0473 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -42,7 +42,7 @@ public class TestBook implements IGuideBook { @Override public Book buildBook() { BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book")); - binder.setAuthor("TehNut").setColor(Color.PINK).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); + binder.setAuthor("TehNut").setColor(Color.PINK).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setSpawnWithBook().setContentProvider(this::buildContent); return (book = binder.build()); } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 5571e45f..4d6c61ab 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -35,7 +35,7 @@ public class TestBook2 implements IGuideBook { @Override public Book buildBook() { BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book2")); - binder.setAuthor("TehNut").setColor(new Color(80,50,5)).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setContentProvider(this::buildContent); + binder.setAuthor("TehNut").setColor(new Color(80,50,5)).setItemName("Display Name").setHeader("Hello there").setSpawnWithBook().setGuideTitle("Title message").setContentProvider(this::buildContent); diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index e6362b31..03a21479 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -28,6 +28,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -43,12 +44,13 @@ public static void onPlayerJoinWorld(EntityJoinWorldEvent event) { if (!event.getEntity().world.isRemote && event.getEntity() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntity(); CompoundNBT tag = getModTag(player, GuideMod.ID); - if (GuideConfig.SERVER.canSpawnWithBook.get()) { + if (GuideConfig.COMMON.canSpawnWithBook.get()) { for (Book book : GuideAPI.getBooks().values()) { - //if (ConfigHandler.SPAWN_BOOKS.getOrDefault(book, false) && !tag.getBoolean("hasInitial" + book.getTitle())) { TODO + ForgeConfigSpec.BooleanValue bookSpawnConfig = GuideConfig.COMMON.SPAWN_BOOKS.get(book); + if((bookSpawnConfig==null||bookSpawnConfig.get()) && !tag.getBoolean("hasInitial" + book.getRegistryName().toString())){ ItemHandlerHelper.giveItemToPlayer(player, GuideAPI.getStackFromBook(book)); - tag.putBoolean("hasInitial" + book.getTitle(), true); - //} + tag.putBoolean("hasInitial" + book.getRegistryName().toString(), true); + } } } } From 7a9f6090f62a5eb33d057a09c10709cc04ceb5b2 Mon Sep 17 00:00:00 2001 From: maxanier Date: Wed, 8 Apr 2020 23:35:59 +0200 Subject: [PATCH 23/28] Format code and cleanup imports --- .../amerifrance/guideapi/GuideConfig.java | 16 +++--- .../java/amerifrance/guideapi/GuideMod.java | 21 ++++---- .../guideapi/RegistrarGuideAPI.java | 22 ++++---- .../amerifrance/guideapi/api/BookEvent.java | 6 +-- .../amerifrance/guideapi/api/GuideAPI.java | 9 +--- .../amerifrance/guideapi/api/IGuideBook.java | 6 +-- .../java/amerifrance/guideapi/api/IPage.java | 4 +- .../guideapi/api/IRecipeRenderer.java | 9 +--- .../amerifrance/guideapi/api/SubTexture.java | 8 +-- .../amerifrance/guideapi/api/impl/Book.java | 16 +++--- .../guideapi/api/impl/BookBinder.java | 31 ++++++------ .../amerifrance/guideapi/api/impl/Entry.java | 6 +-- .../amerifrance/guideapi/api/impl/Page.java | 3 +- .../impl/abstraction/CategoryAbstract.java | 10 ++-- .../api/impl/abstraction/EntryAbstract.java | 5 +- .../guideapi/api/util/IngredientCycler.java | 19 +++---- .../guideapi/api/util/PageHelper.java | 50 +++++++++---------- .../guideapi/api/util/TextHelper.java | 1 - .../guideapi/button/ButtonBack.java | 8 +-- .../guideapi/button/ButtonNext.java | 30 +++++------ .../guideapi/button/ButtonPrev.java | 8 +-- .../guideapi/button/ButtonSearch.java | 4 +- .../guideapi/category/CategoryItemStack.java | 4 +- .../category/CategoryResourceLocation.java | 3 +- .../amerifrance/guideapi/gui/BaseScreen.java | 21 ++++---- .../guideapi/gui/CategoryScreen.java | 39 +++++++-------- .../amerifrance/guideapi/gui/EntryScreen.java | 36 +++++++------ .../amerifrance/guideapi/gui/HomeScreen.java | 33 ++++++------ .../guideapi/gui/SearchScreen.java | 30 +++++------ .../info/InfoRendererDescription.java | 4 +- .../guideapi/item/ItemGuideBook.java | 6 +-- .../guideapi/network/PacketHandler.java | 9 ++-- .../guideapi/network/PacketSyncCategory.java | 15 +++--- .../guideapi/network/PacketSyncEntry.java | 20 ++++---- .../guideapi/network/PacketSyncHome.java | 12 ++--- .../guideapi/page/PageBrewingRecipe.java | 6 +-- .../guideapi/page/PageIRecipe.java | 18 +++---- .../guideapi/page/PageItemStack.java | 13 ++--- .../guideapi/page/PageJsonRecipe.java | 32 ++++++------ .../amerifrance/guideapi/page/PageText.java | 1 - .../CraftingRecipeRenderer.java | 5 -- .../reciperenderer/FurnaceRecipeRenderer.java | 4 +- .../reciperenderer/ShapedRecipesRenderer.java | 8 +-- .../ShapelessRecipesRenderer.java | 6 +-- .../guideapi/proxy/ClientProxy.java | 14 +++--- .../guideapi/proxy/CommonProxy.java | 2 +- .../amerifrance/guideapi/test/TestBook.java | 31 +++++------- .../amerifrance/guideapi/test/TestBook2.java | 24 ++++----- .../guideapi/util/AnnotationHandler.java | 12 ++--- .../guideapi/util/EventHandler.java | 4 +- .../guideapi/util/ReloadCommand.java | 16 ++---- .../resources/assets/guideapi/lang/de_de.json | 2 - .../resources/assets/guideapi/lang/en_us.json | 4 -- .../resources/assets/guideapi/lang/ru_ru.json | 2 - .../resources/assets/guideapi/lang/zh_cn.json | 2 - .../guideapi/models/item/guidebook.json | 20 ++++++-- 56 files changed, 327 insertions(+), 423 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/GuideConfig.java b/src/main/java/amerifrance/guideapi/GuideConfig.java index 7bda4277..f37dec0c 100644 --- a/src/main/java/amerifrance/guideapi/GuideConfig.java +++ b/src/main/java/amerifrance/guideapi/GuideConfig.java @@ -3,12 +3,8 @@ import amerifrance.guideapi.api.GuideAPI; import amerifrance.guideapi.api.impl.Book; -import com.electronwill.nightconfig.core.CommentedConfig; -import com.google.common.collect.Maps; import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.config.ConfigFileTypeHandler; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; @@ -29,23 +25,23 @@ public static class Common { public final ForgeConfigSpec.BooleanValue canSpawnWithBook; public final ForgeConfigSpec.BooleanValue enableLogging; - public final Map SPAWN_BOOKS = new HashMap<>(); + public final Map SPAWN_BOOKS = new HashMap<>(); Common(ForgeConfigSpec.Builder builder) { builder.comment("Common configurations settings").push("common"); - enableLogging = builder.comment("Enables extra information being printed to the console.").define("enableLogging",true); - canSpawnWithBook = builder.comment("Allows books to spawn with new players.\nThis is a global override for all books if set to false.").define("canSpawnWithBook",true); + enableLogging = builder.comment("Enables extra information being printed to the console.").define("enableLogging", true); + canSpawnWithBook = builder.comment("Allows books to spawn with new players.\nThis is a global override for all books if set to false.").define("canSpawnWithBook", true); builder.comment("If the player should spawn with this book").push("spawnBook"); - for(Book book : GuideAPI.getBooks().values()){ - SPAWN_BOOKS.put(book,builder.define(book.getRegistryName().getNamespace()+"-"+book.getRegistryName().getPath(),book.shouldSpawnWithBook())); + for (Book book : GuideAPI.getBooks().values()) { + SPAWN_BOOKS.put(book, builder.define(book.getRegistryName().getNamespace() + "-" + book.getRegistryName().getPath(), book.shouldSpawnWithBook())); } builder.pop(); builder.pop(); } } - public static void buildConfiguration(){ + public static void buildConfiguration() { final Pair specPair = new ForgeConfigSpec.Builder().configure(Common::new); ForgeConfigSpec commonSpec = specPair.getRight(); COMMON = specPair.getLeft(); diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index 3171c69e..ccb49986 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -1,23 +1,20 @@ package amerifrance.guideapi; -import amerifrance.guideapi.proxy.ClientProxy; import amerifrance.guideapi.api.GuideAPI; import amerifrance.guideapi.api.IGuideBook; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.network.PacketHandler; +import amerifrance.guideapi.proxy.ClientProxy; import amerifrance.guideapi.proxy.CommonProxy; import amerifrance.guideapi.util.AnnotationHandler; import amerifrance.guideapi.util.ReloadCommand; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.commons.lang3.tuple.Pair; @@ -35,8 +32,8 @@ public class GuideMod { public static CommonProxy PROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new); - public GuideMod(){ - INSTANCE=this; + public GuideMod() { + INSTANCE = this; checkDevEnv(); GuideAPI.initialize(); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); @@ -45,14 +42,14 @@ public GuideMod(){ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onServerStarting); } - private void setup(final FMLCommonSetupEvent event){ - if(GuideConfig.COMMON==null){ - throw new IllegalStateException("Did not build configuration, before configuration load. Make sure to call GuideConfig#buildConfiguration during one of the registry events"); + private void setup(final FMLCommonSetupEvent event) { + if (GuideConfig.COMMON == null) { + throw new IllegalStateException("Did not build configuration, before configuration load. Make sure to call GuideConfig#buildConfiguration during one of the registry events"); } PacketHandler.registerPackets(); } - private void loadComplete(final FMLLoadCompleteEvent event){ + private void loadComplete(final FMLLoadCompleteEvent event) { PROXY.initColors(); for (Pair guide : AnnotationHandler.BOOK_CLASSES) @@ -66,8 +63,8 @@ private void checkDevEnv() { } } - private void onServerStarting(FMLServerStartingEvent event){ - if(inDev){ + private void onServerStarting(FMLServerStartingEvent event) { + if (inDev) { event.getCommandDispatcher().register(LiteralArgumentBuilder.literal("guide-api").then(ReloadCommand.register())); } } diff --git a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java index b70f8620..84f42719 100644 --- a/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java +++ b/src/main/java/amerifrance/guideapi/RegistrarGuideAPI.java @@ -6,7 +6,6 @@ import amerifrance.guideapi.item.ItemGuideBook; import amerifrance.guideapi.util.APISetter; import amerifrance.guideapi.util.AnnotationHandler; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.Item; @@ -20,11 +19,10 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; - import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; -@Mod.EventBusSubscriber(modid = "guideapi",bus = Mod.EventBusSubscriber.Bus.MOD) +@Mod.EventBusSubscriber(modid = "guideapi", bus = Mod.EventBusSubscriber.Bus.MOD) public class RegistrarGuideAPI { @@ -44,10 +42,10 @@ public static void registerItems(RegistryEvent.Register event) { @SubscribeEvent @OnlyIn(Dist.CLIENT) public static void registerModels(ModelRegistryEvent event) { - for (Pair guide : AnnotationHandler.BOOK_CLASSES){ - ResourceLocation loc=guide.getRight().getModel(); - if (loc!=null){ - ModelLoader.addSpecialModel(new ModelResourceLocation(loc,"inventory")); + for (Pair guide : AnnotationHandler.BOOK_CLASSES) { + ResourceLocation loc = guide.getRight().getModel(); + if (loc != null) { + ModelLoader.addSpecialModel(new ModelResourceLocation(loc, "inventory")); } } } @@ -56,12 +54,12 @@ public static void registerModels(ModelRegistryEvent event) { @OnlyIn(Dist.CLIENT) public static void bakeModel(ModelBakeEvent event) { for (Pair guide : AnnotationHandler.BOOK_CLASSES) { - ResourceLocation loc=guide.getRight().getModel(); - if (loc!=null){ - ModelResourceLocation newMrl = new ModelResourceLocation(loc,"inventory"); + ResourceLocation loc = guide.getRight().getModel(); + if (loc != null) { + ModelResourceLocation newMrl = new ModelResourceLocation(loc, "inventory"); Item bookItem = GuideAPI.getStackFromBook(guide.getLeft()).getItem(); - ModelResourceLocation oldMrl = new ModelResourceLocation(bookItem.getRegistryName(),"inventory"); - IBakedModel model= event.getModelRegistry().get(newMrl); + ModelResourceLocation oldMrl = new ModelResourceLocation(bookItem.getRegistryName(), "inventory"); + IBakedModel model = event.getModelRegistry().get(newMrl); event.getModelRegistry().put(oldMrl, model); diff --git a/src/main/java/amerifrance/guideapi/api/BookEvent.java b/src/main/java/amerifrance/guideapi/api/BookEvent.java index 6cdc7ec4..f2bb5c32 100644 --- a/src/main/java/amerifrance/guideapi/api/BookEvent.java +++ b/src/main/java/amerifrance/guideapi/api/BookEvent.java @@ -5,8 +5,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.Style; -import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; @@ -14,7 +14,7 @@ /** * Base class for all {@link Book} related events. - * + *

* {@link #book} is the book being opened. * {@link #stack} is the ItemStack of the Book. * {@link #player} is the player opening the book. @@ -45,7 +45,7 @@ public PlayerEntity getPlayer() { /** * Called client side whenever a book is opened. - * + *

* {@link #canceledText} is a status message sent to the player when the book fails to open. */ @Cancelable diff --git a/src/main/java/amerifrance/guideapi/api/GuideAPI.java b/src/main/java/amerifrance/guideapi/api/GuideAPI.java index 613fb3c2..84a80f5a 100644 --- a/src/main/java/amerifrance/guideapi/api/GuideAPI.java +++ b/src/main/java/amerifrance/guideapi/api/GuideAPI.java @@ -3,15 +3,8 @@ import amerifrance.guideapi.api.impl.Book; import com.google.common.collect.*; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemModelMesher; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - import java.util.List; import java.util.Map; @@ -41,7 +34,7 @@ public static ItemStack getStackFromBook(Book book) { */ public static void registerInfoRenderer(Book book, IInfoRenderer infoRenderer, Class... blockClasses) { if (!INFO_RENDERERS.containsKey(book)) - INFO_RENDERERS.put(book, ArrayListMultimap., IInfoRenderer>create()); + INFO_RENDERERS.put(book, ArrayListMultimap.create()); for (Class blockClass : blockClasses) INFO_RENDERERS.get(book).put(blockClass, infoRenderer); diff --git a/src/main/java/amerifrance/guideapi/api/IGuideBook.java b/src/main/java/amerifrance/guideapi/api/IGuideBook.java index af81a475..e414994c 100644 --- a/src/main/java/amerifrance/guideapi/api/IGuideBook.java +++ b/src/main/java/amerifrance/guideapi/api/IGuideBook.java @@ -2,10 +2,10 @@ import amerifrance.guideapi.api.impl.Book; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -25,8 +25,8 @@ public interface IGuideBook { */ @Nullable @OnlyIn(Dist.CLIENT) - default ResourceLocation getModel(){ - return new ResourceLocation("guideapi","guidebook"); + default ResourceLocation getModel() { + return new ResourceLocation("guideapi", "guidebook"); } /** diff --git a/src/main/java/amerifrance/guideapi/api/IPage.java b/src/main/java/amerifrance/guideapi/api/IPage.java index a28d5426..dfe0633e 100644 --- a/src/main/java/amerifrance/guideapi/api/IPage.java +++ b/src/main/java/amerifrance/guideapi/api/IPage.java @@ -1,10 +1,10 @@ package amerifrance.guideapi.api; -import amerifrance.guideapi.gui.BaseScreen; -import amerifrance.guideapi.gui.EntryScreen; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.gui.BaseScreen; +import amerifrance.guideapi.gui.EntryScreen; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java index 05f16de5..bb7954df 100644 --- a/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/api/IRecipeRenderer.java @@ -1,23 +1,18 @@ package amerifrance.guideapi.api; -import amerifrance.guideapi.api.util.IngredientCycler; -import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.IngredientCycler; +import amerifrance.guideapi.gui.BaseScreen; import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.List; -import java.util.Optional; -import java.util.Random; public interface IRecipeRenderer { diff --git a/src/main/java/amerifrance/guideapi/api/SubTexture.java b/src/main/java/amerifrance/guideapi/api/SubTexture.java index 0cccb97b..744c9a6e 100644 --- a/src/main/java/amerifrance/guideapi/api/SubTexture.java +++ b/src/main/java/amerifrance/guideapi/api/SubTexture.java @@ -64,10 +64,10 @@ public void draw(int drawX, int drawY, double zLevel) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); - vertexbuffer.pos((double) drawX, (double) (drawY + height), zLevel).tex((double) ((float) xPos * someMagicValueFromMojang), (double) ((float) (yPos + height) * someMagicValueFromMojang)).endVertex(); - vertexbuffer.pos((double) (drawX + width), (double) (drawY + height), zLevel).tex((double) ((float) (xPos + width) * someMagicValueFromMojang), (double) ((float) (yPos + height) * someMagicValueFromMojang)).endVertex(); - vertexbuffer.pos((double) (drawX + width), (double) drawY, zLevel).tex((double) ((float) (xPos + width) * someMagicValueFromMojang), (double) ((float) yPos * someMagicValueFromMojang)).endVertex(); - vertexbuffer.pos((double) drawX, (double) drawY, zLevel).tex((double) ((float) xPos * someMagicValueFromMojang), (double) ((float) yPos * someMagicValueFromMojang)).endVertex(); + vertexbuffer.pos(drawX, drawY + height, zLevel).tex((float) xPos * someMagicValueFromMojang, (float) (yPos + height) * someMagicValueFromMojang).endVertex(); + vertexbuffer.pos(drawX + width, drawY + height, zLevel).tex((float) (xPos + width) * someMagicValueFromMojang, (float) (yPos + height) * someMagicValueFromMojang).endVertex(); + vertexbuffer.pos(drawX + width, drawY, zLevel).tex((float) (xPos + width) * someMagicValueFromMojang, (float) yPos * someMagicValueFromMojang).endVertex(); + vertexbuffer.pos(drawX, drawY, zLevel).tex((float) xPos * someMagicValueFromMojang, (float) yPos * someMagicValueFromMojang).endVertex(); tessellator.draw(); } diff --git a/src/main/java/amerifrance/guideapi/api/impl/Book.java b/src/main/java/amerifrance/guideapi/api/impl/Book.java index 56765004..f6a6af21 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Book.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Book.java @@ -7,7 +7,7 @@ import net.minecraft.util.ResourceLocation; import org.apache.commons.lang3.builder.ToStringBuilder; -import java.awt.Color; +import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -45,11 +45,11 @@ protected Book(Consumer> contentProvider, String title, S this.creativeTab = creativeTab; } - public void initializeContent(){ - if(!isInitialized){ - LogHelper.debug("Opening book "+registryName.toString()+" for the first time -> Initializing content"); + public void initializeContent() { + if (!isInitialized) { + LogHelper.debug("Opening book " + registryName.toString() + " for the first time -> Initializing content"); contentProvider.accept(categories); - isInitialized=true; + isInitialized = true; } } @@ -57,10 +57,10 @@ public void initializeContent(){ * Can be used to force content initialisation independent of first use regardless of if it was initialized previously. * Use at own risk. Might cause crashes if the book is currently open. */ - public void forceInitializeContent(){ - LogHelper.info("Force initializing book content "+registryName.toString()); + public void forceInitializeContent() { + LogHelper.info("Force initializing book content " + registryName.toString()); categories.clear(); - isInitialized=false; + isInitialized = false; initializeContent(); } diff --git a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java index cad5fde6..090903bb 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java +++ b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java @@ -6,10 +6,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.forgespi.language.IModInfo; -import java.awt.Color; +import java.awt.*; import java.util.List; import java.util.function.Consumer; @@ -45,7 +44,7 @@ public BookBinder(ResourceLocation registryName) { * @param contentProvider The consumer. Categories are displayed in which they are added to the provided list * @return the builder instance for chaining. */ - public BookBinder setContentProvider(Consumer> contentProvider){ + public BookBinder setContentProvider(Consumer> contentProvider) { this.contentProvider = contentProvider; return this; } @@ -63,7 +62,7 @@ public BookBinder setGuideTitle(String guideTitle) { /** * Sets the header text of this book. The header is displayed at the top of the home page above the category listing. - * + *

* By default, this is the same as {@link #guideTitle}. * * @param header The header text to display. @@ -76,7 +75,7 @@ public BookBinder setHeader(String header) { /** * Sets the unlocalized name for the item containing this book. - * + *

* By default, this is the same as {@link #guideTitle}. * * @param itemName The unlocalized name for this item. @@ -90,7 +89,7 @@ public BookBinder setItemName(String itemName) { /** * The author of this book. If your books are lore-heavy, using an actual author name is acceptable. If not, you can * just use your mod name. - * + *

* By default, this uses the name of the mod container obtained from looking up the domain of {@link #registryName}. * * @param author The author of this book. @@ -104,7 +103,7 @@ public BookBinder setAuthor(String author) { /** * The texture to use for the pages themselves. These are un-colored and drawn just how they appear in the texture file. * The dimensions should remain the same as the default texture. - * + *

* By default, this uses the same page texture as vanilla books. * * @param pageTexture The page texture to use for this guide. @@ -118,7 +117,7 @@ public BookBinder setPageTexture(ResourceLocation pageTexture) { /** * The texture to use for the border of the book. These are colored with {@link #color}. The dimensions should remain * the same as the default texture. - * + *

* By default, this uses a greyscale version of the outline of vanilla books. * * @param outlineTexture The outline texture to use for this guide. @@ -131,7 +130,7 @@ public BookBinder setOutlineTexture(ResourceLocation outlineTexture) { /** * Indicates that the item containing this book has a custom model that you will manually register. - * + *

* By default, a generic book model will be registered and colored with {@link #color}. * * @return the builder instance for chaining. @@ -143,7 +142,7 @@ public BookBinder setHasCustomModel() { /** * Sets the color to overlay on the book model and GUI border. - * + *

* By default, this is a reddish-brown color. * * @param color The color to overlay with. @@ -157,10 +156,9 @@ public BookBinder setColor(Color color) { /** * An overload that takes an RGB color instead of a {@link Color} instance. * - * @see #setColor(int) - * * @param color The color to overlay with. * @return the builder instance for chaining. + * @see #setColor(int) */ public BookBinder setColor(int color) { return setColor(new Color(color)); @@ -169,7 +167,7 @@ public BookBinder setColor(int color) { /** * Sets the default config option for whether new players should spawn with this book in their inventory. Players may * override this in the config if they wish. - * + *

* By default, books will not spawn in the player's inventory. * * @return the builder instance for chaining. @@ -181,7 +179,7 @@ public BookBinder setSpawnWithBook() { /** * Sets the Creative Tab this book should appear in. - * + *

* By default, all books will appear in {@link ItemGroup#MISC}. * * @param creativeTab The creative tab this book should display in. @@ -194,6 +192,7 @@ public BookBinder setCreativeTab(ItemGroup creativeTab) { /** * Constructs a book from the given data. Will modify specific values if not set so they have defaults. + * * @return a constructed book. */ public Book build() { @@ -206,8 +205,8 @@ public Book build() { if (this.itemName == null) this.itemName = guideTitle.substring(5); - if(contentProvider ==null){ - throw new IllegalStateException("Content supplier of book "+registryName.toString()+" must be provided"); + if (contentProvider == null) { + throw new IllegalStateException("Content supplier of book " + registryName.toString() + " must be provided"); } return new Book(contentProvider, guideTitle, header, itemName, author, pageTexture, outlineTexture, hasCustomModel, color, spawnWithBook, registryName, creativeTab); diff --git a/src/main/java/amerifrance/guideapi/api/impl/Entry.java b/src/main/java/amerifrance/guideapi/api/impl/Entry.java index e225450b..126c5c83 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Entry.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Entry.java @@ -13,10 +13,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.config.GuiUtils; -import java.awt.Color; -import java.util.Collections; +import java.awt.*; import java.util.List; public class Entry extends EntryAbstract { @@ -66,7 +64,7 @@ public void drawExtras(Book book, CategoryAbstract category, int entryX, int ent cutString = true; if (GuiHelper.isMouseBetween(mouseX, mouseY, entryX, entryY, entryWidth, entryHeight) && cutString) { - guiBase.renderTooltip(getLocalizedName(),entryX,entryY+12); + guiBase.renderTooltip(getLocalizedName(), entryX, entryY + 12); } diff --git a/src/main/java/amerifrance/guideapi/api/impl/Page.java b/src/main/java/amerifrance/guideapi/api/impl/Page.java index 9632dcd9..604ae24d 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Page.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Page.java @@ -47,7 +47,6 @@ public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, Pl public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; - if (getClass() != o.getClass()) return false; - return true; + return getClass() == o.getClass(); } } diff --git a/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java b/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java index 2560b668..f99f1805 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java +++ b/src/main/java/amerifrance/guideapi/api/impl/abstraction/CategoryAbstract.java @@ -29,7 +29,7 @@ public CategoryAbstract(Map entries, String nam } public CategoryAbstract(String name) { - this(Maps.newLinkedHashMap(), name); + this(Maps.newLinkedHashMap(), name); } /** @@ -67,8 +67,7 @@ public void addEntries(Map entries) { public void removeEntries(List keys) { for (ResourceLocation key : keys) - if (entries.containsKey(key)) - entries.remove(key); + entries.remove(key); } /** @@ -157,10 +156,7 @@ public boolean equals(Object o) { CategoryAbstract that = (CategoryAbstract) o; if (entries != null ? !entries.equals(that.entries) : that.entries != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - return true; + return name != null ? name.equals(that.name) : that.name == null; } @Override diff --git a/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java b/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java index 1ccc490a..373735ce 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java +++ b/src/main/java/amerifrance/guideapi/api/impl/abstraction/EntryAbstract.java @@ -73,10 +73,7 @@ public boolean equals(Object o) { EntryAbstract that = (EntryAbstract) o; if (pageList != null ? !pageList.equals(that.pageList) : that.pageList != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - return true; + return name != null ? name.equals(that.name) : that.name == null; } @Override diff --git a/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java b/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java index f1a78e43..cb3722da 100644 --- a/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java +++ b/src/main/java/amerifrance/guideapi/api/util/IngredientCycler.java @@ -1,13 +1,7 @@ package amerifrance.guideapi.api.util; -import amerifrance.guideapi.api.IRecipeRenderer; -import amerifrance.guideapi.api.impl.Book; -import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; -import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -25,8 +19,8 @@ public class IngredientCycler { private int cycleIdx = 0; private Random rand = new Random(); - public void tick(@Nonnull Minecraft mc){ - long time = mc.world!=null?mc.world.getGameTime():0; + public void tick(@Nonnull Minecraft mc) { + long time = mc.world != null ? mc.world.getGameTime() : 0; if (lastCycle < 0 || lastCycle < time - 20) { if (lastCycle > 0) { cycleIdx++; @@ -40,15 +34,16 @@ public void tick(@Nonnull Minecraft mc){ * Retrieves a itemstack that matches the ingredient. * Cycles though all matching stacks. * Must call {@link IngredientCycler#tick(Minecraft)} before (e.g. once per onDraw) + * * @param ingredient The ingredient - * @param index An "unique" id for this ingredient, so multiple ingredients can be cycled independently + * @param index An "unique" id for this ingredient, so multiple ingredients can be cycled independently * @return Optional. Can be empty if ingredient is invalid and has no matching stacks */ - public Optional getCycledIngredientStack(@Nonnull Ingredient ingredient, int index){ + public Optional getCycledIngredientStack(@Nonnull Ingredient ingredient, int index) { ItemStack[] itemStacks = ingredient.getMatchingStacks(); - if(itemStacks.length>0){ + if (itemStacks.length > 0) { rand.setSeed(index); - int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) %itemStacks.length; + int id = (index + rand.nextInt(itemStacks.length) + cycleIdx) % itemStacks.length; return Optional.of(itemStacks[id]); } return Optional.empty(); diff --git a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java index 7a596136..95a43740 100644 --- a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java @@ -1,7 +1,6 @@ package amerifrance.guideapi.api.util; import amerifrance.guideapi.api.IPage; -import amerifrance.guideapi.api.impl.Page; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.page.PageItemStack; import amerifrance.guideapi.page.PageText; @@ -14,38 +13,37 @@ import net.minecraft.item.crafting.Ingredient; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.text.WordUtils; import java.util.ArrayList; import java.util.List; public class PageHelper { - /** * Split the given text into multiple section if it does not fit one page. * The first page can have a different number of lines than the subsequent ones if desired * Insert new line characters to wrap the text to the available line width. - * @param locText Text to process - * @param lineWidth Available width (pixel) - * @param firstHeight Available height on the first page (pixel) + * + * @param locText Text to process + * @param lineWidth Available width (pixel) + * @param firstHeight Available height on the first page (pixel) * @param subsequentHeight Available height on subsequent pages (pixel) * @return Each list element should be drawn on a individual page. Lines are wrapped using '\n' */ - public static List prepareForLongText(String locText, int lineWidth, int firstHeight, int subsequentHeight){ + public static List prepareForLongText(String locText, int lineWidth, int firstHeight, int subsequentHeight) { FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; - int firstCount = firstHeight/fontRenderer.FONT_HEIGHT; - int count = subsequentHeight/fontRenderer.FONT_HEIGHT; - List lines = new ArrayList<>(fontRenderer.listFormattedStringToWidth(locText,lineWidth)); //Create a new list from returned list so we can later remove items + int firstCount = firstHeight / fontRenderer.FONT_HEIGHT; + int count = subsequentHeight / fontRenderer.FONT_HEIGHT; + List lines = new ArrayList<>(fontRenderer.listFormattedStringToWidth(locText, lineWidth)); //Create a new list from returned list so we can later remove items List pages = new ArrayList<>(); - List pageLines = lines.size()>firstCount ? lines.subList(0,firstCount):lines; - pages.add(StringUtils.join( pageLines, "\n")); + List pageLines = lines.size() > firstCount ? lines.subList(0, firstCount) : lines; + pages.add(StringUtils.join(pageLines, "\n")); pageLines.clear(); - while(lines.size()>0){ - pageLines = lines.size()>count ? lines.subList(0,count):lines; - pages.add(StringUtils.join(pageLines,"\n")); + while (lines.size() > 0) { + pageLines = lines.size() > count ? lines.subList(0, count) : lines; + pages.add(StringUtils.join(pageLines, "\n")); pageLines.clear(); } return pages; @@ -54,14 +52,13 @@ public static List prepareForLongText(String locText, int lineWidth, int /** * Spread the text over multiple pages if necessary. Display ingredient at first page */ - public static List pagesForLongText(String locText, Ingredient ingredient){ - List pageText = prepareForLongText(locText,164,79,120); + public static List pagesForLongText(String locText, Ingredient ingredient) { + List pageText = prepareForLongText(locText, 164, 79, 120); List pageList = new ArrayList<>(); - for(int i=0;i pagesForLongText(String locText, Ingredient ingredient } - public static List pagesForLongText(String locText){ + public static List pagesForLongText(String locText) { List pageList = new ArrayList<>(); - prepareForLongText(locText,164,120,120).forEach(t->pageList.add(new PageText(t))); + prepareForLongText(locText, 164, 120, 120).forEach(t -> pageList.add(new PageText(t))); return pageList; } @@ -109,7 +106,7 @@ public static List pagesForLongText(String locText, Block block) { /** * @param locText - Text - * @param item - The stack to put on the first page + * @param item - The stack to put on the first page * @return a list of IPages with the text cut to fit on page */ public static List pagesForLongText(String locText, ItemStack item) { @@ -125,8 +122,7 @@ public static boolean areIRecipesEqual(IRecipe recipe1, IRecipe recipe2) { if (recipe1 == recipe2) return true; if (recipe1 == null || recipe2 == null || recipe1.getClass() != recipe2.getClass()) return false; if (recipe1.equals(recipe2)) return true; - if (!recipe1.getRecipeOutput().isItemEqual(recipe2.getRecipeOutput())) return false; + return recipe1.getRecipeOutput().isItemEqual(recipe2.getRecipeOutput()); // if (recipe1.getRecipeSize() != recipe2.getRecipeSize()) return false;//FN was removed, there is no size now - return true; } } diff --git a/src/main/java/amerifrance/guideapi/api/util/TextHelper.java b/src/main/java/amerifrance/guideapi/api/util/TextHelper.java index f135691b..bf6a6c34 100644 --- a/src/main/java/amerifrance/guideapi/api/util/TextHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/TextHelper.java @@ -1,6 +1,5 @@ package amerifrance.guideapi.api.util; -import net.minecraft.client.resources.I18n; import net.minecraftforge.fml.ForgeI18n; import org.apache.commons.lang3.text.WordUtils; diff --git a/src/main/java/amerifrance/guideapi/button/ButtonBack.java b/src/main/java/amerifrance/guideapi/button/ButtonBack.java index 8f71deb7..6c258196 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonBack.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonBack.java @@ -18,7 +18,7 @@ public class ButtonBack extends ButtonGuideAPI { public ButtonBack(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { - super(widthIn, heightIn, 18, 10, onPress,guiBase); + super(widthIn, heightIn, 18, 10, onPress, guiBase); } @Override @@ -30,10 +30,10 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { - this.blit(x,y+1,70,201,18,10); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); + this.blit(x, y + 1, 70, 201, 18, 10); + GuiUtils.drawHoveringText(getHoveringText(), mouseX, mouseY, guiBase.width, guiBase.height, -1, Minecraft.getInstance().fontRenderer); } else { - this.blit(x,y,94,201,18,10); + this.blit(x, y, 94, 201, 18, 10); } GlStateManager.disableBlend(); RenderHelper.disableStandardItemLighting(); diff --git a/src/main/java/amerifrance/guideapi/button/ButtonNext.java b/src/main/java/amerifrance/guideapi/button/ButtonNext.java index df9917da..343e1b04 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonNext.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonNext.java @@ -18,24 +18,24 @@ public class ButtonNext extends ButtonGuideAPI { public ButtonNext(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { - super(widthIn, heightIn, 18, 10, onPress,guiBase); + super(widthIn, heightIn, 18, 10, onPress, guiBase); } @Override - public void renderButton( int mouseX, int mouseY, float partialTicks) { - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.enableBlend(); - GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.disableLighting(); - Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); - if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { - this.blit(x,y+1,47,201,18,10); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); - } else { - this.blit(x,y,24,201,18,10); - } - GlStateManager.disableBlend(); - RenderHelper.disableStandardItemLighting(); + public void renderButton(int mouseX, int mouseY, float partialTicks) { + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.enableBlend(); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.disableLighting(); + Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); + if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { + this.blit(x, y + 1, 47, 201, 18, 10); + GuiUtils.drawHoveringText(getHoveringText(), mouseX, mouseY, guiBase.width, guiBase.height, -1, Minecraft.getInstance().fontRenderer); + } else { + this.blit(x, y, 24, 201, 18, 10); + } + GlStateManager.disableBlend(); + RenderHelper.disableStandardItemLighting(); } diff --git a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java index 2efd593e..97b804d4 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonPrev.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonPrev.java @@ -18,7 +18,7 @@ public class ButtonPrev extends ButtonGuideAPI { public ButtonPrev(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { - super(widthIn, heightIn, 18, 10, onPress,guiBase); + super(widthIn, heightIn, 18, 10, onPress, guiBase); } @Override @@ -30,10 +30,10 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { GlStateManager.disableLighting(); Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(GuideMod.ID, "textures/gui/book_colored.png")); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { - this.blit(x,y+1,47,214,18,10); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); + this.blit(x, y + 1, 47, 214, 18, 10); + GuiUtils.drawHoveringText(getHoveringText(), mouseX, mouseY, guiBase.width, guiBase.height, -1, Minecraft.getInstance().fontRenderer); } else { - this.blit(x,y,24,214,18,10); + this.blit(x, y, 24, 214, 18, 10); } GlStateManager.disableBlend(); RenderHelper.disableStandardItemLighting(); diff --git a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java index f75b06b2..c7055aff 100644 --- a/src/main/java/amerifrance/guideapi/button/ButtonSearch.java +++ b/src/main/java/amerifrance/guideapi/button/ButtonSearch.java @@ -17,7 +17,7 @@ public class ButtonSearch extends ButtonGuideAPI { public ButtonSearch(int widthIn, int heightIn, Button.IPressable onPress, BaseScreen guiBase) { - super(widthIn, heightIn, 15, 15, onPress,guiBase); + super(widthIn, heightIn, 15, 15, onPress, guiBase); } @Override @@ -29,7 +29,7 @@ public void renderButton(int mouseX, int mouseY, float partialTicks) { GlStateManager.disableLighting(); if (GuiHelper.isMouseBetween(mouseX, mouseY, x, y, width, height)) { SubTexture.MAGNIFYING_GLASS.draw(x, y + 1); - GuiUtils.drawHoveringText(getHoveringText(),mouseX,mouseY,guiBase.width,guiBase.height,-1,Minecraft.getInstance().fontRenderer); + GuiUtils.drawHoveringText(getHoveringText(), mouseX, mouseY, guiBase.width, guiBase.height, -1, Minecraft.getInstance().fontRenderer); } else { SubTexture.MAGNIFYING_GLASS.draw(x, y); } diff --git a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java index 64973a89..951b53e3 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryItemStack.java @@ -5,13 +5,11 @@ import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; import amerifrance.guideapi.api.util.GuiHelper; import amerifrance.guideapi.gui.BaseScreen; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.config.GuiUtils; import java.util.Map; @@ -39,7 +37,7 @@ public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - guiBase.renderTooltip(this.getTooltip(),mouseX,mouseY); + guiBase.renderTooltip(this.getTooltip(), mouseX, mouseY); } @Override diff --git a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java index 0e5dda90..908a5a1a 100644 --- a/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java +++ b/src/main/java/amerifrance/guideapi/category/CategoryResourceLocation.java @@ -10,7 +10,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.config.GuiUtils; import java.util.Map; @@ -39,7 +38,7 @@ public void draw(Book book, int categoryX, int categoryY, int categoryWidth, int @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, int categoryX, int categoryY, int categoryWidth, int categoryHeight, int mouseX, int mouseY, BaseScreen guiBase, boolean drawOnLeft, ItemRenderer renderItem) { if (canSee(guiBase.player, guiBase.bookStack) && GuiHelper.isMouseBetween(mouseX, mouseY, categoryX, categoryY, categoryWidth, categoryHeight)) - guiBase.renderTooltip(this.getTooltip(),mouseX,mouseY); + guiBase.renderTooltip(this.getTooltip(), mouseX, mouseY); } @Override diff --git a/src/main/java/amerifrance/guideapi/gui/BaseScreen.java b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java index e8c13701..94c4fa41 100644 --- a/src/main/java/amerifrance/guideapi/gui/BaseScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/BaseScreen.java @@ -42,12 +42,11 @@ public boolean isPauseScreen() { @Override public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) { - if (minecraft!=null&&(p_keyPressed_1_ == GLFW.GLFW_KEY_ESCAPE || p_keyPressed_1_==this.minecraft.gameSettings.keyBindInventory.getKey().getKeyCode())) { + if (minecraft != null && (p_keyPressed_1_ == GLFW.GLFW_KEY_ESCAPE || p_keyPressed_1_ == this.minecraft.gameSettings.keyBindInventory.getKey().getKeyCode())) { this.onClose(); this.minecraft.setGameFocused(true); return true; - } - else{ + } else { return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_); } } @@ -62,10 +61,10 @@ public void drawTexturedModalRectWithColor(int x, int y, int textureX, int textu color3f((float) color.getRed() / 255F, (float) color.getGreen() / 255F, (float) color.getBlue() / 255F); Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(7, DefaultVertexFormats.POSITION_TEX); - tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) this.blitOffset).tex((double) ((float) (textureX) * f), (double) ((float) (textureY + height) * f1)).endVertex(); - tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.blitOffset).tex((double) ((float) (textureX + width) * f), (double) ((float) (textureY + height) * f1)).endVertex(); - tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) this.blitOffset).tex((double) ((float) (textureX + width) * f), (double) ((float) (textureY) * f1)).endVertex(); - tessellator.getBuffer().pos((double) (x), (double) (y), (double) this.blitOffset).tex((double) ((float) (textureX) * f), (double) ((float) (textureY) * f1)).endVertex(); + tessellator.getBuffer().pos(x, y + height, this.blitOffset).tex((float) (textureX) * f, (float) (textureY + height) * f1).endVertex(); + tessellator.getBuffer().pos(x + width, y + height, this.blitOffset).tex((float) (textureX + width) * f, (float) (textureY + height) * f1).endVertex(); + tessellator.getBuffer().pos(x + width, y, this.blitOffset).tex((float) (textureX + width) * f, (float) (textureY) * f1).endVertex(); + tessellator.getBuffer().pos(x, y, this.blitOffset).tex((float) (textureX) * f, (float) (textureY) * f1).endVertex(); tessellator.draw(); disableBlend(); popMatrix(); @@ -82,12 +81,12 @@ public void drawCenteredStringWithShadow(FontRenderer fontRendererObj, String st super.drawCenteredString(fontRendererObj, string, x, y, color); } - public void drawHoveringTextComponents(List tooltip , int mouseX, int mouseY){ - this.drawHoveringText(tooltip.stream().map(ITextComponent::getFormattedText).collect(Collectors.toList()), mouseX,mouseY); + public void drawHoveringTextComponents(List tooltip, int mouseX, int mouseY) { + this.drawHoveringText(tooltip.stream().map(ITextComponent::getFormattedText).collect(Collectors.toList()), mouseX, mouseY); } - public void drawHoveringText(List tooltip , int mouseX, int mouseY){ - GuiUtils.drawHoveringText(tooltip,mouseX,mouseY,width,height,-1,font); + public void drawHoveringText(List tooltip, int mouseX, int mouseY) { + GuiUtils.drawHoveringText(tooltip, mouseX, mouseY, width, height, -1, font); } diff --git a/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java index 6ba814fe..99e8bf7b 100644 --- a/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/CategoryScreen.java @@ -19,10 +19,9 @@ import net.minecraft.util.text.TranslationTextComponent; import org.lwjgl.glfw.GLFW; -import java.awt.Color; -import java.util.List; - import javax.annotation.Nullable; +import java.awt.*; +import java.util.List; public class CategoryScreen extends BaseScreen { @@ -36,10 +35,11 @@ public class CategoryScreen extends BaseScreen { public ButtonPrev buttonPrev; public ButtonSearch buttonSearch; public int entryPage; - @Nullable public EntryAbstract startEntry; + @Nullable + public EntryAbstract startEntry; public CategoryScreen(Book book, CategoryAbstract category, PlayerEntity player, ItemStack bookStack, @Nullable EntryAbstract startEntry) { - super(new TranslationTextComponent(category.name),player, bookStack); + super(new TranslationTextComponent(category.name), player, bookStack); this.book = book; this.category = category; this.pageTexture = book.getPageTexture(); @@ -55,22 +55,22 @@ public void init() { guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - addButton(buttonBack = new ButtonBack( guiLeft + xSize / 6, guiTop, (btn) ->{ + addButton(buttonBack = new ButtonBack(guiLeft + xSize / 6, guiTop, (btn) -> { this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); - },this)); - addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn) -> { - if(entryPage+1 { + if (entryPage + 1 < entryWrapperMap.asMap().size()) { nextPage(); } - },this)); - addButton(buttonPrev = new ButtonPrev( guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn)->{ - if(entryPage>0){ + }, this)); + addButton(buttonPrev = new ButtonPrev(guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn) -> { + if (entryPage > 0) { prevPage(); } - },this)); - addButton(buttonSearch = new ButtonSearch( (guiLeft + xSize / 6) - 25, guiTop + 5, (btn) -> { + }, this)); + addButton(buttonSearch = new ButtonSearch((guiLeft + xSize / 6) - 25, guiTop + 5, (btn) -> { this.minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); - },this)); + }, this)); int eX = guiLeft + 37; int eY = guiTop + 15; @@ -147,7 +147,7 @@ public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3 else if (movement > 0) prevPage(); - return movement!=0||super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); + return movement != 0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); } @Override @@ -155,14 +155,12 @@ public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) if (keyCode == GLFW.GLFW_KEY_BACKSPACE || keyCode == this.minecraft.gameSettings.keyBindUseItem.getKey().getKeyCode()) { this.minecraft.displayGuiScreen(new HomeScreen(book, player, bookStack)); return true; - } - else if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && entryPage + 1 < entryWrapperMap.asMap().size()) { + } else if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && entryPage + 1 < entryWrapperMap.asMap().size()) { nextPage(); return true; - } - else if ((keyCode == GLFW.GLFW_KEY_DOWN|| keyCode == GLFW.GLFW_KEY_LEFT) && entryPage > 0){ + } else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && entryPage > 0) { prevPage(); return true; } @@ -170,7 +168,6 @@ else if ((keyCode == GLFW.GLFW_KEY_DOWN|| keyCode == GLFW.GLFW_KEY_LEFT) && entr } - @Override public void onClose() { super.onClose(); diff --git a/src/main/java/amerifrance/guideapi/gui/EntryScreen.java b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java index d4909fe2..0f2d653e 100644 --- a/src/main/java/amerifrance/guideapi/gui/EntryScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/EntryScreen.java @@ -19,7 +19,7 @@ import net.minecraft.util.text.TranslationTextComponent; import org.lwjgl.glfw.GLFW; -import java.awt.Color; +import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -39,7 +39,7 @@ public class EntryScreen extends BaseScreen { public int pageNumber; public EntryScreen(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack) { - super(new TranslationTextComponent(entry.name),player, bookStack); + super(new TranslationTextComponent(entry.name), player, bookStack); this.book = book; this.category = category; this.entry = entry; @@ -47,7 +47,7 @@ public EntryScreen(Book book, CategoryAbstract category, EntryAbstract entry, Pl this.outlineTexture = book.getOutlineTexture(); this.pageNumber = 0; } - + @Override public void init() { @@ -58,23 +58,23 @@ public void init() { guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - addButton(buttonBack = new ButtonBack( guiLeft + xSize / 6, guiTop, (btn)-> { + addButton(buttonBack = new ButtonBack(guiLeft + xSize / 6, guiTop, (btn) -> { this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); - },this)); - addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn)->{ - if(pageNumber+1 { + if (pageNumber + 1 < pageWrapperList.size()) { nextPage(); } - },this)); - addButton(buttonPrev = new ButtonPrev( guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn)->{ - if(pageNumber>0){ + }, this)); + addButton(buttonPrev = new ButtonPrev(guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn) -> { + if (pageNumber > 0) { prevPage(); } - },this)); - addButton(buttonSearch = new ButtonSearch( (guiLeft + xSize / 6) - 25, guiTop + 5, (btn)->{ + }, this)); + addButton(buttonSearch = new ButtonSearch((guiLeft + xSize / 6) - 25, guiTop + 5, (btn) -> { this.minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); - },this)); + }, this)); for (IPage page : this.entry.pageList) { page.onInit(book, category, entry, player, bookStack, this); @@ -109,7 +109,7 @@ public void render(int mouseX, int mouseY, float renderPartialTicks) { @Override public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { - if(!super.mouseClicked(mouseX, mouseY, typeofClick)){ + if (!super.mouseClicked(mouseX, mouseY, typeofClick)) { for (PageWrapper wrapper : this.pageWrapperList) { if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { if (typeofClick == 0) { @@ -142,7 +142,7 @@ else if (movement > 0) prevPage(); - return movement!=0||super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); + return movement != 0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); } @@ -151,12 +151,10 @@ public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) if (keyCode == GLFW.GLFW_KEY_BACKSPACE || keyCode == this.minecraft.gameSettings.keyBindUseItem.getKey().getKeyCode()) { this.minecraft.displayGuiScreen(new CategoryScreen(book, category, player, bookStack, entry)); return true; - } - else if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && pageNumber + 1 < pageWrapperList.size()){ + } else if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && pageNumber + 1 < pageWrapperList.size()) { nextPage(); return true; - } - else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && pageNumber > 0){ + } else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && pageNumber > 0) { prevPage(); return true; } diff --git a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java index 7b309e3b..7de0ea5a 100644 --- a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java @@ -10,7 +10,6 @@ import amerifrance.guideapi.network.PacketSyncHome; import amerifrance.guideapi.wrapper.CategoryWrapper; import com.google.common.collect.HashMultimap; -import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -18,7 +17,7 @@ import net.minecraft.util.text.StringTextComponent; import org.lwjgl.glfw.GLFW; -import java.awt.Color; +import java.awt.*; public class HomeScreen extends BaseScreen { @@ -32,7 +31,7 @@ public class HomeScreen extends BaseScreen { public int categoryPage; public HomeScreen(Book book, PlayerEntity player, ItemStack bookStack) { - super(new StringTextComponent(book.getTitle()),player, bookStack); + super(new StringTextComponent(book.getTitle()), player, bookStack); this.book = book; this.pageTexture = book.getPageTexture(); this.outlineTexture = book.getOutlineTexture(); @@ -46,19 +45,19 @@ public void init() { guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn)->{ - if(categoryPage+1 < categoryWrapperMap.asMap().size()){ + addButton(buttonNext = new ButtonNext(guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn) -> { + if (categoryPage + 1 < categoryWrapperMap.asMap().size()) { nextPage(); } - },this)); - addButton(buttonPrev = new ButtonPrev( guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn)->{ - if(categoryPage>0){ + }, this)); + addButton(buttonPrev = new ButtonPrev(guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn) -> { + if (categoryPage > 0) { prevPage(); } - },this)); - addButton(buttonSearch = new ButtonSearch( (guiLeft + xSize / 6) - 25, guiTop + 5, (btn)->{ + }, this)); + addButton(buttonSearch = new ButtonSearch((guiLeft + xSize / 6) - 25, guiTop + 5, (btn) -> { minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); - },this)); + }, this)); int cX = guiLeft + 45; int cY = guiTop + 40; @@ -138,7 +137,7 @@ public void render(int mouseX, int mouseY, float renderPartialTicks) { @Override public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { - if(!super.mouseClicked(mouseX, mouseY, typeofClick)){ + if (!super.mouseClicked(mouseX, mouseY, typeofClick)) { for (CategoryWrapper wrapper : this.categoryWrapperMap.get(categoryPage)) { if (wrapper.isMouseOnWrapper(mouseX, mouseY) && wrapper.canPlayerSee()) { if (typeofClick == 0) @@ -165,17 +164,14 @@ public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3 else if (movement > 0) prevPage(); - return movement!=0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); + return movement != 0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); } @Override public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) { - if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && categoryPage + 1 < categoryWrapperMap.asMap().size()) - { + if ((keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_RIGHT) && categoryPage + 1 < categoryWrapperMap.asMap().size()) { nextPage(); - } - - else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && categoryPage > 0){ + } else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && categoryPage > 0) { prevPage(); } @@ -183,7 +179,6 @@ else if ((keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_LEFT) && cat } - @Override public void onClose() { super.onClose(); diff --git a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java index 32e6b82a..30c624dc 100644 --- a/src/main/java/amerifrance/guideapi/gui/SearchScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/SearchScreen.java @@ -22,7 +22,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.awt.Color; +import java.awt.*; import java.util.List; import java.util.Locale; @@ -40,7 +40,7 @@ public class SearchScreen extends BaseScreen { private String lastQuery = ""; public SearchScreen(Book book, PlayerEntity player, ItemStack bookStack, Screen parent) { - super(new TranslationTextComponent(book.getTitle()),player, bookStack); + super(new TranslationTextComponent(book.getTitle()), player, bookStack); this.book = book; this.pageTexture = book.getPageTexture(); @@ -56,20 +56,20 @@ public void init() { guiLeft = (this.width - this.xSize) / 2; guiTop = (this.height - this.ySize) / 2; - addButton(new ButtonBack( guiLeft + xSize / 6, guiTop, (btn)->{ + addButton(new ButtonBack(guiLeft + xSize / 6, guiTop, (btn) -> { minecraft.displayGuiScreen(parent); - },this)); - addButton(buttonNext = new ButtonNext( guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn)->{ + }, this)); + addButton(buttonNext = new ButtonNext(guiLeft + 4 * xSize / 6, guiTop + 5 * ySize / 6, (btn) -> { if (currentPage <= searchResults.size() - 1) currentPage++; - },this)); - addButton(buttonPrev = new ButtonPrev( guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn)->{ + }, this)); + addButton(buttonPrev = new ButtonPrev(guiLeft + xSize / 5, guiTop + 5 * ySize / 6, (btn) -> { if (currentPage > 0) currentPage--; - },this)); + }, this)); - searchField = new TextFieldWidget( font, guiLeft + 43, guiTop + 12, 100, 10,""); + searchField = new TextFieldWidget(font, guiLeft + 43, guiTop + 12, 100, 10, ""); searchField.setEnableBackgroundDrawing(false); searchField.changeFocus(true); searchResults = getMatches(book, null, player, bookStack); @@ -117,14 +117,14 @@ public void render(int mouseX, int mouseY, float partialTicks) { @Override public boolean mouseClicked(double mouseX, double mouseY, int typeofClick) { - if(!super.mouseClicked(mouseX, mouseY, typeofClick)){ + if (!super.mouseClicked(mouseX, mouseY, typeofClick)) { if (typeofClick == 1) { if (GuiHelper.isMouseBetween(mouseX, mouseY, searchField.x, searchField.y, searchField.getAdjustedWidth(), searchField.getHeight())) { searchField.setText(""); lastQuery = ""; searchResults = getMatches(book, "", player, bookStack); return true; - } else{ + } else { minecraft.displayGuiScreen(parent); return true; } @@ -145,27 +145,27 @@ public boolean mouseScrolled(double p_mouseScrolled_1_, double p_mouseScrolled_3 else if (movement > 0 && buttonPrev.visible && currentPage > 0) currentPage--; - return movement!=0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); + return movement != 0 || super.mouseScrolled(p_mouseScrolled_1_, p_mouseScrolled_3_, movement); } @Override public boolean keyPressed(int keyCode, int p_keyPressed_2_, int p_keyPressed_3_) { - if (!searchField.isFocused()){ + if (!searchField.isFocused()) { return super.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_); } if (keyCode == GLFW.GLFW_KEY_ESCAPE) searchField.changeFocus(false); - if(searchField.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_)) { + if (searchField.keyPressed(keyCode, p_keyPressed_2_, p_keyPressed_3_)) { this.updateSearch(); } return true; } - private void updateSearch(){ + private void updateSearch() { if (!searchField.getText().equalsIgnoreCase(lastQuery)) { lastQuery = searchField.getText(); searchResults = getMatches(book, searchField.getText(), player, bookStack); diff --git a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java index c4052f3d..e53c1633 100644 --- a/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java +++ b/src/main/java/amerifrance/guideapi/info/InfoRendererDescription.java @@ -15,7 +15,7 @@ import net.minecraft.world.World; import org.apache.commons.lang3.StringEscapeUtils; -import java.awt.Color; +import java.awt.*; import java.util.List; public class InfoRendererDescription implements IInfoRenderer { @@ -47,7 +47,7 @@ public void drawInformation(Book book, World world, BlockPos pos, BlockState sta for (String line : lines) { List cutLines = fontRenderer.listFormattedStringToWidth(line, 100 * scaleMulti); for (String cut : cutLines) { - fontRenderer.drawStringWithShadow(cut, (Minecraft.getInstance().mainWindow.getScaledWidth()/ 2 + 20) * scaleMulti, (((Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - 10) - y) * scaleMulti) + yOffset, Color.WHITE.getRGB()); + fontRenderer.drawStringWithShadow(cut, (Minecraft.getInstance().mainWindow.getScaledWidth() / 2 + 20) * scaleMulti, (((Minecraft.getInstance().mainWindow.getScaledHeight() / 2 - 10) - y) * scaleMulti) + yOffset, Color.WHITE.getRGB()); y -= 10 / scaleMulti; } } diff --git a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java index 60a5e80e..d6937422 100644 --- a/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java +++ b/src/main/java/amerifrance/guideapi/item/ItemGuideBook.java @@ -68,7 +68,7 @@ public ActionResult onItemRightClick(World world, PlayerEntity player ItemStack heldStack = player.getHeldItem(hand); //Only handle book client side - if(!world.isRemote())return ActionResult.newResult(ActionResultType.SUCCESS,heldStack); + if (!world.isRemote()) return ActionResult.newResult(ActionResultType.SUCCESS, heldStack); BookEvent.Open event = new BookEvent.Open(book, heldStack, player); @@ -76,7 +76,7 @@ public ActionResult onItemRightClick(World world, PlayerEntity player player.sendStatusMessage(event.getCanceledText(), true); return ActionResult.newResult(ActionResultType.FAIL, heldStack); } - GuideMod.PROXY.openGuidebook(player,world,book,heldStack); + GuideMod.PROXY.openGuidebook(player, world, book, heldStack); return ActionResult.newResult(ActionResultType.SUCCESS, heldStack); } @@ -90,7 +90,7 @@ public ActionResultType onItemUse(ItemUseContext context) { if (state.getBlock() instanceof IGuideLinked) { IGuideLinked guideLinked = (IGuideLinked) state.getBlock(); - ResourceLocation entryKey = guideLinked.getLinkedEntry(context.getWorld(), context.getPos(),context.getPlayer(), stack); + ResourceLocation entryKey = guideLinked.getLinkedEntry(context.getWorld(), context.getPos(), context.getPlayer(), stack); if (entryKey == null) return ActionResultType.FAIL; diff --git a/src/main/java/amerifrance/guideapi/network/PacketHandler.java b/src/main/java/amerifrance/guideapi/network/PacketHandler.java index 7ca012f6..e436da6b 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketHandler.java +++ b/src/main/java/amerifrance/guideapi/network/PacketHandler.java @@ -11,14 +11,13 @@ public class PacketHandler { private static byte packetId = 0; - public static SimpleChannel INSTANCE = NetworkRegistry.ChannelBuilder.named(new ResourceLocation(GuideMod.ID,"main")).clientAcceptedVersions(PROTOCOL_VERSION::equals).serverAcceptedVersions(PROTOCOL_VERSION::equals).networkProtocolVersion(()->PROTOCOL_VERSION).simpleChannel(); - + public static SimpleChannel INSTANCE = NetworkRegistry.ChannelBuilder.named(new ResourceLocation(GuideMod.ID, "main")).clientAcceptedVersions(PROTOCOL_VERSION::equals).serverAcceptedVersions(PROTOCOL_VERSION::equals).networkProtocolVersion(() -> PROTOCOL_VERSION).simpleChannel(); public static void registerPackets() { - INSTANCE.registerMessage(nextID(),PacketSyncEntry.class,PacketSyncEntry::encode,PacketSyncEntry::decode,PacketSyncEntry::handle); - INSTANCE.registerMessage(nextID(),PacketSyncCategory.class,PacketSyncCategory::encode,PacketSyncCategory::decode,PacketSyncCategory::handle); - INSTANCE.registerMessage(nextID(),PacketSyncHome.class,PacketSyncHome::encode,PacketSyncHome::decode,PacketSyncHome::handle); + INSTANCE.registerMessage(nextID(), PacketSyncEntry.class, PacketSyncEntry::encode, PacketSyncEntry::decode, PacketSyncEntry::handle); + INSTANCE.registerMessage(nextID(), PacketSyncCategory.class, PacketSyncCategory::encode, PacketSyncCategory::decode, PacketSyncCategory::handle); + INSTANCE.registerMessage(nextID(), PacketSyncHome.class, PacketSyncHome::encode, PacketSyncHome::decode, PacketSyncHome::handle); } protected static int nextID() { diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java index 822d0636..236b4351 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncCategory.java @@ -6,7 +6,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; - import net.minecraftforge.fml.network.NetworkEvent; import org.apache.commons.lang3.Validate; @@ -27,23 +26,23 @@ public PacketSyncCategory(int category, int page) { this.page = page; } - static void encode(PacketSyncCategory msg, PacketBuffer buf){ + static void encode(PacketSyncCategory msg, PacketBuffer buf) { buf.writeInt(msg.category); buf.writeInt(msg.page); } - static PacketSyncCategory decode(PacketBuffer buf){ - PacketSyncCategory msg=new PacketSyncCategory(); - msg.category=buf.readInt(); + static PacketSyncCategory decode(PacketBuffer buf) { + PacketSyncCategory msg = new PacketSyncCategory(); + msg.category = buf.readInt(); msg.page = buf.readInt(); return msg; } - public static void handle(final PacketSyncCategory msg, Supplier contextSupplier){ - final NetworkEvent.Context ctx=contextSupplier.get(); + public static void handle(final PacketSyncCategory msg, Supplier contextSupplier) { + final NetworkEvent.Context ctx = contextSupplier.get(); ServerPlayerEntity player = ctx.getSender(); Validate.notNull(player); - ctx.enqueueWork(()->{ + ctx.enqueueWork(() -> { ItemStack book = player.getHeldItemOffhand(); if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) book = player.getHeldItemMainhand(); diff --git a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java index 48ebfb7d..bf0af20a 100644 --- a/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java +++ b/src/main/java/amerifrance/guideapi/network/PacketSyncEntry.java @@ -12,7 +12,7 @@ import java.util.function.Supplier; -public class PacketSyncEntry{ +public class PacketSyncEntry { public int category; public ResourceLocation entry; @@ -30,25 +30,25 @@ public PacketSyncEntry(int category, ResourceLocation entry, int page) { this.page = page; } - static void encode(PacketSyncEntry msg, PacketBuffer buf){ + static void encode(PacketSyncEntry msg, PacketBuffer buf) { buf.writeInt(msg.category); buf.writeResourceLocation(msg.entry); buf.writeInt(msg.page); } - static PacketSyncEntry decode(PacketBuffer buf){ - PacketSyncEntry msg=new PacketSyncEntry(); - msg.category=buf.readInt(); - msg.entry=buf.readResourceLocation(); + static PacketSyncEntry decode(PacketBuffer buf) { + PacketSyncEntry msg = new PacketSyncEntry(); + msg.category = buf.readInt(); + msg.entry = buf.readResourceLocation(); msg.page = buf.readInt(); return msg; } - public static void handle(final PacketSyncEntry msg, Supplier contextSupplier){ - final NetworkEvent.Context ctx=contextSupplier.get(); + public static void handle(final PacketSyncEntry msg, Supplier contextSupplier) { + final NetworkEvent.Context ctx = contextSupplier.get(); ServerPlayerEntity player = ctx.getSender(); Validate.notNull(player); - ctx.enqueueWork(()->{ + ctx.enqueueWork(() -> { ItemStack book = player.getHeldItemOffhand(); if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) book = player.getHeldItemMainhand(); @@ -68,6 +68,4 @@ public static void handle(final PacketSyncEntry msg, Supplier contextSupplier){ - final NetworkEvent.Context ctx=contextSupplier.get(); + public static void handle(final PacketSyncHome msg, Supplier contextSupplier) { + final NetworkEvent.Context ctx = contextSupplier.get(); ServerPlayerEntity player = ctx.getSender(); Validate.notNull(player); - ctx.enqueueWork(()->{ + ctx.enqueueWork(() -> { ItemStack book = player.getHeldItemOffhand(); if (book.isEmpty() || !(book.getItem() instanceof IGuideItem)) book = player.getHeldItemMainhand(); diff --git a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java index d9e4d4b4..4faa05b9 100644 --- a/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageBrewingRecipe.java @@ -1,6 +1,5 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.IRecipeRenderer; import amerifrance.guideapi.api.SubTexture; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.Page; @@ -11,7 +10,6 @@ import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.block.Blocks; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -24,8 +22,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Optional; -import java.util.Random; public class PageBrewingRecipe extends Page { @@ -80,7 +76,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int //start input int finalX = x; int finalY = y; - cycler.getCycledIngredientStack(ingredient,0).ifPresent(stack -> { + cycler.getCycledIngredientStack(ingredient, 0).ifPresent(stack -> { GuiHelper.drawItemStack(stack, finalX, finalY); }); diff --git a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java index 321b009c..924f3e52 100644 --- a/src/main/java/amerifrance/guideapi/page/PageIRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageIRecipe.java @@ -1,14 +1,14 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.api.util.IngredientCycler; -import amerifrance.guideapi.page.reciperenderer.FurnaceRecipeRenderer; import amerifrance.guideapi.api.IRecipeRenderer; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.Page; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.gui.BaseScreen; import amerifrance.guideapi.gui.EntryScreen; +import amerifrance.guideapi.page.reciperenderer.FurnaceRecipeRenderer; import amerifrance.guideapi.page.reciperenderer.ShapedRecipesRenderer; import amerifrance.guideapi.page.reciperenderer.ShapelessRecipesRenderer; import amerifrance.guideapi.util.LogHelper; @@ -31,6 +31,7 @@ public class PageIRecipe extends Page { public IRecipeRenderer iRecipeRenderer; protected boolean isValid; private IngredientCycler ingredientCycler = new IngredientCycler(); + /** * Use this if you are creating a page for a standard recipe, one of: *

@@ -59,17 +60,17 @@ public PageIRecipe(IRecipe recipe, IRecipeRenderer iRecipeRenderer) { @Override @OnlyIn(Dist.CLIENT) public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - if(isValid) { + if (isValid) { super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); ingredientCycler.tick(guiBase.getMinecraft()); - iRecipeRenderer.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj,ingredientCycler); + iRecipeRenderer.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj, ingredientCycler); } } @Override @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { - if(isValid) { + if (isValid) { super.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); iRecipeRenderer.drawExtras(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj); } @@ -90,10 +91,9 @@ public static IRecipeRenderer getRenderer(IRecipe recipe) { return new ShapedRecipesRenderer((ShapedRecipe) recipe); } else if (recipe instanceof ShapelessRecipe) { return new ShapelessRecipesRenderer((ShapelessRecipe) recipe); - } else if(recipe instanceof FurnaceRecipe){ - return new FurnaceRecipeRenderer((FurnaceRecipe)recipe); - } - else { + } else if (recipe instanceof FurnaceRecipe) { + return new FurnaceRecipeRenderer((FurnaceRecipe) recipe); + } else { return null; } } diff --git a/src/main/java/amerifrance/guideapi/page/PageItemStack.java b/src/main/java/amerifrance/guideapi/page/PageItemStack.java index f7af0eaa..68837971 100644 --- a/src/main/java/amerifrance/guideapi/page/PageItemStack.java +++ b/src/main/java/amerifrance/guideapi/page/PageItemStack.java @@ -20,16 +20,17 @@ public class PageItemStack extends PageText { private IngredientCycler ingredientCycler = new IngredientCycler(); - public PageItemStack(String draw, Ingredient ingredient){ - super(draw,60); - this.ingredient=ingredient; + public PageItemStack(String draw, Ingredient ingredient) { + super(draw, 60); + this.ingredient = ingredient; } + /** - * @param draw - Unlocalized text to draw + * @param draw - Unlocalized text to draw * @param ingredient - ItemStack to render */ public PageItemStack(String draw, ItemStack ingredient) { - this(draw,Ingredient.fromStacks(ingredient)); + this(draw, Ingredient.fromStacks(ingredient)); } /** @@ -53,7 +54,7 @@ public PageItemStack(String draw, Block block) { @OnlyIn(Dist.CLIENT) public void drawExtras(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, BaseScreen guiBase, FontRenderer fontRendererObj) { ingredientCycler.tick(guiBase.getMinecraft()); - ingredientCycler.getCycledIngredientStack(ingredient,0).ifPresent(stack -> { + ingredientCycler.getCycledIngredientStack(ingredient, 0).ifPresent(stack -> { GuiHelper.drawScaledItemStack(stack, guiLeft + 101, guiTop + 20, 3); }); } diff --git a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java index cc126ba2..7a5530ec 100644 --- a/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java +++ b/src/main/java/amerifrance/guideapi/page/PageJsonRecipe.java @@ -1,11 +1,11 @@ package amerifrance.guideapi.page; -import amerifrance.guideapi.gui.EntryScreen; -import amerifrance.guideapi.util.LogHelper; import amerifrance.guideapi.api.IRecipeRenderer; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; +import amerifrance.guideapi.gui.EntryScreen; +import amerifrance.guideapi.util.LogHelper; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -16,39 +16,37 @@ import javax.annotation.Nonnull; import java.util.function.Function; -import java.util.function.Supplier; public class PageJsonRecipe extends PageIRecipe { @Nonnull private final ResourceLocation recipeId; @Nonnull - private final Function,IRecipeRenderer> recipeRendererSupplier; + private final Function, IRecipeRenderer> recipeRendererSupplier; public PageJsonRecipe(ResourceLocation recipeId) { - this(recipeId,PageIRecipe::getRenderer); + this(recipeId, PageIRecipe::getRenderer); } - public PageJsonRecipe(ResourceLocation recipeId, Function,IRecipeRenderer> rendererSupplier){ - super(null,null); + public PageJsonRecipe(ResourceLocation recipeId, Function, IRecipeRenderer> rendererSupplier) { + super(null, null); this.recipeId = recipeId; - this.recipeRendererSupplier=rendererSupplier; + this.recipeRendererSupplier = rendererSupplier; } @OnlyIn(Dist.CLIENT) @Override public void onInit(Book book, CategoryAbstract category, EntryAbstract entry, PlayerEntity player, ItemStack bookStack, EntryScreen guiEntry) { super.onInit(book, category, entry, player, bookStack, guiEntry); - if(recipe==null){ - this.recipe = Minecraft.getInstance().getConnection() ==null ? null : Minecraft.getInstance().getConnection().getRecipeManager().getRecipe(recipeId).orElse(null); - if(recipe==null){ - LogHelper.error("Cannot find recipe "+recipeId.toString()); - } - else{ - if(iRecipeRenderer==null){ + if (recipe == null) { + this.recipe = Minecraft.getInstance().getConnection() == null ? null : Minecraft.getInstance().getConnection().getRecipeManager().getRecipe(recipeId).orElse(null); + if (recipe == null) { + LogHelper.error("Cannot find recipe " + recipeId.toString()); + } else { + if (iRecipeRenderer == null) { iRecipeRenderer = recipeRendererSupplier.apply(recipe); - if(iRecipeRenderer==null){ - LogHelper.error("Did not get renderer for recipe type "+recipe.getClass().toString()+" for recipe "+recipeId.toString()); + if (iRecipeRenderer == null) { + LogHelper.error("Did not get renderer for recipe type " + recipe.getClass().toString() + " for recipe " + recipeId.toString()); } } } diff --git a/src/main/java/amerifrance/guideapi/page/PageText.java b/src/main/java/amerifrance/guideapi/page/PageText.java index 18d1ce5c..a6a90f25 100644 --- a/src/main/java/amerifrance/guideapi/page/PageText.java +++ b/src/main/java/amerifrance/guideapi/page/PageText.java @@ -7,7 +7,6 @@ import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.resources.I18n; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.ForgeI18n; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java index 915e8598..1d13ace4 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/CraftingRecipeRenderer.java @@ -10,14 +10,9 @@ import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import com.google.common.base.Strings; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; - -import java.util.Optional; -import java.util.Random; public abstract class CraftingRecipeRenderer> extends RecipeRendererBase { diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java index 6f939a6a..82244ab9 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/FurnaceRecipeRenderer.java @@ -15,7 +15,6 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.text.ITextComponent; -import java.util.ArrayList; import java.util.List; @@ -34,7 +33,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int y = guiTop + 77; Ingredient input = recipe.getIngredients().get(0); - cycler.getCycledIngredientStack(input,0).ifPresent(stack -> { + cycler.getCycledIngredientStack(input, 0).ifPresent(stack -> { GuiHelper.drawItemStack(stack, x, y); List tooltip = null; @@ -43,7 +42,6 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int }); - ItemStack output = recipe.getRecipeOutput(); int x2 = guiLeft + 135; diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java index b9e9d614..dbfebefc 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapedRecipesRenderer.java @@ -7,13 +7,9 @@ import amerifrance.guideapi.api.util.IngredientCycler; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; -import java.util.Arrays; -import java.util.List; - public class ShapedRecipesRenderer extends CraftingRecipeRenderer { public ShapedRecipesRenderer(ShapedRecipe recipe) { @@ -25,12 +21,12 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int super.draw(book, category, entry, guiLeft, guiTop, mouseX, mouseY, guiBase, fontRendererObj, cycler); for (int y = 0; y < recipe.getRecipeHeight(); y++) { for (int x = 0; x < recipe.getRecipeWidth(); x++) { - int i = y*recipe.getRecipeWidth()+x; + int i = y * recipe.getRecipeWidth() + x; int stackX = (x + 1) * 17 + (guiLeft + 53) + x; int stackY = (y + 1) * 17 + (guiTop + 38) + y; Ingredient ingredient = recipe.getIngredients().get(i); - cycler.getCycledIngredientStack(ingredient,i).ifPresent(stack -> { + cycler.getCycledIngredientStack(ingredient, i).ifPresent(stack -> { GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); diff --git a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java index 6903519a..a6e456b9 100644 --- a/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java +++ b/src/main/java/amerifrance/guideapi/page/reciperenderer/ShapelessRecipesRenderer.java @@ -8,13 +8,9 @@ import amerifrance.guideapi.api.util.TextHelper; import amerifrance.guideapi.gui.BaseScreen; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapelessRecipe; -import java.util.Arrays; -import java.util.List; - public class ShapelessRecipesRenderer extends CraftingRecipeRenderer { public ShapelessRecipesRenderer(ShapelessRecipe recipe) { @@ -31,7 +27,7 @@ public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int int stackY = (y + 1) * 17 + (guiTop + 38) + y; if (i < recipe.getIngredients().size()) { Ingredient ingredient = recipe.getIngredients().get(i); - cycler.getCycledIngredientStack(ingredient,i).ifPresent(stack -> { + cycler.getCycledIngredientStack(ingredient, i).ifPresent(stack -> { GuiHelper.drawItemStack(stack, stackX, stackY); if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) tooltips = GuiHelper.getTooltip(stack); diff --git a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java index 0c5f7a22..38655c6f 100644 --- a/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/ClientProxy.java @@ -1,15 +1,15 @@ package amerifrance.guideapi.proxy; -import amerifrance.guideapi.gui.CategoryScreen; -import amerifrance.guideapi.gui.HomeScreen; import amerifrance.guideapi.api.BookEvent; import amerifrance.guideapi.api.GuideAPI; import amerifrance.guideapi.api.IGuideItem; import amerifrance.guideapi.api.impl.Book; import amerifrance.guideapi.api.impl.abstraction.CategoryAbstract; import amerifrance.guideapi.api.impl.abstraction.EntryAbstract; -import amerifrance.guideapi.gui.EntryScreen; import amerifrance.guideapi.api.util.NBTBookTags; +import amerifrance.guideapi.gui.CategoryScreen; +import amerifrance.guideapi.gui.EntryScreen; +import amerifrance.guideapi.gui.HomeScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SimpleSound; import net.minecraft.entity.player.PlayerEntity; @@ -24,7 +24,7 @@ public class ClientProxy extends CommonProxy { @Override public void playSound(SoundEvent sound) { - Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(sound,1)); + Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(sound, 1)); } @Override @@ -64,20 +64,20 @@ public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack int pageNumber = tagCompound.getInt(NBTBookTags.PAGE_TAG); EntryScreen guiEntry = new EntryScreen(book, category, entry, player, bookStack); guiEntry.pageNumber = pageNumber; - Minecraft.getInstance().displayGuiScreen( guiEntry); + Minecraft.getInstance().displayGuiScreen(guiEntry); return; } else if (tagCompound.contains(NBTBookTags.CATEGORY_TAG)) { CategoryAbstract category = book.getCategoryList().get(tagCompound.getInt(NBTBookTags.CATEGORY_TAG)); int entryPage = tagCompound.getInt(NBTBookTags.ENTRY_PAGE_TAG); CategoryScreen guiCategory = new CategoryScreen(book, category, player, bookStack, null); guiCategory.entryPage = entryPage; - Minecraft.getInstance().displayGuiScreen( guiCategory); + Minecraft.getInstance().displayGuiScreen(guiCategory); return; } else { int categoryNumber = tagCompound.getInt(NBTBookTags.CATEGORY_PAGE_TAG); HomeScreen guiHome = new HomeScreen(book, player, bookStack); guiHome.categoryPage = categoryNumber; - Minecraft.getInstance().displayGuiScreen( guiHome); + Minecraft.getInstance().displayGuiScreen(guiHome); return; } } diff --git a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java index 575b329d..e3f34384 100644 --- a/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java +++ b/src/main/java/amerifrance/guideapi/proxy/CommonProxy.java @@ -11,7 +11,7 @@ public class CommonProxy { - public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack bookStack){ + public void openGuidebook(PlayerEntity player, World world, Book book, ItemStack bookStack) { } public void playSound(SoundEvent sound) { diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index bf6b0473..ccc6a591 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -16,20 +16,16 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import net.minecraft.block.Blocks; -import net.minecraft.item.Items; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.Tags; -import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.awt.Color; +import java.awt.*; import java.util.List; import java.util.Map; @@ -41,12 +37,12 @@ public class TestBook implements IGuideBook { @Nullable @Override public Book buildBook() { - BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book")); + BookBinder binder = new BookBinder(new ResourceLocation("guideapi", "test_book")); binder.setAuthor("TehNut").setColor(Color.PINK).setItemName("Display Name").setHeader("Hello there").setGuideTitle("Title message").setSpawnWithBook().setContentProvider(this::buildContent); return (book = binder.build()); } - private void buildContent(List categories){ + private void buildContent(List categories) { Map entries = Maps.newHashMap(); @@ -54,20 +50,19 @@ private void buildContent(List categories){ pages.add(new PageText("Hello, this is\nsome text with a new line.")); pages.add(new PageText("Hello, this is some text without a new line. It is long so it should probably be automaticall wrapped")); pages.addAll(PageHelper.pagesForLongText("Hello, this is some text. It is very long so it should be split across multiple pages. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.")); - pages.addAll(PageHelper.pagesForLongText("Hello, this is some text. It is very long so it should be split across multiple pages. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",Items.COAL_BLOCK)); + pages.addAll(PageHelper.pagesForLongText("Hello, this is some text. It is very long so it should be split across multiple pages. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", Items.COAL_BLOCK)); - pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stone"))); - pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","charcoal"))); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "stone"))); + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "charcoal"))); - pages.add(new PageJsonRecipe(new ResourceLocation("minecraft","stick"),recipe -> recipe instanceof ShapedRecipe ? new ShapedRecipesRenderer((ShapedRecipe) recipe) : null)); //Probably want to use your own method as render supplier and print proper logs + pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "stick"), recipe -> recipe instanceof ShapedRecipe ? new ShapedRecipesRenderer((ShapedRecipe) recipe) : null)); //Probably want to use your own method as render supplier and print proper logs - pages.add(new PageIRecipe(new ShapedRecipe(new ResourceLocation("guideapi","test11"), "test",1,1,NonNullList.from(Ingredient.EMPTY,Ingredient.fromStacks(new ItemStack(Items.PUMPKIN))),new ItemStack(Blocks.OAK_LOG)))); + pages.add(new PageIRecipe(new ShapedRecipe(new ResourceLocation("guideapi", "test11"), "test", 1, 1, NonNullList.from(Ingredient.EMPTY, Ingredient.fromStacks(new ItemStack(Items.PUMPKIN))), new ItemStack(Blocks.OAK_LOG)))); pages.add(new PageJsonRecipe(new ResourceLocation("minecraft", "acacia_fence"))); - pages.add(new PageItemStack("These are all logs",Ingredient.fromTag(ItemTags.LOGS))); - pages.add(new PageTextImage("guideapi.test.string",new ResourceLocation("guideapi","textures/gui/testimage.png"),true)); - pages.add(new PageTextImage("guideapi.test.string",new ResourceLocation("guideapi","textures/gui/testimage.png"),false)); - pages.add(new PageImage(new ResourceLocation("guideapi","textures/gui/testimage.png"))); - + pages.add(new PageItemStack("These are all logs", Ingredient.fromTag(ItemTags.LOGS))); + pages.add(new PageTextImage("guideapi.test.string", new ResourceLocation("guideapi", "textures/gui/testimage.png"), true)); + pages.add(new PageTextImage("guideapi.test.string", new ResourceLocation("guideapi", "textures/gui/testimage.png"), false)); + pages.add(new PageImage(new ResourceLocation("guideapi", "textures/gui/testimage.png"))); Entry entry = new EntryItemStack(pages, "guideapi.test.entry", new ItemStack(Items.POTATO)); diff --git a/src/main/java/amerifrance/guideapi/test/TestBook2.java b/src/main/java/amerifrance/guideapi/test/TestBook2.java index 4d6c61ab..217f96b2 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook2.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook2.java @@ -8,22 +8,19 @@ import amerifrance.guideapi.api.util.PageHelper; import amerifrance.guideapi.category.CategoryItemStack; import amerifrance.guideapi.entry.EntryItemStack; -import amerifrance.guideapi.page.*; +import amerifrance.guideapi.page.PageBrewingRecipe; +import amerifrance.guideapi.page.PageJsonRecipe; +import amerifrance.guideapi.page.PageText; +import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.potion.Potions; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.potion.PotionUtils; -import net.minecraft.util.NonNullList; +import net.minecraft.potion.Potions; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.Tags; import net.minecraftforge.common.brewing.BrewingRecipe; -import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.awt.Color; +import java.awt.*; import java.util.List; @GuideBook @@ -34,9 +31,8 @@ public class TestBook2 implements IGuideBook { @Nullable @Override public Book buildBook() { - BookBinder binder = new BookBinder(new ResourceLocation("guideapi","test_book2")); - binder.setAuthor("TehNut").setColor(new Color(80,50,5)).setItemName("Display Name").setHeader("Hello there").setSpawnWithBook().setGuideTitle("Title message").setContentProvider(this::buildContent); - + BookBinder binder = new BookBinder(new ResourceLocation("guideapi", "test_book2")); + binder.setAuthor("TehNut").setColor(new Color(80, 50, 5)).setItemName("Display Name").setHeader("Hello there").setSpawnWithBook().setGuideTitle("Title message").setContentProvider(this::buildContent); return (book = binder.build()); @@ -48,12 +44,12 @@ private void buildContent(List categories) { testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text")); //testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE)); //testCategory.getEntry("entry").addPage(PageIRecipe.newShaped(new ItemStack(Items.ACACIA_BOAT), "X X", "XXX", 'X', new ItemStack(Blocks.ACACIA_PLANKS, 1, 4))); - testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)),Ingredient.fromStacks( new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) + testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)), Ingredient.fromStacks(new ItemStack(Items.GLISTERING_MELON_SLICE)), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.HEALING))) ); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("bread"))); testCategory.getEntry("entry").addPage(new PageJsonRecipe(new ResourceLocation("redstone"))); testCategory.getEntry("entry").addPageList(PageHelper.pagesForLongText("guideapi.test.format")); - testCategory.addEntry("unicode",new EntryItemStack("Творческая книга",new ItemStack(Items.BEEF))); + testCategory.addEntry("unicode", new EntryItemStack("Творческая книга", new ItemStack(Items.BEEF))); testCategory.getEntry("unicode").addPage(new PageText("Творческая книга \u0F06")); categories.add(testCategory); } diff --git a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java index f8abba35..e118c81c 100644 --- a/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java +++ b/src/main/java/amerifrance/guideapi/util/AnnotationHandler.java @@ -7,7 +7,6 @@ import com.google.common.collect.Lists; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.ModList; - import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.commons.lang3.tuple.Pair; import org.objectweb.asm.Type; @@ -31,13 +30,12 @@ public static void gatherBooks() { .collect(Collectors.toList()); - for (EventPriority priority : EventPriority.values()) - for(ModFileScanData.AnnotationData data: annotations){ - try{ + for (ModFileScanData.AnnotationData data : annotations) { + try { - EventPriority priority1 = (EventPriority) data.getAnnotationData().getOrDefault("priority",EventPriority.NORMAL); - if(priority!=priority1)continue; + EventPriority priority1 = (EventPriority) data.getAnnotationData().getOrDefault("priority", EventPriority.NORMAL); + if (priority != priority1) continue; Class genericClass = Class.forName(data.getClassType().getClassName()); if (!IGuideBook.class.isAssignableFrom(genericClass)) continue; @@ -48,7 +46,7 @@ public static void gatherBooks() { APISetter.registerBook(book); BOOK_CLASSES.add(Pair.of(book, guideBook)); - }catch (Exception e) { + } catch (Exception e) { LogHelper.error("Error registering book for class " + data.getClassType().getClassName()); e.printStackTrace(); } diff --git a/src/main/java/amerifrance/guideapi/util/EventHandler.java b/src/main/java/amerifrance/guideapi/util/EventHandler.java index 03a21479..9ba3e27a 100644 --- a/src/main/java/amerifrance/guideapi/util/EventHandler.java +++ b/src/main/java/amerifrance/guideapi/util/EventHandler.java @@ -47,7 +47,7 @@ public static void onPlayerJoinWorld(EntityJoinWorldEvent event) { if (GuideConfig.COMMON.canSpawnWithBook.get()) { for (Book book : GuideAPI.getBooks().values()) { ForgeConfigSpec.BooleanValue bookSpawnConfig = GuideConfig.COMMON.SPAWN_BOOKS.get(book); - if((bookSpawnConfig==null||bookSpawnConfig.get()) && !tag.getBoolean("hasInitial" + book.getRegistryName().toString())){ + if ((bookSpawnConfig == null || bookSpawnConfig.get()) && !tag.getBoolean("hasInitial" + book.getRegistryName().toString())) { ItemHandlerHelper.giveItemToPlayer(player, GuideAPI.getStackFromBook(book)); tag.putBoolean("hasInitial" + book.getRegistryName().toString(), true); } @@ -81,7 +81,7 @@ public static void renderOverlay(RenderGameOverlayEvent.Pre event) { if (book == null) return; - BlockPos rayTracePos=((BlockRayTraceResult)rayTrace).getPos(); + BlockPos rayTracePos = ((BlockRayTraceResult) rayTrace).getPos(); BlockState state = world.getBlockState(rayTracePos); String linkedEntry = null; if (state.getBlock() instanceof IGuideLinked) { diff --git a/src/main/java/amerifrance/guideapi/util/ReloadCommand.java b/src/main/java/amerifrance/guideapi/util/ReloadCommand.java index a37d28b8..65091291 100644 --- a/src/main/java/amerifrance/guideapi/util/ReloadCommand.java +++ b/src/main/java/amerifrance/guideapi/util/ReloadCommand.java @@ -3,21 +3,15 @@ import amerifrance.guideapi.api.GuideAPI; import amerifrance.guideapi.api.impl.Book; import com.mojang.brigadier.LiteralMessage; -import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; -import net.minecraft.command.ISuggestionProvider; import net.minecraft.command.arguments.ResourceLocationArgument; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.common.thread.EffectiveSide; import net.minecraftforge.fml.loading.FMLEnvironment; /** @@ -26,23 +20,23 @@ */ public class ReloadCommand { - private static final DynamicCommandExceptionType BOOK_NOT_FOUND = new DynamicCommandExceptionType((id) -> new StringTextComponent("Book with registry id "+ id+ " not found")); + private static final DynamicCommandExceptionType BOOK_NOT_FOUND = new DynamicCommandExceptionType((id) -> new StringTextComponent("Book with registry id " + id + " not found")); private static final SimpleCommandExceptionType NOT_CLIENT = new SimpleCommandExceptionType(new LiteralMessage("This command can only be used in singleplayer")); public static ArgumentBuilder register() { return Commands.literal("reload") .then(Commands.argument("bookid", ResourceLocationArgument.resourceLocation()).executes((context) -> { - if(FMLEnvironment.dist != Dist.CLIENT){ + if (FMLEnvironment.dist != Dist.CLIENT) { throw NOT_CLIENT.create(); } - ResourceLocation id = ResourceLocationArgument.getResourceLocation(context,"bookid"); + ResourceLocation id = ResourceLocationArgument.getResourceLocation(context, "bookid"); Book b = GuideAPI.getBooks().get(id); - if(b == null){ + if (b == null) { throw BOOK_NOT_FOUND.create(id.toString()); } b.forceInitializeContent(); return 0; - })); + })); } } diff --git a/src/main/resources/assets/guideapi/lang/de_de.json b/src/main/resources/assets/guideapi/lang/de_de.json index dd010fa2..cc29684b 100644 --- a/src/main/resources/assets/guideapi/lang/de_de.json +++ b/src/main/resources/assets/guideapi/lang/de_de.json @@ -1,13 +1,11 @@ { "_comment": "Item", "item.guideapi.book": "Handbuch", - "_comment": "Button hovering text", "guideapi.button.back": "Zurück", "guideapi.button.next": "Nächste", "guideapi.button.prev": "Vorherige", "guideapi.button.search": "Suche", - "_comment": "Text to draw", "guideapi.text.crafting.shaped": "Crafting", "guideapi.text.crafting.shapeless": "Formloses Crafting", diff --git a/src/main/resources/assets/guideapi/lang/en_us.json b/src/main/resources/assets/guideapi/lang/en_us.json index 894e48a5..344ace5d 100644 --- a/src/main/resources/assets/guideapi/lang/en_us.json +++ b/src/main/resources/assets/guideapi/lang/en_us.json @@ -1,13 +1,11 @@ { "_comment": "Item", "item.guideapi.book": "Guide Book", - "_comment": "Button hovering text", "guideapi.button.back": "Back", "guideapi.button.next": "Next", "guideapi.button.prev": "Previous", "guideapi.button.search": "Search", - "_comment": "Text to draw", "guideapi.text.crafting.shaped": "Shaped Crafting", "guideapi.text.crafting.shapeless": "Shapeless Crafting", @@ -15,13 +13,11 @@ "guideapi.text.linked.open": "Sneak + Use to open", "guideapi.text.brewing.brew": "Brewing", "guidepai.text.brewing.error": "&cError in the recipe", - "_comment": "Test", "guideapi.test.format": "This i\\ns a formatting\\n\\ttest", "guideapi.test.category": "Test Category", "guideapi.test.entry": "Test Entry which is very very very long", "guideapi.test.string": "Some translated content string", - "_comment": "Unused", "text.furnace.error": "&cError in the recipe", "text.book.warning": "&c[WARNING] Delete this item, it has no associated book!", diff --git a/src/main/resources/assets/guideapi/lang/ru_ru.json b/src/main/resources/assets/guideapi/lang/ru_ru.json index 7ec19e7b..8b891b1e 100644 --- a/src/main/resources/assets/guideapi/lang/ru_ru.json +++ b/src/main/resources/assets/guideapi/lang/ru_ru.json @@ -1,12 +1,10 @@ { "_comment": "Item", "item.guideapi.book": "Стандартная книга Guide-API", - "_comment": "Button hovering text", "guideapi.button.back": "Назад", "guideapi.button.next": "След.", "guideapi.button.prev": "Пред.", - "_comment": "Text to draw", "guideapi.text.crafting.shaped": "Форменное создание", "guideapi.text.crafting.shapeless": "Бесформенное создание", diff --git a/src/main/resources/assets/guideapi/lang/zh_cn.json b/src/main/resources/assets/guideapi/lang/zh_cn.json index b53e2544..4aeaa0bc 100644 --- a/src/main/resources/assets/guideapi/lang/zh_cn.json +++ b/src/main/resources/assets/guideapi/lang/zh_cn.json @@ -1,12 +1,10 @@ { "_comment": "Item", "item.guideapi.book": "Guide-API 默认书", - "_comment": "Button hovering text", "guideapi.button.back": "返回", "guideapi.button.next": "下一页", "guideapi.button.prev": "上一页", - "_comment": "Text to draw", "guideapi.text.crafting.shaped": "普通配方", "guideapi.text.crafting.shapeless": "无形配方", diff --git a/src/main/resources/assets/guideapi/models/item/guidebook.json b/src/main/resources/assets/guideapi/models/item/guidebook.json index 0cd9effb..c1ece281 100644 --- a/src/main/resources/assets/guideapi/models/item/guidebook.json +++ b/src/main/resources/assets/guideapi/models/item/guidebook.json @@ -1,14 +1,26 @@ { - "parent":"item/generated", + "parent": "item/generated", "textures": { "layer0": "guideapi:items/book_base", "layer1": "guideapi:items/book_page" }, "display": { "firstperson_lefthand": { - "rotation": [ 0, 90, -25 ], - "translation": [ 1.13, 3.2, 1.13 ], - "scale": [ 0.68, 0.68, 0.68 ] + "rotation": [ + 0, + 90, + -25 + ], + "translation": [ + 1.13, + 3.2, + 1.13 + ], + "scale": [ + 0.68, + 0.68, + 0.68 + ] } } } \ No newline at end of file From 192f2edcdfff551458553d8091adada34360b97f Mon Sep 17 00:00:00 2001 From: maxanier Date: Thu, 9 Apr 2020 00:02:50 +0200 Subject: [PATCH 24/28] Include #35 and #104 --- src/main/resources/assets/guideapi/lang/ru_ru.json | 4 ++++ src/main/resources/assets/guideapi/lang/zh_cn.json | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/guideapi/lang/ru_ru.json b/src/main/resources/assets/guideapi/lang/ru_ru.json index 8b891b1e..d4507047 100644 --- a/src/main/resources/assets/guideapi/lang/ru_ru.json +++ b/src/main/resources/assets/guideapi/lang/ru_ru.json @@ -5,10 +5,14 @@ "guideapi.button.back": "Назад", "guideapi.button.next": "След.", "guideapi.button.prev": "Пред.", + "guideapi.button.search":"Поиск", "_comment": "Text to draw", "guideapi.text.crafting.shaped": "Форменное создание", "guideapi.text.crafting.shapeless": "Бесформенное создание", "guideapi.text.furnace.smelting": "Плавка", + "guideapi.text.linked.open": "Шифт + ПКМ, чтобы открыть", + "guideapi.text.brewing.brew": "зельеварение", + "guidepai.text.brewing.error": "&cОшибка в рецепте", "text.furnace.error": "&cОшибка в рецепте", "text.book.warning": "&c[ВНИМАНИЕ] Выкиньте этот предмет, у него нет связанной книги!", "text.book.creative": "Творческая книга", diff --git a/src/main/resources/assets/guideapi/lang/zh_cn.json b/src/main/resources/assets/guideapi/lang/zh_cn.json index 4aeaa0bc..d066dd99 100644 --- a/src/main/resources/assets/guideapi/lang/zh_cn.json +++ b/src/main/resources/assets/guideapi/lang/zh_cn.json @@ -6,9 +6,9 @@ "guideapi.button.next": "下一页", "guideapi.button.prev": "上一页", "_comment": "Text to draw", - "guideapi.text.crafting.shaped": "普通配方", + "guideapi.text.crafting.shaped": "有序合成", "guideapi.text.crafting.shapeless": "无形配方", - "guideapi.text.furnace.smelting": "冶炼", + "guideapi.text.furnace.smelting": "烧炼", "text.furnace.error": "&c合成配方出错", "text.book.warning": "&c[警告] 删除这个物品, 它没有关联的书!", "text.book.creative": "创造模式书本", From 51e329de6c29e2761ff406d65408f3066ea273b9 Mon Sep 17 00:00:00 2001 From: maxanier Date: Thu, 9 Apr 2020 00:20:18 +0200 Subject: [PATCH 25/28] Removed unused customModel book property --- .../java/amerifrance/guideapi/api/impl/Book.java | 9 +-------- .../amerifrance/guideapi/api/impl/BookBinder.java | 15 +-------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/api/impl/Book.java b/src/main/java/amerifrance/guideapi/api/impl/Book.java index f6a6af21..6f0e88e8 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/Book.java +++ b/src/main/java/amerifrance/guideapi/api/impl/Book.java @@ -22,7 +22,6 @@ public class Book { private final String author; private final ResourceLocation pageTexture; private final ResourceLocation outlineTexture; - private final boolean customModel; private final Color color; private final boolean spawnWithBook; private final ResourceLocation registryName; @@ -30,7 +29,7 @@ public class Book { private boolean isInitialized; - protected Book(Consumer> contentProvider, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, boolean customModel, Color color, boolean spawnWithBook, ResourceLocation registryName, ItemGroup creativeTab) { + protected Book(Consumer> contentProvider, String title, String header, String displayName, String author, ResourceLocation pageTexture, ResourceLocation outlineTexture, Color color, boolean spawnWithBook, ResourceLocation registryName, ItemGroup creativeTab) { this.contentProvider = contentProvider; this.title = title; this.header = header; @@ -38,7 +37,6 @@ protected Book(Consumer> contentProvider, String title, S this.author = author; this.pageTexture = pageTexture; this.outlineTexture = outlineTexture; - this.customModel = customModel; this.color = color; this.spawnWithBook = spawnWithBook; this.registryName = registryName; @@ -92,10 +90,6 @@ public ResourceLocation getOutlineTexture() { return this.outlineTexture; } - public boolean hasCustomModel() { - return this.customModel; - } - public Color getColor() { return this.color; } @@ -123,7 +117,6 @@ public String toString() { .append("author", author) .append("pageTexture", pageTexture) .append("outlineTexture", outlineTexture) - .append("customModel", customModel) .append("color", color) .append("spawnWithBook", spawnWithBook) .append("registryName", registryName) diff --git a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java index 090903bb..2649bec4 100644 --- a/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java +++ b/src/main/java/amerifrance/guideapi/api/impl/BookBinder.java @@ -22,7 +22,6 @@ public class BookBinder { private String author; private ResourceLocation pageTexture = new ResourceLocation("guideapi", "textures/gui/book_colored.png"); private ResourceLocation outlineTexture = new ResourceLocation("guideapi", "textures/gui/book_greyscale.png"); - private boolean hasCustomModel; private Color color = new Color(171, 70, 30); private boolean spawnWithBook; private ItemGroup creativeTab = ItemGroup.MISC; @@ -128,18 +127,6 @@ public BookBinder setOutlineTexture(ResourceLocation outlineTexture) { return this; } - /** - * Indicates that the item containing this book has a custom model that you will manually register. - *

- * By default, a generic book model will be registered and colored with {@link #color}. - * - * @return the builder instance for chaining. - */ - public BookBinder setHasCustomModel() { - this.hasCustomModel = true; - return this; - } - /** * Sets the color to overlay on the book model and GUI border. *

@@ -209,6 +196,6 @@ public Book build() { throw new IllegalStateException("Content supplier of book " + registryName.toString() + " must be provided"); } - return new Book(contentProvider, guideTitle, header, itemName, author, pageTexture, outlineTexture, hasCustomModel, color, spawnWithBook, registryName, creativeTab); + return new Book(contentProvider, guideTitle, header, itemName, author, pageTexture, outlineTexture, color, spawnWithBook, registryName, creativeTab); } } From fa32265c855823b066367372164be337d4c73972 Mon Sep 17 00:00:00 2001 From: maxanier Date: Thu, 9 Apr 2020 01:09:26 +0200 Subject: [PATCH 26/28] Properly handle newlines in pagesForLongText --- .../java/amerifrance/guideapi/api/util/PageHelper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java index 95a43740..c48b3df7 100644 --- a/src/main/java/amerifrance/guideapi/api/util/PageHelper.java +++ b/src/main/java/amerifrance/guideapi/api/util/PageHelper.java @@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class PageHelper { @@ -35,7 +36,8 @@ public static List prepareForLongText(String locText, int lineWidth, int FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer; int firstCount = firstHeight / fontRenderer.FONT_HEIGHT; int count = subsequentHeight / fontRenderer.FONT_HEIGHT; - List lines = new ArrayList<>(fontRenderer.listFormattedStringToWidth(locText, lineWidth)); //Create a new list from returned list so we can later remove items + List lines = new ArrayList<>(); + Arrays.stream(locText.split("\n")).forEach(l -> lines.addAll(fontRenderer.listFormattedStringToWidth(l, lineWidth))); //Make sure to also split at manually specified newlines List pages = new ArrayList<>(); List pageLines = lines.size() > firstCount ? lines.subList(0, firstCount) : lines; @@ -53,7 +55,7 @@ public static List prepareForLongText(String locText, int lineWidth, int * Spread the text over multiple pages if necessary. Display ingredient at first page */ public static List pagesForLongText(String locText, Ingredient ingredient) { - List pageText = prepareForLongText(locText, 164, 79, 120); + List pageText = prepareForLongText(locText, 164, 81, 120); List pageList = new ArrayList<>(); for (int i = 0; i < pageText.size(); i++) { if (i == 0) { @@ -68,7 +70,7 @@ public static List pagesForLongText(String locText, Ingredient ingredient public static List pagesForLongText(String locText) { List pageList = new ArrayList<>(); - prepareForLongText(locText, 164, 120, 120).forEach(t -> pageList.add(new PageText(t))); + prepareForLongText(locText, 164, 126, 126).forEach(t -> pageList.add(new PageText(t))); return pageList; } @@ -78,7 +80,7 @@ public static void drawFormattedText(int x, int y, BaseScreen guiBase, String to toDraw = StringEscapeUtils.unescapeJava(toDraw).replaceAll("\\t", " "); String[] lines = toDraw.split("\n"); for (String line : lines) { - List cutLines = fontRenderer.listFormattedStringToWidth(line, 2 * guiBase.xSize / 3); + List cutLines = fontRenderer.listFormattedStringToWidth(line, 170); for (String cut : cutLines) { fontRenderer.drawString(cut, x, y, 0); y += 10; From adfb34d996c4d4b6ee6506724990556c764262a1 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sun, 12 Apr 2020 13:29:59 +0200 Subject: [PATCH 27/28] Fix home screen rendering position --- .../amerifrance/guideapi/gui/HomeScreen.java | 37 +++---------------- .../amerifrance/guideapi/test/TestBook.java | 6 +++ 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java index 7de0ea5a..8036ac34 100644 --- a/src/main/java/amerifrance/guideapi/gui/HomeScreen.java +++ b/src/main/java/amerifrance/guideapi/gui/HomeScreen.java @@ -59,9 +59,8 @@ public void init() { minecraft.displayGuiScreen(new SearchScreen(book, player, bookStack, this)); }, this)); - int cX = guiLeft + 45; + int cX = guiLeft + 55; int cY = guiTop + 40; - int drawLoc = 0; int i = 0; int pageNumber = 0; @@ -70,39 +69,13 @@ public void init() { continue; category.onInit(book, this, player, bookStack); - switch (drawLoc) { - case 0: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); - cX += 27; - drawLoc = 1; - break; - } - case 1: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); - cX += 27; - drawLoc = 2; - break; - } - case 2: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); - cX += 27; - drawLoc = 3; - break; - } - case 3: { - categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX, cY, 23, 23, player, this.font, itemRenderer, false, bookStack)); - drawLoc = 0; - cX = guiLeft + 45; - cY += 30; - break; - } - } + int x = i % 5; + int y = i / 5; + categoryWrapperMap.put(pageNumber, new CategoryWrapper(book, category, cX + x * 27, cY + y * 30, 23, 23, player, this.font, itemRenderer, false, bookStack)); i++; - if (i >= 16) { + if (i >= 20) { i = 0; - cX = guiLeft + 45; - cY = guiTop + 40; pageNumber++; } } diff --git a/src/main/java/amerifrance/guideapi/test/TestBook.java b/src/main/java/amerifrance/guideapi/test/TestBook.java index ccc6a591..85525338 100644 --- a/src/main/java/amerifrance/guideapi/test/TestBook.java +++ b/src/main/java/amerifrance/guideapi/test/TestBook.java @@ -68,5 +68,11 @@ private void buildContent(List categories) { Entry entry = new EntryItemStack(pages, "guideapi.test.entry", new ItemStack(Items.POTATO)); entries.put(new ResourceLocation("guideapi", "entry"), entry); categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.ACACIA_DOOR))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.PUMPKIN))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.WOODEN_AXE))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.SPRUCE_WOOD))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.BONE_MEAL))); + categories.add(new CategoryItemStack(entries, "guideapi.test.category", new ItemStack(Items.WHEAT))); + } } From 6d087cc6099c55d4b3ea9594fb4c7e48230e66f5 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sat, 25 Apr 2020 11:35:43 +0200 Subject: [PATCH 28/28] Remove unnecessary bus registration --- src/main/java/amerifrance/guideapi/GuideMod.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/amerifrance/guideapi/GuideMod.java b/src/main/java/amerifrance/guideapi/GuideMod.java index ccb49986..29f9efef 100644 --- a/src/main/java/amerifrance/guideapi/GuideMod.java +++ b/src/main/java/amerifrance/guideapi/GuideMod.java @@ -39,7 +39,6 @@ public GuideMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete); MinecraftForge.EVENT_BUS.addListener(this::onServerStarting); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onServerStarting); } private void setup(final FMLCommonSetupEvent event) {