添加弹孔、烟雾和击中音效
This commit is contained in:
parent
57617475f3
commit
9f68619ea0
7 changed files with 60 additions and 51 deletions
|
@ -41,7 +41,6 @@ import java.util.function.Supplier;
|
|||
public class TargetMod {
|
||||
public static final Logger LOGGER = LogManager.getLogger(TargetMod.class);
|
||||
public static final String MODID = "target";
|
||||
|
||||
public TargetMod() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
|
|
@ -14,44 +14,44 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class BulltholeParticle extends TextureSheetParticle {
|
||||
public static BulltholeParticleProvider provider(SpriteSet spriteSet) {
|
||||
return new BulltholeParticleProvider(spriteSet);
|
||||
}
|
||||
public static BulltholeParticleProvider provider(SpriteSet spriteSet) {
|
||||
return new BulltholeParticleProvider(spriteSet);
|
||||
}
|
||||
|
||||
public static class BulltholeParticleProvider implements ParticleProvider<SimpleParticleType> {
|
||||
private final SpriteSet spriteSet;
|
||||
public static class BulltholeParticleProvider implements ParticleProvider<SimpleParticleType> {
|
||||
private final SpriteSet spriteSet;
|
||||
|
||||
public BulltholeParticleProvider(SpriteSet spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
public BulltholeParticleProvider(SpriteSet spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle createParticle(SimpleParticleType typeIn, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new BulltholeParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
|
||||
}
|
||||
}
|
||||
public Particle createParticle(SimpleParticleType typeIn, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new BulltholeParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
private final SpriteSet spriteSet;
|
||||
private final SpriteSet spriteSet;
|
||||
|
||||
protected BulltholeParticle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet) {
|
||||
super(world, x, y, z);
|
||||
this.spriteSet = spriteSet;
|
||||
this.setSize(0f, 0f);
|
||||
this.lifetime = 100;
|
||||
this.gravity = 0f;
|
||||
this.hasPhysics = false;
|
||||
this.xd = vx * 0;
|
||||
this.yd = vy * 0;
|
||||
this.zd = vz * 0;
|
||||
this.pickSprite(spriteSet);
|
||||
}
|
||||
protected BulltholeParticle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet) {
|
||||
super(world, x, y, z);
|
||||
this.spriteSet = spriteSet;
|
||||
this.setSize(0f, 0f);
|
||||
this.lifetime = 100;
|
||||
this.gravity = 0f;
|
||||
this.hasPhysics = false;
|
||||
this.xd = vx * 0;
|
||||
this.yd = vy * 0;
|
||||
this.zd = vz * 0;
|
||||
this.pickSprite(spriteSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleRenderType getRenderType() {
|
||||
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
@Override
|
||||
public ParticleRenderType getRenderType() {
|
||||
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
}
|
||||
}
|
|
@ -1,16 +1,20 @@
|
|||
package net.mcreator.target.entity;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.phys.*;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.mcreator.target.headshot.BoundingBoxManager;
|
||||
import net.mcreator.target.headshot.IHeadshotBox;
|
||||
|
@ -94,11 +98,21 @@ public class ProjectileEntity extends ThrowableItemProjectile {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onHitBlock(BlockHitResult pResult) {
|
||||
super.onHitBlock(pResult);
|
||||
if (!this.level().isClientSide) {
|
||||
this.discard();
|
||||
}
|
||||
protected void onHitBlock(BlockHitResult hitResult) {
|
||||
super.onHitBlock(hitResult);
|
||||
Vec3 location = hitResult.getLocation();
|
||||
|
||||
if (this.level() instanceof ServerLevel _level)
|
||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(location.x, location.y, location.z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
||||
"particle target:bullthole ~ ~ ~ 0 0 0 0 1 force");
|
||||
if (this.level() instanceof ServerLevel _level)
|
||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(location.x, location.y, location.z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
||||
"particle minecraft:smoke ~ ~ ~ 0 0.1 0 0.01 3 force");
|
||||
if (this.level() instanceof ServerLevel _level)
|
||||
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(location.x, location.y, location.z), Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null).withSuppressedOutput(),
|
||||
"playsound target:land block @a ~ ~ ~ 1 1");
|
||||
|
||||
this.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -233,7 +233,7 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
|
|||
public static AttributeSupplier.Builder createAttributes() {
|
||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0);
|
||||
builder = builder.add(Attributes.MAX_HEALTH, 100);
|
||||
builder = builder.add(Attributes.MAX_HEALTH, 40);
|
||||
builder = builder.add(Attributes.ARMOR, 0);
|
||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
|
||||
builder = builder.add(Attributes.FOLLOW_RANGE, 16);
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.target.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
@ -18,3 +15,4 @@ public class TargetModParticleTypes {
|
|||
public static final RegistryObject<SimpleParticleType> FIRESTAR = REGISTRY.register("firestar", () -> new SimpleParticleType(false));
|
||||
public static final RegistryObject<SimpleParticleType> BULLTHOLE = REGISTRY.register("bullthole", () -> new SimpleParticleType(false));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.target.init;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
@ -20,3 +17,4 @@ public class TargetModParticles {
|
|||
event.registerSpriteSet(TargetModParticleTypes.BULLTHOLE.get(), BulltholeParticle::provider);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BulletfireNormalProcedure {
|
|||
ProjectileEntity projectile = new ProjectileEntity(entity.level(), living);
|
||||
projectile.setOwner(living);
|
||||
|
||||
projectile.setPos(living.getX(), living.getEyeY() - 0.1, living.getZ());
|
||||
projectile.setPos((living.getX() + (-0.5) * living.getLookAngle().x), (living.getEyeY() - 0.1 + (-0.5) * living.getLookAngle().y), (living.getZ() + (-0.5) * living.getLookAngle().z));
|
||||
projectile.shoot(living.getLookAngle().x, living.getLookAngle().y, living.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"),
|
||||
(float) living.getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue());
|
||||
entity.level().addFreshEntity(projectile);
|
||||
|
|
Loading…
Add table
Reference in a new issue