From 73b4d285f1b47ed7ecbc299712501051e9fd0878 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 4 Mar 2022 15:59:04 +0100 Subject: [PATCH] update to 1.18.2 yooo --- build.gradle | 16 +++---- .../naturesaura/api/multiblock/Matcher.java | 5 ++- .../blocks/BlockAncientSapling.java | 2 +- .../naturesaura/blocks/multi/Multiblocks.java | 2 +- .../tiles/BlockEntityBlastFurnaceBooster.java | 2 +- .../tiles/BlockEntityFlowerGenerator.java | 2 +- .../blocks/tiles/BlockEntityOakGenerator.java | 2 +- .../blocks/tiles/BlockEntityWoodStand.java | 4 +- .../chunk/effect/NetherGrassEffect.java | 3 +- .../chunk/effect/OreSpawnEffect.java | 8 ++-- .../naturesaura/compat/CuriosCompat.java | 2 +- .../naturesaura/data/BlockTagProvider.java | 5 ++- .../naturesaura/data/ItemTagProvider.java | 3 +- .../entities/EntityMoverMinecart.java | 2 +- .../ellpeck/naturesaura/gen/ModFeatures.java | 24 ++++++----- .../naturesaura/items/ItemCrimsonMeal.java | 2 +- .../items/ItemStructureFinder.java | 14 +++--- .../naturesaura/items/tools/ItemAxe.java | 2 +- .../ellpeck/naturesaura/reg/ModRegistry.java | 43 +++++++++---------- 19 files changed, 75 insertions(+), 68 deletions(-) diff --git a/build.gradle b/build.gradle index 9d14737a..d7bb1c04 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ if (System.getenv('BUILD_NUMBER') != null) { java.toolchain.languageVersion = JavaLanguageVersion.of(17) minecraft { - mappings channel: 'official', version: '1.18.1' + mappings channel: 'official', version: '1.18.2' runs { client { @@ -102,16 +102,16 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.18.1-39.0.5' + minecraft 'net.minecraftforge:forge:1.18.2-40.0.3' - compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47:api") - runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47") + compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117:api") + runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117") - compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-63:api") - runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-63") + compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-66-SNAPSHOT:api") + runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-66-SNAPSHOT") - runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0") - compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0:api") + runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.6.3") + compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.6.3:api") // TODO Enchantability /* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/ diff --git a/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java b/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java index c80dc06c..81036a01 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java +++ b/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.api.multiblock; import net.minecraft.core.BlockPos; import net.minecraft.tags.Tag; +import net.minecraft.tags.TagKey; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -13,8 +14,8 @@ public record Matcher(BlockState defaultState, ICheck check) { return new Matcher(Blocks.AIR.defaultBlockState(), null); } - public static Matcher tag(Block defaultBlock, Tag.Named tag) { - return new Matcher(defaultBlock.defaultBlockState(), (level, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName())); + public static Matcher tag(Block defaultBlock, TagKey tag) { + return new Matcher(defaultBlock.defaultBlockState(), (level, start, offset, pos, state, c) -> state.is(tag)); } public interface ICheck { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index 0f5e6294..1321175d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -69,7 +69,7 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock, if (state.getValue(SaplingBlock.STAGE) == 0) { level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4); } else if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) { - ModFeatures.Configured.ANCIENT_TREE.place(level, level.getChunkSource().getGenerator(), rand, pos); + ModFeatures.Configured.ANCIENT_TREE.value().place(level, level.getChunkSource().getGenerator(), rand, pos); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java index ac67d9e5..0a3eb159 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java @@ -77,7 +77,7 @@ public final class Multiblocks { new String[][]{ {" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}}, 'R', new Matcher(Blocks.POPPY.defaultBlockState(), - (level, start, offset, pos, state, c) -> BlockTags.SMALL_FLOWERS.contains(state.getBlock())), + (level, start, offset, pos, state, c) -> state.is(BlockTags.SMALL_FLOWERS)), '0', ModBlocks.OFFERING_TABLE, ' ', Matcher.wildcard()); public static final IMultiblock ANIMAL_SPAWNER = NaturesAuraAPI.instance().createMultiblock( diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java index a2972474..62e7ff8f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java @@ -68,7 +68,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I private boolean isApplicable(List ingredients) { for (var ing : ingredients) { for (var stack : ing.getItems()) { - if (stack.getItem().getTags().stream().anyMatch(t -> t.getPath().startsWith("ores/"))) + if (stack.getTags().anyMatch(t -> t.location().getPath().startsWith("ores/"))) return true; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java index 3799463c..edf48b14 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java @@ -38,7 +38,7 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick for (var z = -range; z <= range; z++) { var offset = this.worldPosition.offset(x, y, z); var state = this.level.getBlockState(offset); - if (BlockTags.SMALL_FLOWERS.contains(state.getBlock())) + if (state.is(BlockTags.SMALL_FLOWERS)) possible.add(offset); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOakGenerator.java index b76f0baf..d04e32eb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOakGenerator.java @@ -22,7 +22,7 @@ public class BlockEntityOakGenerator extends BlockEntityImpl implements ITickabl if (!this.level.isClientSide) while (!this.scheduledBigTrees.isEmpty()) { var pos = this.scheduledBigTrees.remove(); - if (this.level.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) { + if (this.level.getBlockState(pos).is(BlockTags.LOGS)) { var toAdd = 100000; var canGen = this.canGenerateRightNow(toAdd); if (canGen) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java index f6c175fc..82c334ed 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java @@ -133,7 +133,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl for (var z = -1; z <= 1; z++) { var offset = pos.offset(x, y, z); var state = level.getBlockState(offset); - if (state.getBlock().getTags().contains(BlockTags.LOGS.getName()) || includeLeaves && state.getBlock() instanceof LeavesBlock) { + if (state.is(BlockTags.LOGS) || includeLeaves && state.getBlock() instanceof LeavesBlock) { if (drop) { level.destroyBlock(offset, true); } else { @@ -154,7 +154,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl } for (var i = 0; i < 2; i++) { var state = this.level.getBlockState(this.ritualPos.above(i)); - if (!(state.getBlock().getTags().contains(BlockTags.LOGS.getName()))) + if (!(state.is(BlockTags.LOGS))) return false; } if (this.timer < this.recipe.time / 2) { diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java index be87e0a9..f734250a 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java @@ -80,8 +80,7 @@ public class NetherGrassEffect implements IDrainSpotEffect { continue; var state = level.getBlockState(goalPos); - var block = state.getBlock(); - if (Tags.Blocks.NETHERRACK.contains(block)) { + if (state.is(Tags.Blocks.NETHERRACK)) { level.setBlockAndUpdate(goalPos, ModBlocks.NETHER_GRASS.defaultBlockState()); var closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos); diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index faa351fb..5ad08f49 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -13,6 +13,7 @@ import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.Tag; +import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; import net.minecraft.util.Tuple; import net.minecraft.util.random.WeightedRandom; @@ -105,7 +106,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { var y = Mth.floor(powderPos.y + level.random.nextGaussian() * range); var z = Mth.floor(powderPos.z + level.random.nextGaussian() * range); var orePos = new BlockPos(x, y, z); - if (orePos.distSqr(powderPos.x, powderPos.y, powderPos.z, true) <= range * range + if (orePos.distToCenterSqr(powderPos.x, powderPos.y, powderPos.z) <= range * range && orePos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(orePos)) { var state = level.getBlockState(orePos); if (state.getBlock() != requiredBlock) @@ -116,10 +117,11 @@ public class OreSpawnEffect implements IDrainSpotEffect { var ore = WeightedRandom.getRandomItem(level.random, ores, totalWeight).orElse(null); if (ore == null) continue; - var tag = level.getTagManager().getOrEmpty(Registry.BLOCK_REGISTRY).getTag(ore.tag); + var tag = TagKey.create(Registry.BLOCK_REGISTRY, ore.tag); if (tag == null) continue; - for (var toPlace : tag.getValues()) { + for (var holder : Registry.BLOCK.getTagOrEmpty(tag)) { + var toPlace = holder.value(); if (toPlace == null || toPlace == Blocks.AIR) continue; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java index 1c2f45f7..15d44fac 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java @@ -93,7 +93,7 @@ public class CuriosCompat implements ICompat { @Override public void addItemTags(ItemTagProvider provider) { for (var entry : TYPES.entrySet()) { - var tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue())); + var tag = ItemTags.create(new ResourceLocation("curios", entry.getValue())); provider.tag(tag).add(entry.getKey()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java index 94cd34d9..19f1b15e 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java @@ -6,6 +6,7 @@ import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.common.Tags; @@ -14,7 +15,7 @@ import org.jetbrains.annotations.Nullable; public class BlockTagProvider extends BlockTagsProvider { - public static final Tags.IOptionalNamedTag NETHER_ALTAR_WOOD = BlockTags.createOptional(new ResourceLocation(NaturesAura.MOD_ID, "nether_altar_wood")); + public static final TagKey NETHER_ALTAR_WOOD = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "nether_altar_wood")); public BlockTagProvider(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper) { super(gen, NaturesAura.MOD_ID, existingFileHelper); @@ -28,7 +29,7 @@ public class BlockTagProvider extends BlockTagsProvider { this.tag(BlockTags.LEAVES).add(ModBlocks.GOLDEN_LEAVES, ModBlocks.ANCIENT_LEAVES, ModBlocks.DECAYED_LEAVES); this.tag(BlockTags.RAILS).add(ModBlocks.DIMENSION_RAIL_END, ModBlocks.DIMENSION_RAIL_NETHER, ModBlocks.DIMENSION_RAIL_OVERWORLD); this.tag(BlockTags.SLABS).add(ModBlocks.ANCIENT_SLAB, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_BRICK_SLAB); - this.tag(Tags.Blocks.DIRT).add(ModBlocks.NETHER_GRASS); + this.tag(BlockTags.DIRT).add(ModBlocks.NETHER_GRASS); this.tag(BlockTags.SMALL_FLOWERS).add(ModBlocks.END_FLOWER, ModBlocks.AURA_BLOOM); this.tag(NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS); } diff --git a/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java index 66417484..a7a369e1 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java @@ -11,6 +11,7 @@ import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.Tag; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ExistingFileHelper; @@ -37,7 +38,7 @@ public class ItemTagProvider extends ItemTagsProvider { } @Override - public TagAppender tag(Tag.Named p_126549_) { + public TagAppender tag(TagKey p_126549_) { // super is protected, but CuriosCompat needs this return super.tag(p_126549_); } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java index b53128ee..64091142 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java @@ -156,7 +156,7 @@ public class EntityMoverMinecart extends AbstractMinecart { } @Override - public ItemStack getCartItem() { + public ItemStack getPickResult() { return new ItemStack(ModItems.MOVER_CART); } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index d3ae0f39..00c214c2 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.gen; +import net.minecraft.core.Holder; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; @@ -20,22 +21,23 @@ public final class ModFeatures { public static final class Configured { - public static final ConfiguredFeature ANCIENT_TREE = ModFeatures.ANCIENT_TREE.configured(new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build()); - public static final ConfiguredFeature AURA_BLOOM = ModFeatures.AURA_BLOOM.configured(FeatureConfiguration.NONE); - public static final ConfiguredFeature AURA_CACTUS = ModFeatures.AURA_CACTUS.configured(FeatureConfiguration.NONE); - public static final ConfiguredFeature WARPED_AURA_MUSHROOM = ModFeatures.WARPED_AURA_MUSHROOM.configured(FeatureConfiguration.NONE); - public static final ConfiguredFeature CRIMSON_AURA_MUSHROOM = ModFeatures.CRIMSON_AURA_MUSHROOM.configured(FeatureConfiguration.NONE); - public static final ConfiguredFeature AURA_MUSHROOM = ModFeatures.AURA_MUSHROOM.configured(FeatureConfiguration.NONE); + public static Holder> ANCIENT_TREE; + public static Holder> NETHER_WART_MUSHROOM; + public static Holder> AURA_BLOOM; + public static Holder> AURA_CACTUS; + public static Holder> WARPED_AURA_MUSHROOM; + public static Holder> CRIMSON_AURA_MUSHROOM; + public static Holder> AURA_MUSHROOM; } public static final class Placed { - public static final PlacedFeature AURA_BLOOM = ModFeatures.Configured.AURA_BLOOM.placed(); - public static final PlacedFeature AURA_CACTUS = ModFeatures.Configured.AURA_CACTUS.placed(); - public static final PlacedFeature WARPED_AURA_MUSHROOM = ModFeatures.Configured.WARPED_AURA_MUSHROOM.placed(); - public static final PlacedFeature CRIMSON_AURA_MUSHROOM = ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.placed(); - public static final PlacedFeature AURA_MUSHROOM = ModFeatures.Configured.AURA_MUSHROOM.placed(); + public static Holder AURA_BLOOM; + public static Holder AURA_CACTUS; + public static Holder WARPED_AURA_MUSHROOM; + public static Holder CRIMSON_AURA_MUSHROOM; + public static Holder AURA_MUSHROOM; } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java index b52d1824..c819f932 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java @@ -27,7 +27,7 @@ public class ItemCrimsonMeal extends ItemImpl { if (level.random.nextInt(5) == 0) { int age = state.getValue(NetherWartBlock.AGE); if (age >= 3) { - ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.place((ServerLevel) level, ((ServerLevel) level).getChunkSource().getGenerator(), level.random, pos); + ModFeatures.Configured.CRIMSON_AURA_MUSHROOM.value().place((ServerLevel) level, ((ServerLevel) level).getChunkSource().getGenerator(), level.random, pos); } else { level.setBlockAndUpdate(pos, state.setValue(NetherWartBlock.AGE, age + 1)); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java index b3cd6e0e..0d29f9f6 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java @@ -2,7 +2,8 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.entities.EntityStructureFinder; import de.ellpeck.naturesaura.entities.ModEntities; -import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -10,15 +11,15 @@ import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; public class ItemStructureFinder extends ItemImpl { - private final StructureFeature structureName; + private final Holder> structureName; private final int color; private final int radius; - public ItemStructureFinder(String baseName, StructureFeature structureName, int color, int radius) { + public ItemStructureFinder(String baseName, Holder> structureName, int color, int radius) { super(baseName); this.structureName = structureName; this.color = color; @@ -29,13 +30,14 @@ public class ItemStructureFinder extends ItemImpl { public InteractionResultHolder use(Level levelIn, Player playerIn, InteractionHand handIn) { var stack = playerIn.getItemInHand(handIn); if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) { - var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, this.structureName, playerIn.blockPosition(), this.radius, false); + var holderSet = HolderSet.direct(this.structureName); + var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false); if (pos != null) { var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn); entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ()); entity.setItem(stack); entity.getEntityData().set(EntityStructureFinder.COLOR, this.color); - entity.signalTo(pos.above(64)); + entity.signalTo(pos.getFirst().above(64)); levelIn.addFreshEntity(entity); stack.shrink(1); diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java index 55a23cfc..e63f9832 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java @@ -48,7 +48,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Override public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, Player player) { if (itemstack.getItem() == ModItems.SKY_AXE) { - if (player.level.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) { + if (player.level.getBlockState(pos).is(BlockTags.LOGS)) { BlockEntityWoodStand.recurseTreeDestruction(player.level, pos, pos, false, true); return true; } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 26fb643d..aa679e2a 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -24,6 +24,9 @@ import de.ellpeck.naturesaura.recipes.EnabledCondition; import de.ellpeck.naturesaura.recipes.ModRecipes; import net.minecraft.core.Registry; import net.minecraft.data.BuiltinRegistries; +import net.minecraft.data.worldgen.StructureFeatures; +import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; @@ -42,6 +45,8 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.StructureFeature; +import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.material.Material; import net.minecraftforge.common.crafting.CraftingHelper; @@ -214,9 +219,9 @@ public final class ModRegistry { new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST), new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS), new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET), - new ItemStructureFinder("fortress_finder", StructureFeature.NETHER_BRIDGE, 0xba2800, 1024), - new ItemStructureFinder("end_city_finder", StructureFeature.END_CITY, 0xca5cd6, 1024), - new ItemStructureFinder("outpost_finder", StructureFeature.PILLAGER_OUTPOST, 0xab9f98, 2048), + new ItemStructureFinder("fortress_finder", StructureFeatures.FORTRESS, 0xba2800, 1024), + new ItemStructureFinder("end_city_finder", StructureFeatures.END_CITY, 0xca5cd6, 1024), + new ItemStructureFinder("outpost_finder", StructureFeatures.PILLAGER_OUTPOST, 0xab9f98, 2048), new ItemBreakPrevention(), new ItemPetReviver(), new ItemNetheriteFinder() @@ -313,25 +318,19 @@ public final class ModRegistry { } public static void init() { - // register features 27 more times for some reason - for (var entry : ModFeatures.Configured.class.getFields()) { - try { - var feature = (ConfiguredFeature) entry.get(null); - Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, feature.feature.getRegistryName(), feature); - } catch (IllegalAccessException e) { - NaturesAura.LOGGER.error(e); - } - } - for (var entry : ModFeatures.Placed.class.getFields()) { - try { - var placed = (PlacedFeature) entry.get(null); - // why are you making this so difficult for me - Supplier> feature = ObfuscationReflectionHelper.getPrivateValue(PlacedFeature.class, placed, "f_191775_"); - Registry.register(BuiltinRegistries.PLACED_FEATURE, feature.get().feature.getRegistryName(), placed); - } catch (IllegalAccessException e) { - NaturesAura.LOGGER.error(e); - } - } + ModFeatures.Configured.AURA_BLOOM = FeatureUtils.register(ModFeatures.AURA_BLOOM.getRegistryName().toString(), ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.AURA_CACTUS = FeatureUtils.register(ModFeatures.AURA_CACTUS.getRegistryName().toString(), ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.WARPED_AURA_MUSHROOM = FeatureUtils.register(ModFeatures.WARPED_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.CRIMSON_AURA_MUSHROOM = FeatureUtils.register(ModFeatures.CRIMSON_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.CRIMSON_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.AURA_MUSHROOM = FeatureUtils.register(ModFeatures.AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.ANCIENT_TREE = FeatureUtils.register(ModFeatures.ANCIENT_TREE.getRegistryName().toString(), ModFeatures.ANCIENT_TREE, new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build()); + ModFeatures.Configured.NETHER_WART_MUSHROOM = FeatureUtils.register(ModFeatures.NETHER_WART_MUSHROOM.getRegistryName().toString(), ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + + ModFeatures.Placed.AURA_BLOOM = PlacementUtils.register(ModFeatures.AURA_BLOOM.getRegistryName().toString(), ModFeatures.Configured.AURA_BLOOM); + ModFeatures.Placed.AURA_CACTUS = PlacementUtils.register(ModFeatures.AURA_CACTUS.getRegistryName().toString(), ModFeatures.Configured.AURA_CACTUS); + ModFeatures.Placed.WARPED_AURA_MUSHROOM = PlacementUtils.register(ModFeatures.WARPED_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.Configured.WARPED_AURA_MUSHROOM); + ModFeatures.Placed.CRIMSON_AURA_MUSHROOM = PlacementUtils.register(ModFeatures.CRIMSON_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); + ModFeatures.Placed.AURA_MUSHROOM = PlacementUtils.register(ModFeatures.AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.Configured.AURA_MUSHROOM); } public static Block createFlowerPot(Block block) {