添加了新perk
This commit is contained in:
parent
f8feb06679
commit
31c8d09c55
6 changed files with 60 additions and 31 deletions
|
@ -191,7 +191,6 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开火部分
|
// 开火部分
|
||||||
|
|
||||||
double weight = stack.getOrCreateTag().getDouble("weight");
|
double weight = stack.getOrCreateTag().getDouble("weight");
|
||||||
|
|
||||||
double speed = 1;
|
double speed = 1;
|
||||||
|
@ -210,7 +209,6 @@ public class ClientEventHandler {
|
||||||
cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 24);
|
cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
|
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
|
||||||
&& (player.getMainHandItem().is(ModTags.Items.NORMAL_GUN)
|
&& (player.getMainHandItem().is(ModTags.Items.NORMAL_GUN)
|
||||||
&& cantFireTime == 0
|
&& cantFireTime == 0
|
||||||
|
@ -218,7 +216,6 @@ public class ClientEventHandler {
|
||||||
&& !notInGame()
|
&& !notInGame()
|
||||||
|| (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getDouble("minigun_rotation") >= 10
|
|| (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting() && stack.getOrCreateTag().getDouble("overheat") == 0 && !player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getDouble("minigun_rotation") >= 10
|
||||||
))) {
|
))) {
|
||||||
|
|
||||||
double customRpm = 0;
|
double customRpm = 0;
|
||||||
|
|
||||||
if (stack.getItem() == ModItems.DEVOTION.get()) {
|
if (stack.getItem() == ModItems.DEVOTION.get()) {
|
||||||
|
@ -233,12 +230,16 @@ public class ClientEventHandler {
|
||||||
if (rpm == 0) {
|
if (rpm == 0) {
|
||||||
rpm = 600;
|
rpm = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stack.getOrCreateTag().getInt("DesperadoTimePost") > 0) {
|
||||||
|
rpm *= 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
double rps = rpm / 60;
|
double rps = rpm / 60;
|
||||||
|
|
||||||
// cooldown in ms
|
// cooldown in ms
|
||||||
double cooldown = 1000 / rps;
|
double cooldown = 1000 / rps;
|
||||||
|
|
||||||
|
|
||||||
if (!clientTimer.started()) {
|
if (!clientTimer.started()) {
|
||||||
clientTimer.start();
|
clientTimer.start();
|
||||||
// 首发瞬间发射
|
// 首发瞬间发射
|
||||||
|
@ -249,7 +250,6 @@ public class ClientEventHandler {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ShootMessage(spread));
|
ModUtils.PACKET_HANDLER.sendToServer(new ShootMessage(spread));
|
||||||
clientTimer.setProgress((long) (clientTimer.getProgress() - cooldown));
|
clientTimer.setProgress((long) (clientTimer.getProgress() - cooldown));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
clientTimer.stop();
|
clientTimer.stop();
|
||||||
fireSpread = 0;
|
fireSpread = 0;
|
||||||
|
|
|
@ -451,6 +451,10 @@ public class LivingEventHandler {
|
||||||
handleKillingTallyAddCount(stack);
|
handleKillingTallyAddCount(stack);
|
||||||
handleSubsistence(stack, attacker);
|
handleSubsistence(stack, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DamageTypeTool.isHeadshotDamage(source)) {
|
||||||
|
handleDesperado(stack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleClipPerks(ItemStack stack) {
|
private static void handleClipPerks(ItemStack stack) {
|
||||||
|
@ -584,6 +588,15 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleDesperado(ItemStack stack) {
|
||||||
|
int level = PerkHelper.getItemPerkLevel(ModPerks.DESPERADO.get(), stack);
|
||||||
|
if (level == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.getOrCreateTag().putInt("DesperadoTime", 90 + level * 10);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启死亡掉落时掉落一个弹药盒
|
* 开启死亡掉落时掉落一个弹药盒
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class ReloadEventHandler {
|
||||||
handleHealClipPre(stack);
|
handleHealClipPre(stack);
|
||||||
handleKillClipPre(stack);
|
handleKillClipPre(stack);
|
||||||
handleKillingTallyPre(stack);
|
handleKillingTallyPre(stack);
|
||||||
|
handleDesperadoPre(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -45,6 +46,7 @@ public class ReloadEventHandler {
|
||||||
|
|
||||||
handleHealClipPost(player, stack);
|
handleHealClipPost(player, stack);
|
||||||
handleKillClipPost(stack);
|
handleKillClipPost(stack);
|
||||||
|
handleDesperadoPost(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleHealClipPre(ItemStack stack) {
|
private static void handleHealClipPre(ItemStack stack) {
|
||||||
|
@ -103,4 +105,23 @@ public class ReloadEventHandler {
|
||||||
stack.getOrCreateTag().putInt("KillingTally", 0);
|
stack.getOrCreateTag().putInt("KillingTally", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleDesperadoPre(ItemStack stack) {
|
||||||
|
int time = stack.getOrCreateTag().getInt("DesperadoTime");
|
||||||
|
if (time > 0) {
|
||||||
|
stack.getOrCreateTag().putInt("DesperadoTime", 0);
|
||||||
|
stack.getOrCreateTag().putBoolean("Desperado", true);
|
||||||
|
} else {
|
||||||
|
stack.getOrCreateTag().putBoolean("Desperado", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleDesperadoPost(ItemStack stack) {
|
||||||
|
if (!stack.getOrCreateTag().getBoolean("Desperado")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int level = PerkHelper.getItemPerkLevel(ModPerks.DESPERADO.get(), stack);
|
||||||
|
stack.getOrCreateTag().putInt("DesperadoTimePost", 110 + level * 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class ModPerks {
|
||||||
public static final RegistryObject<Perk> FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", () -> new Perk("field_doctor", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", () -> new Perk("field_doctor", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> SUPER_RECHARGE = FUNC_PERKS.register("super_recharge", () -> new Perk("super_recharge", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> SUPER_RECHARGE = FUNC_PERKS.register("super_recharge", () -> new Perk("super_recharge", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> DIMENSION_MAGAZINE = FUNC_PERKS.register("dimension_magazine", () -> new Perk("dimension_magazine", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> DIMENSION_MAGAZINE = FUNC_PERKS.register("dimension_magazine", () -> new Perk("dimension_magazine", Perk.Type.FUNCTIONAL));
|
||||||
|
public static final RegistryObject<Perk> DESPERADO = FUNC_PERKS.register("desperado", () -> new Perk("desperado", Perk.Type.FUNCTIONAL));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Damage Perks
|
* Damage Perks
|
||||||
|
|
|
@ -43,8 +43,7 @@ public abstract class GunItem extends Item {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack itemstack, Level level, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack itemstack, Level level, Entity entity, int slot, boolean selected) {
|
||||||
if (entity instanceof LivingEntity living) {
|
if (entity instanceof LivingEntity) {
|
||||||
ItemStack mainHandItem = living.getMainHandItem();
|
|
||||||
if (!itemstack.is(ModTags.Items.GUN)) {
|
if (!itemstack.is(ModTags.Items.GUN)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +56,6 @@ public abstract class GunItem extends Item {
|
||||||
|
|
||||||
if (itemstack.getOrCreateTag().getBoolean("draw")) {
|
if (itemstack.getOrCreateTag().getBoolean("draw")) {
|
||||||
itemstack.getOrCreateTag().putBoolean("draw", false);
|
itemstack.getOrCreateTag().putBoolean("draw", false);
|
||||||
// itemstack.getOrCreateTag().putInt("draw_time", 0);
|
|
||||||
|
|
||||||
if (itemstack.getItem() == ModItems.RPG.get() && itemstack.getOrCreateTag().getInt("ammo") == 0) {
|
if (itemstack.getItem() == ModItems.RPG.get() && itemstack.getOrCreateTag().getInt("ammo") == 0) {
|
||||||
itemstack.getOrCreateTag().putDouble("empty", 1);
|
itemstack.getOrCreateTag().putDouble("empty", 1);
|
||||||
|
@ -83,9 +81,7 @@ public abstract class GunItem extends Item {
|
||||||
if ((itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") + 1)
|
if ((itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") + 1)
|
||||||
|| (!itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag"))
|
|| (!itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) && itemstack.getOrCreateTag().getInt("ammo") > itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag"))
|
||||||
) {
|
) {
|
||||||
|
|
||||||
int count = itemstack.getOrCreateTag().getInt("ammo") - itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") - (itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) ? 1 : 0);
|
int count = itemstack.getOrCreateTag().getInt("ammo") - itemstack.getOrCreateTag().getInt("mag") + itemstack.getOrCreateTag().getInt("customMag") - (itemstack.is(ModTags.Items.EXTRA_ONE_AMMO) ? 1 : 0);
|
||||||
|
|
||||||
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
|
||||||
if (itemstack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
if (itemstack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
|
@ -156,22 +152,8 @@ public abstract class GunItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleGunPerks(ItemStack stack) {
|
private void handleGunPerks(ItemStack stack) {
|
||||||
if (stack.getOrCreateTag().getInt("HealClipTime") > 0) {
|
reduceTagTime(stack, "HealClipTime", "KillClipReloadTime", "KillClipTime", "FourthTimesCharmTick", "HeadSeeker",
|
||||||
stack.getOrCreateTag().putInt("HealClipTime", Math.max(0, stack.getOrCreateTag().getInt("HealClipTime") - 1));
|
"DesperadoTime", "DesperadoTimePost");
|
||||||
}
|
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getInt("KillClipReloadTime") > 0) {
|
|
||||||
stack.getOrCreateTag().putInt("KillClipReloadTime", Math.max(0, stack.getOrCreateTag().getInt("KillClipReloadTime") - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getInt("KillClipTime") > 0) {
|
|
||||||
stack.getOrCreateTag().putInt("KillClipTime", Math.max(0, stack.getOrCreateTag().getInt("KillClipTime") - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getInt("FourthTimesCharmTick") > 0) {
|
|
||||||
stack.getOrCreateTag().putInt("FourthTimesCharmTick",
|
|
||||||
Math.max(0, stack.getOrCreateTag().getInt("FourthTimesCharmTick") - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PerkHelper.getItemPerkLevel(ModPerks.FOURTH_TIMES_CHARM.get(), stack) > 0) {
|
if (PerkHelper.getItemPerkLevel(ModPerks.FOURTH_TIMES_CHARM.get(), stack) > 0) {
|
||||||
int count = stack.getOrCreateTag().getInt("FourthTimesCharmCount");
|
int count = stack.getOrCreateTag().getInt("FourthTimesCharmCount");
|
||||||
|
@ -184,10 +166,6 @@ public abstract class GunItem extends Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getInt("HeadSeeker") > 0) {
|
|
||||||
stack.getOrCreateTag().putInt("HeadSeeker", Math.max(0, stack.getOrCreateTag().getInt("HeadSeeker") - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
int ctmMag = stack.getOrCreateTag().getInt("mag");
|
int ctmMag = stack.getOrCreateTag().getInt("mag");
|
||||||
if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
||||||
stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.1 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * ctmMag)));
|
stack.getOrCreateTag().putInt("customMag", (int) (Math.ceil(0.1 * PerkHelper.getItemPerkLevel(ModPerks.DIMENSION_MAGAZINE.get(), stack) * ctmMag)));
|
||||||
|
@ -201,4 +179,20 @@ public abstract class GunItem extends Item {
|
||||||
public boolean canApplyPerk(Perk perk) {
|
public boolean canApplyPerk(Perk perk) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reduceTagTime(ItemStack stack, String... tag) {
|
||||||
|
if (!stack.hasTag() || stack.getTag() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String t : tag) {
|
||||||
|
if (!stack.getTag().contains(t)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getOrCreateTag().getInt(t) > 0) {
|
||||||
|
stack.getOrCreateTag().putInt(t, Math.max(0, stack.getOrCreateTag().getInt(t) - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ public class PerkHelper {
|
||||||
}
|
}
|
||||||
case FUNCTIONAL -> {
|
case FUNCTIONAL -> {
|
||||||
return perk == ModPerks.HEAL_CLIP.get() || perk == ModPerks.FIELD_DOCTOR.get() ||
|
return perk == ModPerks.HEAL_CLIP.get() || perk == ModPerks.FIELD_DOCTOR.get() ||
|
||||||
perk == ModPerks.FOURTH_TIMES_CHARM.get() || perk == ModPerks.SUBSISTENCE.get();
|
perk == ModPerks.FOURTH_TIMES_CHARM.get() || perk == ModPerks.SUBSISTENCE.get() || perk == ModPerks.DESPERADO.get();
|
||||||
}
|
}
|
||||||
case DAMAGE -> {
|
case DAMAGE -> {
|
||||||
return perk == ModPerks.KILL_CLIP.get() || perk == ModPerks.GUTSHOT_STRAIGHT.get() ||
|
return perk == ModPerks.KILL_CLIP.get() || perk == ModPerks.GUTSHOT_STRAIGHT.get() ||
|
||||||
|
|
Loading…
Add table
Reference in a new issue