添加伤害类型
This commit is contained in:
parent
e361717a00
commit
3291e087ee
10 changed files with 60 additions and 28 deletions
|
@ -6,7 +6,6 @@ import net.mcreator.superbwarfare.init.ModEntities;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
import net.mcreator.superbwarfare.tools.CustomExplosion;
|
import net.mcreator.superbwarfare.tools.CustomExplosion;
|
||||||
import net.mcreator.superbwarfare.tools.ParticleTool;
|
import net.mcreator.superbwarfare.tools.ParticleTool;
|
||||||
import net.mcreator.superbwarfare.tools.ProjectileTool;
|
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
|
@ -116,7 +115,14 @@ public class ClaymoreEntity extends LivingEntity implements GeoEntity, AnimatedE
|
||||||
super.die(source);
|
super.die(source);
|
||||||
|
|
||||||
if (level() instanceof ServerLevel) {
|
if (level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.getOwner(), 15.0f, 7.5f, 1);
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
|
ModDamageTypes.causeMineDamage(this.level().registryAccess(), this.getOwner()), 15.0f,
|
||||||
|
this.getX(), this.getY(), this.getZ(), 7.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||||
|
explosion.explode();
|
||||||
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||||
|
explosion.finalizeExplosion(false);
|
||||||
|
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||||
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,9 @@ public class GunGrenadeEntity extends ThrowableItemProjectile {
|
||||||
|
|
||||||
if (this.tickCount > 0) {
|
if (this.tickCount > 0) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, entity, this.damage * 1.8f, 7.5f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
entity, this.damage * 1.8f, 7.5f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +107,12 @@ public class GunGrenadeEntity extends ThrowableItemProjectile {
|
||||||
if (state.getBlock() instanceof BellBlock bell) {
|
if (state.getBlock() instanceof BellBlock bell) {
|
||||||
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
|
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tickCount > 0) {
|
if (this.tickCount > 0) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.damage * 1.8f, 7.5f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
this, this.damage * 1.8f, 7.5f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +130,9 @@ public class GunGrenadeEntity extends ThrowableItemProjectile {
|
||||||
|
|
||||||
if (this.tickCount > 200 || this.isInWater()) {
|
if (this.tickCount > 200 || this.isInWater()) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.damage * 1.8f, 7.5f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
this, this.damage * 1.8f, 7.5f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,9 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
|
||||||
|
|
||||||
if (this.tickCount > 1) {
|
if (this.tickCount > 1) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, entity, this.damage, 8.0f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
entity, this.damage, 8.0f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +152,9 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
|
||||||
|
|
||||||
if (this.tickCount > 1) {
|
if (this.tickCount > 1) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.damage, 8.0f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
this, this.damage, 8.0f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +207,9 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
|
||||||
|
|
||||||
if (this.tickCount > 200 || this.isInWater()) {
|
if (this.tickCount > 200 || this.isInWater()) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.damage, 8.0f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
this, this.damage, 8.0f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,9 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
||||||
|
|
||||||
if (this.tickCount > 1) {
|
if (this.tickCount > 1) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, entity, this.damage * 0.67f, 10.0f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
entity, this.damage * 0.67f, 10.0f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +128,9 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
||||||
|
|
||||||
if (this.tickCount > 1) {
|
if (this.tickCount > 1) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.damage * 0.67f, 10.0f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
this, this.damage * 0.67f, 10.0f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +157,9 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
||||||
|
|
||||||
if (this.tickCount > 100 || this.isInWater()) {
|
if (this.tickCount > 100 || this.isInWater()) {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
ProjectileTool.causeCustomExplode(this, this.damage * 0.67f, 10.0f, this.monsterMultiplier);
|
ProjectileTool.causeCustomExplode(this,
|
||||||
|
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()),
|
||||||
|
this, this.damage * 0.67f, 10.0f, this.monsterMultiplier);
|
||||||
}
|
}
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
@ -181,7 +187,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getGravity() {
|
protected float getGravity() {
|
||||||
return 0.03F;
|
return super.getGravity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSyncedAnimation() {
|
public String getSyncedAnimation() {
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class ModDamageTypes {
|
||||||
public static final ResourceKey<DamageType> SHOCK = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "shock"));
|
public static final ResourceKey<DamageType> SHOCK = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "shock"));
|
||||||
public static final ResourceKey<DamageType> PROJECTILE_BOOM = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "projectile_boom"));
|
public static final ResourceKey<DamageType> PROJECTILE_BOOM = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "projectile_boom"));
|
||||||
public static final ResourceKey<DamageType> CANNON_FIRE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "cannon_fire"));
|
public static final ResourceKey<DamageType> CANNON_FIRE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "cannon_fire"));
|
||||||
|
public static final ResourceKey<DamageType> CUSTOM_EXPLOSION = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "custom_explosion"));
|
||||||
|
|
||||||
public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
||||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker);
|
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker);
|
||||||
|
@ -58,6 +59,10 @@ public class ModDamageTypes {
|
||||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE_HEADSHOT_ABSOLUTE), directEntity, attacker);
|
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE_HEADSHOT_ABSOLUTE), directEntity, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DamageSource causeCustomExplosionDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
||||||
|
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(CUSTOM_EXPLOSION), directEntity, attacker);
|
||||||
|
}
|
||||||
|
|
||||||
private static class DamageMessages extends DamageSource {
|
private static class DamageMessages extends DamageSource {
|
||||||
public DamageMessages(Holder.Reference<DamageType> typeReference) {
|
public DamageMessages(Holder.Reference<DamageType> typeReference) {
|
||||||
super(typeReference);
|
super(typeReference);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package net.mcreator.superbwarfare.tools;
|
package net.mcreator.superbwarfare.tools;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.init.ModDamageTypes;
|
import net.mcreator.superbwarfare.init.ModDamageTypes;
|
||||||
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.world.level.Explosion;
|
||||||
|
|
||||||
|
@ -10,9 +10,8 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ProjectileTool {
|
public class ProjectileTool {
|
||||||
|
|
||||||
public static void causeCustomExplode(ThrowableItemProjectile projectile, Entity target, float damage, float radius, float damageMultiplier) {
|
public static void causeCustomExplode(ThrowableItemProjectile projectile, @Nullable DamageSource source, Entity target, float damage, float radius, float damageMultiplier) {
|
||||||
CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile,
|
CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, source, damage,
|
||||||
ModDamageTypes.causeProjectileBoomDamage(projectile.level().registryAccess(), projectile, projectile.getOwner()), damage,
|
|
||||||
target.getX(), target.getY(), target.getZ(), radius, Explosion.BlockInteraction.KEEP).setDamageMultiplier(damageMultiplier);
|
target.getX(), target.getY(), target.getZ(), radius, Explosion.BlockInteraction.KEEP).setDamageMultiplier(damageMultiplier);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
||||||
|
@ -21,6 +20,11 @@ public class ProjectileTool {
|
||||||
projectile.discard();
|
projectile.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void causeCustomExplode(ThrowableItemProjectile projectile, Entity target, float damage, float radius, float damageMultiplier) {
|
||||||
|
causeCustomExplode(projectile, ModDamageTypes.causeCustomExplosionDamage(projectile.level().registryAccess(), projectile, projectile.getOwner()),
|
||||||
|
target, damage, radius, damageMultiplier);
|
||||||
|
}
|
||||||
|
|
||||||
public static void causeCustomExplode(ThrowableItemProjectile projectile, float damage, float radius, float damageMultiplier) {
|
public static void causeCustomExplode(ThrowableItemProjectile projectile, float damage, float radius, float damageMultiplier) {
|
||||||
causeCustomExplode(projectile, projectile, damage, radius, damageMultiplier);
|
causeCustomExplode(projectile, projectile, damage, radius, damageMultiplier);
|
||||||
}
|
}
|
||||||
|
@ -29,14 +33,4 @@ public class ProjectileTool {
|
||||||
causeCustomExplode(projectile, damage, radius, 0.0f);
|
causeCustomExplode(projectile, damage, radius, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void causeCustomExplode(LivingEntity projectile, @Nullable LivingEntity owner, float damage, float radius, float damageMultiplier) {
|
|
||||||
CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile,
|
|
||||||
ModDamageTypes.causeProjectileBoomDamage(projectile.level().registryAccess(), projectile, owner), damage,
|
|
||||||
projectile.getX(), projectile.getY(), projectile.getZ(), radius, 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"replace": false,
|
"replace": false,
|
||||||
"values": [
|
"values": [
|
||||||
"superbwarfare:projectile_boom",
|
"superbwarfare:projectile_boom",
|
||||||
|
"superbwarfare:custom_explosion",
|
||||||
"superbwarfare:cannon_fire"
|
"superbwarfare:cannon_fire"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"replace": false,
|
"replace": false,
|
||||||
"values": [
|
"values": [
|
||||||
"superbwarfare:projectile_boom"
|
"superbwarfare:projectile_boom",
|
||||||
|
"superbwarfare:custom_explosion"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"replace": false,
|
"replace": false,
|
||||||
"values": [
|
"values": [
|
||||||
"superbwarfare:projectile_boom"
|
"superbwarfare:projectile_boom",
|
||||||
|
"superbwarfare:custom_explosion"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"exhaustion": 0.1,
|
||||||
|
"message_id": "projectile_boom",
|
||||||
|
"scaling": "never"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue