Skip to content

Commit

Permalink
Updated to fabric 0.100.3+1.21
Browse files Browse the repository at this point in the history
- changes made adhear to fabric version 0.100.3+1.21
- updated mod to support Minecraft 1.21
  • Loading branch information
Sephta committed Jun 23, 2024
1 parent 65e8468 commit 7f6cc5d
Show file tree
Hide file tree
Showing 173 changed files with 123 additions and 342 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

# Mod Properties
Expand All @@ -15,4 +15,4 @@ archives_base_name=stal-alloys
modid=stal-alloys

# Dependencies
fabric_version=0.100.2+1.20.6
fabric_version=0.100.3+1.21
4 changes: 2 additions & 2 deletions src/main/java/net/stal/alloys/block/StalAlloysBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ public class StalAlloysBlocks {
private static Block registerBlock(String name, Block block) {
registerBlockItem(name, block);

return Registry.register(Registries.BLOCK, new Identifier(StalAlloys.MOD_ID, name), block);
return Registry.register(Registries.BLOCK, Identifier.of(StalAlloys.MOD_ID, name), block);
}

private static Item registerBlockItem(String name, Block block) {
Item item = Registry.register(Registries.ITEM, new Identifier(StalAlloys.MOD_ID, name), new BlockItem(block, new Item.Settings()));
Item item = Registry.register(Registries.ITEM, Identifier.of(StalAlloys.MOD_ID, name), new BlockItem(block, new Item.Settings()));

return item;
}
Expand Down
24 changes: 19 additions & 5 deletions src/main/java/net/stal/alloys/block/entity/AlloySmelterEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void readNbt(NbtCompound nbt, WrapperLookup registryLookup) {

NbtCompound nbtCompound = nbt.getCompound(mRecipesUsedNBTKey);
for (String string : nbtCompound.getKeys()) {
this.recipesUsed.put(new Identifier(string), nbtCompound.getInt(string));
this.recipesUsed.put(Identifier.of(string), nbtCompound.getInt(string));
}
}

Expand Down Expand Up @@ -213,8 +213,15 @@ private static boolean hasRecipe(AlloySmelterEntity entity) {
}

Optional<RecipeEntry<AlloySmelterRecipe>> recipeFromInventoryOpt = entity.getWorld()
.getRecipeManager()
.getFirstMatch(AlloySmelterRecipe.AlloySmelterRecipeType.INSTANCE, inventory, entity.getWorld());
.getRecipeManager()
.getFirstMatch(
AlloySmelterRecipe.AlloySmelterRecipeType.INSTANCE,
new AlloySmelterRecipeInput(
inventory.getStack(AlloySmelterInventorySlots.FIRST.value),
inventory.getStack(AlloySmelterInventorySlots.SECOND.value)
),
entity.getWorld()
);

if (recipeFromInventoryOpt.isPresent()) {
AlloySmelterRecipe recipe = recipeFromInventoryOpt.get().value();
Expand All @@ -236,8 +243,15 @@ private static void craftItem(AlloySmelterEntity entity) {
}

Optional<RecipeEntry<AlloySmelterRecipe>> recipeFromInventoryOpt = entity.getWorld()
.getRecipeManager()
.getFirstMatch(AlloySmelterRecipe.AlloySmelterRecipeType.INSTANCE, inventory, entity.getWorld());
.getRecipeManager()
.getFirstMatch(
AlloySmelterRecipe.AlloySmelterRecipeType.INSTANCE,
new AlloySmelterRecipeInput(
inventory.getStack(AlloySmelterInventorySlots.FIRST.value),
inventory.getStack(AlloySmelterInventorySlots.SECOND.value)
),
entity.getWorld()
);

if (recipeFromInventoryOpt.isPresent() && hasRecipe(entity)) {
AlloySmelterRecipe recipe = recipeFromInventoryOpt.get().value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void registerModBlockEntities() {

ALLOY_SMELTER_ENTITY = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
new Identifier(
Identifier.of(
StalAlloys.MOD_ID,
"alloy_smelter"
),
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/net/stal/alloys/datagen/StalAlloysRecipeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,39 @@ public void generate(RecipeExporter exporter) {
.input('C', Items.COBBLED_DEEPSLATE)
.criterion(hasItem(Items.DEEPSLATE), conditionsFromItem(Items.DEEPSLATE))
.criterion(hasItem(Items.FURNACE), conditionsFromItem(Items.FURNACE))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "alloy_smelter"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "alloy_smelter"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRASS_BOOTS, 1)
.pattern("# #")
.pattern("# #")
.pattern(" ")
.input('#', StalAlloysItems.BRASS_INGOT)
.criterion(hasItem(StalAlloysItems.BRASS_INGOT), conditionsFromItem(StalAlloysItems.BRASS_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "brass_boots"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "brass_boots"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRASS_CHESTPLATE, 1)
.pattern("# #")
.pattern("###")
.pattern("###")
.input('#', StalAlloysItems.BRASS_INGOT)
.criterion(hasItem(StalAlloysItems.BRASS_INGOT), conditionsFromItem(StalAlloysItems.BRASS_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "brass_chestplate"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "brass_chestplate"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRASS_HELMET, 1)
.pattern("###")
.pattern("# #")
.pattern(" ")
.input('#', StalAlloysItems.BRASS_INGOT)
.criterion(hasItem(StalAlloysItems.BRASS_INGOT), conditionsFromItem(StalAlloysItems.BRASS_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "brass_helmet"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "brass_helmet"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRASS_LEGGINGS, 1)
.pattern("###")
.pattern("# #")
.pattern("# #")
.input('#', StalAlloysItems.BRASS_INGOT)
.criterion(hasItem(StalAlloysItems.BRASS_INGOT), conditionsFromItem(StalAlloysItems.BRASS_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "brass_leggings"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "brass_leggings"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.BRONZE_AXE, 1)
.pattern("## ")
Expand All @@ -104,13 +104,13 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.BRONZE_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.BRONZE_INGOT), conditionsFromItem(StalAlloysItems.BRONZE_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "bronze_axe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "bronze_axe"));

ShapelessRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRONZE_DAGGER, 1)
.input(StalAlloysItems.BRONZE_INGOT, 1)
.input(Items.STICK, 1)
.criterion(hasItem(StalAlloysItems.BRONZE_INGOT), conditionsFromItem(StalAlloysItems.BRONZE_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "bronze_dagger"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "bronze_dagger"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRONZE_DIRK, 1)
.pattern(" #")
Expand All @@ -119,7 +119,7 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.BRONZE_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.BRONZE_INGOT), conditionsFromItem(StalAlloysItems.BRONZE_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "bronze_dirk"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "bronze_dirk"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.BRONZE_SWORD, 1)
.pattern(" # ")
Expand All @@ -128,15 +128,15 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.BRONZE_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.BRONZE_INGOT), conditionsFromItem(StalAlloysItems.BRONZE_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "bronze_sword"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "bronze_sword"));

ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, StalAlloysItems.CARBON_PLATE, 1)
.pattern(" ")
.pattern("CCC")
.pattern("CCC")
.input('C', StalAlloysItems.RAW_CARBON)
.criterion(hasItem(StalAlloysItems.RAW_CARBON), conditionsFromItem(StalAlloysItems.RAW_CARBON))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "carbon_plate"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "carbon_plate"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.COPPER_AXE, 1)
.pattern("## ")
Expand All @@ -145,7 +145,7 @@ public void generate(RecipeExporter exporter) {
.input('#', Items.COPPER_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(Items.COPPER_INGOT), conditionsFromItem(Items.COPPER_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "copper_axe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "copper_axe"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.COPPER_HOE, 1)
.pattern("## ")
Expand All @@ -154,7 +154,7 @@ public void generate(RecipeExporter exporter) {
.input('#', Items.COPPER_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(Items.COPPER_INGOT), conditionsFromItem(Items.COPPER_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "copper_hoe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "copper_hoe"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.COPPER_PICKAXE, 1)
.pattern("###")
Expand All @@ -163,7 +163,7 @@ public void generate(RecipeExporter exporter) {
.input('#', Items.COPPER_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(Items.COPPER_INGOT), conditionsFromItem(Items.COPPER_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "copper_pickaxe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "copper_pickaxe"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.COPPER_SHOVEL, 1)
.pattern(" # ")
Expand All @@ -172,7 +172,7 @@ public void generate(RecipeExporter exporter) {
.input('#', Items.COPPER_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(Items.COPPER_INGOT), conditionsFromItem(Items.COPPER_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "copper_shovel"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "copper_shovel"));

ShapedRecipeJsonBuilder.create(RecipeCategory.COMBAT, StalAlloysItems.COPPER_SWORD, 1)
.pattern(" # ")
Expand All @@ -181,7 +181,7 @@ public void generate(RecipeExporter exporter) {
.input('#', Items.COPPER_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(Items.COPPER_INGOT), conditionsFromItem(Items.COPPER_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "copper_sword"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "copper_sword"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.STEEL_AXE, 1)
.pattern("## ")
Expand All @@ -190,7 +190,7 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.STEEL_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.STEEL_INGOT), conditionsFromItem(StalAlloysItems.STEEL_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "steel_axe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "steel_axe"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.STEEL_HOE, 1)
.pattern("## ")
Expand All @@ -199,7 +199,7 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.STEEL_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.STEEL_INGOT), conditionsFromItem(StalAlloysItems.STEEL_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "steel_hoe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "steel_hoe"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.STEEL_PICKAXE, 1)
.pattern("###")
Expand All @@ -208,7 +208,7 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.STEEL_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.STEEL_INGOT), conditionsFromItem(StalAlloysItems.STEEL_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "steel_pickaxe"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "steel_pickaxe"));

ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, StalAlloysItems.STEEL_SHOVEL, 1)
.pattern(" # ")
Expand All @@ -217,7 +217,7 @@ public void generate(RecipeExporter exporter) {
.input('#', StalAlloysItems.STEEL_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(StalAlloysItems.STEEL_INGOT), conditionsFromItem(StalAlloysItems.STEEL_INGOT))
.offerTo(exporter, new Identifier(StalAlloys.MOD_ID, "steel_shovel"));
.offerTo(exporter, Identifier.of(StalAlloys.MOD_ID, "steel_shovel"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public class StalAlloysArmorMaterials extends ArmorMaterials{
private static RegistryEntry<ArmorMaterial> registerArmorMaterial(String id, EnumMap<ArmorItem.Type, Integer> defense, int enchantability, RegistryEntry<SoundEvent> equipSound, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
return Registry.registerReference(
Registries.ARMOR_MATERIAL,
new Identifier(StalAlloys.MOD_ID, id),
Identifier.of(StalAlloys.MOD_ID, id),
new ArmorMaterial(
defense,
enchantability,
equipSound,
repairIngredient,
List.of(new ArmorMaterial.Layer(new Identifier(StalAlloys.MOD_ID, id))),
List.of(new ArmorMaterial.Layer(Identifier.of(StalAlloys.MOD_ID, id))),
toughness,
knockbackResistance
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class StalAlloysItemGroup {

public static final RegistryKey<ItemGroup> STAL_ALLOYS = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(StalAlloys.MOD_ID, "stal_alloys"));
public static final RegistryKey<ItemGroup> STAL_ALLOYS = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(StalAlloys.MOD_ID, "stal_alloys"));

public static final ItemGroup STAL_ALLOYS_ITEM_GROUP = Registry.register(
Registries.ITEM_GROUP,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/stal/alloys/item/StalAlloysItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class StalAlloysItems {
public static final Item STAINLESS_STEEL_BOOTS = registerItem("stainless_steel_boots", new ArmorItem(StalAlloysArmorMaterials.STAINLESS_STEEL, ArmorItem.Type.BOOTS, new Item.Settings()));

private static Item registerItem(String name, Item item) {
return Registry.register(Registries.ITEM, new Identifier(StalAlloys.MOD_ID, name), item);
return Registry.register(Registries.ITEM, Identifier.of(StalAlloys.MOD_ID, name), item);
}

public static void registerModItems() {
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/net/stal/alloys/recipe/AlloySmelterRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.recipe.RecipeSerializer;

import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
Expand All @@ -17,7 +15,7 @@

import java.util.List;

public class AlloySmelterRecipe implements Recipe<SimpleInventory> {
public class AlloySmelterRecipe implements Recipe<AlloySmelterRecipeInput> {

private final ItemStack mOutput;
private final int mCookingTime;
Expand Down Expand Up @@ -47,21 +45,21 @@ public AlloySmelterRecipe( int cookingtime, int experience, List<Ingredient> rec
}

@Override
public boolean matches(SimpleInventory inventory, World world) {
public boolean matches(AlloySmelterRecipeInput recipeInput, World world) {
if (world.isClient()) return false;

boolean matchA = mRecipeItems.get(0).test(inventory.getStack(0 /* 0 is the first slot */)) &&
mRecipeItems.get(1).test(inventory.getStack(1 /* 1 is the second slot */));
boolean matchA = mRecipeItems.get(0).test(recipeInput.getStackInSlot(0 /* 0 is the first slot */)) &&
mRecipeItems.get(1).test(recipeInput.getStackInSlot(1 /* 1 is the second slot */));

// This is here because the inputs are slot agnostic
boolean matchB = mRecipeItems.get(1).test(inventory.getStack(0 /* 0 is the first slot */)) &&
mRecipeItems.get(0).test(inventory.getStack(1 /* 1 is the second slot */));
boolean matchB = mRecipeItems.get(1).test(recipeInput.getStackInSlot(0 /* 0 is the first slot */)) &&
mRecipeItems.get(0).test(recipeInput.getStackInSlot(1 /* 1 is the second slot */));

return matchA || matchB;
}

@Override
public ItemStack craft(SimpleInventory inventory, WrapperLookup lookup) {
public ItemStack craft(AlloySmelterRecipeInput recipeInput, WrapperLookup lookup) {
return mOutput;
}

Expand Down
49 changes: 49 additions & 0 deletions src/main/java/net/stal/alloys/recipe/AlloySmelterRecipeInput.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package net.stal.alloys.recipe;

import net.minecraft.item.ItemStack;
import net.minecraft.recipe.input.RecipeInput;


public record AlloySmelterRecipeInput(ItemStack slotA, ItemStack slotB) implements RecipeInput {


public AlloySmelterRecipeInput(ItemStack slotA, ItemStack slotB) {
this.slotA = slotA;
this.slotB = slotB;
}

@Override
public int getSize() {
return 2;
}

@Override
public ItemStack getStackInSlot(int slot) {
ItemStack result;
switch (slot) {
case 0:
result = this.slotA;
break;
case 1:
result = this.slotB;
break;
default:
throw new IllegalArgumentException("Recipe does not contain slot " + slot);
}

return result;
}

public boolean isEmpty() {
return this.slotA.isEmpty() && this.slotB.isEmpty();
}

public ItemStack slotA() {
return this.slotA.copy();
}

public ItemStack slotB() {
return this.slotB.copy();
}

}
Loading

0 comments on commit 7f6cc5d

Please sign in to comment.