移除多余排序和类型转换(恼),提取ShakeClientMessage发送方法
This commit is contained in:
parent
00d99566c4
commit
252ed5a86e
14 changed files with 39 additions and 141 deletions
|
@ -37,7 +37,6 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -185,7 +184,7 @@ public class ClaymoreEntity extends Entity implements GeoEntity, OwnableEntity {
|
|||
|
||||
if (this.tickCount >= 40) {
|
||||
final Vec3 center = new Vec3(x + 1.5 * this.getLookAngle().x, y + 1.5 * this.getLookAngle().y, z + 1.5 * this.getLookAngle().z);
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(2.5 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
for (var target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(2.5 / 2d), e -> true)) {
|
||||
var condition = this.getOwner() != target
|
||||
&& (target instanceof LivingEntity || target instanceof VehicleEntity)
|
||||
&& !(target instanceof TargetEntity)
|
||||
|
|
|
@ -42,13 +42,11 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -58,7 +56,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
|||
import software.bernie.geckolib.animation.AnimatableManager;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -828,14 +825,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
|
||||
}
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(5), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 5, 12, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 5, 6, 5, 12);
|
||||
|
||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 2);
|
||||
} else if (getWeaponIndex(0) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) {
|
||||
|
@ -874,14 +864,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
|||
|
||||
this.entityData.set(LOADED_ROCKET, this.getEntityData().get(LOADED_ROCKET) - 1);
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(5), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 5, 12, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 5, 6, 5, 12);
|
||||
|
||||
reloadCoolDown = 15;
|
||||
} else if (getWeaponIndex(0) == 2 && this.getEntityData().get(LOADED_BOMB) > 0) {
|
||||
|
|
|
@ -48,7 +48,6 @@ import net.neoforged.api.distmarker.Dist;
|
|||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -58,7 +57,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
|||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, CannonEntity, OBBEntity {
|
||||
|
@ -453,12 +451,8 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
|||
|
||||
this.entityData.set(COOL_DOWN, 100);
|
||||
this.consumeEnergy(VehicleConfig.ANNIHILATOR_SHOOT_COST.get());
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(20), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(15, 15, 25, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 20, 15, 15, 25);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
|||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -42,13 +41,11 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -61,7 +58,6 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
@ -329,14 +325,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
playShootSound3p(player, 0, 4, 12, 24);
|
||||
}
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 5, 9, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 5, 6, 5, 9);
|
||||
|
||||
this.entityData.set(CANNON_RECOIL_TIME, 40);
|
||||
this.entityData.set(YAW, getTurretYRot());
|
||||
|
|
|
@ -57,7 +57,6 @@ import software.bernie.geckolib.animation.AnimatableManager;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -437,8 +436,7 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
|||
float f = 0.7f;
|
||||
AABB aabb = AABB.ofSize(this.getEyePosition(), f, 0.3, f);
|
||||
var level = this.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getY(), this.getZ());
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, aabb, e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
for (var target : level.getEntitiesOfClass(Entity.class, aabb, e -> true)) {
|
||||
if (this != target && target != null
|
||||
&& !(target instanceof ItemEntity || target instanceof Projectile || target instanceof ProjectileEntity || target instanceof LaserEntity
|
||||
|| target.getType().is(ModTags.EntityTypes.DECOY) || target instanceof AreaEffectCloud || target instanceof C4Entity)) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.core.particles.ParticleTypes;
|
|||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -37,13 +36,11 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -54,7 +51,6 @@ import software.bernie.geckolib.animation.*;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
@ -234,14 +230,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
playShootSound3p(player, 0, 4, 12, 24);
|
||||
}
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 5, 9, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 5, 6, 5, 9);
|
||||
|
||||
this.entityData.set(CANNON_RECOIL_TIME, 40);
|
||||
this.entityData.set(YAW, getTurretYRot());
|
||||
|
|
|
@ -36,13 +36,11 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -53,8 +51,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
|||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity {
|
||||
|
||||
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||
|
@ -326,13 +322,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
|||
Mth.clamp(count--, 1, 5), 0.15, 0.15, 0.15, 0.0025);
|
||||
}
|
||||
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(20), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(15, 15, 45, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 20, 15, 15, 45);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,11 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -53,8 +51,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
|||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEntity {
|
||||
|
||||
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT);
|
||||
|
@ -386,13 +382,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
|||
this.getZ() + 5 * this.getLookAngle().z,
|
||||
100, 7, 0.02, 7, 0.005);
|
||||
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(20), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(15, 15, 45, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 20, 15, 15, 45);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
|
@ -287,12 +286,8 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
|
||||
this.entityData.set(HEAT, entityData.get(HEAT) + 55);
|
||||
this.consumeEnergy(VehicleConfig.PRISM_TANK_SHOOT_COST_MODE_1.get());
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(5), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(8, 4, 7, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 5, 8, 4, 7);
|
||||
}
|
||||
|
||||
float dis = laserLengthEntity(root);
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.core.particles.ParticleTypes;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -28,13 +27,11 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -45,7 +42,6 @@ import software.bernie.geckolib.animation.*;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
@ -180,14 +176,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
playShootSound3p(player, 0, 4, 12, 24);
|
||||
}
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 5, 5, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 5, 6, 5, 5);
|
||||
|
||||
this.entityData.set(CANNON_RECOIL_TIME, 30);
|
||||
this.entityData.set(YAW, getTurretYRot());
|
||||
|
|
|
@ -52,14 +52,12 @@ import net.minecraft.world.level.ClipContext;
|
|||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Math;
|
||||
|
@ -71,7 +69,6 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
|
@ -237,7 +234,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
@ -516,14 +512,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
}
|
||||
}
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(8), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(10, 8, 60, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 8, 10, 8, 60);
|
||||
} else if (getWeaponIndex(0) == 2) {
|
||||
if (this.cannotFireCoax) return;
|
||||
|
||||
|
@ -583,14 +572,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
this.entityData.set(GUN_FIRE_TIME, 2);
|
||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 4);
|
||||
|
||||
Level level = player.level();
|
||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 4, 6, this.getX(), this.getEyeY(), this.getZ()));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(this, 4, 6, 4, 6);
|
||||
|
||||
if (hasCreativeAmmo) return;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -86,8 +85,8 @@ public class BeamTest extends Item {
|
|||
beamTest.getChargeSound().forEach(sound -> {
|
||||
var clientboundstopsoundpacket = new ClientboundStopSoundPacket(sound.getLocation(), SoundSource.PLAYERS);
|
||||
final Vec3 center = new Vec3(player.getX(), player.getY(), player.getZ());
|
||||
for (ServerPlayer player1 : player.level().getEntitiesOfClass(ServerPlayer.class, new AABB(center, center).inflate(48), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
player1.connection.send(clientboundstopsoundpacket);
|
||||
for (ServerPlayer serverPlayer : player.level().getEntitiesOfClass(ServerPlayer.class, new AABB(center, center).inflate(48), e -> true)) {
|
||||
serverPlayer.connection.send(clientboundstopsoundpacket);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,12 @@ import io.netty.buffer.ByteBuf;
|
|||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -40,4 +46,16 @@ public record ShakeClientMessage(
|
|||
public @NotNull Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void sendToNearbyPlayers(Level level, double x, double y, double z, double sendRadius, double time, double radius, double amplitude) {
|
||||
var center = new Vec3(x, y, z);
|
||||
|
||||
for (var serverPlayer : level.getEntitiesOfClass(ServerPlayer.class, new AABB(center, center).inflate(sendRadius), e -> true)) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(time, radius, amplitude, x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendToNearbyPlayers(Entity source, double sendRadius, double time, double radius, double amplitude) {
|
||||
sendToNearbyPlayers(source.level(), source.getX(), source.getY(), source.getZ(), sendRadius, time, radius, amplitude);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -25,10 +24,8 @@ import net.minecraft.world.level.material.FluidState;
|
|||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
@ -78,38 +75,24 @@ public class CustomExplosion extends Explosion {
|
|||
|
||||
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction, boolean vanillaExplode) {
|
||||
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
|
||||
final Vec3 center = new Vec3(pToBlowX, pToBlowY, pToBlowZ);
|
||||
|
||||
if (pLevel instanceof ServerLevel && vanillaExplode) {
|
||||
pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, 0.4f * pRadius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE);
|
||||
}
|
||||
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4 * radius), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(20 + 0.02 * damage, 3 * pRadius, 50 + 0.05 * damage, pToBlowX, pToBlowY, pToBlowZ));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, 4 * radius, 20 + 0.02 * damage, 3 * pRadius, 50 + 0.05 * damage);
|
||||
}
|
||||
|
||||
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction) {
|
||||
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
|
||||
final Vec3 center = new Vec3(pToBlowX, pToBlowY, pToBlowZ);
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4 * radius), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(5 + 0.02 * damage, 0.75 * pRadius, 4 + 0.02 * damage, pToBlowX, pToBlowY, pToBlowZ));
|
||||
}
|
||||
}
|
||||
|
||||
ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, 4 * radius, 5 + 0.02 * damage, 0.75 * pRadius, 4 + 0.02 * damage);
|
||||
}
|
||||
|
||||
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius) {
|
||||
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, BlockInteraction.KEEP);
|
||||
|
||||
final Vec3 center = new Vec3(pToBlowX, pToBlowY, pToBlowZ);
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(radius), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
if (target instanceof ServerPlayer serverPlayer && !(target == pSource && pSource.getVehicle() != null)) {
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(20 + 0.02 * damage, pRadius, 10 + 0.03 * damage, pToBlowX, pToBlowY, pToBlowZ));
|
||||
}
|
||||
}
|
||||
ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, radius, 20 + 0.02 * damage, pRadius, 10 + 0.03 * damage);
|
||||
}
|
||||
|
||||
public CustomExplosion setFireTime(int fireTime) {
|
||||
|
|
Loading…
Add table
Reference in a new issue