添加了淬毒弹
This commit is contained in:
parent
e0099683ba
commit
be6aa7b50c
6 changed files with 37 additions and 1 deletions
|
@ -58,6 +58,7 @@ import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnData, GeoEntity, AnimatedEntity {
|
public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnData, GeoEntity, AnimatedEntity {
|
||||||
public static final EntityDataAccessor<Float> COLOR_R = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT);
|
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 boolean zoom = false;
|
||||||
private float bypassArmorRate = 0.0f;
|
private float bypassArmorRate = 0.0f;
|
||||||
private float undeadMultiple = 1.0f;
|
private float undeadMultiple = 1.0f;
|
||||||
|
private Supplier<MobEffectInstance> mobEffect = () -> null;
|
||||||
|
|
||||||
public ProjectileEntity(EntityType<? extends ProjectileEntity> p_i50159_1_, Level p_i50159_2_) {
|
public ProjectileEntity(EntityType<? extends ProjectileEntity> p_i50159_1_, Level p_i50159_2_) {
|
||||||
super(p_i50159_1_, 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) {
|
protected void onHitBlock(Vec3 location) {
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
if (this.beast) {
|
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);
|
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);
|
performDamage(entity, this.damage, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.mobEffect.get() != null && entity instanceof LivingEntity living) {
|
||||||
|
living.addEffect(this.mobEffect.get(), this.shooter);
|
||||||
|
}
|
||||||
|
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,6 +695,11 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectileEntity effect(Supplier<MobEffectInstance> supplier) {
|
||||||
|
this.mobEffect = supplier;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRGB(float[] rgb) {
|
public void setRGB(float[] rgb) {
|
||||||
this.entityData.set(COLOR_R, rgb[0]);
|
this.entityData.set(COLOR_R, rgb[0]);
|
||||||
this.entityData.set(COLOR_G, rgb[1]);
|
this.entityData.set(COLOR_G, rgb[1]);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
|
@ -362,6 +363,11 @@ public class GunEventHandler {
|
||||||
if (perk instanceof AmmoPerk ammoPerk) {
|
if (perk instanceof AmmoPerk ammoPerk) {
|
||||||
bypassArmorRate += ammoPerk.bypassArmorRate;
|
bypassArmorRate += ammoPerk.bypassArmorRate;
|
||||||
projectile.setRGB(ammoPerk.rgb);
|
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);
|
bypassArmorRate = Mth.clamp(bypassArmorRate, 0, 1);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.perk.AmmoPerk;
|
import net.mcreator.superbwarfare.perk.AmmoPerk;
|
||||||
import net.mcreator.superbwarfare.perk.Perk;
|
import net.mcreator.superbwarfare.perk.Perk;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
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)));
|
() -> 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",
|
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)));
|
() -> 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> 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));
|
public static final RegistryObject<Perk> FOURTH_TIMES_CHARM = PERKS.register("fourth_times_charm", () -> new Perk("fourth_times_charm", Perk.Type.FUNCTIONAL));
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
package net.mcreator.superbwarfare.perk;
|
package net.mcreator.superbwarfare.perk;
|
||||||
|
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.effect.MobEffect;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class AmmoPerk extends Perk {
|
public class AmmoPerk extends Perk {
|
||||||
public float bypassArmorRate;
|
public float bypassArmorRate;
|
||||||
public float[] rgb;
|
public float[] rgb;
|
||||||
|
public Supplier<MobEffect> mobEffect;
|
||||||
|
|
||||||
public AmmoPerk(AmmoPerk.Builder builder) {
|
public AmmoPerk(AmmoPerk.Builder builder) {
|
||||||
super(builder.descriptionId, builder.type);
|
super(builder.descriptionId, builder.type);
|
||||||
this.bypassArmorRate = builder.bypassArmorRate;
|
this.bypassArmorRate = builder.bypassArmorRate;
|
||||||
this.rgb = builder.rgb;
|
this.rgb = builder.rgb;
|
||||||
|
this.mobEffect = builder.mobEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
@ -17,6 +22,7 @@ public class AmmoPerk extends Perk {
|
||||||
Type type;
|
Type type;
|
||||||
float bypassArmorRate = 0.0f;
|
float bypassArmorRate = 0.0f;
|
||||||
float[] rgb = {1, 222 / 255f, 39 / 255f};
|
float[] rgb = {1, 222 / 255f, 39 / 255f};
|
||||||
|
public Supplier<MobEffect> mobEffect = () -> null;
|
||||||
|
|
||||||
public Builder(String descriptionId, Type type) {
|
public Builder(String descriptionId, Type type) {
|
||||||
this.descriptionId = descriptionId;
|
this.descriptionId = descriptionId;
|
||||||
|
@ -34,5 +40,10 @@ public class AmmoPerk extends Perk {
|
||||||
this.rgb[2] = b / 255f;
|
this.rgb[2] = b / 255f;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AmmoPerk.Builder mobEffect(Supplier<MobEffect> mobEffect) {
|
||||||
|
this.mobEffect = mobEffect;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,8 @@
|
||||||
"des.superbwarfare.silver_bullet": "Causes extra damage to undead entities",
|
"des.superbwarfare.silver_bullet": "Causes extra damage to undead entities",
|
||||||
"item.superbwarfare.beast_bullet": "Beast Bullet",
|
"item.superbwarfare.beast_bullet": "Beast Bullet",
|
||||||
"des.superbwarfare.beast_bullet": "Ignore obstacles, Increase criteria area, Kill every living entity",
|
"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",
|
"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",
|
||||||
|
|
|
@ -178,6 +178,8 @@
|
||||||
"des.superbwarfare.silver_bullet": "对亡灵生物造成额外伤害",
|
"des.superbwarfare.silver_bullet": "对亡灵生物造成额外伤害",
|
||||||
"item.superbwarfare.beast_bullet": "野兽弹",
|
"item.superbwarfare.beast_bullet": "野兽弹",
|
||||||
"des.superbwarfare.beast_bullet": "无视障碍物,增大判定范围,秒杀一切生物",
|
"des.superbwarfare.beast_bullet": "无视障碍物,增大判定范围,秒杀一切生物",
|
||||||
|
"item.superbwarfare.poisonous_bullet": "淬毒弹",
|
||||||
|
"des.superbwarfare.poisonous_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