尝试添加热诱弹
This commit is contained in:
parent
ff3041ceed
commit
d16aacdd6c
8 changed files with 44 additions and 0 deletions
|
@ -431,6 +431,8 @@ public class ClickHandler {
|
|||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(4, state == 1));
|
||||
} else if (key == options.keyShift.getKey().getValue()) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
|||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
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.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
|
@ -160,4 +162,14 @@ public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
|||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||
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.ProjectileEntity;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
|
@ -179,10 +180,30 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
}
|
||||
|
||||
lowHealthWarning();
|
||||
releaseDecoy();
|
||||
|
||||
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
|
||||
public void travel() {
|
||||
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||
|
|
|
@ -36,6 +36,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
|||
public boolean backInputDown;
|
||||
public boolean upInputDown;
|
||||
public boolean downInputDown;
|
||||
public boolean decoyInputDown;
|
||||
public double lastTickSpeed;
|
||||
public double lastTickVerticalSpeed;
|
||||
public int collisionCoolDown;
|
||||
|
|
|
@ -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 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 RELEASE_DECOY = new KeyMapping("key.superbwarfare.release_decoy", GLFW.GLFW_KEY_X, "key.categories.superbwarfare");
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
|
||||
|
@ -73,6 +74,7 @@ public class ModKeyMappings {
|
|||
event.register(FIRE);
|
||||
event.register(HOLD_ZOOM);
|
||||
event.register(SWITCH_ZOOM);
|
||||
event.register(RELEASE_DECOY);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
|
|
|
@ -54,6 +54,9 @@ public class VehicleMovementMessage {
|
|||
case 5:
|
||||
mobileVehicleEntity.downInputDown = message.clicked;
|
||||
break;
|
||||
case 6:
|
||||
mobileVehicleEntity.decoyInputDown = message.clicked;
|
||||
break;
|
||||
}
|
||||
|
||||
if (player.getMainHandItem().is(ModItems.MONITOR.get())) {
|
||||
|
@ -64,6 +67,7 @@ public class VehicleMovementMessage {
|
|||
mobileVehicleEntity.backInputDown = false;
|
||||
mobileVehicleEntity.upInputDown = false;
|
||||
mobileVehicleEntity.downInputDown = false;
|
||||
mobileVehicleEntity.decoyInputDown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -399,6 +399,7 @@
|
|||
"key.superbwarfare.edit_magazine": "Switch Magazine",
|
||||
"key.superbwarfare.edit_stock": "Switch Stock",
|
||||
"key.superbwarfare.edit_grip": "Switch Grip",
|
||||
"key.superbwarfare.release_decoy": "Release Decoy",
|
||||
|
||||
"effect.superbwarfare.shock": "Shock",
|
||||
"effect.superbwarfare.burn": "Burn",
|
||||
|
|
|
@ -398,6 +398,7 @@
|
|||
"key.superbwarfare.edit_magazine": "切换弹匣",
|
||||
"key.superbwarfare.edit_stock": "切换枪托",
|
||||
"key.superbwarfare.edit_grip": "切换握把",
|
||||
"key.superbwarfare.release_decoy": "释放诱饵",
|
||||
|
||||
"effect.superbwarfare.shock": "电击",
|
||||
"effect.superbwarfare.burn": "点燃",
|
||||
|
|
Loading…
Add table
Reference in a new issue