优化后坐力相关
This commit is contained in:
parent
6508899616
commit
18d7196535
34 changed files with 184 additions and 310 deletions
|
@ -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(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)),
|
||||
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.rifle.AK47Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.shotgun.Aa12Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.machinegun.DevotionItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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);
|
||||
|
||||
CoreGeoBone n0 = getAnimationProcessor().getBone("00");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.handgun.Glock17Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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) {
|
||||
shen.setPosY(0.03f * (float) (fp + 2 * 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));
|
||||
} else {
|
||||
shen.setPosY(0.08f * (float) (fp + 2 * fr));
|
||||
shen.setPosZ(1.9f * (float) (fp + 0.54f * 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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.handgun.Glock18Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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) {
|
||||
shen.setPosY(0.03f * (float) (fp + 2 * 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));
|
||||
} else {
|
||||
shen.setPosY(0.08f * (float) (fp + 2 * fr));
|
||||
shen.setPosZ(1.9f * (float) (fp + 0.54f * 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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.rifle.Hk416Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.launcher.JavelinItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.setRotX(0.17f * (float) (0.18f * fp + 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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.sniper.K98Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.handgun.M1911Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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) {
|
||||
shen.setPosY(0.03f * (float) (fp + 2 * 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));
|
||||
} else {
|
||||
shen.setPosY(0.08f * (float) (fp + 2 * fr));
|
||||
shen.setPosZ(1.9f * (float) (fp + 0.54f * 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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.rifle.M4Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.machinegun.M60Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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));
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.launcher.M79Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.shotgun.M870Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.sniper.M98bItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -72,7 +71,7 @@ public class M98bItemModel extends GeoModel<M98bItem> {
|
|||
shen.setRotZ(-0.01f * (float) (fp + 1.3 * 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.setPosY(0.3f * (float) zp - (float) (0.2f * zpz));
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.machinegun.MinigunItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.setRotX(0.05f * (float) (0.18f * fp + 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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.rifle.Mk14Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -89,7 +88,7 @@ public class Mk14ItemModel extends GeoModel<Mk14Item> {
|
|||
shen.setPosY(0.06f * (float) (fp + 2 * fr));
|
||||
shen.setPosZ(0.9f * (float) (fp + 0.54f * 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 {
|
||||
shen.setPosY(0.04f * (float) (fp + 2 * 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));
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.sniper.MosinNagantItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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.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");
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.sniper.Ntw20Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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.setPosY(-0.45f * (float) zp - (float) (0.2f * zpz));
|
||||
gun.setPosZ(10.0f * (float) zp + (float) (0.3f * zpz));
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.rifle.Qbz95Item;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.launcher.RpgItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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.setPosY(-0.04f * (float) zp - (float) (0.2f * zpz));
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.machinegun.RpkItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.sniper.SentinelItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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");
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.rifle.SksItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.sniper.SvdItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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.setRotZ(-0.04f * (float) fp);
|
||||
holo.setScaleX(0.75f);
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.mcreator.superbwarfare.ModUtils;
|
|||
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||
import net.mcreator.superbwarfare.init.ModTags;
|
||||
import net.mcreator.superbwarfare.item.gun.smg.VectorItem;
|
||||
import net.mcreator.superbwarfare.network.ModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.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 move = getAnimationProcessor().getBone("move");
|
||||
|
|
|
@ -46,7 +46,8 @@ import software.bernie.geckolib.core.object.PlayState;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
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);
|
||||
|
||||
public String animationprocedure = "empty";
|
||||
|
@ -70,7 +71,22 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
@Override
|
||||
protected void 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
|
||||
|
@ -163,47 +179,25 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
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
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
if (this.getFirstPassenger() == null) return;
|
||||
|
||||
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) > 0) {
|
||||
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
|
||||
}
|
||||
|
||||
if (this.getPersistentData().getInt("FireCooldown") > 28) {
|
||||
gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
|
||||
if (this.entityData.get(COOL_DOWN) > 28) {
|
||||
if (Math.random() < 0.5) {
|
||||
capability.recoilHorizon = -1;
|
||||
this.entityData.set(TYPE, -1);
|
||||
} else {
|
||||
capability.recoilHorizon = 1;
|
||||
this.entityData.set(TYPE, 1);
|
||||
}
|
||||
|
||||
capability.cannonRecoil = 10;
|
||||
capability.syncPlayerVariables(gunner);
|
||||
});
|
||||
}
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cannonShoot(Player player) {
|
||||
if (this.getPersistentData().getInt("FireCooldown") > 0) {
|
||||
if (this.entityData.get(COOL_DOWN) > 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
this.getPersistentData().putInt("FireCooldown", 30);
|
||||
this.entityData.set(COOL_DOWN, 30);
|
||||
|
||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
|
||||
this.getX() + 5 * this.getLookAngle().x,
|
||||
|
@ -365,8 +359,8 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
if (this.getFirstPassenger() != null) {
|
||||
Entity gunner = this.getFirstPassenger();
|
||||
var capability = gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||
if (capability.orElse(new ModVariables.PlayerVariables()).cannonRecoil > 0) {
|
||||
if (capability.orElse(new ModVariables.PlayerVariables()).recoilHorizon == 1) {
|
||||
if (this.entityData.get(COOL_DOWN) > 0) {
|
||||
if (this.entityData.get(TYPE) == 1) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
|
||||
} else {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire2"));
|
||||
|
@ -379,19 +373,6 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
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
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
|
@ -402,17 +383,15 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
}
|
||||
|
||||
public String getSyncedAnimation() {
|
||||
return this.entityData.get(ANIMATION);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAnimation(String animation) {
|
||||
this.entityData.set(ANIMATION, animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
|
||||
data.add(new AnimationController<>(this, "procedure", 0, this::procedurePredicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,7 +48,8 @@ import software.bernie.geckolib.core.object.PlayState;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
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);
|
||||
|
||||
public String animationprocedure = "empty";
|
||||
|
@ -71,7 +72,22 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
@Override
|
||||
protected void 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
|
||||
|
@ -164,33 +180,12 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
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
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
if (this.getFirstPassenger() == null) return;
|
||||
|
||||
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);
|
||||
});
|
||||
if (this.entityData.get(COOL_DOWN) > 0) {
|
||||
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
|
||||
}
|
||||
|
||||
this.refreshDimensions();
|
||||
|
@ -198,7 +193,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
|
||||
@Override
|
||||
public void cannonShoot(Player player) {
|
||||
if (this.getPersistentData().getInt("FireCooldown") > 0) {
|
||||
if (this.entityData.get(COOL_DOWN) > 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> capability.recoilHorizon = 1);
|
||||
this.entityData.set(TYPE, 1);
|
||||
} else {
|
||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> capability.recoilHorizon = -1);
|
||||
this.entityData.set(TYPE, -1);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
this.getPersistentData().putInt("FireCooldown", 74);
|
||||
this.entityData.set(COOL_DOWN, 74);
|
||||
|
||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
|
||||
this.getX() + 5 * this.getLookAngle().x,
|
||||
|
@ -440,8 +435,8 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
if (this.getFirstPassenger() != null) {
|
||||
Entity gunner = this.getFirstPassenger();
|
||||
var capability = gunner.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
|
||||
if (capability.orElse(new ModVariables.PlayerVariables()).cannonRecoil > 0) {
|
||||
if (capability.orElse(new ModVariables.PlayerVariables()).recoilHorizon == 1) {
|
||||
if (this.entityData.get(COOL_DOWN) > 64) {
|
||||
if (this.entityData.get(TYPE) == 1) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.salvo_fire"));
|
||||
} else {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mle1934.fire"));
|
||||
|
@ -454,19 +449,6 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
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
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
|
@ -477,17 +459,15 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
}
|
||||
|
||||
public String getSyncedAnimation() {
|
||||
return this.entityData.get(ANIMATION);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAnimation(String animation) {
|
||||
this.entityData.set(ANIMATION, animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
data.add(new AnimationController<>(this, "movement", 0, this::movementPredicate));
|
||||
data.add(new AnimationController<>(this, "procedure", 0, this::procedurePredicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ 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.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
@ -71,6 +72,11 @@ public class ClientEventHandler {
|
|||
public static double firePos = 0;
|
||||
public static double firePosZ = 0;
|
||||
public static double fireRot = 0;
|
||||
|
||||
|
||||
public static double recoilTime = 0;
|
||||
|
||||
public static double recoilHorizon = 0;
|
||||
public static double droneCameraRotX = 0;
|
||||
public static double droneCameraRotY = 0;
|
||||
public static double droneRotX = 0;
|
||||
|
@ -224,6 +230,7 @@ public class ClientEventHandler {
|
|||
|
||||
} else {
|
||||
clientTimer.stop();
|
||||
fireSpread = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,6 +256,7 @@ public class ClientEventHandler {
|
|||
handleWeaponZoom();
|
||||
handlePlayerBreath(living);
|
||||
handleWeaponFire(event, living);
|
||||
handleGunRecoil();
|
||||
handleShockCamera(event, living);
|
||||
handleBowPullAnimation(living);
|
||||
}
|
||||
|
@ -441,16 +449,17 @@ public class ClientEventHandler {
|
|||
ItemStack stack = entity.getMainHandItem();
|
||||
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) {
|
||||
firePosTimer = 0.001;
|
||||
fireRotTimer = 0.001;
|
||||
firePosZ = 0.1;
|
||||
fireSpread += 0.2;
|
||||
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);
|
||||
|
||||
if (0 < firePosTimer) {
|
||||
|
@ -469,11 +478,11 @@ public class ClientEventHandler {
|
|||
|
||||
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));
|
||||
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.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)));
|
||||
} 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.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)));
|
||||
|
@ -487,6 +496,70 @@ public class ClientEventHandler {
|
|||
fireRotTimer = 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;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -93,13 +93,11 @@ public class PlayerEventHandler {
|
|||
handleSpecialWeaponAmmo(player);
|
||||
handleChangeFireRate(player);
|
||||
handleBocekPulling(player);
|
||||
handleGunRecoil(player);
|
||||
isProne(player);
|
||||
}
|
||||
|
||||
handleGround(player);
|
||||
handleSimulationDistance(player);
|
||||
handleCannonTime(player);
|
||||
handleTacticalSprint(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) {
|
||||
if (player.level() instanceof ServerLevel serverLevel && player instanceof ServerPlayer serverPlayer) {
|
||||
var distanceManager = serverLevel.getChunkSource().chunkMap.getDistanceManager();
|
||||
|
|
|
@ -71,8 +71,6 @@ public class ModVariables {
|
|||
PlayerVariables clone = event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
|
||||
clone.zoom = original.zoom;
|
||||
clone.holdFire = original.holdFire;
|
||||
clone.recoil = original.recoil;
|
||||
clone.recoilHorizon = original.recoilHorizon;
|
||||
clone.rifleAmmo = original.rifleAmmo;
|
||||
clone.handgunAmmo = original.handgunAmmo;
|
||||
clone.shotgunAmmo = original.shotgunAmmo;
|
||||
|
@ -261,10 +259,6 @@ public class ModVariables {
|
|||
public static class PlayerVariables {
|
||||
public boolean zoom = false;
|
||||
public boolean holdFire = false;
|
||||
public double recoil = 0;
|
||||
public double recoilHorizon = 0;
|
||||
public int cannonRecoil = 0;
|
||||
|
||||
public int rifleAmmo = 0;
|
||||
public int handgunAmmo = 0;
|
||||
public int shotgunAmmo = 0;
|
||||
|
@ -288,9 +282,6 @@ public class ModVariables {
|
|||
CompoundTag nbt = new CompoundTag();
|
||||
nbt.putBoolean("zoom", zoom);
|
||||
nbt.putBoolean("holdFire", holdFire);
|
||||
nbt.putDouble("recoil", recoil);
|
||||
nbt.putDouble("recoil_horizon", recoilHorizon);
|
||||
nbt.putInt("cannonRecoil", cannonRecoil);
|
||||
nbt.putInt("rifle_ammo", rifleAmmo);
|
||||
nbt.putInt("handgun_ammo", handgunAmmo);
|
||||
nbt.putInt("shotgun_ammo", shotgunAmmo);
|
||||
|
@ -312,9 +303,6 @@ public class ModVariables {
|
|||
CompoundTag nbt = (CompoundTag) Tag;
|
||||
zoom = nbt.getBoolean("zoom");
|
||||
holdFire = nbt.getBoolean("holdFire");
|
||||
recoil = nbt.getDouble("recoil");
|
||||
recoilHorizon = nbt.getDouble("recoil_horizon");
|
||||
cannonRecoil = nbt.getInt("cannonRecoil");
|
||||
rifleAmmo = nbt.getInt("rifle_ammo");
|
||||
handgunAmmo = nbt.getInt("handgun_ammo");
|
||||
shotgunAmmo = nbt.getInt("shotgun_ammo");
|
||||
|
@ -367,9 +355,6 @@ public class ModVariables {
|
|||
PlayerVariables variables = entity.getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables());
|
||||
variables.zoom = message.data.zoom;
|
||||
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.handgunAmmo = message.data.handgunAmmo;
|
||||
variables.shotgunAmmo = message.data.shotgunAmmo;
|
||||
|
|
|
@ -304,7 +304,7 @@ public class FireMessage {
|
|||
|
||||
stack.getOrCreateTag().putBoolean("shoot", true);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,22 +8,22 @@ import net.minecraftforge.network.NetworkEvent;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ShootAnimationMessage {
|
||||
public class ShootClientMessage {
|
||||
public double time;
|
||||
|
||||
public ShootAnimationMessage(double time) {
|
||||
public ShootClientMessage(double time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public static void encode(ShootAnimationMessage message, FriendlyByteBuf buffer) {
|
||||
public static void encode(ShootClientMessage message, FriendlyByteBuf buffer) {
|
||||
buffer.writeDouble(message.time);
|
||||
}
|
||||
|
||||
public static ShootAnimationMessage decode(FriendlyByteBuf buffer) {
|
||||
return new ShootAnimationMessage(buffer.readDouble());
|
||||
public static ShootClientMessage decode(FriendlyByteBuf buffer) {
|
||||
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,
|
||||
() -> () -> ClientEventHandler.handleFireRecoilTimeMessage(message.time, context)));
|
||||
context.get().setPacketHandled(true);
|
|
@ -163,7 +163,7 @@ public class ShootMessage {
|
|||
stack.getOrCreateTag().putBoolean("shoot", true);
|
||||
|
||||
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);
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue