添加子弹对于PartEntity判定的处理

This commit is contained in:
Light_Quanta 2024-05-10 18:10:27 +08:00
parent b0452ecce7
commit 90ac4c88fa
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -33,6 +33,7 @@ import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.*; import net.minecraft.world.phys.*;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.entity.IEntityAdditionalSpawnData; import net.minecraftforge.entity.IEntityAdditionalSpawnData;
import net.minecraftforge.entity.PartEntity;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -301,6 +302,10 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
protected void onHitEntity(Entity entity, boolean headshot) { protected void onHitEntity(Entity entity, boolean headshot) {
if (entity == null) return; if (entity == null) return;
if (entity instanceof PartEntity<?> part) {
entity = part.getParent();
}
if (beast && entity instanceof LivingEntity living) { if (beast && entity instanceof LivingEntity living) {
if (living.isDeadOrDying()) return; if (living.isDeadOrDying()) return;
if (living instanceof ServerPlayer victim) { if (living instanceof ServerPlayer victim) {