允许发射器发射蜂群无人机
This commit is contained in:
parent
c8b10d1255
commit
61ba12084c
6 changed files with 135 additions and 6 deletions
|
@ -59,13 +59,17 @@ public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEnti
|
|||
private float explosionRadius = 5f;
|
||||
|
||||
private float randomFloat;
|
||||
private int guide_type = 0;
|
||||
private int guideType = 0;
|
||||
|
||||
public SwarmDroneEntity(EntityType<? extends SwarmDroneEntity> type, Level level) {
|
||||
super(type, level);
|
||||
this.noCulling = true;
|
||||
}
|
||||
|
||||
public SwarmDroneEntity(double x, double y, double z, Level level) {
|
||||
super(ModEntities.SWARM_DRONE.get(), x, y, z, level);
|
||||
}
|
||||
|
||||
public SwarmDroneEntity(LivingEntity entity, Level level, float explosionDamage, float explosionRadius) {
|
||||
super(ModEntities.SWARM_DRONE.get(), entity, level);
|
||||
this.explosionDamage = explosionDamage;
|
||||
|
@ -87,7 +91,7 @@ public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEnti
|
|||
}
|
||||
|
||||
public void setGuideType(int guideType) {
|
||||
this.guide_type = guideType;
|
||||
this.guideType = guideType;
|
||||
}
|
||||
|
||||
public void setTargetVec(Vec3 targetPos) {
|
||||
|
@ -223,7 +227,7 @@ public class SwarmDroneEntity extends FastThrowableProjectile implements GeoEnti
|
|||
Entity shooter = this.getOwner();
|
||||
Vec3 targetPos;
|
||||
|
||||
if (guide_type == 0 && entity != null) {
|
||||
if (guideType == 0 && entity != null) {
|
||||
targetPos = entity.getEyePosition();
|
||||
this.entityData.set(TARGET_X, (float) targetPos.x);
|
||||
this.entityData.set(TARGET_Y, (float) targetPos.y);
|
||||
|
|
|
@ -648,12 +648,10 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
|
||||
var swarmDroneEntity = ((SwarmDroneWeapon) getWeapon(2)).create(player);
|
||||
|
||||
|
||||
Vector4f shootPosition1 = transformPosition(transformT, 0, 0, 0);
|
||||
Vector4f shootPosition2 = transformPosition(transformT, 0, 1, 0);
|
||||
Vec3 direct = new Vec3(shootPosition1.x, shootPosition1.y, shootPosition1.z).vectorTo(new Vec3(shootPosition2.x, shootPosition2.y, shootPosition2.z));
|
||||
|
||||
|
||||
swarmDroneEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
swarmDroneEntity.shoot(direct.x, direct.y, direct.z, 1.2f, 10);
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class ModItems {
|
|||
public static final DeferredHolder<Item, Item> ROCKET_70 = AMMO.register("rocket_70", Rocket70::new);
|
||||
public static final DeferredHolder<Item, WireGuideMissile> WIRE_GUIDE_MISSILE = AMMO.register("wire_guide_missile", WireGuideMissile::new);
|
||||
public static final DeferredHolder<Item, Agm> AGM = AMMO.register("agm", Agm::new);
|
||||
public static final DeferredHolder<Item, Item> SWARM_DRONE = AMMO.register("swarm_drone", () -> new Item(new Item.Properties()));
|
||||
public static final DeferredHolder<Item, SwarmDrone> SWARM_DRONE = AMMO.register("swarm_drone", SwarmDrone::new);
|
||||
public static final DeferredHolder<Item, MediumAerialBomb> MEDIUM_AERIAL_BOMB = AMMO.register("medium_aerial_bomb", MediumAerialBomb::new);
|
||||
public static final DeferredHolder<Item, BeamTest> BEAM_TEST = AMMO.register("beam_test", BeamTest::new);
|
||||
|
||||
|
|
125
src/main/java/com/atsuishio/superbwarfare/item/SwarmDrone.java
Normal file
125
src/main/java/com/atsuishio/superbwarfare/item/SwarmDrone.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package com.atsuishio.superbwarfare.item;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Position;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ProjectileItem;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
|
||||
public class SwarmDrone extends Item implements ProjectileItem {
|
||||
|
||||
public SwarmDrone() {
|
||||
super(new Properties());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public AbstractProjectileDispenseBehavior getLaunchBehavior() {
|
||||
// return new AbstractProjectileDispenseBehavior() {
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack execute(BlockSource blockSource, ItemStack pStack) {
|
||||
// Level level = blockSource.getLevel();
|
||||
// Position position = DispenserBlock.getDispensePosition(blockSource);
|
||||
// Direction direction = blockSource.getBlockState().getValue(DispenserBlock.FACING);
|
||||
// Projectile projectile = this.getProjectile(level, position, pStack);
|
||||
//
|
||||
// float yVec = direction.getStepY();
|
||||
// if (direction != Direction.DOWN) {
|
||||
// yVec += 1F;
|
||||
// }
|
||||
//
|
||||
// projectile.shoot(direction.getStepX(), yVec, direction.getStepZ(), this.getPower(), this.getUncertainty());
|
||||
//
|
||||
// BlockHitResult result = level.clip(new ClipContext(new Vec3(position.x(), position.y(), position.z()),
|
||||
// new Vec3(position.x(), position.y(), position.z()).add(new Vec3(direction.step().mul(128))),
|
||||
// ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, projectile));
|
||||
// Vec3 hitPos = result.getLocation();
|
||||
// ((SwarmDroneEntity) projectile).setGuideType(1);
|
||||
// ((SwarmDroneEntity) projectile).setTargetVec(hitPos);
|
||||
//
|
||||
// level.addFreshEntity(projectile);
|
||||
// pStack.shrink(1);
|
||||
// return pStack;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @ParametersAreNonnullByDefault
|
||||
// protected @NotNull Projectile getProjectile(Level pLevel, Position pos, ItemStack pStack) {
|
||||
// return new SwarmDroneEntity(pos.x(), pos.y(), pos.z(), pLevel);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void playSound(BlockSource blockSource) {
|
||||
// blockSource.getLevel().playSound(null, blockSource.getPos(), ModSounds.DECOY_FIRE.get(), SoundSource.BLOCKS, 2.0F, 1.0F);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
// public class SwarmDroneDispenseBehavior extends ProjectileDispenseBehavior {
|
||||
//
|
||||
// public SwarmDroneDispenseBehavior(Item projectile) {
|
||||
// super(projectile);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @ParametersAreNonnullByDefault
|
||||
// public @NotNull ItemStack execute(BlockSource blockSource, ItemStack stack) {
|
||||
// Level level = blockSource.level();
|
||||
// Position position = DispenserBlock.getDispensePosition(blockSource);
|
||||
// Direction direction = blockSource.state().getValue(DispenserBlock.FACING);
|
||||
// Projectile projectile = this.getProjectile(level, position, stack);
|
||||
//
|
||||
// float yVec = direction.getStepY();
|
||||
// if (direction != Direction.DOWN) {
|
||||
// yVec += 1F;
|
||||
// }
|
||||
//
|
||||
// projectile.shoot(direction.getStepX(), yVec, direction.getStepZ(), this.getPower(), this.getUncertainty());
|
||||
//
|
||||
// BlockHitResult result = level.clip(new ClipContext(new Vec3(position.x(), position.y(), position.z()),
|
||||
// new Vec3(position.x(), position.y(), position.z()).add(new Vec3(direction.step().mul(128))),
|
||||
// ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, projectile));
|
||||
// Vec3 hitPos = result.getLocation();
|
||||
// ((SwarmDroneEntity) projectile).setGuideType(1);
|
||||
// ((SwarmDroneEntity) projectile).setTargetVec(hitPos);
|
||||
//
|
||||
// level.addFreshEntity(projectile);
|
||||
// pStack.shrink(1);
|
||||
// return pStack;
|
||||
// return super.execute(blockSource, stack);
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO 怎么发射?
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
tooltipComponents.add(Component.translatable("des.superbwarfare.swarm_drone").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull DispenseConfig createDispenseConfig() {
|
||||
return ProjectileItem.DispenseConfig.builder()
|
||||
.uncertainty(1)
|
||||
.power(0.5f)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public @NotNull Projectile asProjectile(Level level, Position pos, ItemStack stack, Direction direction) {
|
||||
return new SwarmDroneEntity(pos.x(), pos.y(), pos.z(), level);
|
||||
}
|
||||
}
|
|
@ -169,6 +169,7 @@
|
|||
"item.superbwarfare.wire_guide_missile": "Wire Guide Missile",
|
||||
"des.superbwarfare.wire_guide_missile": "Suitable for BMP-2",
|
||||
"item.superbwarfare.swarm_drone": "Swarm Drone",
|
||||
"des.superbwarfare.swarm_drone": "Suitable for YX-100 MBT",
|
||||
"item.superbwarfare.medium_aerial_bomb": "Medium Aerial Bomb",
|
||||
"des.superbwarfare.medium_aerial_bomb": "Suitable for A-10 Thunderbolt II",
|
||||
"item.superbwarfare.agm": "Air-to-ground Missile",
|
||||
|
|
|
@ -169,6 +169,7 @@
|
|||
"item.superbwarfare.wire_guide_missile": "线控导弹",
|
||||
"des.superbwarfare.wire_guide_missile": "适配BMP-2步兵战车",
|
||||
"item.superbwarfare.swarm_drone": "蜂群无人机",
|
||||
"des.superbwarfare.swarm_drone": "适配YX-100主战坦克",
|
||||
"item.superbwarfare.medium_aerial_bomb": "中型航空炸弹",
|
||||
"des.superbwarfare.medium_aerial_bomb": "适配A-10攻击机",
|
||||
"item.superbwarfare.agm": "空对地导弹",
|
||||
|
|
Loading…
Add table
Reference in a new issue