more amulets & restructuring

This commit is contained in:
Jenny 2025-04-11 02:45:42 +02:00
parent 5352ce4840
commit 8e1edd46bf
Signed by: Jenny
GPG Key ID: 2072A14E40940632
36 changed files with 262 additions and 251 deletions

@ -12,7 +12,6 @@ import static com.jenny.magic.Magic.MODID;
public class blockEntities {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID);
public static void register(IEventBus bus) {
BLOCK_ENTITIES.register(bus);
} public static final RegistryObject<BlockEntityType<AntiSpawnerBE>> ANTI_SPAWNER_BE =
@ -21,4 +20,5 @@ public class blockEntities {
blocks.ANTI_SPAWNER.get()).build(null));
}

@ -1,6 +1,6 @@
package com.jenny.magic.enchantments;
import com.jenny.magic.items.BaseWand;
import com.jenny.magic.items.wands.BaseWand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

@ -1,49 +0,0 @@
package com.jenny.magic.items;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Random;
public class QualityItem extends BaseItem {
public QualityItem(Properties pProperties) {
super(pProperties);
}
@Override
public ItemStack getDefaultInstance() {
return setQuality(new ItemStack(this));
}
protected ItemStack setQuality(@NotNull ItemStack itemStack) {
float quality = (float) new Random(System.nanoTime()).nextInt(0, 21) / 10 + 1;
CompoundTag tag;
if (itemStack.getTag() != null) {
tag = itemStack.getTag();
} else {
tag = new CompoundTag();
}
tag.putFloat("magic_quality", quality);
itemStack.setTag(tag);
return itemStack;
}
protected float getQuality(@NotNull ItemStack itemStack) {
return itemStack.getTag() != null ? itemStack.getTag().getFloat("magic_quality") : 1;
}
@Override
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
MutableComponent toolTip = Component.literal(Float.toString(getQuality(pStack)));
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_RED));
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
}
}

@ -0,0 +1,46 @@
package com.jenny.magic.items.amulets;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class AmuletBase extends com.jenny.magic.items.scrolls.SingleActionScroll {
public AmuletBase(Properties pProperties) {
super(pProperties.stacksTo(1));
}
public static boolean isEnabled(CompoundTag tag) {
if (tag != null && tag.contains("amulet_enabled") && tag.getString("amulet_enabled").equals("false")) {
return false;
} else {
return true;
}
}
public static CompoundTag setEnabled(CompoundTag tag, boolean b) {
tag.putString("amulet_enabled", Boolean.toString(b));
return tag;
}
protected void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level) {
CompoundTag tag = itemStack.getTag();
if (tag == null) {
tag = new CompoundTag();
}
itemStack.setTag(setEnabled(tag, !isEnabled(tag)));
}
@Override
public Component getName(@NotNull ItemStack pStack) {
if (!isEnabled(pStack.getTag())) {
return Component.translatable(this.getDescriptionId(pStack)).withStyle(ChatFormatting.GRAY);
} else {
return Component.translatable(this.getDescriptionId(pStack));
}
}
}

@ -0,0 +1,30 @@
package com.jenny.magic.items.amulets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public class AmuletBonemeal extends AmuletBase {
protected static int chance = 10;
public AmuletBonemeal(Properties pProperties) {
super(pProperties);
}
protected static BlockPos getLocation(Player player) {
return player.blockPosition().offset(new Vec3i(player.level().getRandom().nextIntBetweenInclusive(-5, 5), 0, player.level().getRandom().nextIntBetweenInclusive(-5, 5)));
}
@Override
public void inventoryTick(@NotNull ItemStack pStack, @NotNull Level pLevel, @NotNull Entity pEntity, int pSlotId, boolean pIsSelected) {
if (!pLevel.isClientSide && isEnabled(pStack.getTag()) && pLevel.getRandom().nextInt(chance) == 0 && pEntity instanceof Player pPlayer) {
BoneMealItem.applyBonemeal(new ItemStack(Items.BONE_MEAL), pLevel, getLocation(pPlayer), pPlayer);
}
}
}

@ -1,6 +1,5 @@
package com.jenny.magic.items;
package com.jenny.magic.items.amulets;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
@ -11,25 +10,26 @@ import org.jetbrains.annotations.NotNull;
import java.util.Optional;
public class AmuletEffect extends BaseItem {
public class AmuletEffect extends AmuletBase {
private MobEffect effect;
private int delay, duration, amplifier;
private int delay, duration, amplifier, tick;
public AmuletEffect(Properties pProperties, MobEffect effect, int delay, int duration, int amplifier) {
super(pProperties.stacksTo(1));
super(pProperties);
this.effect = effect;
this.delay = delay;
this.duration = duration;
this.amplifier = amplifier;
this.tick = 0;
}
@Override
public void inventoryTick(@NotNull ItemStack pStack, @NotNull Level pLevel, @NotNull Entity pEntity, int pSlotId, boolean pIsSelected) {
if (!pLevel.isClientSide && ((ServerLevel) pLevel).getServer().getTickCount() % this.delay == 0) {
if (!pLevel.isClientSide && isEnabled(pStack.getTag()) && tick % delay == 0) {
if (pEntity instanceof LivingEntity p) {
p.addEffect(new MobEffectInstance(effect, this.duration, this.amplifier, true, true, true, null, Optional.empty()));
System.out.println("test1878567");
p.addEffect(new MobEffectInstance(effect, duration, amplifier, true, true, true, null, Optional.empty()));
}
}
tick++;
}
}

@ -0,0 +1,35 @@
package com.jenny.magic.items.amulets;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public class AmuletImmunity extends AmuletBase {
private static int delay = 200;
private int count = 0;
public AmuletImmunity(Item.Properties pProperties) {
super(pProperties);
}
@Override
public void inventoryTick(@NotNull ItemStack pStack, @NotNull Level pLevel, @NotNull Entity pEntity, int pSlotId, boolean pIsSelected) {
if (!pLevel.isClientSide) {
count = count < 200 ? count + 1 : count;
if (count == 200 && pEntity instanceof LivingEntity entity) {
for (MobEffectInstance effect : entity.getActiveEffects()) {
if (effect.getEffect().getCategory().equals(MobEffectCategory.HARMFUL)) {
entity.removeEffect(effect.getEffect());
count = 1;
break;
}
}
}
}
}
}

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.amulets;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
@ -6,17 +6,16 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public class AmuletRepair extends BaseItem {
public class AmuletRepair extends AmuletBase {
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) {
if (!pLevel.isClientSide && isEnabled(pStack.getTag()) && 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);
}

@ -0,0 +1,31 @@
package com.jenny.magic.items.amulets;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.NotNull;
public class AmuletSuction extends AmuletBase {
private int delay, tick;
private float range, power;
public AmuletSuction(Properties pProperties, int delay, float range, float power) {
super(pProperties);
this.delay = delay;
this.range = range;
this.power = power;
this.tick = 0;
}
@Override
public void inventoryTick(@NotNull ItemStack pStack, @NotNull Level pLevel, @NotNull Entity pEntity, int pSlotId, boolean pIsSelected) {
if (this.tick % this.delay == 0 && isEnabled(pStack.getTag())) {
for (Entity drop : pLevel.getEntitiesOfClass(ItemEntity.class, new AABB(pEntity.position(), pEntity.position()).inflate(range), (itemEntity) -> true)) {
drop.addDeltaMovement(pEntity.position().subtract(drop.position()).normalize().scale(power));
}
}
tick++;
}
}

@ -1,5 +1,9 @@
package com.jenny.magic.items;
import com.jenny.magic.items.amulets.*;
import com.jenny.magic.items.scrolls.*;
import com.jenny.magic.items.wands.WandHurtful;
import com.jenny.magic.items.wands.WandVacuum;
import net.minecraft.ChatFormatting;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.Item;
@ -15,19 +19,21 @@ 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().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 = ITEMS.register("scroll_teleport", () -> new ScrollTeleportPersistent(new Item.Properties().stacksTo(1)));
public static final RegistryObject<Item> SCROLL_TELEPORT_BRITTLE = ITEMS.register("scroll_teleport_brittle", () -> new ScrollTeleportConsumable(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)));
public static final RegistryObject<Item> SCROLL_TELEPORT_BIOME_PLAINS = ITEMS.register("scroll_teleport_biome_plains", () -> new TeleportScrollBiome(new Item.Properties().stacksTo(16), Biomes.PLAINS, ChatFormatting.GREEN));
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> SCROLL_TELEPORT_BIOME_PLAINS = ITEMS.register("scroll_teleport_biome_plains", () -> new ScrollTeleportBiome(new Item.Properties().stacksTo(16), Biomes.PLAINS, ChatFormatting.GREEN));
public static final RegistryObject<Item> SCROLL_HEALTH = ITEMS.register("scroll_health", () -> new ScrollHealth(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> SCROLL_REPEL = ITEMS.register("scroll_repel", () -> new ScrollRepel(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> SCROLL_BONEMEAL = ITEMS.register("scroll_bonemeal", () -> new ScrollBonemeal(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> AMULET_BREATHING = ITEMS.register("amulet_breathing", () -> new AmuletEffect(new Item.Properties(), MobEffects.WATER_BREATHING, 100, 200, 1));
public static final RegistryObject<Item> AMULET_BREATHING = ITEMS.register("amulet_breathing", () -> new AmuletEffect(new Item.Properties(), MobEffects.WATER_BREATHING, 200, 500, 1));
public static final RegistryObject<Item> AMULET_NIGHTVISION = ITEMS.register("amulet_nightvision", () -> new AmuletEffect(new Item.Properties(), MobEffects.NIGHT_VISION, 200, 500, 1));
public static final RegistryObject<Item> DRAGON_HEART = ITEMS.register("dragon_heart", () -> new QualityItem(new Item.Properties()));
public static final RegistryObject<Item> AMULET_SATURATION = ITEMS.register("amulet_saturation", () -> new AmuletEffect(new Item.Properties(), MobEffects.SATURATION, 200, 500, 1));
public static final RegistryObject<Item> AMULET_SUCTION = ITEMS.register("amulet_suction", () -> new AmuletSuction(new Item.Properties(), 3, 4, 0.5f));
public static final RegistryObject<Item> AMULET_BONEMEAL = ITEMS.register("amulet_bonemeal", () -> new AmuletBonemeal(new Item.Properties()));
public static final RegistryObject<Item> AMULET_GOLD = ITEMS.register("amulet_gold", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> AMULET_IMMUNITY = ITEMS.register("amulet_immunity", () -> new AmuletImmunity(new Item.Properties()));
public static void register(IEventBus bus) {
ITEMS.register(bus);
}

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.networking.networking;
import com.jenny.magic.networking.packets.EffectS2C;
@ -6,19 +6,20 @@ import com.jenny.magic.particles.effects;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class BonemealScroll extends SingleActionScroll {
public BonemealScroll(Properties pProperties) {
public class ScrollBonemeal extends SingleActionScroll {
public ScrollBonemeal(Item.Properties pProperties) {
super(pProperties);
}
@Override
void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, @NotNull Level level) {
protected void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, @NotNull Level level) {
if (!level.isClientSide) {
boolean flag = false;
for (int x = -5; x <= 5; x++) {

@ -1,22 +1,23 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.networking.networking;
import com.jenny.magic.networking.packets.EffectS2C;
import com.jenny.magic.particles.effects;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class HealthScroll extends SingleActionScroll {
public HealthScroll(Properties pProperties) {
public class ScrollHealth extends SingleActionScroll {
public ScrollHealth(Item.Properties pProperties) {
super(pProperties);
}
@Override
void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level) {
protected void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level) {
if (!level.isClientSide) {
if (player.getMaxHealth() != player.getHealth()) {
player.heal(5);

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.networking.networking;
import com.jenny.magic.networking.packets.EffectS2C;
@ -7,21 +7,25 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class RepelScroll extends SingleActionScroll {
public RepelScroll(Properties pProperties) {
public class ScrollRepel extends SingleActionScroll {
public ScrollRepel(Item.Properties pProperties) {
super(pProperties);
}
@Override
void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, @NotNull Level level) {
protected void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, @NotNull Level level) {
if (!level.isClientSide) {
boolean flag = false;
for (Entity e : level.getEntitiesOfClass(LivingEntity.class, player.getBoundingBox().inflate(5, 2, 5))) {
if (e.is(player)) {
continue;
}
e.addDeltaMovement(e.position().subtract(player.position()).normalize().scale(5 * e.position().subtract(player.position()).length()).multiply(1, 0, 1));
flag = true;
networking.sendToPlayer(new EffectS2C(effects.EFFECT.SCROLL_REPEL, e.position().add(0, e.getEyeHeight(), 0)), (ServerPlayer) player);

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.config.ConfigServer;
import com.jenny.magic.networking.networking;
@ -25,8 +25,8 @@ import java.util.List;
import static com.jenny.magic.Magic.MODID;
public class TeleportScroll extends BaseItem {
public TeleportScroll(Properties pProperties) {
public class ScrollTeleport extends ScrollTeleportRandom {
public ScrollTeleport(Properties pProperties) {
super(pProperties);
}

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.networking.networking;
import com.jenny.magic.networking.packets.EffectS2C;
@ -28,11 +28,11 @@ import java.util.List;
import static com.jenny.magic.Magic.MODID;
public class TeleportScrollBiome extends BaseItem {
public class ScrollTeleportBiome extends ScrollTeleportRandom {
private final ResourceKey<Biome> biome;
private final ChatFormatting color;
public TeleportScrollBiome(Properties pProperties, ResourceKey<Biome> biome, ChatFormatting color) {
public ScrollTeleportBiome(Properties pProperties, ResourceKey<Biome> biome, ChatFormatting color) {
super(pProperties);
this.biome = biome;
this.color = color;

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
@ -6,8 +6,8 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class TeleportScrollConsumable extends TeleportScroll {
public TeleportScrollConsumable(Properties pProperties) {
public class ScrollTeleportConsumable extends ScrollTeleport {
public ScrollTeleportConsumable(Properties pProperties) {
super(pProperties);
}

@ -1,13 +1,13 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class TeleportScrollPersistent extends TeleportScroll {
public class ScrollTeleportPersistent extends ScrollTeleport {
public TeleportScrollPersistent(Properties pProperties) {
public ScrollTeleportPersistent(Properties pProperties) {
super(pProperties);
}

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.networking.networking;
import com.jenny.magic.networking.packets.ManaAmountS2C;
@ -20,9 +20,9 @@ import java.util.List;
import static com.jenny.magic.Magic.MODID;
abstract class BaseItem extends Item {
public abstract class ScrollTeleportRandom extends Item {
public BaseItem(Properties pProperties) {
public ScrollTeleportRandom(Properties pProperties) {
super(pProperties);
}
@ -52,7 +52,7 @@ abstract class BaseItem extends Item {
}
}
enum ParticleDirection {
public enum ParticleDirection {
INWARD,
OUTWARD
}

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
@ -10,7 +10,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
abstract class SingleActionScroll extends BaseItem {
public abstract class SingleActionScroll extends ScrollTeleportRandom {
public SingleActionScroll(Properties pProperties) {
super(pProperties);
}
@ -27,5 +27,5 @@ abstract class SingleActionScroll extends BaseItem {
return InteractionResult.SUCCESS;
}
abstract void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level);
protected abstract void use(Vec3 pos, Player player, @NotNull ItemStack itemStack, Level level);
}

@ -1,4 +1,4 @@
package com.jenny.magic.items;
package com.jenny.magic.items.scrolls;
import com.jenny.magic.config.ConfigServer;
import com.jenny.magic.networking.networking;
@ -30,7 +30,7 @@ import java.util.List;
import static com.jenny.magic.Magic.MODID;
public class TeleportScrollRandom extends BaseItem {
public class TeleportScrollRandom extends ScrollTeleportRandom {
public TeleportScrollRandom(Properties pProperties) {
super(pProperties);
}

@ -1,38 +1,33 @@
package com.jenny.magic.items;
package com.jenny.magic.items.wands;
import com.jenny.magic.entities.BaseWandProjectile;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public abstract class BaseWand extends QualityItem {
public BaseWand(Properties properties) {
public abstract class BaseWand extends Item {
public BaseWand(Item.Properties properties) {
super(properties.stacksTo(1).durability(100));
}
private static void onItemDestroyed(Player player) {
}
@Override
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level pLevel, Player pPlayer, @NotNull InteractionHand pUsedHand) {
ItemStack itemstack = pPlayer.getItemInHand(pUsedHand);
BaseWandProjectile projectile = newProjectile(pLevel);
projectile.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), 0.0F, 2.0F);
pLevel.addFreshEntity(projectile);
itemstack.hurtAndBreak(1, pPlayer, (player) -> {
player.broadcastBreakEvent(pPlayer.getUsedItemHand());
});
itemstack.hurtAndBreak(1, pPlayer, (player) -> player.broadcastBreakEvent(pPlayer.getUsedItemHand()));
return InteractionResultHolder.success(itemstack);
}
;
@Override
public boolean isValidRepairItem(@NotNull ItemStack pStack, @NotNull ItemStack pRepairCandidate) {
if (pRepairCandidate.getItem().getDescriptionId().equals(items.DRAGON_HEART.get().getDescriptionId())) {
if (pRepairCandidate.getItem().getDescriptionId().equals(Items.DIAMOND.getDescriptionId())) {
while (pRepairCandidate.getCount() >= 1 && pStack.isDamaged()) {
pRepairCandidate.shrink(1);
pStack.setDamageValue(pStack.getDamageValue() - 20);

@ -1,11 +1,12 @@
package com.jenny.magic.items;
package com.jenny.magic.items.wands;
import com.jenny.magic.entities.BaseWandProjectile;
import com.jenny.magic.entities.HurtfulProjectile;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
public class WandHurtful extends BaseWand {
public WandHurtful(Properties p_41383_) {
public WandHurtful(Item.Properties p_41383_) {
super(p_41383_);
}

@ -1,5 +1,6 @@
package com.jenny.magic.items;
package com.jenny.magic.items.wands;
import com.jenny.magic.items.scrolls.ScrollTeleportRandom;
import com.jenny.magic.networking.networking;
import com.jenny.magic.networking.packets.EffectS2C;
import com.jenny.magic.particles.effects;
@ -16,7 +17,7 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class WandVacuum extends BaseItem {
public class WandVacuum extends ScrollTeleportRandom {
public WandVacuum(Properties pProperties) {
super(pProperties);
}

@ -1,61 +0,0 @@
package com.jenny.magic.mixins;
import com.jenny.magic.mana.ManaClient;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Gui.class)
public class ExperienceToMana {
@Shadow
protected int screenHeight;
@Unique
private float experienceProgress;
@Unique
private int experienceLevel;
@Unique
private ResourceLocation guiIconsLocation = new ResourceLocation("textures/gui/icons_mana.png");
@Unique
private Gui self() {
return (Gui) (Object) this;
}
@Unique
private boolean manaMode() {
return System.currentTimeMillis() - ManaClient.lastUse < 1000;
}
/**
* @author xJenny69
* @reason display mana instead of xp bar
*/
@Inject(method = "renderExperienceBar", at = @At("HEAD"))
public void renderExperienceBarHead(GuiGraphics pGuiGraphics, int pX, CallbackInfo ci) {
if (manaMode()) {
experienceLevel = Minecraft.getInstance().player.experienceLevel;
experienceProgress = Minecraft.getInstance().player.experienceProgress;
Minecraft.getInstance().player.experienceLevel = ManaClient.mana;
Minecraft.getInstance().player.experienceProgress = (float) ManaClient.mana / 100;
}
}
@Inject(method = "renderExperienceBar", at = @At("TAIL"))
public void renderExperienceBarTail(GuiGraphics pGuiGraphics, int pX, CallbackInfo ci) {
if (manaMode()) {
int l = this.screenHeight - 32 + 3;
pGuiGraphics.blit(guiIconsLocation, pX, l, 0, 64, 182, 5);
Minecraft.getInstance().player.experienceLevel = experienceLevel;
Minecraft.getInstance().player.experienceProgress = experienceProgress;
}
}
}

@ -0,0 +1,20 @@
package com.jenny.magic.mixins;
import com.jenny.magic.items.items;
import com.jenny.magic.util.util;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(net.minecraft.world.entity.monster.piglin.PiglinAi.class)
public class PiglinAi {
@Inject(method = "isWearingGold", at = @At("RETURN"), cancellable = true)
private static void isWearingGold(LivingEntity pLivingEntity, CallbackInfoReturnable<Boolean> cir) {
if (pLivingEntity instanceof Player player && util.hasItem(player, items.AMULET_GOLD.get())) {
cir.setReturnValue(true);
}
}
}

@ -1,63 +0,0 @@
package com.jenny.magic.mixins;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.ShapelessRecipe;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(ShapelessRecipe.class)
public class ShapelessRecipeMixin {
@Final
@Shadow
ItemStack result;
@Final
@Shadow
NonNullList<Ingredient> ingredients;
/**
* @author xJenny69
* @reason allow "magic_quality" tag to be passed on
*/
@Overwrite
public ItemStack assemble(CraftingContainer pContainer, RegistryAccess pRegistryAccess) {
for (Ingredient ingredient : ingredients) {
for (ItemStack itemStack : ingredient.getItems()) {
if (itemStack.getTag() != null && itemStack.getTag().contains("magic_quality")) {
CompoundTag tag = result.getTag();
tag.putFloat("magic_quality", itemStack.getTag().getFloat("magic_quality"));
result.setTag(tag);
return result.copy();
}
}
}
return result.copy();
}
/**
* @author
* @reason
*/
@Overwrite
public ItemStack getResultItem(RegistryAccess pRegistryAccess) {
for (Ingredient ingredient : ingredients) {
for (ItemStack itemStack : ingredient.getItems()) {
if (itemStack.getTag() != null && itemStack.getTag().contains("magic_quality")) {
CompoundTag tag = result.getTag();
tag.putFloat("magic_quality", itemStack.getTag().getFloat("magic_quality"));
result.setTag(tag);
return result.copy();
}
}
}
return result.copy();
}
}

@ -0,0 +1,16 @@
package com.jenny.magic.util;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
public class util {
public static boolean hasItem(Player player, Item item) {
for (ItemStack itemStack : player.getInventory().items) {
if (itemStack.getItem().equals(item)) {
return true;
}
}
return false;
}
}

Binary file not shown.

After

(image error) Size: 300 B

Binary file not shown.

After

(image error) Size: 278 B

Binary file not shown.

After

(image error) Size: 283 B

Binary file not shown.

After

(image error) Size: 272 B

Binary file not shown.

After

(image error) Size: 267 B

Binary file not shown.

Before

(image error) Size: 243 B

After

(image error) Size: 267 B

Binary file not shown.

After

(image error) Size: 289 B

Binary file not shown.

After

(image error) Size: 273 B

@ -2,14 +2,12 @@
"required": true,
"minVersion": "0.8",
"package": "com.jenny.magic.mixins",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_17",
"refmap": "magic.refmap.json",
"mixins": [
"ShapelessRecipeMixin"
],
"client": [
"ExperienceToMana"
"PiglinAi"
],
"client": [],
"injectors": {
"defaultRequire": 1
}