重做转动视角武器偏移

This commit is contained in:
Atsuihsio 2024-06-05 14:05:54 +08:00
parent 622e345c51
commit b284608dd9
29 changed files with 391 additions and 592 deletions

View file

@ -14,7 +14,7 @@ def getGitCommitHash() {
return stdout.toString().trim()
}
version = '0.1.1-SNAPSHOT-' + getGitCommitHash()
version = '0.1.2-SNAPSHOT-' + getGitCommitHash()
group = 'com.Atsushio.target'
archivesBaseName = 'target'

View file

@ -136,21 +136,23 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
double m = player.getPersistentData().getDouble("move");
double yaw = player.getPersistentData().getDouble("yaw");
double pit = player.getPersistentData().getDouble("gun_pitch");
double vy = player.getPersistentData().getDouble("vy");
move.setPosY(-0.95f * (float) vy);
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0.7f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(0.7f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -111,28 +111,25 @@ public class Aa12ItemModel extends GeoModel<Aa12Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.Abekiri;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -95,26 +96,24 @@ public class AbekiriItemModel extends GeoModel<Abekiri> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -655,27 +655,25 @@ public class DevotionItemModel extends GeoModel<Devotion> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-1.2f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(1.8f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(1.6f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
if (player.getPersistentData().getDouble("prone") > 0) {
l.setRotX(1.5f);

View file

@ -122,27 +122,25 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-1.2f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0.75f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(0.75f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -97,27 +97,25 @@ public class HuntingRifleItemModel extends GeoModel<HuntingRifle> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.Kraber;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -120,41 +121,24 @@ public class KraberItemModel extends GeoModel<Kraber> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double vy = player.getPersistentData().getDouble("vy");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
move.setPosX(9.3f * (float) m);
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-0.8f * (float) vy);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
double xRot = player.getPersistentData().getDouble("xRot");
move.setPosX(0);
double yRot = player.getPersistentData().getDouble("yRot");
move.setRotX(0);
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotZ(0);
move.setRotX(0.8f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(0);
move.setRotY(0.6f * Mth.DEG_TO_RAD * (float) yRot);
move.setPosY(-0.2f * (float) vy);
} else {
move.setPosY(-1 * (float) vy);
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
}
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -112,27 +112,25 @@ public class M4ItemModel extends GeoModel<M4Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-1.0f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0.65f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(0.65f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.M60Item;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -152,26 +153,24 @@ public class M60ItemModel extends GeoModel<M60Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1.6f * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-1.6f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -110,27 +110,25 @@ public class M79ItemModel extends GeoModel<M79Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1f * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.M870Item;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -122,26 +123,24 @@ public class M870ItemModel extends GeoModel<M870Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.M98bItem;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -128,26 +129,24 @@ public class M98bItemModel extends GeoModel<M98bItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -102,27 +102,25 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.Minigun;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -105,26 +106,24 @@ public class MinigunItemModel extends GeoModel<Minigun> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1.8f * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(2.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(3.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.Mk14Item;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -141,39 +142,24 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double vy = player.getPersistentData().getDouble("vy");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
move.setPosX(9.3f * (float) m);
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-0.95f * (float) vy);
move.setPosY(-1 * (float) vy);
double xRot = player.getPersistentData().getDouble("xRot");
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
double yRot = player.getPersistentData().getDouble("yRot");
move.setPosX(0);
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0);
move.setRotX(1.6f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotZ(0);
move.setRotY(1.6f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotY(0);
} else {
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setRotZ(2.7f * (float) yaw + 2.7f * (float) m);
move.setRotY(3.9f * (float) yaw - 1.7f * (float) m);
}
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -117,27 +117,25 @@ public class RpgItemModel extends GeoModel<RpgItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1.3f * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -141,27 +141,25 @@ public class RpkItemModel extends GeoModel<RpkItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0.6f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(0.6f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.SentinelItem;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -139,42 +140,25 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double vy = player.getPersistentData().getDouble("vy");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
move.setPosX(9.3f * (float) m);
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-0.95f * (float) vy);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
double xRot = player.getPersistentData().getDouble("xRot");
move.setPosY(-0.2f * (float) vy);
double yRot = player.getPersistentData().getDouble("yRot");
move.setPosX(0.3f * (float) m);
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0.5f * (float) pit);
move.setRotX(1.4f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotZ(0.7f * (float) yaw + 0.2f * (float) m);
move.setRotY(1.4f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotY(0.9f * (float) yaw - 0.7f * (float) m);
} else {
move.setPosY(-1.3f * (float) vy);
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
}
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone flare = getAnimationProcessor().getBone("flare");

View file

@ -128,28 +128,25 @@ public class SksItemModel extends GeoModel<SksItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -42,9 +42,6 @@ public class SvdItemModel extends GeoModel<SvdItem> {
Player player = Minecraft.getInstance().player;
ItemStack stack = player.getMainHandItem();
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
if (stack.getOrCreateTag().getDouble("gj") == 1) {
bolt.setPosZ(3.25f);
}
@ -153,24 +150,25 @@ public class SvdItemModel extends GeoModel<SvdItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
glass.setPosX(0.25f * -PosX);

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.Taser;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
@ -95,27 +96,25 @@ public class TaserItemModel extends GeoModel<Taser> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -97,27 +97,25 @@ public class TracheliumItemModel extends GeoModel<Trachelium> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1.5f * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-0.95f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
CoreGeoBone camera = getAnimationProcessor().getBone("camera");

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.VectorItem;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
@ -115,26 +116,24 @@ public class VectorItemModel extends GeoModel<VectorItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0;
m = player.getPersistentData().getDouble("move");
double m = player.getPersistentData().getDouble("move");
double yaw = 0;
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy);
double vy = player.getPersistentData().getDouble("vy");
move.setPosX(9.3f * (float) m);
move.setRotX(2.0f * (float) pit);
move.setPosY(-1.2f * (float) vy);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
double xRot = player.getPersistentData().getDouble("xRot");
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
double yRot = player.getPersistentData().getDouble("yRot");
double zRot = player.getPersistentData().getDouble("zRot");
move.setRotX(0.7f * Mth.DEG_TO_RAD * (float) xRot);
move.setRotY(0.7f * Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
}
}

View file

@ -253,7 +253,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
Vec3 movement = this.getDeltaMovement();
this.setDeltaMovement(movement.x, movement.y - 0.1, movement.z);
this.setDeltaMovement(movement.x, movement.y - 0.05, movement.z);
this.tickCount++;
if (this.tickCount > 30) {

View file

@ -7,7 +7,9 @@ import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
@ -16,6 +18,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.ViewportEvent;
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -24,6 +27,22 @@ import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ClientEventHandler {
@SubscribeEvent
public static void onRenderHand(RenderHandEvent event) {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) {
return;
}
var data = player.getPersistentData();
float xRotOffset = Mth.lerp(event.getPartialTick(), player.xBobO, player.xBob);
float yRotOffset = Mth.lerp(event.getPartialTick(), player.yBobO, player.yBob);
float xRot = player.getViewXRot(event.getPartialTick()) - xRotOffset;
float yRot = player.getViewYRot(event.getPartialTick()) - yRotOffset;
data.putDouble("xRot", Mth.clamp(0.05 * xRot,-5,5) * (1 - 0.75 * data.getDouble("zoom_time")));
data.putDouble("yRot", Mth.clamp(0.05 * yRot,-10,10) * (1 - 0.75 * data.getDouble("zoom_time")));
data.putDouble("zRot", Mth.clamp(0.1 * yRot,-10,10) * (1 - data.getDouble("zoom_time")));
}
@SubscribeEvent
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
ClientLevel level = Minecraft.getInstance().level;
@ -183,155 +202,16 @@ public class ClientEventHandler {
((data.getDouble("move") - Math.pow(Math.abs(data.getDouble("move")) + 0.05, 2) * 0.2 * times * (1 - 0.1 * data.getDouble("zoom_time")))
* (1 - 0.1 * data.getDouble("zoom_time"))));
}
if (data.getDouble("turnr") == 1) {
data.putDouble("turntimeyaw", (data.getDouble("turntimeyaw") + 0.08 * times * Math.pow(data.getDouble("amplitudeyaw"), 2)));
}
if (data.getDouble("turnl") == 1) {
data.putDouble("turntimeyaw", (data.getDouble("turntimeyaw") - 0.08 * times * Math.pow(data.getDouble("amplitudeyaw"), 2)));
}
if (data.getDouble("turntimeyaw") > 1) {
data.putDouble("turntimeyaw", 1);
}
if (data.getDouble("turntimeyaw") < -1) {
data.putDouble("turntimeyaw", (-1));
}
if (data.getDouble("turntimeyaw") >= 0) {
if (data.getDouble("turnr") == 0) {
data.putDouble("turntimeyaw", (data.getDouble("turntimeyaw") - 0.02 * times));
}
}
if (data.getDouble("turntimeyaw") < 0) {
if (data.getDouble("turnl") == 0) {
data.putDouble("turntimeyaw", (data.getDouble("turntimeyaw") + 0.02 * times));
}
}
if (data.getDouble("amplitudeyaw") < Math.abs(data.getDouble("r1") - data.getDouble("r2"))) {
data.putDouble("amplitudeyaw", (data.getDouble("amplitudeyaw")
+ 0.005 * Math.sin(0.5 * Math.PI * (Math.abs(data.getDouble("r1") - data.getDouble("r2")) - data.getDouble("amplitudeyaw")))));
} else {
data.putDouble("amplitudeyaw", (data.getDouble("amplitudeyaw")
- 0.005 * Math.sin(0.5 * Math.PI * (Math.abs(data.getDouble("r1") - data.getDouble("r2")) - data.getDouble("amplitudeyaw")))));
}
if (data.getDouble("amplitudeyaw") > 0) {
data.putDouble("amplitudeyaw", (data.getDouble("amplitudeyaw") - 0.01 * Math.pow(data.getDouble("amplitudeyaw"), 2)));
} else {
data.putDouble("amplitudeyaw", (data.getDouble("amplitudeyaw") + 0.01 * Math.pow(data.getDouble("amplitudeyaw"), 2)));
}
data.putDouble("yaw", (0.04 * Math.tan(0.25 * Math.PI * data.getDouble("turntimeyaw")) * (1 - 1 * data.getDouble("zoom_time"))));
if (data.getDouble("turnu") == 1) {
data.putDouble("turntimepitch", (data.getDouble("turntimepitch") + 0.02 * times));
}
if (data.getDouble("turnd") == 1) {
data.putDouble("turntimepitch", (data.getDouble("turntimepitch") - 0.02 * times));
}
if (data.getDouble("turntimepitch") > 1) {
data.putDouble("turntimepitch", 1);
}
if (data.getDouble("turntimepitch") < -1) {
data.putDouble("turntimepitch", (-1));
}
if (data.getDouble("turntimepitch") >= 0) {
if (data.getDouble("turnu") == 0) {
data.putDouble("turntimepitch", (data.getDouble("turntimepitch") - 0.04 * times));
}
}
if (data.getDouble("turntimepitch") < 0) {
if (data.getDouble("turnd") == 0) {
data.putDouble("turntimepitch", (data.getDouble("turntimepitch") + 0.04 * times));
}
}
if (data.getDouble("amplitudepitch") < Math.abs(data.getDouble("p1") - data.getDouble("p2"))) {
data.putDouble("amplitudepitch", (data.getDouble("amplitudepitch")
+ 0.00001 * Math.pow(Math.abs(data.getDouble("p1") - data.getDouble("p2")) - data.getDouble("amplitudepitch"), 2)));
} else {
data.putDouble("amplitudepitch", (data.getDouble("amplitudepitch")
- 0.00001 * Math.pow(Math.abs(data.getDouble("p1") - data.getDouble("p2")) - data.getDouble("amplitudepitch"), 2)));
}
if (data.getDouble("amplitudepitch") > 0) {
data.putDouble("amplitudepitch", (data.getDouble("amplitudepitch") - 0.01 * Math.pow(data.getDouble("amplitudepitch"), 2)));
} else {
data.putDouble("amplitudepitch", (data.getDouble("amplitudepitch") + 0.01 * Math.pow(data.getDouble("amplitudepitch"), 2)));
}
data.putDouble("gun_pitch",
((0.15 * data.getDouble("amplitudepitch") * Math.tan(0.25 * Math.PI * data.getDouble("turntimepitch")) * (1 - 0.8 * data.getDouble("zoom_time"))
- 0.05 * data.getDouble("vy")) * (1 - 1 * data.getDouble("zoom_time"))));
if (data.getDouble("firetime") == 0) {
data.putDouble("rottime", (data.getDouble("rottime") + 1));
if (data.getDouble("rottime") >= 3) {
data.putDouble("rottime", 0);
}
if (data.getDouble("rottime") == 1) {
data.putDouble("r1", (entity.getYRot()));
data.putDouble("p1", (entity.getXRot()));
}
if (data.getDouble("rottime") == 2) {
data.putDouble("r2", (entity.getYRot()));
data.putDouble("p2", (entity.getXRot()));
}
if (0 > data.getDouble("r1") - data.getDouble("r2")) {
data.putDouble("rot", (data.getDouble("rot") - 0.01));
} else if (0 < data.getDouble("r1") - data.getDouble("r2")) {
data.putDouble("rot", (data.getDouble("rot") + 0.01));
} else if (0 == data.getDouble("r1") - data.getDouble("r2")) {
data.putDouble("rot", 0);
}
if (0 > data.getDouble("p1") - data.getDouble("p2")) {
data.putDouble("pit", (data.getDouble("pit") - 0.01));
} else if (0 < data.getDouble("p1") - data.getDouble("p2")) {
data.putDouble("pit", (data.getDouble("pit") + 0.01));
} else if (0 == data.getDouble("p1") - data.getDouble("p2")) {
data.putDouble("pit", 0);
}
if (data.getDouble("rot") < 0) {
data.putDouble("rot", (data.getDouble("rot") + 2 * times * Math.pow(data.getDouble("rot"), 2)));
if (data.getDouble("rot") < -0.04) {
data.putDouble("turnr", 1);
data.putDouble("turnl", 0);
}
} else if (data.getDouble("rot") > 0) {
data.putDouble("rot", (data.getDouble("rot") - 2 * times * Math.pow(data.getDouble("rot"), 2)));
if (data.getDouble("rot") > 0.04) {
data.putDouble("turnl", 1);
data.putDouble("turnr", 0);
}
} else {
data.putDouble("rot", 0);
data.putDouble("turnl", 0);
data.putDouble("turnr", 0);
}
if (data.getDouble("pit") < 0) {
data.putDouble("pit", (data.getDouble("pit") + 2 * times * Math.pow(data.getDouble("pit"), 2)));
if (data.getDouble("pit") < -0.034) {
data.putDouble("turnu", 1);
data.putDouble("turnd", 0);
}
} else if (data.getDouble("pit") > 0) {
data.putDouble("pit", (data.getDouble("pit") - 2 * times * Math.pow(data.getDouble("pit"), 2)));
if (data.getDouble("pit") > 0.034) {
data.putDouble("turnd", 1);
data.putDouble("turnu", 0);
}
} else {
data.putDouble("pit", 0);
data.putDouble("turnd", 0);
data.putDouble("turnu", 0);
}
} else {
data.putDouble("pit", 0);
data.putDouble("turnl", 0);
data.putDouble("turnr", 0);
data.putDouble("turnd", 0);
data.putDouble("turnu", 0);
}
double velocity = entity.getDeltaMovement().y();
if (-0.8 < velocity + 0.078 && velocity + 0.078 < 0.8) {
if (data.getDouble("vy") < entity.getDeltaMovement().y() + 0.078) {
data.putDouble("vy",
((data.getDouble("vy") + 0.5 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.6 * data.getDouble("zoom_time"))));
((data.getDouble("vy") + 0.5 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.3 * data.getDouble("zoom_time"))));
} else {
data.putDouble("vy",
((data.getDouble("vy") - 0.5 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.6 * data.getDouble("zoom_time"))));
((data.getDouble("vy") - 0.5 * Math.pow((velocity + 0.078) - data.getDouble("vy"), 2)) * (1 - 0.3 * data.getDouble("zoom_time"))));
}
}
if (data.getDouble("vy") > 0.8) {

View file

@ -35,67 +35,11 @@ public class GunEventHandler {
}
if (event.phase == TickEvent.Phase.END) {
handleGunsDev(player);
handleGunFire(player);
handleMiniGunFire(player);
}
}
private static void handleGunsDev(Player player) {
if (player == null) {
return;
}
ItemStack stack = player.getMainHandItem();
double basic = stack.getOrCreateTag().getDouble("dev");
double sprint = player.isSprinting() ? 0.5 * basic : 0;
double sneaking = player.isShiftKeyDown() ? (-0.25) * basic : 0;
double prone = player.getPersistentData().getDouble("prone") > 0 ? (-0.5) * basic : 0;
double jump = player.onGround() ? 0 : 1.5 * basic;
double fire = stack.getOrCreateTag().getInt("fire_animation") > 0 ? 0.5 * basic : 0;
double ride = player.isPassenger() ? (-0.5) * basic : 0;
double walk;
if (player.getPersistentData().getDouble("move_forward") == 1 || player.getPersistentData().getDouble("move_backward") == 1 ||
player.getPersistentData().getDouble("move_left") == 1 || player.getPersistentData().getDouble("move_right") == 1) {
walk = 0.2 * basic;
} else {
walk = 0;
}
double zoom;
if (player.getPersistentData().getDouble("zoom_animation_time") > 4) {
if (stack.is(TargetModTags.Items.SNIPER_RIFLE)) {
zoom = 0.0001;
} else if (stack.is(TargetModTags.Items.SHOTGUN)) {
zoom = 0.9;
} else {
zoom = 0.0001;
}
} else {
zoom = 1;
}
double index = zoom * (basic + walk + sprint + sneaking + prone + jump + fire + ride);
if (player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) < index) {
player.getAttribute(TargetModAttributes.SPREAD.get())
.setBaseValue(player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) + 0.125 * Math.pow(index - player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()), 2));
} else {
player.getAttribute(TargetModAttributes.SPREAD.get())
.setBaseValue(player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) - 0.125 * Math.pow(index - player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()), 2));
}
if (player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) > 15) {
player.getAttribute(TargetModAttributes.SPREAD.get()).setBaseValue(15);
}
if (player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) < 0) {
player.getAttribute(TargetModAttributes.SPREAD.get()).setBaseValue(0);
}
}
/**
* 通用的武器开火流程
*/

View file

@ -1,5 +1,6 @@
package net.mcreator.target.event;
import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.init.TargetModTags;
@ -53,7 +54,6 @@ public class PlayerEventHandler {
}
if (event.phase == TickEvent.Phase.END) {
handleAiming(player);
handlePlayerProne(player);
handlePlayerSprint(player);
handleWeaponLevel(player);
@ -68,16 +68,6 @@ public class PlayerEventHandler {
}
}
/**
* 判断玩家是否瞄准
*/
private static void handleAiming(Player player) {
ItemStack itemstack = player.getMainHandItem();
if (itemstack.is(TargetModTags.Items.GUN)) {
itemstack.getOrCreateTag().putBoolean("aiming", player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables()).zooming);
}
}
/**
* 判断玩家是否趴下
@ -292,6 +282,10 @@ public class PlayerEventHandler {
Runnable recoilRunnable = () -> {
while (recoilTimer[0] < recoilDuration) {
/**
* 开火动画计时器
*/
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).firing > 0) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.firing = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).firing - 0.1;
@ -304,6 +298,10 @@ public class PlayerEventHandler {
});
}
/**
* 计算后坐力
*/
float rx, ry;
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && player.getPersistentData().getDouble("prone") == 0) {
rx = 0.7f;
@ -329,17 +327,71 @@ public class PlayerEventHandler {
recoil = recoil + 0.017 * (2.1 - recoil);
double sinRes = 0;
sinRes = 0.35 * Math.sin(Math.PI * (1.5 * recoil)) * (3 - Math.pow(recoil , 2)) + 0.054;
sinRes = 0.35 * Math.sin(Math.PI * (1.5 * recoil)) * (3 - Math.pow(recoil , 2)) + 0.065;
float newPitch = ((float) (player.getXRot() - 7.5f * recoilY * ry * (sinRes + Mth.clamp(0.75 - recoil,0,0.7))));
float newPitch = ((float) (player.getXRot() - 5f * recoilY * ry * (sinRes + Mth.clamp(0.8 - recoil,0,0.8))));
player.setXRot(newPitch);
player.xRotO = player.getXRot();
float newYaw = ((float) (player.getYRot() - 7.5f * recoilYaw * recoilX * rx * sinRes));
float newYaw = ((float) (player.getYRot() - 5f * recoilYaw * recoilX * rx * sinRes));
player.setYRot(newYaw);
player.yRotO = player.getYRot();
}
/**
* 计算散布
*/
ItemStack stack = player.getMainHandItem();
double basic = stack.getOrCreateTag().getDouble("dev");
double sprint = player.isSprinting() ? 0.5 * basic : 0;
double sneaking = player.isShiftKeyDown() ? (-0.25) * basic : 0;
double prone = player.getPersistentData().getDouble("prone") > 0 ? (-0.5) * basic : 0;
double jump = player.onGround() ? 0 : 1.5 * basic;
double fire = stack.getOrCreateTag().getInt("fire_animation") > 0 ? 0.5 * basic : 0;
double ride = player.isPassenger() ? (-0.5) * basic : 0;
double walk;
if (player.getPersistentData().getDouble("move_forward") == 1 || player.getPersistentData().getDouble("move_backward") == 1 ||
player.getPersistentData().getDouble("move_left") == 1 || player.getPersistentData().getDouble("move_right") == 1) {
walk = 0.2 * basic;
} else {
walk = 0;
}
double zoom;
if (player.getPersistentData().getDouble("zoom_animation_time") > 4) {
if (stack.is(TargetModTags.Items.SNIPER_RIFLE)) {
zoom = 0.0001;
} else if (stack.is(TargetModTags.Items.SHOTGUN)) {
zoom = 0.9;
} else {
zoom = 0.0001;
}
} else {
zoom = 1;
}
double index = zoom * (basic + walk + sprint + sneaking + prone + jump + fire + ride);
if (player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) < index) {
player.getAttribute(TargetModAttributes.SPREAD.get())
.setBaseValue(player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) + 0.125 * Math.pow(index - player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()), 2));
} else {
player.getAttribute(TargetModAttributes.SPREAD.get())
.setBaseValue(player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) - 0.125 * Math.pow(index - player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()), 2));
}
if (player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) > 15) {
player.getAttribute(TargetModAttributes.SPREAD.get()).setBaseValue(15);
}
if (player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()) < 0) {
player.getAttribute(TargetModAttributes.SPREAD.get()).setBaseValue(0);
}
double finalRecoil = recoil;
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(c -> {
c.recoil = finalRecoil;

View file

@ -42,11 +42,11 @@
{
"name": "holo",
"parent": "0",
"pivot": [0.16719, 3.80781, -94.66641],
"pivot": [0.19453, 3.82344, -94.66641],
"cubes": [
{
"origin": [-9.64821, -6.00759, -94.66641],
"size": [19.6308, 19.6308, 0],
"origin": [-5.30209, -1.67319, -94.66641],
"size": [10.99325, 10.99325, 0],
"uv": {
"north": {"uv": [126.8877, 64.44092], "uv_size": [0, -0.25]},
"east": {"uv": [0, 0], "uv_size": [0, 8]},