Skip to content

Commit

Permalink
Make GTNHLib required dependency & use fastutil just like upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune committed Feb 17, 2024
1 parent 768429d commit 2393c40
Show file tree
Hide file tree
Showing 28 changed files with 163 additions and 160 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/
dependencies {
api("org.jetbrains:annotations:24.0.1")
api("com.github.GTNewHorizons:GTNHLib:0.2.4:dev")

compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.4.8:dev") { transitive = false }
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ channel = stable
mappingsVersion = 12

# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/

# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
Expand Down Expand Up @@ -117,7 +117,7 @@ includeWellKnownRepositories = true
usesMavenPublishing = true

# Maven repository to publish the mod to.
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/

# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.9'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
}


4 changes: 2 additions & 2 deletions src/main/java/com/cleanroommc/modularui/GuiErrorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.cleanroommc.modularui.api.widget.IGuiElement;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

Expand All @@ -14,7 +14,7 @@ public class GuiErrorHandler {

public static final GuiErrorHandler INSTANCE = new GuiErrorHandler();

private final Set<GuiError> errorSet = new HashSet<>();
private final Set<GuiError> errorSet = new ObjectOpenHashSet<>();
private final List<GuiError> errors = new ArrayList<>();

private GuiErrorHandler() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/cleanroommc/modularui/ModularUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class ModularUI {

static final String DEPENDENCIES = "required-after:gtnhmixins@[2.0.1,); "
+ "required-after:gtnhlib@[0.2.0,);"
+ "after:NotEnoughItems@[2.3.27-GTNH,);"
+ "after:hodgepodge@[2.0.0,);"
+ "before:gregtech";
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/cleanroommc/modularui/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import cpw.mods.fml.common.Loader;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;

import net.minecraft.network.PacketBuffer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
Expand All @@ -23,7 +24,7 @@
@Deprecated
public class Config {

private static final Map<String, Config> configs = new HashMap<>();
private static final Map<String, Config> configs = new Object2ObjectLinkedOpenHashMap<>();
private static final Path configPath = Loader.instance().getConfigDir().toPath();

@NotNull
Expand All @@ -44,8 +45,8 @@ public static Builder builder(String name) {

private final String name;
private final String basePath;
private final Map<String, Config> categories = new HashMap<>();
private final Map<String, Value> values = new HashMap<>();
private final Map<String, Config> categories = new Object2ObjectLinkedOpenHashMap<>();
private final Map<String, Value> values = new Object2ObjectLinkedOpenHashMap<>();
private final File filePath;
private final boolean synced;

Expand Down Expand Up @@ -159,8 +160,8 @@ public static class Builder {
private final String name;
private final Builder parent;
private String basePath = "modularui";
private final Map<String, Config> categories = new HashMap<>();
private final Map<String, Value> values = new HashMap<>();
private final Map<String, Config> categories = new Object2ObjectLinkedOpenHashMap<>();
private final Map<String, Value> values = new Object2ObjectLinkedOpenHashMap<>();
private boolean synced = true;

private Builder(String name, Builder parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

public class DrawableSerialization implements JsonSerializer<IDrawable>, JsonDeserializer<IDrawable> {

private static final Map<String, Function<JsonObject, IDrawable>> DRAWABLE_TYPES = new HashMap<>();
private static final Map<String, UITexture> TEXTURES = new HashMap<>();
private static final Map<String, Function<JsonObject, IDrawable>> DRAWABLE_TYPES = new Object2ObjectOpenHashMap<>();
private static final Map<String, UITexture> TEXTURES = new Object2ObjectOpenHashMap<>();

public static void registerTexture(String s, UITexture texture) {
TEXTURES.put(s, texture);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/cleanroommc/modularui/drawable/Stencil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.cleanroommc.modularui.api.layout.IViewportStack;
import com.cleanroommc.modularui.screen.viewport.GuiContext;
import com.cleanroommc.modularui.utils.ArrayListStack;
import com.cleanroommc.modularui.widget.sizer.Area;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;

import net.minecraft.client.renderer.Tessellator;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL11;
Expand All @@ -13,9 +15,9 @@
public class Stencil {

// Stores a stack of areas that are transformed, so it represents the actual area
private final static ArrayListStack<Area> stencils = new ArrayListStack<>();
private final static ObjectArrayList<Area> stencils = new ObjectArrayList<>();
// Stores a stack of stencilShapes which is used to mark and remove the stencil shape area
private final static ArrayListStack<Runnable> stencilShapes = new ArrayListStack<>();
private final static ObjectArrayList<Runnable> stencilShapes = new ObjectArrayList<>();
// the current highest stencil value
private static int stencilValue = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -33,7 +37,7 @@

public class GuiManager {

private static final Map<String, UIFactory<?>> FACTORIES = new HashMap<>(16);
private static final Object2ObjectMap<String, UIFactory<?>> FACTORIES = new Object2ObjectOpenHashMap<>(16);

private static GuiScreenWrapper lastMui;
private static final List<EntityPlayer> openedContainers = new ArrayList<>(4);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/cleanroommc/modularui/holoui/HoloUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.screen.NEISettingsImpl;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
Expand All @@ -18,7 +21,7 @@
@ApiStatus.Experimental
public class HoloUI {

private static final Map<ResourceLocation, Supplier<ModularScreen>> syncedHolos = new HashMap<>();
private static final Map<ResourceLocation, Supplier<ModularScreen>> syncedHolos = new Object2ObjectOpenHashMap<>();

public static void registerSyncedHoloUI(ResourceLocation loc, Supplier<ModularScreen> screen) {
syncedHolos.put(loc, screen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import com.cleanroommc.modularui.widgets.Dialog;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
Expand All @@ -30,8 +35,6 @@
import javax.annotation.Nonnegative;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -70,8 +73,8 @@ public static ModularScreen getCurrent() {
private final PanelManager panelManager;
private final GuiContext context = new GuiContext(this);
private final Area screenArea = new Area();
private final Map<Class<?>, List<IGuiAction>> guiActionListeners = new HashMap<>();
private final Map<IWidget, Runnable> frameUpdates = new HashMap<>();
private final Map<Class<?>, List<IGuiAction>> guiActionListeners = new Object2ObjectOpenHashMap<>();
private final Object2ObjectArrayMap<IWidget, Runnable> frameUpdates = new Object2ObjectArrayMap<>();

private ITheme currentTheme;
private GuiScreenWrapper screenWrapper;
Expand Down Expand Up @@ -218,8 +221,8 @@ public void onUpdate() {
@MustBeInvokedByOverriders
public void onFrameUpdate() {
this.panelManager.checkDirty();
for (Iterator<Map.Entry<IWidget, Runnable>> iterator = this.frameUpdates.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<IWidget, Runnable> entry = iterator.next();
for (ObjectIterator<Object2ObjectMap.Entry<IWidget, Runnable>> iterator = this.frameUpdates.object2ObjectEntrySet().fastIterator(); iterator.hasNext(); ) {
Object2ObjectMap.Entry<IWidget, Runnable> entry = iterator.next();
if (!entry.getKey().isValid()) {
iterator.remove();
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import com.cleanroommc.modularui.api.layout.IViewport;
import com.cleanroommc.modularui.api.layout.IViewportStack;
import com.cleanroommc.modularui.utils.ArrayListStack;
import com.cleanroommc.modularui.utils.GuiUtils;
import com.cleanroommc.modularui.widget.sizer.Area;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector2f;
Expand All @@ -24,7 +25,7 @@ public class GuiViewportStack implements IViewportStack {

private static final Vector3f sharedVec = new Vector3f();

private final ArrayListStack<TransformationMatrix> viewportStack = new ArrayListStack<>();
private final ObjectArrayList<TransformationMatrix> viewportStack = new ObjectArrayList<>();
private final List<Area> viewportAreas = new ArrayList<>();
private TransformationMatrix top;
private TransformationMatrix topViewport;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cleanroommc/modularui/test/TestGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import com.cleanroommc.modularui.widgets.layout.Grid;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
Expand All @@ -41,7 +41,7 @@ public void onClose() {
if (this.lines == null) {
this.lines = IntStream.range(0, 20).mapToObj(i -> "Option " + (i + 1)).collect(Collectors.toList());
this.configuredOptions = this.lines;
this.availableElements = new HashMap<>();
this.availableElements = new Object2ObjectOpenHashMap<>();
}
AtomicReference<SortableListWidget<String, SortableListWidget.Item<String>>> ref = new AtomicReference<>(null);
List<List<AvailableElement>> availableMatrix = Grid.mapToMatrix(2, this.lines, (index, value) -> {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/cleanroommc/modularui/theme/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import com.cleanroommc.modularui.api.IThemeApi;
import com.cleanroommc.modularui.screen.Tooltip;

import java.util.HashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

import java.util.Map;

public class Theme implements ITheme {
Expand All @@ -18,7 +19,7 @@ public class Theme implements ITheme {
public static final String TEXT_FIELD = "textField";
public static final String TOGGLE_BUTTON = "toggleButton";

private final Map<String, WidgetTheme> widgetThemes = new HashMap<>();
private final Map<String, WidgetTheme> widgetThemes = new Object2ObjectOpenHashMap<>();

private final String id;
private final ITheme parentTheme;
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/com/cleanroommc/modularui/theme/ThemeAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import com.cleanroommc.modularui.drawable.GuiTextures;
import com.cleanroommc.modularui.utils.Color;
import com.cleanroommc.modularui.utils.JsonBuilder;

import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class ThemeAPI implements IThemeApi {
Expand All @@ -22,12 +23,12 @@ public class ThemeAPI implements IThemeApi {
public static final String DEFAULT = "DEFAULT";
public static final ITheme DEFAULT_DEFAULT = new DefaultTheme();

private final Map<String, ITheme> THEMES = new HashMap<>();
protected final Map<String, List<JsonBuilder>> defaultThemes = new HashMap<>();
protected final Map<String, WidgetTheme> defaultWidgetThemes = new HashMap<>();
protected final Map<String, WidgetThemeParser> widgetThemeFunctions = new HashMap<>();
protected final Map<String, String> jsonScreenThemes = new HashMap<>();
private final Map<String, String> screenThemes = new HashMap<>();
private final Object2ObjectMap<String, ITheme> THEMES = new Object2ObjectOpenHashMap<>();
protected final Object2ObjectMap<String, List<JsonBuilder>> defaultThemes = new Object2ObjectOpenHashMap<>();
protected final Object2ObjectMap<String, WidgetTheme> defaultWidgetThemes = new Object2ObjectOpenHashMap<>();
protected final Object2ObjectMap<String, WidgetThemeParser> widgetThemeFunctions = new Object2ObjectOpenHashMap<>();
protected final Object2ObjectOpenHashMap<String, String> jsonScreenThemes = new Object2ObjectOpenHashMap<>();
private final Object2ObjectMap<String, String> screenThemes = new Object2ObjectOpenHashMap<>();

private ThemeAPI() {
registerWidgetTheme(Theme.PANEL, new WidgetTheme(GuiTextures.MC_BACKGROUND, null, Color.WHITE.main, 0xFF404040, false), WidgetTheme::new);
Expand Down
Loading

0 comments on commit 2393c40

Please sign in to comment.