SSK去营业妨碍化,重新添加后坐力流程
This commit is contained in:
parent
8bdc39a849
commit
c22798b2b7
8 changed files with 8558 additions and 10693 deletions
|
@ -68,7 +68,7 @@ public class PlayerEventHandler {
|
|||
handleDistantRange(player);
|
||||
handleRenderDamageIndicator(player);
|
||||
handleBocekPulling(player);
|
||||
handleGunRecoil(player);
|
||||
// handleGunRecoil(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,76 +396,76 @@ public class PlayerEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleGunRecoil(Player player) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
// private static void handleGunRecoil(Player player) {
|
||||
// ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (!stack.is(TargetModTags.Items.GUN)) {
|
||||
return;
|
||||
}
|
||||
// if (!stack.is(TargetModTags.Items.GUN)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
float recoilX = (float) stack.getOrCreateTag().getDouble("recoilx");
|
||||
float recoilY = (float) stack.getOrCreateTag().getDouble("recoily");
|
||||
float recoilYaw = (float) (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon;
|
||||
// float recoilX = (float) stack.getOrCreateTag().getDouble("recoilx");
|
||||
// float recoilY = (float) stack.getOrCreateTag().getDouble("recoily");
|
||||
// float recoilYaw = (float) (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon;
|
||||
|
||||
double[] recoilTimer = {0};
|
||||
double totalTime = 100;
|
||||
int sleepTime = 2;
|
||||
double recoilDuration = totalTime / sleepTime;
|
||||
// double[] recoilTimer = {0};
|
||||
// double totalTime = 100;
|
||||
// int sleepTime = 2;
|
||||
// double recoilDuration = totalTime / sleepTime;
|
||||
|
||||
Runnable recoilRunnable = () -> {
|
||||
while (recoilTimer[0] < recoilDuration) {
|
||||
float rx;
|
||||
float ry;
|
||||
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && player.getPersistentData().getDouble("prone") == 0) {
|
||||
rx = 0.7f;
|
||||
ry = 0.8f;
|
||||
} else if (player.getPersistentData().getDouble("prone") > 0) {
|
||||
if (stack.getOrCreateTag().getDouble("bipod") == 1) {
|
||||
rx = 0.05f;
|
||||
ry = 0.1f;
|
||||
} else {
|
||||
rx = 0.5f;
|
||||
ry = 0.7f;
|
||||
}
|
||||
} else {
|
||||
rx = 1f;
|
||||
ry = 1f;
|
||||
}
|
||||
// Runnable recoilRunnable = () -> {
|
||||
// while (recoilTimer[0] < recoilDuration) {
|
||||
// float rx;
|
||||
// float ry;
|
||||
// if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && player.getPersistentData().getDouble("prone") == 0) {
|
||||
// rx = 0.7f;
|
||||
// ry = 0.8f;
|
||||
// } else if (player.getPersistentData().getDouble("prone") > 0) {
|
||||
// if (stack.getOrCreateTag().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(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil;
|
||||
if (recoil >= 1) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoil = 0;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
}
|
||||
// double recoil = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil;
|
||||
// if (recoil >= 1) {
|
||||
// player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
// capability.recoil = 0;
|
||||
// capability.syncPlayerVariables(player);
|
||||
// });
|
||||
// }
|
||||
|
||||
if (recoil > 0) {
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoil = recoil + 0.0025;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
// if (recoil > 0) {
|
||||
// player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
// capability.recoil = recoil + 0.0025;
|
||||
// capability.syncPlayerVariables(player);
|
||||
// });
|
||||
|
||||
double sinRes = Math.sin(2 * Math.PI * (1.03f * recoil - 0.032047110911)) + 0.2;
|
||||
// double sinRes = Math.sin(2 * Math.PI * (1.03f * recoil - 0.032047110911)) + 0.2;
|
||||
|
||||
float newPitch = ((float) (player.getXRot() - 1.5f * recoilY * ry * sinRes));
|
||||
player.setXRot(newPitch);
|
||||
player.xRotO = player.getXRot();
|
||||
// float newPitch = ((float) (player.getXRot() - 1.5f * recoilY * ry * sinRes));
|
||||
// player.setXRot(newPitch);
|
||||
// player.xRotO = player.getXRot();
|
||||
|
||||
float newYaw = ((float) (player.getYRot() - 1.0f * recoilYaw * recoilX * rx * sinRes));
|
||||
player.setYRot(newYaw);
|
||||
player.yRotO = player.getYRot();
|
||||
}
|
||||
// float newYaw = ((float) (player.getYRot() - 1.0f * recoilYaw * recoilX * rx * sinRes));
|
||||
// player.setYRot(newYaw);
|
||||
// player.yRotO = player.getYRot();
|
||||
// }
|
||||
|
||||
recoilTimer[0]++;
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread recoilThread = new Thread(recoilRunnable);
|
||||
recoilThread.start();
|
||||
}
|
||||
// recoilTimer[0]++;
|
||||
// try {
|
||||
// Thread.sleep(sleepTime);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// Thread recoilThread = new Thread(recoilRunnable);
|
||||
// recoilThread.start();
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.mcreator.target.init.TargetModMobEffects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class GunRecoilProcedure {
|
||||
@SubscribeEvent
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
execute(event, event.player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute(Entity entity) {
|
||||
execute(null, entity);
|
||||
}
|
||||
|
||||
private static void execute(@Nullable Event event, Entity entity) {
|
||||
|
||||
|
||||
float recoilx = ((float) (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("recoilx"));
|
||||
float recoily = ((float) (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("recoily"));
|
||||
float recoilyaw = ((float) (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon);
|
||||
|
||||
double[] recoilTimer = {0};
|
||||
double totalTime = 100;
|
||||
int sleepTime = 2;
|
||||
double recoilDuration = totalTime / sleepTime;
|
||||
Runnable recoilRunnable = () -> {
|
||||
while (recoilTimer[0] < recoilDuration) {
|
||||
|
||||
if (entity == null)
|
||||
return;
|
||||
float rx = 0;
|
||||
float ry = 0;
|
||||
|
||||
if (entity.isShiftKeyDown() && entity.getBbHeight() >= 1 && entity.getPersistentData().getDouble("prone") == 0) {
|
||||
rx = 0.7f;
|
||||
ry = 0.8f;
|
||||
} else if (entity.getPersistentData().getDouble("prone") > 0) {
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("bipod") == 1) {
|
||||
rx = 0.05f;
|
||||
ry = 0.1f;
|
||||
} else {
|
||||
rx = 0.5f;
|
||||
ry = 0.7f;
|
||||
}
|
||||
} else {
|
||||
rx = 1f;
|
||||
ry = 1f;
|
||||
}
|
||||
|
||||
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil >= 1) {
|
||||
{
|
||||
double _setval = 0;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoil = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil > 0) {
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil + 0.0025;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.recoil = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
|
||||
float newPitch = ((float) (entity.getXRot() - 1.5f * recoily * ry * (Math.sin(2 * Math.PI * (1.03f * (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil - 0.032047110911)) + 0.2)));
|
||||
entity.setXRot(newPitch);
|
||||
entity.xRotO = entity.getXRot();
|
||||
|
||||
float newYaw = ((float) (entity.getYRot() - 1.0f * recoilyaw * recoilx * rx * (Math.sin(2 * Math.PI * (1.03f * (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoil - 0.032047110911)) + 0.2)));
|
||||
entity.setYRot(newYaw);
|
||||
entity.yRotO = entity.getYRot();
|
||||
|
||||
}
|
||||
|
||||
recoilTimer[0]++;
|
||||
try {
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread recoilThread = new Thread(recoilRunnable);
|
||||
recoilThread.start();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "target:item/akicon"
|
||||
"layer0": "target:item/sks_icon"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 31 KiB |
Binary file not shown.
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 37 KiB |
BIN
src/main/resources/assets/target/textures/item/sks_icon.png
Normal file
BIN
src/main/resources/assets/target/textures/item/sks_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Loading…
Add table
Reference in a new issue