规范化变量命名
This commit is contained in:
parent
9afbc97ab5
commit
a7c98f6c45
68 changed files with 345 additions and 364 deletions
|
@ -80,7 +80,7 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class Aa12ItemModel extends GeoModel<Aa12Item> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class AbekiriItemModel extends GeoModel<Abekiri> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -119,7 +119,7 @@ public class BocekItemModel extends GeoModel<BocekItem> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
fire.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class DevotionItemModel extends GeoModel<Devotion> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.002f * (float) fp);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class KraberItemModel extends GeoModel<Kraber> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -61,7 +61,7 @@ public class M4ItemModel extends GeoModel<M4Item> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -102,7 +102,7 @@ public class M60ItemModel extends GeoModel<M60Item> {
|
|||
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);
|
||||
tiba.setRotZ(-0.2f * (float) fp);
|
||||
} else {
|
||||
|
|
|
@ -67,7 +67,7 @@ public class M79ItemModel extends GeoModel<M79Item> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class M870ItemModel extends GeoModel<M870Item> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class M98bItemModel extends GeoModel<M98bItem> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -71,7 +71,7 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -54,7 +54,7 @@ public class MinigunItemModel extends GeoModel<Minigun> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -78,7 +78,7 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -93,7 +93,7 @@ public class RpkItemModel extends GeoModel<RpkItem> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -94,7 +94,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SksItemModel extends GeoModel<SksItem> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class SvdItemModel extends GeoModel<SvdItem> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
|
|||
|
||||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class VectorItemModel extends GeoModel<VectorItem> {
|
|||
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);
|
||||
} else {
|
||||
shen.setRotZ(-0.003f * (float) fp);
|
||||
|
|
|
@ -28,11 +28,11 @@ public class CrosshairOverlay {
|
|||
|
||||
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.depthMask(false);
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
|
||||
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.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
|
||||
public class PvPmodeCommand {
|
||||
|
@ -36,14 +30,14 @@ public class PvPmodeCommand {
|
|||
if (entity != null)
|
||||
direction = entity.getDirection();
|
||||
|
||||
if (TargetModVariables.MapVariables.get(world).pvpmode == true) {
|
||||
TargetModVariables.MapVariables.get(world).pvpmode = false;
|
||||
if (TargetModVariables.MapVariables.get(world).pvpMode == true) {
|
||||
TargetModVariables.MapVariables.get(world).pvpMode = false;
|
||||
TargetModVariables.MapVariables.get(world).syncData(world);
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("PVPMODE:OFF"), false);
|
||||
|
||||
} else {
|
||||
TargetModVariables.MapVariables.get(world).pvpmode = true;
|
||||
TargetModVariables.MapVariables.get(world).pvpMode = true;
|
||||
TargetModVariables.MapVariables.get(world).syncData(world);
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("PVPMODE:ON"), false);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class BocekarrowEntity extends AbstractArrow implements ItemSupplier {
|
|||
if (this.getOwner() instanceof LivingEntity living) {
|
||||
double _setval = 25;
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = _setval;
|
||||
capability.hitIndicator = _setval;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
@ -121,7 +121,7 @@ public class BocekarrowEntity extends AbstractArrow implements ItemSupplier {
|
|||
setBaseDamage(getBaseDamage() * 2);
|
||||
double _setval = 25;
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.headind = _setval;
|
||||
capability.headIndicator = _setval;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
|
|
@ -81,7 +81,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
|
|||
if (this.getOwner() instanceof LivingEntity living) {
|
||||
double _setval = 25;
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = _setval;
|
||||
capability.hitIndicator = _setval;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
@ -118,7 +118,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
|
|||
setBaseDamage(getBaseDamage() * 2);
|
||||
double _setval = 25;
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.headind = _setval;
|
||||
capability.headIndicator = _setval;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
|
|
@ -327,7 +327,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
|
||||
if (this.shooter instanceof ServerPlayer player) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = 25;
|
||||
capability.hitIndicator = 25;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
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 -> {
|
||||
capability.headind = 25;
|
||||
capability.headIndicator = 25;
|
||||
capability.syncPlayerVariables(shooter);
|
||||
});
|
||||
|
||||
|
@ -357,7 +357,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
|
|||
}
|
||||
|
||||
shooter.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = 25;
|
||||
capability.hitIndicator = 25;
|
||||
capability.syncPlayerVariables(shooter);
|
||||
});
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
|
|||
Entity entity = result.getEntity();
|
||||
if (this.getOwner() instanceof LivingEntity living) {
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = 25;
|
||||
capability.hitIndicator = 25;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
@ -133,7 +133,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
|
|||
setBaseDamage(getBaseDamage() * 5);
|
||||
double _setval = 25;
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.headind = _setval;
|
||||
capability.headIndicator = _setval;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
|
|||
Entity entity = result.getEntity();
|
||||
if (this.getOwner() instanceof LivingEntity living) {
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = 25;
|
||||
capability.hitIndicator = 25;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
|
||||
|
@ -112,7 +112,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSu
|
|||
if (this.getOwner() instanceof LivingEntity living) {
|
||||
setBaseDamage(getBaseDamage() * 1.5f);
|
||||
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.headind = 25;
|
||||
capability.headIndicator = 25;
|
||||
capability.syncPlayerVariables(living);
|
||||
});
|
||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||
|
|
|
@ -282,11 +282,11 @@ public class ClientEventHandler {
|
|||
if (0 < entity.getPersistentData().getDouble("firetime") && entity.getPersistentData().getDouble("firetime") < 0.2) {
|
||||
entity.getPersistentData().putDouble("firepos",
|
||||
(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.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))));
|
||||
} 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.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))));
|
||||
|
@ -295,11 +295,11 @@ public class ClientEventHandler {
|
|||
if (0.2 <= entity.getPersistentData().getDouble("firetime") && entity.getPersistentData().getDouble("firetime") < 1) {
|
||||
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"))));
|
||||
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.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))));
|
||||
} 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.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))));
|
||||
|
|
|
@ -215,12 +215,12 @@ public class GunEventHandler {
|
|||
ItemStack heldItem = player.getMainHandItem();
|
||||
if (Math.random() < 0.5) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoilhorizon = -1;
|
||||
capability.recoilHorizon = -1;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
} else {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoilhorizon = 1;
|
||||
capability.recoilHorizon = 1;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class PlayerEventHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!TargetModVariables.MapVariables.get(player.level()).pvpmode) {
|
||||
if (!TargetModVariables.MapVariables.get(player.level()).pvpMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,32 +185,32 @@ public class PlayerEventHandler {
|
|||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
|
||||
}
|
||||
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)) {
|
||||
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"))) + "/"
|
||||
+ 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)
|
||||
|| stack.is(ItemTags.create(new ResourceLocation("target:smg")))) {
|
||||
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"))) + "/"
|
||||
+ 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)) {
|
||||
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"))) + "/"
|
||||
+ 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)) {
|
||||
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"))) + "/"
|
||||
+ 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"))) + "/"
|
||||
+ (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
|
||||
|
@ -247,7 +247,7 @@ public class PlayerEventHandler {
|
|||
private static void handleGround(Player player) {
|
||||
if (player.onGround()) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.playerdoublejump = false;
|
||||
capability.playerDoubleJump = false;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SniperAmmoBox extends Item {
|
|||
stack.shrink(1);
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class DoubleJumpMessage {
|
|||
}
|
||||
|
||||
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)));
|
||||
if (!level.isClientSide()) {
|
||||
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);
|
||||
}
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.playerdoublejump = false;
|
||||
capability.playerDoubleJump = false;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class FireMessage {
|
|||
player.getPersistentData().putDouble("minifiring", 0);
|
||||
player.getPersistentData().putDouble("minigunfiring", 0);
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.bowpullhold = false;
|
||||
capability.bowPullHold = false;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
BowlooseProcedure.execute(player);
|
||||
|
|
|
@ -1,39 +1,33 @@
|
|||
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.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.function.Supplier;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class TargetModVariables {
|
||||
|
@ -52,86 +46,85 @@ public class TargetModVariables {
|
|||
public static class EventBusVariableHandlers {
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedInSyncPlayerVariables(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.getEntity().level().isClientSide()) {
|
||||
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
|
||||
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator);
|
||||
}
|
||||
if (event.getEntity().level().isClientSide()) return;
|
||||
|
||||
for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
|
||||
entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerRespawnedSyncPlayerVariables(PlayerEvent.PlayerRespawnEvent event) {
|
||||
if (!event.getEntity().level().isClientSide()) {
|
||||
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
|
||||
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator);
|
||||
}
|
||||
if (event.getEntity().level().isClientSide()) return;
|
||||
|
||||
for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
|
||||
entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerChangedDimensionSyncPlayerVariables(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
if (!event.getEntity().level().isClientSide()) {
|
||||
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
|
||||
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator);
|
||||
}
|
||||
if (event.getEntity().level().isClientSide()) return;
|
||||
|
||||
for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
|
||||
entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clonePlayer(PlayerEvent.Clone event) {
|
||||
event.getOriginal().revive();
|
||||
PlayerVariables original = ((PlayerVariables) event.getOriginal().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()));
|
||||
PlayerVariables clone = ((PlayerVariables) event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()));
|
||||
PlayerVariables original = event.getOriginal().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.zooming = original.zooming;
|
||||
clone.recoil = original.recoil;
|
||||
clone.recoilhorizon = original.recoilhorizon;
|
||||
clone.recoilHorizon = original.recoilHorizon;
|
||||
clone.firing = original.firing;
|
||||
clone.targetangle = original.targetangle;
|
||||
clone.rifleammo = original.rifleammo;
|
||||
clone.targetAngle = original.targetAngle;
|
||||
clone.rifleAmmo = original.rifleAmmo;
|
||||
clone.refresh = original.refresh;
|
||||
clone.handgunammo = original.handgunammo;
|
||||
clone.shotgunammo = original.shotgunammo;
|
||||
clone.sniperammo = original.sniperammo;
|
||||
clone.bowpullhold = original.bowpullhold;
|
||||
clone.bowpull = original.bowpull;
|
||||
clone.playerdoublejump = original.playerdoublejump;
|
||||
clone.hitind = original.hitind;
|
||||
clone.headind = original.headind;
|
||||
clone.killind = original.killind;
|
||||
if (!event.isWasDeath()) {
|
||||
}
|
||||
if (!event.getEntity().level().isClientSide()) {
|
||||
for (Entity entityiterator : new ArrayList<>(event.getEntity().level().players())) {
|
||||
((PlayerVariables) entityiterator.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables())).syncPlayerVariables(entityiterator);
|
||||
}
|
||||
clone.handgunAmmo = original.handgunAmmo;
|
||||
clone.shotgunAmmo = original.shotgunAmmo;
|
||||
clone.sniperAmmo = original.sniperAmmo;
|
||||
clone.bowPullHold = original.bowPullHold;
|
||||
clone.bowPull = original.bowPull;
|
||||
clone.playerDoubleJump = original.playerDoubleJump;
|
||||
clone.hitIndicator = original.hitIndicator;
|
||||
clone.headIndicator = original.headIndicator;
|
||||
clone.killIndicator = original.killIndicator;
|
||||
|
||||
if (event.getEntity().level().isClientSide()) return;
|
||||
|
||||
for (Entity entity : new ArrayList<>(event.getEntity().level().players())) {
|
||||
entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()).syncPlayerVariables(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.getEntity().level().isClientSide()) {
|
||||
SavedData mapdata = MapVariables.get(event.getEntity().level());
|
||||
SavedData worlddata = WorldVariables.get(event.getEntity().level());
|
||||
if (mapdata != null)
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(0, mapdata));
|
||||
if (worlddata != null)
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worlddata));
|
||||
}
|
||||
if (event.getEntity().level().isClientSide()) return;
|
||||
|
||||
SavedData mapData = MapVariables.get(event.getEntity().level());
|
||||
SavedData worldData = WorldVariables.get(event.getEntity().level());
|
||||
if (mapData != null)
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(0, mapData));
|
||||
if (worldData != null)
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worldData));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
if (!event.getEntity().level().isClientSide()) {
|
||||
SavedData worlddata = WorldVariables.get(event.getEntity().level());
|
||||
if (worlddata != null)
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new SavedDataSyncMessage(1, worlddata));
|
||||
}
|
||||
if (event.getEntity().level().isClientSide()) return;
|
||||
|
||||
SavedData worldData = WorldVariables.get(event.getEntity().level());
|
||||
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 final String DATA_NAME = "target_worldvars";
|
||||
public static final String DATA_NAME = "target_world_variables";
|
||||
|
||||
public static WorldVariables load(CompoundTag tag) {
|
||||
WorldVariables data = new WorldVariables();
|
||||
|
@ -156,17 +149,15 @@ public class TargetModVariables {
|
|||
static WorldVariables clientSide = new WorldVariables();
|
||||
|
||||
public static WorldVariables get(LevelAccessor world) {
|
||||
if (world instanceof ServerLevel level) {
|
||||
return level.getDataStorage().computeIfAbsent(e -> WorldVariables.load(e), WorldVariables::new, DATA_NAME);
|
||||
} else {
|
||||
return clientSide;
|
||||
}
|
||||
if (world instanceof ServerLevel level)
|
||||
return level.getDataStorage().computeIfAbsent(WorldVariables::load, WorldVariables::new, DATA_NAME);
|
||||
return clientSide;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapVariables extends SavedData {
|
||||
public static final String DATA_NAME = "target_mapvars";
|
||||
public boolean pvpmode = false;
|
||||
public static final String DATA_NAME = "target_map_variables";
|
||||
public boolean pvpMode = false;
|
||||
|
||||
public static MapVariables load(CompoundTag tag) {
|
||||
MapVariables data = new MapVariables();
|
||||
|
@ -174,14 +165,14 @@ public class TargetModVariables {
|
|||
return data;
|
||||
}
|
||||
|
||||
public void read(CompoundTag nbt) {
|
||||
pvpmode = nbt.getBoolean("pvpmode");
|
||||
public static MapVariables get(LevelAccessor world) {
|
||||
if (world instanceof ServerLevelAccessor serverLevelAcc)
|
||||
return serverLevelAcc.getLevel().getServer().getLevel(Level.OVERWORLD).getDataStorage().computeIfAbsent(MapVariables::load, MapVariables::new, DATA_NAME);
|
||||
return clientSide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag nbt) {
|
||||
nbt.putBoolean("pvpmode", pvpmode);
|
||||
return nbt;
|
||||
public void read(CompoundTag nbt) {
|
||||
pvpMode = nbt.getBoolean("pvp_mode");
|
||||
}
|
||||
|
||||
public void syncData(LevelAccessor world) {
|
||||
|
@ -192,12 +183,10 @@ public class TargetModVariables {
|
|||
|
||||
static MapVariables clientSide = new MapVariables();
|
||||
|
||||
public static MapVariables get(LevelAccessor world) {
|
||||
if (world instanceof ServerLevelAccessor serverLevelAcc) {
|
||||
return serverLevelAcc.getLevel().getServer().getLevel(Level.OVERWORLD).getDataStorage().computeIfAbsent(e -> MapVariables.load(e), MapVariables::new, DATA_NAME);
|
||||
} else {
|
||||
return clientSide;
|
||||
}
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag nbt) {
|
||||
nbt.putBoolean("pvp_mode", pvpMode);
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,13 +197,13 @@ public class TargetModVariables {
|
|||
public SavedDataSyncMessage(FriendlyByteBuf buffer) {
|
||||
this.type = buffer.readInt();
|
||||
CompoundTag nbt = buffer.readNbt();
|
||||
if (nbt != null) {
|
||||
this.data = this.type == 0 ? new MapVariables() : new WorldVariables();
|
||||
if (this.data instanceof MapVariables mapVariables)
|
||||
mapVariables.read(nbt);
|
||||
else if (this.data instanceof WorldVariables worldVariables)
|
||||
worldVariables.read(nbt);
|
||||
}
|
||||
if (nbt == null) return;
|
||||
|
||||
this.data = this.type == 0 ? new MapVariables() : new WorldVariables();
|
||||
if (this.data instanceof MapVariables mapVariables)
|
||||
mapVariables.read(nbt);
|
||||
else if (this.data instanceof WorldVariables worldVariables)
|
||||
worldVariables.read(nbt);
|
||||
}
|
||||
|
||||
public SavedDataSyncMessage(int type, SavedData data) {
|
||||
|
@ -276,23 +265,23 @@ public class TargetModVariables {
|
|||
public boolean zoom = false;
|
||||
public boolean zooming = false;
|
||||
public double recoil = 0;
|
||||
public double recoilhorizon = 0;
|
||||
public double recoilHorizon = 0;
|
||||
public double firing = 0;
|
||||
public double targetangle = 0;
|
||||
public double rifleammo = 0;
|
||||
public double targetAngle = 0;
|
||||
public double rifleAmmo = 0;
|
||||
public boolean refresh = false;
|
||||
public double handgunammo = 0;
|
||||
public double shotgunammo = 0;
|
||||
public double sniperammo = 0;
|
||||
public boolean bowpullhold = false;
|
||||
public boolean bowpull = false;
|
||||
public boolean playerdoublejump = false;
|
||||
public double hitind = 0;
|
||||
public double headind = 0;
|
||||
public double killind = 0;
|
||||
public double handgunAmmo = 0;
|
||||
public double shotgunAmmo = 0;
|
||||
public double sniperAmmo = 0;
|
||||
public boolean bowPullHold = false;
|
||||
public boolean bowPull = false;
|
||||
public boolean playerDoubleJump = false;
|
||||
public double hitIndicator = 0;
|
||||
public double headIndicator = 0;
|
||||
public double killIndicator = 0;
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
|
@ -301,20 +290,20 @@ public class TargetModVariables {
|
|||
nbt.putBoolean("zoom", zoom);
|
||||
nbt.putBoolean("zooming", zooming);
|
||||
nbt.putDouble("recoil", recoil);
|
||||
nbt.putDouble("recoilhorizon", recoilhorizon);
|
||||
nbt.putDouble("recoil_horizon", recoilHorizon);
|
||||
nbt.putDouble("firing", firing);
|
||||
nbt.putDouble("targetangle", targetangle);
|
||||
nbt.putDouble("rifleammo", rifleammo);
|
||||
nbt.putDouble("target_angle", targetAngle);
|
||||
nbt.putDouble("rifle_ammo", rifleAmmo);
|
||||
nbt.putBoolean("refresh", refresh);
|
||||
nbt.putDouble("handgunammo", handgunammo);
|
||||
nbt.putDouble("shotgunammo", shotgunammo);
|
||||
nbt.putDouble("sniperammo", sniperammo);
|
||||
nbt.putBoolean("bowpullhold", bowpullhold);
|
||||
nbt.putBoolean("bowpull", bowpull);
|
||||
nbt.putBoolean("playerdoublejump", playerdoublejump);
|
||||
nbt.putDouble("hitind", hitind);
|
||||
nbt.putDouble("headind", headind);
|
||||
nbt.putDouble("killind", killind);
|
||||
nbt.putDouble("handgun_ammo", handgunAmmo);
|
||||
nbt.putDouble("shotgun_ammo", shotgunAmmo);
|
||||
nbt.putDouble("sniper_ammo", sniperAmmo);
|
||||
nbt.putBoolean("bow_pull_hold", bowPullHold);
|
||||
nbt.putBoolean("bow_pull", bowPull);
|
||||
nbt.putBoolean("player_double_jump", playerDoubleJump);
|
||||
nbt.putDouble("hit_indicator", hitIndicator);
|
||||
nbt.putDouble("head_indicator", headIndicator);
|
||||
nbt.putDouble("kill_indicator", killIndicator);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
|
@ -323,20 +312,20 @@ public class TargetModVariables {
|
|||
zoom = nbt.getBoolean("zoom");
|
||||
zooming = nbt.getBoolean("zooming");
|
||||
recoil = nbt.getDouble("recoil");
|
||||
recoilhorizon = nbt.getDouble("recoilhorizon");
|
||||
recoilHorizon = nbt.getDouble("recoil_horizon");
|
||||
firing = nbt.getDouble("firing");
|
||||
targetangle = nbt.getDouble("targetangle");
|
||||
rifleammo = nbt.getDouble("rifleammo");
|
||||
targetAngle = nbt.getDouble("target_angle");
|
||||
rifleAmmo = nbt.getDouble("rifle_ammo");
|
||||
refresh = nbt.getBoolean("refresh");
|
||||
handgunammo = nbt.getDouble("handgunammo");
|
||||
shotgunammo = nbt.getDouble("shotgunammo");
|
||||
sniperammo = nbt.getDouble("sniperammo");
|
||||
bowpullhold = nbt.getBoolean("bowpullhold");
|
||||
bowpull = nbt.getBoolean("bowpull");
|
||||
playerdoublejump = nbt.getBoolean("playerdoublejump");
|
||||
hitind = nbt.getDouble("hitind");
|
||||
headind = nbt.getDouble("headind");
|
||||
killind = nbt.getDouble("killind");
|
||||
handgunAmmo = nbt.getDouble("handgun_ammo");
|
||||
shotgunAmmo = nbt.getDouble("shotgun_ammo");
|
||||
sniperAmmo = nbt.getDouble("sniper_ammo");
|
||||
bowPullHold = nbt.getBoolean("bow_pull_hold");
|
||||
bowPull = nbt.getBoolean("bow_pull");
|
||||
playerDoubleJump = nbt.getBoolean("player_double_jump");
|
||||
hitIndicator = nbt.getDouble("hit_indicator");
|
||||
headIndicator = nbt.getDouble("head_indicator");
|
||||
killIndicator = nbt.getDouble("kill_indicator");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,9 +344,9 @@ public class TargetModVariables {
|
|||
this.target = buffer.readInt();
|
||||
}
|
||||
|
||||
public PlayerVariablesSyncMessage(PlayerVariables data, int entityid) {
|
||||
public PlayerVariablesSyncMessage(PlayerVariables data, int entityId) {
|
||||
this.data = data;
|
||||
this.target = entityid;
|
||||
this.target = entityId;
|
||||
}
|
||||
|
||||
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) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
if (!context.getDirection().getReceptionSide().isServer()) {
|
||||
PlayerVariables variables = ((PlayerVariables) Minecraft.getInstance().player.level().getEntity(message.target).getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()));
|
||||
variables.zoom = message.data.zoom;
|
||||
variables.zooming = message.data.zooming;
|
||||
variables.recoil = message.data.recoil;
|
||||
variables.recoilhorizon = message.data.recoilhorizon;
|
||||
variables.firing = message.data.firing;
|
||||
variables.targetangle = message.data.targetangle;
|
||||
variables.rifleammo = message.data.rifleammo;
|
||||
variables.refresh = message.data.refresh;
|
||||
variables.handgunammo = message.data.handgunammo;
|
||||
variables.shotgunammo = message.data.shotgunammo;
|
||||
variables.sniperammo = message.data.sniperammo;
|
||||
variables.bowpullhold = message.data.bowpullhold;
|
||||
variables.bowpull = message.data.bowpull;
|
||||
variables.playerdoublejump = message.data.playerdoublejump;
|
||||
variables.hitind = message.data.hitind;
|
||||
variables.headind = message.data.headind;
|
||||
variables.killind = message.data.killind;
|
||||
}
|
||||
context.setPacketHandled(true);
|
||||
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.zooming = message.data.zooming;
|
||||
variables.recoil = message.data.recoil;
|
||||
variables.recoilHorizon = message.data.recoilHorizon;
|
||||
variables.firing = message.data.firing;
|
||||
variables.targetAngle = message.data.targetAngle;
|
||||
variables.rifleAmmo = message.data.rifleAmmo;
|
||||
variables.refresh = message.data.refresh;
|
||||
variables.handgunAmmo = message.data.handgunAmmo;
|
||||
variables.shotgunAmmo = message.data.shotgunAmmo;
|
||||
variables.sniperAmmo = message.data.sniperAmmo;
|
||||
variables.bowPullHold = message.data.bowPullHold;
|
||||
variables.bowPull = message.data.bowPull;
|
||||
variables.playerDoubleJump = message.data.playerDoubleJump;
|
||||
variables.hitIndicator = message.data.hitIndicator;
|
||||
variables.headIndicator = message.data.headIndicator;
|
||||
variables.killIndicator = message.data.killIndicator;
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ public class AA12ReloadProcedure {
|
|||
double ammo = tag.getDouble("ammo");
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -86,11 +86,11 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ public class AbekiriWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class BowPullAnimationProcedure {
|
|||
}
|
||||
float times = 90f / fps;
|
||||
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) {
|
||||
persistentData.putDouble("pulltime", (persistentData.getDouble("pulltime") + 0.014 * times));
|
||||
} 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));
|
||||
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) {
|
||||
persistentData.putDouble("bowtime", (persistentData.getDouble("bowtime") + 0.014 * times));
|
||||
} 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));
|
||||
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) {
|
||||
persistentData.putDouble("handtime", (persistentData.getDouble("handtime") + 0.014 * times));
|
||||
} else {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class BowlooseProcedure {
|
|||
}
|
||||
}
|
||||
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.firing = 1;
|
||||
capability.syncPlayerVariables(player);
|
||||
|
|
|
@ -27,28 +27,28 @@ public class CreativeAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
|||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.sniperammo = _setval;
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class GunRecoilProcedure {
|
|||
|
||||
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 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 totalTime = 100;
|
||||
|
|
|
@ -25,9 +25,9 @@ public class HandgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
|||
_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 -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ public class HandgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
|||
if (entity == null)
|
||||
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 -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ public class HandgunReload1Procedure {
|
|||
ItemStack stack;
|
||||
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
|
||||
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 -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ public class HandgunReload1Procedure {
|
|||
stack.getOrCreateTag().putDouble("reloading", 0);
|
||||
stack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ public class HandgunReload2Procedure {
|
|||
ItemStack stack;
|
||||
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
|
||||
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 -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ public class HandgunReload2Procedure {
|
|||
stack.getOrCreateTag().putDouble("reloading", 0);
|
||||
stack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunammo = _setval;
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class Hitindication2Procedure {
|
|||
{
|
||||
double _setval = 25;
|
||||
sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.hitind = _setval;
|
||||
capability.hitIndicator = _setval;
|
||||
capability.syncPlayerVariables(sourceentity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,29 +32,29 @@ public class HitindicationProcedure {
|
|||
while (recoilTimer[0] < recoilDuration) {
|
||||
if (entity == null)
|
||||
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 -> {
|
||||
capability.hitind = _setval;
|
||||
capability.hitIndicator = _setval;
|
||||
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 -> {
|
||||
capability.headind = _setval;
|
||||
capability.headIndicator = _setval;
|
||||
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 -> {
|
||||
capability.killind = _setval;
|
||||
capability.killIndicator = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class JumppadBlockShiTiZaiFangKuaiZhongPengZhuangShiProcedure {
|
|||
{
|
||||
boolean _setval = true;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.playerdoublejump = _setval;
|
||||
capability.playerDoubleJump = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class KillindicationProcedure {
|
|||
{
|
||||
double _setval = 40;
|
||||
sourceentity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.killind = _setval;
|
||||
capability.killIndicator = _setval;
|
||||
capability.syncPlayerVariables(sourceentity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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()))
|
||||
&& usehand.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
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.firing = 1;
|
||||
capability.syncPlayerVariables(entity);
|
||||
|
|
|
@ -42,15 +42,15 @@ public class M870WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
if (itemstack.getOrCreateTag().getDouble("prepare") == 10 && itemstack.getOrCreateTag().getDouble("emptyreload") == 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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
}
|
||||
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) {
|
||||
itemstack.getOrCreateTag().putDouble("stop", 1);
|
||||
} else {
|
||||
|
@ -73,14 +73,14 @@ public class M870WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
if (itemstack.getOrCreateTag().getDouble("loading") == 9) {
|
||||
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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
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().putDouble("forcestop", 0);
|
||||
itemstack.getOrCreateTag().putDouble("stop", 0);
|
||||
|
|
|
@ -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("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) {
|
||||
itemstack.getOrCreateTag().putDouble("stop", 1);
|
||||
} else {
|
||||
|
@ -60,14 +60,14 @@ public class MarlinWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
if (itemstack.getOrCreateTag().getDouble("loading") == 9) {
|
||||
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 -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
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().putDouble("forcestop", 0);
|
||||
itemstack.getOrCreateTag().putDouble("stop", 0);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class MinigunautofireProcedure {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
usehand.getOrCreateTag().putDouble("heat", (usehand.getOrCreateTag().getDouble("heat") + 1));
|
||||
if (usehand.getOrCreateTag().getDouble("heat") >= 50.5) {
|
||||
|
@ -73,7 +73,7 @@ public class MinigunautofireProcedure {
|
|||
GunsTool.spawnBullet(player);
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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("emptyreload", 1);
|
||||
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
|
||||
|
@ -41,7 +41,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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("reloadtime", 61);
|
||||
tag.putDouble("emptyreload", 1);
|
||||
|
@ -71,7 +71,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -88,7 +88,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -105,7 +105,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -122,7 +122,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -139,7 +139,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -156,7 +156,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -173,7 +173,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -191,7 +191,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -208,7 +208,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -224,7 +224,7 @@ public class PlayerReloadProcedure {
|
|||
if (player.getMainHandItem().getItem() == TargetModItems.DEVOTION.get()
|
||||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& 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) {
|
||||
if (tag.getDouble("ammo") > 0) {
|
||||
tag.putDouble("reloading", 1);
|
||||
|
@ -241,7 +241,7 @@ public class PlayerReloadProcedure {
|
|||
if (player.getMainHandItem().getItem() == TargetModItems.RPK.get()
|
||||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& 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) {
|
||||
if (tag.getDouble("ammo") > 0) {
|
||||
tag.putDouble("reloading", 1);
|
||||
|
@ -259,7 +259,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -276,7 +276,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("reloading", 1);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
|
@ -292,7 +292,7 @@ public class PlayerReloadProcedure {
|
|||
if (player.getMainHandItem().getItem() == TargetModItems.M_60.get()
|
||||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& 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) {
|
||||
if (tag.getDouble("ammo") > 0) {
|
||||
tag.putDouble("reloading", 1);
|
||||
|
@ -310,7 +310,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
|
||||
player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 5);
|
||||
|
@ -324,7 +324,7 @@ public class PlayerReloadProcedure {
|
|||
&& !(player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem()))
|
||||
&& tag.getDouble("reloading") == 0
|
||||
&& 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) {
|
||||
tag.putDouble("emptyreload", 1);
|
||||
tag.putDouble("reloading", 1);
|
||||
|
|
|
@ -33,14 +33,14 @@ public class PressFireProcedure {
|
|||
}
|
||||
}
|
||||
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) {
|
||||
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.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.bowpullhold = true;
|
||||
capability.bowPullHold = true;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
if (player.getMainHandItem().getOrCreateTag().getDouble("ammo") == 0) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
|
|||
private static void execute(@Nullable Event event, Entity entity) {
|
||||
if (entity == null)
|
||||
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()
|
||||
&& (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()))
|
||||
|
@ -42,7 +42,7 @@ public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
|
|||
{
|
||||
boolean _setval = true;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.bowpull = _setval;
|
||||
capability.bowPull = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class PullXiaoGuoChiXuShiMeiKeFaShengProcedure {
|
|||
{
|
||||
boolean _setval = false;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.bowpull = _setval;
|
||||
capability.bowPull = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
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.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class Reload1Procedure {
|
||||
public static void execute(Entity entity) {
|
||||
|
@ -14,11 +13,11 @@ public class Reload1Procedure {
|
|||
ItemStack stack = ItemStack.EMPTY;
|
||||
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
|
||||
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 -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -26,11 +25,11 @@ public class Reload1Procedure {
|
|||
stack.getOrCreateTag().putDouble("reloading", 0);
|
||||
stack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
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.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class Reload2Procedure {
|
||||
public static void execute(Entity entity) {
|
||||
|
@ -15,11 +14,11 @@ public class Reload2Procedure {
|
|||
double ammo1 = 0;
|
||||
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
|
||||
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 -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -27,11 +26,11 @@ public class Reload2Procedure {
|
|||
stack.getOrCreateTag().putDouble("reloading", 0);
|
||||
stack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ public class RifleAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
|||
_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 -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ public class RifleAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
|||
if (entity == null)
|
||||
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 -> {
|
||||
capability.rifleammo = _setval;
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class RpgFireProcedure {
|
|||
if (mainHandItem.getItem() == TargetModItems.RPG.get() && tag.getDouble("reloading") == 0 && !player.getCooldowns().isOnCooldown(mainHandItem.getItem())
|
||||
&& tag.getDouble("ammo") > 0) {
|
||||
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.firing = 1;
|
||||
capability.syncPlayerVariables(player);
|
||||
|
|
|
@ -25,9 +25,9 @@ public class ShotgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
|||
_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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ public class ShotgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
|||
if (entity == null)
|
||||
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 -> {
|
||||
capability.shotgunammo = _setval;
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ public class SniperAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
|||
if (entity == null)
|
||||
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 -> {
|
||||
capability.sniperammo = _setval;
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ public class SniperReload1Procedure {
|
|||
id = stack.getOrCreateTag().getDouble("id");
|
||||
ammo1 = stack.getOrCreateTag().getDouble("mag") - 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 -> {
|
||||
capability.sniperammo = _setval;
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ public class SniperReload1Procedure {
|
|||
stack.getOrCreateTag().putDouble("reloading", 0);
|
||||
stack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.sniperammo = _setval;
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ public class SniperReload2Procedure {
|
|||
id = stack.getOrCreateTag().getDouble("id");
|
||||
ammo1 = stack.getOrCreateTag().getDouble("mag") - 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 -> {
|
||||
capability.sniperammo = _setval;
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ public class SniperReload2Procedure {
|
|||
stack.getOrCreateTag().putDouble("reloading", 0);
|
||||
stack.getOrCreateTag().putDouble("emptyreload", 0);
|
||||
} 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;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.sniperammo = _setval;
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TaserfireProcedure {
|
|||
&& usehand.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
|
||||
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.firing = 1;
|
||||
capability.syncPlayerVariables(entity);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class GunsTool {
|
|||
}
|
||||
|
||||
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) {
|
||||
stack.getOrCreateTag().putDouble("damageadd", 1 + 0.05 * (stack.getOrCreateTag().getDouble("level") - 10));
|
||||
} else {
|
||||
|
@ -89,7 +89,7 @@ public class GunsTool {
|
|||
public static void spawnBullet(Player player) {
|
||||
ItemStack heldItem = player.getMainHandItem();
|
||||
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.firing = 1;
|
||||
capability.syncPlayerVariables(player);
|
||||
|
|
Loading…
Add table
Reference in a new issue