6
6
import com .github .franckyi .ibeeditor .client .screen .model .entry .item .PotionEffectEntryModel ;
7
7
import com .github .franckyi .ibeeditor .client .screen .model .entry .item .PotionSelectionEntryModel ;
8
8
import com .github .franckyi .ibeeditor .common .ModTexts ;
9
+ import net .minecraft .core .registries .BuiltInRegistries ;
9
10
import net .minecraft .nbt .CompoundTag ;
10
11
import net .minecraft .nbt .ListTag ;
11
12
import net .minecraft .nbt .Tag ;
12
13
import net .minecraft .network .chat .MutableComponent ;
14
+ import net .minecraft .world .effect .MobEffects ;
13
15
14
16
public class ItemPotionEffectsCategoryModel extends ItemEditorCategoryModel {
15
17
private ListTag potionEffectList ;
@@ -23,7 +25,7 @@ protected void setupEntries() {
23
25
getEntries ().add (new PotionSelectionEntryModel (this , ModTexts .DEFAULT_POTION ,
24
26
getTag ().getString ("Potion" ), getCustomPotionColor (),
25
27
p -> getTag ().putString ("Potion" , p ), this ::setCustomPotionColor ));
26
- getTag ().getList ("CustomPotionEffects " , Tag .TAG_COMPOUND ).stream ()
28
+ getTag ().getList ("custom_potion_effects " , Tag .TAG_COMPOUND ).stream ()
27
29
.map (CompoundTag .class ::cast )
28
30
.map (this ::createPotionEffectEntry )
29
31
.forEach (getEntries ()::add );
@@ -63,36 +65,36 @@ private void setCustomPotionColor(int color) {
63
65
64
66
private EntryModel createPotionEffectEntry (CompoundTag tag ) {
65
67
if (tag != null ) {
66
- int id = tag .getInt ( "Id " );
67
- int amplifier = tag .getInt ("Amplifier " ); // defaults to 0
68
- int duration = tag .contains ("Duration " , Tag .TAG_INT ) ? tag .getInt ("Duration " ) : 1 ;
69
- boolean ambient = tag .getBoolean ("Ambient " ); // defaults to false
70
- boolean showParticles = !tag .contains ("ShowParticles " , Tag .TAG_BYTE ) || tag .getBoolean ("ShowParticles " );
71
- boolean showIcon = tag .getBoolean ("ShowIcon " );
68
+ String id = tag .getString ( "id " );
69
+ int amplifier = tag .getInt ("amplifier " ); // defaults to 0
70
+ int duration = tag .contains ("duration " , Tag .TAG_INT ) ? tag .getInt ("duration " ) : 1 ;
71
+ boolean ambient = tag .getBoolean ("ambient " ); // defaults to false
72
+ boolean showParticles = !tag .contains ("show_particles " , Tag .TAG_BYTE ) || tag .getBoolean ("show_particles " );
73
+ boolean showIcon = tag .getBoolean ("show_icon " );
72
74
return new PotionEffectEntryModel (this , id , amplifier , duration , ambient , showParticles , showIcon , this ::addPotionEffect );
73
75
}
74
- return new PotionEffectEntryModel (this , 1 , 0 , 1 , false , true , true , this ::addPotionEffect );
76
+ return new PotionEffectEntryModel (this , BuiltInRegistries . MOB_EFFECT . getKey ( MobEffects . MOVEMENT_SPEED ). toString () , 0 , 1 , false , true , true , this ::addPotionEffect );
75
77
}
76
78
77
79
@ Override
78
80
public void apply () {
79
81
potionEffectList = new ListTag ();
80
82
super .apply ();
81
83
if (!potionEffectList .isEmpty ()) {
82
- getOrCreateTag ().put ("CustomPotionEffects " , potionEffectList );
83
- } else if (getOrCreateTag ().contains ("CustomPotionEffects " )) {
84
- getOrCreateTag ().remove ("CustomPotionEffects " );
84
+ getOrCreateTag ().put ("custom_potion_effects " , potionEffectList );
85
+ } else if (getOrCreateTag ().contains ("custom_potion_effects " )) {
86
+ getOrCreateTag ().remove ("custom_potion_effects " );
85
87
}
86
88
}
87
89
88
- private void addPotionEffect (int id , int amplifier , int duration , boolean ambient , boolean showParticles , boolean showIcon ) {
90
+ private void addPotionEffect (String id , int amplifier , int duration , boolean ambient , boolean showParticles , boolean showIcon ) {
89
91
CompoundTag tag = new CompoundTag ();
90
- tag .putInt ( "Id " , id );
91
- tag .putInt ("Amplifier " , amplifier );
92
- tag .putInt ("Duration " , duration );
93
- tag .putBoolean ("Ambient " , ambient );
94
- tag .putBoolean ("ShowParticles " , showParticles );
95
- tag .putBoolean ("ShowIcon " , showIcon );
92
+ tag .putString ( "id " , id );
93
+ tag .putInt ("amplifier " , amplifier );
94
+ tag .putInt ("duration " , duration );
95
+ tag .putBoolean ("ambient " , ambient );
96
+ tag .putBoolean ("show_particles " , showParticles );
97
+ tag .putBoolean ("show_icon " , showIcon );
96
98
potionEffectList .add (tag );
97
99
}
98
100
}
0 commit comments