优化后坐力相关

This commit is contained in:
Atsuihsio 2024-10-02 12:55:00 +08:00
parent 6508899616
commit 18d7196535
34 changed files with 184 additions and 310 deletions

View file

@ -121,7 +121,7 @@ public class ModUtils {
addNetworkMessage(ModVariables.PlayerVariablesSyncMessage.class, ModVariables.PlayerVariablesSyncMessage::buffer, ModVariables.PlayerVariablesSyncMessage::new, ModVariables.PlayerVariablesSyncMessage::handler); addNetworkMessage(ModVariables.PlayerVariablesSyncMessage.class, ModVariables.PlayerVariablesSyncMessage::buffer, ModVariables.PlayerVariablesSyncMessage::new, ModVariables.PlayerVariablesSyncMessage::handler);
addNetworkMessage(ModVariables.PlayerVariablesSyncMessage.class, ModVariables.PlayerVariablesSyncMessage::buffer, ModVariables.PlayerVariablesSyncMessage::new, ModVariables.PlayerVariablesSyncMessage::handler); addNetworkMessage(ModVariables.PlayerVariablesSyncMessage.class, ModVariables.PlayerVariablesSyncMessage::buffer, ModVariables.PlayerVariablesSyncMessage::new, ModVariables.PlayerVariablesSyncMessage::handler);
addNetworkMessage(ShootMessage.class, ShootMessage::encode, ShootMessage::decode, ShootMessage::handler); addNetworkMessage(ShootMessage.class, ShootMessage::encode, ShootMessage::decode, ShootMessage::handler);
addNetworkMessage(ShootAnimationMessage.class, ShootAnimationMessage::encode, ShootAnimationMessage::decode, ShootAnimationMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); addNetworkMessage(ShootClientMessage.class, ShootClientMessage::encode, ShootClientMessage::decode, ShootClientMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)), event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get()))); Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.AK47Item; import net.mcreator.superbwarfare.item.gun.rifle.AK47Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -79,7 +78,7 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
shuan.setPosZ(2.4f * (float) fp); shuan.setPosZ(2.4f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.shotgun.Aa12Item; import net.mcreator.superbwarfare.item.gun.shotgun.Aa12Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -74,7 +73,7 @@ public class Aa12ItemModel extends GeoModel<Aa12Item> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.machinegun.DevotionItem; import net.mcreator.superbwarfare.item.gun.machinegun.DevotionItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -92,7 +91,7 @@ public class DevotionItemModel extends GeoModel<DevotionItem> {
shen.setRotX(0.02f * (float) (0.18f * fp + fr)); shen.setRotX(0.02f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
bolt.setPosZ(-2f * (float) fp); bolt.setPosZ(-2f * (float) fp);
CoreGeoBone n0 = getAnimationProcessor().getBone("00"); CoreGeoBone n0 = getAnimationProcessor().getBone("00");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.handgun.Glock17Item; import net.mcreator.superbwarfare.item.gun.handgun.Glock17Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -72,16 +71,16 @@ public class Glock17ItemModel extends GeoModel<Glock17Item> {
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.03f * (float) (fp + 2 * fr)); shen.setPosY(0.03f * (float) (fp + 2 * fr));
shen.setPosZ(2.6f * (float) (fp + 0.84f * fr)); shen.setPosZ(2.6f * (float) (fp + 0.84f * fr));
shen.setRotY(0.05f * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setRotY(0.05f * (float) (ClientEventHandler.recoilHorizon * fp));
shen.setRotX(0.005f * (float) (fp + fr)); shen.setRotX(0.005f * (float) (fp + fr));
} else { } else {
shen.setPosY(0.08f * (float) (fp + 2 * fr)); shen.setPosY(0.08f * (float) (fp + 2 * fr));
shen.setPosZ(1.9f * (float) (fp + 0.54f * fr)); shen.setPosZ(1.9f * (float) (fp + 0.54f * fr));
shen.setRotX(0.17f * (float) (0.18f * fp + fr)); shen.setRotX(0.17f * (float) (0.18f * fp + fr));
shen.setRotY(0.1f * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setRotY(0.1f * (float) (ClientEventHandler.recoilHorizon * fp));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.7f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.7f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
slide.setPosZ(1.5f * (float) fp); slide.setPosZ(1.5f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.handgun.Glock18Item; import net.mcreator.superbwarfare.item.gun.handgun.Glock18Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -80,16 +79,16 @@ public class Glock18ItemModel extends GeoModel<Glock18Item> {
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.03f * (float) (fp + 2 * fr)); shen.setPosY(0.03f * (float) (fp + 2 * fr));
shen.setPosZ(2.6f * (float) (fp + 0.84f * fr)); shen.setPosZ(2.6f * (float) (fp + 0.84f * fr));
shen.setRotY(0.05f * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setRotY(0.05f * (float) (ClientEventHandler.recoilHorizon * fp));
shen.setRotX(0.005f * (float) (fp + fr)); shen.setRotX(0.005f * (float) (fp + fr));
} else { } else {
shen.setPosY(0.08f * (float) (fp + 2 * fr)); shen.setPosY(0.08f * (float) (fp + 2 * fr));
shen.setPosZ(1.9f * (float) (fp + 0.54f * fr)); shen.setPosZ(1.9f * (float) (fp + 0.54f * fr));
shen.setRotX(0.17f * (float) (0.18f * fp + fr)); shen.setRotX(0.17f * (float) (0.18f * fp + fr));
shen.setRotY(0.1f * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setRotY(0.1f * (float) (ClientEventHandler.recoilHorizon * fp));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.7f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.7f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
slide.setPosZ(1.5f * (float) fp); slide.setPosZ(1.5f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.Hk416Item; import net.mcreator.superbwarfare.item.gun.rifle.Hk416Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -78,7 +77,7 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.launcher.JavelinItem; import net.mcreator.superbwarfare.item.gun.launcher.JavelinItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -69,7 +68,7 @@ public class JavelinItemModel extends GeoModel<JavelinItem> {
shen.setPosZ(3.8f * (float) (fp + 0.54f * fr)); shen.setPosZ(3.8f * (float) (fp + 0.54f * fr));
shen.setRotX(0.17f * (float) (0.18f * fp + fr)); shen.setRotX(0.17f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
shen.setPosX((float)(0.75f * fr * (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX((float)(0.75f * fr * ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.sniper.K98Item; import net.mcreator.superbwarfare.item.gun.sniper.K98Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -85,7 +84,7 @@ public class K98ItemModel extends GeoModel<K98Item> {
shen.setRotX(0.17f * (float) (0.18f * fp + fr)); shen.setRotX(0.17f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.handgun.M1911Item; import net.mcreator.superbwarfare.item.gun.handgun.M1911Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -70,16 +69,16 @@ public class M1911ItemModel extends GeoModel<M1911Item> {
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) { if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
shen.setPosY(0.03f * (float) (fp + 2 * fr)); shen.setPosY(0.03f * (float) (fp + 2 * fr));
shen.setPosZ(2.6f * (float) (fp + 0.84f * fr)); shen.setPosZ(2.6f * (float) (fp + 0.84f * fr));
shen.setRotY(0.05f * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setRotY(0.05f * (float) (ClientEventHandler.recoilHorizon * fp));
shen.setRotX(0.005f * (float) (fp + fr)); shen.setRotX(0.005f * (float) (fp + fr));
} else { } else {
shen.setPosY(0.08f * (float) (fp + 2 * fr)); shen.setPosY(0.08f * (float) (fp + 2 * fr));
shen.setPosZ(1.9f * (float) (fp + 0.54f * fr)); shen.setPosZ(1.9f * (float) (fp + 0.54f * fr));
shen.setRotX(0.17f * (float) (0.18f * fp + fr)); shen.setRotX(0.17f * (float) (0.18f * fp + fr));
shen.setRotY(0.1f * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setRotY(0.1f * (float) (ClientEventHandler.recoilHorizon * fp));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.7f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.7f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
slide.setPosZ(2.75f * (float) fp); slide.setPosZ(2.75f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.M4Item; import net.mcreator.superbwarfare.item.gun.rifle.M4Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -78,7 +77,7 @@ public class M4ItemModel extends GeoModel<M4Item> {
shen.setRotX(0.03f * (float) (0.18f * fp + fr)); shen.setRotX(0.03f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.machinegun.M60Item; import net.mcreator.superbwarfare.item.gun.machinegun.M60Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -121,7 +120,7 @@ public class M60ItemModel extends GeoModel<M60Item> {
shen.setRotX(0.04f * (float) (0.18f * fp + fr)); shen.setRotX(0.04f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
tiba.setRotZ((float) (-0.25f * fp + 0.4 * fr)); tiba.setRotZ((float) (-0.25f * fp + 0.4 * fr));

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.launcher.M79Item; import net.mcreator.superbwarfare.item.gun.launcher.M79Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -76,7 +75,7 @@ public class M79ItemModel extends GeoModel<M79Item> {
shen.setRotX(0.1f * (float) (0.18f * fp + fr)); shen.setRotX(0.1f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.shotgun.M870Item; import net.mcreator.superbwarfare.item.gun.shotgun.M870Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -78,7 +77,7 @@ public class M870ItemModel extends GeoModel<M870Item> {
shen.setRotX(0.3f * (float) (0.18f * fp + fr)); shen.setRotX(0.3f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.sniper.M98bItem; import net.mcreator.superbwarfare.item.gun.sniper.M98bItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -72,7 +71,7 @@ public class M98bItemModel extends GeoModel<M98bItem> {
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
scope.setPosZ(75.2f * (float) (fp + 0.54f * fr)); scope.setPosZ(75.2f * (float) (fp + 0.54f * fr));
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
gun.setPosX(2.245f * (float) zp); gun.setPosX(2.245f * (float) zp);
gun.setPosY(0.3f * (float) zp - (float) (0.2f * zpz)); gun.setPosY(0.3f * (float) zp - (float) (0.2f * zpz));

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.machinegun.MinigunItem; import net.mcreator.superbwarfare.item.gun.machinegun.MinigunItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -70,7 +69,7 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr)); shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr));
shen.setRotX(0.05f * (float) (0.18f * fp + fr)); shen.setRotX(0.05f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.02f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.02f * (float) (fp + 1.3 * fr));
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.Mk14Item; import net.mcreator.superbwarfare.item.gun.rifle.Mk14Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -89,7 +88,7 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
shen.setPosY(0.06f * (float) (fp + 2 * fr)); shen.setPosY(0.06f * (float) (fp + 2 * fr));
shen.setPosZ(0.9f * (float) (fp + 0.54f * fr)); shen.setPosZ(0.9f * (float) (fp + 0.54f * fr));
shen.setRotX(0.005f * (float) (fp + fr)); shen.setRotX(0.005f * (float) (fp + fr));
shen.setRotZ(0.01f * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp) * (float) fp); shen.setRotZ(0.01f * (float)(ClientEventHandler.recoilHorizon * fp));
} else { } else {
shen.setPosY(0.04f * (float) (fp + 2 * fr)); shen.setPosY(0.04f * (float) (fp + 2 * fr));
shen.setPosZ(1.2f * (float) (fp + 0.54f * fr)); shen.setPosZ(1.2f * (float) (fp + 0.54f * fr));
@ -97,11 +96,11 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
rex.setRotZ(0.01f * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp) * (float) fp); rex.setRotZ(0.01f * (float)(ClientEventHandler.recoilHorizon * fp));
rex.setPosY(-0.23f * (float) (fp + 2.3 * fr)); rex.setPosY(-0.23f * (float) (fp + 2.3 * fr));
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
action.setPosZ(2.5f * (float) fp); action.setPosZ(2.5f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.sniper.MosinNagantItem; import net.mcreator.superbwarfare.item.gun.sniper.MosinNagantItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -95,10 +94,10 @@ public class MosinNagantItemModel extends GeoModel<MosinNagantItem> {
shen.setRotX(0.17f * (float) (0.18f * fp + fr)); shen.setRotX(0.17f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX((float)(0.75f * fr * (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX((float)(0.75f * fr * ClientEventHandler.recoilHorizon * fp));
rex.setPosY(0.05f + 0.1f * (float) fp); rex.setPosY(0.05f + 0.1f * (float) fp);
rex.setRotZ((float) (-0.08f * fp * (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon)); rex.setRotZ((float) (-0.08f * fp * ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.sniper.Ntw20Item; import net.mcreator.superbwarfare.item.gun.sniper.Ntw20Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -79,7 +78,7 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
gun.setPosX(4.54f * (float) zp); gun.setPosX(4.54f * (float) zp);
gun.setPosY(-0.45f * (float) zp - (float) (0.2f * zpz)); gun.setPosY(-0.45f * (float) zp - (float) (0.2f * zpz));
gun.setPosZ(10.0f * (float) zp + (float) (0.3f * zpz)); gun.setPosZ(10.0f * (float) zp + (float) (0.3f * zpz));

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.Qbz95Item; import net.mcreator.superbwarfare.item.gun.rifle.Qbz95Item;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -77,7 +76,7 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
bolt.setPosZ(5f * (float) fp); bolt.setPosZ(5f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.launcher.RpgItem; import net.mcreator.superbwarfare.item.gun.launcher.RpgItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -73,7 +72,7 @@ public class RpgItemModel extends GeoModel<RpgItem> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
gun.setPosX(0.91f * (float) zp); gun.setPosX(0.91f * (float) zp);
gun.setPosY(-0.04f * (float) zp - (float) (0.2f * zpz)); gun.setPosY(-0.04f * (float) zp - (float) (0.2f * zpz));

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.machinegun.RpkItem; import net.mcreator.superbwarfare.item.gun.machinegun.RpkItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -93,7 +92,7 @@ public class RpkItemModel extends GeoModel<RpkItem> {
shen.setRotX(0.04f * (float) (0.18f * fp + fr)); shen.setRotX(0.04f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
shuan.setPosZ(2.4f * (float) fp); shuan.setPosZ(2.4f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.sniper.SentinelItem; import net.mcreator.superbwarfare.item.gun.sniper.SentinelItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -94,7 +93,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
shen.setRotX(0.15f * (float) (0.18f * fp + fr)); shen.setRotX(0.15f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
CoreGeoBone charge = getAnimationProcessor().getBone("charge"); CoreGeoBone charge = getAnimationProcessor().getBone("charge");

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.SksItem; import net.mcreator.superbwarfare.item.gun.rifle.SksItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -88,7 +87,7 @@ public class SksItemModel extends GeoModel<SksItem> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
shuan.setPosZ(2f * (float) fp); shuan.setPosZ(2f * (float) fp);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.sniper.SvdItem; import net.mcreator.superbwarfare.item.gun.sniper.SvdItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -99,7 +98,7 @@ public class SvdItemModel extends GeoModel<SvdItem> {
shen.setRotX(0.07f * (float) (0.18f * fp + fr)); shen.setRotX(0.07f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.04f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float)fr * (float)(ClientEventHandler.recoilHorizon * fp));
holo.setPosY(0.05f + 1.1f * (float) fp); holo.setPosY(0.05f + 1.1f * (float) fp);
holo.setRotZ(-0.04f * (float) fp); holo.setRotZ(-0.04f * (float) fp);
holo.setScaleX(0.75f); holo.setScaleX(0.75f);

View file

@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.event.ClientEventHandler; import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags; import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.smg.VectorItem; import net.mcreator.superbwarfare.item.gun.smg.VectorItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@ -94,7 +93,7 @@ public class VectorItemModel extends GeoModel<VectorItem> {
shen.setRotX(0.03f * (float) (0.18f * fp + fr)); shen.setRotX(0.03f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr)); shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
} }
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).recoilHorizon * fp)); shen.setPosX(0.5f * (float) fr * (float) (ClientEventHandler.recoilHorizon * fp));
CoreGeoBone root = getAnimationProcessor().getBone("root"); CoreGeoBone root = getAnimationProcessor().getBone("root");
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");

View file

@ -46,7 +46,8 @@ import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntity { public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public String animationprocedure = "empty"; public String animationprocedure = "empty";
@ -70,7 +71,22 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData(); super.defineSynchedData();
this.entityData.define(ANIMATION, "undefined"); this.entityData.define(COOL_DOWN, 0);
this.entityData.define(TYPE, 0);
}
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("cool_down", this.entityData.get(COOL_DOWN));
compound.putInt("type", this.entityData.get(TYPE));
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.entityData.set(COOL_DOWN, compound.getInt("cool_down"));
this.entityData.set(TYPE, compound.getInt("type"));
} }
@Override @Override
@ -163,47 +179,25 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
} }
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
}
@Override @Override
public void baseTick() { public void baseTick() {
super.baseTick(); super.baseTick();
if (this.entityData.get(COOL_DOWN) > 0) {
if (this.getFirstPassenger() == null) return; this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
Entity gunner = this.getFirstPassenger();
if (this.getPersistentData().getInt("FireCooldown") > 0) {
this.getPersistentData().putInt("FireCooldown", this.getPersistentData().getInt("FireCooldown") - 1);
} }
if (this.entityData.get(COOL_DOWN) > 28) {
if (this.getPersistentData().getInt("FireCooldown") > 28) { if (Math.random() < 0.5) {
gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { this.entityData.set(TYPE, -1);
} else {
if (Math.random() < 0.5) { this.entityData.set(TYPE, 1);
capability.recoilHorizon = -1; }
} else {
capability.recoilHorizon = 1;
}
capability.cannonRecoil = 10;
capability.syncPlayerVariables(gunner);
});
} }
this.refreshDimensions(); this.refreshDimensions();
} }
@Override @Override
public void cannonShoot(Player player) { public void cannonShoot(Player player) {
if (this.getPersistentData().getInt("FireCooldown") > 0) { if (this.entityData.get(COOL_DOWN) > 0) {
return; return;
} }
@ -258,7 +252,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1); serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1);
} }
this.getPersistentData().putInt("FireCooldown", 30); this.entityData.set(COOL_DOWN, 30);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + 5 * this.getLookAngle().x, this.getX() + 5 * this.getLookAngle().x,
@ -365,8 +359,8 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
if (this.getFirstPassenger() != null) { if (this.getFirstPassenger() != null) {
Entity gunner = this.getFirstPassenger(); Entity gunner = this.getFirstPassenger();
var capability = gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null); var capability = gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (capability.orElse(new ModVariables.PlayerVariables()).cannonRecoil > 0) { if (this.entityData.get(COOL_DOWN) > 0) {
if (capability.orElse(new ModVariables.PlayerVariables()).recoilHorizon == 1) { if (this.entityData.get(TYPE) == 1) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire")); return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
} else { } else {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire2")); return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire2"));
@ -379,19 +373,6 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
return PlayState.STOP; return PlayState.STOP;
} }
private PlayState procedurePredicate(AnimationState<Mk42Entity> event) {
if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
this.animationprocedure = "empty";
event.getController().forceAnimationReset();
}
} else if (animationprocedure.equals("empty")) {
return PlayState.STOP;
}
return PlayState.CONTINUE;
}
@Override @Override
protected void tickDeath() { protected void tickDeath() {
++this.deathTime; ++this.deathTime;
@ -402,17 +383,15 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
} }
public String getSyncedAnimation() { public String getSyncedAnimation() {
return this.entityData.get(ANIMATION); return null;
} }
public void setAnimation(String animation) { public void setAnimation(String animation) {
this.entityData.set(ANIMATION, animation);
} }
@Override @Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) { public void registerControllers(AnimatableManager.ControllerRegistrar data) {
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate)); data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
data.add(new AnimationController<>(this, "procedure", 0, this::procedurePredicate));
} }
@Override @Override

View file

@ -48,7 +48,8 @@ import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil; import software.bernie.geckolib.util.GeckoLibUtil;
public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEntity { public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public String animationprocedure = "empty"; public String animationprocedure = "empty";
@ -71,7 +72,22 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
@Override @Override
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData(); super.defineSynchedData();
this.entityData.define(ANIMATION, "undefined"); this.entityData.define(COOL_DOWN, 0);
this.entityData.define(TYPE, 0);
}
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("cool_down", this.entityData.get(COOL_DOWN));
compound.putInt("type", this.entityData.get(TYPE));
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.entityData.set(COOL_DOWN, compound.getInt("cool_down"));
this.entityData.set(TYPE, compound.getInt("type"));
} }
@Override @Override
@ -164,33 +180,12 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
} }
@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
}
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
}
@Override @Override
public void baseTick() { public void baseTick() {
super.baseTick(); super.baseTick();
if (this.getFirstPassenger() == null) return; if (this.entityData.get(COOL_DOWN) > 0) {
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
Entity gunner = this.getFirstPassenger();
if (this.getPersistentData().getInt("FireCooldown") > 0) {
this.getPersistentData().putInt("FireCooldown", this.getPersistentData().getInt("FireCooldown") - 1);
}
if (this.getPersistentData().getInt("FireCooldown") > 72) {
gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.cannonRecoil = 10;
capability.syncPlayerVariables(gunner);
});
} }
this.refreshDimensions(); this.refreshDimensions();
@ -198,7 +193,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
@Override @Override
public void cannonShoot(Player player) { public void cannonShoot(Player player) {
if (this.getPersistentData().getInt("FireCooldown") > 0) { if (this.entityData.get(COOL_DOWN) > 0) {
return; return;
} }
@ -338,9 +333,9 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
Mth.clamp(countR--,1,5), 0.1, 0.1, 0.1, 0.002); Mth.clamp(countR--,1,5), 0.1, 0.1, 0.1, 0.002);
} }
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> capability.recoilHorizon = 1); this.entityData.set(TYPE, 1);
} else { } else {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> capability.recoilHorizon = -1); this.entityData.set(TYPE, -1);
} }
if (player instanceof ServerPlayer serverPlayer) { if (player instanceof ServerPlayer serverPlayer) {
@ -351,7 +346,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1); serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1);
} }
this.getPersistentData().putInt("FireCooldown", 74); this.entityData.set(COOL_DOWN, 74);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
this.getX() + 5 * this.getLookAngle().x, this.getX() + 5 * this.getLookAngle().x,
@ -440,8 +435,8 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
if (this.getFirstPassenger() != null) { if (this.getFirstPassenger() != null) {
Entity gunner = this.getFirstPassenger(); Entity gunner = this.getFirstPassenger();
var capability = gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null); var capability = gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (capability.orElse(new ModVariables.PlayerVariables()).cannonRecoil > 0) { if (this.entityData.get(COOL_DOWN) > 64) {
if (capability.orElse(new ModVariables.PlayerVariables()).recoilHorizon == 1) { if (this.entityData.get(TYPE) == 1) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.salvo_fire")); return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.salvo_fire"));
} else { } else {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.fire")); return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.fire"));
@ -454,19 +449,6 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
return PlayState.STOP; return PlayState.STOP;
} }
private PlayState procedurePredicate(AnimationState<Mle1934Entity> event) {
if (!animationprocedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationprocedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
this.animationprocedure = "empty";
event.getController().forceAnimationReset();
}
} else if (animationprocedure.equals("empty")) {
return PlayState.STOP;
}
return PlayState.CONTINUE;
}
@Override @Override
protected void tickDeath() { protected void tickDeath() {
++this.deathTime; ++this.deathTime;
@ -477,17 +459,15 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
} }
public String getSyncedAnimation() { public String getSyncedAnimation() {
return this.entityData.get(ANIMATION); return null;
} }
public void setAnimation(String animation) { public void setAnimation(String animation) {
this.entityData.set(ANIMATION, animation);
} }
@Override @Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) { public void registerControllers(AnimatableManager.ControllerRegistrar data) {
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate)); data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
data.add(new AnimationController<>(this, "procedure", 0, this::procedurePredicate));
} }
@Override @Override

View file

@ -18,6 +18,7 @@ import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
@ -71,6 +72,11 @@ public class ClientEventHandler {
public static double firePos = 0; public static double firePos = 0;
public static double firePosZ = 0; public static double firePosZ = 0;
public static double fireRot = 0; public static double fireRot = 0;
public static double recoilTime = 0;
public static double recoilHorizon = 0;
public static double droneCameraRotX = 0; public static double droneCameraRotX = 0;
public static double droneCameraRotY = 0; public static double droneCameraRotY = 0;
public static double droneRotX = 0; public static double droneRotX = 0;
@ -224,6 +230,7 @@ public class ClientEventHandler {
} else { } else {
clientTimer.stop(); clientTimer.stop();
fireSpread = 0;
} }
} }
@ -249,6 +256,7 @@ public class ClientEventHandler {
handleWeaponZoom(); handleWeaponZoom();
handlePlayerBreath(living); handlePlayerBreath(living);
handleWeaponFire(event, living); handleWeaponFire(event, living);
handleGunRecoil();
handleShockCamera(event, living); handleShockCamera(event, living);
handleBowPullAnimation(living); handleBowPullAnimation(living);
} }
@ -441,16 +449,17 @@ public class ClientEventHandler {
ItemStack stack = entity.getMainHandItem(); ItemStack stack = entity.getMainHandItem();
double amplitude = 15000 * stack.getOrCreateTag().getDouble("recoil_y") * stack.getOrCreateTag().getDouble("recoil_x"); double amplitude = 15000 * stack.getOrCreateTag().getDouble("recoil_y") * stack.getOrCreateTag().getDouble("recoil_x");
var capability = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (fireRecoilTime > 0) { if (fireRecoilTime > 0) {
firePosTimer = 0.001; firePosTimer = 0.001;
fireRotTimer = 0.001; fireRotTimer = 0.001;
firePosZ = 0.1; firePosZ = 0.1;
fireSpread += 0.2;
fireRecoilTime -= 7 * times; fireRecoilTime -= 7 * times;
recoilHorizon = 2 * Math.random() - 1;
fireSpread += 0.1;
recoilTime = 0.01;
} }
fireSpread = Mth.clamp(fireSpread - 0.6 * (Math.pow(fireSpread, 2) * times), 0, 100); fireSpread = Mth.clamp(fireSpread - 0.1 * (Math.pow(fireSpread, 2) * times), 0, 100);
firePosZ = Mth.clamp(firePosZ - 0.02 * times, 0, 0.6); firePosZ = Mth.clamp(firePosZ - 0.02 * times, 0, 0.6);
if (0 < firePosTimer) { if (0 < firePosTimer) {
@ -469,11 +478,11 @@ public class ClientEventHandler {
if (0 < fireRotTimer && fireRotTimer < 1.732) { if (0 < fireRotTimer && fireRotTimer < 1.732) {
fireRot = 1 / 6.3 * (fireRotTimer - 0.5) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)); fireRot = 1 / 6.3 * (fireRotTimer - 0.5) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2));
if ((capability.orElse(new ModVariables.PlayerVariables())).recoilHorizon > 0) { if (recoilHorizon > 0) {
event.setYaw((float) (yaw - 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1))); event.setYaw((float) (yaw - 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1)));
event.setPitch((float) (pitch + 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1))); event.setPitch((float) (pitch + 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1)));
event.setRoll((float) (roll + 4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 0, 0.5) * (2 * Math.random() - 1))); event.setRoll((float) (roll + 4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 0, 0.5) * (2 * Math.random() - 1)));
} else if ((capability.orElse(new ModVariables.PlayerVariables())).recoilHorizon <= 0) { } else if (recoilHorizon <= 0) {
event.setYaw((float) (yaw + 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1))); event.setYaw((float) (yaw + 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1)));
event.setPitch((float) (pitch - 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1))); event.setPitch((float) (pitch - 1.3 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 1 * Mth.clamp(0.3 - fireRotTimer, 0, 1) * (2 * Math.random() - 1)));
event.setRoll((float) (roll - 4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 0, 0.5) * (2 * Math.random() - 1))); event.setRoll((float) (roll - 4.2 * amplitude * (1 / 6.3 * (fireRotTimer - 0.5)) * Math.sin(6.3 * (fireRotTimer - 0.5)) * (3 - Math.pow(fireRotTimer, 2)) + 3 * Mth.clamp(0.5 - fireRotTimer, 0, 0.5) * (2 * Math.random() - 1)));
@ -487,6 +496,70 @@ public class ClientEventHandler {
fireRotTimer = 0; fireRotTimer = 0;
fireRot = 0; fireRot = 0;
} }
}
private static void handleGunRecoil() {
Player player = Minecraft.getInstance().player;
if (player == null) return;
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
CompoundTag tag = player.getMainHandItem().getOrCreateTag();
float times = Minecraft.getInstance().getDeltaFrameTime();
float recoilX = (float) tag.getDouble("recoil_x");
float recoilY = (float) tag.getDouble("recoil_y");
float recoilPitch = 30f;
float recoilYaw = 25f;
/*
计算后坐力
*/
float rx, ry;
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && !isProne(player)) {
rx = 0.7f;
ry = 0.8f;
} else if (isProne(player)) {
if (tag.getDouble("bipod") == 1) {
rx = 0.05f;
ry = 0.1f;
} else {
rx = 0.5f;
ry = 0.7f;
}
} else {
rx = 1f;
ry = 1f;
}
double sinRes = 0;
if (0 < recoilTime && recoilTime < 0.5) {
float newPitch = player.getXRot() - 0.02f * ry * times;
player.setXRot(newPitch);
player.xRotO = player.getXRot();
}
if (0 < recoilTime && recoilTime < 2) {
recoilTime = recoilTime + 0.3 * times;
sinRes = Math.sin(Math.PI * recoilTime);
}
if (2 <= recoilTime && recoilTime < 2.5) {
recoilTime = recoilTime + 0.17 * times;
sinRes = 0.4 * Math.sin(2 * Math.PI * recoilTime);
}
if (0 < recoilTime && recoilTime < 2.5) {
float newPitch = (float) (player.getXRot() - recoilPitch * recoilY * ry * (sinRes + Mth.clamp(0.5 - recoilTime, 0, 0.5)) * times * fireSpread);
player.setXRot(newPitch);
player.xRotO = player.getXRot();
float newYaw = (float) (player.getYRot() - recoilYaw * recoilHorizon * recoilX * rx * sinRes * times - 100 * recoilHorizon * firePos * recoilX * rx * times * fireSpread);
player.setYRot(newYaw);
player.yRotO = player.getYRot();
}
if (recoilTime >= 2.5) recoilTime = 0d;
} }

View file

@ -93,13 +93,11 @@ public class PlayerEventHandler {
handleSpecialWeaponAmmo(player); handleSpecialWeaponAmmo(player);
handleChangeFireRate(player); handleChangeFireRate(player);
handleBocekPulling(player); handleBocekPulling(player);
handleGunRecoil(player);
isProne(player); isProne(player);
} }
handleGround(player); handleGround(player);
handleSimulationDistance(player); handleSimulationDistance(player);
handleCannonTime(player);
handleTacticalSprint(player); handleTacticalSprint(player);
handleBreath(player); handleBreath(player);
} }
@ -239,15 +237,6 @@ public class PlayerEventHandler {
} }
} }
private static void handleCannonTime(Player player) {
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).cannonRecoil > 0) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.cannonRecoil = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).cannonRecoil - 1;
capability.syncPlayerVariables(player);
});
}
}
/** /**
* 判断玩家是否在奔跑 * 判断玩家是否在奔跑
*/ */
@ -371,113 +360,6 @@ public class PlayerEventHandler {
} }
} }
private static void handleGunRecoil(Player player) {
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
CompoundTag tag = player.getMainHandItem().getOrCreateTag();
float recoilX = (float) tag.getDouble("recoil_x");
float recoilY = (float) tag.getDouble("recoil_y");
float recoilPitch = 3f;
float recoilYaw = 2f;
float horizonRecoil = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.recoilHorizon).orElse(0d).floatValue();
if (tag.getBoolean("shoot")) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = 2 * Math.random() - 1;
capability.recoil = 0.1;
capability.syncPlayerVariables(player);
});
tag.putBoolean("shoot", false);
}
double[] recoilTimer = {0};
double totalTime = 20;
int sleepTime = 2;
double recoilDuration = totalTime / sleepTime;
Runnable recoilRunnable = () -> {
while (recoilTimer[0] < recoilDuration) {
if (tag.getBoolean("shoot")) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = 2 * Math.random() - 1;
capability.recoil = 0.1;
capability.syncPlayerVariables(player);
});
tag.putBoolean("shoot", false);
}
/*
计算后坐力
*/
float rx, ry;
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && !isProne(player)) {
rx = 0.7f;
ry = 0.8f;
} else if (isProne(player)) {
if (tag.getDouble("bipod") == 1) {
rx = 0.05f;
ry = 0.1f;
} else {
rx = 0.5f;
ry = 0.7f;
}
} else {
rx = 1f;
ry = 1f;
}
double recoil = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.recoil).orElse(0d);
if (recoil >= 2.5) recoil = 0d;
double sinRes = 0;
if (0 < recoil && recoil < 0.5) {
float newPitch = player.getXRot() - 0.05f * ry;
player.setXRot(newPitch);
player.xRotO = player.getXRot();
}
if (0 < recoil && recoil < 2) {
recoil = recoil + 0.025;
sinRes = Math.sin(Math.PI * recoil);
}
if (2 <= recoil && recoil < 2.5) {
recoil = recoil + 0.013;
sinRes = 0.4 * Math.sin(2 * Math.PI * recoil);
}
if (0 < recoil && recoil < 2.5) {
float newPitch = (float) (player.getXRot() - recoilPitch * recoilY * ry * (sinRes + Mth.clamp(0.8 - recoil, 0, 0.8)));
player.setXRot(newPitch);
player.xRotO = player.getXRot();
float newYaw = (float) (player.getYRot() - recoilYaw * horizonRecoil * recoilX * rx * sinRes);
player.setYRot(newYaw);
player.yRotO = player.getYRot();
}
double finalRecoil = recoil;
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(c -> {
c.recoil = finalRecoil;
c.syncPlayerVariables(player);
});
recoilTimer[0]++;
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
ModUtils.LOGGER.error(e.getLocalizedMessage());
}
}
};
Thread recoilThread = new Thread(recoilRunnable);
recoilThread.start();
}
private static void handleSimulationDistance(Player player) { private static void handleSimulationDistance(Player player) {
if (player.level() instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer) {
var distanceManager = serverLevel.getChunkSource().chunkMap.getDistanceManager(); var distanceManager = serverLevel.getChunkSource().chunkMap.getDistanceManager();

View file

@ -71,8 +71,6 @@ public class ModVariables {
PlayerVariables clone = event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()); PlayerVariables clone = event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
clone.zoom = original.zoom; clone.zoom = original.zoom;
clone.holdFire = original.holdFire; clone.holdFire = original.holdFire;
clone.recoil = original.recoil;
clone.recoilHorizon = original.recoilHorizon;
clone.rifleAmmo = original.rifleAmmo; clone.rifleAmmo = original.rifleAmmo;
clone.handgunAmmo = original.handgunAmmo; clone.handgunAmmo = original.handgunAmmo;
clone.shotgunAmmo = original.shotgunAmmo; clone.shotgunAmmo = original.shotgunAmmo;
@ -261,10 +259,6 @@ public class ModVariables {
public static class PlayerVariables { public static class PlayerVariables {
public boolean zoom = false; public boolean zoom = false;
public boolean holdFire = false; public boolean holdFire = false;
public double recoil = 0;
public double recoilHorizon = 0;
public int cannonRecoil = 0;
public int rifleAmmo = 0; public int rifleAmmo = 0;
public int handgunAmmo = 0; public int handgunAmmo = 0;
public int shotgunAmmo = 0; public int shotgunAmmo = 0;
@ -288,9 +282,6 @@ public class ModVariables {
CompoundTag nbt = new CompoundTag(); CompoundTag nbt = new CompoundTag();
nbt.putBoolean("zoom", zoom); nbt.putBoolean("zoom", zoom);
nbt.putBoolean("holdFire", holdFire); nbt.putBoolean("holdFire", holdFire);
nbt.putDouble("recoil", recoil);
nbt.putDouble("recoil_horizon", recoilHorizon);
nbt.putInt("cannonRecoil", cannonRecoil);
nbt.putInt("rifle_ammo", rifleAmmo); nbt.putInt("rifle_ammo", rifleAmmo);
nbt.putInt("handgun_ammo", handgunAmmo); nbt.putInt("handgun_ammo", handgunAmmo);
nbt.putInt("shotgun_ammo", shotgunAmmo); nbt.putInt("shotgun_ammo", shotgunAmmo);
@ -312,9 +303,6 @@ public class ModVariables {
CompoundTag nbt = (CompoundTag) Tag; CompoundTag nbt = (CompoundTag) Tag;
zoom = nbt.getBoolean("zoom"); zoom = nbt.getBoolean("zoom");
holdFire = nbt.getBoolean("holdFire"); holdFire = nbt.getBoolean("holdFire");
recoil = nbt.getDouble("recoil");
recoilHorizon = nbt.getDouble("recoil_horizon");
cannonRecoil = nbt.getInt("cannonRecoil");
rifleAmmo = nbt.getInt("rifle_ammo"); rifleAmmo = nbt.getInt("rifle_ammo");
handgunAmmo = nbt.getInt("handgun_ammo"); handgunAmmo = nbt.getInt("handgun_ammo");
shotgunAmmo = nbt.getInt("shotgun_ammo"); shotgunAmmo = nbt.getInt("shotgun_ammo");
@ -367,9 +355,6 @@ public class ModVariables {
PlayerVariables variables = entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()); PlayerVariables variables = entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
variables.zoom = message.data.zoom; variables.zoom = message.data.zoom;
variables.holdFire = message.data.holdFire; variables.holdFire = message.data.holdFire;
variables.recoil = message.data.recoil;
variables.recoilHorizon = message.data.recoilHorizon;
variables.cannonRecoil = message.data.cannonRecoil;
variables.rifleAmmo = message.data.rifleAmmo; variables.rifleAmmo = message.data.rifleAmmo;
variables.handgunAmmo = message.data.handgunAmmo; variables.handgunAmmo = message.data.handgunAmmo;
variables.shotgunAmmo = message.data.shotgunAmmo; variables.shotgunAmmo = message.data.shotgunAmmo;

View file

@ -304,7 +304,7 @@ public class FireMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
} }
@ -416,7 +416,7 @@ public class FireMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
} }
@ -469,7 +469,7 @@ public class FireMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
} }
@ -529,7 +529,7 @@ public class FireMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
} }
@ -590,7 +590,7 @@ public class FireMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
} }

View file

@ -8,22 +8,22 @@ import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
public class ShootAnimationMessage { public class ShootClientMessage {
public double time; public double time;
public ShootAnimationMessage(double time) { public ShootClientMessage(double time) {
this.time = time; this.time = time;
} }
public static void encode(ShootAnimationMessage message, FriendlyByteBuf buffer) { public static void encode(ShootClientMessage message, FriendlyByteBuf buffer) {
buffer.writeDouble(message.time); buffer.writeDouble(message.time);
} }
public static ShootAnimationMessage decode(FriendlyByteBuf buffer) { public static ShootClientMessage decode(FriendlyByteBuf buffer) {
return new ShootAnimationMessage(buffer.readDouble()); return new ShootClientMessage(buffer.readDouble());
} }
public static void handle(ShootAnimationMessage message, Supplier<NetworkEvent.Context> context) { public static void handle(ShootClientMessage message, Supplier<NetworkEvent.Context> context) {
context.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, context.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
() -> () -> ClientEventHandler.handleFireRecoilTimeMessage(message.time, context))); () -> () -> ClientEventHandler.handleFireRecoilTimeMessage(message.time, context)));
context.get().setPacketHandled(true); context.get().setPacketHandled(true);

View file

@ -163,7 +163,7 @@ public class ShootMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
@ -216,7 +216,7 @@ public class ShootMessage {
stack.getOrCreateTag().putBoolean("shoot", true); stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) { if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootAnimationMessage(10)); ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
} }
} }
} }