添加更多的爆炸物配置
This commit is contained in:
parent
476d7f6ff0
commit
248f57de6c
9 changed files with 174 additions and 32 deletions
|
@ -6,13 +6,72 @@ public class ExplosionConfig {
|
||||||
|
|
||||||
public static ForgeConfigSpec.IntValue EXPLOSION_PENETRATION_RATIO;
|
public static ForgeConfigSpec.IntValue EXPLOSION_PENETRATION_RATIO;
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.IntValue RGO_GRENADE_EXPLOSION_DAMAGE;
|
||||||
|
public static ForgeConfigSpec.IntValue RGO_GRENADE_EXPLOSION_RADIUS;
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.IntValue M67_GRENADE_EXPLOSION_DAMAGE;
|
||||||
|
public static ForgeConfigSpec.IntValue M67_GRENADE_EXPLOSION_RADIUS;
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.IntValue MORTAR_SHELL_EXPLOSION_DAMAGE;
|
||||||
|
public static ForgeConfigSpec.IntValue MORTAR_SHELL_EXPLOSION_RADIUS;
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_HIT_DAMAGE;
|
||||||
|
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_EXPLOSION_DAMAGE;
|
||||||
|
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_EXPLOSION_RADIUS;
|
||||||
|
|
||||||
public static void init(ForgeConfigSpec.Builder builder) {
|
public static void init(ForgeConfigSpec.Builder builder) {
|
||||||
builder.push("explosion_penetration");
|
builder.push("explosion");
|
||||||
|
|
||||||
builder.comment("The percentage of explosion damage you take behind cover");
|
builder.comment("The percentage of explosion damage you take behind cover");
|
||||||
EXPLOSION_PENETRATION_RATIO = builder.defineInRange("explosion_destroy", 15, 0, 100);
|
EXPLOSION_PENETRATION_RATIO = builder.defineInRange("explosion_destroy", 15, 0, 100);
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
|
|
||||||
|
builder.push("RGO Grenade");
|
||||||
|
|
||||||
|
builder.comment("The explosion damage of RGO grenade");
|
||||||
|
RGO_GRENADE_EXPLOSION_DAMAGE = builder.defineInRange("Rgo grenade explosion damage", 90, 1, 10000000);
|
||||||
|
|
||||||
|
builder.comment("The explosion radius of RGO grenade");
|
||||||
|
RGO_GRENADE_EXPLOSION_RADIUS = builder.defineInRange("Rgo grenade explosion radius", 5, 1, 50);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
|
|
||||||
|
builder.push("M67 Grenade");
|
||||||
|
|
||||||
|
builder.comment("The explosion damage of M67 grenade");
|
||||||
|
M67_GRENADE_EXPLOSION_DAMAGE = builder.defineInRange("Rgo grenade explosion damage", 120, 1, 10000000);
|
||||||
|
|
||||||
|
builder.comment("The explosion radius of M67 grenade");
|
||||||
|
M67_GRENADE_EXPLOSION_RADIUS = builder.defineInRange("Rgo grenade explosion radius", 6, 1, 50);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
|
|
||||||
|
builder.push("Mortar shell");
|
||||||
|
|
||||||
|
builder.comment("The explosion damage of Mortar shell");
|
||||||
|
MORTAR_SHELL_EXPLOSION_DAMAGE = builder.defineInRange("Rgo grenade explosion damage", 160, 1, 10000000);
|
||||||
|
|
||||||
|
builder.comment("The explosion radius of Mortar shell");
|
||||||
|
MORTAR_SHELL_EXPLOSION_RADIUS = builder.defineInRange("Rgo grenade explosion radius", 9, 1, 50);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
|
builder.push("Drone Kamikaze");
|
||||||
|
|
||||||
|
builder.comment("The hit damage of Drone Kamikaze");
|
||||||
|
DRONE_KAMIKAZE_HIT_DAMAGE = builder.defineInRange("Rgo grenade explosion damage", 300, 1, 10000000);
|
||||||
|
|
||||||
|
builder.comment("The explosion damage of Drone Kamikaze");
|
||||||
|
DRONE_KAMIKAZE_EXPLOSION_DAMAGE = builder.defineInRange("Rgo grenade explosion damage", 160, 1, 10000000);
|
||||||
|
|
||||||
|
builder.comment("The explosion radius of Drone Kamikaze");
|
||||||
|
DRONE_KAMIKAZE_EXPLOSION_RADIUS = builder.defineInRange("Rgo grenade explosion radius", 9, 1, 50);
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class ExplosionDestroyConfig {
|
||||||
public static ForgeConfigSpec.BooleanValue EXPLOSION_DESTROY;
|
public static ForgeConfigSpec.BooleanValue EXPLOSION_DESTROY;
|
||||||
|
|
||||||
public static void init(ForgeConfigSpec.Builder builder) {
|
public static void init(ForgeConfigSpec.Builder builder) {
|
||||||
builder.push("explosion");
|
builder.push("explosion_destroy");
|
||||||
|
|
||||||
builder.comment("Set TRUE to allow Explosion to destroy blocks");
|
builder.comment("Set TRUE to allow Explosion to destroy blocks");
|
||||||
EXPLOSION_DESTROY = builder.define("explosion_destroy", false);
|
EXPLOSION_DESTROY = builder.define("explosion_destroy", false);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -40,6 +41,7 @@ import java.util.UUID;
|
||||||
public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, OwnableEntity {
|
public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity, OwnableEntity {
|
||||||
|
|
||||||
protected static final EntityDataAccessor<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.OPTIONAL_UUID);
|
protected static final EntityDataAccessor<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.OPTIONAL_UUID);
|
||||||
|
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.STRING);
|
||||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.FLOAT);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData() {
|
protected void defineSynchedData() {
|
||||||
this.entityData.define(OWNER_UUID, Optional.empty());
|
this.entityData.define(OWNER_UUID, Optional.empty());
|
||||||
|
this.entityData.define(LAST_ATTACKER_UUID, "undefined");
|
||||||
this.entityData.define(HEALTH, 10f);
|
this.entityData.define(HEALTH, 10f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +86,10 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
|
||||||
amount *= 0.2f;
|
amount *= 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (source.getEntity() != null) {
|
||||||
|
this.entityData.set(LAST_ATTACKER_UUID, source.getEntity().getStringUUID());
|
||||||
|
}
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel serverLevel) {
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.2, this.getZ(), 2, 0.02, 0.02, 0.02, 0.1, false);
|
ParticleTool.sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.2, this.getZ(), 2, 0.02, 0.02, 0.02, 0.1, false);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +115,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
compound.putFloat("Health", this.entityData.get(HEALTH));
|
compound.putFloat("Health", this.entityData.get(HEALTH));
|
||||||
|
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
|
||||||
if (this.getOwnerUUID() != null) {
|
if (this.getOwnerUUID() != null) {
|
||||||
compound.putUUID("Owner", this.getOwnerUUID());
|
compound.putUUID("Owner", this.getOwnerUUID());
|
||||||
}
|
}
|
||||||
|
@ -120,6 +127,10 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
|
||||||
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compound.contains("LastAttacker")) {
|
||||||
|
this.entityData.set(LAST_ATTACKER_UUID, compound.getString("LastAttacker"));
|
||||||
|
}
|
||||||
|
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
if (compound.hasUUID("Owner")) {
|
if (compound.hasUUID("Owner")) {
|
||||||
uuid = compound.getUUID("Owner");
|
uuid = compound.getUUID("Owner");
|
||||||
|
@ -217,8 +228,9 @@ public class ClaymoreEntity extends Entity implements GeoEntity, AnimatedEntity,
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), null,
|
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
|
||||||
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), null, null), 25.0f,
|
CustomExplosion explosion = new CustomExplosion(this.level(), attacker,
|
||||||
|
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker, attacker), 25.0f,
|
||||||
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.entity;
|
package com.atsuishio.superbwarfare.entity;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.RgoGrenadeEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.RgoGrenadeEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
|
@ -10,7 +11,6 @@ import com.atsuishio.superbwarfare.item.Monitor;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
|
@ -48,6 +48,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
import net.minecraftforge.network.PlayMessages;
|
import net.minecraftforge.network.PlayMessages;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import org.joml.Vector3f;
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||||
|
@ -173,6 +174,55 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
this.entityData.set(ROT_Z, compound.getFloat("rotZ"));
|
this.entityData.set(ROT_Z, compound.getFloat("rotZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Vector3f getForwardDirection() {
|
||||||
|
return new Vector3f(
|
||||||
|
Mth.sin(-getYRot() * ((float) Math.PI / 180)),
|
||||||
|
0.0f,
|
||||||
|
Mth.cos(getYRot() * ((float) Math.PI / 180))
|
||||||
|
).normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Vector3f getRightDirection() {
|
||||||
|
return new Vector3f(
|
||||||
|
Mth.cos(-getYRot() * ((float) Math.PI / 180)),
|
||||||
|
0.0f,
|
||||||
|
Mth.sin(getYRot() * ((float) Math.PI / 180))
|
||||||
|
).normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (this.level().isClientSide) {
|
||||||
|
//
|
||||||
|
// if (!this.onGround()) {
|
||||||
|
// // left and right
|
||||||
|
// float moveX = 0;
|
||||||
|
// if (Minecraft.getInstance().options.keyLeft.isDown()) {
|
||||||
|
// moveX = -1;
|
||||||
|
// } else if (Minecraft.getInstance().options.keyRight.isDown()) {
|
||||||
|
// moveX = 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Vector3f direction = getRightDirection().mul(moveX);
|
||||||
|
// setDeltaMovement(getDeltaMovement().add(direction.x, direction.y, direction.z));
|
||||||
|
//
|
||||||
|
// // forward and backward
|
||||||
|
//// direction = getForwardDirection().mul(thrust * pressingInterpolatedZ.getSmooth());
|
||||||
|
//// setDeltaMovement(getDeltaMovement().add(direction.x, direction.y, direction.z));
|
||||||
|
// } else {
|
||||||
|
// // up and down
|
||||||
|
//
|
||||||
|
// float moveY = 0;
|
||||||
|
// if (Minecraft.getInstance().options.keyJump.isDown()) {
|
||||||
|
// moveY = -1;
|
||||||
|
// } else if (Minecraft.getInstance().options.keyShift.isDown()) {
|
||||||
|
// moveY = 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// setDeltaMovement(getDeltaMovement().add(0.0f, moveY, 0.0f));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
@ -242,11 +292,13 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER));
|
Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER));
|
||||||
|
|
||||||
if (!this.onGround()) {
|
if (!this.onGround()) {
|
||||||
this.level().playSound(null, this.getOnPos(), ModSounds.DRONE_SOUND.get(), SoundSource.AMBIENT, 3, 1);
|
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
ItemStack stack = controller.getMainHandItem();
|
ItemStack stack = controller.getMainHandItem();
|
||||||
if (stack.getOrCreateTag().getBoolean("Using") && controller instanceof ServerPlayer serverPlayer) {
|
if (stack.getOrCreateTag().getBoolean("Using") && controller.level().isClientSide) {
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.DRONE_SOUND.get(), 4, 1);
|
controller.playSound(ModSounds.DRONE_SOUND.get(), 32, 1);
|
||||||
|
}
|
||||||
|
if (!controller.level().isClientSide) {
|
||||||
|
this.level().playSound(null, this.getOnPos(), ModSounds.DRONE_SOUND.get(), SoundSource.AMBIENT, 3, 1);
|
||||||
}
|
}
|
||||||
controller.setYRot(controller.getYRot() - 5 * this.entityData.get(ROT_X) * Mth.abs(this.entityData.get(MOVE_Z)));
|
controller.setYRot(controller.getYRot() - 5 * this.entityData.get(ROT_X) * Mth.abs(this.entityData.get(MOVE_Z)));
|
||||||
}
|
}
|
||||||
|
@ -419,7 +471,7 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
public void hitEntityCrash(Player controller, Entity target) {
|
public void hitEntityCrash(Player controller, Entity target) {
|
||||||
if (lastTickSpeed > 0.2) {
|
if (lastTickSpeed > 0.2) {
|
||||||
if (this.entityData.get(KAMIKAZE) && 6 * lastTickSpeed > this.getHealth()) {
|
if (this.entityData.get(KAMIKAZE) && 6 * lastTickSpeed > this.getHealth()) {
|
||||||
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), 600);
|
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), ExplosionConfig.DRONE_KAMIKAZE_HIT_DAMAGE.get());
|
||||||
}
|
}
|
||||||
target.hurt(ModDamageTypes.causeDroneHitDamage(this.level().registryAccess(), this, controller), (float) (5 * lastTickSpeed));
|
target.hurt(ModDamageTypes.causeDroneHitDamage(this.level().registryAccess(), this, controller), (float) (5 * lastTickSpeed));
|
||||||
if (target instanceof Mob mobEntity) {
|
if (target instanceof Mob mobEntity) {
|
||||||
|
@ -486,8 +538,8 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
|
||||||
|
|
||||||
private void kamikazeExplosion(Entity source) {
|
private void kamikazeExplosion(Entity source) {
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), source, source), 125,
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), source, source), ExplosionConfig.DRONE_KAMIKAZE_EXPLOSION_DAMAGE.get(),
|
||||||
this.getX(), this.getY(), this.getZ(), 7.5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
this.getX(), this.getY(), this.getZ(), ExplosionConfig.DRONE_KAMIKAZE_EXPLOSION_RADIUS.get(), ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.atsuishio.superbwarfare.entity;
|
package com.atsuishio.superbwarfare.entity;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.client.gui.RangeHelper;
|
import com.atsuishio.superbwarfare.client.gui.RangeHelper;
|
||||||
|
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -45,8 +45,6 @@ import software.bernie.geckolib.core.animation.RawAnimation;
|
||||||
import software.bernie.geckolib.core.object.PlayState;
|
import software.bernie.geckolib.core.object.PlayState;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
|
||||||
|
|
||||||
public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
||||||
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(MortarEntity.class, EntityDataSerializers.FLOAT);
|
||||||
|
@ -164,7 +162,7 @@ public class MortarEntity extends Entity implements GeoEntity, AnimatedEntity {
|
||||||
if (level instanceof ServerLevel server) {
|
if (level instanceof ServerLevel server) {
|
||||||
MortarShellEntity entityToSpawn = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), player, level);
|
MortarShellEntity entityToSpawn = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), player, level);
|
||||||
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
|
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
|
||||||
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.9);
|
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 8, (float) 0.3);
|
||||||
level.addFreshEntity(entityToSpawn);
|
level.addFreshEntity(entityToSpawn);
|
||||||
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
|
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (this.getX() + 3 * this.getLookAngle().x), (this.getY() + 0.1 + 3 * this.getLookAngle().y), (this.getZ() + 3 * this.getLookAngle().z), 8, 0.4, 0.4, 0.4,
|
||||||
0.007);
|
0.007);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||||
|
@ -61,8 +60,8 @@ public class DroneModel extends GeoModel<DroneEntity> {
|
||||||
|
|
||||||
float times = (float) (0.5f * Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8));
|
float times = (float) (0.5f * Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8));
|
||||||
|
|
||||||
rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X));
|
// rotX = Mth.lerp(0.5f * times, rotX, animatable.getEntityData().get(ROT_X));
|
||||||
rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z));
|
// rotZ = Mth.lerp(0.5f * times, rotZ, animatable.getEntityData().get(ROT_Z));
|
||||||
|
|
||||||
main.setRotZ(rotX);
|
main.setRotZ(rotX);
|
||||||
main.setRotX(rotZ);
|
main.setRotX(rotZ);
|
||||||
|
@ -76,7 +75,7 @@ public class DroneModel extends GeoModel<DroneEntity> {
|
||||||
CoreGeoBone wingBL = getAnimationProcessor().getBone("wingBL");
|
CoreGeoBone wingBL = getAnimationProcessor().getBone("wingBL");
|
||||||
CoreGeoBone wingBR = getAnimationProcessor().getBone("wingBR");
|
CoreGeoBone wingBR = getAnimationProcessor().getBone("wingBR");
|
||||||
|
|
||||||
rotation = (float) Mth.lerp(times, rotation, animatable.onGround() ? 0 : 0.08 - 0.1 * animatable.getEntityData().get(MOVE_Y));
|
// rotation = (float) Mth.lerp(times, rotation, animatable.onGround() ? 0 : 0.08 - 0.1 * animatable.getEntityData().get(MOVE_Y));
|
||||||
|
|
||||||
wingFL.setRotY(wingFL.getRotY() - rotation);
|
wingFL.setRotY(wingFL.getRotY() - rotation);
|
||||||
wingFR.setRotY(wingFL.getRotY() - rotation);
|
wingFR.setRotY(wingFL.getRotY() - rotation);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.entity.projectile;
|
package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
@ -128,7 +129,7 @@ public class HandGrenadeEntity extends ThrowableItemProjectile {
|
||||||
if (this.fuse <= 0) {
|
if (this.fuse <= 0) {
|
||||||
this.discard();
|
this.discard();
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
ProjectileTool.causeCustomExplode(this, 125f, 5f, 1.2f);
|
ProjectileTool.causeCustomExplode(this, ExplosionConfig.M67_GRENADE_EXPLOSION_DAMAGE.get(), ExplosionConfig.M67_GRENADE_EXPLOSION_RADIUS.get(), 1.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package com.atsuishio.superbwarfare.entity.projectile;
|
package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.ProjectileTool;
|
import com.atsuishio.superbwarfare.tools.ProjectileTool;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -26,9 +27,9 @@ import net.minecraftforge.network.PlayMessages;
|
||||||
|
|
||||||
public class MortarShellEntity extends ThrowableItemProjectile {
|
public class MortarShellEntity extends ThrowableItemProjectile {
|
||||||
|
|
||||||
private float damage = 175f;
|
private float damage = ExplosionConfig.MORTAR_SHELL_EXPLOSION_DAMAGE.get();
|
||||||
private int life = 600;
|
private int life = 600;
|
||||||
private float radius = 8f;
|
private float radius = ExplosionConfig.MORTAR_SHELL_EXPLOSION_RADIUS.get();
|
||||||
|
|
||||||
public MortarShellEntity(EntityType<? extends MortarShellEntity> type, Level world) {
|
public MortarShellEntity(EntityType<? extends MortarShellEntity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
@ -61,7 +62,7 @@ public class MortarShellEntity extends ThrowableItemProjectile {
|
||||||
if (pCompound.contains("Damage")) {
|
if (pCompound.contains("Damage")) {
|
||||||
this.damage = pCompound.getFloat("Damage");
|
this.damage = pCompound.getFloat("Damage");
|
||||||
} else {
|
} else {
|
||||||
this.damage = 250f;
|
this.damage = ExplosionConfig.MORTAR_SHELL_EXPLOSION_DAMAGE.get();;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCompound.contains("Life")) {
|
if (pCompound.contains("Life")) {
|
||||||
|
@ -73,7 +74,7 @@ public class MortarShellEntity extends ThrowableItemProjectile {
|
||||||
if (pCompound.contains("Radius")) {
|
if (pCompound.contains("Radius")) {
|
||||||
this.radius = pCompound.getFloat("Radius");
|
this.radius = pCompound.getFloat("Radius");
|
||||||
} else {
|
} else {
|
||||||
this.radius = 12.5f;
|
this.radius = ExplosionConfig.MORTAR_SHELL_EXPLOSION_RADIUS.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package com.atsuishio.superbwarfare.entity.projectile;
|
package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
|
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||||
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.ProjectileTool;
|
import com.atsuishio.superbwarfare.tools.ProjectileTool;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -16,11 +20,13 @@ 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.util.Mth;
|
||||||
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
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;
|
||||||
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.BellBlock;
|
import net.minecraft.world.level.block.BellBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -36,6 +42,8 @@ import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache
|
||||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity {
|
public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEntity {
|
||||||
private int fuse = 80;
|
private int fuse = 80;
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
@ -78,7 +86,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
if (state.getBlock() instanceof BellBlock bell) {
|
if (state.getBlock() instanceof BellBlock bell) {
|
||||||
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
bell.attemptToRing(this.level(), resultPos, blockResult.getDirection());
|
||||||
}
|
}
|
||||||
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
ProjectileTool.causeCustomExplode(this, ExplosionConfig.RGO_GRENADE_EXPLOSION_DAMAGE.get(), ExplosionConfig.RGO_GRENADE_EXPLOSION_RADIUS.get(), 1.2f);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
|
@ -92,7 +100,9 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(entity instanceof DroneEntity)) {
|
if (!(entity instanceof DroneEntity)) {
|
||||||
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
causeRgoExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
entity, ExplosionConfig.RGO_GRENADE_EXPLOSION_DAMAGE.get(), ExplosionConfig.RGO_GRENADE_EXPLOSION_RADIUS.get(), 1.2f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -100,6 +110,16 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void causeRgoExplode(ThrowableItemProjectile projectile, @Nullable DamageSource source, Entity entity, float damage, float radius, float damageMultiplier) {
|
||||||
|
CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, source, damage,
|
||||||
|
entity.getX(), entity.getY(), entity.getZ(), radius, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(damageMultiplier);
|
||||||
|
explosion.explode();
|
||||||
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
||||||
|
explosion.finalizeExplosion(false);
|
||||||
|
ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position());
|
||||||
|
projectile.discard();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
@ -108,7 +128,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
if (this.fuse <= 0) {
|
if (this.fuse <= 0) {
|
||||||
this.discard();
|
this.discard();
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
ProjectileTool.causeCustomExplode(this, 100f, 4f, 1.2f);
|
ProjectileTool.causeCustomExplode(this, ExplosionConfig.RGO_GRENADE_EXPLOSION_DAMAGE.get(), ExplosionConfig.RGO_GRENADE_EXPLOSION_RADIUS.get(), 1.2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue