Continue mapping migration

This commit is contained in:
Aleksey 2021-04-12 21:38:22 +03:00
parent 99ade39404
commit f03fd03bd0
499 changed files with 12567 additions and 12723 deletions

View file

@ -2,64 +2,75 @@ package ru.betterend.entity;
import java.util.List;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.SpawnReason;
import net.minecraft.world.entity.ai.goal.FollowTargetGoal;
import net.minecraft.world.entity.ai.goal.LookAroundGoal;
import net.minecraft.world.entity.ai.goal.LookAtEntityGoal;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.WanderAroundFarGoal;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.mob.HostileEntity;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import ru.betterend.registry.EndSounds;
import ru.betterend.util.MHelper;
public class ShadowWalkerEntity extends HostileEntity {
public class ShadowWalkerEntity extends Monster {
public ShadowWalkerEntity(EntityType<ShadowWalkerEntity> entityType, Level world) {
super(entityType, world);
}
@Override
protected void initGoals() {
this.goalSelector.add(2, new AttackGoal(this, 1.0D, false));
this.goalSelector.add(7, new WanderAroundFarGoal(this, 1.0D));
this.goalSelector.add(8, new LookAtEntityGoal(this, Player.class, 8.0F));
this.goalSelector.add(8, new LookAroundGoal(this));
this.targetSelector.add(2, new FollowTargetGoal<Player>(this, Player.class, true));
protected void registerGoals() {
this.goalSelector.addGoal(2, new AttackGoal(this, 1.0D, false));
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D));
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<Player>(this, Player.class, true));
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return HostileEntity.createHostileAttributes().add(Attributes.FOLLOW_RANGE, 35.0)
.add(Attributes.MOVEMENT_SPEED, 0.15).add(Attributes.ATTACK_DAMAGE, 4.5).add(Attributes.ARMOR, 2.0)
.add(Attributes.ZOMBIE_SPAWN_REINFORCEMENTS);
public static AttributeSupplier.Builder createMobAttributes() {
return Monster.createMonsterAttributes()
.add(Attributes.FOLLOW_RANGE, 35.0)
.add(Attributes.MOVEMENT_SPEED, 0.15)
.add(Attributes.ATTACK_DAMAGE, 4.5)
.add(Attributes.ARMOR, 2.0)
.add(Attributes.SPAWN_REINFORCEMENTS_CHANCE);
}
@Override
public void tick() {
super.tick();
world.addParticle(ParticleTypes.ASH, getX() + random.nextGaussian() * 0.2,
getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0);
world.addParticle(ParticleTypes.SMOKE, getX() + random.nextGaussian() * 0.2,
getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0);
world.addParticle(ParticleTypes.ENTITY_EFFECT, getX() + random.nextGaussian() * 0.2,
getY() + random.nextGaussian() * 0.5 + 1, getZ() + random.nextGaussian() * 0.2, 0, 0, 0);
level.addParticle(ParticleTypes.ASH,
getX() + random.nextGaussian() * 0.2,
getY() + random.nextGaussian() * 0.5 + 1,
getZ() + random.nextGaussian() * 0.2,
0, 0, 0);
level.addParticle(ParticleTypes.SMOKE,
getX() + random.nextGaussian() * 0.2,
getY() + random.nextGaussian() * 0.5 + 1,
getZ() + random.nextGaussian() * 0.2,
0, 0, 0);
level.addParticle(ParticleTypes.ENTITY_EFFECT,
getX() + random.nextGaussian() * 0.2,
getY() + random.nextGaussian() * 0.5 + 1,
getZ() + random.nextGaussian() * 0.2,
0, 0, 0);
}
@Override
protected SoundEvent getAmbientSound() {
return EndSounds.ENTITY_SHADOW_WALKER;
@ -76,51 +87,47 @@ public class ShadowWalkerEntity extends HostileEntity {
}
@Override
protected void playStepSound(BlockPos pos, BlockState state) {
}
protected void playStepSound(BlockPos pos, BlockState state) {}
@Override
protected float getSoundVolume() {
return MHelper.randRange(0.25F, 0.5F, random);
}
@Override
protected float getSoundPitch() {
protected float getVoicePitch() {
return MHelper.randRange(0.75F, 1.25F, random);
}
@Override
public boolean tryAttack(Entity target) {
boolean attack = super.tryAttack(target);
public boolean doHurtTarget(Entity target) {
boolean attack = super.doHurtTarget(target);
if (attack && target instanceof LivingEntity) {
LivingEntity living = (LivingEntity) target;
if (!(living.hasMobEffect(MobEffects.BLINDNESS))) {
living.addMobEffect(new MobEffectInstance(MobEffects.BLINDNESS, 60));
if (!(living.hasEffect(MobEffects.BLINDNESS))) {
living.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 60));
}
}
return attack;
}
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerLevelAccessor world,
SpawnReason spawnReason, BlockPos pos, Random random) {
if (HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random)) {
Box box = new Box(pos).expand(16);
List<ShadowWalkerEntity> entities = world.getEntitiesByClass(ShadowWalkerEntity.class, box, (entity) -> {
return true;
});
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
if (Monster.checkMonsterSpawnRules(type, world, spawnReason, pos, random)) {
AABB box = new AABB(pos).inflate(16);
List<ShadowWalkerEntity> entities = world.getEntitiesOfClass(ShadowWalkerEntity.class, box, (entity) -> { return true; });
return entities.size() < 6;
}
return false;
}
private final class AttackGoal extends MeleeAttackGoal {
private final ShadowWalkerEntity walker;
private int ticks;
public AttackGoal(ShadowWalkerEntity walker, double speed, boolean pauseWhenMobIdle) {
super(walker, speed, pauseWhenMobIdle);
this.walker = walker;
}
super(walker, speed, pauseWhenMobIdle);
this.walker = walker;
}
public void start() {
super.start();
@ -129,16 +136,17 @@ public class ShadowWalkerEntity extends HostileEntity {
public void stop() {
super.stop();
this.walker.setAttacking(false);
this.walker.setAggressive(false);
}
public void tick() {
super.tick();
++this.ticks;
if (this.ticks >= 5 && this.method_28348() < this.method_28349() / 2) {
this.walker.setAttacking(true);
} else {
this.walker.setAttacking(false);
if (this.ticks >= 5 && this.getTicksUntilNextAttack() < this.getAttackInterval() / 2) {
this.walker.setAggressive(true);
}
else {
this.walker.setAggressive(false);
}
}
}