添加弹孔、烟雾和击中音效
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 class TargetMod {
|
||||||
public static final Logger LOGGER = LogManager.getLogger(TargetMod.class);
|
public static final Logger LOGGER = LogManager.getLogger(TargetMod.class);
|
||||||
public static final String MODID = "target";
|
public static final String MODID = "target";
|
||||||
|
|
||||||
public TargetMod() {
|
public TargetMod() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
package net.mcreator.target.entity;
|
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.entity.Entity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
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.phys.*;
|
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.BoundingBoxManager;
|
||||||
import net.mcreator.target.headshot.IHeadshotBox;
|
import net.mcreator.target.headshot.IHeadshotBox;
|
||||||
|
@ -94,12 +98,22 @@ public class ProjectileEntity extends ThrowableItemProjectile {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHitBlock(BlockHitResult pResult) {
|
protected void onHitBlock(BlockHitResult hitResult) {
|
||||||
super.onHitBlock(pResult);
|
super.onHitBlock(hitResult);
|
||||||
if (!this.level().isClientSide) {
|
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();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Item getDefaultItem() {
|
protected Item getDefaultItem() {
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class Target1Entity extends PathfinderMob implements GeoEntity {
|
||||||
public static AttributeSupplier.Builder createAttributes() {
|
public static AttributeSupplier.Builder createAttributes() {
|
||||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
||||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0);
|
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.ARMOR, 0);
|
||||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
|
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
|
||||||
builder = builder.add(Attributes.FOLLOW_RANGE, 16);
|
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;
|
package net.mcreator.target.init;
|
||||||
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
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> FIRESTAR = REGISTRY.register("firestar", () -> new SimpleParticleType(false));
|
||||||
public static final RegistryObject<SimpleParticleType> BULLTHOLE = REGISTRY.register("bullthole", () -> 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;
|
package net.mcreator.target.init;
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
@ -20,3 +17,4 @@ public class TargetModParticles {
|
||||||
event.registerSpriteSet(TargetModParticleTypes.BULLTHOLE.get(), BulltholeParticle::provider);
|
event.registerSpriteSet(TargetModParticleTypes.BULLTHOLE.get(), BulltholeParticle::provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class BulletfireNormalProcedure {
|
||||||
ProjectileEntity projectile = new ProjectileEntity(entity.level(), living);
|
ProjectileEntity projectile = new ProjectileEntity(entity.level(), living);
|
||||||
projectile.setOwner(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"),
|
projectile.shoot(living.getLookAngle().x, living.getLookAngle().y, living.getLookAngle().z, (float) usehand.getOrCreateTag().getDouble("velocity"),
|
||||||
(float) living.getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue());
|
(float) living.getAttribute(TargetModAttributes.SPREAD.get()).getBaseValue());
|
||||||
entity.level().addFreshEntity(projectile);
|
entity.level().addFreshEntity(projectile);
|
||||||
|
|
Loading…
Add table
Reference in a new issue