Boost Wand particles
This commit is contained in:
parent
90ef92b453
commit
760eddcaeb
@ -1,6 +1,10 @@
|
||||
package com.jenny.magic.items.wands;
|
||||
|
||||
import com.jenny.magic.config.ConfigServer;
|
||||
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.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
@ -37,6 +41,9 @@ public class WandBoost extends BaseWand {
|
||||
|
||||
@Override
|
||||
public void releaseUsing(@NotNull ItemStack itemStack, @NotNull Level level, @NotNull LivingEntity livingEntity, int pTimeLeft) {
|
||||
if (!level.isClientSide) {
|
||||
networking.sendToClose(new EffectS2C(effects.EFFECT.WAND_BOOST, livingEntity.position().add(0, 1, 0)), (ServerLevel) level);
|
||||
}
|
||||
if (!ConfigServer.C_PREVENT_BREAKING.get() || itemStack.getMaxDamage() - itemStack.getDamageValue() > 1) {
|
||||
livingEntity.addDeltaMovement(directionPlayer(livingEntity).scale(getBoostPower(pTimeLeft)));
|
||||
itemStack.hurtAndBreak(1, livingEntity, (player) -> player.broadcastBreakEvent(player.getUsedItemHand()));
|
||||
|
@ -16,6 +16,7 @@ public class effects {
|
||||
case SCROLL_TELEPORT_TARGET -> teleportTarget(origin);
|
||||
case SCROLL_BONEMEAL -> bonemeal(origin);
|
||||
case SCROLL_HEALTH -> health(origin);
|
||||
case WAND_BOOST -> boost(origin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +61,14 @@ public class effects {
|
||||
}
|
||||
}
|
||||
|
||||
private static void boost(Vec3 v) {
|
||||
Vec3 pos;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
pos = randPos(0.5f).add(v);
|
||||
level().addParticle(ParticleTypes.POOF, pos.x, pos.y, pos.z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vec3 randPos(float maxDist) {
|
||||
return new Vec3(
|
||||
rng().nextFloat() * 2 - 1,
|
||||
@ -100,6 +109,7 @@ public class effects {
|
||||
SCROLL_REPEL,
|
||||
SCROLL_WITHER,
|
||||
SCROLL_BONEMEAL,
|
||||
WAND_VACUUM
|
||||
WAND_VACUUM,
|
||||
WAND_BOOST
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user