From 7def14b6961cdb17dcd6dadf16450e13f90a69bc Mon Sep 17 00:00:00 2001 From: cheaterpaul Date: Sun, 29 Oct 2023 03:15:29 +0100 Subject: [PATCH] balance mother fight - spawn more ghosts in shorter intervals if more players are involved - remove freeze effect from ghost - increased ghost speed when not in blocks - increase remains defender damage --- .../blockentity/MotherBlockEntity.java | 15 +++++---- .../vampirism/entity/GhostEntity.java | 31 +++++++++++++------ .../entity/RemainsDefenderEntity.java | 2 +- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/de/teamlapen/vampirism/blockentity/MotherBlockEntity.java b/src/main/java/de/teamlapen/vampirism/blockentity/MotherBlockEntity.java index 32cc5daec2..e912b6e7e0 100644 --- a/src/main/java/de/teamlapen/vampirism/blockentity/MotherBlockEntity.java +++ b/src/main/java/de/teamlapen/vampirism/blockentity/MotherBlockEntity.java @@ -66,16 +66,15 @@ public static void serverTick(Level level, BlockPos blockPos, BlockState blockSt player.addEffect(new MobEffectInstance(MobEffects.HUNGER, 5 * 20, 2)); ModParticles.spawnParticlesServer(player.level(), new FlyingBloodParticleOptions(100, false, p.getX() + 0.5, p.getY() + 0.5, p.getZ() + 0.5, 0.5f), player.getX(), player.getY() + player.getEyeHeight() / 2, player.getZ(), 5, 0.1f, 0.1f, 0.1f, 0); } - - if (e.level.getRandom().nextInt(3) == 0) { - if (e.level.getEntitiesOfClass(GhostEntity.class, e.getArea().inflate(10)).size() < Math.min(e.activePlayers.size(), 5)) { - BlockPos left = vuls.get(e.level.getRandom().nextInt(vuls.size())).getLeft(); - e.spawnGhost(level, left); - } - } } } } + if (e.level.getRandom().nextFloat() < Math.max(0.02f, Math.min(0.1f, e.activePlayers.size() * 0.002f))) { + var blocks = e.getTreeStructure(false).getCachedBlocks(); + if (e.level.getEntitiesOfClass(GhostEntity.class, e.getArea().inflate(10)).size() < Math.min(e.activePlayers.size() * 1.6, 10)) { + blocks.stream().skip(e.level.getRandom().nextInt(blocks.size())).findFirst().ifPresent(pos -> e.spawnGhost(level, pos)); + } + } } //Handle destruction -------------------------------- if (e.level != null && e.destructionTimer > 0) { @@ -313,7 +312,7 @@ private AABB getArea() { private void spawnGhosts() { Set vuls = this.getTreeStructure(false).getCachedBlocks(); int size = this.level.getEntitiesOfClass(GhostEntity.class, this.getArea()).size(); - for(int i = size; i < 3; i++) { + for(int i = size; i < Math.max(3, Math.min(this.activePlayers.size() * 1.6, 10)); i++) { vuls.stream().skip(level.getRandom().nextInt(vuls.size())).findFirst().ifPresent(pos -> this.spawnGhost(level, pos)); } } diff --git a/src/main/java/de/teamlapen/vampirism/entity/GhostEntity.java b/src/main/java/de/teamlapen/vampirism/entity/GhostEntity.java index 29a203baa8..c0b716ad56 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/GhostEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/GhostEntity.java @@ -16,6 +16,8 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.PathfinderMob; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.control.FlyingMoveControl; @@ -28,14 +30,18 @@ import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeMod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.UUID; + public class GhostEntity extends VampirismEntity implements IRemainsEntity, IEntityFollower { + private static final UUID SPEED_MODIFIER = UUID.fromString("e8c3b0b0-3d6c-11eb-b378-0242ac130002"); private IEntityLeader leader; public GhostEntity(@NotNull EntityType type, @NotNull Level world) { @@ -61,15 +67,6 @@ public boolean isInvulnerableTo(DamageSource pSource) { return pSource.is(DamageTypeTags.IS_PROJECTILE) || pSource.is(ModTags.DamageTypes.MOTHER_RESISTANT_TO) && super.isInvulnerableTo(pSource); } - @Override - public void playerTouch(Player pPlayer) { - if (pPlayer.canFreeze()) { - pPlayer.setTicksFrozen(Math.min(pPlayer.getTicksFrozen() + 2, pPlayer.getTicksRequiredToFreeze() + 10)); - } - } - - - @Override protected void registerGoals() { this.goalSelector.addGoal(1, new GhostMeleeAttackGoal(1, true)); @@ -96,11 +93,27 @@ protected double getFollowDistance() { public void tick() { this.setNoGravity(true); this.noPhysics = true; + checkInsideBlocks(); super.tick(); this.noPhysics = false; this.setNoGravity(true); } + @Override + protected void onInsideBlock(BlockState pState) { + if (pState.isAir()) { + AttributeInstance attribute = getAttribute(Attributes.FLYING_SPEED); + if (attribute != null && attribute.getModifier(SPEED_MODIFIER) == null) { + attribute.addTransientModifier(new AttributeModifier(SPEED_MODIFIER, "free movement", 0.2, AttributeModifier.Operation.ADDITION)); + } + } else { + AttributeInstance attribute = getAttribute(Attributes.FLYING_SPEED); + if (attribute != null) { + attribute.removeModifier(SPEED_MODIFIER); + } + } + } + @Override public boolean isFollowing() { return this.leader != null; diff --git a/src/main/java/de/teamlapen/vampirism/entity/RemainsDefenderEntity.java b/src/main/java/de/teamlapen/vampirism/entity/RemainsDefenderEntity.java index ef8a426ec2..383f254201 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/RemainsDefenderEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/RemainsDefenderEntity.java @@ -41,7 +41,7 @@ public class RemainsDefenderEntity extends Mob implements IRemainsEntity { public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.ARMOR, 15).add(Attributes.ATTACK_DAMAGE, 5).add(Attributes.ARMOR_TOUGHNESS, 6); + return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.ARMOR, 15).add(Attributes.ATTACK_DAMAGE, 10).add(Attributes.ARMOR_TOUGHNESS, 6); } public RemainsDefenderEntity(EntityType type, Level pLevel) {