完善穿透
This commit is contained in:
parent
b80b554993
commit
2c4bcef205
9 changed files with 97 additions and 9 deletions
|
@ -1,10 +1,7 @@
|
|||
package net.mcreator.target.entity;
|
||||
|
||||
import net.mcreator.target.TargetMod;
|
||||
import net.mcreator.target.init.TargetModDamageTypes;
|
||||
import net.mcreator.target.init.TargetModEntities;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
import net.mcreator.target.init.*;
|
||||
import net.mcreator.target.network.message.ClientIndicatorMessage;
|
||||
import net.mcreator.target.tools.CustomExplosion;
|
||||
import net.mcreator.target.tools.ParticleTool;
|
||||
|
@ -22,10 +19,13 @@ import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.StonecutterBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
|
@ -95,7 +95,21 @@ public class CannonShellEntity extends ThrowableItemProjectile {
|
|||
if (this.level() instanceof ServerLevel) {
|
||||
causeExplode();
|
||||
}
|
||||
this.discard();
|
||||
|
||||
Vec3 vec = this.getDeltaMovement();
|
||||
double vec_x = vec.x;
|
||||
double vec_y = vec.y;
|
||||
double vec_z = vec.z;
|
||||
|
||||
this.setDeltaMovement(vec_x - 0.02 * vec_x, vec_y - 0.02 * vec_y, vec_z - 0.02 * vec_z);
|
||||
|
||||
this.durability -= 2;
|
||||
if (this.durability <= 0) {
|
||||
if (!this.level().isClientSide()) {
|
||||
causeExplode();
|
||||
}
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,6 +131,26 @@ public class CannonShellEntity extends ThrowableItemProjectile {
|
|||
|
||||
float hardness = this.level().getBlockState(BlockPos.containing(x, y, z)).getBlock().defaultDestroyTime();
|
||||
this.durability -= (int) hardness;
|
||||
causeSmallExplode();
|
||||
|
||||
if (blockState.is(TargetModBlocks.BARBED_WIRE.get()) || blockState.is(Blocks.NETHERITE_BLOCK)) {
|
||||
this.durability -= 10;
|
||||
}
|
||||
|
||||
if (blockState.is(Blocks.IRON_BLOCK) || blockState.is(Blocks.COPPER_BLOCK)) {
|
||||
this.durability -= 5;
|
||||
}
|
||||
|
||||
if (blockState.is(Blocks.GOLD_BLOCK)) {
|
||||
this.durability -= 3;
|
||||
}
|
||||
|
||||
Vec3 vec = this.getDeltaMovement();
|
||||
double vec_x = vec.x;
|
||||
double vec_y = vec.y;
|
||||
double vec_z = vec.z;
|
||||
|
||||
this.setDeltaMovement(vec_x - 0.02 * vec_x * hardness, vec_y - 0.02 * vec_y * hardness, vec_z - 0.02 * vec_z * hardness);
|
||||
|
||||
if (this.durability <= 0) {
|
||||
if (!this.level().isClientSide()) {
|
||||
|
@ -153,7 +187,21 @@ public class CannonShellEntity extends ThrowableItemProjectile {
|
|||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||
explosion.finalizeExplosion(false);
|
||||
|
||||
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
|
||||
if (explosionRadius > 7) {
|
||||
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
|
||||
} else {
|
||||
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||
}
|
||||
}
|
||||
|
||||
private void causeSmallExplode() {
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||
TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 10,
|
||||
this.getX(), this.getY(), this.getZ(), 3, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||
explosion.explode();
|
||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||
explosion.finalizeExplosion(false);
|
||||
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -267,6 +267,7 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity {
|
|||
float explosionDamage = 0;
|
||||
float fireProbability = 0;
|
||||
int fireTime = 0;
|
||||
int durability = 0;
|
||||
|
||||
if (player.getMainHandItem().is(TargetModItems.HE_5_INCHES.get())) {
|
||||
hitDamage = 100;
|
||||
|
@ -274,17 +275,29 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity {
|
|||
explosionDamage = 200;
|
||||
fireProbability = 0.18F;
|
||||
fireTime = 100;
|
||||
durability = 0;
|
||||
}
|
||||
|
||||
if (player.getMainHandItem().is(TargetModItems.AP_5_INCHES.get())) {
|
||||
hitDamage = 150;
|
||||
explosionRadius = 3;
|
||||
explosionDamage = 250;
|
||||
fireProbability = 0;
|
||||
fireTime = 0;
|
||||
durability = 25;
|
||||
}
|
||||
|
||||
if (!player.isCreative()) {
|
||||
player.getMainHandItem().shrink(1);
|
||||
}
|
||||
|
||||
CannonShellEntity entityToSpawn = new CannonShellEntity(TargetModEntities.CANNON_SHELL.get(), player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime);
|
||||
CannonShellEntity entityToSpawn = new CannonShellEntity(TargetModEntities.CANNON_SHELL.get(), player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime).durability(durability);
|
||||
|
||||
entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ());
|
||||
entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 15, 0.1f);
|
||||
level.addFreshEntity(entityToSpawn);
|
||||
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
SoundTool.playLocalSound(serverPlayer, TargetModSounds.MK_42_FIRE_1P.get(), 2, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.MK_42_FIRE_3P.get(), SoundSource.PLAYERS, 6, 1);
|
||||
|
|
|
@ -69,6 +69,7 @@ public class TargetModItems {
|
|||
public static final RegistryObject<Item> MORTAR_SHELLS = AMMO.register("mortar_shells", MortarShells::new);
|
||||
public static final RegistryObject<Item> ROCKET = AMMO.register("rocket", Rocket::new);
|
||||
public static final RegistryObject<Item> HE_5_INCHES = AMMO.register("he_5_inches", He5Inches::new);
|
||||
public static final RegistryObject<Item> AP_5_INCHES = AMMO.register("ap_5_inches", Ap5Inches::new);
|
||||
|
||||
/**
|
||||
* items
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Ap5Inches extends CannonShellItem {
|
||||
public Ap5Inches() {
|
||||
super(new Properties().stacksTo(64).rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@ public class ParticleTool {
|
|||
sendParticle(serverLevel, ParticleTypes.FALLING_WATER, x, y + 3, z, 600, 1.5, 4, 1.5, 1, true);
|
||||
sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP, x, y, z, 1000, 3, 0.5, 3, 0.1, true);
|
||||
}
|
||||
sendParticle(serverLevel, ParticleTypes.EXPLOSION, x, y + 1, z, 100, 1, 1, 1, 1, true);
|
||||
sendParticle(serverLevel, ParticleTypes.EXPLOSION, x, y + 1, z, 5, 0.7, 0.7, 0.7, 1, true);
|
||||
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, x, y, z, 80, 0.4, 1, 0.4, 0.02, true);
|
||||
sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, x, y + 1, z, 80, 0.4, 1, 0.4, 0.02, true);
|
||||
sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, x, y, z, 80, 2, 0.001, 2, 0.01, true);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "target:item/shells/ap_5_inches"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "target:item/he_5_inches"
|
||||
"layer0": "target:item/shells/he_5_inches"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 436 B |
Loading…
Add table
Reference in a new issue