Skip to content

Commit aef81cb

Browse files
committed
Update for Minecraft 1.20.2-pre4.
- Update for Minecraft 1.20.2-pre4 * Update Fabric API dep; closes #155 * Major changes to piglin bartering loot methods * Significant changes to ItemPredicates in recipe conditions * Significant changes to Ash layer mixin
1 parent e520c85 commit aef81cb

File tree

7 files changed

+61
-113
lines changed

7 files changed

+61
-113
lines changed

common/src/main/java/com/terraformersmc/cinderscapes/block/PhotofernBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public PhotofernBlock() {
1616
}
1717

1818
@Override
19-
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) {
19+
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) {
2020
return true;
2121
}
2222

common/src/main/java/com/terraformersmc/cinderscapes/data/CinderscapesRecipeProvider.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
99
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags;
1010
import net.minecraft.advancement.criterion.InventoryChangedCriterion;
11-
import net.minecraft.data.server.recipe.RecipeJsonProvider;
11+
import net.minecraft.data.server.recipe.RecipeExporter;
1212
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
1313
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
14+
import net.minecraft.item.Item;
1415
import net.minecraft.item.Items;
15-
import net.minecraft.predicate.NbtPredicate;
1616
import net.minecraft.predicate.NumberRange;
17-
import net.minecraft.predicate.item.EnchantmentPredicate;
1817
import net.minecraft.predicate.item.ItemPredicate;
1918
import net.minecraft.recipe.Ingredient;
2019
import net.minecraft.recipe.book.RecipeCategory;
2120
import net.minecraft.registry.tag.ItemTags;
21+
import net.minecraft.registry.tag.TagKey;
2222
import net.minecraft.util.Identifier;
2323

2424
import java.util.List;
25-
import java.util.function.Consumer;
25+
import java.util.Optional;
2626

2727
public class CinderscapesRecipeProvider extends FabricRecipeProvider {
2828
protected CinderscapesRecipeProvider(FabricDataOutput dataOutput) {
2929
super(dataOutput);
3030
}
3131

3232
@Override
33-
public void generate(Consumer<RecipeJsonProvider> exporter) {
33+
public void generate(RecipeExporter exporter) {
3434
// vanilla recipes
3535
ShapedRecipeJsonBuilder.create(RecipeCategory.REDSTONE, Items.COMPARATOR, 1)
3636
.pattern(" T ")
@@ -39,8 +39,7 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
3939
.input('T', Items.REDSTONE_TORCH)
4040
.input('Q', ConventionalItemTags.QUARTZ)
4141
.input('S', Items.STONE)
42-
.criterion("has_quartz", InventoryChangedCriterion.Conditions.items(
43-
new ItemPredicate(ConventionalItemTags.QUARTZ, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
42+
.criterion("has_quartz", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(ConventionalItemTags.QUARTZ)))
4443
.offerTo(exporter, new Identifier("minecraft", "comparator"));
4544

4645
ShapedRecipeJsonBuilder.create(RecipeCategory.REDSTONE, Items.DAYLIGHT_DETECTOR, 1)
@@ -50,8 +49,7 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
5049
.input('G', Items.GLASS)
5150
.input('Q', ConventionalItemTags.QUARTZ)
5251
.input('W', ItemTags.WOODEN_SLABS)
53-
.criterion("has_quartz", InventoryChangedCriterion.Conditions.items(
54-
new ItemPredicate(ConventionalItemTags.QUARTZ, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
52+
.criterion("has_quartz", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(ConventionalItemTags.QUARTZ)))
5553
.offerTo(exporter, new Identifier("minecraft", "daylight_detector"));
5654

5755
ShapedRecipeJsonBuilder.create(RecipeCategory.REDSTONE, Items.OBSERVER, 1)
@@ -61,8 +59,7 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
6159
.input('C', Items.COBBLESTONE)
6260
.input('Q', ConventionalItemTags.QUARTZ)
6361
.input('R', Items.REDSTONE)
64-
.criterion("has_quartz", InventoryChangedCriterion.Conditions.items(
65-
new ItemPredicate(ConventionalItemTags.QUARTZ, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
62+
.criterion("has_quartz", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(ConventionalItemTags.QUARTZ)))
6663
.offerTo(exporter, new Identifier("minecraft", "observer"));
6764

6865

@@ -84,8 +81,7 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
8481
.input(CinderscapesItemTags.SULFURS)
8582
.input(ItemTags.COALS)
8683
.input(Items.BONE_MEAL)
87-
.criterion("has_sulfurs", InventoryChangedCriterion.Conditions.items(
88-
new ItemPredicate(CinderscapesItemTags.SULFURS, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
84+
.criterion("has_sulfurs", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.SULFURS)))
8985
.offerTo(exporter);
9086

9187

@@ -110,13 +106,11 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
110106
.offerTo(exporter);
111107
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.ROSE_QUARTZ_PILLAR, CinderscapesBlocks.ROSE_QUARTZ_BLOCK);
112108
createSlabRecipe(RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.ROSE_QUARTZ_SLAB, Ingredient.ofItems(CinderscapesBlocks.CHISELED_ROSE_QUARTZ_BLOCK, CinderscapesBlocks.ROSE_QUARTZ_BLOCK, CinderscapesBlocks.ROSE_QUARTZ_PILLAR))
113-
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(
114-
new ItemPredicate(CinderscapesItemTags.ROSE_QUARTZ_CONVERTIBLES, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
109+
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.ROSE_QUARTZ_CONVERTIBLES)))
115110
.offerTo(exporter);
116111
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.ROSE_QUARTZ_SLAB, CinderscapesBlocks.ROSE_QUARTZ_BLOCK, 2);
117112
createStairsRecipe(CinderscapesBlocks.ROSE_QUARTZ_STAIRS, Ingredient.ofItems(CinderscapesBlocks.CHISELED_ROSE_QUARTZ_BLOCK, CinderscapesBlocks.ROSE_QUARTZ_BLOCK, CinderscapesBlocks.ROSE_QUARTZ_PILLAR))
118-
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(
119-
new ItemPredicate(CinderscapesItemTags.ROSE_QUARTZ_CONVERTIBLES, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
113+
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.ROSE_QUARTZ_CONVERTIBLES)))
120114
.offerTo(exporter);
121115
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.ROSE_QUARTZ_STAIRS, CinderscapesBlocks.ROSE_QUARTZ_BLOCK);
122116
offerSmelting(exporter, List.of(CinderscapesBlocks.ROSE_QUARTZ_BLOCK), RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOOTH_ROSE_QUARTZ, 0.1f, 200, "building_blocks");
@@ -147,13 +141,11 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
147141
.offerTo(exporter);
148142
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOKY_QUARTZ_PILLAR, CinderscapesBlocks.SMOKY_QUARTZ_BLOCK);
149143
createSlabRecipe(RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOKY_QUARTZ_SLAB, Ingredient.ofItems(CinderscapesBlocks.CHISELED_SMOKY_QUARTZ_BLOCK, CinderscapesBlocks.SMOKY_QUARTZ_BLOCK, CinderscapesBlocks.SMOKY_QUARTZ_PILLAR))
150-
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(
151-
new ItemPredicate(CinderscapesItemTags.SMOKY_QUARTZ_CONVERTIBLES, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
144+
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.SMOKY_QUARTZ_CONVERTIBLES)))
152145
.offerTo(exporter);
153146
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOKY_QUARTZ_SLAB, CinderscapesBlocks.SMOKY_QUARTZ_BLOCK, 2);
154147
createStairsRecipe(CinderscapesBlocks.SMOKY_QUARTZ_STAIRS, Ingredient.ofItems(CinderscapesBlocks.CHISELED_SMOKY_QUARTZ_BLOCK, CinderscapesBlocks.SMOKY_QUARTZ_BLOCK, CinderscapesBlocks.SMOKY_QUARTZ_PILLAR))
155-
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(
156-
new ItemPredicate(CinderscapesItemTags.SMOKY_QUARTZ_CONVERTIBLES, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
148+
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.SMOKY_QUARTZ_CONVERTIBLES)))
157149
.offerTo(exporter);
158150
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOKY_QUARTZ_STAIRS, CinderscapesBlocks.SMOKY_QUARTZ_BLOCK);
159151
offerSmelting(exporter, List.of(CinderscapesBlocks.SMOKY_QUARTZ_BLOCK), RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOOTH_SMOKY_QUARTZ, 0.1f, 200, "building_blocks");
@@ -184,13 +176,11 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
184176
.offerTo(exporter);
185177
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SULFUR_QUARTZ_PILLAR, CinderscapesBlocks.SULFUR_QUARTZ_BLOCK);
186178
createSlabRecipe(RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SULFUR_QUARTZ_SLAB, Ingredient.ofItems(CinderscapesBlocks.CHISELED_SULFUR_QUARTZ_BLOCK, CinderscapesBlocks.SULFUR_QUARTZ_BLOCK, CinderscapesBlocks.SULFUR_QUARTZ_PILLAR))
187-
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(
188-
new ItemPredicate(CinderscapesItemTags.SULFUR_QUARTZ_CONVERTIBLES, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
179+
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.SULFUR_QUARTZ_CONVERTIBLES)))
189180
.offerTo(exporter);
190181
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SULFUR_QUARTZ_SLAB, CinderscapesBlocks.SULFUR_QUARTZ_BLOCK, 2);
191182
createStairsRecipe(CinderscapesBlocks.SULFUR_QUARTZ_STAIRS, Ingredient.ofItems(CinderscapesBlocks.CHISELED_SULFUR_QUARTZ_BLOCK, CinderscapesBlocks.SULFUR_QUARTZ_BLOCK, CinderscapesBlocks.SULFUR_QUARTZ_PILLAR))
192-
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(
193-
new ItemPredicate(CinderscapesItemTags.SULFUR_QUARTZ_CONVERTIBLES, null, NumberRange.IntRange.ANY, NumberRange.IntRange.ANY, EnchantmentPredicate.ARRAY_OF_ANY, EnchantmentPredicate.ARRAY_OF_ANY, null, NbtPredicate.ANY)))
183+
.criterion("has_quartz_blocks", InventoryChangedCriterion.Conditions.items(getItemTagPredicate(CinderscapesItemTags.SULFUR_QUARTZ_CONVERTIBLES)))
194184
.offerTo(exporter);
195185
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SULFUR_QUARTZ_STAIRS, CinderscapesBlocks.SULFUR_QUARTZ_BLOCK);
196186
offerSmelting(exporter, List.of(CinderscapesBlocks.SULFUR_QUARTZ_BLOCK), RecipeCategory.BUILDING_BLOCKS, CinderscapesBlocks.SMOOTH_SULFUR_QUARTZ, 0.1f, 200, "building_blocks");
@@ -280,6 +270,20 @@ public void generate(Consumer<RecipeJsonProvider> exporter) {
280270
.offerTo(exporter);
281271
}
282272

273+
// Returns an ItemPredicate matching any item in the provided ItemTag key.
274+
private static ItemPredicate getItemTagPredicate(TagKey<Item> itemTagKey) {
275+
return new ItemPredicate(
276+
Optional.of(itemTagKey),
277+
Optional.empty(),
278+
NumberRange.IntRange.ANY,
279+
NumberRange.IntRange.ANY,
280+
List.of(),
281+
List.of(),
282+
Optional.empty(),
283+
Optional.empty()
284+
);
285+
}
286+
283287
@Override
284288
protected Identifier getRecipeIdentifier(Identifier identifier) {
285289
return new Identifier(Cinderscapes.NAMESPACE, identifier.getPath());

common/src/main/java/com/terraformersmc/cinderscapes/init/CinderscapesTrades.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
package com.terraformersmc.cinderscapes.init;
22

3-
import com.terraformersmc.cinderscapes.Cinderscapes;
4-
import com.terraformersmc.cinderscapes.loottables.IntegratedEntry;
53
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
64
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
75
import net.minecraft.item.ItemStack;
86
import net.minecraft.item.Items;
9-
import net.minecraft.loot.condition.LootCondition;
10-
import net.minecraft.loot.entry.LootPoolEntryType;
11-
import net.minecraft.loot.function.LootFunction;
7+
import net.minecraft.loot.entry.ItemEntry;
128
import net.minecraft.loot.function.SetCountLootFunction;
139
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
14-
import net.minecraft.registry.Registries;
15-
import net.minecraft.registry.Registry;
1610
import net.minecraft.util.Identifier;
1711
import net.minecraft.village.TradeOffer;
1812
import net.minecraft.village.VillagerProfession;
1913

2014
public class CinderscapesTrades {
2115
private static final Identifier BARTERING_LOOT_TABLE_ID = new Identifier("minecraft", "gameplay/piglin_bartering");
2216

23-
public static final LootPoolEntryType INTEGRATED = Registry.register(Registries.LOOT_POOL_ENTRY_TYPE, Cinderscapes.id("integrated"), new LootPoolEntryType(new IntegratedEntry.Serializer()));
24-
2517
public static void init() {
2618

2719
LootTableEvents.MODIFY.register((resourceManager, manager, id, supplier, setter) -> {
2820
if (BARTERING_LOOT_TABLE_ID.equals(id)) {
2921
supplier.modifyPools((pools) -> {
30-
pools .with(new IntegratedEntry(CinderscapesItems.ROSE_QUARTZ, 20, 0, new LootCondition[]{}, new LootFunction[]{SetCountLootFunction.builder(UniformLootNumberProvider.create(5, 12)).build()}))
31-
.with(new IntegratedEntry(CinderscapesItems.SMOKY_QUARTZ, 20, 0, new LootCondition[]{}, new LootFunction[]{SetCountLootFunction.builder(UniformLootNumberProvider.create(5, 12)).build()}))
32-
.with(new IntegratedEntry(CinderscapesItems.SULFUR_QUARTZ, 20, 0, new LootCondition[]{}, new LootFunction[]{SetCountLootFunction.builder(UniformLootNumberProvider.create(5, 12)).build()}));
22+
pools .with(ItemEntry.builder(CinderscapesItems.ROSE_QUARTZ).weight(20).quality(0).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(5, 12))).build())
23+
.with(ItemEntry.builder(CinderscapesItems.SMOKY_QUARTZ).weight(20).quality(0).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(5, 12))).build())
24+
.with(ItemEntry.builder(CinderscapesItems.SULFUR_QUARTZ).weight(20).quality(0).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(5, 12))).build());
3325
});
3426
}
3527
});

common/src/main/java/com/terraformersmc/cinderscapes/loottables/IntegratedEntry.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

common/src/main/java/com/terraformersmc/cinderscapes/mixin/MixinServerWorld.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
import net.minecraft.registry.entry.RegistryEntry;
1111
import net.minecraft.server.world.ServerWorld;
1212
import net.minecraft.util.math.BlockPos;
13-
import net.minecraft.util.math.ChunkPos;
1413
import net.minecraft.util.math.Direction;
1514
import net.minecraft.util.profiler.Profiler;
1615
import net.minecraft.world.MutableWorldProperties;
1716
import net.minecraft.world.World;
1817
import net.minecraft.world.biome.Biome;
19-
import net.minecraft.world.chunk.WorldChunk;
2018
import net.minecraft.world.dimension.DimensionType;
2119
import org.spongepowered.asm.mixin.Mixin;
2220
import org.spongepowered.asm.mixin.injection.At;
@@ -33,10 +31,18 @@ protected MixinServerWorld(MutableWorldProperties properties, RegistryKey<World>
3331
}
3432

3533
// TODO: Revisit this and make it easier to read
36-
@Inject(method="tickChunk", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/world/ServerWorld;getBiome(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/registry/entry/RegistryEntry;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
37-
private void cinderscapes$tickChunk(WorldChunk chunk, int randomTickSpeed, CallbackInfo callback, ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos2, BlockPos blockPos3) {
34+
// And fix having two calls to getBiome (maybe requires MixinExtras)
35+
@Inject(method="tickIceAndSnow",
36+
at = @At(value = "INVOKE_ASSIGN",
37+
target = "Lnet/minecraft/server/world/ServerWorld;getBiome(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/registry/entry/RegistryEntry;",
38+
ordinal = 0,
39+
shift = At.Shift.AFTER
40+
),
41+
locals = LocalCapture.NO_CAPTURE
42+
)
43+
private void cinderscapes$tickAsh(boolean raining, BlockPos tickPos, CallbackInfo ci) {
3844
if (CinderscapesConfig.INSTANCE.enableAshFall) {
39-
BlockPos pos = this.getRandomPosInChunk(i, 0, j, 15);
45+
BlockPos pos = tickPos.mutableCopy();
4046
BlockState state = getBlockState(pos);
4147
RegistryEntry<Biome> biome = this.getBiome(pos);
4248

0 commit comments

Comments
 (0)