@@ -121,13 +121,9 @@ public Sound getSound(LivingEntity entity, int height, ItemStack item, boolean b
121
121
}
122
122
123
123
private boolean bigOrSpeedy ;
124
- @ SuppressWarnings ("NotNullFieldNotInitialized" )
125
124
private SoundType soundType ;
126
- @ SuppressWarnings ("NotNullFieldNotInitialized" )
127
125
private Expression <Number > height ;
128
- @ SuppressWarnings ("NotNullFieldNotInitialized" )
129
126
private Expression <LivingEntity > entities ;
130
- @ SuppressWarnings ("NotNullFieldNotInitialized" )
131
127
private Expression <ItemType > item ;
132
128
133
129
@ Override
@@ -145,12 +141,10 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
145
141
146
142
@ Override
147
143
protected String @ Nullable [] get (Event event ) {
148
- //noinspection ConstantValue
149
- int height = this .height == null ? -1 : this .height .getOptionalSingle (event ).orElse (-1 ).intValue ();
144
+ int height = this .height == null ? -1 : this .height .getOptionalSingle (event ).orElse (-1 ).intValue ();
150
145
151
146
ItemStack defaultItem = new ItemStack (soundType == SoundType .EAT ? Material .COOKED_BEEF : Material .POTION );
152
- //noinspection ConstantValue
153
- ItemStack item = this .item == null ? defaultItem : this .item .getOptionalSingle (event ).map (ItemType ::getRandom ).orElse (defaultItem );
147
+ ItemStack item = this .item == null ? defaultItem : this .item .getOptionalSingle (event ).map (ItemType ::getRandom ).orElse (defaultItem );
154
148
155
149
return entities .stream (event )
156
150
.map (entity -> soundType .getSound (entity , height , item , bigOrSpeedy ))
@@ -172,29 +166,27 @@ public Class<? extends String> getReturnType() {
172
166
173
167
@ Override
174
168
public String toString (@ Nullable Event event , boolean debug ) {
175
- String soundDescription = "unknown" ;
169
+ String sound = "unknown" ;
176
170
switch (soundType ) {
177
- case DAMAGE , DEATH , SWIM , AMBIENT -> soundDescription = soundType .name ().toLowerCase ();
171
+ case DAMAGE , DEATH , SWIM , AMBIENT -> sound = soundType .name ().toLowerCase ();
178
172
case FALL -> {
179
- //noinspection ConstantValue
180
- if (this .height == null ) {
181
- soundDescription = bigOrSpeedy ? "high fall damage" : "normal fall damage" ;
173
+ if (this .height == null ) {
174
+ sound = bigOrSpeedy ? "high fall damage" : "normal fall damage" ;
182
175
} else {
183
- soundDescription = "fall damage from a height of " + this .height .toString (event , debug );
176
+ sound = "fall damage from a height of " + this .height .toString (event , debug );
184
177
}
185
178
}
186
- case SPLASH -> soundDescription = bigOrSpeedy ? "speedy splash" : "splash" ;
179
+ case SPLASH -> sound = bigOrSpeedy ? "speedy splash" : "splash" ;
187
180
case EAT , DRINK -> {
188
181
String action = soundType == SoundType .EAT ? "eating" : "drinking" ;
189
- //noinspection ConstantValue
190
- if (this .item == null ) {
191
- soundDescription = action ;
182
+ if (this .item == null ) {
183
+ sound = action ;
192
184
} else {
193
- soundDescription = action + " " + this .item .toString (event , debug );
185
+ sound = action + " " + this .item .toString (event , debug );
194
186
}
195
187
}
196
188
}
197
- return soundDescription + " sound of " + entities .toString (event , debug );
189
+ return sound + " sound of " + entities .toString (event , debug );
198
190
}
199
191
200
192
}
0 commit comments