Skip to content

Commit

Permalink
Port to 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed May 12, 2024
1 parent eec8791 commit 9f826d7
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 108 deletions.
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ plugins {
repositories {
gradlePluginPortal()
mavenCentral()
maven("https://maven.minecraftforge.net/") {
name = "MinecraftForge"
maven("https://maven.neoforged.net/releases/") {
name = "NeoForged"
}
maven("https://maven.architectury.dev/") {
name = "Architectury"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class SubprojectPlugin: Plugin<Project> {
val loom = project.the<LoomGradleExtensionAPI>()
loom.silentMojangMappingsLicense()

// FIXME y tho? :(
loom.mixin.useLegacyMixinAp = true
loom.mixin.defaultRefmapName = "flywheel.refmap.json"
}

Expand Down Expand Up @@ -181,6 +183,6 @@ val processResourcesExpandProperties = listOf(
"minecraft_semver_version_range",
"minecraft_maven_version_range",
"fabric_api_version_range",
"forge_version_range",
"neoforge_version_range",
)

Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract class LevelRendererMixin {
flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN);
}

@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER))
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderSectionLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER))
private void flywheel$onStage$afterTranslucentTerrain(CallbackInfo ci) {
flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN);
}
Expand All @@ -113,6 +113,7 @@ abstract class LevelRendererMixin {
flywheel$dispatch(RenderStage.AFTER_PARTICLES);
}

//fixme take a look over if this is still needed
@Group(name = "onStage$afterParticles")
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;)V", shift = Shift.AFTER))
private void flywheel$onStage$afterParticles$forge(CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import net.minecraft.world.level.block.entity.BlockEntity;

@Mixin(targets = "net.minecraft.client.renderer.chunk.ChunkRenderDispatcher$RenderChunk$RebuildTask")
@Mixin(targets = "net.minecraft.client.renderer.chunk.SectionRenderDispatcher$RenderSection$RebuildTask")
abstract class RebuildTaskMixin {
@Inject(method = "handleBlockEntity(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$RebuildTask$CompileResults;Lnet/minecraft/world/level/block/entity/BlockEntity;)V", at = @At("HEAD"), cancellable = true)
@Inject(method = "handleBlockEntity(Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection$RebuildTask$CompileResults;Lnet/minecraft/world/level/block/entity/BlockEntity;)V", at = @At("HEAD"), cancellable = true)
private void flywheel$tryAddBlockEntity(@Coerce Object compileResults, BlockEntity blockEntity, CallbackInfo ci) {
if (VisualizationHelper.tryAddBlockEntity(blockEntity)) {
ci.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

Expand All @@ -21,14 +22,14 @@ abstract class MinecraftMixin {
@Final
private ReloadableResourceManager resourceManager;

@Inject(method = "method_24040", at = @At("HEAD"))
private void flywheel$onEndInitialResourceReload(Optional<Throwable> error, CallbackInfo ci) {
@Inject(method = "method_53522", at = @At("HEAD"))
private void flywheel$onEndInitialResourceReload(@Coerce Object gameLoadCookie, Optional<Throwable> error, CallbackInfo ci) {
EndClientResourceReloadCallback.EVENT.invoker()
.onEndClientResourceReload((Minecraft) (Object) this, resourceManager, true, error);
}

@Inject(method = "method_24228", at = @At("HEAD"))
private void flywheel$onEndManualResourceReload(boolean recovery, CompletableFuture<Void> future,
private void flywheel$onEndManualResourceReload(boolean recovery, @Coerce Object gameLoadCookie, CompletableFuture<Void> future,
Optional<Throwable> error, CallbackInfo ci) {
EndClientResourceReloadCallback.EVENT.invoker()
.onEndClientResourceReload((Minecraft) (Object) this, resourceManager, false, error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class MinecraftMixin {
}
}

@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
@Inject(method = "clearClientLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
private void flywheel$onClearLevel(CallbackInfo ci) {
if (level != null) {
LevelAttached.invalidateLevel(level);
Expand Down
12 changes: 5 additions & 7 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ defaultPackageInfos {
}

loom {
forge {
mixinConfig("flywheel.backend.mixins.json")
mixinConfig("flywheel.impl.mixins.json")
mixinConfig("flywheel.impl.sodium.mixins.json")
}

runs {
configureEach {
property("forge.logging.markers", "")
Expand All @@ -69,8 +63,12 @@ loom {
}
}

repositories {
maven("https://maven.neoforged.net/releases/")
}

dependencies {
forge("net.minecraftforge:forge:${property("minecraft_version")}-${property("forge_version")}")
neoForge("net.neoforged:neoforge:${property("neoforge_version")}")

modCompileOnly("maven.modrinth:embeddium:${property("embeddium_version")}")
modCompileOnly("maven.modrinth:oculus:${property("oculus_version")}")
Expand Down
2 changes: 1 addition & 1 deletion forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
loom.platform = forge
loom.platform = neoforge
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.jozufozu.flywheel.api.event;

import net.minecraftforge.eventbus.api.Event;
import net.neoforged.bus.api.Event;

/**
* This event is posted to the Forge event bus.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import net.minecraft.client.Minecraft;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent;
import net.neoforged.bus.api.Event;
import net.neoforged.fml.event.IModBusEvent;

/**
* This event is posted to mod event buses.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.jozufozu.flywheel.api.event;

import net.neoforged.bus.api.Event;

import org.jetbrains.annotations.Nullable;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraftforge.eventbus.api.Event;

/**
* This event is posted to the Forge event bus.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.jozufozu.flywheel.api.event;

import net.neoforged.bus.api.Event;

import org.joml.Matrix4f;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraftforge.eventbus.api.Event;

/**
* This event is posted to the Forge event bus.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.util.Iterator;
import java.util.function.Function;

import net.neoforged.neoforge.client.ChunkRenderTypeSet;
import net.neoforged.neoforge.client.model.data.ModelData;

import org.jetbrains.annotations.Nullable;

import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
Expand All @@ -20,8 +23,6 @@
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraftforge.client.ChunkRenderTypeSet;
import net.minecraftforge.client.model.data.ModelData;

final class BakedModelBufferer {
private static final RenderType[] CHUNK_LAYERS = RenderType.chunkBufferLayers().toArray(RenderType[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.function.BiFunction;

import net.neoforged.neoforge.client.model.data.ModelData;

import org.jetbrains.annotations.Nullable;

import com.google.common.collect.ImmutableList;
Expand All @@ -20,7 +22,6 @@
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelData;

public final class ForgeBakedModelBuilder extends BakedModelBuilder {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.function.BiFunction;

import net.neoforged.neoforge.client.model.data.ModelData;

import org.jetbrains.annotations.Nullable;

import com.google.common.collect.ImmutableList;
Expand All @@ -18,7 +20,6 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelData;

public final class ForgeBlockModelBuilder extends BlockModelBuilder {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.function.BiFunction;
import java.util.function.Function;

import net.neoforged.neoforge.client.model.data.ModelData;

import org.jetbrains.annotations.Nullable;

import com.google.common.collect.ImmutableList;
Expand All @@ -19,7 +21,6 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraftforge.client.model.data.ModelData;

public final class ForgeMultiBlockModelBuilder extends MultiBlockModelBuilder {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import java.util.Map;

import net.neoforged.neoforge.client.event.ModelEvent;

import org.jetbrains.annotations.ApiStatus;

import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.event.ModelEvent;

@ApiStatus.Internal
public final class PartialModelEventHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
import net.neoforged.neoforge.common.ModConfigSpec;

public final class FlwCommands {
private FlwCommands() {
Expand All @@ -28,7 +27,7 @@ public static void registerClientCommands(RegisterClientCommandsEvent event) {

LiteralArgumentBuilder<CommandSourceStack> command = Commands.literal("flywheel");

ConfigValue<String> backendValue = config.client.backend;
ModConfigSpec.ConfigValue<String> backendValue = config.client.backend;
command.then(Commands.literal("backend")
.executes(context -> {
Backend backend = BackendManager.getBackend();
Expand Down Expand Up @@ -58,7 +57,7 @@ public static void registerClientCommands(RegisterClientCommandsEvent event) {
return Command.SINGLE_SUCCESS;
})));

BooleanValue limitUpdatesValue = config.client.limitUpdates;
ModConfigSpec.BooleanValue limitUpdatesValue = config.client.limitUpdates;
command.then(Commands.literal("limitUpdates")
.executes(context -> {
if (limitUpdatesValue.get()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jozufozu.flywheel.impl;

import net.neoforged.neoforge.common.NeoForge;

import org.jetbrains.annotations.Nullable;

import com.jozufozu.flywheel.api.event.BeginFrameEvent;
Expand All @@ -9,22 +11,21 @@
import com.jozufozu.flywheel.api.event.RenderStageEvent;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraftforge.common.MinecraftForge;

public class FlwImplXplatImpl implements FlwImplXplat {
@Override
public void dispatchBeginFrameEvent(RenderContext context) {
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(context));
NeoForge.EVENT_BUS.post(new BeginFrameEvent(context));
}

@Override
public void dispatchReloadLevelRendererEvent(@Nullable ClientLevel level) {
MinecraftForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level));
NeoForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level));
}

@Override
public void dispatchRenderStageEvent(RenderContext context, RenderStage stage) {
MinecraftForge.EVENT_BUS.post(new RenderStageEvent(context, stage));
NeoForge.EVENT_BUS.post(new RenderStageEvent(context, stage));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.lang.reflect.Field;

import net.neoforged.fml.ModList;
import net.neoforged.fml.util.ObfuscationReflectionHelper;

import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;

Expand All @@ -23,8 +26,6 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;

public class FlwLibXplatImpl implements FlwLibXplat {
private static final Logger LOGGER = LogUtils.getLogger();
Expand All @@ -38,6 +39,7 @@ public BlockRenderDispatcher createVanillaBlockRenderDispatcher() {
field.setAccessible(true);
field.set(dispatcher, field.get(defaultDispatcher));
}
// fixme ~ is this still needed? neoforge uses mojmap at runtime
ObfuscationReflectionHelper.setPrivateValue(BlockRenderDispatcher.class, dispatcher, new ModelBlockRenderer(Minecraft.getInstance().getBlockColors()), "f_110900_");
} catch (Exception e) {
LOGGER.error("Failed to initialize vanilla BlockRenderDispatcher!", e);
Expand Down
Loading

0 comments on commit 9f826d7

Please sign in to comment.