加入视角抖动(AK,SKS)
This commit is contained in:
parent
99269f409a
commit
22714210ca
6 changed files with 229 additions and 10 deletions
|
@ -1,14 +1,22 @@
|
|||
package net.mcreator.target.client.model.item;
|
||||
|
||||
import net.mcreator.target.init.TargetModMobEffects;
|
||||
import net.mcreator.target.item.gun.AK47Item;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.event.ViewportEvent;
|
||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||
import software.bernie.geckolib.core.animation.AnimationState;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
|
||||
public class AK47ItemModel extends GeoModel<AK47Item> {
|
||||
|
||||
|
@ -136,5 +144,13 @@ public class AK47ItemModel extends GeoModel<AK47Item> {
|
|||
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
|
||||
|
||||
move.setRotY(1.9f * (float) yaw - (float) m);
|
||||
|
||||
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
||||
|
||||
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
|
||||
|
||||
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
|
||||
|
||||
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.SksItem;
|
|||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||
|
@ -137,5 +138,13 @@ public class SksItemModel extends GeoModel<SksItem> {
|
|||
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m);
|
||||
|
||||
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m);
|
||||
|
||||
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
|
||||
|
||||
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
|
||||
|
||||
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
|
||||
|
||||
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class ClientEventHandler {
|
|||
handleWeaponZoom(living);
|
||||
handleWeaponFire(event, living);
|
||||
handleShockCamera(event, living);
|
||||
PlayerCameraShake(event, living);
|
||||
handleBowPullAnimation(living);
|
||||
}
|
||||
}
|
||||
|
@ -425,6 +426,20 @@ public class ClientEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void PlayerCameraShake(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) {
|
||||
var data = entity.getPersistentData();
|
||||
double yaw = event.getYaw();
|
||||
double pitch = event.getPitch();
|
||||
double roll = event.getRoll();
|
||||
|
||||
event.setPitch((float) (pitch + data.getDouble("camera_rot_x")));
|
||||
|
||||
event.setYaw((float) (yaw + data.getDouble("camera_rot_y")));
|
||||
|
||||
event.setRoll((float) (roll + data.getDouble("camera_rot_z")));
|
||||
|
||||
}
|
||||
|
||||
private static void handleBowPullAnimation(LivingEntity entity) {
|
||||
float fps = Minecraft.getInstance().getFps();
|
||||
if (fps <= 0) {
|
||||
|
|
|
@ -40,6 +40,26 @@
|
|||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.2": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [0, 0, -1],
|
||||
"easing": "easeInOutSine"
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [1, -1, 1]
|
||||
},
|
||||
"0.6": {
|
||||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -241,6 +261,25 @@
|
|||
"vector": [2.5, -2, 0]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [-0.5, -0.5, 0.5]
|
||||
},
|
||||
"0.2": {
|
||||
"vector": [0.5, 0, -0.5]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [-0.5, 0.5, 0.5]
|
||||
},
|
||||
"0.6": {
|
||||
"vector": [0.5, 0, -0.5]
|
||||
},
|
||||
"0.8": {
|
||||
"vector": [-0.5, -0.5, 0.5]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -679,44 +718,44 @@
|
|||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [1, 0, 2],
|
||||
"vector": [1, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [-1, 0, -2],
|
||||
"vector": [-0.5, 0, -1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.7": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
},
|
||||
"1.1": {
|
||||
"1.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"1.3": {
|
||||
"1.2": {
|
||||
"vector": [0, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.4": {
|
||||
"1.3": {
|
||||
"vector": [-1, 0, -2],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.6": {
|
||||
"1.5": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
},
|
||||
"1.9": {
|
||||
"1.8": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"2.0": {
|
||||
"1.9": {
|
||||
"vector": [0, 2, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"2.1": {
|
||||
"2.0": {
|
||||
"vector": [-1, -1, -2],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"2.3": {
|
||||
"2.2": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
}
|
||||
|
@ -927,6 +966,40 @@
|
|||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.3": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [1, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [-0.5, 0, -1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.7": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
},
|
||||
"1.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"1.2": {
|
||||
"vector": [0, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.3": {
|
||||
"vector": [-1, 0, -2],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.5": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,25 @@
|
|||
"vector": [2.5, -3, 0]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.0": {
|
||||
"vector": [-0.5, -0.5, 0.5]
|
||||
},
|
||||
"0.2": {
|
||||
"vector": [0.5, 0, -0.5]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [-0.5, 0.5, 0.5]
|
||||
},
|
||||
"0.6": {
|
||||
"vector": [0.5, 0, -0.5]
|
||||
},
|
||||
"0.8": {
|
||||
"vector": [-0.5, -0.5, 0.5]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -411,6 +430,55 @@
|
|||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.3": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [1, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [-0.5, 0, -1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.7": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
},
|
||||
"1.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"1.2": {
|
||||
"vector": [0, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.3": {
|
||||
"vector": [-1, 0, -2],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.5": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
},
|
||||
"1.8": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"1.9": {
|
||||
"vector": [0, 2, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"2.0": {
|
||||
"vector": [-1, -1, -2],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"2.2": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -594,6 +662,40 @@
|
|||
"vector": [0, 0, 0]
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"rotation": {
|
||||
"0.3": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"0.4": {
|
||||
"vector": [1, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.5": {
|
||||
"vector": [-0.5, 0, -1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"0.7": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
},
|
||||
"1.0": {
|
||||
"vector": [0, 0, 0]
|
||||
},
|
||||
"1.2": {
|
||||
"vector": [0, 0, 1],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.3": {
|
||||
"vector": [-1, 0, -2],
|
||||
"easing": "easeInElastic"
|
||||
},
|
||||
"1.5": {
|
||||
"vector": [0, 0, 0],
|
||||
"easing": "easeOutBack"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
"visible_bounds_offset": [0, 0, 0]
|
||||
},
|
||||
"bones": [
|
||||
{
|
||||
"name": "camera",
|
||||
"pivot": [0, 0, 0]
|
||||
},
|
||||
{
|
||||
"name": "root",
|
||||
"pivot": [0, 0, 0]
|
||||
|
|
Loading…
Add table
Reference in a new issue