注册了蝴蝶弹
This commit is contained in:
parent
4a916be618
commit
ec91fed148
5 changed files with 53 additions and 3 deletions
|
@ -2,6 +2,8 @@ package com.atsuishio.superbwarfare.compat;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
|
import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.projectile.Projectile;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
@ -23,6 +25,9 @@ public class CompatHolder {
|
||||||
@ObjectHolder(registryName = "minecraft:mob_effect", value = VRC + ":curse_flame")
|
@ObjectHolder(registryName = "minecraft:mob_effect", value = VRC + ":curse_flame")
|
||||||
public static final MobEffect VRC_CURSE_FLAME = null;
|
public static final MobEffect VRC_CURSE_FLAME = null;
|
||||||
|
|
||||||
|
@ObjectHolder(registryName = "minecraft:entity_type", value = VRC + ":rain_shower_butterfly")
|
||||||
|
public static final EntityType<? extends Projectile> VRC_RAIN_SHOWER_BUTTERFLY = null;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onInterModEnqueue(final InterModEnqueueEvent event) {
|
public static void onInterModEnqueue(final InterModEnqueueEvent event) {
|
||||||
event.enqueueWork(() -> hasMod(CLOTH_CONFIG, () -> DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClothConfigHelper::registerScreen)));
|
event.enqueueWork(() -> hasMod(CLOTH_CONFIG, () -> DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClothConfigHelper::registerScreen)));
|
||||||
|
|
|
@ -1,25 +1,28 @@
|
||||||
package com.atsuishio.superbwarfare.event;
|
package com.atsuishio.superbwarfare.event;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
|
import com.atsuishio.superbwarfare.compat.CompatHolder;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
|
||||||
import com.atsuishio.superbwarfare.event.modevent.ReloadEvent;
|
import com.atsuishio.superbwarfare.event.modevent.ReloadEvent;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
import com.atsuishio.superbwarfare.tools.GunInfo;
|
import com.atsuishio.superbwarfare.tools.GunInfo;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.entity.projectile.Projectile;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
@ -186,6 +189,10 @@ public class GunEventHandler {
|
||||||
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
||||||
var perk = PerkHelper.getPerkByType(heldItem, Perk.Type.AMMO);
|
var perk = PerkHelper.getPerkByType(heldItem, Perk.Type.AMMO);
|
||||||
|
|
||||||
|
if (perk != null && perk.descriptionId.equals("butterfly_bullet")) {
|
||||||
|
if (handleButterflyBullet(perk, heldItem, player)) return;
|
||||||
|
}
|
||||||
|
|
||||||
ProjectileEntity projectile = new ProjectileEntity(player.level())
|
ProjectileEntity projectile = new ProjectileEntity(player.level())
|
||||||
.shooter(player)
|
.shooter(player)
|
||||||
.damage(perk instanceof AmmoPerk ammoPerk && ammoPerk.slug ? projectileAmount * damage : damage)
|
.damage(perk instanceof AmmoPerk ammoPerk && ammoPerk.slug ? projectileAmount * damage : damage)
|
||||||
|
@ -258,6 +265,38 @@ public class GunEventHandler {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean handleButterflyBullet(Perk perk, ItemStack heldItem, Player player) {
|
||||||
|
int perkLevel = PerkHelper.getItemPerkLevel(perk, heldItem);
|
||||||
|
|
||||||
|
var entityType = CompatHolder.VRC_RAIN_SHOWER_BUTTERFLY;
|
||||||
|
if (entityType != null) {
|
||||||
|
Projectile projectile = entityType.create(player.level());
|
||||||
|
|
||||||
|
float inaccuracy = Math.max(0.0f, 1.1f - perkLevel * .1f);
|
||||||
|
projectile.setOwner(player);
|
||||||
|
projectile.setPos(player.getX() - 0.1 * player.getLookAngle().x,
|
||||||
|
player.getEyeY() - 0.1 - 0.1 * player.getLookAngle().y, player.getZ() + -0.1 * player.getLookAngle().z);
|
||||||
|
|
||||||
|
Vec3 vec3 = (new Vec3(player.getLookAngle().x, player.getLookAngle().y + 0.001f, player.getLookAngle().z)).normalize().scale(1.2).
|
||||||
|
add(player.level().random.triangle(0.0D, 0.0172275D * (double) inaccuracy),
|
||||||
|
player.level().random.triangle(0.0D, 0.0172275D * (double) inaccuracy),
|
||||||
|
player.level().random.triangle(0.0D, 0.0172275D * (double) inaccuracy)).
|
||||||
|
add(player.getDeltaMovement().x, player.onGround() ? 0.0 : 0.05 * player.getDeltaMovement().y, player.getDeltaMovement().z).
|
||||||
|
scale(5.0f);
|
||||||
|
projectile.setDeltaMovement(vec3);
|
||||||
|
projectile.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * (double) (180F / (float) Math.PI)));
|
||||||
|
projectile.setXRot((float) (Mth.atan2(vec3.y, vec3.horizontalDistance()) * (double) (180F / (float) Math.PI)));
|
||||||
|
projectile.yRotO = projectile.getYRot();
|
||||||
|
projectile.xRotO = projectile.getXRot();
|
||||||
|
|
||||||
|
projectile.setNoGravity(true);
|
||||||
|
player.level().addFreshEntity(projectile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用的武器换弹流程
|
* 通用的武器换弹流程
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -79,6 +79,8 @@ public class ModPerks {
|
||||||
if (ModList.get().isLoaded(CompatHolder.VRC)) {
|
if (ModList.get().isLoaded(CompatHolder.VRC)) {
|
||||||
AMMO_PERKS.register("curse_flame_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("curse_flame_bullet", Perk.Type.AMMO)
|
AMMO_PERKS.register("curse_flame_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("curse_flame_bullet", Perk.Type.AMMO)
|
||||||
.bypassArmorRate(0.0f).damageRate(1.2f).speedRate(0.9f).rgb(0xB1, 0xC1, 0xF2).mobEffect(() -> CompatHolder.VRC_CURSE_FLAME)));
|
.bypassArmorRate(0.0f).damageRate(1.2f).speedRate(0.9f).rgb(0xB1, 0xC1, 0xF2).mobEffect(() -> CompatHolder.VRC_CURSE_FLAME)));
|
||||||
|
AMMO_PERKS.register("butterfly_bullet", () -> new AmmoPerk(new AmmoPerk.Builder("butterfly_bullet", Perk.Type.AMMO)
|
||||||
|
.bypassArmorRate(0.0f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,6 +250,8 @@
|
||||||
"des.superbwarfare.he_bullet": "The bullet will explode after hitting the target",
|
"des.superbwarfare.he_bullet": "The bullet will explode after hitting the target",
|
||||||
"item.superbwarfare.incendiary_bullet": "Incendiary Bullet",
|
"item.superbwarfare.incendiary_bullet": "Incendiary Bullet",
|
||||||
"des.superbwarfare.incendiary_bullet": "The bullet will ignites the target after hitting the target",
|
"des.superbwarfare.incendiary_bullet": "The bullet will ignites the target after hitting the target",
|
||||||
|
"item.superbwarfare.butterfly_bullet": "Butterfly Bullet",
|
||||||
|
"des.superbwarfare.butterfly_bullet": "Replace the bullet with Rain Shower Butterfly",
|
||||||
|
|
||||||
"item.superbwarfare.heal_clip": "Heal Clip",
|
"item.superbwarfare.heal_clip": "Heal Clip",
|
||||||
"des.superbwarfare.heal_clip": "Reloading after dealing a final blow will heal you and your nearby allies",
|
"des.superbwarfare.heal_clip": "Reloading after dealing a final blow will heal you and your nearby allies",
|
||||||
|
|
|
@ -250,6 +250,8 @@
|
||||||
"des.superbwarfare.he_bullet": "子弹在命中后会爆炸",
|
"des.superbwarfare.he_bullet": "子弹在命中后会爆炸",
|
||||||
"item.superbwarfare.incendiary_bullet": "燃烧弹",
|
"item.superbwarfare.incendiary_bullet": "燃烧弹",
|
||||||
"des.superbwarfare.incendiary_bullet": "子弹在命中后点燃目标",
|
"des.superbwarfare.incendiary_bullet": "子弹在命中后点燃目标",
|
||||||
|
"item.superbwarfare.butterfly_bullet": "蝴蝶弹",
|
||||||
|
"des.superbwarfare.butterfly_bullet": "将子弹替换成骤雨之蝶",
|
||||||
|
|
||||||
"item.superbwarfare.heal_clip": "治疗弹匣",
|
"item.superbwarfare.heal_clip": "治疗弹匣",
|
||||||
"des.superbwarfare.heal_clip": "最后一击后短时间内填装,可治疗自身和附近队友",
|
"des.superbwarfare.heal_clip": "最后一击后短时间内填装,可治疗自身和附近队友",
|
||||||
|
|
Loading…
Add table
Reference in a new issue