aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2022-07-24 23:22:06 -0700
committerAnthony Hilyard <anthony.hilyard@gmail.com>2022-07-24 23:22:06 -0700
commit6d01463c32ea14f48ce273e9daf753905f101946 (patch)
treecbd655526e165d6698850d79080e1c0eeb741622 /src/main/java/com/anthonyhilyard
parent427f975d78b64ec4433e8e0542729feb0e618608 (diff)
downloadIceberg-6d01463c32ea14f48ce273e9daf753905f101946.tar.gz
Iceberg-6d01463c32ea14f48ce273e9daf753905f101946.tar.bz2
Iceberg-6d01463c32ea14f48ce273e9daf753905f101946.zip
Added support for latest Forge and Configured.
Diffstat (limited to 'src/main/java/com/anthonyhilyard')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredConfigHelperMixin.java2
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredModConfigSelectionScreenMixin.java18
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java36
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java1
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java2
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java19
6 files changed, 59 insertions, 19 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredConfigHelperMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredConfigHelperMixin.java
index 682fcb8..9918740 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredConfigHelperMixin.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredConfigHelperMixin.java
@@ -25,7 +25,7 @@ import com.mrcrayfish.configured.util.ConfigHelper;
public class ConfiguredConfigHelperMixin
{
@Inject(method = "gatherAllConfigValues(Lnet/minecraftforge/fml/config/ModConfig;)Ljava/util/List;",
- at = @At(value = "HEAD"), cancellable = true, remap = false)
+ at = @At(value = "HEAD"), cancellable = true, remap = false, require = 0)
private static void gatherAllConfigValuesIcebergSupport(ModConfig config, CallbackInfoReturnable<List<?>> info)
{
if (config.getSpec() instanceof IcebergConfigSpec icebergConfigSpec)
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredModConfigSelectionScreenMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredModConfigSelectionScreenMixin.java
index a682a00..1d0882a 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredModConfigSelectionScreenMixin.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/ConfiguredModConfigSelectionScreenMixin.java
@@ -1,6 +1,8 @@
package com.anthonyhilyard.iceberg.mixin;
import java.lang.reflect.Field;
+import java.util.List;
+import java.util.ArrayList;
import com.anthonyhilyard.iceberg.Loader;
import com.anthonyhilyard.iceberg.config.IcebergConfigSpec;
@@ -56,7 +58,7 @@ public class ConfiguredModConfigSelectionScreenMixin
@Shadow(remap = false)
private boolean hasRequiredPermission() { return true; }
- @Inject(method = "createModifyButton", at = @At(value = "HEAD"), remap = false, cancellable = true)
+ @Inject(method = "createModifyButton", at = @At(value = "HEAD"), remap = false, cancellable = true, require = 0)
private void createModifyButton(ModConfig config, CallbackInfoReturnable<Button> info)
{
if (config.getSpec() instanceof IcebergConfigSpec)
@@ -125,7 +127,7 @@ public class ConfiguredModConfigSelectionScreenMixin
itemHeightField.set(configScreen, 24);
ForgeConfigSpec dummySpec = new ForgeConfigSpec.Builder().build();
- FieldUtils.writeDeclaredField(configScreen, "folderEntry", new IcebergFolderEntry(configScreen, "Root", ((IcebergConfigSpec) config.getSpec()).getValues(), dummySpec, true, (IcebergConfigSpec) config.getSpec()), true);
+ FieldUtils.writeDeclaredField(configScreen, "folderEntry", new IcebergFolderEntry(configScreen, List.of(), ((IcebergConfigSpec) config.getSpec()).getValues(), dummySpec, (IcebergConfigSpec) config.getSpec()), true);
FieldUtils.writeDeclaredField(configScreen, "config", config, true);
minecraft.setScreen(configScreen);
@@ -159,13 +161,15 @@ public class ConfiguredModConfigSelectionScreenMixin
private ForgeConfigSpec spec;
private ConfigScreen configScreen;
private UnmodifiableConfig config;
- public IcebergFolderEntry(ConfigScreen configScreen, String label, UnmodifiableConfig config, ForgeConfigSpec spec, boolean root, IcebergConfigSpec icebergSpec)
+ private final List<String> path;
+ public IcebergFolderEntry(ConfigScreen configScreen, List<String> path, UnmodifiableConfig config, ForgeConfigSpec spec, IcebergConfigSpec icebergSpec)
{
- configScreen.super(label, config, spec, root);
+ configScreen.super(path, config, spec);
icebergConfigSpec = icebergSpec;
this.spec = spec;
this.configScreen = configScreen;
this.config = config;
+ this.path = path;
init();
}
@@ -186,12 +190,13 @@ public class ConfiguredModConfigSelectionScreenMixin
if (value instanceof UnmodifiableConfig)
{
- builder.add(new IcebergFolderEntry(configScreen, key, (UnmodifiableConfig) value, spec, false, icebergConfigSpec));
+ List<String> path = new ArrayList<>(this.path);
+ path.add(key);
+ builder.add(new IcebergFolderEntry(configScreen, path, (UnmodifiableConfig) value, spec, icebergConfigSpec));
}
else if (value instanceof ForgeConfigSpec.ConfigValue<?>)
{
ForgeConfigSpec.ConfigValue<?> configValue = (ForgeConfigSpec.ConfigValue<?>) value;
- Loader.LOGGER.info(configValue.getPath());
ForgeConfigSpec.ValueSpec valueSpec = icebergConfigSpec.getRaw(configValue.getPath());
if (valueSpec != null)
{
@@ -207,6 +212,5 @@ public class ConfiguredModConfigSelectionScreenMixin
return;
}
}
-
}
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
index b87c057..73800cb 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
@@ -4,12 +4,48 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.GameRenderer;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.math.Matrix4f;
public class GuiHelper
{
+ public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
+ {
+ RenderSystem.enableDepthTest();
+ RenderSystem.disableTexture();
+ RenderSystem.enableBlend();
+ RenderSystem.defaultBlendFunc();
+ RenderSystem.setShader(GameRenderer::getPositionColorShader);
+
+ Tesselator tessellator = Tesselator.getInstance();
+ BufferBuilder bufferBuilder = tessellator.getBuilder();
+ bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
+ drawGradientRect(mat, bufferBuilder, left, top, right, bottom, zLevel, startColor, endColor);
+ BufferUploader.drawWithShader(bufferBuilder.end());
+
+ RenderSystem.disableBlend();
+ RenderSystem.enableTexture();
+ }
+
+ public static void drawGradientRect(Matrix4f mat, BufferBuilder bufferBuilder, int left, int top, int right, int bottom, int zLevel, int startColor, int endColor)
+ {
+ float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
+ float startRed = (float)(startColor >> 16 & 255) / 255.0F;
+ float startGreen = (float)(startColor >> 8 & 255) / 255.0F;
+ float startBlue = (float)(startColor & 255) / 255.0F;
+ float endAlpha = (float)(endColor >> 24 & 255) / 255.0F;
+ float endRed = (float)(endColor >> 16 & 255) / 255.0F;
+ float endGreen = (float)(endColor >> 8 & 255) / 255.0F;
+ float endBlue = (float)(endColor & 255) / 255.0F;
+
+ bufferBuilder.vertex(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ bufferBuilder.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ bufferBuilder.vertex(mat, left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
+ bufferBuilder.vertex(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
+ }
+
public static void drawGradientRectHorizontal(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
{
float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java b/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
index d5bcbfa..b885e43 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
@@ -12,6 +12,7 @@ import java.util.List;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
+@Deprecated(forRemoval = true)
public class ItemColor
{
private static class ColorCollector implements FormattedCharSink
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java b/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java
index cfbc203..b21c168 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java
@@ -148,7 +148,7 @@ public class Selectors
* @param selector A selector string to check against.
* @return True if the item matches, false otherwise.
*/
- @SuppressWarnings("deprecation")
+ @SuppressWarnings({"deprecation", "removal"})
public static boolean itemMatches(ItemStack item, String selector)
{
String itemResourceLocation = ForgeRegistries.ITEMS.getKey(item.getItem()).toString();
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
index 467604b..63ec096 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
@@ -37,7 +37,6 @@ import com.mojang.math.Matrix4f;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.client.gui.GuiUtils;
public class Tooltips
{
@@ -151,15 +150,15 @@ public class Tooltips
borderColorStart = colorEvent.getBorderStart();
borderColorEnd = colorEvent.getBorderEnd();
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 3, rectY - 4, rectX + rect.getWidth() + 3, rectY - 3, backgroundColorStart, backgroundColorStart);
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 3, rectY + rect.getHeight() + 3, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 4, backgroundColorEnd, backgroundColorEnd);
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 3, rectY - 3, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 3, backgroundColorStart, backgroundColorEnd);
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 4, rectY - 3, rectX - 3, rectY + rect.getHeight() + 3, backgroundColorStart, backgroundColorEnd);
- GuiUtils.drawGradientRect(mat, zLevel, rectX + rect.getWidth() + 3, rectY - 3, rectX + rect.getWidth() + 4, rectY + rect.getHeight() + 3, backgroundColorStart, backgroundColorEnd);
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 3, rectY - 3 + 1, rectX - 3 + 1, rectY + rect.getHeight() + 3 - 1, borderColorStart, borderColorEnd);
- GuiUtils.drawGradientRect(mat, zLevel, rectX + rect.getWidth() + 2, rectY - 3 + 1, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 3 - 1, borderColorStart, borderColorEnd);
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 3, rectY - 3, rectX + rect.getWidth() + 3, rectY - 3 + 1, borderColorStart, borderColorStart);
- GuiUtils.drawGradientRect(mat, zLevel, rectX - 3, rectY + rect.getHeight() + 2, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 3, borderColorEnd, borderColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 3, rectY - 4, rectX + rect.getWidth() + 3, rectY - 3, backgroundColorStart, backgroundColorStart);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 3, rectY + rect.getHeight() + 3, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 4, backgroundColorEnd, backgroundColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 3, rectY - 3, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 3, backgroundColorStart, backgroundColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 4, rectY - 3, rectX - 3, rectY + rect.getHeight() + 3, backgroundColorStart, backgroundColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX + rect.getWidth() + 3, rectY - 3, rectX + rect.getWidth() + 4, rectY + rect.getHeight() + 3, backgroundColorStart, backgroundColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 3, rectY - 3 + 1, rectX - 3 + 1, rectY + rect.getHeight() + 3 - 1, borderColorStart, borderColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX + rect.getWidth() + 2, rectY - 3 + 1, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 3 - 1, borderColorStart, borderColorEnd);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 3, rectY - 3, rectX + rect.getWidth() + 3, rectY - 3 + 1, borderColorStart, borderColorStart);
+ GuiHelper.drawGradientRect(mat, zLevel, rectX - 3, rectY + rect.getHeight() + 2, rectX + rect.getWidth() + 3, rectY + rect.getHeight() + 3, borderColorEnd, borderColorEnd);
BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
poseStack.translate(0.0D, 0.0D, zLevel);