diff --git a/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java b/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java index 8f1f6b979..f72f81f40 100644 --- a/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java +++ b/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java @@ -1,8 +1,9 @@ package net.mcreator.target.entity; import net.mcreator.target.TargetMod; -import net.mcreator.target.init.*; -import net.mcreator.target.network.TargetModVariables; +import net.mcreator.target.init.TargetModDamageTypes; +import net.mcreator.target.init.TargetModEntities; +import net.mcreator.target.init.TargetModItems; import net.mcreator.target.tools.CustomExplosion; import net.mcreator.target.tools.ParticleTool; import net.minecraft.core.registries.Registries; @@ -27,7 +28,6 @@ import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; -import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; @@ -254,18 +254,14 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); - for (int index0 = 0; index0 < 250; index0++) { + for (int index0 = 0; index0 < 100; index0++) { fragShoot(); } } public void fragShoot() { - if (!this.level().isClientSide()) { - - Vec3 vec3 = (this.position()); - - FragEntity frag = new FragEntity(this.getOwner(), level()); + FragEntity frag = new FragEntity(this.getOwner(), level()).setPosition0(this.position()); frag.setPos(this.getX(), this.getEyeY() + 0.1, this.getZ()); frag.shoot(this.getLookAngle().x, this.getLookAngle().y + 0.5f, this.getLookAngle().z, 7, diff --git a/src/main/java/net/mcreator/target/entity/FragEntity.java b/src/main/java/net/mcreator/target/entity/FragEntity.java index f135975d6..ce42bd50a 100644 --- a/src/main/java/net/mcreator/target/entity/FragEntity.java +++ b/src/main/java/net/mcreator/target/entity/FragEntity.java @@ -24,9 +24,8 @@ import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; -import java.util.Optional; - public class FragEntity extends ThrowableItemProjectile { + private Vec3 position0; public FragEntity(EntityType type, Level world) { super(type, world); @@ -43,6 +42,12 @@ public class FragEntity extends ThrowableItemProjectile { public FragEntity(PlayMessages.SpawnEntity spawnEntity, Level level) { this(TargetModEntities.FRAG.get(), level); } + + public FragEntity setPosition0(Vec3 position0) { + this.position0 = position0; + return this; + } + @Override public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); @@ -66,7 +71,9 @@ public class FragEntity extends ThrowableItemProjectile { living.level().playSound(null, living.blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5)); - entity.hurt(TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 4 - (float) Mth.clamp(0.04 * this.position().distanceTo(this.getOwner().position()) * (entity instanceof LivingEntity living_ ? living_.getMaxHealth() : 1),0,3.5)); + entity.hurt(TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), + 5 - (float) Mth.clamp(0.2 * this.position0.distanceTo(entity.position()) + * (entity instanceof LivingEntity livingEntity ? livingEntity.getMaxHealth() / 100 + 1 : 1), 0, 4.5)); } } @@ -77,7 +84,6 @@ public class FragEntity extends ThrowableItemProjectile { public void onHitBlock(BlockHitResult blockHitResult) { super.onHitBlock(blockHitResult); - this.discard(); } diff --git a/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java b/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java index c4c09fdab..243ccb726 100644 --- a/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java +++ b/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java @@ -178,16 +178,14 @@ public class GunGrenadeEntity extends ThrowableItemProjectile { explosion.finalizeExplosion(false); ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); - for (int index0 = 0; index0 < 200; index0++) { + for (int index0 = 0; index0 < 50; index0++) { fragShoot(); } } public void fragShoot() { - if (!this.level().isClientSide()) { - - FragEntity frag = new FragEntity((LivingEntity) this.getOwner(), level()); + FragEntity frag = new FragEntity((LivingEntity) this.getOwner(), level()).setPosition0(this.position()); frag.setPos(this.getX(), this.getEyeY() + 0.1, this.getZ()); frag.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 5,