diff --git a/SpongeAPI b/SpongeAPI index f42a8a8a443..7f4b70ea4c9 160000 --- a/SpongeAPI +++ b/SpongeAPI @@ -1 +1 @@ -Subproject commit f42a8a8a44309e2230e05b081736ac28cdfa2511 +Subproject commit 7f4b70ea4c9738df9069df51ca0bd36b44f9e329 diff --git a/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertiesGenerator.java b/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertiesGenerator.java index 202e77ae676..fbcf5ea6048 100644 --- a/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertiesGenerator.java +++ b/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertiesGenerator.java @@ -32,6 +32,7 @@ import net.minecraft.core.FrontAndTop; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CreakingHeartBlock; import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerState; import net.minecraft.world.level.block.entity.vault.VaultState; import net.minecraft.world.level.block.state.BlockState; @@ -131,6 +132,7 @@ static PropertyType ofProperty(final Property prop) { vanillaEnumTypeMapping.put(StructureMode.class, BlockStatePropertiesGenerator.inDataTypePkg("StructureMode")); vanillaEnumTypeMapping.put(PistonType.class, BlockStatePropertiesGenerator.inDataTypePkg("PistonType")); vanillaEnumTypeMapping.put(BambooLeaves.class, BlockStatePropertiesGenerator.inDataTypePkg("BambooLeavesType")); + vanillaEnumTypeMapping.put(CreakingHeartBlock.CreakingHeartState.class, BlockStatePropertiesGenerator.inDataTypePkg("CreakingHeart")); vanillaEnumTypeMapping.put(WallSide.class, BlockStatePropertiesGenerator.inDataTypePkg("WallConnectionState")); vanillaEnumTypeMapping.put(RailShape.class, BlockStatePropertiesGenerator.inDataTypePkg("RailDirection")); vanillaEnumTypeMapping.put(AttachFace.class, BlockStatePropertiesGenerator.inDataTypePkg("AttachmentSurface")); diff --git a/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertyKeysGenerator.java b/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertyKeysGenerator.java index d00816a08ce..8e269ac5864 100644 --- a/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertyKeysGenerator.java +++ b/generator/src/main/java/org/spongepowered/vanilla/generator/BlockStatePropertyKeysGenerator.java @@ -33,6 +33,7 @@ import com.squareup.javapoet.TypeVariableName; import net.minecraft.core.Direction; import net.minecraft.core.FrontAndTop; +import net.minecraft.world.level.block.CreakingHeartBlock; import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerState; import net.minecraft.world.level.block.entity.vault.VaultState; import net.minecraft.world.level.block.state.BlockState; @@ -129,6 +130,7 @@ static BlockStatePropertyKeysGenerator.PropertyType ofProperty(final Property vanillaEnumTypeMapping.put(StructureMode.class, BlockStatePropertyKeysGenerator.inDataTypePkg("StructureMode")); vanillaEnumTypeMapping.put(PistonType.class, BlockStatePropertyKeysGenerator.inDataTypePkg("PistonType")); vanillaEnumTypeMapping.put(BambooLeaves.class, BlockStatePropertyKeysGenerator.inDataTypePkg("BambooLeavesType")); + vanillaEnumTypeMapping.put(CreakingHeartBlock.CreakingHeartState.class, BlockStatePropertyKeysGenerator.inDataTypePkg("CreakingHeart")); vanillaEnumTypeMapping.put(WallSide.class, BlockStatePropertyKeysGenerator.inDataTypePkg("WallConnectionState")); vanillaEnumTypeMapping.put(RailShape.class, BlockStatePropertyKeysGenerator.inDataTypePkg("RailDirection")); vanillaEnumTypeMapping.put(AttachFace.class, BlockStatePropertyKeysGenerator.inDataTypePkg("AttachmentSurface")); diff --git a/generator/src/main/java/org/spongepowered/vanilla/generator/EnumEntriesValidator.java b/generator/src/main/java/org/spongepowered/vanilla/generator/EnumEntriesValidator.java index 27618ec8527..78acf6a1f41 100644 --- a/generator/src/main/java/org/spongepowered/vanilla/generator/EnumEntriesValidator.java +++ b/generator/src/main/java/org/spongepowered/vanilla/generator/EnumEntriesValidator.java @@ -136,7 +136,11 @@ public void generate(final Context ctx) { // Sort field entries and add them back to the class processedFields.sort(Comparator.comparing(field -> field.getVariable(0).getNameAsString())); - primaryTypeDeclaration.getMembers().addAll(lastNonFieldIndex, processedFields); + var indextoAddAt = lastNonFieldIndex; + if (indextoAddAt == -1) { + indextoAddAt = 0; + } + primaryTypeDeclaration.getMembers().addAll(indextoAddAt, processedFields); if (!added.isEmpty()) { Logger.info("Added {} entries to {} that will require manual action to implement: {}", added.size(), this.targetClassSimpleName, added); diff --git a/generator/src/main/java/org/spongepowered/vanilla/generator/GeneratorMain.java b/generator/src/main/java/org/spongepowered/vanilla/generator/GeneratorMain.java index 9df502ce99f..fa239231a98 100644 --- a/generator/src/main/java/org/spongepowered/vanilla/generator/GeneratorMain.java +++ b/generator/src/main/java/org/spongepowered/vanilla/generator/GeneratorMain.java @@ -170,14 +170,11 @@ private static Pair loadVanill final var wga = staticRegistries.getAccessForLoading(RegistryLayer.WORLDGEN); List> tl = TagLoader.buildUpdatedLookups(wga, pendingTags); RegistryAccess.Frozen wgr = RegistryDataLoader.load(rm, tl, RegistryDataLoader.WORLDGEN_REGISTRIES); - tl = TagLoader.buildUpdatedLookups(wgr, pendingTags); List> cl = Stream.concat(tl.stream(), wgr.listRegistries()).toList(); final LayeredRegistryAccess withWorldGen = staticRegistries.replaceFrom(RegistryLayer.WORLDGEN, wgr); - pendingTags = TagLoader.loadTagsForExistingRegistries(rm, staticRegistries.getLayer(RegistryLayer.WORLDGEN)); RegistryAccess.Frozen da = RegistryDataLoader.load(rm, cl, RegistryDataLoader.DIMENSION_REGISTRIES); - TagLoader.buildUpdatedLookups(da, pendingTags); final LayeredRegistryAccess withDimensions = withWorldGen.replaceFrom(RegistryLayer.DIMENSIONS, da); - pendingTags = TagLoader.loadTagsForExistingRegistries(rm, staticRegistries.getLayer(RegistryLayer.DIMENSIONS)); + TagLoader.loadTagsForExistingRegistries(rm, withDimensions.getLayer(RegistryLayer.WORLDGEN)); final RegistryAccess.Frozen compositeRegistries = withDimensions.getAccessForLoading(RegistryLayer.RELOADABLE); final var resourcesFuture = ReloadableServerResources.loadResources( @@ -378,7 +375,7 @@ private static List generators(final Context context) { ), new EnumEntriesValidator<>( "world.explosion", - "BlockInteractions", + "ExplosionBlockInteractions", Explosion.BlockInteraction.class, "name", "sponge" diff --git a/generator/src/main/java/org/spongepowered/vanilla/generator/RegistryEntriesGenerator.java b/generator/src/main/java/org/spongepowered/vanilla/generator/RegistryEntriesGenerator.java index 72abbf31d06..753594ccfeb 100644 --- a/generator/src/main/java/org/spongepowered/vanilla/generator/RegistryEntriesGenerator.java +++ b/generator/src/main/java/org/spongepowered/vanilla/generator/RegistryEntriesGenerator.java @@ -24,10 +24,13 @@ */ package org.spongepowered.vanilla.generator; +import com.squareup.javapoet.AnnotationSpec; +import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; +import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; @@ -35,6 +38,7 @@ import net.minecraft.world.flag.FeatureElement; import net.minecraft.world.flag.FeatureFlagSet; import net.minecraft.world.flag.FeatureFlags; +import org.jetbrains.annotations.ApiStatus; import java.io.IOException; import java.util.Comparator; @@ -121,7 +125,7 @@ public void generate(final Context ctx) throws IOException { clazz.addAnnotation(Types.suppressWarnings("unused")); final RegistryScope scopeType; - Registry registry = (Registry) BuiltInRegistries.REGISTRY.get(this.registry.location()).orElse(null); + Registry registry = (Registry) BuiltInRegistries.REGISTRY.get(this.registry.location()).map(Holder.Reference::value).orElse(null); if (registry == null) { registry = ctx.registries().lookup(this.registry).orElse(null); if (registry == null) { @@ -160,12 +164,12 @@ private FieldSpec makeField(final String ownType, final TypeName fieldType, fina if (!featureFlagSet.isSubsetOf(FeatureFlags.VANILLA_SET)) { final var flags = FeatureFlags.REGISTRY.toNames(featureFlagSet).stream().map(rl -> rl.getNamespace().equals("minecraft") ? rl.getPath() : rl.getNamespace() + ":" + rl.getPath()).toArray(); // Use this when new feature flags are introduced -// if (featureFlagSet.contains(FeatureFlags.UPDATE_1_20)) { -// var annotation = AnnotationSpec.builder(ClassName.get("org.spongepowered.api.util.annotation", "Experimental")) -// .addMember("value", "$S", flags).build(); -// builder.addAnnotation(annotation).build(); -// builder.addAnnotation(ApiStatus.Experimental.class).build(); -// } + if (featureFlagSet.contains(FeatureFlags.WINTER_DROP)) { + var annotation = AnnotationSpec.builder(ClassName.get("org.spongepowered.api.util.annotation", "Experimental")) + .addMember("value", "$S", flags).build(); + builder.addAnnotation(annotation).build(); + builder.addAnnotation(ApiStatus.Experimental.class).build(); + } } diff --git a/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java b/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java index 92460049d70..5a732f206ce 100644 --- a/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java @@ -373,7 +373,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(ravager, Keys.CAN_JOIN_RAID, true); this.checkOfferData(ravager, Keys.CAN_JOIN_RAID, false); - final Entity boat = world.createEntity(EntityTypes.BOAT.get(), position); + final Entity boat = world.createEntity(EntityTypes.OAK_BOAT.get(), position); this.checkOfferData(boat, Keys.CAN_MOVE_ON_LAND, true); this.checkOfferData(boat, Keys.CAN_MOVE_ON_LAND, false);