添加治疗弹匣附魔
This commit is contained in:
parent
dc4a236841
commit
1a8ee5d446
13 changed files with 138 additions and 61 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
|
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
|
||||||
|
public class HealClip extends Enchantment {
|
||||||
|
|
||||||
|
public HealClip() {
|
||||||
|
super(Rarity.RARE, EnchantmentCategoryTool.GUN, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxLevel() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinCost(int pLevel) {
|
||||||
|
return 15 + 6 * pLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxCost(int pLevel) {
|
||||||
|
return getMinCost(pLevel) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
|
public class KillClip {
|
||||||
|
}
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package net.mcreator.superbwarfare.enchantment;
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
@ -8,8 +7,8 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
|
||||||
public class LongerWireEnchantment extends Enchantment {
|
public class LongerWire extends Enchantment {
|
||||||
public LongerWireEnchantment(EquipmentSlot... slots) {
|
public LongerWire(EquipmentSlot... slots) {
|
||||||
super(Rarity.UNCOMMON, EnchantmentCategoryTool.TASER, slots);
|
super(Rarity.UNCOMMON, EnchantmentCategoryTool.TASER, slots);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
|
|
||||||
package net.mcreator.superbwarfare.enchantment;
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
|
||||||
public class MonsterHunterEnchantment extends Enchantment {
|
public class MonsterHunter extends Enchantment {
|
||||||
public MonsterHunterEnchantment(EquipmentSlot... slots) {
|
public MonsterHunter(EquipmentSlot... slots) {
|
||||||
super(Rarity.UNCOMMON, EnchantmentCategoryTool.GUN, slots);
|
super(Rarity.UNCOMMON, EnchantmentCategoryTool.GUN, slots);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package net.mcreator.superbwarfare.enchantment;
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
@ -8,8 +7,8 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
|
||||||
public class SuperRechargeEnchantment extends Enchantment {
|
public class SuperRecharge extends Enchantment {
|
||||||
public SuperRechargeEnchantment(EquipmentSlot... slots) {
|
public SuperRecharge(EquipmentSlot... slots) {
|
||||||
super(Rarity.UNCOMMON, EnchantmentCategoryTool.TASER, slots);
|
super(Rarity.UNCOMMON, EnchantmentCategoryTool.TASER, slots);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package net.mcreator.superbwarfare.enchantment;
|
||||||
|
|
||||||
|
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
|
||||||
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
|
||||||
|
public class VoltOverload extends Enchantment {
|
||||||
|
public VoltOverload(EquipmentSlot... slots) {
|
||||||
|
super(Enchantment.Rarity.UNCOMMON, EnchantmentCategoryTool.TASER, slots);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinCost(int pLevel) {
|
||||||
|
return 8 + 6 * pLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxCost(int pLevel) {
|
||||||
|
return super.getMaxCost(pLevel) + 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxLevel() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canApplyAtEnchantingTable(ItemStack itemstack) {
|
||||||
|
return Ingredient.of(new ItemStack(ModItems.TASER.get())).test(itemstack);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +0,0 @@
|
||||||
|
|
||||||
package net.mcreator.superbwarfare.enchantment;
|
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
|
||||||
|
|
||||||
public class VoltOverloadEnchantment extends Enchantment {
|
|
||||||
public VoltOverloadEnchantment(EquipmentSlot... slots) {
|
|
||||||
super(Enchantment.Rarity.UNCOMMON, EnchantmentCategoryTool.TASER, slots);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMinCost(int pLevel) {
|
|
||||||
return 8 + 6 * pLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxCost(int pLevel) {
|
|
||||||
return super.getMaxCost(pLevel) + 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxLevel() {
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canApplyAtEnchantingTable(ItemStack itemstack) {
|
|
||||||
return Ingredient.of(new ItemStack(ModItems.TASER.get())).test(itemstack);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,6 +28,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
|
@ -63,6 +64,7 @@ public class GunEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleHealClip(player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -813,4 +815,16 @@ public class GunEventHandler {
|
||||||
tag.putBoolean("sentinel_is_charging", false);
|
tag.putBoolean("sentinel_is_charging", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleHealClip(Player player, ItemStack stack) {
|
||||||
|
int time = stack.getOrCreateTag().getInt("HealClipTime");
|
||||||
|
if (time > 0) {
|
||||||
|
player.heal(player.getMaxHealth() * .6f);
|
||||||
|
List<Player> players = player.level().getEntitiesOfClass(Player.class, player.getBoundingBox().inflate(5))
|
||||||
|
.stream().filter(p -> p.isAlliedTo(player)).toList();
|
||||||
|
players.forEach(p -> p.heal(p.getMaxHealth() * .3f));
|
||||||
|
|
||||||
|
stack.getOrCreateTag().putInt("HealClipTime", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,7 @@ package net.mcreator.superbwarfare.event;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.Target1Entity;
|
import net.mcreator.superbwarfare.entity.Target1Entity;
|
||||||
import net.mcreator.superbwarfare.init.ModDamageTypes;
|
import net.mcreator.superbwarfare.init.*;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
|
||||||
import net.mcreator.superbwarfare.init.ModSounds;
|
|
||||||
import net.mcreator.superbwarfare.init.ModTags;
|
|
||||||
import net.mcreator.superbwarfare.item.gun.GunItem;
|
import net.mcreator.superbwarfare.item.gun.GunItem;
|
||||||
import net.mcreator.superbwarfare.network.ModVariables;
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.mcreator.superbwarfare.network.message.ClientIndicatorMessage;
|
import net.mcreator.superbwarfare.network.message.ClientIndicatorMessage;
|
||||||
|
@ -25,6 +22,7 @@ import net.minecraft.world.entity.LivingEntity;
|
||||||
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.entity.projectile.Projectile;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
|
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
|
@ -52,6 +50,7 @@ public class LivingEventHandler {
|
||||||
|
|
||||||
killIndication(event.getSource().getEntity());
|
killIndication(event.getSource().getEntity());
|
||||||
handlePlayerKillEntity(event);
|
handlePlayerKillEntity(event);
|
||||||
|
handleHealClip(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,4 +247,32 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleHealClip(LivingDeathEvent 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)) {
|
||||||
|
ItemStack stack = attacker.getMainHandItem();
|
||||||
|
if (!stack.is(ModTags.Items.GUN)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int level = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.HEAL_CLIP.get(), stack);
|
||||||
|
if (level != 0) {
|
||||||
|
stack.getOrCreateTag().putInt("HealClipTime", 80 + level * 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,19 @@
|
||||||
package net.mcreator.superbwarfare.init;
|
package net.mcreator.superbwarfare.init;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.enchantment.LongerWireEnchantment;
|
import net.mcreator.superbwarfare.enchantment.*;
|
||||||
import net.mcreator.superbwarfare.enchantment.MonsterHunterEnchantment;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.enchantment.VoltOverloadEnchantment;
|
|
||||||
import net.mcreator.superbwarfare.enchantment.SuperRechargeEnchantment;
|
|
||||||
|
|
||||||
public class ModEnchantments {
|
public class ModEnchantments {
|
||||||
public static final DeferredRegister<Enchantment> REGISTRY = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, ModUtils.MODID);
|
public static final DeferredRegister<Enchantment> REGISTRY = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, ModUtils.MODID);
|
||||||
public static final RegistryObject<Enchantment> VOLT_OVERLOAD = REGISTRY.register("volt_overload", () -> new VoltOverloadEnchantment());
|
|
||||||
public static final RegistryObject<Enchantment> SUPER_RECHARGE = REGISTRY.register("super_recharge", () -> new SuperRechargeEnchantment());
|
public static final RegistryObject<Enchantment> VOLT_OVERLOAD = REGISTRY.register("volt_overload", VoltOverload::new);
|
||||||
public static final RegistryObject<Enchantment> LONGER_WIRE = REGISTRY.register("longer_wire", () -> new LongerWireEnchantment());
|
public static final RegistryObject<Enchantment> SUPER_RECHARGE = REGISTRY.register("super_recharge", SuperRecharge::new);
|
||||||
public static final RegistryObject<Enchantment> MONSTER_HUNTER = REGISTRY.register("monster_hunter", () -> new MonsterHunterEnchantment());
|
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> HEAL_CLIP = REGISTRY.register("heal_clip", HealClip::new);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,18 +78,24 @@ public abstract class GunItem extends Item {
|
||||||
itemstack.getOrCreateTag().putInt("draw_time", (itemstack.getOrCreateTag().getInt("draw_time") + 1));
|
itemstack.getOrCreateTag().putInt("draw_time", (itemstack.getOrCreateTag().getInt("draw_time") + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack.getOrCreateTag().getInt("fire_animation") > 0) {
|
if (itemstack.getOrCreateTag().getInt("fire_animation") > 0) {
|
||||||
itemstack.getOrCreateTag().putInt("fire_animation", (itemstack.getOrCreateTag().getInt("fire_animation") - 1));
|
itemstack.getOrCreateTag().putInt("fire_animation", (itemstack.getOrCreateTag().getInt("fire_animation") - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("flash_time") > 0) {
|
if (itemstack.getOrCreateTag().getDouble("flash_time") > 0) {
|
||||||
itemstack.getOrCreateTag().putDouble("flash_time", (itemstack.getOrCreateTag().getDouble("flash_time") - 1));
|
itemstack.getOrCreateTag().putDouble("flash_time", (itemstack.getOrCreateTag().getDouble("flash_time") - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemstack.getOrCreateTag().contains("HealClipTime")) {
|
||||||
|
itemstack.getOrCreateTag().putInt("HealClipTime", Math.max(0, itemstack.getOrCreateTag().getInt("HealClipTime") - 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
|
public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
|
||||||
return false;
|
return super.onEntitySwing(stack, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -239,6 +239,8 @@
|
||||||
"enchantment.superbwarfare.longer_wire.desc": "Increases the range of TaserGun",
|
"enchantment.superbwarfare.longer_wire.desc": "Increases the range of TaserGun",
|
||||||
"enchantment.superbwarfare.monster_hunter": "Monster Hunter",
|
"enchantment.superbwarfare.monster_hunter": "Monster Hunter",
|
||||||
"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.desc": "Reloading after dealing a final blow will heal you and your nearby allies",
|
||||||
|
|
||||||
"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 ]",
|
||||||
|
|
|
@ -239,6 +239,8 @@
|
||||||
"enchantment.superbwarfare.longer_wire.desc": "增加泰瑟枪的射程",
|
"enchantment.superbwarfare.longer_wire.desc": "增加泰瑟枪的射程",
|
||||||
"enchantment.superbwarfare.monster_hunter": "怪物猎人",
|
"enchantment.superbwarfare.monster_hunter": "怪物猎人",
|
||||||
"enchantment.superbwarfare.monster_hunter.desc": "增加对怪物的子弹伤害",
|
"enchantment.superbwarfare.monster_hunter.desc": "增加对怪物的子弹伤害",
|
||||||
|
"enchantment.superbwarfare.heal_clip": "治疗弹匣",
|
||||||
|
"enchantment.superbwarfare.heal_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