合并瞄准方法
This commit is contained in:
parent
0bdf98346d
commit
337708ac06
2 changed files with 12 additions and 23 deletions
|
@ -1,23 +0,0 @@
|
|||
package net.mcreator.target.event;
|
||||
|
||||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class AimingHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END && event.player != null) {
|
||||
ItemStack itemstack = event.player.getMainHandItem();
|
||||
|
||||
if (itemstack.is(TargetModTags.Items.GUN)) {
|
||||
itemstack.getOrCreateTag().putBoolean("aiming", event.player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).zooming);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,6 +54,7 @@ public class PlayerEventHandler {
|
|||
}
|
||||
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
handleAiming(player);
|
||||
handlePlayerProne(player);
|
||||
handlePlayerSprint(player);
|
||||
handleWeaponLevel(player);
|
||||
|
@ -72,6 +73,17 @@ public class PlayerEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断玩家是否瞄准
|
||||
*/
|
||||
private static void handleAiming(Player player) {
|
||||
ItemStack itemstack = player.getMainHandItem();
|
||||
|
||||
if (itemstack.is(TargetModTags.Items.GUN)) {
|
||||
itemstack.getOrCreateTag().putBoolean("aiming", player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).zooming);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断玩家是否趴下
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue