Skip to content

Commit

Permalink
Fix JEI/REI not showing ingredients in recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNijjar committed Jan 29, 2024
1 parent a659486 commit 7da4dda
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 42 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ jobs:
resourceful-lib | depends | *
resourceful-config | depends | *
botarium | depends | *
cadmus | recommends | *
argonauts | recommends | *
curseforge-dependencies: |
shimmer | recommends | *
athena | recommends | *
modrinth-dependencies: |
athena-ctm | recommends | *
shimmer! | recommends | *
- name: Upload Fabric Releases (Curse/Modrinth/Github)
id: fabric_release
Expand All @@ -88,7 +95,14 @@ jobs:
resourceful-lib | depends | *
resourceful-config | depends | *
botarium | depends | *
cadmus | recommends | *
argonauts | recommends | *
curseforge-dependencies: |
shimmer | recommends | *
athena | recommends | *
modrinth-dependencies: |
athena-ctm | recommends | *
shimmer! | recommends | *
- name: Generate Discord Embed
run: ./gradlew injectEmbed
Expand Down
10 changes: 1 addition & 9 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,4 @@ See https://modrinth.com/mod/ad-astra/version/1.15.7 for the full changelog.

## Changes

- Added biome and dimension translations
- Fixed create compat (#441)
- Fixed diamond ore incorrect tag (#440)
- Fixed waterlogged blocks getting destroyed in space (#437)
- Fixed missing blocks in mars temple and lunarian tower.
- Re-added planet sky rendering resource pack support.
- Added German radio station (#438)
- Fixed crash with cryo freezer moving fluids
- Added config to disable oxygen, temperature, and gravity
- Fixed JEI/REI not showing ingredients in recipes
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ public PlanetsMenu(int containerId, Inventory inventory, FriendlyByteBuf buf) {
inventory,
PlanetsMenuProvider.createDisabledPlanetsFromBuf(buf),
PlanetsMenuProvider.createSpaceStationsFromBuf(buf),
PlanetsMenuProvider.createClaimedChunksFromBuf(buf),
PlanetsMenuProvider.createSpawnLocationsFromBuf(buf));
PlanetsMenuProvider.createSpawnLocationsFromBuf(buf),
PlanetsMenuProvider.createClaimedChunksFromBuf(buf)
);
}

public PlanetsMenu(int containerId,
Inventory inventory,
Set<ResourceLocation> disabledPlanets,
Map<ResourceKey<Level>, Map<UUID, Set<SpaceStation>>> spaceStations,
Object2BooleanMap<ResourceKey<Level>> claimedChunks,
Set<GlobalPos> spawnLocations) {
Set<GlobalPos> spawnLocations,
Object2BooleanMap<ResourceKey<Level>> claimedChunks) {
super(ModMenus.PLANETS.get(), containerId);
this.inventory = inventory;
player = inventory.player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Component getDisplayName() {

@Override
public AbstractContainerMenu createMenu(int containerId, Inventory inventory, Player player) {
return new PlanetsMenu(containerId, inventory, Set.of(), Map.of(), Object2BooleanMaps.emptyMap(), Set.of());
return new PlanetsMenu(containerId, inventory, Set.of(), Map.of(), Set.of(), Object2BooleanMaps.emptyMap());
}

@Override
Expand All @@ -59,20 +59,20 @@ public void writeExtraData(ServerPlayer player, FriendlyByteBuf buffer) {
});
});

if (CadmusIntegration.cadmusLoaded()) {
buffer.writeVarInt(AdAstraData.planets().size());
AdAstraData.planets().keySet().forEach(dimension -> {
buffer.writeResourceKey(dimension);
buffer.writeBoolean(CadmusIntegration.isClaimed(player.server.getLevel(dimension), player.chunkPosition()));
});
}

List<GlobalPos> locations = new ArrayList<>();
AdAstraData.planets().forEach((dimension, planet) ->
LaunchingDimensionHandler.getSpawningLocation(player, player.serverLevel(), planet).ifPresent(locations::add));

buffer.writeVarInt(locations.size());
locations.forEach(buffer::writeGlobalPos);

buffer.writeVarInt(AdAstraData.planets().size());
if (CadmusIntegration.cadmusLoaded()) {
AdAstraData.planets().keySet().forEach(dimension -> {
buffer.writeResourceKey(dimension);
buffer.writeBoolean(CadmusIntegration.isClaimed(player.server.getLevel(dimension), player.chunkPosition()));
});
}
}

public static Set<ResourceLocation> createDisabledPlanetsFromBuf(FriendlyByteBuf buf) {
Expand Down Expand Up @@ -115,18 +115,16 @@ public static Map<ResourceKey<Level>, Map<UUID, Set<SpaceStation>>> createSpaceS


public static Object2BooleanMap<ResourceKey<Level>> createClaimedChunksFromBuf(FriendlyByteBuf buf) {
if (CadmusIntegration.cadmusLoaded()) {
int dimensionCount = buf.readVarInt();
Object2BooleanMap<ResourceKey<Level>> claimedChunks = new Object2BooleanOpenHashMap<>();

for (int i = 0; i < dimensionCount; i++) {
ResourceKey<Level> dimension = buf.readResourceKey(Registries.DIMENSION);
claimedChunks.put(dimension, buf.readBoolean());
}
int dimensionCount = buf.readVarInt();
if (dimensionCount == 0) return Object2BooleanMaps.emptyMap();
Object2BooleanMap<ResourceKey<Level>> claimedChunks = new Object2BooleanOpenHashMap<>();

return Object2BooleanMaps.unmodifiable(claimedChunks);
for (int i = 0; i < dimensionCount; i++) {
ResourceKey<Level> dimension = buf.readResourceKey(Registries.DIMENSION);
claimedChunks.put(dimension, buf.readBoolean());
}
return Object2BooleanMaps.emptyMap();

return Object2BooleanMaps.unmodifiable(claimedChunks);
}

public static Set<GlobalPos> createSpawnLocationsFromBuf(FriendlyByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public static Codec<SpaceStationRecipe> codec(ResourceLocation id) {
).apply(instance, SpaceStationRecipe::new));
}

public static Codec<SpaceStationRecipe> netCodec(ResourceLocation id) {
return RecordCodecBuilder.create(instance -> instance.group(
RecordCodecBuilder.point(id),
IngredientHolder.NETWORK_CODEC.listOf().fieldOf("ingredients").forGetter(SpaceStationRecipe::ingredients),
ResourceKey.codec(Registries.DIMENSION).fieldOf("dimension").forGetter(SpaceStationRecipe::dimension)
).apply(instance, SpaceStationRecipe::new));
}

@Override
public boolean matches(@NotNull Container container, @NotNull Level level) {
for (IngredientHolder holder : ingredients) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public record IngredientHolder(Ingredient ingredient, int count) {
Codec.INT.fieldOf("count").orElse(1).forGetter(IngredientHolder::count)
).apply(instance, IngredientHolder::new));

public static final Codec<IngredientHolder> NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group(
IngredientCodec.NETWORK_CODEC.fieldOf("ingredient").forGetter(IngredientHolder::ingredient),
Codec.INT.fieldOf("count").orElse(1).forGetter(IngredientHolder::count)
).apply(instance, IngredientHolder::new));

public static IngredientHolder of(Ingredient ingredient) {
return new IngredientHolder(ingredient, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public static Codec<AlloyingRecipe> codec(ResourceLocation id) {
).apply(instance, AlloyingRecipe::new));
}

public static Codec<AlloyingRecipe> netCodec(ResourceLocation id) {
return RecordCodecBuilder.create(instance -> instance.group(
RecordCodecBuilder.point(id),
Codec.INT.fieldOf("cookingtime").forGetter(AlloyingRecipe::cookingTime),
Codec.INT.fieldOf("energy").forGetter(AlloyingRecipe::energy),
IngredientCodec.NETWORK_CODEC.listOf().fieldOf("ingredients").forGetter(AlloyingRecipe::ingredients),
ItemStackCodec.NETWORK_CODEC.fieldOf("result").forGetter(AlloyingRecipe::result)
).apply(instance, AlloyingRecipe::new));
}

@Override
public boolean matches(@NotNull Container container, @NotNull Level level) {
if (container.getContainerSize() < ingredients.size()) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public static Codec<CompressingRecipe> codec(ResourceLocation id) {
).apply(instance, CompressingRecipe::new));
}

public static Codec<CompressingRecipe> netCodec(ResourceLocation id) {
return RecordCodecBuilder.create(instance -> instance.group(
RecordCodecBuilder.point(id),
Codec.INT.fieldOf("cookingtime").forGetter(CompressingRecipe::cookingTime),
Codec.INT.fieldOf("energy").forGetter(CompressingRecipe::energy),
IngredientCodec.NETWORK_CODEC.fieldOf("ingredient").forGetter(CompressingRecipe::ingredient),
ItemStackCodec.NETWORK_CODEC.fieldOf("result").forGetter(CompressingRecipe::result)
).apply(instance, CompressingRecipe::new));
}

@Override
public boolean matches(@NotNull Container container, @NotNull Level level) {
if (!ingredient.test(container.getItem(1))) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ public static Codec<CryoFreezingRecipe> codec(ResourceLocation id) {
).apply(instance, CryoFreezingRecipe::new));
}

public static Codec<CryoFreezingRecipe> netCodec(ResourceLocation id) {
return RecordCodecBuilder.create(instance -> instance.group(
RecordCodecBuilder.point(id),
Codec.INT.fieldOf("cookingtime").forGetter(CryoFreezingRecipe::cookingTime),
Codec.INT.fieldOf("energy").forGetter(CryoFreezingRecipe::energy),
IngredientCodec.NETWORK_CODEC.fieldOf("ingredient").forGetter(CryoFreezingRecipe::input),
FluidHolder.NEW_CODEC.fieldOf("result").forGetter(CryoFreezingRecipe::result)
).apply(instance, CryoFreezingRecipe::new));
}

@Override
public boolean matches(@NotNull Container container, @NotNull Level level) {
if (!input.test(container.getItem(1))) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public static Codec<NasaWorkbenchRecipe> codec(ResourceLocation id) {
).apply(instance, NasaWorkbenchRecipe::new));
}

public static Codec<NasaWorkbenchRecipe> netCodec(ResourceLocation id) {
return RecordCodecBuilder.create(instance -> instance.group(
RecordCodecBuilder.point(id),
IngredientCodec.NETWORK_CODEC.listOf().fieldOf("ingredients").forGetter(NasaWorkbenchRecipe::ingredients),
ItemStackCodec.NETWORK_CODEC.fieldOf("result").forGetter(NasaWorkbenchRecipe::result)
).apply(instance, NasaWorkbenchRecipe::new));
}

@Override
public boolean matches(@NotNull Container container, @NotNull Level level) {
if (container.getContainerSize() < 14) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class ModRecipeSerializers {
public static final ResourcefulRegistry<RecipeSerializer<?>> RECIPE_SERIALIZERS = ResourcefulRegistries.create(BuiltInRegistries.RECIPE_SERIALIZER, AdAstra.MOD_ID);

public static final RegistryEntry<CodecRecipeSerializer<CompressingRecipe>> COMPRESSING = RECIPE_SERIALIZERS.register("compressing", () ->
new CodecRecipeSerializer<>(ModRecipeTypes.COMPRESSING.get(), CompressingRecipe::codec));
new CodecRecipeSerializer<>(ModRecipeTypes.COMPRESSING.get(), CompressingRecipe::codec, CompressingRecipe::netCodec));

public static final RegistryEntry<CodecRecipeSerializer<AlloyingRecipe>> ALLOYING = RECIPE_SERIALIZERS.register("alloying", () ->
new CodecRecipeSerializer<>(ModRecipeTypes.ALLOYING.get(), AlloyingRecipe::codec));
new CodecRecipeSerializer<>(ModRecipeTypes.ALLOYING.get(), AlloyingRecipe::codec, AlloyingRecipe::netCodec));

public static final RegistryEntry<CodecRecipeSerializer<OxygenLoadingRecipe>> OXYGEN_LOADING = RECIPE_SERIALIZERS.register("oxygen_loading", () ->
new CodecRecipeSerializer<>(ModRecipeTypes.OXYGEN_LOADING.get(), OxygenLoadingRecipe::codec));
Expand All @@ -26,11 +26,11 @@ public class ModRecipeSerializers {
new CodecRecipeSerializer<>(ModRecipeTypes.REFINING.get(), RefiningRecipe::codec));

public static final RegistryEntry<CodecRecipeSerializer<CryoFreezingRecipe>> CRYO_FREEZING = RECIPE_SERIALIZERS.register("cryo_freezing", () ->
new CodecRecipeSerializer<>(ModRecipeTypes.CRYO_FREEZING.get(), CryoFreezingRecipe::codec));
new CodecRecipeSerializer<>(ModRecipeTypes.CRYO_FREEZING.get(), CryoFreezingRecipe::codec, CryoFreezingRecipe::netCodec));

public static final RegistryEntry<CodecRecipeSerializer<NasaWorkbenchRecipe>> NASA_WORKBENCH_SERIALIZER = RECIPE_SERIALIZERS.register("nasa_workbench", () ->
new CodecRecipeSerializer<>(ModRecipeTypes.NASA_WORKBENCH.get(), NasaWorkbenchRecipe::codec));
new CodecRecipeSerializer<>(ModRecipeTypes.NASA_WORKBENCH.get(), NasaWorkbenchRecipe::codec, NasaWorkbenchRecipe::netCodec));

public static final RegistryEntry<CodecRecipeSerializer<SpaceStationRecipe>> SPACE_STATION_SERIALIZER = RECIPE_SERIALIZERS.register("space_station_recipe", () ->
new CodecRecipeSerializer<>(ModRecipeTypes.SPACE_STATION_RECIPE.get(), SpaceStationRecipe::codec));
new CodecRecipeSerializer<>(ModRecipeTypes.SPACE_STATION_RECIPE.get(), SpaceStationRecipe::codec, SpaceStationRecipe::netCodec));
}
4 changes: 1 addition & 3 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ dependencies {
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = fabricLoaderVersion)
modApi(group = "net.fabricmc.fabric-api", name = "fabric-api", version = "$fabricApiVersion+$minecraftVersion")

modLocalRuntime(group = "me.shedaniel", name = "RoughlyEnoughItems-fabric", version = reiVersion) {
isTransitive = false
}
modLocalRuntime(group = "me.shedaniel", name = "RoughlyEnoughItems-fabric", version = reiVersion)

modApi(group = "com.terraformersmc", name = "modmenu", version = modMenuVersion)

Expand Down
2 changes: 1 addition & 1 deletion fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
fabricLoaderVersion=0.15.5
fabricLoaderVersion=0.15.6
fabricApiVersion=0.91.0
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G

enabledPlatforms=fabric,forge

version=1.15.11
version=1.15.12
group=earth.terrarium.adastra

minecraftVersion=1.20.1
Expand Down

0 comments on commit 7da4dda

Please sign in to comment.