正确发射中型火箭
This commit is contained in:
parent
b21a595095
commit
67a7acb39d
2 changed files with 14 additions and 37 deletions
|
@ -5,7 +5,10 @@ import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.MediumRocketEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.MediumRocketEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSerializers;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.atsuishio.superbwarfare.item.common.ammo.MediumRocketItem;
|
import com.atsuishio.superbwarfare.item.common.ammo.MediumRocketItem;
|
||||||
import com.atsuishio.superbwarfare.item.common.container.ContainerBlockItem;
|
import com.atsuishio.superbwarfare.item.common.container.ContainerBlockItem;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
|
@ -186,8 +189,8 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
// 撬棍发射
|
// 撬棍发射
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
if (items.get(i).getItem() instanceof MediumRocketItem) {
|
if (items.get(i).getItem() instanceof MediumRocketItem) {
|
||||||
items.set(i, ItemStack.EMPTY);
|
|
||||||
shoot(player, i);
|
shoot(player, i);
|
||||||
|
items.set(i, ItemStack.EMPTY);
|
||||||
setChanged();
|
setChanged();
|
||||||
player.swing(InteractionHand.MAIN_HAND);
|
player.swing(InteractionHand.MAIN_HAND);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
@ -212,45 +215,15 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
if (level() instanceof ServerLevel server) {
|
if (level() instanceof ServerLevel server) {
|
||||||
ItemStack stack = items.get(i);
|
ItemStack stack = items.get(i);
|
||||||
|
|
||||||
float damage;
|
if (!(stack.getItem() instanceof MediumRocketItem rocketItem)) {
|
||||||
float radius;
|
return;
|
||||||
float explosionDamage;
|
|
||||||
float fireProbability;
|
|
||||||
int fireTime;
|
|
||||||
MediumRocketEntity.Type type;
|
|
||||||
int sparedAmount;
|
|
||||||
|
|
||||||
if (stack.is(ModItems.MEDIUM_ROCKET_AP.get())) {
|
|
||||||
damage = 500;
|
|
||||||
radius = 6;
|
|
||||||
explosionDamage = 100;
|
|
||||||
fireProbability = 0;
|
|
||||||
fireTime = 0;
|
|
||||||
type = MediumRocketEntity.Type.AP;
|
|
||||||
sparedAmount = 0;
|
|
||||||
} else if (stack.is(ModItems.MEDIUM_ROCKET_HE.get())) {
|
|
||||||
damage = 200;
|
|
||||||
radius = 12;
|
|
||||||
explosionDamage = 200;
|
|
||||||
fireProbability = 0.2f;
|
|
||||||
fireTime = 40;
|
|
||||||
type = MediumRocketEntity.Type.HE;
|
|
||||||
sparedAmount = 0;
|
|
||||||
} else {
|
|
||||||
damage = 300;
|
|
||||||
radius = 12;
|
|
||||||
explosionDamage = 300;
|
|
||||||
fireProbability = 0;
|
|
||||||
fireTime = 0;
|
|
||||||
type = MediumRocketEntity.Type.CM;
|
|
||||||
sparedAmount = 20;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OBB obb = this.barrel[i];
|
OBB obb = this.barrel[i];
|
||||||
Vec3 shootPos = new Vec3(obb.center());
|
Vec3 shootPos = new Vec3(obb.center());
|
||||||
|
|
||||||
MediumRocketEntity entityToSpawn = new MediumRocketEntity(player, server, damage, radius, explosionDamage, fireProbability, fireTime, type, sparedAmount);
|
MediumRocketEntity entityToSpawn = rocketItem.createProjectile(server, shootPos);
|
||||||
entityToSpawn.setPos(shootPos.x, shootPos.y, shootPos.z);
|
entityToSpawn.setOwner(player);
|
||||||
entityToSpawn.shoot(getShootVector(1).x, getShootVector(1).y, getShootVector(1).z, 10, (float) 0.25);
|
entityToSpawn.shoot(getShootVector(1).x, getShootVector(1).y, getShootVector(1).z, 10, (float) 0.25);
|
||||||
server.addFreshEntity(entityToSpawn);
|
server.addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@ public class MediumRocketItem extends Item implements ProjectileItem {
|
||||||
this.sparedAmount = sparedAmount;
|
this.sparedAmount = sparedAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MediumRocketEntity createProjectile(Level level, Position pos) {
|
||||||
|
return new MediumRocketEntity(ModEntities.MEDIUM_ROCKET.get(), pos.x(), pos.y(), pos.z(), level, damage, radius, explosionDamage, fireProbability, fireTime, type, sparedAmount);
|
||||||
|
}
|
||||||
|
|
||||||
public static class MediumRocketDispenseBehavior extends ProjectileDispenseBehavior {
|
public static class MediumRocketDispenseBehavior extends ProjectileDispenseBehavior {
|
||||||
public MediumRocketDispenseBehavior(Item item) {
|
public MediumRocketDispenseBehavior(Item item) {
|
||||||
super(item);
|
super(item);
|
||||||
|
@ -53,7 +57,7 @@ public class MediumRocketItem extends Item implements ProjectileItem {
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public @NotNull Projectile asProjectile(Level level, Position pos, ItemStack stack, Direction direction) {
|
public @NotNull Projectile asProjectile(Level level, Position pos, ItemStack stack, Direction direction) {
|
||||||
return new MediumRocketEntity(ModEntities.MEDIUM_ROCKET.get(), pos.x(), pos.y(), pos.z(), level, damage, radius, explosionDamage, fireProbability, fireTime, type, sparedAmount);
|
return createProjectile(level, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue