start notches

This commit is contained in:
Sunskimmer822 2022-03-04 13:10:53 -08:00
parent 31b21dce7d
commit aee9b4f81c
3 changed files with 47 additions and 8 deletions

View File

@ -3,10 +3,14 @@ package net.serenas.shitmod;
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;
import net.minecraft.world.World;
import java.util.concurrent.TimeUnit;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
@ -17,10 +21,27 @@ public class fragileHeartCharm extends Item {
super(settings);
}
public int availableSlots = 1;
@Override
public TypedActionResult<ItemStack> use(World World, PlayerEntity Playerentity, Hand Hand) {
Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 20*1000000, 3));
Playerentity.getMainHandStack().damage(50,Playerentity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
if (availableSlots > 0) {
availableSlots--;
Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 20*1000000, 2));
Playerentity.getMainHandStack().damage(50,Playerentity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
try {
TimeUnit.SECONDS.sleep(100);
} 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<ItemStack>(ActionResult.SUCCESS, Playerentity.getStackInHand(Hand));
}
}

View File

@ -19,7 +19,7 @@ public class kingsoul extends Item {
}
public int availableSlots = 2;
public int availableSlots = 10;
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity PlayerEntity, Hand hand) {
@ -34,7 +34,7 @@ public class kingsoul extends Item {
}
availableSlots++;
} else if (availableSlots < 0) {
} else if (availableSlots < 1) {
PlayerEntity.sendMessage(new LiteralText("You don't have enough charm notches to do that!"), true);
}

View File

@ -1,12 +1,15 @@
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.TypedActionResult;
import net.minecraft.world.World;
@ -18,11 +21,26 @@ public class stalwartShell extends Item{
super(settings);
}
public int availableSlots = 8;
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity Playerentity, Hand hand) {
Playerentity.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 20, 5));
Playerentity.getMainHandStack().damage(1,Playerentity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
return new TypedActionResult<ItemStack>(ActionResult.SUCCESS, Playerentity.getStackInHand(hand));
public TypedActionResult<ItemStack> use(World world, PlayerEntity PlayerEntity, Hand hand) {
if (availableSlots > 0) {
availableSlots--;
PlayerEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 20, 5));
PlayerEntity.getMainHandStack().damage(1,PlayerEntity,e-> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
try {
TimeUnit.SECONDS.sleep(15);
} 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<ItemStack>(ActionResult.SUCCESS, PlayerEntity.getStackInHand(hand));
}