添加Kill Clip附魔
This commit is contained in:
parent
2181c46060
commit
a5be6ea3fc
7 changed files with 84 additions and 4 deletions
|
@ -1,4 +1,27 @@
|
||||||
package net.mcreator.superbwarfare.enchantment;
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
public class KillClip {
|
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
|
||||||
|
public class KillClip extends Enchantment {
|
||||||
|
|
||||||
|
public KillClip() {
|
||||||
|
super(Rarity.UNCOMMON, EnchantmentCategoryTool.GUN, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxLevel() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinCost(int pLevel) {
|
||||||
|
return 20 + 3 * pLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxCost(int pLevel) {
|
||||||
|
return getMinCost(pLevel) + 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHealClip(player, stack);
|
handleHealClip(player, stack);
|
||||||
|
handleKillClip(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -833,4 +834,14 @@ public class GunEventHandler {
|
||||||
stack.getOrCreateTag().putInt("HealClipTime", 0);
|
stack.getOrCreateTag().putInt("HealClipTime", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleKillClip(ItemStack stack) {
|
||||||
|
int level = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.KILL_CLIP.get(), stack);
|
||||||
|
|
||||||
|
int time = stack.getOrCreateTag().getInt("KillClipReloadTime");
|
||||||
|
if (time > 0) {
|
||||||
|
stack.getOrCreateTag().putInt("KillClipTime", 90 + 10 * level);
|
||||||
|
stack.getOrCreateTag().putInt("KillClipReloadTime", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class LivingEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleKillClipDamage(event);
|
||||||
renderDamageIndicator(event);
|
renderDamageIndicator(event);
|
||||||
reduceBulletDamage(event, event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
reduceBulletDamage(event, event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
||||||
}
|
}
|
||||||
|
@ -50,7 +51,7 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
killIndication(event.getSource().getEntity());
|
killIndication(event.getSource().getEntity());
|
||||||
handlePlayerKillEntity(event);
|
handlePlayerKillEntity(event);
|
||||||
handleHealClip(event);
|
handleClipEnchantments(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reduceBulletDamage(LivingHurtEvent event, DamageSource damagesource, LivingEntity entity, Entity sourceentity, double amount) {
|
private static void reduceBulletDamage(LivingHurtEvent event, DamageSource damagesource, LivingEntity entity, Entity sourceentity, double amount) {
|
||||||
|
@ -248,7 +249,7 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleHealClip(LivingDeathEvent event) {
|
private static void handleClipEnchantments(LivingDeathEvent event) {
|
||||||
DamageSource source = event.getSource();
|
DamageSource source = event.getSource();
|
||||||
|
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
|
@ -263,7 +264,9 @@ public class LivingEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.is(ModDamageTypes.GUN_FIRE) || source.is(ModDamageTypes.GUN_FIRE_HEADSHOT)) {
|
if (source.is(ModDamageTypes.GUN_FIRE) || source.is(ModDamageTypes.GUN_FIRE_HEADSHOT) ||
|
||||||
|
source.is(ModDamageTypes.ARROW_IN_BRAIN) || source.is(ModDamageTypes.ARROW_IN_KNEE)
|
||||||
|
|| source.is(ModDamageTypes.PROJECTILE_BOOM)) {
|
||||||
ItemStack stack = attacker.getMainHandItem();
|
ItemStack stack = attacker.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) {
|
if (!stack.is(ModTags.Items.GUN)) {
|
||||||
return;
|
return;
|
||||||
|
@ -273,6 +276,40 @@ public class LivingEventHandler {
|
||||||
if (healClipLevel != 0) {
|
if (healClipLevel != 0) {
|
||||||
stack.getOrCreateTag().putInt("HealClipTime", 80 + healClipLevel * 20);
|
stack.getOrCreateTag().putInt("HealClipTime", 80 + healClipLevel * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int killClipLevel = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.KILL_CLIP.get(), stack);
|
||||||
|
if (killClipLevel != 0) {
|
||||||
|
stack.getOrCreateTag().putInt("KillClipReloadTime", 80);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleKillClipDamage(LivingHurtEvent event) {
|
||||||
|
DamageSource source = event.getSource();
|
||||||
|
|
||||||
|
Player attacker = null;
|
||||||
|
if (source.getEntity() instanceof Player player) {
|
||||||
|
attacker = player;
|
||||||
|
}
|
||||||
|
if (source.getDirectEntity() instanceof Projectile projectile && projectile.getOwner() instanceof Player player) {
|
||||||
|
attacker = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attacker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source.is(ModDamageTypes.GUN_FIRE) || source.is(ModDamageTypes.GUN_FIRE_HEADSHOT) ||
|
||||||
|
source.is(ModDamageTypes.ARROW_IN_BRAIN) || source.is(ModDamageTypes.ARROW_IN_KNEE)
|
||||||
|
|| source.is(ModDamageTypes.PROJECTILE_BOOM)) {
|
||||||
|
ItemStack stack = attacker.getMainHandItem();
|
||||||
|
if (!stack.is(ModTags.Items.GUN)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getOrCreateTag().getInt("KillClipTime") > 0) {
|
||||||
|
event.setAmount(event.getAmount() * 1.25f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ public class ModEnchantments {
|
||||||
public static final RegistryObject<Enchantment> LONGER_WIRE = REGISTRY.register("longer_wire", LongerWire::new);
|
public static final RegistryObject<Enchantment> LONGER_WIRE = REGISTRY.register("longer_wire", LongerWire::new);
|
||||||
public static final RegistryObject<Enchantment> MONSTER_HUNTER = REGISTRY.register("monster_hunter", MonsterHunter::new);
|
public static final RegistryObject<Enchantment> MONSTER_HUNTER = REGISTRY.register("monster_hunter", MonsterHunter::new);
|
||||||
public static final RegistryObject<Enchantment> HEAL_CLIP = REGISTRY.register("heal_clip", HealClip::new);
|
public static final RegistryObject<Enchantment> HEAL_CLIP = REGISTRY.register("heal_clip", HealClip::new);
|
||||||
|
public static final RegistryObject<Enchantment> KILL_CLIP = REGISTRY.register("kill_clip", KillClip::new);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,10 @@ public abstract class GunItem extends Item {
|
||||||
itemstack.getOrCreateTag().putInt("HealClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("HealClipTime") - 1));
|
itemstack.getOrCreateTag().putInt("HealClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("HealClipTime") - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemstack.getOrCreateTag().getInt("KillClipReloadTime") > 0) {
|
||||||
|
itemstack.getOrCreateTag().putInt("KillClipReloadTime", Math.max(0, itemstack.getOrCreateTag().getInt("KillClipReloadTime") - 1));
|
||||||
|
}
|
||||||
|
|
||||||
if (itemstack.getOrCreateTag().getInt("KillClipTime") > 0) {
|
if (itemstack.getOrCreateTag().getInt("KillClipTime") > 0) {
|
||||||
itemstack.getOrCreateTag().putInt("KillClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("KillClipTime") - 1));
|
itemstack.getOrCreateTag().putInt("KillClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("KillClipTime") - 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,8 @@
|
||||||
"enchantment.superbwarfare.monster_hunter.desc": "Increases bullet damage against monsters",
|
"enchantment.superbwarfare.monster_hunter.desc": "Increases bullet damage against monsters",
|
||||||
"enchantment.superbwarfare.heal_clip": "Heal Clip",
|
"enchantment.superbwarfare.heal_clip": "Heal Clip",
|
||||||
"enchantment.superbwarfare.heal_clip.desc": "Reloading after dealing a final blow will heal you and your nearby allies",
|
"enchantment.superbwarfare.heal_clip.desc": "Reloading after dealing a final blow will heal you and your nearby allies",
|
||||||
|
"enchantment.superbwarfare.kill_clip": "Kill Clip",
|
||||||
|
"enchantment.superbwarfare.kill_clip.desc": "Increases the damage of weapon after dealing a final blow",
|
||||||
|
|
||||||
"des.superbwarfare.sensitivity": "Current Sensitivity of This Gun: %1$s",
|
"des.superbwarfare.sensitivity": "Current Sensitivity of This Gun: %1$s",
|
||||||
"des.superbwarfare.need_bolt_action": "[ Need Bolt Action ]",
|
"des.superbwarfare.need_bolt_action": "[ Need Bolt Action ]",
|
||||||
|
|
|
@ -241,6 +241,8 @@
|
||||||
"enchantment.superbwarfare.monster_hunter.desc": "增加对怪物的子弹伤害",
|
"enchantment.superbwarfare.monster_hunter.desc": "增加对怪物的子弹伤害",
|
||||||
"enchantment.superbwarfare.heal_clip": "治疗弹匣",
|
"enchantment.superbwarfare.heal_clip": "治疗弹匣",
|
||||||
"enchantment.superbwarfare.heal_clip.desc": "最后一击后短时间内填装,可治疗自身和附近队友",
|
"enchantment.superbwarfare.heal_clip.desc": "最后一击后短时间内填装,可治疗自身和附近队友",
|
||||||
|
"enchantment.superbwarfare.kill_clip": "杀戮弹匣",
|
||||||
|
"enchantment.superbwarfare.kill_clip.desc": "完成击杀后填装可提升武器伤害",
|
||||||
|
|
||||||
"des.superbwarfare.sensitivity": "当前枪械的灵敏度为:%1$s",
|
"des.superbwarfare.sensitivity": "当前枪械的灵敏度为:%1$s",
|
||||||
"des.superbwarfare.need_bolt_action": "【需要拉栓】",
|
"des.superbwarfare.need_bolt_action": "【需要拉栓】",
|
||||||
|
|
Loading…
Add table
Reference in a new issue