尝试添加热诱弹

This commit is contained in:
Atsuihsio 2025-01-07 23:53:34 +08:00
parent ff3041ceed
commit d16aacdd6c
8 changed files with 44 additions and 0 deletions

View file

@ -431,6 +431,8 @@ public class ClickHandler {
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(4, state == 1)); ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(4, state == 1));
} else if (key == options.keyShift.getKey().getValue()) { } else if (key == options.keyShift.getKey().getValue()) {
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(5, state == 1)); ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(5, state == 1));
} else if (key == ModKeyMappings.RELEASE_DECOY.getKey().getValue()) {
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(6, state == 1));
} }
} }
} }

View file

@ -15,6 +15,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
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.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -26,6 +27,7 @@ import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.PlayMessages; import net.minecraftforge.network.PlayMessages;
@ -160,4 +162,14 @@ public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
return this.cache; return this.cache;
} }
public void decoyShoot(Entity entity, Vec3 shootVec, float pVelocity) {
Vec3 vec3 = shootVec.normalize().scale(pVelocity);
this.setDeltaMovement(entity.getDeltaMovement().add(vec3));
double d0 = vec3.horizontalDistance();
this.setYRot((float)(Mth.atan2(vec3.x, vec3.z) * 57.2957763671875));
this.setXRot((float)(Mth.atan2(vec3.y, d0) * 57.2957763671875));
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
}
} }

View file

@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity; import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.init.*;
@ -179,10 +180,30 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
} }
lowHealthWarning(); lowHealthWarning();
releaseDecoy();
this.refreshDimensions(); this.refreshDimensions();
} }
public void releaseDecoy() {
if (decoyInputDown) {
if (!this.level().isClientSide()) {
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
for (int i = 0; i < 6; i++) {
GunGrenadeEntity gunGrenadeEntity = new GunGrenadeEntity((LivingEntity) passenger, this.level(),
5,
5,
5);
gunGrenadeEntity.setPos(this.getX(), this.getY() + 0.3, this.getZ());
gunGrenadeEntity.decoyShoot(this, this.getViewVector(1).yRot(60 * i), 0.4f);
this.level().addFreshEntity(gunGrenadeEntity);
}
}
decoyInputDown = false;
}
}
@Override @Override
public void travel() { public void travel() {
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);

View file

@ -36,6 +36,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
public boolean backInputDown; public boolean backInputDown;
public boolean upInputDown; public boolean upInputDown;
public boolean downInputDown; public boolean downInputDown;
public boolean decoyInputDown;
public double lastTickSpeed; public double lastTickSpeed;
public double lastTickVerticalSpeed; public double lastTickVerticalSpeed;
public int collisionCoolDown; public int collisionCoolDown;

View file

@ -53,6 +53,7 @@ public class ModKeyMappings {
public static final KeyMapping FIRE = new KeyMapping("key.superbwarfare.fire", InputConstants.Type.MOUSE, GLFW.GLFW_MOUSE_BUTTON_LEFT, "key.categories.superbwarfare"); public static final KeyMapping FIRE = new KeyMapping("key.superbwarfare.fire", InputConstants.Type.MOUSE, GLFW.GLFW_MOUSE_BUTTON_LEFT, "key.categories.superbwarfare");
public static final KeyMapping HOLD_ZOOM = new KeyMapping("key.superbwarfare.hold_zoom", InputConstants.Type.MOUSE, GLFW.GLFW_MOUSE_BUTTON_RIGHT, "key.categories.superbwarfare"); public static final KeyMapping HOLD_ZOOM = new KeyMapping("key.superbwarfare.hold_zoom", InputConstants.Type.MOUSE, GLFW.GLFW_MOUSE_BUTTON_RIGHT, "key.categories.superbwarfare");
public static final KeyMapping SWITCH_ZOOM = new KeyMapping("key.superbwarfare.switch_zoom", GLFW.GLFW_KEY_UNKNOWN, "key.categories.superbwarfare"); public static final KeyMapping SWITCH_ZOOM = new KeyMapping("key.superbwarfare.switch_zoom", GLFW.GLFW_KEY_UNKNOWN, "key.categories.superbwarfare");
public static final KeyMapping RELEASE_DECOY = new KeyMapping("key.superbwarfare.release_decoy", GLFW.GLFW_KEY_X, "key.categories.superbwarfare");
@SubscribeEvent @SubscribeEvent
public static void registerKeyMappings(RegisterKeyMappingsEvent event) { public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
@ -73,6 +74,7 @@ public class ModKeyMappings {
event.register(FIRE); event.register(FIRE);
event.register(HOLD_ZOOM); event.register(HOLD_ZOOM);
event.register(SWITCH_ZOOM); event.register(SWITCH_ZOOM);
event.register(RELEASE_DECOY);
} }
@Mod.EventBusSubscriber(value = Dist.CLIENT) @Mod.EventBusSubscriber(value = Dist.CLIENT)

View file

@ -54,6 +54,9 @@ public class VehicleMovementMessage {
case 5: case 5:
mobileVehicleEntity.downInputDown = message.clicked; mobileVehicleEntity.downInputDown = message.clicked;
break; break;
case 6:
mobileVehicleEntity.decoyInputDown = message.clicked;
break;
} }
if (player.getMainHandItem().is(ModItems.MONITOR.get())) { if (player.getMainHandItem().is(ModItems.MONITOR.get())) {
@ -64,6 +67,7 @@ public class VehicleMovementMessage {
mobileVehicleEntity.backInputDown = false; mobileVehicleEntity.backInputDown = false;
mobileVehicleEntity.upInputDown = false; mobileVehicleEntity.upInputDown = false;
mobileVehicleEntity.downInputDown = false; mobileVehicleEntity.downInputDown = false;
mobileVehicleEntity.decoyInputDown = false;
} }
} }
} }

View file

@ -399,6 +399,7 @@
"key.superbwarfare.edit_magazine": "Switch Magazine", "key.superbwarfare.edit_magazine": "Switch Magazine",
"key.superbwarfare.edit_stock": "Switch Stock", "key.superbwarfare.edit_stock": "Switch Stock",
"key.superbwarfare.edit_grip": "Switch Grip", "key.superbwarfare.edit_grip": "Switch Grip",
"key.superbwarfare.release_decoy": "Release Decoy",
"effect.superbwarfare.shock": "Shock", "effect.superbwarfare.shock": "Shock",
"effect.superbwarfare.burn": "Burn", "effect.superbwarfare.burn": "Burn",

View file

@ -398,6 +398,7 @@
"key.superbwarfare.edit_magazine": "切换弹匣", "key.superbwarfare.edit_magazine": "切换弹匣",
"key.superbwarfare.edit_stock": "切换枪托", "key.superbwarfare.edit_stock": "切换枪托",
"key.superbwarfare.edit_grip": "切换握把", "key.superbwarfare.edit_grip": "切换握把",
"key.superbwarfare.release_decoy": "释放诱饵",
"effect.superbwarfare.shock": "电击", "effect.superbwarfare.shock": "电击",
"effect.superbwarfare.burn": "点燃", "effect.superbwarfare.burn": "点燃",