添加了淬毒弹

This commit is contained in:
17146 2024-08-09 02:12:32 +08:00
parent e0099683ba
commit be6aa7b50c
6 changed files with 37 additions and 1 deletions

View file

@ -58,6 +58,7 @@ import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnData, GeoEntity, AnimatedEntity {
public static final EntityDataAccessor<Float> COLOR_R = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT);
@ -86,6 +87,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
private boolean zoom = false;
private float bypassArmorRate = 0.0f;
private float undeadMultiple = 1.0f;
private Supplier<MobEffectInstance> mobEffect = () -> null;
public ProjectileEntity(EntityType<? extends ProjectileEntity> p_i50159_1_, Level p_i50159_2_) {
super(p_i50159_1_, p_i50159_2_);
@ -335,7 +337,6 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
}
protected void onHitBlock(Vec3 location) {
if (this.level() instanceof ServerLevel serverLevel) {
if (this.beast) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.END_ROD, location.x, location.y, location.z, 15, 0.1, 0.1, 0.1, 0.05, true);
@ -429,6 +430,11 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
performDamage(entity, this.damage, false);
}
if (this.mobEffect.get() != null && entity instanceof LivingEntity living) {
living.addEffect(this.mobEffect.get(), this.shooter);
}
this.discard();
}
@ -689,6 +695,11 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
return this;
}
public ProjectileEntity effect(Supplier<MobEffectInstance> supplier) {
this.mobEffect = supplier;
return this;
}
public void setRGB(float[] rgb) {
this.entityData.set(COLOR_R, rgb[0]);
this.entityData.set(COLOR_G, rgb[1]);

View file

@ -21,6 +21,7 @@ import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -362,6 +363,11 @@ public class GunEventHandler {
if (perk instanceof AmmoPerk ammoPerk) {
bypassArmorRate += ammoPerk.bypassArmorRate;
projectile.setRGB(ammoPerk.rgb);
if (ammoPerk.mobEffect.get() != null) {
int level = PerkHelper.getItemPerkLevel(perk, heldItem);
projectile.effect(() -> new MobEffectInstance(ammoPerk.mobEffect.get(), 100, level - 1));
}
}
bypassArmorRate = Mth.clamp(bypassArmorRate, 0, 1);

View file

@ -4,6 +4,7 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.perk.AmmoPerk;
import net.mcreator.superbwarfare.perk.Perk;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.effect.MobEffects;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
@ -25,6 +26,9 @@ public class ModPerks {
() -> new AmmoPerk(new AmmoPerk.Builder("silver_bullet", Perk.Type.AMMO).bypassArmorRate(0.1f).rgb(87, 166, 219)));
public static final RegistryObject<AmmoPerk> BEAST_BULLET = PERKS.register("beast_bullet",
() -> new AmmoPerk(new AmmoPerk.Builder("beast_bullet", Perk.Type.AMMO).bypassArmorRate(0.0f).rgb(134, 65, 14)));
public static final RegistryObject<AmmoPerk> POISONOUS_BULLET = PERKS.register("poisonous_bullet",
() -> new AmmoPerk(new AmmoPerk.Builder("poisonous_bullet", Perk.Type.AMMO).bypassArmorRate(0.0f).rgb(48, 131, 6)
.mobEffect(() -> MobEffects.POISON)));
public static final RegistryObject<Perk> HEAL_CLIP = PERKS.register("heal_clip", () -> new Perk("heal_clip", Perk.Type.FUNCTIONAL));
public static final RegistryObject<Perk> FOURTH_TIMES_CHARM = PERKS.register("fourth_times_charm", () -> new Perk("fourth_times_charm", Perk.Type.FUNCTIONAL));

View file

@ -1,15 +1,20 @@
package net.mcreator.superbwarfare.perk;
import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffect;
import java.util.function.Supplier;
public class AmmoPerk extends Perk {
public float bypassArmorRate;
public float[] rgb;
public Supplier<MobEffect> mobEffect;
public AmmoPerk(AmmoPerk.Builder builder) {
super(builder.descriptionId, builder.type);
this.bypassArmorRate = builder.bypassArmorRate;
this.rgb = builder.rgb;
this.mobEffect = builder.mobEffect;
}
public static class Builder {
@ -17,6 +22,7 @@ public class AmmoPerk extends Perk {
Type type;
float bypassArmorRate = 0.0f;
float[] rgb = {1, 222 / 255f, 39 / 255f};
public Supplier<MobEffect> mobEffect = () -> null;
public Builder(String descriptionId, Type type) {
this.descriptionId = descriptionId;
@ -34,5 +40,10 @@ public class AmmoPerk extends Perk {
this.rgb[2] = b / 255f;
return this;
}
public AmmoPerk.Builder mobEffect(Supplier<MobEffect> mobEffect) {
this.mobEffect = mobEffect;
return this;
}
}
}

View file

@ -178,6 +178,8 @@
"des.superbwarfare.silver_bullet": "Causes extra damage to undead entities",
"item.superbwarfare.beast_bullet": "Beast Bullet",
"des.superbwarfare.beast_bullet": "Ignore obstacles, Increase criteria area, Kill every living entity",
"item.superbwarfare.poisonous_bullet": "Poisonous Bullet",
"des.superbwarfare.poisonous_bullet": "Makes the target poison after landing a hit",
"item.superbwarfare.heal_clip": "Heal Clip",
"des.superbwarfare.heal_clip": "Reloading after dealing a final blow will heal you and your nearby allies",

View file

@ -178,6 +178,8 @@
"des.superbwarfare.silver_bullet": "对亡灵生物造成额外伤害",
"item.superbwarfare.beast_bullet": "野兽弹",
"des.superbwarfare.beast_bullet": "无视障碍物,增大判定范围,秒杀一切生物",
"item.superbwarfare.poisonous_bullet": "淬毒弹",
"des.superbwarfare.poisonous_bullet": "命中后会使目标中毒",
"item.superbwarfare.heal_clip": "治疗弹匣",
"des.superbwarfare.heal_clip": "最后一击后短时间内填装,可治疗自身和附近队友",