移除无人机shader,修改炮弹重力,重制火炮标尺
This commit is contained in:
parent
51d7f41321
commit
740b810168
20 changed files with 137 additions and 142 deletions
|
@ -97,10 +97,17 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
int k = (w - i) / 2;
|
||||
int l = (h - j) / 2;
|
||||
if (ClientEventHandler.zoomVehicle) {
|
||||
Entity lookingEntity = TraceTool.findLookingEntity(player, 512);
|
||||
|
||||
Vec3 shootPos = player.getEyePosition(deltaTracker.getRealtimeDeltaTicks());
|
||||
|
||||
if (!(cannon instanceof AnnihilatorEntity)) {
|
||||
shootPos = cannon.driverZoomPos(deltaTracker.getRealtimeDeltaTicks());
|
||||
}
|
||||
|
||||
Entity lookingEntity = TraceTool.vehiclefFindLookingEntity(cannon, shootPos, 512);
|
||||
boolean lookAtEntity = false;
|
||||
|
||||
BlockHitResult result = player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getViewVector(1).scale(512)),
|
||||
BlockHitResult result = player.level().clip(new ClipContext(shootPos, shootPos.add(player.getViewVector(1).scale(512)),
|
||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
|
||||
Vec3 hitPos = result.getLocation();
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
public static int MAX_DISTANCE = 256;
|
||||
private static final ResourceLocation FRAME = Mod.loc("textures/screens/frame/frame.png");
|
||||
private static final ResourceLocation TV_FRAME = Mod.loc("textures/screens/land/tv_frame.png");
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
|
@ -72,6 +73,9 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
if (stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked")) {
|
||||
guiGraphics.blit(Mod.loc("textures/screens/drone.png"), w / 2 - 16, h / 2 - 16, 0, 0, 32, 32, 32, 32);
|
||||
guiGraphics.blit(Mod.loc("textures/screens/drone_fov.png"), w / 2 + 100, h / 2 - 64, 0, 0, 64, 129, 64, 129);
|
||||
int addW = (w / h) * 48;
|
||||
int addH = (w / h) * 27;
|
||||
preciseBlit(guiGraphics, TV_FRAME, (float) -addW / 2, (float) -addH / 2, 10, 0, 0.0F, w + addW, h + addH, w + addW, h + addH);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.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);
|
||||
guiGraphics.drawString(mc.font, Component.literal(FormatTool.format1D(ClientEventHandler.droneFovLerp, "x")),
|
||||
|
|
|
@ -3,15 +3,19 @@ package com.atsuishio.superbwarfare.client.renderer.entity;
|
|||
import com.atsuishio.superbwarfare.client.layer.vehicle.Mk42Layer;
|
||||
import com.atsuishio.superbwarfare.client.model.entity.Mk42Model;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Mk42Entity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class Mk42Renderer extends GeoEntityRenderer<Mk42Entity> {
|
||||
|
@ -44,7 +48,14 @@ public class Mk42Renderer extends GeoEntityRenderer<Mk42Entity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(Mk42Entity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
public void renderRecursively(PoseStack poseStack, Mk42Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
String name = bone.getName();
|
||||
|
||||
if (name.equals("bone")) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
bone.setHidden(ClientEventHandler.zoomVehicle && animatable.getFirstPassenger() == player);
|
||||
}
|
||||
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,19 @@ package com.atsuishio.superbwarfare.client.renderer.entity;
|
|||
import com.atsuishio.superbwarfare.client.layer.vehicle.Mle1934Layer;
|
||||
import com.atsuishio.superbwarfare.client.model.entity.Mle1934Model;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Mle1934Entity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class Mle1934Renderer extends GeoEntityRenderer<Mle1934Entity> {
|
||||
|
@ -44,7 +48,14 @@ public class Mle1934Renderer extends GeoEntityRenderer<Mle1934Entity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(Mle1934Entity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
public void renderRecursively(PoseStack poseStack, Mle1934Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
String name = bone.getName();
|
||||
|
||||
if (name.equals("bone")) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
bone.setHidden(ClientEventHandler.zoomVehicle && animatable.getFirstPassenger() == player);
|
||||
}
|
||||
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,19 +51,21 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt
|
|||
private int durability = 40;
|
||||
private boolean firstHit = true;
|
||||
public Set<Long> loadedChunks = new HashSet<>();
|
||||
private float gravity = 0.1f;
|
||||
|
||||
public CannonShellEntity(EntityType<? extends CannonShellEntity> type, Level world) {
|
||||
super(type, world);
|
||||
this.noCulling = true;
|
||||
}
|
||||
|
||||
public CannonShellEntity(LivingEntity entity, Level world, float damage, float radius, float explosionDamage, float fireProbability, int fireTime) {
|
||||
public CannonShellEntity(LivingEntity entity, Level world, float damage, float radius, float explosionDamage, float fireProbability, int fireTime, float gravity) {
|
||||
super(ModEntities.CANNON_SHELL.get(), entity, world);
|
||||
this.damage = damage;
|
||||
this.radius = radius;
|
||||
this.explosionDamage = explosionDamage;
|
||||
this.fireProbability = fireProbability;
|
||||
this.fireTime = fireTime;
|
||||
this.gravity = gravity;
|
||||
}
|
||||
|
||||
public CannonShellEntity durability(int durability) {
|
||||
|
@ -310,7 +312,7 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt
|
|||
|
||||
@Override
|
||||
protected double getDefaultGravity() {
|
||||
return 0.2F;
|
||||
return gravity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -494,6 +494,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getTurretTransform(ticks);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 0, 0.75f);
|
||||
|
|
|
@ -418,6 +418,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getTurretTransform(ticks);
|
||||
Vector4f worldPosition = transformPosition(transform, 0.3f, 0.75f, 0.56f);
|
||||
|
|
|
@ -60,6 +60,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> YAW = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
||||
|
||||
private final float shellGravity = 0.1f;
|
||||
|
||||
public Mk42Entity(EntityType<Mk42Entity> type, Level world) {
|
||||
super(type, world);
|
||||
|
@ -82,6 +83,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
.explosionDamage(VehicleConfig.MK42_AP_EXPLOSION_DAMAGE.get())
|
||||
.explosionRadius(VehicleConfig.MK42_AP_EXPLOSION_RADIUS.get().floatValue())
|
||||
.durability(60)
|
||||
.gravity(shellGravity)
|
||||
.sound(ModSounds.CANNON_RELOAD.get())
|
||||
.icon(Mod.loc("textures/screens/vehicle_weapon/ap_shell.png")),
|
||||
new CannonShellWeapon()
|
||||
|
@ -91,6 +93,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
.durability(0)
|
||||
.fireProbability(0.18F)
|
||||
.fireTime(2)
|
||||
.gravity(shellGravity)
|
||||
.sound(ModSounds.CANNON_RELOAD.get())
|
||||
.icon(Mod.loc("textures/screens/vehicle_weapon/he_shell.png")),
|
||||
}
|
||||
|
@ -150,18 +153,25 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
int targetX = pos.getX();
|
||||
int targetY = pos.getY();
|
||||
int targetZ = pos.getZ();
|
||||
var isDepressed = parameters.isDepressed();
|
||||
|
||||
if (!RangeTool.canReach(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), -14.9, 85, parameters.isDepressed()))
|
||||
Matrix4f transform = getVehicleFlatTransform(1);
|
||||
Vector4f worldPosition = transformPosition(transform, 0f, 2.16f, 0.5175f);
|
||||
Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
|
||||
if (!RangeTool.canReach(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), -14.9, 85, isDepressed))
|
||||
return;
|
||||
|
||||
this.look(new Vec3(targetX, targetY, targetZ));
|
||||
entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), parameters.isDepressed()));
|
||||
entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), isDepressed));
|
||||
}
|
||||
|
||||
private void look(Vec3 pTarget) {
|
||||
Vec3 vec3 = this.getEyePosition();
|
||||
double d0 = pTarget.x - vec3.x;
|
||||
double d2 = pTarget.z - vec3.z;
|
||||
Matrix4f transform = getVehicleFlatTransform(1);
|
||||
Vector4f worldPosition = transformPosition(transform, 0f, 2.16f, 0.5175f);
|
||||
Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
double d0 = pTarget.x - shootPos.x;
|
||||
double d2 = pTarget.z - shootPos.z;
|
||||
entityData.set(YAW, Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F));
|
||||
}
|
||||
|
||||
|
@ -274,6 +284,13 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getVehicleFlatTransform(1);
|
||||
Vector4f worldPosition = transformPosition(transform, 0f, 2.16f + 1.4f, 0.5175f);
|
||||
return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vehicleShoot(Player player, int type) {
|
||||
if (this.entityData.get(COOL_DOWN) > 0) return;
|
||||
|
@ -346,7 +363,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
Entity passenger = this.getFirstPassenger();
|
||||
if (passenger != null) {
|
||||
entityData.set(YAW, passenger.getYHeadRot());
|
||||
entityData.set(PITCH, passenger.getXRot() - 1.3f);
|
||||
entityData.set(PITCH, passenger.getXRot() - 2f);
|
||||
}
|
||||
|
||||
float diffY = Mth.wrapDegrees(entityData.get(YAW) - this.getYRot());
|
||||
|
@ -355,12 +372,12 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
turretTurnSound(diffX, diffY, 0.95f);
|
||||
|
||||
this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY, -1.75f, 1.75f));
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -3f, 3f), -85, 16.3f));
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -3f, 3f), -85, 15f));
|
||||
}
|
||||
|
||||
protected void clampRotation(Entity entity) {
|
||||
float f = Mth.wrapDegrees(entity.getXRot());
|
||||
float f1 = Mth.clamp(f, -85.0F, 16.3F);
|
||||
float f1 = Mth.clamp(f, -85.0F, 17F);
|
||||
entity.xRotO += f1 - f;
|
||||
entity.setXRot(entity.getXRot() + f1 - f);
|
||||
}
|
||||
|
@ -418,6 +435,14 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getBarrelVector(float pPartialTicks) {
|
||||
if (getFirstPassenger() != null) {
|
||||
return getFirstPassenger().getViewVector(pPartialTicks);
|
||||
}
|
||||
return super.getBarrelVector(pPartialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getVehicleIcon() {
|
||||
return Mod.loc("textures/vehicle_icon/sherman_icon.png");
|
||||
|
|
|
@ -60,6 +60,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> YAW = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
private final float shellGravity = 0.1f;
|
||||
|
||||
public Mle1934Entity(EntityType<Mle1934Entity> type, Level world) {
|
||||
super(type, world);
|
||||
|
@ -74,6 +75,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
.explosionDamage(VehicleConfig.MLE1934_AP_EXPLOSION_DAMAGE.get())
|
||||
.explosionRadius(VehicleConfig.MLE1934_AP_EXPLOSION_RADIUS.get().floatValue())
|
||||
.durability(70)
|
||||
.gravity(shellGravity)
|
||||
.sound(ModSounds.CANNON_RELOAD.get())
|
||||
.icon(Mod.loc("textures/screens/vehicle_weapon/ap_shell.png")),
|
||||
new CannonShellWeapon()
|
||||
|
@ -83,6 +85,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
.durability(0)
|
||||
.fireProbability(0.24F)
|
||||
.fireTime(5)
|
||||
.gravity(shellGravity)
|
||||
.sound(ModSounds.CANNON_RELOAD.get())
|
||||
.icon(Mod.loc("textures/screens/vehicle_weapon/he_shell.png")),
|
||||
}
|
||||
|
@ -153,18 +156,27 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
int targetX = pos.getX();
|
||||
int targetY = pos.getY();
|
||||
int targetZ = pos.getZ();
|
||||
var isDepressed = parameters.isDepressed();
|
||||
|
||||
if (!RangeTool.canReach(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), -2.7, 30, parameters.isDepressed()))
|
||||
this.look(new Vec3(targetX, targetY, targetZ));
|
||||
Matrix4f transform = getVehicleFlatTransform(1);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 1.4992625f, 1.52065f);
|
||||
Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
|
||||
if (!RangeTool.canReach(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), -2.7, 30, isDepressed))
|
||||
return;
|
||||
|
||||
this.look(new Vec3(targetX, targetY, targetZ));
|
||||
entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, 0.2F, this.getEyePosition(), new Vec3(targetX, targetY, targetZ), parameters.isDepressed()));
|
||||
entityData.set(PITCH, (float) -RangeTool.calculateAngle(15, shellGravity, shootPos, new Vec3(targetX, targetY, targetZ), isDepressed));
|
||||
}
|
||||
|
||||
private void look(Vec3 pTarget) {
|
||||
Vec3 vec3 = this.getEyePosition();
|
||||
double d0 = pTarget.x - vec3.x;
|
||||
double d2 = pTarget.z - vec3.z;
|
||||
Matrix4f transform = getVehicleFlatTransform(1);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 1.4992625f, 1.52065f);
|
||||
Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
|
||||
double d0 = pTarget.x - shootPos.x;
|
||||
double d2 = pTarget.z - shootPos.z;
|
||||
entityData.set(YAW, Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F));
|
||||
}
|
||||
|
||||
|
@ -282,6 +294,13 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
this.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getVehicleFlatTransform(1);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 1.4992625f + 1.4f, 1.52065f);
|
||||
return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vehicleShoot(Player player, int type) {
|
||||
if (this.entityData.get(COOL_DOWN) > 0) return;
|
||||
|
@ -404,7 +423,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
Entity passenger = this.getFirstPassenger();
|
||||
if (passenger != null) {
|
||||
entityData.set(YAW, passenger.getYHeadRot());
|
||||
entityData.set(PITCH, passenger.getXRot() - 1.2f);
|
||||
entityData.set(PITCH, passenger.getXRot() - 2f);
|
||||
}
|
||||
|
||||
float diffY = Mth.wrapDegrees(entityData.get(YAW) - this.getYRot());
|
||||
|
@ -413,12 +432,12 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
turretTurnSound(diffX, diffY, 0.95f);
|
||||
|
||||
this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY, -1.25f, 1.25f));
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -2f, 2f), -30, 4f));
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(0.5f * diffX, -2f, 2f), -30, 5f));
|
||||
}
|
||||
|
||||
protected void clampRotation(Entity entity) {
|
||||
float f = Mth.wrapDegrees(entity.getXRot());
|
||||
float f1 = Mth.clamp(f, -30.0F, 4.0F);
|
||||
float f1 = Mth.clamp(f, -30.0F, 7.0F);
|
||||
entity.xRotO += f1 - f;
|
||||
entity.setXRot(entity.getXRot() + f1 - f);
|
||||
}
|
||||
|
@ -485,6 +504,14 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getBarrelVector(float pPartialTicks) {
|
||||
if (getFirstPassenger() != null) {
|
||||
return getFirstPassenger().getViewVector(pPartialTicks);
|
||||
}
|
||||
return super.getBarrelVector(pPartialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getVehicleIcon() {
|
||||
return Mod.loc("textures/vehicle_icon/mle1934_icon.png");
|
||||
|
|
|
@ -556,6 +556,7 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
return new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getBarrelTransform(ticks);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 0.95f, 0f);
|
||||
|
|
|
@ -428,6 +428,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
this.clampRotation(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getBarrelTransform(ticks);
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
.fireTime(0)
|
||||
.durability(100)
|
||||
.velocity(40)
|
||||
.gravity(0.1f)
|
||||
.sound(ModSounds.INTO_MISSILE.get())
|
||||
.ammo(ModItems.AP_5_INCHES.get())
|
||||
.icon(Mod.loc("textures/screens/vehicle_weapon/ap_shell.png")),
|
||||
|
@ -116,6 +117,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
.fireTime(2)
|
||||
.durability(0)
|
||||
.velocity(25)
|
||||
.gravity(0.1f)
|
||||
.sound(ModSounds.INTO_CANNON.get())
|
||||
.ammo(ModItems.HE_5_INCHES.get())
|
||||
.icon(Mod.loc("textures/screens/vehicle_weapon/he_shell.png")),
|
||||
|
@ -763,6 +765,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
Matrix4f transform = getTurretTransform(ticks);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 1.2f, 0.6076875f);
|
||||
|
|
|
@ -947,6 +947,10 @@ public abstract class VehicleEntity extends Entity {
|
|||
this.gunXRot = pGunXRot;
|
||||
}
|
||||
|
||||
public Vec3 driverZoomPos(float ticks) {
|
||||
return getEyePosition();
|
||||
}
|
||||
|
||||
public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
if (!(this instanceof WeaponVehicleEntity weaponVehicle)) return;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class CannonShellWeapon extends VehicleWeapon {
|
||||
public float hitDamage, explosionRadius, explosionDamage, fireProbability, velocity;
|
||||
public float hitDamage, explosionRadius, explosionDamage, fireProbability, velocity, gravity;
|
||||
public int fireTime, durability;
|
||||
|
||||
public CannonShellWeapon hitDamage(float hitDamage) {
|
||||
|
@ -42,6 +42,11 @@ public class CannonShellWeapon extends VehicleWeapon {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CannonShellWeapon gravity(float gravity) {
|
||||
this.gravity = gravity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CannonShellEntity create(Player player) {
|
||||
return new CannonShellEntity(player,
|
||||
player.level(),
|
||||
|
@ -49,7 +54,8 @@ public class CannonShellWeapon extends VehicleWeapon {
|
|||
this.explosionRadius,
|
||||
this.explosionDamage,
|
||||
this.fireProbability,
|
||||
this.fireTime
|
||||
this.fireTime,
|
||||
this.gravity
|
||||
).durability(this.durability);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -876,11 +876,6 @@ public class ClientEventHandler {
|
|||
&& tag.getBoolean("Linked"))
|
||||
) {
|
||||
handleDroneCamera(event, living, tag);
|
||||
} else {
|
||||
var effect = Minecraft.getInstance().gameRenderer.currentEffect();
|
||||
if (effect != null && effect.getName().equals(Mod.MODID + ":shaders/post/scan_pincushion.json")) {
|
||||
Minecraft.getInstance().gameRenderer.shutdownEffect();
|
||||
}
|
||||
}
|
||||
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
|
@ -931,19 +926,12 @@ public class ClientEventHandler {
|
|||
handleShockCamera(event, living);
|
||||
}
|
||||
|
||||
public static void handleDroneCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity, final CompoundTag tag) {
|
||||
private static void handleDroneCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity, final CompoundTag tag) {
|
||||
DroneEntity drone = EntityFindUtil.findDrone(entity.level(), tag.getString("LinkedDrone"));
|
||||
|
||||
if (drone != null) {
|
||||
event.setRoll(drone.getRoll((float) event.getPartialTick()) * (1 - (drone.getPitch((float) event.getPartialTick()) / 90)));
|
||||
}
|
||||
|
||||
if (drone != null && tag.getBoolean("Using")) {
|
||||
if (Minecraft.getInstance().gameRenderer.currentEffect() == null) {
|
||||
// TODO 无人机 shader
|
||||
// Minecraft.getInstance().gameRenderer.loadEffect(Mod.loc("shaders/post/scan_pincushion.json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
|
|
|
@ -140,9 +140,13 @@ public abstract class CameraMixin {
|
|||
return;
|
||||
}
|
||||
|
||||
if (player.getVehicle() instanceof CannonEntity && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle)) {
|
||||
if (player.getVehicle() instanceof VehicleEntity vehicle && vehicle instanceof CannonEntity cannon && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle)) {
|
||||
setRotation(Mth.lerp(partialTicks, player.yRotO, player.getYRot()), Mth.lerp(partialTicks, player.xRotO, player.getXRot()));
|
||||
setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
|
||||
if (!(cannon instanceof AnnihilatorEntity) && ClientEventHandler.zoomVehicle) {
|
||||
setPosition(vehicle.driverZoomPos(partialTicks).x, vehicle.driverZoomPos(partialTicks).y, vehicle.driverZoomPos(partialTicks).z);
|
||||
} else {
|
||||
setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"targets": [
|
||||
"swap"
|
||||
],
|
||||
"passes": [
|
||||
{
|
||||
"name": "scan_pincushion",
|
||||
"intarget": "minecraft:main",
|
||||
"outtarget": "swap"
|
||||
},
|
||||
{
|
||||
"name": "blit",
|
||||
"intarget": "swap",
|
||||
"outtarget": "minecraft:main"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
#version 150
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
const vec4 Zero = vec4(0.0);
|
||||
const vec4 Half = vec4(0.5);
|
||||
const vec4 One = vec4(1.0);
|
||||
const vec4 Two = vec4(2.0);
|
||||
|
||||
const float Pi = 3.1415926535;
|
||||
const float PincushionAmount = 0.02;
|
||||
const float CurvatureAmount = 0.02;
|
||||
const float ScanlineAmount = 0.8;
|
||||
const float ScanlineScale = 1.0;
|
||||
const float ScanlineHeight = 1.0;
|
||||
const float ScanlineBrightScale = 1.0;
|
||||
const float ScanlineBrightOffset = 0.0;
|
||||
const float ScanlineOffset = 0.0;
|
||||
const vec3 Floor = vec3(0.05, 0.05, 0.05);
|
||||
const vec3 Power = vec3(0.8, 0.8, 0.8);
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 InTexel = texture(DiffuseSampler, texCoord);
|
||||
|
||||
vec2 PinUnitCoord = texCoord * Two.xy - One.xy;
|
||||
float PincushionR2 = pow(length(PinUnitCoord), 2.0);
|
||||
vec2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2;
|
||||
vec2 ScanCoord = texCoord;
|
||||
|
||||
ScanCoord *= One.xy - PincushionAmount * 0.2;
|
||||
ScanCoord += PincushionAmount * 0.1;
|
||||
ScanCoord += PincushionCurve;
|
||||
|
||||
vec2 CurvatureClipCurve = PinUnitCoord * CurvatureAmount * PincushionR2;
|
||||
vec2 ScreenClipCoord = texCoord;
|
||||
ScreenClipCoord -= Half.xy;
|
||||
ScreenClipCoord *= One.xy - CurvatureAmount * 0.2;
|
||||
ScreenClipCoord += Half.xy;
|
||||
ScreenClipCoord += CurvatureClipCurve;
|
||||
|
||||
// -- Alpha Clipping --
|
||||
if (ScanCoord.x < 0.0) discard;
|
||||
if (ScanCoord.y < 0.0) discard;
|
||||
if (ScanCoord.x > 1.0) discard;
|
||||
if (ScanCoord.y > 1.0) discard;
|
||||
|
||||
// -- Scanline Simulation --
|
||||
float InnerSine = ScanCoord.y * InSize.y * ScanlineScale * 0.25;
|
||||
float ScanBrightMod = sin(InnerSine * Pi + ScanlineOffset * InSize.y * 0.25);
|
||||
float ScanBrightness = mix(1.0, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0) * 0.5, ScanlineAmount);
|
||||
vec3 ScanlineTexel = InTexel.rgb * ScanBrightness;
|
||||
|
||||
// -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
|
||||
ScanlineTexel = Floor + (One.xyz - Floor) * ScanlineTexel;
|
||||
|
||||
ScanlineTexel.rgb = pow(ScanlineTexel.rgb, Power);
|
||||
|
||||
fragColor = vec4(ScanlineTexel.rgb, 1.0);
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "scan_pincushion",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }
|
||||
]
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 6 KiB |
Loading…
Add table
Reference in a new issue