添加瞄准冷却
This commit is contained in:
parent
f30c0e385c
commit
ba3ad15c0b
2 changed files with 42 additions and 31 deletions
|
@ -8,10 +8,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.*;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.network.message.LaserShootMessage;
|
import com.atsuishio.superbwarfare.network.message.*;
|
||||||
import com.atsuishio.superbwarfare.network.message.LungeMineAttackMessage;
|
|
||||||
import com.atsuishio.superbwarfare.network.message.ShootMessage;
|
|
||||||
import com.atsuishio.superbwarfare.network.message.VehicleFireMessage;
|
|
||||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
|
@ -31,6 +28,7 @@ import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.HumanoidArm;
|
import net.minecraft.world.entity.HumanoidArm;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.npc.AbstractVillager;
|
||||||
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.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
|
@ -54,6 +52,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@ -146,6 +145,7 @@ public class ClientEventHandler {
|
||||||
public static Entity entity;
|
public static Entity entity;
|
||||||
|
|
||||||
public static int dismountCountdown = 0;
|
public static int dismountCountdown = 0;
|
||||||
|
public static int aimVillagerCountdown = 0;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void handleWeaponTurn(RenderHandEvent event) {
|
public static void handleWeaponTurn(RenderHandEvent event) {
|
||||||
|
@ -208,6 +208,21 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notInGame() && !ClickHandler.switchZoom) {
|
||||||
|
zoom = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
isProne(player);
|
||||||
|
beamShoot(player, stack);
|
||||||
|
handleLungeAttack(player, stack);
|
||||||
|
|
||||||
|
if (event.phase == TickEvent.Phase.END) {
|
||||||
|
handleVariableDecrease();
|
||||||
|
aimAtVillager(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleVariableDecrease() {
|
||||||
if (miniGunRot > 0) {
|
if (miniGunRot > 0) {
|
||||||
miniGunRot--;
|
miniGunRot--;
|
||||||
}
|
}
|
||||||
|
@ -216,13 +231,9 @@ public class ClientEventHandler {
|
||||||
dismountCountdown--;
|
dismountCountdown--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notInGame() && !ClickHandler.switchZoom) {
|
if (aimVillagerCountdown > 0) {
|
||||||
zoom = false;
|
aimVillagerCountdown--;
|
||||||
}
|
}
|
||||||
|
|
||||||
isProne(player);
|
|
||||||
beamShoot(player, stack);
|
|
||||||
handleLungeAttack(player, stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProne(Player player) {
|
public static boolean isProne(Player player) {
|
||||||
|
@ -1370,4 +1381,21 @@ public class ClientEventHandler {
|
||||||
shells[i].setRotY((float) (randomShell[2] * shellIndexTime[i]));
|
shells[i].setRotY((float) (randomShell[2] * shellIndexTime[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void aimAtVillager(Player player) {
|
||||||
|
if (aimVillagerCountdown > 0) return;
|
||||||
|
|
||||||
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom) {
|
||||||
|
Entity entity = TraceTool.findLookingEntity(player, 10);
|
||||||
|
if (entity instanceof AbstractVillager villager) {
|
||||||
|
List<Entity> entities = SeekTool.seekLivingEntities(villager, villager.level(), 16, 120);
|
||||||
|
for (var e : entities) {
|
||||||
|
if (e == player) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new AimVillagerMessage(villager.getId()));
|
||||||
|
aimVillagerCountdown = 80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@ import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.network.message.AimVillagerMessage;
|
|
||||||
import com.atsuishio.superbwarfare.network.message.SimulationDistanceMessage;
|
import com.atsuishio.superbwarfare.network.message.SimulationDistanceMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.*;
|
import com.atsuishio.superbwarfare.tools.GunInfo;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
@ -16,9 +17,7 @@ import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.npc.AbstractVillager;
|
|
||||||
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.minecraftforge.event.AnvilUpdateEvent;
|
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||||
|
@ -28,8 +27,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class PlayerEventHandler {
|
public class PlayerEventHandler {
|
||||||
|
|
||||||
|
@ -88,7 +85,7 @@ public class PlayerEventHandler {
|
||||||
handlePlayerSprint(player);
|
handlePlayerSprint(player);
|
||||||
handleSpecialWeaponAmmo(player);
|
handleSpecialWeaponAmmo(player);
|
||||||
handleBocekPulling(player);
|
handleBocekPulling(player);
|
||||||
aimAtVillager(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGround(player);
|
handleGround(player);
|
||||||
|
@ -98,20 +95,6 @@ public class PlayerEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void aimAtVillager(Player player) {
|
|
||||||
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom) {
|
|
||||||
Entity entity = TraceTool.findLookingEntity(player, 10);
|
|
||||||
if (entity instanceof AbstractVillager villager) {
|
|
||||||
List<Entity> entities = SeekTool.seekLivingEntities(villager, villager.level(), 16, 120);
|
|
||||||
for (var e : entities) {
|
|
||||||
if (e == player) {
|
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new AimVillagerMessage(villager.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleBreath(Player player) {
|
private static void handleBreath(Player player) {
|
||||||
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath) {
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue