-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Neoforge 21.4.84 support, add breaks with sodium 0.6.6 or below to mo…
…ds file Fixes: #337
- Loading branch information
Showing
9 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
fabric/src/main/java/ca/fxco/moreculling/MoreCullingFabric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,51 @@ | ||
package ca.fxco.moreculling; | ||
|
||
import ca.fxco.moreculling.api.model.BakedOpacity; | ||
import ca.fxco.moreculling.mixin.accessors.BlockModelShaperAccessor; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; | ||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.PackType; | ||
import net.minecraft.server.packs.resources.ResourceManager; | ||
import net.minecraft.util.Unit; | ||
import net.minecraft.util.profiling.Profiler; | ||
import net.minecraft.util.profiling.ProfilerFiller; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
|
||
import static ca.fxco.moreculling.MoreCulling.blockRenderManager; | ||
|
||
public class MoreCullingFabric implements ClientModInitializer { | ||
@Override | ||
public void onInitializeClient() { | ||
MoreCulling.init(); | ||
|
||
ResourceManagerHelper.get(PackType.CLIENT_RESOURCES) | ||
.registerReloadListener(new IdentifiableResourceReloadListener() { | ||
@Override | ||
public ResourceLocation getFabricId() { | ||
return MoreCulling.RELOAD_LISTENER_ID; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> reload(PreparationBarrier barrier, ResourceManager manager, Executor backgroundExecutor, Executor gameExecutor) { | ||
return barrier.wait(Unit.INSTANCE).thenRunAsync(() -> { | ||
ProfilerFiller profilerfiller = Profiler.get(); | ||
profilerfiller.push("listener"); | ||
|
||
Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache); | ||
|
||
((BlockModelShaperAccessor) blockRenderManager.getBlockModelShaper()).getModels() | ||
.forEach((state, model) -> | ||
((BakedOpacity) model).moreculling$resetTranslucencyCache(state)); | ||
|
||
profilerfiller.pop(); | ||
}, gameExecutor); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 34 additions & 2 deletions
36
neoforge/src/main/java/ca/fxco/moreculling/MoreCullingNeoforge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,48 @@ | ||
package ca.fxco.moreculling; | ||
|
||
import ca.fxco.moreculling.api.model.BakedOpacity; | ||
import ca.fxco.moreculling.config.ModMenuConfig; | ||
import ca.fxco.moreculling.mixin.accessors.BlockModelShaperAccessor; | ||
import net.minecraft.util.Unit; | ||
import net.minecraft.util.profiling.Profiler; | ||
import net.minecraft.util.profiling.ProfilerFiller; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.fml.ModContainer; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent; | ||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory; | ||
|
||
import static ca.fxco.moreculling.MoreCulling.blockRenderManager; | ||
|
||
@Mod(value = MoreCulling.MOD_ID, dist = Dist.CLIENT) | ||
public class MoreCullingNeoforge { | ||
public MoreCullingNeoforge(ModContainer container) { | ||
public MoreCullingNeoforge(ModContainer container, IEventBus bus) { | ||
MoreCulling.init(); | ||
|
||
container.registerExtensionPoint(IConfigScreenFactory.class, (con, screen) -> ModMenuConfig.createConfigScreen(screen)); | ||
container.registerExtensionPoint(IConfigScreenFactory.class, | ||
(con, screen) -> ModMenuConfig.createConfigScreen(screen)); | ||
|
||
bus.addListener(this::registerReloadListener); | ||
} | ||
|
||
public void registerReloadListener(AddClientReloadListenersEvent event) { | ||
event.addListener(MoreCulling.RELOAD_LISTENER_ID, (barrier, | ||
resourceManager, | ||
executor, gameExecutor) -> | ||
barrier.wait(Unit.INSTANCE).thenRunAsync(() -> { | ||
ProfilerFiller profilerfiller = Profiler.get(); | ||
profilerfiller.push("listener"); | ||
|
||
Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache); | ||
|
||
((BlockModelShaperAccessor) blockRenderManager.getBlockModelShaper()).getModels() | ||
.forEach((state, model) -> | ||
((BakedOpacity) model).moreculling$resetTranslucencyCache(state)); | ||
|
||
profilerfiller.pop(); | ||
}, gameExecutor)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters