Skip to content

Commit

Permalink
Fix various issues with port to neo
Browse files Browse the repository at this point in the history
- Adjust injector for recipe remainders
- Fix issues with inability to check for the ability to send handshake packet
- Adjust OwoShaderProgram to use Identifier instead of string
- Fix possible null exception within ItemSettings and Item mixin
- Bump networking
  • Loading branch information
Dragon-Seeker committed Sep 10, 2024
1 parent a7640b5 commit 94afcc2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ dependencies {
api("org.sinytra:forgified-fabric-loader:2.5.29+0.16.0+1.21")

include modApi("org.sinytra.forgified-fabric-api:fabric-api-base:0.4.42+d1308dedd1") { exclude group: "fabric-api" }
include modApi("org.sinytra.forgified-fabric-api:fabric-networking-api-v1:4.2.2+c9adfcd719") { exclude group: "fabric-api" }
include modApi("org.sinytra.forgified-fabric-api:fabric-networking-api-v1:4.2.2+a92978fd19") { exclude group: "fabric-api" }
include modApi("org.sinytra.forgified-fabric-api:fabric-screen-api-v1:2.0.24+79a4c2b0d1") { exclude group: "fabric-api" }

testmodImplementation sourceSets.main.output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Mixin(Item.class)
public class ItemMixin implements OwoItemExtensions {

protected Supplier<@Nullable ? extends ItemGroup> owo$group = () -> null;
protected @Nullable Supplier<@Nullable ? extends ItemGroup> owo$group = () -> null;

@Unique
private int owo$tab = 0;
Expand Down Expand Up @@ -53,7 +53,7 @@ private void grabTab(Item.Settings settings, CallbackInfo ci) {

@Override
public @Nullable ItemGroup owo$group() {
return this.owo$group.get();
return this.owo$group != null ? this.owo$group.get() : null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Item.Settings group(Supplier<OwoItemGroup> groupSupplier) {

@Override
public OwoItemGroup group() {
return owo$group.get();
return owo$group != null ? owo$group.get() : null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.World;
import net.neoforged.neoforge.common.conditions.WithConditions;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -33,8 +35,12 @@
@Mixin(RecipeManager.class)
public abstract class RecipeManagerMixin {

@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeEntry;<init>(Lnet/minecraft/util/Identifier;Lnet/minecraft/recipe/Recipe;)V"))
private void deserializeRecipeSpecificRemainders(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, @Local Map.Entry<Identifier, JsonElement> entry) {
public final ThreadLocal<Map.Entry<Identifier, JsonElement>> previousMapEntry = ThreadLocal.withInitial(() -> null);

@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Ljava/util/Optional;ifPresentOrElse(Ljava/util/function/Consumer;Ljava/lang/Runnable;)V"))
private void deserializeRecipeSpecificRemainders(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, @Local Map.Entry<Identifier, JsonElement> entry, @Local Optional<WithConditions<Recipe<?>>> decoded) {
if(decoded.isEmpty()) return;

var json = entry.getValue().getAsJsonObject();
if (!json.has("owo:remainders")) return;

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/wispforest/owo/network/OwoHandshake.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.fml.loading.FMLLoader;
import org.jetbrains.annotations.ApiStatus;
import org.sinytra.fabric.networking_api.client.NeoClientConfigurationNetworking;

import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -161,7 +162,8 @@ private static void syncServer(HandshakeResponse response, ServerConfigurationNe

@OnlyIn(Dist.CLIENT)
private static void handleReadyClient(ClientConfigurationNetworkHandler handler, MinecraftClient client) {
if (ClientConfigurationNetworking.canSend(CHANNEL_ID) || !HANDSHAKE_REQUIRED || !ENABLED) return;
// TODO: Report issues with ClientConfigurationNetworking.canSend(CHANNEL_ID)
if (NeoClientConfigurationNetworking.canSend(CHANNEL_ID) || !HANDSHAKE_REQUIRED || !ENABLED) return;

client.execute(() -> {
((ClientCommonNetworkHandlerAccessor) handler)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/wispforest/owo/shader/GlProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public GlProgram(Identifier id, VertexFormat vertexFormat) {
REGISTERED_PROGRAMS.add(new Pair<>(
resourceFactory -> {
try {
return new OwoShaderProgram(resourceFactory, id.toString(), vertexFormat);
return new OwoShaderProgram(resourceFactory, id, vertexFormat);
} catch (IOException e) {
throw new RuntimeException("Failed to initialized owo shader program", e);
}
Expand Down Expand Up @@ -89,8 +89,8 @@ public static void forEachProgram(Consumer<Pair<Function<ResourceFactory, Shader
}

public static class OwoShaderProgram extends ShaderProgram {
private OwoShaderProgram(ResourceFactory factory, String name, VertexFormat format) throws IOException {
super(factory, name, format);
private OwoShaderProgram(ResourceFactory factory, Identifier id, VertexFormat format) throws IOException {
super(factory, id, format);
}
}
}
4 changes: 2 additions & 2 deletions src/testmod/java/io/wispforest/uwu/Uwu.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public Uwu(IEventBus eventBus) {
new ParticleSystemController(Identifier.of("uwu", "server_only_particles"));
}

System.out.println(RegistryAccess.getEntry(Registries.ITEM, Items.ACACIA_BOAT));
System.out.println(RegistryAccess.getEntry(Registries.ITEM, Identifier.of("acacia_planks")));
System.out.println(Registries.ITEM.getEntry(Items.ACACIA_BOAT));
System.out.println(Registries.ITEM.getEntry(Identifier.of("acacia_planks")));

// UwuShapedRecipe.init();

Expand Down
2 changes: 1 addition & 1 deletion src/testmod/resources/assets/uwu/owo_ui/parse_fail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<blur quality="3" size="5"/>
</surface>
<!-- invalid xml -->
</flow-layout
</flow-layout>
</components>
</owo-ui>

0 comments on commit 94afcc2

Please sign in to comment.