修复了装填的崩溃问题
This commit is contained in:
parent
b8c87ef8ba
commit
525b960e89
7 changed files with 43 additions and 102 deletions
|
@ -97,13 +97,12 @@ public class TargetMod {
|
||||||
addNetworkMessage(FireMessage.class, FireMessage::buffer, FireMessage::new, FireMessage::handler);
|
addNetworkMessage(FireMessage.class, FireMessage::buffer, FireMessage::new, FireMessage::handler);
|
||||||
addNetworkMessage(FireModeMessage.class, FireModeMessage::buffer, FireModeMessage::new, FireModeMessage::handler);
|
addNetworkMessage(FireModeMessage.class, FireModeMessage::buffer, FireModeMessage::new, FireModeMessage::handler);
|
||||||
addNetworkMessage(GunRecycleGuiButtonMessage.class, GunRecycleGuiButtonMessage::buffer, GunRecycleGuiButtonMessage::new, GunRecycleGuiButtonMessage::handler);
|
addNetworkMessage(GunRecycleGuiButtonMessage.class, GunRecycleGuiButtonMessage::buffer, GunRecycleGuiButtonMessage::new, GunRecycleGuiButtonMessage::handler);
|
||||||
addNetworkMessage(ReloadMessage.class, ReloadMessage::buffer, ReloadMessage::new, ReloadMessage::handler);
|
addNetworkMessage(ReloadMessage.class, ReloadMessage::encode, ReloadMessage::decode, ReloadMessage::handler);
|
||||||
addNetworkMessage(PlayerGunKillMessage.class, PlayerGunKillMessage::encode, PlayerGunKillMessage::decode, PlayerGunKillMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(PlayerGunKillMessage.class, PlayerGunKillMessage::encode, PlayerGunKillMessage::decode, PlayerGunKillMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
addNetworkMessage(ClientIndicatorMessage.class, ClientIndicatorMessage::encode, ClientIndicatorMessage::decode, ClientIndicatorMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
addNetworkMessage(ClientIndicatorMessage.class, ClientIndicatorMessage::encode, ClientIndicatorMessage::decode, ClientIndicatorMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||||
addNetworkMessage(SensitivityMessage.class, SensitivityMessage::encode, SensitivityMessage::decode, SensitivityMessage::handler);
|
addNetworkMessage(SensitivityMessage.class, SensitivityMessage::encode, SensitivityMessage::decode, SensitivityMessage::handler);
|
||||||
addNetworkMessage(AdjustZoomFovMessage.class, AdjustZoomFovMessage::encode, AdjustZoomFovMessage::decode, AdjustZoomFovMessage::handler);
|
addNetworkMessage(AdjustZoomFovMessage.class, AdjustZoomFovMessage::encode, AdjustZoomFovMessage::decode, AdjustZoomFovMessage::handler);
|
||||||
addNetworkMessage(AdjustMortarAngleMessage.class, AdjustMortarAngleMessage::encode, AdjustMortarAngleMessage::decode, AdjustMortarAngleMessage::handler);
|
addNetworkMessage(AdjustMortarAngleMessage.class, AdjustMortarAngleMessage::encode, AdjustMortarAngleMessage::decode, AdjustMortarAngleMessage::handler);
|
||||||
addNetworkMessage(GunReloadResultMessage.class, GunReloadResultMessage::encode, GunReloadResultMessage::decode, GunReloadResultMessage::handler);
|
|
||||||
|
|
||||||
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
||||||
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), TargetModPotion.SHOCK.get())));
|
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), TargetModPotion.SHOCK.get())));
|
||||||
|
|
|
@ -356,25 +356,25 @@ public class GunEventHandler {
|
||||||
//启动换弹
|
//启动换弹
|
||||||
if (tag.getBoolean("start_reload")) {
|
if (tag.getBoolean("start_reload")) {
|
||||||
if (stack.is(TargetModTags.Items.OPEN_BOLT)) {
|
if (stack.is(TargetModTags.Items.OPEN_BOLT)) {
|
||||||
if(tag.getInt("ammo") == 0) {
|
if (tag.getInt("ammo") == 0) {
|
||||||
tag.putInt("gun_reloading_time",(int)tag.getDouble("empty_reload_time"));
|
tag.putInt("gun_reloading_time", (int) tag.getDouble("empty_reload_time"));
|
||||||
stack.getOrCreateTag().putBoolean("is_empty_reloading",true);
|
stack.getOrCreateTag().putBoolean("is_empty_reloading", true);
|
||||||
playGunEmptyReloadSounds(player);
|
playGunEmptyReloadSounds(player);
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("gun_reloading_time",(int)tag.getDouble("normal_reload_time"));
|
tag.putInt("gun_reloading_time", (int) tag.getDouble("normal_reload_time"));
|
||||||
stack.getOrCreateTag().putBoolean("is_normal_reloading",true);
|
stack.getOrCreateTag().putBoolean("is_normal_reloading", true);
|
||||||
playGunNormalReloadSounds(player);
|
playGunNormalReloadSounds(player);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tag.putInt("gun_reloading_time",(int)tag.getDouble("empty_reload_time"));
|
tag.putInt("gun_reloading_time", (int) tag.getDouble("empty_reload_time"));
|
||||||
stack.getOrCreateTag().putBoolean("is_empty_reloading",true);
|
stack.getOrCreateTag().putBoolean("is_empty_reloading", true);
|
||||||
playGunEmptyReloadSounds(player);
|
playGunEmptyReloadSounds(player);
|
||||||
}
|
}
|
||||||
tag.putBoolean("start_reload",false);
|
tag.putBoolean("start_reload", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("gun_reloading_time") > 0) {
|
if (tag.getInt("gun_reloading_time") > 0) {
|
||||||
tag.putInt("gun_reloading_time",tag.getInt("gun_reloading_time") - 1);
|
tag.putInt("gun_reloading_time", tag.getInt("gun_reloading_time") - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getItem() == TargetModItems.RPG.get()) {
|
if (stack.getItem() == TargetModItems.RPG.get()) {
|
||||||
|
@ -384,7 +384,6 @@ public class GunEventHandler {
|
||||||
if (tag.getInt("gun_reloading_time") == 7) {
|
if (tag.getInt("gun_reloading_time") == 7) {
|
||||||
tag.putBoolean("close_hammer", false);
|
tag.putBoolean("close_hammer", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getItem() == TargetModItems.MK_14.get()) {
|
if (stack.getItem() == TargetModItems.MK_14.get()) {
|
||||||
|
@ -407,7 +406,7 @@ public class GunEventHandler {
|
||||||
|
|
||||||
if (tag.getInt("gun_reloading_time") == 1) {
|
if (tag.getInt("gun_reloading_time") == 1) {
|
||||||
if (stack.is(TargetModTags.Items.OPEN_BOLT)) {
|
if (stack.is(TargetModTags.Items.OPEN_BOLT)) {
|
||||||
if(tag.getInt("ammo") == 0) {
|
if (tag.getInt("ammo") == 0) {
|
||||||
playGunEmptyReload(player);
|
playGunEmptyReload(player);
|
||||||
} else {
|
} else {
|
||||||
playGunNormalReload(player);
|
playGunNormalReload(player);
|
||||||
|
@ -417,32 +416,32 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void playGunNormalReload(Player player) {
|
|
||||||
|
|
||||||
|
public static void playGunNormalReload(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (stack.is(TargetModTags.Items.SHOTGUN)) {
|
if (stack.is(TargetModTags.Items.SHOTGUN)) {
|
||||||
if (stack.getItem() == TargetModItems.ABEKIRI.get()) {
|
if (stack.getItem() == TargetModItems.ABEKIRI.get()) {
|
||||||
GunsTool.reload(player, GunInfo.Type.SHOTGUN);
|
GunsTool.reload(player, GunInfo.Type.SHOTGUN);
|
||||||
} else {
|
} else {
|
||||||
GunsTool.reload(player, GunInfo.Type.SHOTGUN ,true);
|
GunsTool.reload(player, GunInfo.Type.SHOTGUN, true);
|
||||||
}
|
}
|
||||||
} else if (stack.is(TargetModTags.Items.SNIPER_RIFLE)) {
|
} else if (stack.is(TargetModTags.Items.SNIPER_RIFLE)) {
|
||||||
GunsTool.reload(player, GunInfo.Type.SNIPER ,true);
|
GunsTool.reload(player, GunInfo.Type.SNIPER, true);
|
||||||
} else if (stack.is(TargetModTags.Items.HANDGUN) || stack.is(TargetModTags.Items.SMG)) {
|
} else if (stack.is(TargetModTags.Items.HANDGUN) || stack.is(TargetModTags.Items.SMG)) {
|
||||||
GunsTool.reload(player, GunInfo.Type.HANDGUN ,true);
|
GunsTool.reload(player, GunInfo.Type.HANDGUN, true);
|
||||||
} else if (stack.is(TargetModTags.Items.RIFLE)) {
|
} else if (stack.is(TargetModTags.Items.RIFLE)) {
|
||||||
if (stack.getItem() == TargetModItems.M_60.get()) {
|
if (stack.getItem() == TargetModItems.M_60.get()) {
|
||||||
GunsTool.reload(player, GunInfo.Type.RIFLE);
|
GunsTool.reload(player, GunInfo.Type.RIFLE);
|
||||||
} else {
|
} else {
|
||||||
GunsTool.reload(player, GunInfo.Type.RIFLE ,true);
|
GunsTool.reload(player, GunInfo.Type.RIFLE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stack.getOrCreateTag().putBoolean("is_normal_reloading", false);
|
stack.getOrCreateTag().putBoolean("is_normal_reloading", false);
|
||||||
stack.getOrCreateTag().putBoolean("is_empty_reloading", false);
|
stack.getOrCreateTag().putBoolean("is_empty_reloading", false);
|
||||||
}
|
}
|
||||||
public static void playGunEmptyReload(Player player) {
|
|
||||||
|
|
||||||
|
public static void playGunEmptyReload(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (stack.is(TargetModTags.Items.SHOTGUN)) {
|
if (stack.is(TargetModTags.Items.SHOTGUN)) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ public class TargetModKeyMappings {
|
||||||
super.setDown(isDown);
|
super.setDown(isDown);
|
||||||
if (isDownOld != isDown && isDown && Minecraft.getInstance().player != null) {
|
if (isDownOld != isDown && isDown && Minecraft.getInstance().player != null) {
|
||||||
TargetMod.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
TargetMod.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
||||||
ReloadMessage.pressAction(Minecraft.getInstance().player, 0);
|
|
||||||
}
|
}
|
||||||
isDownOld = isDown;
|
isDownOld = isDown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package net.mcreator.target.network.message;
|
package net.mcreator.target.network.message;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModItems;
|
|
||||||
import net.mcreator.target.init.TargetModSounds;
|
import net.mcreator.target.init.TargetModSounds;
|
||||||
import net.mcreator.target.init.TargetModTags;
|
import net.mcreator.target.init.TargetModTags;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -9,10 +8,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
@ -60,11 +56,10 @@ public class FireModeMessage {
|
||||||
public static void changeFireMode(Player player) {
|
public static void changeFireMode(Player player) {
|
||||||
ItemStack mainHandItem = player.getMainHandItem();
|
ItemStack mainHandItem = player.getMainHandItem();
|
||||||
CompoundTag tag = mainHandItem.getOrCreateTag();
|
CompoundTag tag = mainHandItem.getOrCreateTag();
|
||||||
Item item = mainHandItem.getItem();
|
|
||||||
int fireMode = tag.getInt("fire_mode");
|
int fireMode = tag.getInt("fire_mode");
|
||||||
|
|
||||||
if (mainHandItem.is(TargetModTags.Items.GUN)) {
|
if (mainHandItem.is(TargetModTags.Items.GUN)) {
|
||||||
if (tag.getInt("fire_mode") == 0) {
|
if (fireMode == 0) {
|
||||||
if (tag.getDouble("burst") == 1) {
|
if (tag.getDouble("burst") == 1) {
|
||||||
tag.putInt("fire_mode", 1);
|
tag.putInt("fire_mode", 1);
|
||||||
setFireMode(player, tag);
|
setFireMode(player, tag);
|
||||||
|
@ -76,7 +71,7 @@ public class FireModeMessage {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tag.getInt("fire_mode") == 1) {
|
if (fireMode == 1) {
|
||||||
if (tag.getDouble("auto") == 1) {
|
if (tag.getDouble("auto") == 1) {
|
||||||
tag.putInt("fire_mode", 2);
|
tag.putInt("fire_mode", 2);
|
||||||
setFireMode(player, tag);
|
setFireMode(player, tag);
|
||||||
|
@ -88,7 +83,7 @@ public class FireModeMessage {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tag.getInt("fire_mode") == 2) {
|
if (fireMode == 2) {
|
||||||
if (tag.getDouble("semi") == 1) {
|
if (tag.getDouble("semi") == 1) {
|
||||||
tag.putInt("fire_mode", 0);
|
tag.putInt("fire_mode", 0);
|
||||||
setFireMode(player, tag);
|
setFireMode(player, tag);
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package net.mcreator.target.network.message;
|
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModTags;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class GunReloadResultMessage {
|
|
||||||
private final int need_to_add;
|
|
||||||
|
|
||||||
public GunReloadResultMessage(int need_to_add) {
|
|
||||||
this.need_to_add = need_to_add;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void encode(GunReloadResultMessage message, FriendlyByteBuf byteBuf) {
|
|
||||||
byteBuf.writeInt(message.need_to_add);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GunReloadResultMessage decode(FriendlyByteBuf byteBuf) {
|
|
||||||
return new GunReloadResultMessage(byteBuf.readInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handler(GunReloadResultMessage message, Supplier<NetworkEvent.Context> context) {
|
|
||||||
context.get().enqueueWork(() -> {
|
|
||||||
ServerPlayer player = context.get().getSender();
|
|
||||||
if (player == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
if (!stack.is(TargetModTags.Items.GUN)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var tag = stack.getOrCreateTag();
|
|
||||||
|
|
||||||
tag.putInt("ammo", message.need_to_add);
|
|
||||||
tag.putBoolean("is_normal_reloading", false);
|
|
||||||
tag.putBoolean("is_empty_reloading", false);
|
|
||||||
});
|
|
||||||
context.get().setPacketHandled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ package net.mcreator.target.network.message;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.mcreator.target.init.TargetModTags;
|
import net.mcreator.target.init.TargetModTags;
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
import net.mcreator.target.procedures.PlayerReloadProcedure;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -20,11 +19,11 @@ public class ReloadMessage {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReloadMessage(FriendlyByteBuf buffer) {
|
public static ReloadMessage decode(FriendlyByteBuf buffer) {
|
||||||
this.type = buffer.readInt();
|
return new ReloadMessage(buffer.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void buffer(ReloadMessage message, FriendlyByteBuf buffer) {
|
public static void encode(ReloadMessage message, FriendlyByteBuf buffer) {
|
||||||
buffer.writeInt(message.type);
|
buffer.writeInt(message.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,30 +37,25 @@ public class ReloadMessage {
|
||||||
context.setPacketHandled(true);
|
context.setPacketHandled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pressAction(Player entity, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
Level world = entity.level();
|
Level level = player.level();
|
||||||
|
|
||||||
if (!world.hasChunkAt(entity.blockPosition()))
|
if (!level.isLoaded(player.blockPosition()))
|
||||||
return;
|
return;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
// PlayerReloadProcedure.execute(entity);
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
var capability = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables());
|
||||||
|
|
||||||
ItemStack stack = entity.getMainHandItem();
|
if (!player.isSpectator()
|
||||||
var capability = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables());
|
&& stack.is(TargetModTags.Items.GUN)
|
||||||
|
&& !capability.zooming
|
||||||
if (!entity.isSpectator()
|
&& !(player.getCooldowns().isOnCooldown(stack.getItem()))
|
||||||
&& stack.is(TargetModTags.Items.GUN)
|
&& (stack.getOrCreateTag().getInt("gun_reloading_time") == 0)
|
||||||
&& !capability.zooming
|
|
||||||
&& !(entity.getCooldowns().isOnCooldown(stack.getItem()))
|
|
||||||
&& (stack.getOrCreateTag().getInt("gun_reloading_time") == 0)
|
|
||||||
) {
|
) {
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
|
|
||||||
boolean can_reload = false;
|
boolean can_reload = tag.getDouble("normal_reload_time") != 0 || tag.getDouble("empty_reload_time") != 0;
|
||||||
|
|
||||||
if (tag.getDouble("normal_reload_time") != 0 || tag.getDouble("empty_reload_time") != 0) {
|
|
||||||
can_reload = true;
|
|
||||||
}
|
|
||||||
//检查备弹
|
//检查备弹
|
||||||
if (stack.is(TargetModTags.Items.SHOTGUN) && capability.shotgunAmmo == 0) {
|
if (stack.is(TargetModTags.Items.SHOTGUN) && capability.shotgunAmmo == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -82,15 +76,15 @@ public class ReloadMessage {
|
||||||
if (stack.is(TargetModTags.Items.OPEN_BOLT) && can_reload) {
|
if (stack.is(TargetModTags.Items.OPEN_BOLT) && can_reload) {
|
||||||
if (stack.getItem() == TargetModItems.M_60.get() || stack.getItem() == TargetModItems.ABEKIRI.get()) {
|
if (stack.getItem() == TargetModItems.M_60.get() || stack.getItem() == TargetModItems.ABEKIRI.get()) {
|
||||||
if (tag.getInt("ammo") < tag.getDouble("mag")) {
|
if (tag.getInt("ammo") < tag.getDouble("mag")) {
|
||||||
tag.putBoolean("start_reload",true);
|
tag.putBoolean("start_reload", true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tag.getInt("ammo") < tag.getDouble("mag") + 1) {
|
if (tag.getInt("ammo") < tag.getDouble("mag") + 1) {
|
||||||
tag.putBoolean("start_reload",true);
|
tag.putBoolean("start_reload", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tag.getInt("ammo") < tag.getDouble("mag")){
|
} else if (tag.getInt("ammo") < tag.getDouble("mag")) {
|
||||||
tag.putBoolean("start_reload",true);
|
tag.putBoolean("start_reload", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ package net.mcreator.target.tools;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import net.mcreator.target.TargetMod;
|
import net.mcreator.target.TargetMod;
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
import net.mcreator.target.network.message.AdjustMortarAngleMessage;
|
|
||||||
import net.mcreator.target.network.message.GunReloadResultMessage;
|
|
||||||
import net.mcreator.target.network.message.GunsDataMessage;
|
import net.mcreator.target.network.message.GunsDataMessage;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
@ -133,7 +131,10 @@ public class GunsTool {
|
||||||
capability.syncPlayerVariables(entity);
|
capability.syncPlayerVariables(entity);
|
||||||
});
|
});
|
||||||
|
|
||||||
int need_to_add = ammo + Math.min(ammoToAdd, playerAmmo);
|
int needToAdd = ammo + Math.min(ammoToAdd, playerAmmo);
|
||||||
TargetMod.PACKET_HANDLER.sendToServer(new GunReloadResultMessage(need_to_add));
|
|
||||||
|
tag.putInt("ammo", needToAdd);
|
||||||
|
tag.putBoolean("is_normal_reloading", false);
|
||||||
|
tag.putBoolean("is_empty_reloading", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue