添加无人机缩放功能,修复无人机视角穿模问题
This commit is contained in:
parent
3b26081e1c
commit
0c25793a61
12 changed files with 1502 additions and 1441 deletions
|
@ -18,6 +18,7 @@ import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -156,6 +157,11 @@ public class ClickHandler {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
|
ClientEventHandler.droneFov = Mth.clamp(ClientEventHandler.droneFov + 0.4 * scroll, 1, 6);
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
|
||||||
Entity looking = TraceTool.findLookingEntity(player, 6);
|
Entity looking = TraceTool.findLookingEntity(player, 6);
|
||||||
if (looking == null) return;
|
if (looking == null) return;
|
||||||
if (looking instanceof MortarEntity && player.isShiftKeyDown()) {
|
if (looking instanceof MortarEntity && player.isShiftKeyDown()) {
|
||||||
|
|
|
@ -4,10 +4,12 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.DroneEntity;
|
import net.mcreator.superbwarfare.entity.DroneEntity;
|
||||||
|
import net.mcreator.superbwarfare.event.ClientEventHandler;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.tools.EntityFindUtil;
|
import net.mcreator.superbwarfare.tools.EntityFindUtil;
|
||||||
import net.mcreator.superbwarfare.tools.TraceTool;
|
import net.mcreator.superbwarfare.tools.TraceTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -23,6 +25,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import static net.mcreator.superbwarfare.client.RenderHelper.preciseBlit;
|
||||||
import static net.mcreator.superbwarfare.entity.DroneEntity.AMMO;
|
import static net.mcreator.superbwarfare.entity.DroneEntity.AMMO;
|
||||||
import static net.mcreator.superbwarfare.entity.DroneEntity.KAMIKAZE;
|
import static net.mcreator.superbwarfare.entity.DroneEntity.KAMIKAZE;
|
||||||
|
|
||||||
|
@ -46,6 +49,11 @@ public class DroneUIOverlay {
|
||||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
event.getGuiGraphics().blit(ModUtils.loc("textures/screens/drone.png"), w / 2 - 16, h / 2 - 16, 0, 0, 32, 32, 32, 32);
|
event.getGuiGraphics().blit(ModUtils.loc("textures/screens/drone.png"), w / 2 - 16, h / 2 - 16, 0, 0, 32, 32, 32, 32);
|
||||||
|
event.getGuiGraphics().blit(ModUtils.loc("textures/screens/drone_fov.png"), w / 2 + 100, h / 2 - 64, 0, 0, 64, 129, 64, 129);
|
||||||
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||||
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/drone_fov_move.png"), (float) w / 2 + 100, (float) (h / 2 - 64 - ((ClientEventHandler.droneFovLerp - 1) * 23.8)), 0, 0, 64, 129, 64, 129);
|
||||||
|
event.getGuiGraphics().drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##.#").format(ClientEventHandler.droneFovLerp) + "x"),
|
||||||
|
w / 2 + 144, h / 2 + 56 - (int) ((ClientEventHandler.droneFovLerp - 1) * 23.8), -1, false);
|
||||||
|
|
||||||
DroneEntity entity = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
|
DroneEntity entity = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
|
||||||
|
|
||||||
|
|
|
@ -195,11 +195,11 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
|
|
||||||
if (this.getPersistentData().getBoolean("forward")) {
|
if (this.getPersistentData().getBoolean("forward")) {
|
||||||
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) - 0.1f);
|
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) - 0.1f);
|
||||||
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), -0.5f));
|
this.entityData.set(ROT_Z, Mth.lerp(0.05f, this.entityData.get(ROT_Z), -0.2f));
|
||||||
}
|
}
|
||||||
if (this.getPersistentData().getBoolean("backward")) {
|
if (this.getPersistentData().getBoolean("backward")) {
|
||||||
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) + 0.1f);
|
this.entityData.set(MOVE_Z, this.entityData.get(MOVE_Z) + 0.1f);
|
||||||
this.entityData.set(ROT_Z, Mth.lerp(0.1f, this.entityData.get(ROT_Z), 0.5f));
|
this.entityData.set(ROT_Z, Mth.lerp(0.05f, this.entityData.get(ROT_Z), 0.2f));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.entityData.set(ROT_X, 0f);
|
this.entityData.set(ROT_X, 0f);
|
||||||
|
@ -214,7 +214,7 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
|
|
||||||
this.entityData.set(ROT_Z, Mth.lerp(0.05f, this.entityData.get(ROT_Z), 0));
|
this.entityData.set(ROT_Z, Mth.lerp(0.05f, this.entityData.get(ROT_Z), 0));
|
||||||
|
|
||||||
this.entityData.set(MOVE_Z, Mth.lerp(0.1f, this.entityData.get(MOVE_Z), 0));
|
this.entityData.set(MOVE_Z, Mth.lerp(0.05f, this.entityData.get(MOVE_Z), 0));
|
||||||
|
|
||||||
if (this.getPersistentData().getBoolean("up")) {
|
if (this.getPersistentData().getBoolean("up")) {
|
||||||
this.entityData.set(MOVE_Y, -1.5f);
|
this.entityData.set(MOVE_Y, -1.5f);
|
||||||
|
|
|
@ -2,13 +2,19 @@ package net.mcreator.superbwarfare.entity.model;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.entity.DroneEntity;
|
import net.mcreator.superbwarfare.entity.DroneEntity;
|
||||||
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
import net.mcreator.superbwarfare.tools.EntityFindUtil;
|
||||||
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;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||||
import software.bernie.geckolib.core.animation.AnimationState;
|
import software.bernie.geckolib.core.animation.AnimationState;
|
||||||
import software.bernie.geckolib.model.GeoModel;
|
import software.bernie.geckolib.model.GeoModel;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import static net.mcreator.superbwarfare.entity.DroneEntity.*;
|
import static net.mcreator.superbwarfare.entity.DroneEntity.*;
|
||||||
import static net.mcreator.superbwarfare.event.ClientEventHandler.droneBodyAngle;
|
import static net.mcreator.superbwarfare.event.ClientEventHandler.droneBodyAngle;
|
||||||
|
|
||||||
|
@ -43,7 +49,7 @@ public class DroneModel extends GeoModel<DroneEntity> {
|
||||||
CoreGeoBone ammo5 = getAnimationProcessor().getBone("ammo5");
|
CoreGeoBone ammo5 = getAnimationProcessor().getBone("ammo5");
|
||||||
CoreGeoBone ammo6 = getAnimationProcessor().getBone("ammo6");
|
CoreGeoBone ammo6 = getAnimationProcessor().getBone("ammo6");
|
||||||
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
CoreGeoBone shell = getAnimationProcessor().getBone("shell");
|
||||||
CoreGeoBone body = getAnimationProcessor().getBone("0");
|
CoreGeoBone main = getAnimationProcessor().getBone("0");
|
||||||
|
|
||||||
ammo6.setHidden(animatable.getEntityData().get(AMMO) <= 5);
|
ammo6.setHidden(animatable.getEntityData().get(AMMO) <= 5);
|
||||||
ammo5.setHidden(animatable.getEntityData().get(AMMO) <= 4);
|
ammo5.setHidden(animatable.getEntityData().get(AMMO) <= 4);
|
||||||
|
@ -58,8 +64,8 @@ public class DroneModel extends GeoModel<DroneEntity> {
|
||||||
rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X));
|
rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X));
|
||||||
rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z));
|
rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z));
|
||||||
|
|
||||||
body.setRotZ(rotX);
|
main.setRotZ(rotX);
|
||||||
body.setRotX(rotZ);
|
main.setRotX(rotZ);
|
||||||
|
|
||||||
droneBodyAngle(rotX, rotZ);
|
droneBodyAngle(rotX, rotZ);
|
||||||
|
|
||||||
|
@ -77,5 +83,30 @@ public class DroneModel extends GeoModel<DroneEntity> {
|
||||||
wingBL.setRotY(wingFL.getRotY() - rotation);
|
wingBL.setRotY(wingFL.getRotY() - rotation);
|
||||||
wingBR.setRotY(wingFL.getRotY() - rotation);
|
wingBR.setRotY(wingFL.getRotY() - rotation);
|
||||||
|
|
||||||
|
CoreGeoBone weapon = getAnimationProcessor().getBone("Weapon");
|
||||||
|
|
||||||
|
String id = animatable.getEntityData().get(CONTROLLER);
|
||||||
|
|
||||||
|
UUID uuid;
|
||||||
|
try {
|
||||||
|
uuid = UUID.fromString(id);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = animatable.level().getPlayerByUUID(uuid);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
DroneEntity drone = EntityFindUtil.findDrone(player.level(), stack.getOrCreateTag().getString("LinkedDrone"));
|
||||||
|
|
||||||
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
|
if (drone != null && drone.getUUID() == animatable.getUUID()) {
|
||||||
|
weapon.setHidden(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
weapon.setHidden(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class HandGrenadeEntity extends ThrowableItemProjectile {
|
||||||
if (this.fuse <= 0) {
|
if (this.fuse <= 0) {
|
||||||
this.discard();
|
this.discard();
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
ProjectileTool.causeCustomExplode(this, 175f, 7.25f, 2.2f);
|
ProjectileTool.causeCustomExplode(this, 175f, 7.25f, 1.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
||||||
}
|
}
|
||||||
if (this.tickCount > 2) {
|
if (this.tickCount > 2) {
|
||||||
ProjectileTool.causeCustomExplode(this, 135f, 6.75f, 1.5f);
|
ProjectileTool.causeCustomExplode(this, 135f, 6.75f, 1.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -101,7 +101,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.tickCount > 2 && !(entity instanceof DroneEntity)) {
|
if (this.tickCount > 2 && !(entity instanceof DroneEntity)) {
|
||||||
ProjectileTool.causeCustomExplode(this, 150f, 4.75f, 2f);
|
ProjectileTool.causeCustomExplode(this, 150f, 4.75f, 1.2f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -157,7 +157,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
}
|
}
|
||||||
|
|
||||||
public void droneShoot(Entity drone) {
|
public void droneShoot(Entity drone) {
|
||||||
Vec3 vec3 = (new Vec3(0.5 * drone.getDeltaMovement().x, drone.getDeltaMovement().y, 0.5 * drone.getDeltaMovement().z));
|
Vec3 vec3 = (new Vec3(0.2 * drone.getDeltaMovement().x, 0.2 * drone.getDeltaMovement().y, 0.2 * drone.getDeltaMovement().z));
|
||||||
this.setDeltaMovement(vec3);
|
this.setDeltaMovement(vec3);
|
||||||
double d0 = vec3.horizontalDistance();
|
double d0 = vec3.horizontalDistance();
|
||||||
this.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * (double) (180F / (float) Math.PI)));
|
this.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * (double) (180F / (float) Math.PI)));
|
||||||
|
|
|
@ -82,14 +82,15 @@ public class ClientEventHandler {
|
||||||
public static double recoilTime = 0;
|
public static double recoilTime = 0;
|
||||||
|
|
||||||
public static double recoilHorizon = 0;
|
public static double recoilHorizon = 0;
|
||||||
|
|
||||||
public static double recoilY = 0;
|
public static double recoilY = 0;
|
||||||
|
|
||||||
public static double droneRotX = 0;
|
public static double droneRotX = 0;
|
||||||
public static double droneRotZ = 0;
|
public static double droneRotZ = 0;
|
||||||
|
public static double droneFov = 1;
|
||||||
|
public static double droneFovLerp = 1;
|
||||||
|
|
||||||
public static double breathTime = 0;
|
public static double breathTime = 0;
|
||||||
|
|
||||||
public static double fov = 0;
|
public static double fov = 0;
|
||||||
|
|
||||||
public static double pullTimer = 0;
|
public static double pullTimer = 0;
|
||||||
public static double bowTimer = 0;
|
public static double bowTimer = 0;
|
||||||
public static double handTimer = 0;
|
public static double handTimer = 0;
|
||||||
|
@ -1033,9 +1034,17 @@ public class ClientEventHandler {
|
||||||
fov = event.getFOV();
|
fov = event.getFOV();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom && !stack.is(ModTags.Items.GUN)) {
|
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom && !stack.is(ModTags.Items.GUN)) {
|
||||||
event.setFOV(event.getFOV() / 5);
|
event.setFOV(event.getFOV() / 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
|
|
||||||
|
droneFovLerp = Mth.lerp(0.1 * Minecraft.getInstance().getDeltaFrameTime() , droneFovLerp, droneFov);
|
||||||
|
|
||||||
|
event.setFOV(event.getFOV() / droneFovLerp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class CameraMixin {
|
||||||
CameraPos.rotateZ(-drone.getXRot() * Mth.DEG_TO_RAD);
|
CameraPos.rotateZ(-drone.getXRot() * Mth.DEG_TO_RAD);
|
||||||
CameraPos.rotateY(-yRot * Mth.DEG_TO_RAD);
|
CameraPos.rotateY(-yRot * Mth.DEG_TO_RAD);
|
||||||
setRotation(drone.getViewYRot(partialTicks), drone.getViewXRot(partialTicks));
|
setRotation(drone.getViewYRot(partialTicks), drone.getViewXRot(partialTicks));
|
||||||
setPosition(Mth.lerp(partialTicks, drone.xo + CameraPos.x, drone.getX() + CameraPos.x), Mth.lerp(partialTicks, drone.yo + CameraPos.y, drone.getY() + CameraPos.y), Mth.lerp(partialTicks, drone.zo + CameraPos.z, drone.getZ() + CameraPos.z));
|
setPosition(Mth.lerp(partialTicks, drone.xo + CameraPos.x, drone.getX() + CameraPos.x), Mth.lerp(partialTicks, drone.yo + 0.075, drone.getEyeY()), Mth.lerp(partialTicks, drone.zo + CameraPos.z, drone.getZ() + CameraPos.z));
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
|
||||||
|
import static net.mcreator.superbwarfare.event.ClientEventHandler.droneFovLerp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: MrCrayfish
|
* Author: MrCrayfish
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +47,7 @@ public class MouseHandlerMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
return 0.32;
|
return 0.33 / (1 + 0.08 * (droneFovLerp - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stack.is(ModTags.Items.GUN)) {
|
if (!stack.is(ModTags.Items.GUN)) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 364 B |
Loading…
Add table
Reference in a new issue