1
1
package dev .latvian .mods .klib .data ;
2
2
3
+ import com .mojang .authlib .GameProfile ;
3
4
import com .mojang .brigadier .arguments .BoolArgumentType ;
4
5
import com .mojang .brigadier .arguments .DoubleArgumentType ;
5
6
import com .mojang .brigadier .arguments .FloatArgumentType ;
16
17
import dev .latvian .mods .klib .color .Gradient ;
17
18
import dev .latvian .mods .klib .easing .Easing ;
18
19
import dev .latvian .mods .klib .easing .EasingGroup ;
20
+ import dev .latvian .mods .klib .math .InterpolatedDouble ;
21
+ import dev .latvian .mods .klib .math .InterpolatedFloat ;
19
22
import dev .latvian .mods .klib .math .Line ;
20
23
import dev .latvian .mods .klib .math .MovementType ;
21
24
import dev .latvian .mods .klib .math .Range ;
25
28
import dev .latvian .mods .klib .util .IntOrUUID ;
26
29
import dev .latvian .mods .klib .util .ParsedEntitySelector ;
27
30
import net .minecraft .commands .arguments .ComponentArgument ;
31
+ import net .minecraft .commands .arguments .DimensionArgument ;
32
+ import net .minecraft .commands .arguments .GameProfileArgument ;
28
33
import net .minecraft .commands .arguments .ParticleArgument ;
29
34
import net .minecraft .commands .arguments .ResourceLocationArgument ;
30
35
import net .minecraft .commands .arguments .UuidArgument ;
37
42
import net .minecraft .core .Holder ;
38
43
import net .minecraft .core .particles .ParticleOptions ;
39
44
import net .minecraft .core .particles .ParticleTypes ;
45
+ import net .minecraft .core .registries .Registries ;
40
46
import net .minecraft .network .chat .Component ;
41
47
import net .minecraft .network .chat .ComponentSerialization ;
42
48
import net .minecraft .network .codec .ByteBufCodecs ;
49
+ import net .minecraft .resources .ResourceKey ;
50
+ import net .minecraft .resources .ResourceLocation ;
43
51
import net .minecraft .sounds .SoundEvent ;
44
52
import net .minecraft .sounds .SoundSource ;
45
53
import net .minecraft .world .InteractionHand ;
46
54
import net .minecraft .world .item .ItemStack ;
55
+ import net .minecraft .world .level .Level ;
47
56
import net .minecraft .world .level .block .Mirror ;
48
57
import net .minecraft .world .level .block .Rotation ;
49
58
import net .minecraft .world .level .block .state .BlockState ;
@@ -81,6 +90,8 @@ public interface DataTypes {
81
90
DataType <Vec3 > VEC3S = DataType .of (MCCodecs .VEC3S , MCStreamCodecs .VEC3S , Vec3 .class );
82
91
DataType <BlockPos > BLOCK_POS = DataType .of (BlockPos .CODEC , BlockPos .STREAM_CODEC , BlockPos .class );
83
92
DataType <Integer > TICKS = DataType .of (KLibCodecs .TICKS , ByteBufCodecs .VAR_INT , Integer .class );
93
+ DataType <GameProfile > GAME_PROFILE = DataType .of (MCCodecs .GAME_PROFILE , MCStreamCodecs .GAME_PROFILE , GameProfile .class );
94
+ DataType <ResourceKey <Level >> DIMENSION = DataType .of (MCCodecs .DIMENSION , MCStreamCodecs .DIMENSION , (Class ) ResourceKey .class );
84
95
85
96
static void register () {
86
97
DataType .register (ID .java ("bool" ), BOOL , BoolArgumentType ::bool , BoolArgumentType ::getBool );
@@ -109,6 +120,11 @@ static void register() {
109
120
DataType .register (ID .mc ("vec3s" ), VEC3S , () -> Vec3Argument .vec3 (), Vec3Argument ::getVec3 );
110
121
DataType .register (ID .mc ("block_pos" ), BLOCK_POS , BlockPosArgument ::blockPos , BlockPosArgument ::getBlockPos );
111
122
DataType .register (ID .mc ("ticks" ), TICKS , () -> KLibCodecs .TIME_ARGUMENT , IntegerArgumentType ::getInteger );
123
+ DataType .register (ID .mc ("game_profile" ), GAME_PROFILE , GameProfileArgument ::gameProfile , (ctx , name ) -> {
124
+ var profiles = GameProfileArgument .getGameProfiles (ctx , name );
125
+ return profiles .isEmpty () ? null : profiles .iterator ().next ();
126
+ });
127
+ DataType .register (ID .mc ("dimension" ), DIMENSION , DimensionArgument ::dimension , (ctx , name ) -> ResourceKey .create (Registries .DIMENSION , ctx .getArgument (name , ResourceLocation .class )));
112
128
113
129
DataType .register (KLibMod .id ("color" ), Color .DATA_TYPE );
114
130
DataType .register (KLibMod .id ("gradient" ), Gradient .DATA_TYPE );
@@ -125,5 +141,7 @@ static void register() {
125
141
DataType .register (KLibMod .id ("easing_group" ), EasingGroup .DATA_TYPE );
126
142
DataType .register (KLibMod .id ("int_or_uuid" ), IntOrUUID .DATA_TYPE );
127
143
DataType .register (KLibMod .id ("line" ), Line .DATA_TYPE );
144
+ DataType .register (KLibMod .id ("interpolated_float" ), InterpolatedFloat .DATA_TYPE );
145
+ DataType .register (KLibMod .id ("interpolated_double" ), InterpolatedDouble .DATA_TYPE );
128
146
}
129
147
}
0 commit comments