优化代码
This commit is contained in:
parent
9408c315e9
commit
a3191ef95b
4 changed files with 15 additions and 15 deletions
|
@ -5,6 +5,7 @@ import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.Commands;
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
@ -35,7 +36,10 @@ public class MediumExpCommand {
|
||||||
world.playLocalSound(x, (y + 1), z, TargetModSounds.EXPFAR.get(), SoundSource.BLOCKS, 24, 1, false);
|
world.playLocalSound(x, (y + 1), z, TargetModSounds.EXPFAR.get(), SoundSource.BLOCKS, 24, 1, false);
|
||||||
world.playLocalSound(x, (y + 1), z, TargetModSounds.EXPVERYFAR.get(), SoundSource.BLOCKS, 64, 1, false);
|
world.playLocalSound(x, (y + 1), z, TargetModSounds.EXPVERYFAR.get(), SoundSource.BLOCKS, 64, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world instanceof ServerLevel server) {
|
if (world instanceof ServerLevel server) {
|
||||||
|
// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, x, y, z, 80, 0.4, 1, 0.4, 0.02);
|
||||||
|
|
||||||
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
||||||
"particle minecraft:campfire_cosy_smoke ~ ~ ~ 0.4 1 0.4 0.02 80 force");
|
"particle minecraft:campfire_cosy_smoke ~ ~ ~ 0.4 1 0.4 0.02 80 force");
|
||||||
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
server.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, new Vec3(x, (y + 1), z), Vec2.ZERO, server, 4, "", Component.literal(""), server.getServer(), null).withSuppressedOutput(),
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.mcreator.target.headshot.BoundingBoxManager;
|
||||||
import net.mcreator.target.headshot.IHeadshotBox;
|
import net.mcreator.target.headshot.IHeadshotBox;
|
||||||
import net.mcreator.target.init.TargetModDamageTypes;
|
import net.mcreator.target.init.TargetModDamageTypes;
|
||||||
import net.mcreator.target.init.TargetModEntities;
|
import net.mcreator.target.init.TargetModEntities;
|
||||||
|
import net.mcreator.target.init.TargetModSounds;
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
import net.minecraft.commands.CommandSource;
|
import net.minecraft.commands.CommandSource;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
@ -89,8 +90,7 @@ public class BocekArrowEntity extends AbstractArrow implements ItemSupplier {
|
||||||
capability.syncPlayerVariables(living);
|
capability.syncPlayerVariables(living);
|
||||||
});
|
});
|
||||||
if (!living.level().isClientSide() && living.getServer() != null) {
|
if (!living.level().isClientSide() && living.getServer() != null) {
|
||||||
living.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, living.position(), living.getRotationVector(), living.level() instanceof ServerLevel ? (ServerLevel) living.level() : null, 4,
|
living.playSound(TargetModSounds.INDICATION.get());
|
||||||
living.getName().getString(), living.getDisplayName(), living.level().getServer(), living), "playsound target:indication voice @a ~ ~ ~ 1 1");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,9 @@ import net.minecraftforge.network.PacketDistributor;
|
||||||
public class LivingEntityEventHandler {
|
public class LivingEntityEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onEntityAttacked(LivingHurtEvent event) {
|
public static void onEntityAttacked(LivingHurtEvent event) {
|
||||||
if (event == null || event.getEntity() == null) return;
|
if (event == null || event.getEntity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
renderDamageIndicator(event);
|
renderDamageIndicator(event);
|
||||||
target1DamageImmune(event, event.getEntity());
|
target1DamageImmune(event, event.getEntity());
|
||||||
reduceBulletDamage(event, event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
reduceBulletDamage(event, event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
||||||
|
@ -46,14 +48,17 @@ public class LivingEntityEventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onEntityAttacked(LivingAttackEvent event) {
|
public static void onEntityAttacked(LivingAttackEvent event) {
|
||||||
if (event == null || event.getEntity() == null) return;
|
if (event == null || event.getEntity() == null) {
|
||||||
arrowDamageImmuneForMine(event, event.getSource(), event.getSource().getEntity());
|
return;
|
||||||
|
}
|
||||||
claymoreDamage(event, event.getEntity().level(), event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
claymoreDamage(event, event.getEntity().level(), event.getSource(), event.getEntity(), event.getSource().getEntity(), event.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onEntityDeath(LivingDeathEvent event) {
|
public static void onEntityDeath(LivingDeathEvent event) {
|
||||||
if (event == null || event.getEntity() == null) return;
|
if (event == null || event.getEntity() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
killIndication(event.getSource().getEntity());
|
killIndication(event.getSource().getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,15 +131,6 @@ public class LivingEntityEventHandler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void arrowDamageImmuneForMine(Event event, DamageSource damageSource, Entity sourceEntity) {
|
|
||||||
if (damageSource == null || sourceEntity == null) return;
|
|
||||||
if (sourceEntity instanceof Player player && (!sourceEntity.isAlive() || player.isSpectator())
|
|
||||||
&& (damageSource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:arrow_in_brain")))
|
|
||||||
|| damageSource.is(ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("target:mine")))
|
|
||||||
|| damageSource.is(DamageTypes.ARROW))
|
|
||||||
) event.setCanceled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderDamageIndicator(LivingHurtEvent event) {
|
private static void renderDamageIndicator(LivingHurtEvent event) {
|
||||||
if (event == null || event.getEntity() == null) return;
|
if (event == null || event.getEntity() == null) return;
|
||||||
var damagesource = event.getSource();
|
var damagesource = event.getSource();
|
||||||
|
|
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Loading…
Add table
Reference in a new issue