potion parsing error catching

This commit is contained in:
Flemmli97 2021-06-13 18:39:37 +02:00
parent 98cbaed769
commit ab567278ee
2 changed files with 4 additions and 5 deletions

View File

@ -21,7 +21,6 @@ import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.registry.Registry;
import java.util.Collection;
import java.util.Collections;
@ -111,14 +110,15 @@ public class PotionEditScreenHandler extends ServerOnlyScreenHandler<Claim> {
String[] potion = s.split(";");
int amp = 1;
StatusEffect effect = CrossPlatformStuff.effectFromString(potion[0]);
if(effect == StatusEffects.LUCK && !potion[0].equals("minecraft:luck")) {
if (effect == null || (effect == StatusEffects.LUCK && !potion[0].equals("minecraft:luck"))) {
ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f);
return;
}
if(potion.length > 1) {
if (potion.length > 1) {
try {
amp = Integer.parseInt(potion[1]);
} catch (NumberFormatException e) {}
} catch (NumberFormatException e) {
}
}
this.claim.addPotion(effect, amp);
player.closeHandledScreen();

View File

@ -41,7 +41,6 @@ public class StringResultScreenHandler extends AnvilScreenHandler {
this.output.setStack(0, out);
this.cons = cons;
this.ret = ret;
}
public static void createNewStringResult(PlayerEntity player, Consumer<String> cons, Runnable ret) {