Skip to content

Commit 6e9dfaf

Browse files
committed
Enable NeoForge project
1 parent 9d584d1 commit 6e9dfaf

File tree

20 files changed

+49
-895
lines changed

20 files changed

+49
-895
lines changed
Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package org.embeddedt.modernfix.api.entrypoint;
22

3-
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
4-
import net.minecraft.client.resources.model.*;
5-
import net.minecraft.resources.ResourceLocation;
6-
7-
import java.util.function.Function;
8-
9-
103
/**
114
* Implement this interface in a mod class and add it to "modernfix:integration_v1" in your mod metadata file
125
* to integrate with ModernFix's features.
@@ -20,58 +13,4 @@ public interface ModernFixClientIntegration {
2013
*/
2114
default void onDynamicResourcesStatusChange(boolean enabled) {
2215
}
23-
24-
/**
25-
* Called to allow mods to observe the loading of an unbaked model and either make changes to it or wrap it with their
26-
* own instance.
27-
* @param location the ResourceLocation of the model (this may be a ModelResourceLocation)
28-
* @param originalModel the original model
29-
* @param bakery the model bakery - do not touch internal fields as they probably don't behave the way you expect
30-
* with dynamic resources on
31-
* @return the model which should actually be loaded for this resource location
32-
*/
33-
default UnbakedModel onUnbakedModelLoad(ResourceLocation location, UnbakedModel originalModel, ModelBakery bakery) {
34-
return originalModel;
35-
}
36-
37-
/**
38-
* Called to allow mods to observe the use of an unbaked model at bake time and either make changes to it or wrap it with their
39-
* own instance.
40-
* @param location the ResourceLocation of the model (this may be a ModelResourceLocation)
41-
* @param originalModel the original model
42-
* @param bakery the model bakery - do not touch internal fields as they probably don't behave the way you expect
43-
* with dynamic resources on
44-
* @return the model which should actually be loaded for this resource location
45-
*/
46-
default UnbakedModel onUnbakedModelPreBake(ResourceLocation location, UnbakedModel originalModel, ModelBakery bakery) {
47-
return originalModel;
48-
}
49-
50-
/**
51-
* Called to allow mods to observe the loading of a baked model and either make changes to it or wrap it with their
52-
* own instance.
53-
* @param location the ResourceLocation of the model (this may be a ModelResourceLocation)
54-
* @param originalModel the original model
55-
* @param bakery the model bakery - do not touch internal fields as they probably don't behave the way you expect
56-
* with dynamic resources on
57-
* @return the model which should actually be loaded for this resource location
58-
*/
59-
@Deprecated
60-
default BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery) {
61-
return originalModel;
62-
}
63-
64-
/**
65-
* Called to allow mods to observe the loading of a baked model and either make changes to it or wrap it with their
66-
* own instance.
67-
* @param location the ResourceLocation of the model (this may be a ModelResourceLocation)
68-
* @param originalModel the original model
69-
* @param bakery the model bakery - do not touch internal fields as they probably don't behave the way you expect
70-
* with dynamic resources on
71-
* @param textureGetter function to retrieve textures for this model
72-
* @return the model which should actually be loaded for this resource location
73-
*/
74-
default BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery, Function<Material, TextureAtlasSprite> textureGetter) {
75-
return onBakedModelLoad(location, baseModel, originalModel, state, bakery);
76-
}
7716
}

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/blast_search_trees/SessionSearchTreesMixin.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.embeddedt.modernfix.searchtree.SearchTreeProviderRegistry;
1414
import org.lwjgl.glfw.GLFW;
1515
import org.lwjgl.glfw.GLFWErrorCallback;
16+
import org.spongepowered.asm.mixin.Final;
1617
import org.spongepowered.asm.mixin.Mixin;
1718
import org.spongepowered.asm.mixin.Shadow;
1819
import org.spongepowered.asm.mixin.injection.At;
@@ -28,6 +29,8 @@
2829
public abstract class SessionSearchTreesMixin {
2930
@Shadow private CompletableFuture<SearchTree<RecipeCollection>> recipeSearch;
3031
@Shadow private CompletableFuture<SearchTree<ItemStack>> creativeByNameSearch;
32+
@Shadow @Final private static SessionSearchTrees.Key CREATIVE_NAMES;
33+
@Shadow @Final private static SessionSearchTrees.Key CREATIVE_TAGS;
3134
private SearchTreeProviderRegistry.Provider mfix$provider;
3235

3336
@Inject(method = "<init>", at = @At("RETURN"))
@@ -63,11 +66,12 @@ private Runnable useModernFixRecipeTree(Runnable r, @Local(ordinal = 0, argsOnly
6366
}
6467
}
6568

66-
@ModifyArg(method = "updateCreativeTooltips", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/SessionSearchTrees;register(Lnet/minecraft/client/multiplayer/SessionSearchTrees$Key;Ljava/lang/Runnable;)V"), index = 1)
67-
private Runnable useSearchModItems(Runnable r) {
69+
@ModifyArg(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/SessionSearchTrees;register(Lnet/minecraft/client/multiplayer/SessionSearchTrees$Key;Ljava/lang/Runnable;)V"), index = 1)
70+
private Runnable useOverridenSearchTreeLogic(SessionSearchTrees.Key key, Runnable r) {
6871
if(mfix$provider == null) {
6972
return r;
70-
} else {
73+
}
74+
if(key == CREATIVE_NAMES) {
7175
return () -> {
7276
CompletableFuture<?> old = this.creativeByNameSearch;
7377
this.creativeByNameSearch = CompletableFuture.supplyAsync(() -> {
@@ -76,13 +80,7 @@ private Runnable useSearchModItems(Runnable r) {
7680
old.cancel(true);
7781
};
7882
}
79-
}
80-
81-
@ModifyArg(method = "updateCreativeTags", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/SessionSearchTrees;register(Lnet/minecraft/client/multiplayer/SessionSearchTrees$Key;Ljava/lang/Runnable;)V"), index = 1)
82-
private Runnable useSearchModTags(Runnable r) {
83-
if(mfix$provider == null) {
84-
return r;
85-
} else {
83+
if(key == CREATIVE_TAGS) {
8684
return () -> {
8785
CompletableFuture<?> old = this.creativeByNameSearch;
8886
this.creativeByNameSearch = CompletableFuture.supplyAsync(() -> {
@@ -91,5 +89,6 @@ private Runnable useSearchModTags(Runnable r) {
9189
old.cancel(true);
9290
};
9391
}
92+
return r;
9493
}
9594
}

common/src/main/java/org/embeddedt/modernfix/dynamicresources/ModelBakeryHelpers.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
import com.google.common.base.Splitter;
44
import com.google.common.collect.ImmutableList;
5-
import com.mojang.datafixers.util.Pair;
65
import net.minecraft.client.resources.model.*;
7-
import net.minecraft.resources.ResourceLocation;
86
import net.minecraft.world.level.block.Block;
97
import net.minecraft.world.level.block.state.BlockState;
108
import net.minecraft.world.level.block.state.StateDefinition;
119
import net.minecraft.world.level.block.state.properties.Property;
12-
import org.embeddedt.modernfix.api.entrypoint.ModernFixClientIntegration;
1310

1411
import java.util.*;
15-
import java.util.function.BiFunction;
1612

1713
public class ModelBakeryHelpers {
1814
/**
@@ -108,13 +104,4 @@ public static ImmutableList<BlockState> getBlockStatesForMRL(StateDefinition<Blo
108104
}
109105
return ImmutableList.copyOf(finalList);
110106
}
111-
112-
public static ModernFixClientIntegration bakedModelWrapper(BiFunction<ResourceLocation, Pair<UnbakedModel, BakedModel>, BakedModel> consumer) {
113-
return new ModernFixClientIntegration() {
114-
@Override
115-
public BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery) {
116-
return consumer.apply(location, Pair.of(baseModel, originalModel));
117-
}
118-
};
119-
}
120107
}

common/src/main/resources/modernfix.accesswidener

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ accessible field net/minecraft/client/renderer/block/model/multipart/MultiPart d
3838
accessible field net/minecraft/client/renderer/block/model/ItemOverrides$BakedOverride model Lnet/minecraft/client/resources/model/BakedModel;
3939
mutable field net/minecraft/client/renderer/block/model/ItemOverrides$BakedOverride model Lnet/minecraft/client/resources/model/BakedModel;
4040
accessible field net/minecraft/client/renderer/entity/EnderDragonRenderer$DragonModel entity Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;
41-
accessible method net/minecraft/world/level/block/state/StateDefinition appendPropertyCodec (Lcom/mojang/serialization/MapCodec;Ljava/util/function/Supplier;Ljava/lang/String;Lnet/minecraft/world/level/block/state/properties/Property;)Lcom/mojang/serialization/MapCodec;
41+
accessible method net/minecraft/world/level/block/state/StateDefinition appendPropertyCodec (Lcom/mojang/serialization/MapCodec;Ljava/util/function/Supplier;Ljava/lang/String;Lnet/minecraft/world/level/block/state/properties/Property;)Lcom/mojang/serialization/MapCodec;
42+
accessible class net/minecraft/client/multiplayer/SessionSearchTrees$Key

gradle.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ junit_version=5.10.0-M1
55
mixinextras_version=0.3.2
66

77
mod_id=modernfix
8-
minecraft_version=1.21-pre3
9-
enabled_platforms=fabric
10-
forge_version=20.6.100-beta
8+
minecraft_version=1.21-pre4
9+
enabled_platforms=fabric,neoforge
10+
forge_version=21.0.0-alpha.1.21-pre4.20240609.000029
11+
neoforge_pr=1076
1112
# parchment_version=2023.07.09
1213
refined_storage_version=4392788
1314
jei_version=16.0.0.28
1415
rei_version=13.0.678
1516
ctm_version=1.20.1-1.1.8+4
1617
kubejs_version=1902.6.0-build.142
1718
rhino_version=1902.2.2-build.268
18-
supported_minecraft_versions=1.21-pre3
19+
supported_minecraft_versions=1.21-pre4
1920

2021
fabric_loader_version=0.15.11
2122
fabric_api_version=0.100.0+1.21

neoforge/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ repositories {
3131
}
3232
}
3333
maven { url "https://maven.neoforged.net" }
34+
if(rootProject.hasProperty("neoforge_pr")) {
35+
maven {
36+
url 'https://prmaven.neoforged.net/NeoForge/pr' + rootProject.neoforge_pr
37+
content {
38+
includeModule('net.neoforged', 'neoforge')
39+
includeModule('net.neoforged', 'testframework')
40+
}
41+
}
42+
}
3443
}
3544

3645
dependencies {

neoforge/src/main/java/org/embeddedt/modernfix/neoforge/ModernFixConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ModernFixConfig {
3232

3333
public static Set<ResourceLocation> getJeiPluginBlacklist() {
3434
if(jeiPluginBlacklist == null) {
35-
jeiPluginBlacklist = BLACKLIST_ASYNC_JEI_PLUGINS.get().stream().map(ResourceLocation::new).collect(Collectors.toSet());
35+
jeiPluginBlacklist = BLACKLIST_ASYNC_JEI_PLUGINS.get().stream().map(ResourceLocation::parse).collect(Collectors.toSet());
3636
}
3737
return jeiPluginBlacklist;
3838
}

neoforge/src/main/java/org/embeddedt/modernfix/neoforge/dynresources/ModelBakeEventHelper.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class ModelBakeEventHelper {
3434
"vampirism",
3535
"elevatorid",
3636
"embers");
37-
private final Map<ResourceLocation, BakedModel> modelRegistry;
38-
private final Set<ResourceLocation> topLevelModelLocations;
37+
private final Map<ModelResourceLocation, BakedModel> modelRegistry;
38+
private final Set<ModelResourceLocation> topLevelModelLocations;
3939
private final MutableGraph<String> dependencyGraph;
40-
public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) {
40+
public ModelBakeEventHelper(Map<ModelResourceLocation, BakedModel> modelRegistry) {
4141
this.modelRegistry = modelRegistry;
4242
this.topLevelModelLocations = new HashSet<>(modelRegistry.keySet());
4343
// Skip going through ModelLocationCache because most of the accesses will be misses
@@ -74,10 +74,10 @@ public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) {
7474
* @param modId the mod that the event is being fired for
7575
* @return a wrapper around the model registry
7676
*/
77-
private Map<ResourceLocation, BakedModel> createWarningRegistry(String modId) {
78-
return new ForwardingInclDefaultsMap<ResourceLocation, BakedModel>() {
77+
private Map<ModelResourceLocation, BakedModel> createWarningRegistry(String modId) {
78+
return new ForwardingInclDefaultsMap<ModelResourceLocation, BakedModel>() {
7979
@Override
80-
protected Map<ResourceLocation, BakedModel> delegate() {
80+
protected Map<ModelResourceLocation, BakedModel> delegate() {
8181
return modelRegistry;
8282
}
8383

@@ -89,13 +89,13 @@ private void logWarning() {
8989
}
9090

9191
@Override
92-
public Set<ResourceLocation> keySet() {
92+
public Set<ModelResourceLocation> keySet() {
9393
logWarning();
9494
return super.keySet();
9595
}
9696

9797
@Override
98-
public Set<Entry<ResourceLocation, BakedModel>> entrySet() {
98+
public Set<Entry<ModelResourceLocation, BakedModel>> entrySet() {
9999
logWarning();
100100
return super.entrySet();
101101
}
@@ -107,14 +107,14 @@ public Collection<BakedModel> values() {
107107
}
108108

109109
@Override
110-
public void replaceAll(BiFunction<? super ResourceLocation, ? super BakedModel, ? extends BakedModel> function) {
110+
public void replaceAll(BiFunction<? super ModelResourceLocation, ? super BakedModel, ? extends BakedModel> function) {
111111
logWarning();
112112
super.replaceAll(function);
113113
}
114114
};
115115
}
116116

117-
public Map<ResourceLocation, BakedModel> wrapRegistry(String modId) {
117+
public Map<ModelResourceLocation, BakedModel> wrapRegistry(String modId) {
118118
final Set<String> modIdsToInclude = new HashSet<>();
119119
modIdsToInclude.add(modId);
120120
try {
@@ -123,11 +123,11 @@ public Map<ResourceLocation, BakedModel> wrapRegistry(String modId) {
123123
modIdsToInclude.remove("minecraft");
124124
if(modIdsToInclude.stream().noneMatch(INCOMPATIBLE_MODS::contains))
125125
return createWarningRegistry(modId);
126-
Set<ResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.getNamespace()));
126+
Set<ModelResourceLocation> ourModelLocations = Sets.filter(this.topLevelModelLocations, loc -> modIdsToInclude.contains(loc.id().getNamespace()));
127127
BakedModel missingModel = modelRegistry.get(ModelBakery.MISSING_MODEL_LOCATION);
128-
return new ForwardingMap<ResourceLocation, BakedModel>() {
128+
return new ForwardingMap<ModelResourceLocation, BakedModel>() {
129129
@Override
130-
protected Map<ResourceLocation, BakedModel> delegate() {
130+
protected Map<ModelResourceLocation, BakedModel> delegate() {
131131
return modelRegistry;
132132
}
133133

@@ -142,7 +142,7 @@ public BakedModel get(@Nullable Object key) {
142142
}
143143

144144
@Override
145-
public Set<ResourceLocation> keySet() {
145+
public Set<ModelResourceLocation> keySet() {
146146
return ourModelLocations;
147147
}
148148

@@ -152,10 +152,10 @@ public boolean containsKey(@Nullable Object key) {
152152
}
153153

154154
@Override
155-
public void replaceAll(BiFunction<? super ResourceLocation, ? super BakedModel, ? extends BakedModel> function) {
155+
public void replaceAll(BiFunction<? super ModelResourceLocation, ? super BakedModel, ? extends BakedModel> function) {
156156
ModernFix.LOGGER.warn("Mod '{}' is calling replaceAll on the model registry. Some hacks will be used to keep this fast, but they may not be 100% compatible.", modId);
157-
List<ResourceLocation> locations = new ArrayList<>(keySet());
158-
for(ResourceLocation location : locations) {
157+
List<ModelResourceLocation> locations = new ArrayList<>(keySet());
158+
for(ModelResourceLocation location : locations) {
159159
/*
160160
* Fetching every model is insanely slow. So we call the function with a null object first, since it
161161
* probably isn't expecting that. If we get an exception thrown, or it returns nonnull, then we know

neoforge/src/main/java/org/embeddedt/modernfix/neoforge/init/ModernFixForge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private void registerItems(RegisterEvent event) {
6565
event.register(Registries.ITEM, helper -> {
6666
Item.Properties props = new Item.Properties();
6767
for(int i = 0; i < 1000000; i++) {
68-
helper.register(new ResourceLocation("modernfix", "item_" + i), new Item(props));
68+
helper.register(ResourceLocation.fromNamespaceAndPath("modernfix", "item_" + i), new Item(props));
6969
}
7070
});
7171
}

neoforge/src/main/java/org/embeddedt/modernfix/neoforge/mixin/bugfix/chunk_deadlock/ChunkMapLoadMixin.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)