Skip to content

Commit

Permalink
Fixed horrifying model load order error
Browse files Browse the repository at this point in the history
  • Loading branch information
UselessBullets committed May 7, 2024
1 parent d02cd50 commit c0e499d
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ dependencies {
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}")
include(implementation("org.apache.commons:commons-lang3:3.12.0"))

// modImplementation "ModMenu:ModMenu:${project.mod_menu_version}"
modImplementation "ModMenu:ModMenu:${project.mod_menu_version}"
}

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ loader_version=0.15.6-babric.6-bta
mod_menu_version=2.0.6

# Mod
mod_version=4.0.3
mod_version=4.0.4-beta.2
mod_group=turniplabs
mod_name=halplibe

5 changes: 3 additions & 2 deletions src/main/java/turniplabs/halplibe/helper/BlockBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
Expand Down Expand Up @@ -457,7 +458,7 @@ public static void reserveRuns(String modId, Toml runs, int neededIds, Consumer<
}
public static class Assignment{
public static boolean blockDispatcherInitialized = false;
public static final Map<Block, Function<Block, BlockModel<?>>> queuedBlockModels = new HashMap<>();
public static final Map<Block, Function<Block, BlockModel<?>>> queuedBlockModels = new LinkedHashMap<>();
public static void queueBlockModel(@NotNull Block block, Function<Block, BlockModel<?>> blockModelSupplier){
if (!HalpLibe.isClient) return;
if (blockModelSupplier == null) return;
Expand All @@ -469,7 +470,7 @@ public static void queueBlockModel(@NotNull Block block, Function<Block, BlockMo
queuedBlockModels.put(block, blockModelSupplier);
}
public static boolean blockColorDispatcherInitialized = false;
public static final Map<Block, Function<Block, BlockColor>> queuedBlockColors = new HashMap<>();
public static final Map<Block, Function<Block, BlockColor>> queuedBlockColors = new LinkedHashMap<>();
public static void queueBlockColor(@NotNull Block block, Function<Block, BlockColor> blockColorSupplier){
if (!HalpLibe.isClient) return;
if (blockColorSupplier == null) return;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/turniplabs/halplibe/helper/EntityHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import turniplabs.halplibe.mixin.accessors.TileEntityRendererAccessor;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;

Expand All @@ -33,7 +34,7 @@ public static void createSpecialTileEntity(Class<? extends TileEntity> clazz, St
}
public static class Assignment {
public static boolean entityRendererDispatcherInitialized = false;
public static final Map<Class<? extends Entity> , Supplier<EntityRenderer<?>>> queuedEntityRenderer = new HashMap<>();
public static final Map<Class<? extends Entity> , Supplier<EntityRenderer<?>>> queuedEntityRenderer = new LinkedHashMap<>();
public static void queueEntityRenderer(@NotNull Class<? extends Entity> clazz, @NotNull Supplier<EntityRenderer<?>> rendererSupplier){
if (!HalpLibe.isClient) return;
if (rendererSupplier == null) return;
Expand All @@ -48,7 +49,7 @@ public static void queueEntityRenderer(@NotNull Class<? extends Entity> clazz, @
queuedEntityRenderer.put(clazz, rendererSupplier);
}
public static boolean tileEntityRendererDispatcherInitialized = false;
public static final Map<Class<? extends TileEntity> , Supplier<TileEntityRenderer<?>>> queuedTileEntityRenderer = new HashMap<>();
public static final Map<Class<? extends TileEntity> , Supplier<TileEntityRenderer<?>>> queuedTileEntityRenderer = new LinkedHashMap<>();
public static void queueTileEntityRenderer(@NotNull Class<? extends TileEntity> clazz, @NotNull Supplier<TileEntityRenderer<?>> rendererSupplier){
if (!HalpLibe.isClient) return;
if (rendererSupplier == null) return;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/turniplabs/halplibe/helper/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
Expand Down Expand Up @@ -122,7 +123,7 @@ public <T extends Item> T build(T item){

public static class Assignment{
public static boolean itemDispatcherInitialized = false;
public static final Map<Item, Function<Item, ItemModel>> queuedItemModels = new HashMap<>();
public static final Map<Item, Function<Item, ItemModel>> queuedItemModels = new LinkedHashMap<>();
public static <T extends Item> void queueItemModel(@NotNull T item, @NotNull Function<T, ItemModel> itemModelSupplier){
if (!HalpLibe.isClient) return;
if (itemDispatcherInitialized){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public abstract class BlockColorDispatcherMixin extends Dispatcher<Block, BlockC
private void addQueuedModels(CallbackInfo ci){
Set<Map.Entry<Block, Function<Block, BlockColor>>> entries = BlockBuilder.Assignment.queuedBlockColors.entrySet();
for (Map.Entry<Block, Function<Block, BlockColor>> entry : entries){
addDispatch(entry.getKey(),entry.getValue().apply(entry.getKey()));
try {
addDispatch(entry.getKey(),entry.getValue().apply(entry.getKey()));
} catch (Exception e){
throw new RuntimeException("Exception Occurred when applying " + entry.getKey().getKey(), e);
}
}
BlockBuilder.Assignment.blockColorDispatcherInitialized = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public abstract class BlockModelDispatcherMixin {
private void addQueuedModels(CallbackInfo ci){
Set<Map.Entry<Block, Function<Block, BlockModel<?>>>>entries = BlockBuilder.Assignment.queuedBlockModels.entrySet();
for (Map.Entry<Block, Function<Block, BlockModel<?>>> entry : entries){
addDispatch(entry.getValue().apply(entry.getKey()));
try {
addDispatch(entry.getValue().apply(entry.getKey()));
} catch (Exception e){
throw new RuntimeException("Exception Occurred when applying " + entry.getKey().getKey(), e);
}
}
BlockBuilder.Assignment.blockDispatcherInitialized = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public abstract class EntityRenderDispatcherMixin {
private void addQueuedModels(CallbackInfo ci){
Set<Map.Entry<Class<? extends Entity> , Supplier<EntityRenderer<?>>>> entries = EntityHelper.Assignment.queuedEntityRenderer.entrySet();
for (Map.Entry<Class<? extends Entity> , Supplier<EntityRenderer<?>>> entry : entries){
renderers.put(entry.getKey(), entry.getValue().get());
try {
renderers.put(entry.getKey(), entry.getValue().get());
} catch (Exception e){
throw new RuntimeException("Exception Occurred when applying " + entry.getKey().getSimpleName(), e);
}
}
EntityHelper.Assignment.entityRendererDispatcherInitialized = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public abstract class ItemModelDispatcherMixin {
private void addQueuedModels(CallbackInfo ci){
Set<Map.Entry<Item, Function<Item, ItemModel>>> entries = ItemBuilder.Assignment.queuedItemModels.entrySet();
for (Map.Entry<Item, Function<Item, ItemModel>> entry : entries){
addDispatch(entry.getValue().apply(entry.getKey()));
try {
addDispatch(entry.getValue().apply(entry.getKey()));
} catch (Exception e){
throw new RuntimeException("Exception Occurred when applying " + entry.getKey().getKey(), e);
}
}
ItemBuilder.Assignment.itemDispatcherInitialized = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public class TileEntityRendererDispatcherMixin {
private void addQueuedModels(CallbackInfo ci){
Set<Map.Entry<Class<? extends TileEntity> , Supplier<TileEntityRenderer<?>>>> entries = EntityHelper.Assignment.queuedTileEntityRenderer.entrySet();
for (Map.Entry<Class<? extends TileEntity> , Supplier<TileEntityRenderer<?>>> entry : entries){
renderers.put(entry.getKey(), entry.getValue().get());
try {
renderers.put(entry.getKey(), entry.getValue().get());
} catch (Exception e){
throw new RuntimeException("Exception Occurred when applying " + entry.getKey().getSimpleName(), e);
}
}
EntityHelper.Assignment.tileEntityRendererDispatcherInitialized = true;
}
Expand Down

0 comments on commit c0e499d

Please sign in to comment.