Skip to content

Commit

Permalink
chore: update api data types for 1.21.2 content
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
  • Loading branch information
gabizou committed Oct 15, 2024
1 parent 20c98f2 commit d36a5a8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion SpongeAPI
Submodule SpongeAPI updated 28 files
+1 −1 src/main/java/org/spongepowered/api/advancement/criteria/trigger/Triggers.java
+98 −0 src/main/java/org/spongepowered/api/block/BlockTypes.java
+2 −0 src/main/java/org/spongepowered/api/block/entity/BlockEntityTypes.java
+39 −0 src/main/java/org/spongepowered/api/block/entity/CreakingHeart.java
+5 −0 src/main/java/org/spongepowered/api/data/BlockStateKeys.java
+35 −0 src/main/java/org/spongepowered/api/data/type/CreakingHeart.java
+44 −0 src/main/java/org/spongepowered/api/data/type/CreakingHearts.java
+4 −0 src/main/java/org/spongepowered/api/effect/particle/ParticleTypes.java
+54 −4 src/main/java/org/spongepowered/api/effect/sound/SoundTypes.java
+45 −3 src/main/java/org/spongepowered/api/entity/EntityTypes.java
+33 −31 src/main/java/org/spongepowered/api/entity/attribute/type/AttributeTypes.java
+30 −0 src/main/java/org/spongepowered/api/entity/living/monster/Creaking.java
+32 −0 src/main/java/org/spongepowered/api/entity/vehicle/Raft.java
+4 −0 src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageTypes.java
+134 −0 src/main/java/org/spongepowered/api/item/ItemTypes.java
+3 −0 src/main/java/org/spongepowered/api/registry/RegistryTypes.java
+4 −0 src/main/java/org/spongepowered/api/state/BooleanStateProperties.java
+5 −0 src/main/java/org/spongepowered/api/state/EnumStateProperties.java
+2 −0 src/main/java/org/spongepowered/api/tag/BlockTypeTags.java
+2 −0 src/main/java/org/spongepowered/api/tag/DamageTypeTags.java
+2 −0 src/main/java/org/spongepowered/api/tag/EntityTypeTags.java
+46 −0 src/main/java/org/spongepowered/api/tag/ItemTypeTags.java
+5 −1 src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteractions.java
+4 −0 src/main/java/org/spongepowered/api/world/gamerule/GameRules.java
+10 −2 src/main/java/org/spongepowered/api/world/generation/feature/Features.java
+6 −2 src/main/java/org/spongepowered/api/world/generation/feature/PlacedFeatures.java
+0 −2 src/main/java/org/spongepowered/api/world/generation/feature/PlacementModifierTypes.java
+4 −0 src/main/java/org/spongepowered/api/world/generation/structure/jigsaw/JigsawPools.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,11 @@ private static Pair<RegistryAccess.Frozen, ReloadableServerResources> loadVanill
final var wga = staticRegistries.getAccessForLoading(RegistryLayer.WORLDGEN);
List<HolderLookup.RegistryLookup<?>> tl = TagLoader.buildUpdatedLookups(wga, pendingTags);
RegistryAccess.Frozen wgr = RegistryDataLoader.load(rm, tl, RegistryDataLoader.WORLDGEN_REGISTRIES);
tl = TagLoader.buildUpdatedLookups(wgr, pendingTags);
List<HolderLookup.RegistryLookup<?>> cl = Stream.concat(tl.stream(), wgr.listRegistries()).toList();
final LayeredRegistryAccess<RegistryLayer> 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<RegistryLayer> 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(
Expand Down Expand Up @@ -378,7 +375,7 @@ private static List<Generator> generators(final Context context) {
),
new EnumEntriesValidator<>(
"world.explosion",
"BlockInteractions",
"ExplosionBlockInteractions",
Explosion.BlockInteraction.class,
"name",
"sponge"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@
*/
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;
import net.minecraft.resources.ResourceLocation;
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;
Expand Down Expand Up @@ -121,7 +125,7 @@ public void generate(final Context ctx) throws IOException {
clazz.addAnnotation(Types.suppressWarnings("unused"));

final RegistryScope scopeType;
Registry<V> registry = (Registry<V>) BuiltInRegistries.REGISTRY.get(this.registry.location()).orElse(null);
Registry<V> registry = (Registry<V>) 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) {
Expand Down Expand Up @@ -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();
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d36a5a8

Please sign in to comment.