移动事件位置
This commit is contained in:
parent
7c27fc02b5
commit
23b8588a53
5 changed files with 23 additions and 18 deletions
|
@ -1,14 +1,16 @@
|
|||
package com.atsuishio.superbwarfare.event.events;
|
||||
package com.atsuishio.superbwarfare.api.event;
|
||||
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.bus.api.ICancellableEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* 玩家击杀生物后,用于判断是否发送击杀播报/显示击杀指示
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public class PreKillEvent extends Event implements ICancellableEvent {
|
||||
|
||||
private final Player player;
|
|
@ -1,29 +1,34 @@
|
|||
package com.atsuishio.superbwarfare.event.events;
|
||||
package com.atsuishio.superbwarfare.api.event;
|
||||
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.bus.api.ICancellableEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ReloadEvent extends Event implements ICancellableEvent {
|
||||
|
||||
public final Player player;
|
||||
public final GunData data;
|
||||
public final ItemStack stack;
|
||||
|
||||
private ReloadEvent(Player player, ItemStack stack) {
|
||||
private ReloadEvent(Player player, GunData data) {
|
||||
this.player = player;
|
||||
this.stack = stack;
|
||||
this.data = data;
|
||||
this.stack = data.stack();
|
||||
}
|
||||
|
||||
public static class Pre extends ReloadEvent {
|
||||
public Pre(Player player, ItemStack stack) {
|
||||
super(player, stack);
|
||||
public Pre(Player player, GunData data) {
|
||||
super(player, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Post extends ReloadEvent {
|
||||
public Post(Player player, ItemStack stack) {
|
||||
super(player, stack);
|
||||
public Post(Player player, GunData data) {
|
||||
super(player, data);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.event;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.event.events.ReloadEvent;
|
||||
import com.atsuishio.superbwarfare.api.event.ReloadEvent;
|
||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
|
@ -103,7 +103,7 @@ public class GunEventHandler {
|
|||
|
||||
// 启动换弹
|
||||
if (reload.reloadStarter.start()) {
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack));
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, data));
|
||||
|
||||
if (gunItem.isOpenBolt(stack)) {
|
||||
if (data.ammo.get() == 0) {
|
||||
|
@ -161,18 +161,16 @@ public class GunEventHandler {
|
|||
}
|
||||
}
|
||||
data.reload.setState(ReloadState.NOT_RELOADING);
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, data));
|
||||
}
|
||||
|
||||
public static void playGunEmptyReload(Player player, GunData data) {
|
||||
ItemStack stack = data.stack();
|
||||
|
||||
if (player.getInventory().hasAnyMatching(item -> item.is(ModItems.CREATIVE_AMMO_BOX.get()))) {
|
||||
data.ammo.set(data.magazine());
|
||||
} else {
|
||||
data.reload(player);
|
||||
}
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, data));
|
||||
}
|
||||
|
||||
public static void playGunEmptyReloadSounds(Player player) {
|
||||
|
@ -231,7 +229,7 @@ public class GunEventHandler {
|
|||
|
||||
// 一阶段
|
||||
if (reload.singleReloadStarter.start()) {
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, stack));
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Pre(player, data));
|
||||
|
||||
if ((data.defaultPrepareLoadTime() != 0 && data.ammo.get() == 0) || stack.is(ModItems.SECONDARY_CATACLYSM.get())) {
|
||||
// 此处判断空仓换弹的时候,是否在准备阶段就需要装填一发,如M870
|
||||
|
@ -353,7 +351,7 @@ public class GunEventHandler {
|
|||
reload.setState(ReloadState.NOT_RELOADING);
|
||||
reload.singleReloadStarter.finish();
|
||||
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, stack));
|
||||
NeoForge.EVENT_BUS.post(new ReloadEvent.Post(player, data));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.event;
|
||||
|
||||
import com.atsuishio.superbwarfare.api.event.PreKillEvent;
|
||||
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||
import com.atsuishio.superbwarfare.config.common.GameplayConfig;
|
||||
import com.atsuishio.superbwarfare.config.server.MiscConfig;
|
||||
|
@ -11,7 +12,6 @@ import com.atsuishio.superbwarfare.entity.vehicle.LaserTowerEntity;
|
|||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.event.events.PreKillEvent;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
import com.atsuishio.superbwarfare.item.common.ammo.box.AmmoBoxInfo;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.event;
|
||||
|
||||
import com.atsuishio.superbwarfare.event.events.ReloadEvent;
|
||||
import com.atsuishio.superbwarfare.api.event.ReloadEvent;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
|
|
Loading…
Add table
Reference in a new issue