diff --git a/src/main/java/net/serenas/shitmod/fragileHeartCharm.java b/src/main/java/net/serenas/shitmod/fragileHeartCharm.java index b098627..e95dcbf 100644 --- a/src/main/java/net/serenas/shitmod/fragileHeartCharm.java +++ b/src/main/java/net/serenas/shitmod/fragileHeartCharm.java @@ -28,6 +28,7 @@ public class fragileHeartCharm extends Item { if (availableSlots > 0) { availableSlots--; + Playerentity.sendMessage(new LiteralText("You have " + availableSlots + "charm notches left."), false); Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 20*1000000, 2)); Playerentity.getMainHandStack().damage(50,Playerentity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); try { diff --git a/src/main/java/net/serenas/shitmod/fragileStrengthCharm.java b/src/main/java/net/serenas/shitmod/fragileStrengthCharm.java index 9c50941..d7e58f7 100644 --- a/src/main/java/net/serenas/shitmod/fragileStrengthCharm.java +++ b/src/main/java/net/serenas/shitmod/fragileStrengthCharm.java @@ -1,11 +1,14 @@ package net.serenas.shitmod; +import java.util.concurrent.TimeUnit; + import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.text.LiteralText; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -16,11 +19,28 @@ public class fragileStrengthCharm extends Item{ public fragileStrengthCharm(Settings settings) { super(settings); } + + public int availableSlots = 1; + @Override - public TypedActionResult use(World world, PlayerEntity Playerentity, Hand Hand) { - Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 20*1000000, 2)); - Playerentity.getMainHandStack().damage(50,Playerentity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); - return new TypedActionResult(ActionResult.SUCCESS, Playerentity.getStackInHand(Hand)); + public TypedActionResult use(World world, PlayerEntity PlayerEntity, Hand Hand) { + if (availableSlots > 0) { + availableSlots--; + PlayerEntity.sendMessage(new LiteralText("You have " + availableSlots + "charm notches left."), false); + PlayerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 20*1000000, 2)); + PlayerEntity.getMainHandStack().damage(50,PlayerEntity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + availableSlots++; + + } else if (availableSlots < 1) { + PlayerEntity.sendMessage(new LiteralText("You don't have enough charm notches to do that!"), true); + } + + return new TypedActionResult(ActionResult.SUCCESS, PlayerEntity.getStackInHand(Hand)); } } diff --git a/src/main/java/net/serenas/shitmod/kingsoul.java b/src/main/java/net/serenas/shitmod/kingsoul.java index 9e4824b..604a64f 100644 --- a/src/main/java/net/serenas/shitmod/kingsoul.java +++ b/src/main/java/net/serenas/shitmod/kingsoul.java @@ -25,6 +25,7 @@ public class kingsoul extends Item { public TypedActionResult use(World world, PlayerEntity PlayerEntity, Hand hand) { if (availableSlots > 0) { availableSlots--; + PlayerEntity.sendMessage(new LiteralText("You have " + availableSlots + "charm notches left."), false); PlayerEntity.getHungerManager().add(1, 1); PlayerEntity.getMainHandStack().damage(1,PlayerEntity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); try { diff --git a/src/main/java/net/serenas/shitmod/stalwartShell.java b/src/main/java/net/serenas/shitmod/stalwartShell.java index 1913ed7..8e49415 100644 --- a/src/main/java/net/serenas/shitmod/stalwartShell.java +++ b/src/main/java/net/serenas/shitmod/stalwartShell.java @@ -27,6 +27,7 @@ public class stalwartShell extends Item{ public TypedActionResult use(World world, PlayerEntity PlayerEntity, Hand hand) { if (availableSlots > 0) { availableSlots--; + PlayerEntity.sendMessage(new LiteralText("You have " + availableSlots + "charm notches left."), false); PlayerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 20, 5)); PlayerEntity.getMainHandStack().damage(1,PlayerEntity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND)); try { diff --git a/src/main/java/net/serenas/shitmod/unbreakableHeartCharm.java b/src/main/java/net/serenas/shitmod/unbreakableHeartCharm.java index f916096..680a498 100644 --- a/src/main/java/net/serenas/shitmod/unbreakableHeartCharm.java +++ b/src/main/java/net/serenas/shitmod/unbreakableHeartCharm.java @@ -1,10 +1,13 @@ package net.serenas.shitmod; +import java.util.concurrent.TimeUnit; + import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.text.LiteralText; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -15,9 +18,26 @@ public class unbreakableHeartCharm extends Item { public unbreakableHeartCharm(Settings settings) { super(settings); } + + public int availableSlots = 1; + @Override - public TypedActionResult use(World world, PlayerEntity Playerentity, Hand Hand) { - Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 20*1000000, 4)); - return new TypedActionResult(ActionResult.SUCCESS, Playerentity.getStackInHand(Hand)); + public TypedActionResult use(World world, PlayerEntity PlayerEntity, Hand Hand) { + + if (availableSlots > 0) { + availableSlots--; + PlayerEntity.sendMessage(new LiteralText("You have " + availableSlots + "charm notches left."), false); + PlayerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 20*1000000, 4)); + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + availableSlots++; + + } else if (availableSlots < 1) { + PlayerEntity.sendMessage(new LiteralText("You don't have enough charm notches to do that!"), true); + } + return new TypedActionResult(ActionResult.SUCCESS, PlayerEntity.getStackInHand(Hand)); } } \ No newline at end of file diff --git a/src/main/java/net/serenas/shitmod/unbreakableStrengthCharm.java b/src/main/java/net/serenas/shitmod/unbreakableStrengthCharm.java index a4df55f..2dafb34 100644 --- a/src/main/java/net/serenas/shitmod/unbreakableStrengthCharm.java +++ b/src/main/java/net/serenas/shitmod/unbreakableStrengthCharm.java @@ -1,10 +1,13 @@ package net.serenas.shitmod; +import java.util.concurrent.TimeUnit; + import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.text.LiteralText; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -15,9 +18,27 @@ public class unbreakableStrengthCharm extends Item { public unbreakableStrengthCharm(Settings settings) { super(settings); } + + public int availableSlots = 1; + @Override - public TypedActionResult use(World world, PlayerEntity Playerentity, Hand Hand) { - Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 20*1000000, 3)); - return new TypedActionResult(ActionResult.SUCCESS, Playerentity.getStackInHand(Hand)); + public TypedActionResult use(World world, PlayerEntity PlayerEntity, Hand Hand) { + + if (availableSlots > 0) { + availableSlots--; + PlayerEntity.sendMessage(new LiteralText("You have " + availableSlots + "charm notches left."), false); + PlayerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 20*1000000, 3)); + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + availableSlots++; + + } else if (availableSlots < 1) { + PlayerEntity.sendMessage(new LiteralText("You don't have enough charm notches to do that!"), true); + } + + return new TypedActionResult(ActionResult.SUCCESS, PlayerEntity.getStackInHand(Hand)); } }