Skip to content

Commit

Permalink
Update to 1.21 (#5)
Browse files Browse the repository at this point in the history
* Fix gradle not running (now you can add github actions and they will work)

* Update to 1.21

* Properly set gradle's java version

* Bump version

* Update to emi release

* 1.21-rc.1 -> 1.21

* Fix maven publishing. Closes #4

* Fixed components being lost when converting ItemStack into TlaStack

* Bump version
  • Loading branch information
Sollace authored Jun 20, 2024
1 parent be4e696 commit a5f271b
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 39 deletions.
11 changes: 3 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,11 @@ tasks.processResources {
}
}

tasks.withType<JavaCompile> {
options.release = 21
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.jar {
Expand All @@ -142,7 +138,6 @@ publishing {
publications {
register<MavenPublication>("mavenJava") {
from(components["java"])
artifact(tasks["sourcesJar"])
}
}

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

mod_version=1.1.1
mod_version=1.2.0-beta.2

fabric_version=0.97.8+1.20.6
rei_version=15.0.728
architectury_version=12.0.26
emi_version=1.1.6+1.20.6
fabric_version=0.100.1+1.21
rei_version=16.0.729
architectury_version=13.0.1
emi_version=1.1.7+1.21
cloth_basic_math_version=0.6.1
cloth_config_version=14.0.126
cloth_config_version=15.0.127
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.inventory.Inventory;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.input.RecipeInput;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -58,13 +58,12 @@ public void addWorkstation(TlaCategory category, TlaIngredient... workstations)
}
}

@SuppressWarnings("unchecked") // For some reason RecipeManager needs an inventory generic, which we don't have but don't need either
@Override
public <T extends Recipe<?>> void addRecipeGenerator(RecipeType<T> type, Function<RecipeEntry<T>, TlaRecipe> generator) {
public <I extends RecipeInput, T extends Recipe<I>> void addRecipeGenerator(RecipeType<T> type, Function<RecipeEntry<T>, TlaRecipe> generator) {
registry.getRecipeManager()
.listAllOfType((RecipeType<Recipe<Inventory>>) type)
.listAllOfType(type)
.forEach(recipe -> {
var tlaRecipe = generator.apply((RecipeEntry<T>) recipe);
var tlaRecipe = generator.apply(recipe);
var emiRecipe = new TlaEmiRecipe(tlaRecipe, categories.get(tlaRecipe.getCategory()));
registry.addRecipe(emiRecipe);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.input.RecipeInput;
import net.minecraft.screen.ScreenHandler;

import java.util.*;
Expand Down Expand Up @@ -95,6 +96,7 @@ public void registerScreens(ScreenRegistry registry) {
clickAreas.forEach(tuple -> registerClickArea(registry, tuple));
}

@SuppressWarnings("unchecked")
private <T extends Screen> void registerClickArea(ScreenRegistry registry, ClickAreaTuple<T> tuple) {
SimpleClickArea<T> clickArea = screen -> {
var bounds = tuple.boundsFunction.apply(screen);
Expand Down Expand Up @@ -134,7 +136,7 @@ public void addWorkstation(TlaCategory category, TlaIngredient... workstations)
}

@Override
public <T extends Recipe<?>> void addRecipeGenerator(RecipeType<T> type, Function<RecipeEntry<T>, TlaRecipe> generator) {
public <I extends RecipeInput, T extends Recipe<I>> void addRecipeGenerator(RecipeType<T> type, Function<RecipeEntry<T>, TlaRecipe> generator) {
recipeGenerators.add(new RecipeGenerator<>(type, generator));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.input.RecipeInput;

import java.util.List;
import java.util.function.Function;
Expand All @@ -38,7 +39,7 @@ public interface PluginContext {
* @see TlaRecipe
* @see #addGenerator
*/
<T extends Recipe<?>> void addRecipeGenerator(RecipeType<T> type, Function<RecipeEntry<T>, TlaRecipe> generator);
<I extends RecipeInput, T extends Recipe<I>> void addRecipeGenerator(RecipeType<T> type, Function<RecipeEntry<T>, TlaRecipe> generator);

/**
* Adds a recipe generator that can create recipe entries in the recipe viewer from any source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static TlaItemStack of(ItemConvertible item) {
}

public static TlaItemStack of(ItemStack stack) {
return of(ItemVariant.of(stack.getItem()), stack.getCount());
return of(ItemVariant.of(stack), stack.getCount());
}

public long getAmount() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
]
},
"depends": {
"fabricloader": ">=0.15.3",
"minecraft": "~1.20.4",
"java": ">=17",
"fabricloader": ">=0.15.11",
"minecraft": "~1.21",
"java": ">=21",
"fabric-api": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public List<TlaIngredient> getCatalysts() {
@Override
public void buildGui(GuiBuilder builder) {
var texture = TextureConfig.builder()
.texture(new Identifier("textures/block/dirt.png"), new Identifier("textures/block/stone.png"))
.texture(Identifier.ofVanilla("textures/block/dirt.png"), Identifier.ofVanilla("textures/block/stone.png"))
.size(35, 10)
.regionSize(16, 16)
.textureSize(16, 16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class TestCategory implements TlaCategory {
@Override
public Identifier getId() {
return new Identifier("testmod:test_recipe");
return Identifier.of("testmod", "test_recipe");
}

@Override
Expand All @@ -35,6 +35,6 @@ public CategoryIcon getIcon() {

@Override
public CategoryIcon getSimpleIcon() {
return CategoryIcon.texture(TextureConfig.builder().texture(new Identifier("minecraft:textures/block/stone.png")).fullSize(16, 16).build());
return CategoryIcon.texture(TextureConfig.builder().texture(Identifier.ofVanilla("textures/block/stone.png")).fullSize(16, 16).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public List<TlaIngredient> getCatalysts() {
@Override
public void buildGui(GuiBuilder builder) {
var dirtTexture = TextureConfig.builder()
.texture(new Identifier("textures/block/dirt.png"))
.texture(Identifier.ofVanilla("textures/block/dirt.png"))
.fullSize(16, 16)
.build();

Expand All @@ -52,7 +52,7 @@ public void buildGui(GuiBuilder builder) {
builder.addArrow(24, 24, true).addTooltip(Text.literal("am full arrow"));
builder.addSlot(TlaStack.of(entry.value().output()).withChance(0.5), 46, 0).markOutput().makeLarge().addTooltip(Text.literal("am large"));
builder.addCustomWidget(0, 22, 16, 16, (context, mouseX, mouseY, delta) -> {
context.drawTexture(new Identifier("textures/block/cobblestone.png"), 0, 0, 0, 0, 16, 16, 16, 16);
context.drawTexture(Identifier.ofVanilla("textures/block/cobblestone.png"), 0, 0, 0, 0, 16, 16, 16, 16);
}).addTooltip(Text.literal("am custom widget"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.command.CommandManager;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class TestMod implements ModInitializer {
public static final RecipeType<TestRecipe> RECIPE_TYPE = RecipeType.register("testmod:test_recipe");
public static final RecipeType<TestRecipe> RECIPE_TYPE = Registry.register(Registries.RECIPE_TYPE, Identifier.of("testmod:test_recipe"), new RecipeType<TestRecipe>() {
@Override
public String toString() {
return "testmod:test_recipe";
}
});
public static final RecipeSerializer<TestRecipe> RECIPE_SERIALIZER = new TestRecipe.Serializer();
public static final ScreenHandlerType<TestScreenHandler> SCREEN_HANDLER_TYPE = new ScreenHandlerType<>(TestScreenHandler::new, FeatureSet.empty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.world.World;

public record TestRecipe(Ingredient input, ItemStack output) implements Recipe<SimpleInventory> {
public record TestRecipe(Ingredient input, ItemStack output) implements Recipe<CraftingRecipeInput> {
@Override
public boolean matches(SimpleInventory inventory, World world) {
return input.test(inventory.getStack(0));
public boolean matches(CraftingRecipeInput inventory, World world) {
return input.test(inventory.getStackInSlot(0));
}

@Override
public ItemStack craft(SimpleInventory inventory, RegistryWrapper.WrapperLookup lookup) {
public ItemStack craft(CraftingRecipeInput inventory, RegistryWrapper.WrapperLookup lookup) {
return output.copy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
},
"output": {
"id": "minecraft:stone",
"Count": 2
"count": 2
}
}

0 comments on commit a5f271b

Please sign in to comment.