将isEditing改为纯客户端
This commit is contained in:
parent
d7b1afe9ba
commit
a710b6b807
30 changed files with 122 additions and 217 deletions
|
@ -8,7 +8,6 @@ import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.neoforge.common.util.INBTSerializable;
|
import net.neoforged.neoforge.common.util.INBTSerializable;
|
||||||
|
@ -19,7 +18,6 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
|
|
||||||
@EventBusSubscriber(modid = Mod.MODID)
|
@EventBusSubscriber(modid = Mod.MODID)
|
||||||
|
@ -28,7 +26,6 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
|
|
||||||
public Map<Ammo, Integer> ammo = new HashMap<>();
|
public Map<Ammo, Integer> ammo = new HashMap<>();
|
||||||
public boolean tacticalSprint = false;
|
public boolean tacticalSprint = false;
|
||||||
public boolean edit = false;
|
|
||||||
|
|
||||||
public void sync(Entity entity) {
|
public void sync(Entity entity) {
|
||||||
if (!entity.hasData(ModAttachments.PLAYER_VARIABLE)) return;
|
if (!entity.hasData(ModAttachments.PLAYER_VARIABLE)) return;
|
||||||
|
@ -41,10 +38,6 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEditing(Entity entity) {
|
|
||||||
return entity.getData(ModAttachments.PLAYER_VARIABLE).edit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
if (!(event.getEntity() instanceof ServerPlayer player)) return;
|
if (!(event.getEntity() instanceof ServerPlayer player)) return;
|
||||||
|
@ -79,7 +72,6 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
}
|
}
|
||||||
|
|
||||||
map.put((byte) -1, this.tacticalSprint ? 1 : 0);
|
map.put((byte) -1, this.tacticalSprint ? 1 : 0);
|
||||||
map.put((byte) -2, this.edit ? 1 : 0);
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -100,22 +92,10 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
if (old.tacticalSprint != this.tacticalSprint) {
|
if (old.tacticalSprint != this.tacticalSprint) {
|
||||||
map.put((byte) -1, this.tacticalSprint ? 1 : 0);
|
map.put((byte) -1, this.tacticalSprint ? 1 : 0);
|
||||||
}
|
}
|
||||||
if (old.edit != this.edit) {
|
|
||||||
map.put((byte) -2, this.edit ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑并同步玩家变量
|
|
||||||
*/
|
|
||||||
public void modify(Player player, Consumer<PlayerVariable> consumer) {
|
|
||||||
watch();
|
|
||||||
consumer.accept(this);
|
|
||||||
sync(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public CompoundTag writeToNBT() {
|
public CompoundTag writeToNBT() {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundTag nbt = new CompoundTag();
|
||||||
|
@ -125,20 +105,17 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
}
|
}
|
||||||
|
|
||||||
nbt.putBoolean("TacticalSprint", tacticalSprint);
|
nbt.putBoolean("TacticalSprint", tacticalSprint);
|
||||||
nbt.putBoolean("EditMode", edit);
|
|
||||||
|
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerVariable readFromNBT(CompoundTag tag) {
|
public void readFromNBT(CompoundTag tag) {
|
||||||
for (var type : Ammo.values()) {
|
for (var type : Ammo.values()) {
|
||||||
type.set(this, type.get(tag));
|
type.set(this, type.get(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
tacticalSprint = tag.getBoolean("TacticalSprint");
|
tacticalSprint = tag.getBoolean("TacticalSprint");
|
||||||
edit = tag.getBoolean("EditMode");
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerVariable copy() {
|
public PlayerVariable copy() {
|
||||||
|
@ -148,7 +125,6 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
type.set(clone, type.get(this));
|
type.set(clone, type.get(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
clone.edit = this.edit;
|
|
||||||
clone.tacticalSprint = this.tacticalSprint;
|
clone.tacticalSprint = this.tacticalSprint;
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
|
@ -162,8 +138,7 @@ public class PlayerVariable implements INBTSerializable<CompoundTag> {
|
||||||
if (type.get(this) != type.get(other)) return false;
|
if (type.get(this) != type.get(other)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tacticalSprint == other.tacticalSprint
|
return tacticalSprint == other.tacticalSprint;
|
||||||
&& edit == other.edit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -44,7 +44,7 @@ import static com.atsuishio.superbwarfare.event.ClientEventHandler.*;
|
||||||
|
|
||||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
|
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
|
||||||
public class ClickHandler {
|
public class ClickHandler {
|
||||||
|
public static boolean isEditing = false;
|
||||||
public static boolean switchZoom = false;
|
public static boolean switchZoom = false;
|
||||||
|
|
||||||
private static boolean notInGame() {
|
private static boolean notInGame() {
|
||||||
|
@ -211,6 +211,7 @@ public class ClickHandler {
|
||||||
|
|
||||||
if (key == ModKeyMappings.RELOAD.getKey().getValue()) {
|
if (key == ModKeyMappings.RELOAD.getKey().getValue()) {
|
||||||
ClientEventHandler.burstFireAmount = 0;
|
ClientEventHandler.burstFireAmount = 0;
|
||||||
|
ClickHandler.isEditing = false;
|
||||||
PacketDistributor.sendToServer(new ReloadMessage(0));
|
PacketDistributor.sendToServer(new ReloadMessage(0));
|
||||||
}
|
}
|
||||||
if (key == ModKeyMappings.FIRE_MODE.getKey().getValue()) {
|
if (key == ModKeyMappings.FIRE_MODE.getKey().getValue()) {
|
||||||
|
@ -224,14 +225,15 @@ public class ClickHandler {
|
||||||
}
|
}
|
||||||
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue() && ClientEventHandler.burstFireAmount == 0) {
|
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue() && ClientEventHandler.burstFireAmount == 0) {
|
||||||
ClientEventHandler.holdFire = false;
|
ClientEventHandler.holdFire = false;
|
||||||
PacketDistributor.sendToServer(new EditModeMessage(0));
|
isEditing = true;
|
||||||
|
player.playSound(ModSounds.EDIT_MODE.get(), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == ModKeyMappings.BREATH.getKey().getValue() && !exhaustion && zoom) {
|
if (key == ModKeyMappings.BREATH.getKey().getValue() && !exhaustion && zoom) {
|
||||||
breath = true;
|
breath = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (isEditing) {
|
||||||
if (!(stack.getItem() instanceof GunItem gunItem)) return;
|
if (!(stack.getItem() instanceof GunItem gunItem)) return;
|
||||||
if (ModKeyMappings.EDIT_GRIP.getKeyModifier().isActive(KeyConflictContext.IN_GAME)) {
|
if (ModKeyMappings.EDIT_GRIP.getKeyModifier().isActive(KeyConflictContext.IN_GAME)) {
|
||||||
if (key == ModKeyMappings.EDIT_GRIP.getKey().getValue() && gunItem.hasCustomGrip(stack)) {
|
if (key == ModKeyMappings.EDIT_GRIP.getKey().getValue() && gunItem.hasCustomGrip(stack)) {
|
||||||
|
@ -305,6 +307,7 @@ public class ClickHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleWeaponFirePress(Player player, ItemStack stack) {
|
public static void handleWeaponFirePress(Player player, ItemStack stack) {
|
||||||
|
isEditing = false;
|
||||||
if (player.hasEffect(ModMobEffects.SHOCK)) return;
|
if (player.hasEffect(ModMobEffects.SHOCK)) return;
|
||||||
|
|
||||||
if (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get())) {
|
if (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get())) {
|
||||||
|
@ -373,12 +376,15 @@ public class ClickHandler {
|
||||||
bowPull = false;
|
bowPull = false;
|
||||||
holdFire = false;
|
holdFire = false;
|
||||||
holdFireVehicle = false;
|
holdFireVehicle = false;
|
||||||
|
isEditing = false;
|
||||||
customRpm = 0;
|
customRpm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
||||||
PacketDistributor.sendToServer(new ZoomMessage(0));
|
PacketDistributor.sendToServer(new ZoomMessage(0));
|
||||||
|
|
||||||
|
ClickHandler.isEditing = false;
|
||||||
|
|
||||||
if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player)) && iVehicle.banHand(player)) {
|
if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player)) && iVehicle.banHand(player)) {
|
||||||
ClientEventHandler.zoomVehicle = true;
|
ClientEventHandler.zoomVehicle = true;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.atsuishio.superbwarfare.client.overlay;
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -62,8 +62,8 @@ public class CrossHairOverlay implements LayeredDraw.Layer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) return;
|
if (ClickHandler.isEditing)
|
||||||
|
return;
|
||||||
if (!player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player)))
|
if (!player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.atsuishio.superbwarfare.client.overlay;
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
@ -34,9 +34,8 @@ public class GrenadeLauncherOverlay implements LayeredDraw.Layer {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
if (ClickHandler.isEditing)
|
||||||
if (cap.edit) return;
|
return;
|
||||||
|
|
||||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
return;
|
return;
|
||||||
if (!shouldRenderCrossHair(player)) return;
|
if (!shouldRenderCrossHair(player)) return;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.atsuishio.superbwarfare.client.overlay;
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -45,9 +45,11 @@ public class HandsomeFrameOverlay implements LayeredDraw.Layer {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
PoseStack poseStack = guiGraphics.pose();
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
|
|
||||||
if (player != null) {
|
if (player == null) return;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) return;
|
|
||||||
|
if (ClickHandler.isEditing)
|
||||||
|
return;
|
||||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -115,4 +117,3 @@ public class HandsomeFrameOverlay implements LayeredDraw.Layer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.client.overlay;
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity;
|
||||||
|
@ -8,7 +9,6 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
@ -63,7 +63,8 @@ public class HelicopterHudOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) return;
|
if (ClickHandler.isEditing)
|
||||||
|
return;
|
||||||
|
|
||||||
if (player.getVehicle() instanceof HelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player) && player.getVehicle() instanceof WeaponVehicleEntity weaponVehicle) {
|
if (player.getVehicle() instanceof HelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player) && player.getVehicle() instanceof WeaponVehicleEntity weaponVehicle) {
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.atsuishio.superbwarfare.client.overlay;
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
|
@ -53,8 +53,8 @@ public class JavelinHudOverlay implements LayeredDraw.Layer {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) return;
|
if (ClickHandler.isEditing)
|
||||||
|
return;
|
||||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.atsuishio.superbwarfare.client.overlay;
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
@ -34,7 +34,7 @@ public class StaminaOverlay implements LayeredDraw.Layer {
|
||||||
var w = guiGraphics.guiWidth();
|
var w = guiGraphics.guiWidth();
|
||||||
var h = guiGraphics.guiHeight();
|
var h = guiGraphics.guiHeight();
|
||||||
|
|
||||||
if (player != null && player.getData(ModAttachments.PLAYER_VARIABLE).edit)
|
if (player != null && ClickHandler.isEditing)
|
||||||
return;
|
return;
|
||||||
if (player != null && player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
if (player != null && player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -415,7 +415,6 @@ public class ClientEventHandler {
|
||||||
public static void handleGunMelee(Player player, ItemStack stack) {
|
public static void handleGunMelee(Player player, ItemStack stack) {
|
||||||
if (stack.getItem() instanceof GunItem gunItem) {
|
if (stack.getItem() instanceof GunItem gunItem) {
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
|
||||||
if (gunItem.hasMeleeAttack(stack)
|
if (gunItem.hasMeleeAttack(stack)
|
||||||
&& gunMelee == 0
|
&& gunMelee == 0
|
||||||
&& drawTime < 0.01
|
&& drawTime < 0.01
|
||||||
|
@ -423,7 +422,7 @@ public class ClientEventHandler {
|
||||||
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
&& !holdFireVehicle
|
&& !holdFireVehicle
|
||||||
&& !notInGame()
|
&& !notInGame()
|
||||||
&& !cap.edit
|
&& !ClickHandler.isEditing
|
||||||
&& !(data.reload.normal() || data.reload.empty())
|
&& !(data.reload.normal() || data.reload.empty())
|
||||||
&& !data.reloading()
|
&& !data.reloading()
|
||||||
&& !data.charging() && !player.getCooldowns().isOnCooldown(stack.getItem())
|
&& !data.charging() && !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||||
|
@ -575,8 +574,6 @@ public class ClientEventHandler {
|
||||||
revolverPreTime = Mth.clamp(revolverPreTime - 1.2 * times, 0, 1);
|
revolverPreTime = Mth.clamp(revolverPreTime - 1.2 * times, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
|
||||||
|
|
||||||
if (((holdFire || burstFireAmount > 0) && shootDelay >= data.shootDelay())
|
if (((holdFire || burstFireAmount > 0) && shootDelay >= data.shootDelay())
|
||||||
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
&& !holdFireVehicle
|
&& !holdFireVehicle
|
||||||
|
@ -585,8 +582,9 @@ public class ClientEventHandler {
|
||||||
&& (stack.is(ModTags.Items.NORMAL_GUN)
|
&& (stack.is(ModTags.Items.NORMAL_GUN)
|
||||||
&& cantFireTime == 0
|
&& cantFireTime == 0
|
||||||
&& drawTime < 0.01
|
&& drawTime < 0.01
|
||||||
&& !cap.edit
|
&& !ClickHandler.isEditing
|
||||||
&& !notInGame()
|
&& !notInGame()
|
||||||
|
&& !ClickHandler.isEditing
|
||||||
&& (!(data.reload.normal() || data.reload.empty())
|
&& (!(data.reload.normal() || data.reload.empty())
|
||||||
&& !data.reloading()
|
&& !data.reloading()
|
||||||
&& !data.charging()
|
&& !data.charging()
|
||||||
|
@ -1119,7 +1117,7 @@ public class ClientEventHandler {
|
||||||
onGround = 0.001;
|
onGround = 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (!ClickHandler.isEditing) {
|
||||||
if (Minecraft.getInstance().options.keyUp.isDown() && firePosTimer == 0) {
|
if (Minecraft.getInstance().options.keyUp.isDown() && firePosTimer == 0) {
|
||||||
moveRotZ = Mth.lerp(0.2f * times, moveRotZ, 0.14) * (1 - zoomTime);
|
moveRotZ = Mth.lerp(0.2f * times, moveRotZ, 0.14) * (1 - zoomTime);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1182,12 +1180,11 @@ public class ClientEventHandler {
|
||||||
double weight = data.weight();
|
double weight = data.weight();
|
||||||
double speed = 1.5 - (0.07 * weight);
|
double speed = 1.5 - (0.07 * weight);
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
|
||||||
if (zoom
|
if (zoom
|
||||||
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
&& !notInGame()
|
&& !notInGame()
|
||||||
&& drawTime < 0.01
|
&& drawTime < 0.01
|
||||||
&& !cap.edit) {
|
&& !ClickHandler.isEditing) {
|
||||||
if (Minecraft.getInstance().player != null) {
|
if (Minecraft.getInstance().player != null) {
|
||||||
cantSprint = 5;
|
cantSprint = 5;
|
||||||
}
|
}
|
||||||
|
@ -1515,7 +1512,7 @@ public class ClientEventHandler {
|
||||||
if (zoom
|
if (zoom
|
||||||
&& !notInGame()
|
&& !notInGame()
|
||||||
&& drawTime < 0.01
|
&& drawTime < 0.01
|
||||||
&& !player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
&& !ClickHandler.isEditing) {
|
||||||
if (!player.isShiftKeyDown()) {
|
if (!player.isShiftKeyDown()) {
|
||||||
int intelligentChipLevel = data.perk.getLevel(ModPerks.INTELLIGENT_CHIP);
|
int intelligentChipLevel = data.perk.getLevel(ModPerks.INTELLIGENT_CHIP);
|
||||||
|
|
||||||
|
@ -1625,6 +1622,7 @@ public class ClientEventHandler {
|
||||||
bowPullTimer = 0;
|
bowPullTimer = 0;
|
||||||
bowPower = 0;
|
bowPower = 0;
|
||||||
cantSprint = 20;
|
cantSprint = 20;
|
||||||
|
ClickHandler.isEditing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleWeaponDraw(LivingEntity entity) {
|
private static void handleWeaponDraw(LivingEntity entity) {
|
||||||
|
|
|
@ -388,12 +388,6 @@ public class LivingEventHandler {
|
||||||
oldData.charge.timer.reset();
|
oldData.charge.timer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
|
||||||
cap.edit = false;
|
|
||||||
|
|
||||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
|
||||||
cap.sync(player);
|
|
||||||
|
|
||||||
oldData.save();
|
oldData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -632,8 +632,6 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
||||||
if (data.reload.prepareTimer.get() == 0 && data.reloading() && data.hasEnoughAmmoToShoot(player)) {
|
if (data.reload.prepareTimer.get() == 0 && data.reloading() && data.hasEnoughAmmoToShoot(player)) {
|
||||||
data.forceStop.set(true);
|
data.forceStop.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.getData(ModAttachments.PLAYER_VARIABLE).modify(player, cap -> cap.edit = false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.handgun;
|
package com.atsuishio.superbwarfare.item.gun.handgun;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.TooltipTool;
|
import com.atsuishio.superbwarfare.client.TooltipTool;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.TracheliumItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.TracheliumItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -190,7 +190,7 @@ public class Trachelium extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.heavy;
|
package com.atsuishio.superbwarfare.item.gun.heavy;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.Ntw20Renderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.Ntw20Renderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModEnumExtensions;
|
import com.atsuishio.superbwarfare.init.ModEnumExtensions;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
|
@ -101,7 +101,7 @@ public class Ntw20Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,13 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, EnergyStorag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBarVisible(ItemStack stack) {
|
public boolean isBarVisible(@NotNull ItemStack stack) {
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
return cap != null && cap.getEnergyStored() > 0;
|
return cap != null && cap.getEnergyStored() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarWidth(ItemStack stack) {
|
public int getBarWidth(@NotNull ItemStack stack) {
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
return Math.round((float) (cap != null ? cap.getEnergyStored() : 0) * 13.0F / 24000F);
|
return Math.round((float) (cap != null ? cap.getEnergyStored() : 0) * 13.0F / 24000F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.machinegun;
|
package com.atsuishio.superbwarfare.item.gun.machinegun;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.RpkItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.RpkItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
|
@ -118,7 +118,7 @@ public class RpkItem extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.AK12ItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.AK12ItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -111,7 +111,7 @@ public class AK12Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak12.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.AK47ItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.AK47ItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -119,7 +119,7 @@ public class AK47Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.Hk416ItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.Hk416ItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -114,7 +114,7 @@ public class Hk416Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.M4ItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.M4ItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -115,7 +115,7 @@ public class M4Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.Mk14ItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.Mk14ItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -116,7 +116,7 @@ public class Mk14Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.rifle;
|
package com.atsuishio.superbwarfare.item.gun.rifle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.Qbz95ItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.Qbz95ItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -119,7 +119,7 @@ public class Qbz95Item extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.smg;
|
package com.atsuishio.superbwarfare.item.gun.smg;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.VectorItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.VectorItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -86,7 +86,7 @@ public class VectorItem extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vector.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vector.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,13 @@ public class SentinelItem extends GunItem implements GeoItem, EnergyStorageItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBarVisible(ItemStack stack) {
|
public boolean isBarVisible(@NotNull ItemStack stack) {
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
return cap != null && cap.getEnergyStored() > 0;
|
return cap != null && cap.getEnergyStored() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarWidth(ItemStack stack) {
|
public int getBarWidth(@NotNull ItemStack stack) {
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
|
|
||||||
return Math.round((float) (cap != null ? cap.getEnergyStored() : 0) * 13.0F / 24000F);
|
return Math.round((float) (cap != null ? cap.getEnergyStored() : 0) * 13.0F / 24000F);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.item.gun.sniper;
|
package com.atsuishio.superbwarfare.item.gun.sniper;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||||
import com.atsuishio.superbwarfare.client.renderer.item.SvdItemRenderer;
|
import com.atsuishio.superbwarfare.client.renderer.item.SvdItemRenderer;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -80,7 +80,7 @@ public class SvdItem extends GunItem implements GeoItem {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,13 @@ public class TaserItem extends GunItem implements GeoItem, EnergyStorageItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBarVisible(ItemStack stack) {
|
public boolean isBarVisible(@NotNull ItemStack stack) {
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
return cap != null && cap.getEnergyStored() != 0;
|
return cap != null && cap.getEnergyStored() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarWidth(ItemStack stack) {
|
public int getBarWidth(@NotNull ItemStack stack) {
|
||||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
return Math.round((float) (cap != null ? cap.getEnergyStored() : 0) * 13.0F / MAX_ENERGY);
|
return Math.round((float) (cap != null ? cap.getEnergyStored() : 0) * 13.0F / MAX_ENERGY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class NetworkRegistry {
|
||||||
public static void register(final RegisterPayloadHandlersEvent event) {
|
public static void register(final RegisterPayloadHandlersEvent event) {
|
||||||
final PayloadRegistrar registrar = event.registrar("1");
|
final PayloadRegistrar registrar = event.registrar("1");
|
||||||
|
|
||||||
registrar.playToClient(PlayerVariablesSyncMessage.TYPE, PlayerVariablesSyncMessage.STREAM_CODEC, PlayerVariablesSyncMessage::handler);
|
registrar.playToClient(PlayerVariablesSyncMessage.TYPE, PlayerVariablesSyncMessage.STREAM_CODEC, (message, context1) -> PlayerVariablesSyncMessage.handler(message));
|
||||||
registrar.playToClient(ShakeClientMessage.TYPE, ShakeClientMessage.STREAM_CODEC, ShakeClientMessage::handler);
|
registrar.playToClient(ShakeClientMessage.TYPE, ShakeClientMessage.STREAM_CODEC, ShakeClientMessage::handler);
|
||||||
registrar.playToClient(ClientMotionSyncMessage.TYPE, ClientMotionSyncMessage.STREAM_CODEC, ClientMotionSyncMessage::handler);
|
registrar.playToClient(ClientMotionSyncMessage.TYPE, ClientMotionSyncMessage.STREAM_CODEC, ClientMotionSyncMessage::handler);
|
||||||
registrar.playToClient(ClientIndicatorMessage.TYPE, ClientIndicatorMessage.STREAM_CODEC, ClientIndicatorMessage::handler);
|
registrar.playToClient(ClientIndicatorMessage.TYPE, ClientIndicatorMessage.STREAM_CODEC, ClientIndicatorMessage::handler);
|
||||||
|
@ -49,7 +49,6 @@ public class NetworkRegistry {
|
||||||
registrar.playToServer(SetFiringParametersMessage.TYPE, SetFiringParametersMessage.STREAM_CODEC, SetFiringParametersMessage::handler);
|
registrar.playToServer(SetFiringParametersMessage.TYPE, SetFiringParametersMessage.STREAM_CODEC, SetFiringParametersMessage::handler);
|
||||||
registrar.playToServer(SensitivityMessage.TYPE, SensitivityMessage.STREAM_CODEC, SensitivityMessage::handler);
|
registrar.playToServer(SensitivityMessage.TYPE, SensitivityMessage.STREAM_CODEC, SensitivityMessage::handler);
|
||||||
registrar.playToServer(EditMessage.TYPE, EditMessage.STREAM_CODEC, EditMessage::handler);
|
registrar.playToServer(EditMessage.TYPE, EditMessage.STREAM_CODEC, EditMessage::handler);
|
||||||
registrar.playToServer(EditModeMessage.TYPE, EditModeMessage.STREAM_CODEC, EditModeMessage::handler);
|
|
||||||
registrar.playToServer(InteractMessage.TYPE, InteractMessage.STREAM_CODEC, InteractMessage::handler);
|
registrar.playToServer(InteractMessage.TYPE, InteractMessage.STREAM_CODEC, InteractMessage::handler);
|
||||||
registrar.playToServer(AdjustMortarAngleMessage.TYPE, AdjustMortarAngleMessage.STREAM_CODEC, AdjustMortarAngleMessage::handler);
|
registrar.playToServer(AdjustMortarAngleMessage.TYPE, AdjustMortarAngleMessage.STREAM_CODEC, AdjustMortarAngleMessage::handler);
|
||||||
registrar.playToServer(ChangeVehicleSeatMessage.TYPE, ChangeVehicleSeatMessage.STREAM_CODEC, ChangeVehicleSeatMessage::handler);
|
registrar.playToServer(ChangeVehicleSeatMessage.TYPE, ChangeVehicleSeatMessage.STREAM_CODEC, ChangeVehicleSeatMessage::handler);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -31,7 +30,7 @@ public record PlayerVariablesSyncMessage(int target, Map<Byte, Integer> data) im
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
public static void handler(final PlayerVariablesSyncMessage message, final IPayloadContext context) {
|
public static void handler(final PlayerVariablesSyncMessage message) {
|
||||||
if (Minecraft.getInstance().player == null) return;
|
if (Minecraft.getInstance().player == null) return;
|
||||||
|
|
||||||
var entity = Minecraft.getInstance().player.level().getEntity(message.target());
|
var entity = Minecraft.getInstance().player.level().getEntity(message.target());
|
||||||
|
@ -42,10 +41,9 @@ public record PlayerVariablesSyncMessage(int target, Map<Byte, Integer> data) im
|
||||||
|
|
||||||
for (var entry : map.entrySet()) {
|
for (var entry : map.entrySet()) {
|
||||||
var type = entry.getKey();
|
var type = entry.getKey();
|
||||||
switch (type) {
|
if (type == -1) {
|
||||||
case -1 -> variable.tacticalSprint = entry.getValue() == 1;
|
variable.tacticalSprint = entry.getValue() == 1;
|
||||||
case -2 -> variable.edit = entry.getValue() == 1;
|
} else {
|
||||||
default -> {
|
|
||||||
var ammoTypes = Ammo.values();
|
var ammoTypes = Ammo.values();
|
||||||
if (type < ammoTypes.length) {
|
if (type < ammoTypes.length) {
|
||||||
var ammo = ammoTypes[type];
|
var ammo = ammoTypes[type];
|
||||||
|
@ -53,7 +51,6 @@ public record PlayerVariablesSyncMessage(int target, Map<Byte, Integer> data) im
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
entity.setData(ModAttachments.PLAYER_VARIABLE, variable);
|
entity.setData(ModAttachments.PLAYER_VARIABLE, variable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
package com.atsuishio.superbwarfare.network.message.send;
|
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.network.codec.ByteBufCodecs;
|
|
||||||
import net.minecraft.network.codec.StreamCodec;
|
|
||||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public record EditModeMessage(int msgType) implements CustomPacketPayload {
|
|
||||||
public static final Type<EditModeMessage> TYPE = new Type<>(Mod.loc("edit_mode"));
|
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, EditModeMessage> STREAM_CODEC = StreamCodec.composite(
|
|
||||||
ByteBufCodecs.INT,
|
|
||||||
EditModeMessage::msgType,
|
|
||||||
EditModeMessage::new
|
|
||||||
);
|
|
||||||
|
|
||||||
public static void handler(EditModeMessage message, final IPayloadContext context) {
|
|
||||||
pressAction(context.player(), message.msgType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void pressAction(Player player, int type) {
|
|
||||||
if (player == null) return;
|
|
||||||
if (type != 0) return;
|
|
||||||
|
|
||||||
ItemStack mainHandItem = player.getMainHandItem();
|
|
||||||
if (!(mainHandItem.getItem() instanceof GunItem gunItem)) return;
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
|
||||||
|
|
||||||
if (gunItem.isCustomizable(mainHandItem)) {
|
|
||||||
if (!cap.edit) {
|
|
||||||
SoundTool.playLocalSound(player, ModSounds.EDIT_MODE.get(), 1f, 1f);
|
|
||||||
}
|
|
||||||
cap.edit = !cap.edit;
|
|
||||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
|
||||||
cap.sync(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Type<? extends CustomPacketPayload> type() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.network.message.send;
|
package com.atsuishio.superbwarfare.network.message.send;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
@ -28,18 +27,13 @@ public record ReloadMessage(int msgType) implements CustomPacketPayload {
|
||||||
|
|
||||||
public static void pressAction(Player player, int type) {
|
public static void pressAction(Player player, int type) {
|
||||||
if (type != 0) return;
|
if (type != 0) return;
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem gunItem)) return;
|
if (!(stack.getItem() instanceof GunItem gunItem)) return;
|
||||||
|
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
if (data.useBackpackAmmo()) return;
|
if (data.useBackpackAmmo()) return;
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
|
||||||
cap.edit = false;
|
|
||||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
|
||||||
cap.sync(player);
|
|
||||||
|
|
||||||
|
|
||||||
if (!player.isSpectator()
|
if (!player.isSpectator()
|
||||||
&& !data.charging()
|
&& !data.charging()
|
||||||
&& !data.reloading()
|
&& !data.reloading()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.network.message.send;
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||||
|
@ -32,12 +31,8 @@ public record ZoomMessage(int msgType) implements CustomPacketPayload {
|
||||||
|
|
||||||
var vehicle = player.getVehicle();
|
var vehicle = player.getVehicle();
|
||||||
// 缩放音效播放条件: 载具是武器载具,且该位置有可用武器
|
// 缩放音效播放条件: 载具是武器载具,且该位置有可用武器
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
|
||||||
|
|
||||||
if (message.msgType == 0) {
|
if (message.msgType == 0) {
|
||||||
cap.edit = false;
|
|
||||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
|
||||||
cap.sync(player);
|
|
||||||
|
|
||||||
if (player.isPassenger()
|
if (player.isPassenger()
|
||||||
&& vehicle instanceof WeaponVehicleEntity weaponEntity
|
&& vehicle instanceof WeaponVehicleEntity weaponEntity
|
||||||
|
|
Loading…
Add table
Reference in a new issue