规范化变量命名

This commit is contained in:
Light_Quanta 2024-05-12 14:50:34 +08:00
parent 9afbc97ab5
commit a7c98f6c45
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
68 changed files with 345 additions and 364 deletions

View file

@ -80,7 +80,7 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -62,7 +62,7 @@ public class Aa12ItemModel extends GeoModel<Aa12Item> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -56,7 +56,7 @@ public class AbekiriItemModel extends GeoModel<Abekiri> {
shen.setRotX(0.08f * (float) fp); shen.setRotX(0.08f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -119,7 +119,7 @@ public class BocekItemModel extends GeoModel<BocekItem> {
fire.setRotX(0.02f * (float) fp); fire.setRotX(0.02f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
fire.setRotZ(0.003f * (float) fp); fire.setRotZ(0.003f * (float) fp);
} else { } else {
fire.setRotZ(-0.003f * (float) fp); fire.setRotZ(-0.003f * (float) fp);

View file

@ -76,7 +76,7 @@ public class DevotionItemModel extends GeoModel<Devotion> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.002f * (float) fp); shen.setRotZ(0.002f * (float) fp);
} else { } else {
shen.setRotZ(-0.002f * (float) fp); shen.setRotZ(-0.002f * (float) fp);

View file

@ -83,7 +83,7 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -60,7 +60,7 @@ public class KraberItemModel extends GeoModel<Kraber> {
shen.setRotX(0.1f * (float) fp); shen.setRotX(0.1f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -61,7 +61,7 @@ public class M4ItemModel extends GeoModel<M4Item> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -102,7 +102,7 @@ public class M60ItemModel extends GeoModel<M60Item> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
tiba.setRotZ(-0.2f * (float) fp); tiba.setRotZ(-0.2f * (float) fp);
} else { } else {

View file

@ -67,7 +67,7 @@ public class M79ItemModel extends GeoModel<M79Item> {
shen.setRotX(0.1f * (float) fp); shen.setRotX(0.1f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -82,7 +82,7 @@ public class M870ItemModel extends GeoModel<M870Item> {
shen.setRotX(0.12f * (float) fp); shen.setRotX(0.12f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -50,7 +50,7 @@ public class M98bItemModel extends GeoModel<M98bItem> {
shen.setRotX(0.1f * (float) fp); shen.setRotX(0.1f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -71,7 +71,7 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
shen.setRotX(0.12f * (float) fp); shen.setRotX(0.12f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -54,7 +54,7 @@ public class MinigunItemModel extends GeoModel<Minigun> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -78,7 +78,7 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -93,7 +93,7 @@ public class RpkItemModel extends GeoModel<RpkItem> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -94,7 +94,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
shen.setRotX(0.1f * (float) fp); shen.setRotX(0.1f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -77,7 +77,7 @@ public class SksItemModel extends GeoModel<SksItem> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -100,7 +100,7 @@ public class SvdItemModel extends GeoModel<SvdItem> {
shen.setRotX(0.08f * (float) fp); shen.setRotX(0.08f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -57,7 +57,7 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
shen.setRotX(0.2f * (float) fp); shen.setRotX(0.2f * (float) fp);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -77,7 +77,7 @@ public class VectorItemModel extends GeoModel<VectorItem> {
shen.setRotX(0.02f * (float) fp); shen.setRotX(0.02f * (float) fp);
} }
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
shen.setRotZ(0.003f * (float) fp); shen.setRotZ(0.003f * (float) fp);
} else { } else {
shen.setRotZ(-0.003f * (float) fp); shen.setRotZ(-0.003f * (float) fp);

View file

@ -28,11 +28,11 @@ public class CrosshairOverlay {
double spread = entity.getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue(); double spread = entity.getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue();
double hitind = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).hitind; double hitind = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).hitIndicator;
double headind = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).headind; double headind = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).headIndicator;
double killind = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).killind; double killind = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).killIndicator;
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
RenderSystem.depthMask(false); RenderSystem.depthMask(false);

View file

@ -1,24 +1,18 @@
package net.mcreator.target.command; package net.mcreator.target.command;
import org.checkerframework.checker.units.qual.s;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.Direction;
import net.minecraft.commands.Commands;
import net.minecraft.world.entity.player.Player;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.LevelAccessor;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.Commands;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public class PvPmodeCommand { public class PvPmodeCommand {
@ -36,14 +30,14 @@ public class PvPmodeCommand {
if (entity != null) if (entity != null)
direction = entity.getDirection(); direction = entity.getDirection();
if (TargetModVariables.MapVariables.get(world).pvpmode == true) { if (TargetModVariables.MapVariables.get(world).pvpMode == true) {
TargetModVariables.MapVariables.get(world).pvpmode = false; TargetModVariables.MapVariables.get(world).pvpMode = false;
TargetModVariables.MapVariables.get(world).syncData(world); TargetModVariables.MapVariables.get(world).syncData(world);
if (entity instanceof Player _player && !_player.level().isClientSide()) if (entity instanceof Player _player && !_player.level().isClientSide())
_player.displayClientMessage(Component.literal("PVPMODE:OFF"), false); _player.displayClientMessage(Component.literal("PVPMODE:OFF"), false);
} else { } else {
TargetModVariables.MapVariables.get(world).pvpmode = true; TargetModVariables.MapVariables.get(world).pvpMode = true;
TargetModVariables.MapVariables.get(world).syncData(world); TargetModVariables.MapVariables.get(world).syncData(world);
if (entity instanceof Player _player && !_player.level().isClientSide()) if (entity instanceof Player _player && !_player.level().isClientSide())
_player.displayClientMessage(Component.literal("PVPMODE:ON"), false); _player.displayClientMessage(Component.literal("PVPMODE:ON"), false);

View file

@ -85,7 +85,7 @@ public class BocekarrowEntity extends AbstractArrow implements ItemSupplier {
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
double _setval = 25; double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = _setval; capability.hitIndicator = _setval;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
@ -121,7 +121,7 @@ public class BocekarrowEntity extends AbstractArrow implements ItemSupplier {
setBaseDamage(getBaseDamage() * 2); setBaseDamage(getBaseDamage() * 2);
double _setval = 25; double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = _setval; capability.headIndicator = _setval;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {

View file

@ -81,7 +81,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
double _setval = 25; double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = _setval; capability.hitIndicator = _setval;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
@ -118,7 +118,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
setBaseDamage(getBaseDamage() * 2); setBaseDamage(getBaseDamage() * 2);
double _setval = 25; double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = _setval; capability.headIndicator = _setval;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {

View file

@ -327,7 +327,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
if (this.shooter instanceof ServerPlayer player) { if (this.shooter instanceof ServerPlayer player) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = 25; capability.hitIndicator = 25;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
var holder = Holder.direct(TargetModSounds.INDICATION.get()); var holder = Holder.direct(TargetModSounds.INDICATION.get());
@ -345,7 +345,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
} }
shooter.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { shooter.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = 25; capability.headIndicator = 25;
capability.syncPlayerVariables(shooter); capability.syncPlayerVariables(shooter);
}); });
@ -357,7 +357,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
} }
shooter.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { shooter.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = 25; capability.hitIndicator = 25;
capability.syncPlayerVariables(shooter); capability.syncPlayerVariables(shooter);
}); });

View file

@ -88,7 +88,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
Entity entity = result.getEntity(); Entity entity = result.getEntity();
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = 25; capability.hitIndicator = 25;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
@ -133,7 +133,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
setBaseDamage(getBaseDamage() * 5); setBaseDamage(getBaseDamage() * 5);
double _setval = 25; double _setval = 25;
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = _setval; capability.headIndicator = _setval;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {

View file

@ -76,7 +76,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
Entity entity = result.getEntity(); Entity entity = result.getEntity();
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = 25; capability.hitIndicator = 25;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
@ -112,7 +112,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
setBaseDamage(getBaseDamage() * 1.5f); setBaseDamage(getBaseDamage() * 1.5f);
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = 25; capability.headIndicator = 25;
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {

View file

@ -282,11 +282,11 @@ public class ClientEventHandler {
if (0 < entity.getPersistentData().getDouble("firetime") && entity.getPersistentData().getDouble("firetime") < 0.2) { if (0 < entity.getPersistentData().getDouble("firetime") && entity.getPersistentData().getDouble("firetime") < 0.2) {
entity.getPersistentData().putDouble("firepos", entity.getPersistentData().putDouble("firepos",
(pose * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + entity.getPersistentData().getDouble("firepos2")))); (pose * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + entity.getPersistentData().getDouble("firepos2"))));
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
event.setYaw((float) (yaw - 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1)))); event.setYaw((float) (yaw - 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1)))); event.setPitch((float) (pitch + 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll + amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1)))); event.setRoll((float) (roll + amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
} else if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == -1) { } else if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == -1) {
event.setYaw((float) (yaw - 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1)))); event.setYaw((float) (yaw - 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1)))); event.setPitch((float) (pitch + 0.2 * amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll - amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1)))); event.setRoll((float) (roll - amplitude * ((-18.34) * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) + 8.58 * entity.getPersistentData().getDouble("firetime") + 0.7 * (2 * Math.random() - 1))));
@ -295,11 +295,11 @@ public class ClientEventHandler {
if (0.2 <= entity.getPersistentData().getDouble("firetime") && entity.getPersistentData().getDouble("firetime") < 1) { if (0.2 <= entity.getPersistentData().getDouble("firetime") && entity.getPersistentData().getDouble("firetime") < 1) {
entity.getPersistentData().putDouble("firepos", entity.getPersistentData().putDouble("firepos",
(pose * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + entity.getPersistentData().getDouble("firepos2")))); (pose * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + entity.getPersistentData().getDouble("firepos2"))));
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == 1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == 1) {
event.setYaw((float) (yaw - 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1)))); event.setYaw((float) (yaw - 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch + 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1)))); event.setPitch((float) (pitch + 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll + amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1)))); event.setRoll((float) (roll + amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
} else if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon == -1) { } else if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon == -1) {
event.setYaw((float) (yaw + 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1)))); event.setYaw((float) (yaw + 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setPitch((float) (pitch - 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1)))); event.setPitch((float) (pitch - 0.2 * amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));
event.setRoll((float) (roll - amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1)))); event.setRoll((float) (roll - amplitude * (3.34 * Math.pow(entity.getPersistentData().getDouble("firetime"), 2) - 5.5 * entity.getPersistentData().getDouble("firetime") + 2.167 + 0.7 * (2 * Math.random() - 1))));

View file

@ -215,12 +215,12 @@ public class GunEventHandler {
ItemStack heldItem = player.getMainHandItem(); ItemStack heldItem = player.getMainHandItem();
if (Math.random() < 0.5) { if (Math.random() < 0.5) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = -1; capability.recoilHorizon = -1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });
} else { } else {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = 1; capability.recoilHorizon = 1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });
} }

View file

@ -29,7 +29,7 @@ public class PlayerEventHandler {
return; return;
} }
if (!TargetModVariables.MapVariables.get(player.level()).pvpmode) { if (!TargetModVariables.MapVariables.get(player.level()).pvpMode) {
return; return;
} }
@ -185,32 +185,32 @@ public class PlayerEventHandler {
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode; return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
} }
if (stack.getItem() == TargetModItems.MINIGUN.get()) { if (stack.getItem() == TargetModItems.MINIGUN.get()) {
return new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo) + " " + firemode; return new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo) + " " + firemode;
} }
if (stack.is(TargetModTags.Items.RIFLE)) { if (stack.is(TargetModTags.Items.RIFLE)) {
stack.getOrCreateTag().putDouble("maxammo", stack.getOrCreateTag().putDouble("maxammo",
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo)); ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo));
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/" return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo) + " " + firemode; + new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo) + " " + firemode;
} }
if (stack.is(TargetModTags.Items.HANDGUN) if (stack.is(TargetModTags.Items.HANDGUN)
|| stack.is(ItemTags.create(new ResourceLocation("target:smg")))) { || stack.is(ItemTags.create(new ResourceLocation("target:smg")))) {
stack.getOrCreateTag().putDouble("maxammo", stack.getOrCreateTag().putDouble("maxammo",
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo)); ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo));
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/" return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo) + " " + firemode; + new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo) + " " + firemode;
} }
if (stack.is(TargetModTags.Items.SHOTGUN)) { if (stack.is(TargetModTags.Items.SHOTGUN)) {
stack.getOrCreateTag().putDouble("maxammo", stack.getOrCreateTag().putDouble("maxammo",
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo)); ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo));
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/" return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo) + " " + firemode; + new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo) + " " + firemode;
} }
if (stack.is(TargetModTags.Items.SNIPER_RIFLE)) { if (stack.is(TargetModTags.Items.SNIPER_RIFLE)) {
stack.getOrCreateTag().putDouble("maxammo", stack.getOrCreateTag().putDouble("maxammo",
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo)); ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo));
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/" return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo) + " " + firemode; + new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo) + " " + firemode;
} }
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/" return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
+ (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode; + (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
@ -247,7 +247,7 @@ public class PlayerEventHandler {
private static void handleGround(Player player) { private static void handleGround(Player player) {
if (player.onGround()) { if (player.onGround()) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.playerdoublejump = false; capability.playerDoubleJump = false;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });
} }

View file

@ -40,7 +40,7 @@ public class SniperAmmoBox extends Item {
stack.shrink(1); stack.shrink(1);
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo + 12; capability.sniperAmmo = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo + 12;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });

View file

@ -48,7 +48,7 @@ public class DoubleJumpMessage {
} }
if (type == 0) { if (type == 0) {
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).playerdoublejump) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).playerDoubleJump) {
entity.setDeltaMovement(new Vec3((1 * entity.getLookAngle().x), 0.8, (1 * entity.getLookAngle().z))); entity.setDeltaMovement(new Vec3((1 * entity.getLookAngle().x), 0.8, (1 * entity.getLookAngle().z)));
if (!level.isClientSide()) { if (!level.isClientSide()) {
level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:doublejump")), SoundSource.BLOCKS, 1, 1); level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:doublejump")), SoundSource.BLOCKS, 1, 1);
@ -56,7 +56,7 @@ public class DoubleJumpMessage {
level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:doublejump")), SoundSource.BLOCKS, 1, 1, false); level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("target:doublejump")), SoundSource.BLOCKS, 1, 1, false);
} }
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.playerdoublejump = false; capability.playerDoubleJump = false;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -50,7 +50,7 @@ public class FireMessage {
player.getPersistentData().putDouble("minifiring", 0); player.getPersistentData().putDouble("minifiring", 0);
player.getPersistentData().putDouble("minigunfiring", 0); player.getPersistentData().putDouble("minigunfiring", 0);
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.bowpullhold = false; capability.bowPullHold = false;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });
BowlooseProcedure.execute(player); BowlooseProcedure.execute(player);

View file

@ -1,39 +1,33 @@
package net.mcreator.target.network; package net.mcreator.target.network;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.capabilities.CapabilityToken;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraft.world.level.saveddata.SavedData;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.core.Direction;
import net.minecraft.client.Minecraft;
import net.mcreator.target.TargetMod; import net.mcreator.target.TargetMod;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.saveddata.SavedData;
import net.minecraftforge.common.capabilities.*;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.network.PacketDistributor;
import java.util.function.Supplier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.Supplier;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class TargetModVariables { public class TargetModVariables {
@ -52,86 +46,85 @@ public class TargetModVariables {
public static class EventBusVariableHandlers { public static class EventBusVariableHandlers {
@SubscribeEvent @SubscribeEvent
public static void onPlayerLoggedInSyncPlayerVariables(PlayerEvent.PlayerLoggedInEvent event) { public static void onPlayerLoggedInSyncPlayerVariables(PlayerEvent.PlayerLoggedInEvent event) {
if (!event.getEntity().level().isClientSide()) { if (event.getEntity().level().isClientSide()) return;
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator); for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
} entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
} }
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerRespawnedSyncPlayerVariables(PlayerEvent.PlayerRespawnEvent event) { public static void onPlayerRespawnedSyncPlayerVariables(PlayerEvent.PlayerRespawnEvent event) {
if (!event.getEntity().level().isClientSide()) { if (event.getEntity().level().isClientSide()) return;
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator); for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
} entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
} }
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerChangedDimensionSyncPlayerVariables(PlayerEvent.PlayerChangedDimensionEvent event) { public static void onPlayerChangedDimensionSyncPlayerVariables(PlayerEvent.PlayerChangedDimensionEvent event) {
if (!event.getEntity().level().isClientSide()) { if (event.getEntity().level().isClientSide()) return;
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator); for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
} entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
} }
} }
@SubscribeEvent @SubscribeEvent
public static void clonePlayer(PlayerEvent.Clone event) { public static void clonePlayer(PlayerEvent.Clone event) {
event.getOriginal().revive(); event.getOriginal().revive();
PlayerVariables original = ((PlayerVariables) event.getOriginal().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())); PlayerVariables original = event.getOriginal().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
PlayerVariables clone = ((PlayerVariables) event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())); PlayerVariables clone = event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
clone.zoom = original.zoom; clone.zoom = original.zoom;
clone.zooming = original.zooming; clone.zooming = original.zooming;
clone.recoil = original.recoil; clone.recoil = original.recoil;
clone.recoilhorizon = original.recoilhorizon; clone.recoilHorizon = original.recoilHorizon;
clone.firing = original.firing; clone.firing = original.firing;
clone.targetangle = original.targetangle; clone.targetAngle = original.targetAngle;
clone.rifleammo = original.rifleammo; clone.rifleAmmo = original.rifleAmmo;
clone.refresh = original.refresh; clone.refresh = original.refresh;
clone.handgunammo = original.handgunammo; clone.handgunAmmo = original.handgunAmmo;
clone.shotgunammo = original.shotgunammo; clone.shotgunAmmo = original.shotgunAmmo;
clone.sniperammo = original.sniperammo; clone.sniperAmmo = original.sniperAmmo;
clone.bowpullhold = original.bowpullhold; clone.bowPullHold = original.bowPullHold;
clone.bowpull = original.bowpull; clone.bowPull = original.bowPull;
clone.playerdoublejump = original.playerdoublejump; clone.playerDoubleJump = original.playerDoubleJump;
clone.hitind = original.hitind; clone.hitIndicator = original.hitIndicator;
clone.headind = original.headind; clone.headIndicator = original.headIndicator;
clone.killind = original.killind; clone.killIndicator = original.killIndicator;
if (!event.isWasDeath()) {
} if (event.getEntity().level().isClientSide()) return;
if (!event.getEntity().level().isClientSide()) {
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) { for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator); entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
}
} }
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) { public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
if (!event.getEntity().level().isClientSide()) { if (event.getEntity().level().isClientSide()) return;
SavedData mapdata = MapVariables.get(event.getEntity().level());
SavedData worlddata = WorldVariables.get(event.getEntity().level()); SavedData mapData = MapVariables.get(event.getEntity().level());
if (mapdata != null) SavedData worldData = WorldVariables.get(event.getEntity().level());
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(0, mapdata)); if (mapData != null)
if (worlddata != null) TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(0, mapData));
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worlddata)); if (worldData != null)
} TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worldData));
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) { public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
if (!event.getEntity().level().isClientSide()) { if (event.getEntity().level().isClientSide()) return;
SavedData worlddata = WorldVariables.get(event.getEntity().level());
if (worlddata != null) SavedData worldData = WorldVariables.get(event.getEntity().level());
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worlddata)); if (worldData != null)
} TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worldData));
} }
} }
public static class WorldVariables extends SavedData { public static class WorldVariables extends SavedData {
public static final String DATA_NAME = "target_worldvars"; public static final String DATA_NAME = "target_world_variables";
public static WorldVariables load(CompoundTag tag) { public static WorldVariables load(CompoundTag tag) {
WorldVariables data = new WorldVariables(); WorldVariables data = new WorldVariables();
@ -156,17 +149,15 @@ public class TargetModVariables {
static WorldVariables clientSide = new WorldVariables(); static WorldVariables clientSide = new WorldVariables();
public static WorldVariables get(LevelAccessor world) { public static WorldVariables get(LevelAccessor world) {
if (world instanceof ServerLevel level) { if (world instanceof ServerLevel level)
return level.getDataStorage().computeIfAbsent(e -> WorldVariables.load(e), WorldVariables::new, DATA_NAME); return level.getDataStorage().computeIfAbsent(WorldVariables::load, WorldVariables::new, DATA_NAME);
} else {
return clientSide; return clientSide;
} }
} }
}
public static class MapVariables extends SavedData { public static class MapVariables extends SavedData {
public static final String DATA_NAME = "target_mapvars"; public static final String DATA_NAME = "target_map_variables";
public boolean pvpmode = false; public boolean pvpMode = false;
public static MapVariables load(CompoundTag tag) { public static MapVariables load(CompoundTag tag) {
MapVariables data = new MapVariables(); MapVariables data = new MapVariables();
@ -174,14 +165,14 @@ public class TargetModVariables {
return data; return data;
} }
public void read(CompoundTag nbt) { public static MapVariables get(LevelAccessor world) {
pvpmode = nbt.getBoolean("pvpmode"); if (world instanceof ServerLevelAccessor serverLevelAcc)
return serverLevelAcc.getLevel().getServer().getLevel(Level.OVERWORLD).getDataStorage().computeIfAbsent(MapVariables::load, MapVariables::new, DATA_NAME);
return clientSide;
} }
@Override public void read(CompoundTag nbt) {
public CompoundTag save(CompoundTag nbt) { pvpMode = nbt.getBoolean("pvp_mode");
nbt.putBoolean("pvpmode", pvpmode);
return nbt;
} }
public void syncData(LevelAccessor world) { public void syncData(LevelAccessor world) {
@ -192,12 +183,10 @@ public class TargetModVariables {
static MapVariables clientSide = new MapVariables(); static MapVariables clientSide = new MapVariables();
public static MapVariables get(LevelAccessor world) { @Override
if (world instanceof ServerLevelAccessor serverLevelAcc) { public CompoundTag save(CompoundTag nbt) {
return serverLevelAcc.getLevel().getServer().getLevel(Level.OVERWORLD).getDataStorage().computeIfAbsent(e -> MapVariables.load(e), MapVariables::new, DATA_NAME); nbt.putBoolean("pvp_mode", pvpMode);
} else { return nbt;
return clientSide;
}
} }
} }
@ -208,14 +197,14 @@ public class TargetModVariables {
public SavedDataSyncMessage(FriendlyByteBuf buffer) { public SavedDataSyncMessage(FriendlyByteBuf buffer) {
this.type = buffer.readInt(); this.type = buffer.readInt();
CompoundTag nbt = buffer.readNbt(); CompoundTag nbt = buffer.readNbt();
if (nbt != null) { if (nbt == null) return;
this.data = this.type == 0 ? new MapVariables() : new WorldVariables(); this.data = this.type == 0 ? new MapVariables() : new WorldVariables();
if (this.data instanceof MapVariables mapVariables) if (this.data instanceof MapVariables mapVariables)
mapVariables.read(nbt); mapVariables.read(nbt);
else if (this.data instanceof WorldVariables worldVariables) else if (this.data instanceof WorldVariables worldVariables)
worldVariables.read(nbt); worldVariables.read(nbt);
} }
}
public SavedDataSyncMessage(int type, SavedData data) { public SavedDataSyncMessage(int type, SavedData data) {
this.type = type; this.type = type;
@ -276,23 +265,23 @@ public class TargetModVariables {
public boolean zoom = false; public boolean zoom = false;
public boolean zooming = false; public boolean zooming = false;
public double recoil = 0; public double recoil = 0;
public double recoilhorizon = 0; public double recoilHorizon = 0;
public double firing = 0; public double firing = 0;
public double targetangle = 0; public double targetAngle = 0;
public double rifleammo = 0; public double rifleAmmo = 0;
public boolean refresh = false; public boolean refresh = false;
public double handgunammo = 0; public double handgunAmmo = 0;
public double shotgunammo = 0; public double shotgunAmmo = 0;
public double sniperammo = 0; public double sniperAmmo = 0;
public boolean bowpullhold = false; public boolean bowPullHold = false;
public boolean bowpull = false; public boolean bowPull = false;
public boolean playerdoublejump = false; public boolean playerDoubleJump = false;
public double hitind = 0; public double hitIndicator = 0;
public double headind = 0; public double headIndicator = 0;
public double killind = 0; public double killIndicator = 0;
public void syncPlayerVariables(Entity entity) { public void syncPlayerVariables(Entity entity) {
if (entity instanceof ServerPlayer serverPlayer) if (entity instanceof ServerPlayer)
TargetMod.PACKET_HANDLER.send(PacketDistributor.DIMENSION.with(entity.level()::dimension), new PlayerVariablesSyncMessage(this, entity.getId())); TargetMod.PACKET_HANDLER.send(PacketDistributor.DIMENSION.with(entity.level()::dimension), new PlayerVariablesSyncMessage(this, entity.getId()));
} }
@ -301,20 +290,20 @@ public class TargetModVariables {
nbt.putBoolean("zoom", zoom); nbt.putBoolean("zoom", zoom);
nbt.putBoolean("zooming", zooming); nbt.putBoolean("zooming", zooming);
nbt.putDouble("recoil", recoil); nbt.putDouble("recoil", recoil);
nbt.putDouble("recoilhorizon", recoilhorizon); nbt.putDouble("recoil_horizon", recoilHorizon);
nbt.putDouble("firing", firing); nbt.putDouble("firing", firing);
nbt.putDouble("targetangle", targetangle); nbt.putDouble("target_angle", targetAngle);
nbt.putDouble("rifleammo", rifleammo); nbt.putDouble("rifle_ammo", rifleAmmo);
nbt.putBoolean("refresh", refresh); nbt.putBoolean("refresh", refresh);
nbt.putDouble("handgunammo", handgunammo); nbt.putDouble("handgun_ammo", handgunAmmo);
nbt.putDouble("shotgunammo", shotgunammo); nbt.putDouble("shotgun_ammo", shotgunAmmo);
nbt.putDouble("sniperammo", sniperammo); nbt.putDouble("sniper_ammo", sniperAmmo);
nbt.putBoolean("bowpullhold", bowpullhold); nbt.putBoolean("bow_pull_hold", bowPullHold);
nbt.putBoolean("bowpull", bowpull); nbt.putBoolean("bow_pull", bowPull);
nbt.putBoolean("playerdoublejump", playerdoublejump); nbt.putBoolean("player_double_jump", playerDoubleJump);
nbt.putDouble("hitind", hitind); nbt.putDouble("hit_indicator", hitIndicator);
nbt.putDouble("headind", headind); nbt.putDouble("head_indicator", headIndicator);
nbt.putDouble("killind", killind); nbt.putDouble("kill_indicator", killIndicator);
return nbt; return nbt;
} }
@ -323,20 +312,20 @@ public class TargetModVariables {
zoom = nbt.getBoolean("zoom"); zoom = nbt.getBoolean("zoom");
zooming = nbt.getBoolean("zooming"); zooming = nbt.getBoolean("zooming");
recoil = nbt.getDouble("recoil"); recoil = nbt.getDouble("recoil");
recoilhorizon = nbt.getDouble("recoilhorizon"); recoilHorizon = nbt.getDouble("recoil_horizon");
firing = nbt.getDouble("firing"); firing = nbt.getDouble("firing");
targetangle = nbt.getDouble("targetangle"); targetAngle = nbt.getDouble("target_angle");
rifleammo = nbt.getDouble("rifleammo"); rifleAmmo = nbt.getDouble("rifle_ammo");
refresh = nbt.getBoolean("refresh"); refresh = nbt.getBoolean("refresh");
handgunammo = nbt.getDouble("handgunammo"); handgunAmmo = nbt.getDouble("handgun_ammo");
shotgunammo = nbt.getDouble("shotgunammo"); shotgunAmmo = nbt.getDouble("shotgun_ammo");
sniperammo = nbt.getDouble("sniperammo"); sniperAmmo = nbt.getDouble("sniper_ammo");
bowpullhold = nbt.getBoolean("bowpullhold"); bowPullHold = nbt.getBoolean("bow_pull_hold");
bowpull = nbt.getBoolean("bowpull"); bowPull = nbt.getBoolean("bow_pull");
playerdoublejump = nbt.getBoolean("playerdoublejump"); playerDoubleJump = nbt.getBoolean("player_double_jump");
hitind = nbt.getDouble("hitind"); hitIndicator = nbt.getDouble("hit_indicator");
headind = nbt.getDouble("headind"); headIndicator = nbt.getDouble("head_indicator");
killind = nbt.getDouble("killind"); killIndicator = nbt.getDouble("kill_indicator");
} }
} }
@ -355,9 +344,9 @@ public class TargetModVariables {
this.target = buffer.readInt(); this.target = buffer.readInt();
} }
public PlayerVariablesSyncMessage(PlayerVariables data, int entityid) { public PlayerVariablesSyncMessage(PlayerVariables data, int entityId) {
this.data = data; this.data = data;
this.target = entityid; this.target = entityId;
} }
public static void buffer(PlayerVariablesSyncMessage message, FriendlyByteBuf buffer) { public static void buffer(PlayerVariablesSyncMessage message, FriendlyByteBuf buffer) {
@ -368,28 +357,28 @@ public class TargetModVariables {
public static void handler(PlayerVariablesSyncMessage message, Supplier<NetworkEvent.Context> contextSupplier) { public static void handler(PlayerVariablesSyncMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
NetworkEvent.Context context = contextSupplier.get(); NetworkEvent.Context context = contextSupplier.get();
context.enqueueWork(() -> { context.enqueueWork(() -> {
if (!context.getDirection().getReceptionSide().isServer()) { context.setPacketHandled(true);
PlayerVariables variables = ((PlayerVariables) Minecraft.getInstance().player.level().getEntity(message.target).getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())); if (context.getDirection().getReceptionSide().isServer()) return;
PlayerVariables variables = Minecraft.getInstance().player.level().getEntity(message.target).getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
variables.zoom = message.data.zoom; variables.zoom = message.data.zoom;
variables.zooming = message.data.zooming; variables.zooming = message.data.zooming;
variables.recoil = message.data.recoil; variables.recoil = message.data.recoil;
variables.recoilhorizon = message.data.recoilhorizon; variables.recoilHorizon = message.data.recoilHorizon;
variables.firing = message.data.firing; variables.firing = message.data.firing;
variables.targetangle = message.data.targetangle; variables.targetAngle = message.data.targetAngle;
variables.rifleammo = message.data.rifleammo; variables.rifleAmmo = message.data.rifleAmmo;
variables.refresh = message.data.refresh; variables.refresh = message.data.refresh;
variables.handgunammo = message.data.handgunammo; variables.handgunAmmo = message.data.handgunAmmo;
variables.shotgunammo = message.data.shotgunammo; variables.shotgunAmmo = message.data.shotgunAmmo;
variables.sniperammo = message.data.sniperammo; variables.sniperAmmo = message.data.sniperAmmo;
variables.bowpullhold = message.data.bowpullhold; variables.bowPullHold = message.data.bowPullHold;
variables.bowpull = message.data.bowpull; variables.bowPull = message.data.bowPull;
variables.playerdoublejump = message.data.playerdoublejump; variables.playerDoubleJump = message.data.playerDoubleJump;
variables.hitind = message.data.hitind; variables.hitIndicator = message.data.hitIndicator;
variables.headind = message.data.headind; variables.headIndicator = message.data.headIndicator;
variables.killind = message.data.killind; variables.killIndicator = message.data.killIndicator;
}
}); });
context.setPacketHandled(true);
} }
} }
} }

View file

@ -11,12 +11,12 @@ public class AA12ReloadProcedure {
double ammo = tag.getDouble("ammo"); double ammo = tag.getDouble("ammo");
double empty = mag - ammo + (plusOne ? 1 : 0); double empty = mag - ammo + (plusOne ? 1 : 0);
double shotgunAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.shotgunammo).orElse(0d); double shotgunAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.shotgunAmmo).orElse(0d);
tag.putDouble("ammo", ammo + Math.min(empty, shotgunAmmo)); tag.putDouble("ammo", ammo + Math.min(empty, shotgunAmmo));
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = Math.max(0, shotgunAmmo - empty); capability.shotgunAmmo = Math.max(0, shotgunAmmo - empty);
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });

View file

@ -42,11 +42,11 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0); itemstack.getOrCreateTag().putDouble("reloadtime", 0);
} }
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) { if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo >= ammo1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo >= ammo1) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo - ammo1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -55,9 +55,9 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("emptyreload", 0); itemstack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
{ {
double _setval = itemstack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo; double _setval = itemstack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -86,11 +86,11 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0); itemstack.getOrCreateTag().putDouble("reloadtime", 0);
} }
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) { if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo >= ammo1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo >= ammo1) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo - ammo1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -99,9 +99,9 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("emptyreload", 0); itemstack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
{ {
double _setval = itemstack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo; double _setval = itemstack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -29,7 +29,7 @@ public class BowPullAnimationProcedure {
} }
float times = 90f / fps; float times = 90f / fps;
CompoundTag persistentData = entity.getPersistentData(); CompoundTag persistentData = entity.getPersistentData();
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowpull) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowPull) {
if (persistentData.getDouble("pulltime") < 1) { if (persistentData.getDouble("pulltime") < 1) {
persistentData.putDouble("pulltime", (persistentData.getDouble("pulltime") + 0.014 * times)); persistentData.putDouble("pulltime", (persistentData.getDouble("pulltime") + 0.014 * times));
} else { } else {
@ -43,7 +43,7 @@ public class BowPullAnimationProcedure {
} }
} }
persistentData.putDouble("pullpos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(persistentData.getDouble("pulltime"), 2) - 1, 2)) + 0.5)); persistentData.putDouble("pullpos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(persistentData.getDouble("pulltime"), 2) - 1, 2)) + 0.5));
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowpull) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowPull) {
if (persistentData.getDouble("bowtime") < 1) { if (persistentData.getDouble("bowtime") < 1) {
persistentData.putDouble("bowtime", (persistentData.getDouble("bowtime") + 0.014 * times)); persistentData.putDouble("bowtime", (persistentData.getDouble("bowtime") + 0.014 * times));
} else { } else {
@ -57,7 +57,7 @@ public class BowPullAnimationProcedure {
} }
} }
persistentData.putDouble("bowpos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(persistentData.getDouble("bowtime"), 2) - 1, 2)) + 0.5)); persistentData.putDouble("bowpos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(persistentData.getDouble("bowtime"), 2) - 1, 2)) + 0.5));
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowpull) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowPull) {
if (persistentData.getDouble("handtime") < 1) { if (persistentData.getDouble("handtime") < 1) {
persistentData.putDouble("handtime", (persistentData.getDouble("handtime") + 0.014 * times)); persistentData.putDouble("handtime", (persistentData.getDouble("handtime") + 0.014 * times));
} else { } else {

View file

@ -69,7 +69,7 @@ public class BowlooseProcedure {
} }
} }
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1; capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1; capability.recoil = 0.1;
capability.firing = 1; capability.firing = 1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);

View file

@ -27,28 +27,28 @@ public class CreativeAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
{ {
double _setval = 2147483647; double _setval = 2147483647;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
{ {
double _setval = 2147483647; double _setval = 2147483647;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
{ {
double _setval = 2147483647; double _setval = 2147483647;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
{ {
double _setval = 2147483647; double _setval = 2147483647;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = _setval; capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -29,7 +29,7 @@ public class GunRecoilProcedure {
float recoilx = ((float) (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("recoilx")); float recoilx = ((float) (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("recoilx"));
float recoily = ((float) (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("recoily")); float recoily = ((float) (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("recoily"));
float recoilyaw = ((float) (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilhorizon); float recoilyaw = ((float) (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon);
double[] recoilTimer = {0}; double[] recoilTimer = {0};
double totalTime = 100; double totalTime = 100;

View file

@ -25,9 +25,9 @@ public class HandgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
} }
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo + 30; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo + 30;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -17,9 +17,9 @@ public class HandgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
if (entity == null) if (entity == null)
return; return;
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo + 5; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo + 5;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -13,11 +13,11 @@ public class HandgunReload1Procedure {
ItemStack stack; ItemStack stack;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY); stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo"); ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo >= ammo1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo >= ammo1) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo - ammo1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -25,11 +25,11 @@ public class HandgunReload1Procedure {
stack.getOrCreateTag().putDouble("reloading", 0); stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0); stack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo)); stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo));
{ {
double _setval = 0; double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -13,11 +13,11 @@ public class HandgunReload2Procedure {
ItemStack stack; ItemStack stack;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY); stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo"); ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo >= ammo2) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo >= ammo2) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo - ammo2; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo - ammo2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -25,11 +25,11 @@ public class HandgunReload2Procedure {
stack.getOrCreateTag().putDouble("reloading", 0); stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0); stack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo)); stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo));
{ {
double _setval = 0; double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunammo = _setval; capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -44,7 +44,7 @@ public class Hitindication2Procedure {
{ {
double _setval = 25; double _setval = 25;
sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = _setval; capability.hitIndicator = _setval;
capability.syncPlayerVariables(sourceentity); capability.syncPlayerVariables(sourceentity);
}); });
} }

View file

@ -32,29 +32,29 @@ public class HitindicationProcedure {
while (recoilTimer[0] < recoilDuration) { while (recoilTimer[0] < recoilDuration) {
if (entity == null) if (entity == null)
return; return;
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).hitind > 0) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).hitIndicator > 0) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).hitind - 1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).hitIndicator - 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.hitind = _setval; capability.hitIndicator = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
} }
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).headind > 0) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).headIndicator > 0) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).headind - 1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).headIndicator - 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.headind = _setval; capability.headIndicator = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
} }
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).killind > 0) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).killIndicator > 0) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).killind - 1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).killIndicator - 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.killind = _setval; capability.killIndicator = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -58,7 +58,7 @@ public class JumppadBlockShiTiZaiFangKuaiZhongPengZhuangShiProcedure {
{ {
boolean _setval = true; boolean _setval = true;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.playerdoublejump = _setval; capability.playerDoubleJump = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -43,7 +43,7 @@ public class KillindicationProcedure {
{ {
double _setval = 40; double _setval = 40;
sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.killind = _setval; capability.killIndicator = _setval;
capability.syncPlayerVariables(sourceentity); capability.syncPlayerVariables(sourceentity);
}); });
} }

View file

@ -24,7 +24,7 @@ public class M79fireProcedure {
if (usehand.getItem() == TargetModItems.M_79.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem())) if (usehand.getItem() == TargetModItems.M_79.get() && usehand.getOrCreateTag().getDouble("reloading") == 0 && !(entity instanceof Player _plrCldCheck4 && _plrCldCheck4.getCooldowns().isOnCooldown(usehand.getItem()))
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1; capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1; capability.recoil = 0.1;
capability.firing = 1; capability.firing = 1;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);

View file

@ -42,15 +42,15 @@ public class M870WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
if (itemstack.getOrCreateTag().getDouble("prepare") == 10 && itemstack.getOrCreateTag().getDouble("emptyreload") == 1) { if (itemstack.getOrCreateTag().getDouble("prepare") == 10 && itemstack.getOrCreateTag().getDouble("emptyreload") == 1) {
itemstack.getOrCreateTag().putDouble("ammo", (itemstack.getOrCreateTag().getDouble("ammo") + 1)); itemstack.getOrCreateTag().putDouble("ammo", (itemstack.getOrCreateTag().getDouble("ammo") + 1));
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo - 1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo - 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
} }
if (itemstack.getOrCreateTag().getDouble("prepare") == 0 && itemstack.getOrCreateTag().getDouble("loading") == 0 if (itemstack.getOrCreateTag().getDouble("prepare") == 0 && itemstack.getOrCreateTag().getDouble("loading") == 0
&& !(itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo == 0)) { && !(itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo == 0)) {
if (itemstack.getOrCreateTag().getDouble("forcestop") == 1) { if (itemstack.getOrCreateTag().getDouble("forcestop") == 1) {
itemstack.getOrCreateTag().putDouble("stop", 1); itemstack.getOrCreateTag().putDouble("stop", 1);
} else { } else {
@ -73,14 +73,14 @@ public class M870WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
if (itemstack.getOrCreateTag().getDouble("loading") == 9) { if (itemstack.getOrCreateTag().getDouble("loading") == 9) {
itemstack.getOrCreateTag().putDouble("ammo", (itemstack.getOrCreateTag().getDouble("ammo") + 1)); itemstack.getOrCreateTag().putDouble("ammo", (itemstack.getOrCreateTag().getDouble("ammo") + 1));
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo - 1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo - 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
} }
if ((itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo == 0) if ((itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo == 0)
&& itemstack.getOrCreateTag().getDouble("loading") == 0 || itemstack.getOrCreateTag().getDouble("stop") == 1) { && itemstack.getOrCreateTag().getDouble("loading") == 0 || itemstack.getOrCreateTag().getDouble("stop") == 1) {
itemstack.getOrCreateTag().putDouble("forcestop", 0); itemstack.getOrCreateTag().putDouble("forcestop", 0);
itemstack.getOrCreateTag().putDouble("stop", 0); itemstack.getOrCreateTag().putDouble("stop", 0);

View file

@ -37,7 +37,7 @@ public class MarlinWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
} }
if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) { if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
if (itemstack.getOrCreateTag().getDouble("prepare") == 0 && itemstack.getOrCreateTag().getDouble("loading") == 0 if (itemstack.getOrCreateTag().getDouble("prepare") == 0 && itemstack.getOrCreateTag().getDouble("loading") == 0
&& !(itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo == 0)) { && !(itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0)) {
if (itemstack.getOrCreateTag().getDouble("forcestop") == 1) { if (itemstack.getOrCreateTag().getDouble("forcestop") == 1) {
itemstack.getOrCreateTag().putDouble("stop", 1); itemstack.getOrCreateTag().putDouble("stop", 1);
} else { } else {
@ -60,14 +60,14 @@ public class MarlinWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
if (itemstack.getOrCreateTag().getDouble("loading") == 9) { if (itemstack.getOrCreateTag().getDouble("loading") == 9) {
itemstack.getOrCreateTag().putDouble("ammo", (itemstack.getOrCreateTag().getDouble("ammo") + 1)); itemstack.getOrCreateTag().putDouble("ammo", (itemstack.getOrCreateTag().getDouble("ammo") + 1));
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo - 1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo - 1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
} }
if ((itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo == 0) if ((itemstack.getOrCreateTag().getDouble("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0)
&& itemstack.getOrCreateTag().getDouble("loading") == 0 || itemstack.getOrCreateTag().getDouble("stop") == 1) { && itemstack.getOrCreateTag().getDouble("loading") == 0 || itemstack.getOrCreateTag().getDouble("stop") == 1) {
itemstack.getOrCreateTag().putDouble("forcestop", 0); itemstack.getOrCreateTag().putDouble("forcestop", 0);
itemstack.getOrCreateTag().putDouble("stop", 0); itemstack.getOrCreateTag().putDouble("stop", 0);

View file

@ -38,7 +38,7 @@ public class MinigunautofireProcedure {
} }
} }
if (usehand.getItem() == TargetModItems.MINIGUN.get() && usehand.getOrCreateTag().getDouble("overheat") == 0 if (usehand.getItem() == TargetModItems.MINIGUN.get() && usehand.getOrCreateTag().getDouble("overheat") == 0
&& (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0
&& !(player.getCooldowns().isOnCooldown(usehand.getItem())) && usehand.getOrCreateTag().getDouble("rot") >= 10) { && !(player.getCooldowns().isOnCooldown(usehand.getItem())) && usehand.getOrCreateTag().getDouble("rot") >= 10) {
usehand.getOrCreateTag().putDouble("heat", (usehand.getOrCreateTag().getDouble("heat") + 1)); usehand.getOrCreateTag().putDouble("heat", (usehand.getOrCreateTag().getDouble("heat") + 1));
if (usehand.getOrCreateTag().getDouble("heat") >= 50.5) { if (usehand.getOrCreateTag().getDouble("heat") >= 50.5) {
@ -73,7 +73,7 @@ public class MinigunautofireProcedure {
GunsTool.spawnBullet(player); GunsTool.spawnBullet(player);
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).rifleammo - 1; capability.rifleAmmo = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).rifleAmmo - 1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });

View file

@ -31,7 +31,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 8 && tag.getDouble("ammo") < 8
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
@ -41,7 +41,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 1 && tag.getDouble("ammo") < 1
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("reloadtime", 61); tag.putDouble("reloadtime", 61);
tag.putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
@ -71,7 +71,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 2 && tag.getDouble("ammo") < 2
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo > 0) {
if (tag.getDouble("ammo") == 1) { if (tag.getDouble("ammo") == 1) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -88,7 +88,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 6 && tag.getDouble("ammo") < 6
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -105,7 +105,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 5 && tag.getDouble("ammo") < 5
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -122,7 +122,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 34 && tag.getDouble("ammo") < 34
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -139,7 +139,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 21 && tag.getDouble("ammo") < 21
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -156,7 +156,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 21 && tag.getDouble("ammo") < 21
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -173,7 +173,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 31 && tag.getDouble("ammo") < 31
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -191,7 +191,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 31 && tag.getDouble("ammo") < 31
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -208,7 +208,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 26 && tag.getDouble("ammo") < 26
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -224,7 +224,7 @@ public class PlayerReloadProcedure {
if (player.getMainHandItem().getItem() == TargetModItems.DEVOTION.get() if (player.getMainHandItem().getItem() == TargetModItems.DEVOTION.get()
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0
&& tag.getDouble("ammo") < 56) { && tag.getDouble("ammo") < 56) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
@ -241,7 +241,7 @@ public class PlayerReloadProcedure {
if (player.getMainHandItem().getItem() == TargetModItems.RPK.get() if (player.getMainHandItem().getItem() == TargetModItems.RPK.get()
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0
&& tag.getDouble("ammo") < 51) { && tag.getDouble("ammo") < 51) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
@ -259,7 +259,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 6 && tag.getDouble("ammo") < 6
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -276,7 +276,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 11 && tag.getDouble("ammo") < 11
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo > 0) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("emptyreload", 0); tag.putDouble("emptyreload", 0);
@ -292,7 +292,7 @@ public class PlayerReloadProcedure {
if (player.getMainHandItem().getItem() == TargetModItems.M_60.get() if (player.getMainHandItem().getItem() == TargetModItems.M_60.get()
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0 && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0
&& tag.getDouble("ammo") < 100) { && tag.getDouble("ammo") < 100) {
if (tag.getDouble("ammo") > 0) { if (tag.getDouble("ammo") > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
@ -310,7 +310,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 8 && tag.getDouble("ammo") < 8
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo > 0) {
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 5); player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 5);
@ -324,7 +324,7 @@ public class PlayerReloadProcedure {
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) && !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
&& tag.getDouble("reloading") == 0 && tag.getDouble("reloading") == 0
&& tag.getDouble("ammo") < 8 && tag.getDouble("ammo") < 8
&& (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo > 0) { && (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo > 0) {
if (tag.getDouble("ammo") == 0) { if (tag.getDouble("ammo") == 0) {
tag.putDouble("emptyreload", 1); tag.putDouble("emptyreload", 1);
tag.putDouble("reloading", 1); tag.putDouble("reloading", 1);

View file

@ -33,14 +33,14 @@ public class PressFireProcedure {
} }
} }
if (player.getMainHandItem().getItem() == TargetModItems.MINIGUN.get() if (player.getMainHandItem().getItem() == TargetModItems.MINIGUN.get()
&& (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo == 0) { && (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0) {
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide() && player.getServer() != null) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:triggerclick player @s ~ ~ ~ 10 1"); player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:triggerclick player @s ~ ~ ~ 10 1");
} }
} }
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.bowpullhold = true; capability.bowPullHold = true;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);
}); });
if (player.getMainHandItem().getOrCreateTag().getDouble("ammo") == 0) { if (player.getMainHandItem().getOrCreateTag().getDouble("ammo") == 0) {

View file

@ -32,7 +32,7 @@ public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
private static void execute(@Nullable Event event, Entity entity) { private static void execute(@Nullable Event event, Entity entity) {
if (entity == null) if (entity == null)
return; return;
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowpullhold) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowPullHold) {
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get() if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get()
&& (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo") > 0 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo") > 0
&& !(entity instanceof Player _plrCldCheck5 && _plrCldCheck5.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem())) && !(entity instanceof Player _plrCldCheck5 && _plrCldCheck5.getCooldowns().isOnCooldown((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem()))
@ -42,7 +42,7 @@ public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
{ {
boolean _setval = true; boolean _setval = true;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.bowpull = _setval; capability.bowPull = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -64,7 +64,7 @@ public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
{ {
boolean _setval = false; boolean _setval = false;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.bowpull = _setval; capability.bowPull = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -1,10 +1,9 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class Reload1Procedure { public class Reload1Procedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
@ -14,11 +13,11 @@ public class Reload1Procedure {
ItemStack stack = ItemStack.EMPTY; ItemStack stack = ItemStack.EMPTY;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY); stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo"); ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo >= ammo1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo >= ammo1) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo - ammo1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -26,11 +25,11 @@ public class Reload1Procedure {
stack.getOrCreateTag().putDouble("reloading", 0); stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0); stack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo)); stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo));
{ {
double _setval = 0; double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -1,10 +1,9 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class Reload2Procedure { public class Reload2Procedure {
public static void execute(Entity entity) { public static void execute(Entity entity) {
@ -15,11 +14,11 @@ public class Reload2Procedure {
double ammo1 = 0; double ammo1 = 0;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY); stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo"); ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo >= ammo2) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo >= ammo2) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo - ammo2; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo - ammo2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -27,11 +26,11 @@ public class Reload2Procedure {
stack.getOrCreateTag().putDouble("reloading", 0); stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0); stack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo)); stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo));
{ {
double _setval = 0; double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -25,9 +25,9 @@ public class RifleAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
} }
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo + 30; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo + 30;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -17,9 +17,9 @@ public class RifleAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
if (entity == null) if (entity == null)
return; return;
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo + 5; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo + 5;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleammo = _setval; capability.rifleAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -28,7 +28,7 @@ public class RpgFireProcedure {
if (mainHandItem.getItem() == TargetModItems.RPG.get() && tag.getDouble("reloading") == 0 && !player.getCooldowns().isOnCooldown(mainHandItem.getItem()) if (mainHandItem.getItem() == TargetModItems.RPG.get() && tag.getDouble("reloading") == 0 && !player.getCooldowns().isOnCooldown(mainHandItem.getItem())
&& tag.getDouble("ammo") > 0) { && tag.getDouble("ammo") > 0) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1; capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1; capability.recoil = 0.1;
capability.firing = 1; capability.firing = 1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);

View file

@ -25,9 +25,9 @@ public class ShotgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
} }
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo + 12; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo + 12;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -17,9 +17,9 @@ public class ShotgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
if (entity == null) if (entity == null)
return; return;
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo + 2; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo + 2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunammo = _setval; capability.shotgunAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -17,9 +17,9 @@ public class SniperAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
if (entity == null) if (entity == null)
return; return;
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo + 2; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo + 2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = _setval; capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -17,11 +17,11 @@ public class SniperReload1Procedure {
id = stack.getOrCreateTag().getDouble("id"); id = stack.getOrCreateTag().getDouble("id");
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo"); ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo"); ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo >= ammo1) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo >= ammo1) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo - ammo1; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = _setval; capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -29,11 +29,11 @@ public class SniperReload1Procedure {
stack.getOrCreateTag().putDouble("reloading", 0); stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0); stack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo)); stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo));
{ {
double _setval = 0; double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = _setval; capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -17,11 +17,11 @@ public class SniperReload2Procedure {
id = stack.getOrCreateTag().getDouble("id"); id = stack.getOrCreateTag().getDouble("id");
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo"); ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo"); ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo >= ammo2) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo >= ammo2) {
{ {
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo - ammo2; double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo - ammo2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = _setval; capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }
@ -29,11 +29,11 @@ public class SniperReload2Procedure {
stack.getOrCreateTag().putDouble("reloading", 0); stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0); stack.getOrCreateTag().putDouble("emptyreload", 0);
} else { } else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo)); stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo));
{ {
double _setval = 0; double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperammo = _setval; capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);
}); });
} }

View file

@ -25,7 +25,7 @@ public class TaserfireProcedure {
&& usehand.getOrCreateTag().getDouble("ammo") > 0) { && usehand.getOrCreateTag().getDouble("ammo") > 0) {
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1; capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1; capability.recoil = 0.1;
capability.firing = 1; capability.firing = 1;
capability.syncPlayerVariables(entity); capability.syncPlayerVariables(entity);

View file

@ -63,7 +63,7 @@ public class GunsTool {
} }
public static void pvpModeCheck(ItemStack stack, Level level) { public static void pvpModeCheck(ItemStack stack, Level level) {
if (!TargetModVariables.MapVariables.get(level).pvpmode) { if (!TargetModVariables.MapVariables.get(level).pvpMode) {
if (stack.getOrCreateTag().getDouble("level") >= 10) { if (stack.getOrCreateTag().getDouble("level") >= 10) {
stack.getOrCreateTag().putDouble("damageadd", 1 + 0.05 * (stack.getOrCreateTag().getDouble("level") - 10)); stack.getOrCreateTag().putDouble("damageadd", 1 + 0.05 * (stack.getOrCreateTag().getDouble("level") - 10));
} else { } else {
@ -89,7 +89,7 @@ public class GunsTool {
public static void spawnBullet(Player player) { public static void spawnBullet(Player player) {
ItemStack heldItem = player.getMainHandItem(); ItemStack heldItem = player.getMainHandItem();
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilhorizon = Math.random() < 0.5 ? -1 : 1; capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
capability.recoil = 0.1; capability.recoil = 0.1;
capability.firing = 1; capability.firing = 1;
capability.syncPlayerVariables(player); capability.syncPlayerVariables(player);