Files
src
build.gradle
gradle.properties
settings.gradle
Code
22 1,373
src/main/java/com/dangerousdungeons/DangerousDungeons.java
package com.dangerousdungeons;
import com.dangerousdungeons.mixin.CreeperEntityAccessor;
import com.dangerousdungeons.entity.DragonEnhancements;
import net.fabricmc.api.ModInitializer;
import net.minecraft.block.BlockState;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributeInstance;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.projectile.ArrowEntity;
import net.minecraft.entity.projectile.ExplosiveProjectileEntity;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.entity.mob.GhastEntity;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.mob.BlazeEntity;
import net.minecraft.entity.mob.MagmaCubeEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.PiglinBruteEntity;
import net.minecraft.entity.mob.SkeletonEntity;
import net.minecraft.entity.mob.WardenEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class DangerousDungeons implements ModInitializer {
public static final String MOD_ID = "dangerousdungeons";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
private static final String HEALTH_TAG = MOD_ID + ":double_health";
private static final String ZOMBIE_GEAR_TAG = MOD_ID + ":zombie_gear";
private static final String ZOMBIE_ELITE_TAG = MOD_ID + ":zombie_elite";
private static final String SKELETON_GEAR_TAG = MOD_ID + ":skeleton_gear";
private static final String SKELETON_AIMBOT_TAG = MOD_ID + ":skeleton_aimbot";
private static final String SKELETON_CROSSBOW_TAG = MOD_ID + ":skeleton_crossbow";
private static final String SKELETON_ARROW_EFFECT_TAG = MOD_ID + ":skeleton_arrow_effect";
private static final String CREEPER_TAG = MOD_ID + ":creeper";
private static final String CREEPER_SPLINTER_TAG = MOD_ID + ":creeper_splinter";
private static final String WARDEN_TAG = MOD_ID + ":warden";
private static final String WITHER_TAG = MOD_ID + ":wither";
private static final String END_TRANSPORT_TAG = MOD_ID + ":enderman_summon";
private static final String WARDEN_SUMMON_TAG = MOD_ID + ":warden_summon";
private static final String WITHER_PHASE_TWO_TAG = MOD_ID + ":wither_phase_two";
private static final String WITHER_RAGE_TAG = MOD_ID + ":wither_rage";
private static final String WITHER_MINION_TAG = MOD_ID + ":wither_minion";
private static final String NETHER_SUMMON_TAG = MOD_ID + ":nether_summon";
private static final String PIGLIN_BRUTE_TAG = MOD_ID + ":piglin_brute";
private static final String GHAST_TAG = MOD_ID + ":ghast";
private static final String SPAWN_CHECKED_TAG = MOD_ID + ":spawn_checked";
private static final String BONUS_SPAWN_TAG = MOD_ID + ":bonus_spawn";
private static final String ZOMBIE_SIEGE_TAG = MOD_ID + ":zombie_siege";
private static final String HOSTILE_TAG = MOD_ID + ":hostile_configured";
private static final String HOSTILE_SPEED_III_TAG = MOD_ID + ":hostile_speed_iii";
private static final String ESCALATION_SUMMON_TAG = MOD_ID + ":escalation_summon";
private static final Map<UUID, BlockPos> BREAKING_BLOCKS = new HashMap<>();
private static final Map<UUID, Float> BREAK_PROGRESS = new HashMap<>();
private static final Map<UUID, Integer> ZOMBIE_SIEGE_TICKS = new HashMap<>();
private static final Map<UUID, Integer> WARDEN_COMBAT_TICKS = new HashMap<>();
@Override
public void onInitialize() {
LOGGER.info("Dangerous Dungeons is ready.");
}
public static void handleEntityTick(Entity entity) {
if (!(entity.getEntityWorld() instanceof ServerWorld world)) {
return;
}
homeSkeletonArrow(entity, world);
enhanceExplosiveProjectile(entity);
DragonEnhancements.handleEntityTick(entity, world);
if (!(entity instanceof MobEntity mob) || !(entity instanceof LivingEntity living)) {
return;
}
if (entity instanceof HostileEntity) {
configureHostile(entity, mob, world);
}
if (entity.getCommandTags().add(HEALTH_TAG)) {
multiplyAttribute(living, EntityAttributes.MAX_HEALTH, 2.0);
living.setHealth(living.getMaxHealth());
}
if (entity instanceof HostileEntity) {
applyWorldEscalation(entity, living, mob, world);
}
increaseUndeadSpawns(entity, world);
if (entity.age <= 1 || entity.age % 40 == 0) {
applyMobEffects(entity, living, getEscalationLevel(world));
}
if (entity.age % 20 == 0 && entity instanceof HostileEntity) {
acquireTarget(entity, mob, world);
}
if (entity.age % 10 == 0 && entity instanceof HostileEntity) {
openDoorsTowardTarget(entity, mob, world);
}
if (entity.getType() == net.minecraft.entity.EntityType.ZOMBIE) {
configureZombie(mob, world);
updateZombieSiege(entity, mob, world);
breakTowardPlayer(entity, world, 1.0F);
disableNearbyShield(entity, world);
} else if (entity.getType() == net.minecraft.entity.EntityType.SKELETON) {
configureSkeleton(mob, world);
strafeTarget(entity, mob);
fireCrossbowSkeleton(entity, mob, world);
} else if (entity instanceof CreeperEntity creeper) {
if (entity.getCommandTags().add(CREEPER_TAG)) {
((CreeperEntityAccessor) creeper).dangerousdungeons$setExplosionRadius(8);
if (world.getRandom().nextFloat() < 0.02F) {
creeper.getDataTracker().set(CreeperEntityAccessor.dangerousdungeons$getChargedData(), true);
}
}
dashCreeper(creeper);
} else if (entity instanceof WardenEntity warden) {
if (entity.getCommandTags().add(WARDEN_TAG)) {
setAttribute(warden, EntityAttributes.FOLLOW_RANGE, 80.0);
}
acquireWardenTarget(warden, world);
updateWardenSummons(warden, world);
breakTowardPlayerInstantly(entity, world);
} else if (entity instanceof WitherEntity wither) {
if (entity.getCommandTags().add(WITHER_TAG)) {
multiplyAttribute(wither, EntityAttributes.FLYING_SPEED, 2.0);
multiplyAttribute(wither, EntityAttributes.ATTACK_DAMAGE, 2.0);
}
updateWitherPhases(wither, world);
breakTowardPlayerInstantly(wither, world);
} else if (entity instanceof EndermanEntity enderman) {
updateEndermanCombat(enderman, world);
} else if (entity instanceof GhastEntity ghast) {
if (entity.getCommandTags().add(GHAST_TAG)) {
multiplyAttribute(ghast, EntityAttributes.FLYING_SPEED, 2.0);
}
} else if (entity instanceof PiglinBruteEntity brute) {
configurePiglinBrute(brute);
} else if (entity instanceof MagmaCubeEntity) {
if (entity.age % 40 == 0) {
addEffect(living, StatusEffects.SPEED, 3);
}
}
if (entity instanceof HostileEntity && mob.getTarget() instanceof PlayerEntity) {
spawnNetherReinforcements(entity, world);
spawnEscalationReinforcements(entity, world);
}
}
private static void configureHostile(Entity entity, MobEntity mob, ServerWorld world) {
if (entity.getCommandTags().add(HOSTILE_TAG)) {
setAttribute(mob, EntityAttributes.FOLLOW_RANGE, 80.0);
entity.getCommandTags().add(HOSTILE_SPEED_III_TAG);
mob.setCanPickUpLoot(true);
}
}
private static int getEscalationLevel(ServerWorld world) {
return 3;
}
private static void applyWorldEscalation(Entity entity, LivingEntity living, MobEntity mob, ServerWorld world) {
for (int stage = 1; stage <= getEscalationLevel(world); stage++) {
if (!entity.getCommandTags().add(MOD_ID + ":escalation_" + stage)) {
continue;
}
float healthRatio = living.getHealth() / living.getMaxHealth();
double healthMultiplier = stage == 1 ? 1.2 : stage == 2 ? 1.25 : 1.4;
double damageMultiplier = stage == 1 ? 1.15 : stage == 2 ? 1.25 : 1.4;
double speedMultiplier = stage == 1 ? 1.1 : stage == 2 ? 1.15 : 1.25;
multiplyAttribute(living, EntityAttributes.MAX_HEALTH, healthMultiplier);
multiplyAttribute(living, EntityAttributes.ATTACK_DAMAGE, damageMultiplier);
multiplyAttribute(mob, EntityAttributes.MOVEMENT_SPEED, speedMultiplier);
setAttribute(mob, EntityAttributes.FOLLOW_RANGE, 80.0 + stage * 20.0);
living.setHealth(living.getMaxHealth() * healthRatio);
}