implement wand durability & repair amulet

This commit is contained in:
Jenny 2025-04-02 13:10:39 +02:00
parent 836934d46d
commit b549ef8df2
Signed by: Jenny
GPG Key ID: 2072A14E40940632
11 changed files with 30 additions and 3 deletions

View File

@ -0,0 +1,25 @@
package com.jenny.magic.items;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public class AmuletRepair extends BaseItem {
public AmuletRepair(@NotNull Properties pProperties) {
super(pProperties.stacksTo(1));
}
@Override
public void inventoryTick(@NotNull ItemStack pStack, @NotNull Level pLevel, @NotNull Entity pEntity, int pSlotId, boolean pIsSelected) {
if (!pLevel.isClientSide && pLevel.getRandom().nextInt(10) == 0 && pEntity instanceof Player pPlayer) {
int rand = pLevel.getRandom().nextInt(0, 9);
ItemStack itemStack = pPlayer.getInventory().items.get(rand);
System.out.println(itemStack.getItem().toString());
if (itemStack.isDamaged()) {
itemStack.setDamageValue(itemStack.getDamageValue() - 1);
}
}
}
}

View File

@ -22,7 +22,9 @@ public abstract class BaseWand extends QualityItem {
BaseWandProjectile projectile = newProjectile(pLevel);
projectile.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), 0.0F, 2.0F);
pLevel.addFreshEntity(projectile);
setDamage(itemstack, getDamage(itemstack) + damageItem(itemstack, 1, pPlayer, (player) -> onItemDestroyed(player)));
itemstack.hurtAndBreak(1, pPlayer, (player) -> {
player.broadcastBreakEvent(pPlayer.getUsedItemHand());
});
return InteractionResultHolder.success(itemstack);
}
@ -34,7 +36,6 @@ public abstract class BaseWand extends QualityItem {
while (pRepairCandidate.getCount() >= 1 && pStack.isDamaged()) {
pRepairCandidate.shrink(1);
pStack.setDamageValue(pStack.getDamageValue() - 20);
System.out.println("test");
}
return true;
} else {

View File

@ -13,7 +13,7 @@ import static com.jenny.magic.Magic.MODID;
public class items {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
public static final RegistryObject<Item> WAND_HURTFUL = ITEMS.register("wand_hurtful", () -> new WandHurtful(new Item.Properties()));
public static final RegistryObject<Item> WAND_VAUUM = ITEMS.register("wand_vacuum", () -> new WandVacuum(new Item.Properties()));
public static final RegistryObject<Item> WAND_VAUUM = ITEMS.register("wand_vacuum", () -> new WandVacuum(new Item.Properties().stacksTo(1)));
public static final RegistryObject<Item> SCROLL_TELEPORT = ITEMS.register("scroll_teleport", () -> new TeleportScrollPersistent(new Item.Properties().stacksTo(1)));
public static final RegistryObject<Item> SCROLL_TELEPORT_BRITTLE = ITEMS.register("scroll_teleport_brittle", () -> new TeleportScrollConsumable(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> SCROLL_TELEPORT_RANDOM = ITEMS.register("scroll_teleport_random", () -> new TeleportScrollRandom(new Item.Properties().stacksTo(1)));
@ -21,6 +21,7 @@ public class items {
public static final RegistryObject<Item> SCROLL_HEALTH = ITEMS.register("scroll_health", () -> new HealthScroll(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> SCROLL_REPEL = ITEMS.register("scroll_repel", () -> new RepelScroll(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> SCROLL_BONEMEAL = ITEMS.register("scroll_bonemeal", () -> new BonemealScroll(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> AMULET_REPAIR = ITEMS.register("amulet_repair", () -> new AmuletRepair(new Item.Properties()));
public static final RegistryObject<Item> DRAGON_HEART = ITEMS.register("dragon_heart", () -> new QualityItem(new Item.Properties()));
public static void register(IEventBus bus) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 B

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B