【问题标题】:Explosion Enchantment Fabric Minecraft Modding爆炸附魔织物 Minecraft 改装
【发布时间】:2021-07-17 05:06:38
【问题描述】:

试图制造一个爆炸结界,让我可以在暴徒命中时触发小爆炸。我不希望爆炸造成破坏,但我希望它造成伤害。


import net.minecraft.block.TntBlock;
import net.minecraft.client.util.math.Vector3d;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.TntEntity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;

public class ExplosiveAspectEnchantment extends Enchantment {

    protected ExplosiveAspectEnchantment(Rarity weight, EnchantmentTarget target, EquipmentSlot[] equipmentSlots) {
        super(weight, target, equipmentSlots);

    }

    @Override
    public int getMinPower(int level) {
        return 100;
    }

    @Override
    public int getMaxLevel() {
        return 1;
    }

    @Override
    public void onTargetDamaged(LivingEntity user, net.minecraft.entity.Entity target, int level) {
        World world = user.world;
        if (target instanceof LivingEntity) {
            Vec3d pos = target.getPos();
            world.createExplosion(user, pos.x, pos.y, pos.z, 4.0F, );
        }
        super.onTargetDamaged(user, target, level);
    }
}

【问题讨论】:

    标签: java minecraft minecraft-fabric


    【解决方案1】:

    简单定义destructionType参数:

    world.createExplosion(user, pos.x, pos.y, pos.z, 4.0F, Explosion.DestructionType.NONE);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-04
      • 2020-08-06
      • 1970-01-01
      • 1970-01-01
      • 2011-10-05
      相关资源
      最近更新 更多