添加直击要害附魔
This commit is contained in:
parent
2cff652b71
commit
6fe095c170
11 changed files with 135 additions and 27 deletions
|
@ -0,0 +1,35 @@
|
|||
package net.mcreator.superbwarfare.enchantment;
|
||||
|
||||
import net.mcreator.superbwarfare.init.ModItems;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
||||
public class GutshotStraight extends Enchantment {
|
||||
|
||||
public GutshotStraight() {
|
||||
super(Rarity.UNCOMMON, EnchantmentCategoryTool.GUN, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return super.getMaxLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int pLevel) {
|
||||
return 13 + 5 * pLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int pLevel) {
|
||||
return getMinCost(pLevel) + 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack itemstack) {
|
||||
return itemstack.is(ModTags.Items.CAN_SHOOT_BULLET) && !itemstack.is(ModItems.MINIGUN.get());
|
||||
}
|
||||
}
|
|
@ -79,6 +79,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
private int monster_multiple = 0;
|
||||
private float legShot = 0.5f;
|
||||
private boolean beast = false;
|
||||
private boolean zoom = false;
|
||||
|
||||
public ProjectileEntity(EntityType<? extends ProjectileEntity> p_i50159_1_, Level p_i50159_2_) {
|
||||
super(p_i50159_1_, p_i50159_2_);
|
||||
|
@ -107,8 +108,8 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
return this;
|
||||
}
|
||||
|
||||
public ProjectileEntity monster_multiple(int monster_multiple) {
|
||||
this.monster_multiple = monster_multiple;
|
||||
public ProjectileEntity monsterMultiple(int monsterMultiple) {
|
||||
this.monster_multiple = monsterMultiple;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -122,6 +123,11 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
return this;
|
||||
}
|
||||
|
||||
public ProjectileEntity zoom(boolean zoom) {
|
||||
this.zoom = zoom;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected EntityResult findEntityOnPath(Vec3 startVec, Vec3 endVec) {
|
||||
Vec3 hitVec = null;
|
||||
|
@ -153,7 +159,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
hitEntity = entity;
|
||||
closestDistance = distanceToHit;
|
||||
headshot = result.isHeadshot();
|
||||
legshot = result.isLegshot();
|
||||
legshot = result.isLegShot();
|
||||
}
|
||||
}
|
||||
return hitEntity != null ? new EntityResult(hitEntity, hitVec, headshot, legshot) : null;
|
||||
|
@ -304,6 +310,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
|
||||
protected void onProjectileTick() {
|
||||
}
|
||||
|
||||
private void onHit(HitResult result) {
|
||||
if (result instanceof BlockHitResult blockHitResult) {
|
||||
if (blockHitResult.getType() == HitResult.Type.MISS) {
|
||||
|
@ -413,15 +420,14 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
}
|
||||
|
||||
if (entity instanceof LivingEntity living) {
|
||||
if (living instanceof Player player && player.isCreative()){
|
||||
if (living instanceof Player player && player.isCreative()) {
|
||||
return;
|
||||
}
|
||||
if (!living.level().isClientSide()) {
|
||||
living.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN,20,2,false,false));
|
||||
living.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 20, 2, false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!this.shooter.level().isClientSide() && this.shooter instanceof ServerPlayer player) {
|
||||
var holder = Holder.direct(ModSounds.INDICATION.get());
|
||||
player.connection.send(new ClientboundSoundPacket(holder, SoundSource.PLAYERS, player.getX(), player.getY(), player.getZ(), 1f, 1f, player.level().random.nextLong()));
|
||||
|
@ -568,13 +574,13 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
private final Entity entity;
|
||||
private final Vec3 hitVec;
|
||||
private final boolean headshot;
|
||||
private final boolean legshot;
|
||||
private final boolean legShot;
|
||||
|
||||
public EntityResult(Entity entity, Vec3 hitVec, boolean headshot, boolean legshot) {
|
||||
public EntityResult(Entity entity, Vec3 hitVec, boolean headshot, boolean legShot) {
|
||||
this.entity = entity;
|
||||
this.hitVec = hitVec;
|
||||
this.headshot = headshot;
|
||||
this.legshot = legshot;
|
||||
this.legShot = legShot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -598,8 +604,8 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
return this.headshot;
|
||||
}
|
||||
|
||||
public boolean isLegshot() {
|
||||
return this.legshot;
|
||||
public boolean isLegShot() {
|
||||
return this.legShot;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,4 +630,8 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
public boolean isZoom() {
|
||||
return this.zoom;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,10 +86,10 @@ public class GunEventHandler {
|
|||
player.getPersistentData().putBoolean("firing", false);
|
||||
}
|
||||
|
||||
int burst_cooldown = 0;
|
||||
int burstCooldown = 0;
|
||||
if (mode == 1) {
|
||||
stack.getOrCreateTag().putInt("burst_fire", (stack.getOrCreateTag().getInt("burst_fire") - 1));
|
||||
burst_cooldown = stack.getOrCreateTag().getInt("burst_fire") == 0 ? interval + 4 : 0;
|
||||
burstCooldown = stack.getOrCreateTag().getInt("burst_fire") == 0 ? interval + 4 : 0;
|
||||
}
|
||||
|
||||
if (stack.getOrCreateTag().getDouble("animindex") == 1) {
|
||||
|
@ -149,10 +149,10 @@ public class GunEventHandler {
|
|||
stack.getOrCreateTag().putDouble("chamber_rot", 20);
|
||||
}
|
||||
|
||||
int zoom_add_cooldown = 0;
|
||||
int zoomAddCooldown = 0;
|
||||
if (stack.getItem() == ModItems.MARLIN.get()) {
|
||||
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).zooming) {
|
||||
zoom_add_cooldown = 5;
|
||||
zoomAddCooldown = 5;
|
||||
stack.getOrCreateTag().putDouble("marlin_animation_time", 15);
|
||||
stack.getOrCreateTag().putBoolean("fastfiring", false);
|
||||
} else {
|
||||
|
@ -161,7 +161,7 @@ public class GunEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
int cooldown = interval + (int) stack.getOrCreateTag().getDouble("fire_sequence") - (int) stack.getOrCreateTag().getDouble("fire_increase") + burst_cooldown + zoom_add_cooldown;
|
||||
int cooldown = interval + (int) stack.getOrCreateTag().getDouble("fire_sequence") - (int) stack.getOrCreateTag().getDouble("fire_increase") + burstCooldown + zoomAddCooldown;
|
||||
player.getCooldowns().addCooldown(stack.getItem(), cooldown);
|
||||
|
||||
for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) {
|
||||
|
@ -343,19 +343,22 @@ public class GunEventHandler {
|
|||
|
||||
if (!player.level().isClientSide()) {
|
||||
float headshot = (float) heldItem.getOrCreateTag().getDouble("headshot");
|
||||
int monster_multiple = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.MONSTER_HUNTER.get(), heldItem);
|
||||
int monsterMultiple = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.MONSTER_HUNTER.get(), heldItem);
|
||||
float damage = (float) (heldItem.getOrCreateTag().getDouble("damage") + heldItem.getOrCreateTag().getDouble("add_damage")) * (float) heldItem.getOrCreateTag().getDouble("damageadd");
|
||||
|
||||
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
||||
|
||||
ProjectileEntity projectile = new ProjectileEntity(player.level())
|
||||
.shooter(player)
|
||||
.damage(damage)
|
||||
.headShot(headshot);
|
||||
.headShot(headshot)
|
||||
.zoom(zoom);
|
||||
|
||||
if (heldItem.getOrCreateTag().getBoolean("beast")) {
|
||||
projectile.beast();
|
||||
}
|
||||
|
||||
projectile.monster_multiple(monster_multiple);
|
||||
projectile.monsterMultiple(monsterMultiple);
|
||||
|
||||
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);
|
||||
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y + 0.0005f, player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.mcreator.superbwarfare.event;
|
||||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
import net.mcreator.superbwarfare.entity.ProjectileEntity;
|
||||
import net.mcreator.superbwarfare.entity.Target1Entity;
|
||||
import net.mcreator.superbwarfare.init.*;
|
||||
import net.mcreator.superbwarfare.item.gun.GunItem;
|
||||
|
@ -40,6 +41,7 @@ public class LivingEventHandler {
|
|||
|
||||
handleKillClipDamage(event);
|
||||
renderDamageIndicator(event);
|
||||
handleGutshotStraightDamage(event);
|
||||
reduceBulletDamage(event, event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
||||
}
|
||||
|
||||
|
@ -312,4 +314,30 @@ public class LivingEventHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleGutshotStraightDamage(LivingHurtEvent event) {
|
||||
DamageSource source = event.getSource();
|
||||
if (!source.is(ModDamageTypes.GUN_FIRE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity directSource = source.getDirectEntity();
|
||||
if (directSource instanceof ProjectileEntity projectile && projectile.getShooter() instanceof Player player) {
|
||||
if (!projectile.isZoom()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!stack.is(ModTags.Items.GUN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int enchantmentLevel = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.GUTSHOT_STRAIGHT.get(), stack);
|
||||
if (enchantmentLevel == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setAmount(event.getAmount() * 1.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package net.mcreator.superbwarfare.init;
|
||||
|
||||
import net.mcreator.superbwarfare.ModUtils;
|
||||
|
@ -18,4 +17,5 @@ public class ModEnchantments {
|
|||
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> KILL_CLIP = REGISTRY.register("kill_clip", KillClip::new);
|
||||
public static final RegistryObject<Enchantment> GUTSHOT_STRAIGHT = REGISTRY.register("gutshot_straight", GutshotStraight::new);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.tags.ItemTags;
|
|||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
|
||||
public class ModTags {
|
||||
|
||||
public static class Items {
|
||||
|
@ -20,7 +19,9 @@ public class ModTags {
|
|||
public static final TagKey<Item> LEGENDARY_GUN = tag("legendary_gun");
|
||||
public static final TagKey<Item> SPECIAL_GUN = tag("special_gun");
|
||||
public static final TagKey<Item> OPEN_BOLT = tag("open_bolt");
|
||||
|
||||
public static final TagKey<Item> CAN_RELOAD = tag("can_reload");
|
||||
public static final TagKey<Item> CAN_SHOOT_BULLET = tag("can_shoot_bullet");
|
||||
|
||||
private static TagKey<Item> tag(String name) {
|
||||
return ItemTags.create(new ResourceLocation(ModUtils.MODID, name));
|
||||
|
|
|
@ -207,17 +207,19 @@ public class FireMessage {
|
|||
double damage;
|
||||
float headshot = (float) tag.getDouble("headshot");
|
||||
float velocity = 4 * (float) tag.getDouble("speed");
|
||||
int monster_multiple = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.MONSTER_HUNTER.get(), heldItem);
|
||||
int monsterMultiple = EnchantmentHelper.getTagEnchantmentLevel(ModEnchantments.MONSTER_HUNTER.get(), heldItem);
|
||||
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
||||
|
||||
var projectile = new ProjectileEntity(player.level())
|
||||
.shooter(player)
|
||||
.headShot(headshot);
|
||||
.headShot(headshot)
|
||||
.monsterMultiple(monsterMultiple)
|
||||
.zoom(zoom);
|
||||
|
||||
if (tag.getBoolean("beast")) {
|
||||
projectile.beast();
|
||||
}
|
||||
|
||||
projectile.monster_multiple(monster_multiple);
|
||||
|
||||
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);
|
||||
|
||||
damage = 0.008333333 * tag.getDouble("damage") * tag.getDouble("speed") * tag.getDouble("damageadd");
|
||||
|
|
|
@ -13,7 +13,7 @@ public class ExtendedEntityRayTraceResult extends EntityHitResult {
|
|||
public ExtendedEntityRayTraceResult(ProjectileEntity.EntityResult result) {
|
||||
super(result.getEntity(), result.getHitPos());
|
||||
this.headshot = result.isHeadshot();
|
||||
this.legshot = result.isLegshot();
|
||||
this.legshot = result.isLegShot();
|
||||
}
|
||||
|
||||
public boolean isHeadshot() {
|
||||
|
|
|
@ -245,6 +245,8 @@
|
|||
"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",
|
||||
"enchantment.superbwarfare.gutshot_straight": "Gutshot Straight",
|
||||
"enchantment.superbwarfare.gutshot_straight.desc": "Aiming down sights increases body shot damage",
|
||||
|
||||
"des.superbwarfare.sensitivity": "Current Sensitivity of This Gun: %1$s",
|
||||
"des.superbwarfare.need_bolt_action": "[ Need Bolt Action ]",
|
||||
|
|
|
@ -245,6 +245,8 @@
|
|||
"enchantment.superbwarfare.heal_clip.desc": "最后一击后短时间内填装,可治疗自身和附近队友",
|
||||
"enchantment.superbwarfare.kill_clip": "杀戮弹匣",
|
||||
"enchantment.superbwarfare.kill_clip.desc": "完成击杀后填装可提升武器伤害",
|
||||
"enchantment.superbwarfare.gutshot_straight": "直击要害",
|
||||
"enchantment.superbwarfare.gutshot_straight.desc": "瞄准时增加身体射击伤害",
|
||||
|
||||
"des.superbwarfare.sensitivity": "当前枪械的灵敏度为:%1$s",
|
||||
"des.superbwarfare.need_bolt_action": "【需要拉栓】",
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"superbwarfare:trachelium",
|
||||
"superbwarfare:hunting_rifle",
|
||||
"superbwarfare:abekiri",
|
||||
"superbwarfare:devotion",
|
||||
"superbwarfare:m_4",
|
||||
"superbwarfare:aa_12",
|
||||
"superbwarfare:hk_416",
|
||||
"superbwarfare:rpk",
|
||||
"superbwarfare:sks",
|
||||
"superbwarfare:ntw_20",
|
||||
"superbwarfare:vector",
|
||||
"superbwarfare:minigun",
|
||||
"superbwarfare:mk_14",
|
||||
"superbwarfare:sentinel",
|
||||
"superbwarfare:m_60",
|
||||
"superbwarfare:svd",
|
||||
"superbwarfare:marlin",
|
||||
"superbwarfare:m_870",
|
||||
"superbwarfare:m_98b",
|
||||
"superbwarfare:ak_47"
|
||||
]
|
||||
}
|
Loading…
Add table
Reference in a new issue