소스 검색

9 patch textures

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 5 년 전
부모
커밋
130b13c215

+ 3 - 3
gradle.properties

@@ -1,12 +1,12 @@
-mod_version=4.1.4-unstable
+mod_version=4.1.5-unstable
 minecraft_version=20w14a
 yarn_version=20w14a+build.2
 fabricloader_version=0.7.9+build.190
 cloth_events_version=2.0.2-unstable
-cloth_config_version=3.1.0-unstable
+cloth_config_version=3.3.1-unstable
 modmenu_version=1.11.0+build.2
 fabric_api=0.5.7+build.314-1.16
-autoconfig1u=1.2.5
+autoconfig1u=2.0
 api_include=me.shedaniel.cloth:cloth-events,me.shedaniel.cloth:config-2,me.sargunvohra.mcmods:autoconfig1u,org.jetbrains:annotations
 api_exculde=
 #api_include=me.shedaniel.cloth:cloth-events,me.shedaniel.cloth:config-2,me.sargunvohra.mcmods:autoconfig1u,org.jetbrains:annotations,net.fabricmc.fabric-api:fabric-

+ 5 - 5
src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java

@@ -110,7 +110,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
     @ApiStatus.Internal
     public static REIPluginEntry registerPlugin(REIPluginEntry plugin) {
         plugins.put(plugin.getPluginIdentifier(), plugin);
-        RoughlyEnoughItemsCore.LOGGER.debug("[REI] Registered plugin %s from %s", plugin.getPluginIdentifier().toString(), plugin.getClass().getSimpleName());
+        RoughlyEnoughItemsCore.LOGGER.debug("Registered plugin %s from %s", plugin.getPluginIdentifier().toString(), plugin.getClass().getSimpleName());
         return plugin;
     }
     
@@ -150,7 +150,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
     public static void syncRecipes(long[] lastSync) {
         if (lastSync != null) {
             if (lastSync[0] > 0 && System.currentTimeMillis() - lastSync[0] <= 5000) {
-                RoughlyEnoughItemsCore.LOGGER.warn("[REI] Suppressing Sync Recipes!");
+                RoughlyEnoughItemsCore.LOGGER.warn("Suppressing Sync Recipes!");
                 return;
             }
             lastSync[0] = System.currentTimeMillis();
@@ -177,7 +177,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
         discoverPluginEntries();
         for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
             if (modContainer.getMetadata().containsCustomElement("roughlyenoughitems:plugins"))
-                RoughlyEnoughItemsCore.LOGGER.error("[REI] REI plugin from " + modContainer.getMetadata().getId() + " is not loaded because it is too old!");
+                RoughlyEnoughItemsCore.LOGGER.error("REI plugin from " + modContainer.getMetadata().getId() + " is not loaded because it is too old!");
         }
         
         ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> {
@@ -224,7 +224,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                 registerPlugin(reiPlugin);
             } catch (Exception e) {
                 e.printStackTrace();
-                RoughlyEnoughItemsCore.LOGGER.error("[REI] Can't load REI plugins from %s: %s", reiPlugin.getClass(), e.getLocalizedMessage());
+                RoughlyEnoughItemsCore.LOGGER.error("Can't load REI plugins from %s: %s", reiPlugin.getClass(), e.getLocalizedMessage());
             }
         }
         for (REIPluginV0 reiPlugin : FabricLoader.getInstance().getEntrypoints("rei_plugins_v0", REIPluginV0.class)) {
@@ -232,7 +232,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
                 registerPlugin(reiPlugin);
             } catch (Exception e) {
                 e.printStackTrace();
-                RoughlyEnoughItemsCore.LOGGER.error("[REI] Can't load REI plugins from %s: %s", reiPlugin.getClass(), e.getLocalizedMessage());
+                RoughlyEnoughItemsCore.LOGGER.error("Can't load REI plugins from %s: %s", reiPlugin.getClass(), e.getLocalizedMessage());
             }
         }
         

+ 9 - 0
src/main/java/me/shedaniel/rei/api/widgets/Panel.java

@@ -25,21 +25,30 @@ package me.shedaniel.rei.api.widgets;
 
 import me.shedaniel.rei.api.REIHelper;
 import me.shedaniel.rei.gui.widget.WidgetWithBounds;
+import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.function.Predicate;
 
 public abstract class Panel extends WidgetWithBounds {
+    @Deprecated
+    @ApiStatus.ScheduledForRemoval
     public abstract int getInnerColor();
     
+    @Deprecated
+    @ApiStatus.ScheduledForRemoval
     public abstract void setInnerColor(int innerColor);
     
+    @Deprecated
+    @ApiStatus.ScheduledForRemoval
     @NotNull
     public final Panel innerColor(int innerColor) {
         setInnerColor(innerColor);
         return this;
     }
     
+    @Deprecated
+    @ApiStatus.ScheduledForRemoval
     @NotNull
     public final Panel innerColor(int lightColor, int darkColor) {
         return innerColor(REIHelper.getInstance().isDarkThemeEnabled() ? darkColor : lightColor);

+ 1 - 1
src/main/java/me/shedaniel/rei/api/widgets/Widgets.java

@@ -182,7 +182,7 @@ public final class Widgets {
     
     @NotNull
     public static Panel createSlotBase(@NotNull Rectangle rectangle) {
-        return new PanelWidget(rectangle).yTextureOffset(-66).rendering(Widgets::shouldSlotBaseRender).innerColor(-7631989, -13619152);
+        return new PanelWidget(rectangle).yTextureOffset(-66).rendering(Widgets::shouldSlotBaseRender);
     }
     
     private static boolean shouldSlotBaseRender(@NotNull Panel panel) {

+ 1 - 1
src/main/java/me/shedaniel/rei/gui/subsets/SubsetsMenu.java

@@ -167,7 +167,7 @@ public class SubsetsMenu extends WidgetWithBounds implements LateRenderable {
                 } else {
                     String translationKey = "subsets.rei." + entry.getKey().replace(':', '.');
                     if (!I18n.hasTranslation(translationKey))
-                        RoughlyEnoughItemsCore.LOGGER.warn("[REI] Subsets menu " + translationKey + " does not have a translation");
+                        RoughlyEnoughItemsCore.LOGGER.warn("Subsets menu " + translationKey + " does not have a translation");
                     entries.add(new SubMenuEntry(I18n.translate(translationKey), buildEntries(entryMap)));
                 }
             }

+ 1 - 1
src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java

@@ -644,7 +644,7 @@ public class EntryListWidget extends WidgetWithBounds {
         long ended = System.nanoTime();
         long time = ended - started;
         if (ConfigObject.getInstance().doDebugSearchTimeRequired())
-            RoughlyEnoughItemsCore.LOGGER.info("[REI] Search Used: %.2fms", time * 1e-6);
+            RoughlyEnoughItemsCore.LOGGER.info("Search Used: %.2fms", time * 1e-6);
         updateEntriesPosition();
     }
     

+ 1 - 1
src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java

@@ -121,7 +121,7 @@ public class ConfigManagerImpl implements ConfigManager {
                                 Collections.singletonList(new FilteringEntry(getUnsafely(field, config, new ArrayList<>()), getUnsafely(field, defaults), list -> setUnsafely(field, config, list)))
                 , (field) -> field.getType() == List.class, ConfigObjectImpl.UseFilteringScreen.class);
         saveConfig();
-        RoughlyEnoughItemsCore.LOGGER.info("[REI] Config loaded.");
+        RoughlyEnoughItemsCore.LOGGER.info("Config loaded.");
     }
     
     @Override

+ 1 - 1
src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java

@@ -101,7 +101,7 @@ public class EntryRegistryImpl implements EntryRegistry {
                 preFilteredList.add(stack);
         }
         long time = System.currentTimeMillis() - started;
-        RoughlyEnoughItemsCore.LOGGER.info("[REI] Refiltered %d entries in %dms.", filteredStacks.size(), time);
+        RoughlyEnoughItemsCore.LOGGER.info("Refiltered %d entries in %dms.", filteredStacks.size(), time);
     }
     
     public void reset() {

+ 7 - 7
src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java

@@ -290,7 +290,7 @@ public class RecipeHelperImpl implements RecipeHelper {
         ((DisplayHelperImpl) DisplayHelper.getInstance()).setBaseBoundsHandler(baseBoundsHandler);
         List<REIPluginEntry> plugins = RoughlyEnoughItemsCore.getPlugins();
         plugins.sort(Comparator.comparingInt(REIPluginEntry::getPriority).reversed());
-        RoughlyEnoughItemsCore.LOGGER.info("[REI] Loading %d plugins: %s", plugins.size(), plugins.stream().map(REIPluginEntry::getPluginIdentifier).map(Identifier::toString).collect(Collectors.joining(", ")));
+        RoughlyEnoughItemsCore.LOGGER.info("Loading %d plugins: %s", plugins.size(), plugins.stream().map(REIPluginEntry::getPluginIdentifier).map(Identifier::toString).collect(Collectors.joining(", ")));
         Collections.reverse(plugins);
         ((EntryRegistryImpl) EntryRegistry.getInstance()).reset();
         List<REIPluginV0> reiPluginV0s = new ArrayList<>();
@@ -301,7 +301,7 @@ public class RecipeHelperImpl implements RecipeHelper {
                     reiPluginV0s.add((REIPluginV0) plugin);
                 }
             } catch (Throwable e) {
-                RoughlyEnoughItemsCore.LOGGER.error("[REI] " + plugin.getPluginIdentifier().toString() + " plugin failed to pre register!", e);
+                RoughlyEnoughItemsCore.LOGGER.error(plugin.getPluginIdentifier().toString() + " plugin failed to pre register!", e);
             }
         }
         for (REIPluginV0 plugin : reiPluginV0s) {
@@ -313,7 +313,7 @@ public class RecipeHelperImpl implements RecipeHelper {
                 plugin.registerRecipeDisplays(this);
                 plugin.registerOthers(this);
             } catch (Throwable e) {
-                RoughlyEnoughItemsCore.LOGGER.error("[REI] " + identifier.toString() + " plugin failed to load!", e);
+                RoughlyEnoughItemsCore.LOGGER.error(identifier.toString() + " plugin failed to load!", e);
             }
         }
         
@@ -322,7 +322,7 @@ public class RecipeHelperImpl implements RecipeHelper {
             try {
                 plugin.postRegister();
             } catch (Throwable e) {
-                RoughlyEnoughItemsCore.LOGGER.error("[REI] " + identifier.toString() + " plugin failed to post register!", e);
+                RoughlyEnoughItemsCore.LOGGER.error(identifier.toString() + " plugin failed to post register!", e);
             }
         }
         if (!recipeFunctions.isEmpty()) {
@@ -334,7 +334,7 @@ public class RecipeHelperImpl implements RecipeHelper {
                         registerDisplay(recipeFunction.category, (RecipeDisplay) recipeFunction.mappingFunction.apply(recipe), 0);
                     }
                 } catch (Exception e) {
-                    RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to add recipes!", e);
+                    RoughlyEnoughItemsCore.LOGGER.error("Failed to add recipes!", e);
                 }
             }
         }
@@ -382,7 +382,7 @@ public class RecipeHelperImpl implements RecipeHelper {
         
         displayVisibilityHandlers.sort(VISIBILITY_HANDLER_COMPARATOR);
         long usedTime = System.currentTimeMillis() - startTime;
-        RoughlyEnoughItemsCore.LOGGER.info("[REI] Registered %d stack entries, %d recipes displays, %d exclusion zones suppliers, %d overlay decider, %d visibility handlers and %d categories (%s) in %d ms.", EntryRegistry.getInstance().getStacksList().size(), recipeCount[0], BaseBoundsHandler.getInstance().supplierSize(), DisplayHelper.getInstance().getAllOverlayDeciders().size(), getDisplayVisibilityHandlers().size(), categories.size(), categories.keySet().stream().map(RecipeCategory::getCategoryName).collect(Collectors.joining(", ")), usedTime);
+        RoughlyEnoughItemsCore.LOGGER.info("Registered %d stack entries, %d recipes displays, %d exclusion zones suppliers, %d overlay decider, %d visibility handlers and %d categories (%s) in %d ms.", EntryRegistry.getInstance().getStacksList().size(), recipeCount[0], BaseBoundsHandler.getInstance().supplierSize(), DisplayHelper.getInstance().getAllOverlayDeciders().size(), getDisplayVisibilityHandlers().size(), categories.size(), categories.keySet().stream().map(RecipeCategory::getCategoryName).collect(Collectors.joining(", ")), usedTime);
     }
     
     @Override
@@ -458,7 +458,7 @@ public class RecipeHelperImpl implements RecipeHelper {
                     return visibility == ActionResult.SUCCESS;
             }
         } catch (Throwable throwable) {
-            RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to check if the recipe is visible!", throwable);
+            RoughlyEnoughItemsCore.LOGGER.error("Failed to check if the recipe is visible!", throwable);
         }
         return true;
     }

+ 17 - 15
src/main/java/me/shedaniel/rei/impl/widgets/ButtonWidget.java

@@ -29,12 +29,12 @@ import me.shedaniel.math.Rectangle;
 import me.shedaniel.rei.api.REIHelper;
 import me.shedaniel.rei.api.widgets.Button;
 import me.shedaniel.rei.api.widgets.Tooltip;
+import net.minecraft.client.gui.DrawableHelper;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.sound.PositionedSoundInstance;
 import net.minecraft.sound.SoundEvents;
 import net.minecraft.text.Text;
 import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -288,20 +288,22 @@ public class ButtonWidget extends Button {
         RenderSystem.enableBlend();
         RenderSystem.blendFuncSeparate(770, 771, 1, 0);
         RenderSystem.blendFunc(770, 771);
-        //Four Corners
-        drawTexture(x, y, getZOffset(), 0, textureOffset * 80, 4, 4, 512, 256);
-        drawTexture(x + width - 4, y, getZOffset(), 252, textureOffset * 80, 4, 4, 512, 256);
-        drawTexture(x, y + height - 4, getZOffset(), 0, textureOffset * 80 + 76, 4, 4, 512, 256);
-        drawTexture(x + width - 4, y + height - 4, getZOffset(), 252, textureOffset * 80 + 76, 4, 4, 512, 256);
         
-        //Sides
-        drawTexture(x + 4, y, getZOffset(), 4, textureOffset * 80, MathHelper.ceil((width - 8) / 2f), 4, 512, 256);
-        drawTexture(x + 4, y + height - 4, getZOffset(), 4, textureOffset * 80 + 76, MathHelper.ceil((width - 8) / 2f), 4, 512, 256);
-        drawTexture(x + 4 + MathHelper.ceil((width - 8) / 2f), y + height - 4, getZOffset(), 252 - MathHelper.floor((width - 8) / 2f), textureOffset * 80 + 76, MathHelper.floor((width - 8) / 2f), 4, 512, 256);
-        drawTexture(x + 4 + MathHelper.ceil((width - 8) / 2f), y, getZOffset(), 252 - MathHelper.floor((width - 8) / 2f), textureOffset * 80, MathHelper.floor((width - 8) / 2f), 4, 512, 256);
-        for (int i = y + 4; i < y + height - 4; i += 76) {
-            drawTexture(x, i, getZOffset(), 0, 4 + textureOffset * 80, MathHelper.ceil(width / 2f), MathHelper.clamp(y + height - 4 - i, 0, 76), 512, 256);
-            drawTexture(x + MathHelper.ceil(width / 2f), i, getZOffset(), 256 - MathHelper.floor(width / 2f), 4 + textureOffset * 80, MathHelper.floor(width / 2f), MathHelper.clamp(y + height - 4 - i, 0, 76), 512, 256);
-        }
+        // 9 Patch Texture
+        
+        // Four Corners
+        drawTexture(x, y, getZOffset(), 0, textureOffset * 80, 8, 8, 512, 256);
+        drawTexture(x + width - 8, y, getZOffset(), 248, textureOffset * 80, 8, 8, 512, 256);
+        drawTexture(x, y + height - 8, getZOffset(), 0, textureOffset * 80 + 72, 8, 8, 512, 256);
+        drawTexture(x + width - 8, y + height - 8, getZOffset(), 248, textureOffset * 80 + 72, 8, 8, 512, 256);
+        
+        // Sides
+        DrawableHelper.drawTexturedQuad(x + 8, x + width - 8, y, y + 8, getZ(), (8) / 256f, (248) / 256f, (textureOffset * 80) / 512f, (textureOffset * 80 + 8) / 512f);
+        DrawableHelper.drawTexturedQuad(x + 8, x + width - 8, y + height - 8, y + height, getZ(), (8) / 256f, (248) / 256f, (textureOffset * 80 + 72) / 512f, (textureOffset * 80 + 80) / 512f);
+        DrawableHelper.drawTexturedQuad(x, x + 8, y + 8, y + height - 8, getZ(), (0) / 256f, (8) / 256f, (textureOffset * 80 + 8) / 512f, (textureOffset * 80 + 72) / 512f);
+        DrawableHelper.drawTexturedQuad(x + width - 8, x + width, y + 8, y + height - 8, getZ(), (248) / 256f, (256) / 256f, (textureOffset * 80 + 8) / 512f, (textureOffset * 80 + 72) / 512f);
+        
+        // Center
+        DrawableHelper.drawTexturedQuad(x + 8, x + width - 8, y + 8, y + height - 8, getZ(), (8) / 256f, (248) / 256f, (textureOffset * 80 + 8) / 512f, (textureOffset * 80 + 72) / 512f);
     }
 }

+ 23 - 22
src/main/java/me/shedaniel/rei/impl/widgets/PanelWidget.java

@@ -30,8 +30,10 @@ import me.shedaniel.rei.api.REIHelper;
 import me.shedaniel.rei.api.widgets.Panel;
 import me.shedaniel.rei.gui.config.RecipeBorderType;
 import me.shedaniel.rei.gui.config.RecipeScreenType;
+import net.minecraft.client.gui.DrawableHelper;
 import net.minecraft.client.gui.Element;
 import net.minecraft.util.Identifier;
+import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collections;
@@ -46,7 +48,6 @@ public final class PanelWidget extends Panel {
     private static final PanelWidget TEMP = new PanelWidget(new Rectangle());
     private Rectangle bounds;
     private int color = -1;
-    private int innerColor = REIHelper.getInstance().isDarkThemeEnabled() ? -13750738 : -3750202;
     private int xTextureOffset = 0;
     private int yTextureOffset = RecipeBorderType.DEFAULT.getYOffset();
     @NotNull
@@ -66,15 +67,17 @@ public final class PanelWidget extends Panel {
         TEMP.render(0, 0, 0);
     }
     
+    @Deprecated
+    @ApiStatus.ScheduledForRemoval
     @Override
     public int getInnerColor() {
-        return innerColor;
+        return REIHelper.getInstance().isDarkThemeEnabled() ? -13750738 : -3750202;
     }
     
+    @Deprecated
+    @ApiStatus.ScheduledForRemoval
     @Override
-    public void setInnerColor(int innerColor) {
-        this.innerColor = innerColor;
-    }
+    public void setInnerColor(int innerColor) {}
     
     @Override
     public int getXTextureOffset() {
@@ -136,24 +139,22 @@ public final class PanelWidget extends Panel {
         int xTextureOffset = getXTextureOffset();
         int yTextureOffset = getYTextureOffset();
         
-        //Four Corners
-        this.drawTexture(x, y, 106 + xTextureOffset, 124 + yTextureOffset, 4, 4);
-        this.drawTexture(x + width - 4, y, 252 + xTextureOffset, 124 + yTextureOffset, 4, 4);
-        this.drawTexture(x, y + height - 4, 106 + xTextureOffset, 186 + yTextureOffset, 4, 4);
-        this.drawTexture(x + width - 4, y + height - 4, 252 + xTextureOffset, 186 + yTextureOffset, 4, 4);
+        // 9 Patch Texture
+        
+        // Four Corners
+        this.drawTexture(x, y, 106 + xTextureOffset, 124 + yTextureOffset, 8, 8);
+        this.drawTexture(x + width - 8, y, 248 + xTextureOffset, 124 + yTextureOffset, 8, 8);
+        this.drawTexture(x, y + height - 8, 106 + xTextureOffset, 182 + yTextureOffset, 8, 8);
+        this.drawTexture(x + width - 8, y + height - 8, 248 + xTextureOffset, 182 + yTextureOffset, 8, 8);
+        
+        // Sides
+        DrawableHelper.drawTexturedQuad(x + 8, x + width - 8, y, y + 8, getZ(), (114 + xTextureOffset) / 256f, (248 + xTextureOffset) / 256f, (124 + yTextureOffset) / 256f, (132 + yTextureOffset) / 256f);
+        DrawableHelper.drawTexturedQuad(x + 8, x + width - 8, y + height - 8, y + height, getZ(), (114 + xTextureOffset) / 256f, (248 + xTextureOffset) / 256f, (182 + yTextureOffset) / 256f, (190 + yTextureOffset) / 256f);
+        DrawableHelper.drawTexturedQuad(x, x + 8, y + 8, y + height - 8, getZ(), (106 + xTextureOffset) / 256f, (114 + xTextureOffset) / 256f, (132 + yTextureOffset) / 256f, (182 + yTextureOffset) / 256f);
+        DrawableHelper.drawTexturedQuad(x + width - 8, x + width, y + 8, y + height - 8, getZ(), (248 + xTextureOffset) / 256f, (256 + xTextureOffset) / 256f, (132 + yTextureOffset) / 256f, (182 + yTextureOffset) / 256f);
         
-        //Sides
-        for (int xx = 4; xx < width - 4; xx += 128) {
-            int thisWidth = Math.min(128, width - 4 - xx);
-            this.drawTexture(x + xx, y, 110 + xTextureOffset, 124 + yTextureOffset, thisWidth, 4);
-            this.drawTexture(x + xx, y + height - 4, 110 + xTextureOffset, 186 + yTextureOffset, thisWidth, 4);
-        }
-        for (int yy = 4; yy < height - 4; yy += 50) {
-            int thisHeight = Math.min(50, height - 4 - yy);
-            this.drawTexture(x, y + yy, 106 + xTextureOffset, 128 + yTextureOffset, 4, thisHeight);
-            this.drawTexture(x + width - 4, y + yy, 252 + xTextureOffset, 128 + yTextureOffset, 4, thisHeight);
-        }
-        fillGradient(x + 4, y + 4, x + width - 4, y + height - 4, getInnerColor(), getInnerColor());
+        // Center
+        DrawableHelper.drawTexturedQuad(x + 8, x + width - 8, y + 8, y + height - 8, getZ(), (114 + xTextureOffset) / 256f, (248 + xTextureOffset) / 256f, (132 + yTextureOffset) / 256f, (182 + yTextureOffset) / 256f);
     }
     
     @Override

+ 1 - 1
src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java

@@ -275,7 +275,7 @@ public class DefaultPlugin implements REIPluginV0 {
             }
         }
         time = System.currentTimeMillis() - time;
-        RoughlyEnoughItemsCore.LOGGER.info("[REI] Applied Check Tags for potion in %dms.", time);
+        RoughlyEnoughItemsCore.LOGGER.info("Applied Check Tags for potion in %dms.", time);
     }
     
     private void applyPotionTransformer(EntryStack stack) {