Skip to content

Commit

Permalink
feat: Add StringRepresentable
Browse files Browse the repository at this point in the history
For some usages it's helpful to have the serializable name that gets used and assists
with interpreting values from user parsed files.
  • Loading branch information
gabizou committed Jun 4, 2024
1 parent 1f49f54 commit c8ee10f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SpongeAPI
Submodule SpongeAPI updated 25 files
+6 −0 src/main/java/org/spongepowered/api/data/Keys.java
+1 −1 src/main/java/org/spongepowered/api/data/type/AttachmentSurface.java
+1 −1 src/main/java/org/spongepowered/api/data/type/BambooLeavesType.java
+1 −1 src/main/java/org/spongepowered/api/data/type/BellAttachmentType.java
+1 −1 src/main/java/org/spongepowered/api/data/type/ChestAttachmentType.java
+1 −1 src/main/java/org/spongepowered/api/data/type/ComparatorMode.java
+1 −1 src/main/java/org/spongepowered/api/data/type/DoorHinge.java
+1 −1 src/main/java/org/spongepowered/api/data/type/DripstoneSegment.java
+1 −1 src/main/java/org/spongepowered/api/data/type/InstrumentType.java
+1 −1 src/main/java/org/spongepowered/api/data/type/JigsawBlockOrientation.java
+1 −1 src/main/java/org/spongepowered/api/data/type/PistonType.java
+1 −1 src/main/java/org/spongepowered/api/data/type/PortionType.java
+1 −1 src/main/java/org/spongepowered/api/data/type/RailDirection.java
+1 −1 src/main/java/org/spongepowered/api/data/type/SculkSensorState.java
+1 −1 src/main/java/org/spongepowered/api/data/type/SlabPortion.java
+1 −1 src/main/java/org/spongepowered/api/data/type/StairShape.java
+13 −0 src/main/java/org/spongepowered/api/data/type/StringRepresentable.java
+1 −1 src/main/java/org/spongepowered/api/data/type/StructureMode.java
+1 −1 src/main/java/org/spongepowered/api/data/type/Tilt.java
+1 −1 src/main/java/org/spongepowered/api/data/type/WallConnectionState.java
+1 −1 src/main/java/org/spongepowered/api/data/type/WireAttachmentType.java
+6 −0 src/main/java/org/spongepowered/api/registry/RegistryTypes.java
+2 −1 src/main/java/org/spongepowered/api/state/EnumStateProperty.java
+8 −1 src/main/java/org/spongepowered/api/util/Axis.java
+7 −1 src/main/java/org/spongepowered/api/util/Direction.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static void register(final DataProviderRegistrator registrator) {
return MatterTypes.SOLID.get();
}
})
.create(Keys.BURNABLE)
.get(BlockBehaviour.BlockStateBase::ignitedByLava)
// TODO state above
.create(Keys.REPRESENTED_INSTRUMENT)
.get(h -> (InstrumentType) (Object) h.instrument());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
package org.spongepowered.common.mixin.api.minecraft.state;

import net.minecraft.world.level.block.state.properties.EnumProperty;
import org.spongepowered.api.data.type.StringRepresentable;
import org.spongepowered.api.state.EnumStateProperty;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(value = EnumProperty.class)
public abstract class EnumPropertyMixin_API<E extends Enum<E>> extends PropertyMixin_API<E> implements EnumStateProperty<E> {
public abstract class EnumPropertyMixin_API<E extends Enum<E> & StringRepresentable> extends PropertyMixin_API<E> implements EnumStateProperty<E> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.spongepowered.common.mixin.api.minecraft.util;

import net.minecraft.util.StringRepresentable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(StringRepresentable.class)
public interface StringRepresentableMixin_API extends org.spongepowered.api.data.type.StringRepresentable {

@Shadow String shadow$getSerializedName();

@Override
default String serializationString() {
return this.shadow$getSerializedName();
}
}
1 change: 1 addition & 0 deletions src/mixins/resources/mixins.sponge.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"minecraft.stats.StatTypeMixin_API",
"minecraft.tags.TagKeyMixin_API",
"minecraft.util.RandomSourceMixin_API",
"minecraft.util.StringRepresentableMixin_API",
"minecraft.world.DifficultyMixin_API",
"minecraft.world.InteractionHandMixin_API",
"minecraft.world.IWorldGenerationBaseReaderMixin_API",
Expand Down

0 comments on commit c8ee10f

Please sign in to comment.