优化切枪音效取消写法
This commit is contained in:
parent
c23a46ee00
commit
c10572883c
1 changed files with 12 additions and 21 deletions
|
@ -138,31 +138,22 @@ public class LivingEntityEventHandler {
|
|||
ItemStack newStack = event.getTo();
|
||||
|
||||
if (oldStack.getItem() instanceof GunItem oldGun && player.level() instanceof ServerLevel serverLevel) {
|
||||
if (newStack.getItem() != oldStack.getItem()) {
|
||||
var newTag = newStack.getTag();
|
||||
var oldTag = oldStack.getTag();
|
||||
|
||||
if (newStack.getItem() != oldStack.getItem()
|
||||
|| newTag == null || oldTag == null
|
||||
|| !newTag.hasUUID("gun_uuid") || !oldTag.hasUUID("gun_uuid")
|
||||
|| !newTag.getUUID("gun_uuid").equals(oldTag.getUUID("gun_uuid"))
|
||||
) {
|
||||
stopGunReloadSound(serverLevel, oldGun);
|
||||
|
||||
newStack.getOrCreateTag().putDouble("draw", 1);
|
||||
if (newStack.getItem() instanceof GunItem) {
|
||||
newStack.getOrCreateTag().putDouble("draw", 1);
|
||||
}
|
||||
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.zoom = false;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.zooming = false;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
player.getPersistentData().putDouble("zoompos", 0);
|
||||
player.getPersistentData().putDouble("zoom_time", 0);
|
||||
|
||||
} else if (!newStack.getOrCreateTag().hasUUID("gun_uuid") || !oldStack.getOrCreateTag().hasUUID("gun_uuid") ||
|
||||
!newStack.getOrCreateTag().getUUID("gun_uuid").equals(oldStack.getOrCreateTag().getUUID("gun_uuid"))) {
|
||||
stopGunReloadSound(serverLevel, oldGun);
|
||||
|
||||
newStack.getOrCreateTag().putDouble("draw", 1);
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.zoom = false;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.zooming = false;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue