63 lines
2 KiB
Java
63 lines
2 KiB
Java
package net.minecraft.world.entity.monster;
|
|
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.effect.MobEffectInstance;
|
|
import net.minecraft.world.effect.MobEffects;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntitySpawnReason;
|
|
import net.minecraft.world.entity.EntityType;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.entity.SpawnGroupData;
|
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
|
import net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.ServerLevelAccessor;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
public class CaveSpider extends Spider {
|
|
public CaveSpider(EntityType<? extends CaveSpider> entityType, Level level) {
|
|
super(entityType, level);
|
|
}
|
|
|
|
public static Builder createCaveSpider() {
|
|
return Spider.createAttributes().add(Attributes.MAX_HEALTH, 12.0);
|
|
}
|
|
|
|
@Override
|
|
public boolean doHurtTarget(ServerLevel level, Entity source) {
|
|
if (super.doHurtTarget(level, source)) {
|
|
if (source instanceof LivingEntity) {
|
|
int i = 0;
|
|
if (this.level().getDifficulty() == Difficulty.NORMAL) {
|
|
i = 7;
|
|
} else if (this.level().getDifficulty() == Difficulty.HARD) {
|
|
i = 15;
|
|
}
|
|
|
|
if (i > 0) {
|
|
((LivingEntity)source).addEffect(new MobEffectInstance(MobEffects.POISON, i * 20, 0), this);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public SpawnGroupData finalizeSpawn(
|
|
ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData spawnGroupData
|
|
) {
|
|
return spawnGroupData;
|
|
}
|
|
|
|
@Override
|
|
public Vec3 getVehicleAttachmentPoint(Entity entity) {
|
|
return entity.getBbWidth() <= this.getBbWidth() ? new Vec3(0.0, 0.21875 * this.getScale(), 0.0) : super.getVehicleAttachmentPoint(entity);
|
|
}
|
|
}
|