Skip to content

Commit

Permalink
feat:
Browse files Browse the repository at this point in the history
- re-activate the ability to disable dragon despawn
- add config for dragon bite healing
- gorgon target tweak
  • Loading branch information
SiverDX authored and TheBv committed Dec 26, 2023
1 parent c1d9842 commit 0874f1a
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#forge:bosses"
]
}
4 changes: 2 additions & 2 deletions src/main/java/com/github/alexthe666/iceandfire/IafConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class IafConfig {
public static double dragonAttackDamageLightning = 3.5F;
public static int maxDragonFlight = 256;
public static int dragonGoldSearchLength = 30;
public static boolean canDragonsHealFromBiting;
public static boolean canDragonsDespawn = true;
public static boolean doDragonsSleep = true;
public static boolean dragonDigWhenStuck = true;
Expand Down Expand Up @@ -114,9 +115,7 @@ public class IafConfig {
public static float dragonsteelBaseArmorToughness = 6;
public static int dragonsteelBaseDurability = 8000;
public static int dragonsteelBaseDurabilityEquipment = 8000;
public static boolean spawnStructuresOnSuperflat = true;
public static boolean dragonMovedWronglyFix = false;
public static int dreadlandsDimensionId = -12;
public static boolean weezerTinkers = true;
public static double dragonBlockBreakingDropChance = 0.1D;
public static boolean dragonAuto3rdPerson = true;
Expand Down Expand Up @@ -182,6 +181,7 @@ public static void bakeServer(final ModConfig config) {
dragonAttackDamageLightning = ConfigHolder.SERVER.dragonAttackDamageLightning.get();
maxDragonFlight = ConfigHolder.SERVER.maxDragonFlight.get();
dragonGoldSearchLength = ConfigHolder.SERVER.dragonGoldSearchLength.get();
canDragonsHealFromBiting = ConfigHolder.SERVER.canDragonsHealFromBiting.get();
canDragonsDespawn = ConfigHolder.SERVER.canDragonsDespawn.get();
doDragonsSleep = ConfigHolder.SERVER.doDragonsSleep.get();
dragonDigWhenStuck = ConfigHolder.SERVER.dragonDigWhenStuck.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ServerConfig {
public final ForgeConfigSpec.DoubleValue dragonAttackDamageLightning;
public final ForgeConfigSpec.IntValue maxDragonFlight;
public final ForgeConfigSpec.IntValue dragonGoldSearchLength;
public final ForgeConfigSpec.BooleanValue canDragonsHealFromBiting;
public final ForgeConfigSpec.BooleanValue canDragonsDespawn;
public final ForgeConfigSpec.BooleanValue doDragonsSleep;
public final ForgeConfigSpec.BooleanValue dragonDigWhenStuck;
Expand Down Expand Up @@ -107,18 +108,18 @@ public class ServerConfig {
public final ForgeConfigSpec.DoubleValue dragonsteelBaseArmorToughness;
public final ForgeConfigSpec.IntValue dragonsteelBaseDurability;
public final ForgeConfigSpec.IntValue dragonsteelBaseDurabilityEquipment;
public final ForgeConfigSpec.BooleanValue dragonMovedWronglyFix;
public final ForgeConfigSpec.BooleanValue weezerTinkers;
public final ForgeConfigSpec.BooleanValue dragonMovedWronglyFix; // FIXME :: Unused
public final ForgeConfigSpec.BooleanValue weezerTinkers; // FIXME :: Unused
public final ForgeConfigSpec.DoubleValue dragonBlockBreakingDropChance;
public final ForgeConfigSpec.BooleanValue completeDragonPathfinding;
public final ForgeConfigSpec.BooleanValue completeDragonPathfinding; // FIXME :: Unused
public final ForgeConfigSpec.BooleanValue generateMausoleums;
public final ForgeConfigSpec.BooleanValue spawnLiches;
public final ForgeConfigSpec.IntValue lichSpawnRate;
public final ForgeConfigSpec.IntValue lichSpawnChance;
public final ForgeConfigSpec.DoubleValue hydraMaxHealth;
public final ForgeConfigSpec.IntValue generateHydraChance;
public final ForgeConfigSpec.BooleanValue explosiveDragonBreath;
public final ForgeConfigSpec.DoubleValue weezerTinkersDisarmChance;
public final ForgeConfigSpec.DoubleValue weezerTinkersDisarmChance; // FIXME :: Unused
public final ForgeConfigSpec.BooleanValue chunkLoadSummonCrystal;
public ForgeConfigSpec.IntValue dangerousWorldGenDistanceLimit;
public ForgeConfigSpec.IntValue dangerousWorldGenSeparationLimit;
Expand Down Expand Up @@ -192,6 +193,7 @@ public ServerConfig(final ForgeConfigSpec.Builder builder) {
builder.push("Behaviour");
this.maxDragonFlight = buildInt(builder, "Max Dragon Flight Height", "all", 128, 100, Integer.MAX_VALUE, "How high dragons can fly, in Y height.");
this.dragonGoldSearchLength = buildInt(builder, "Dragon Gold Search Length", "all", 30, 0, 10000, "How far away dragons will detect gold blocks being destroyed or chests being opened");
this.canDragonsHealFromBiting = buildBoolean(builder, "Dragon Bite Heal", "all", true, "Whether the bite attack from a dragon heals them or not.");
this.canDragonsDespawn = buildBoolean(builder, "Dragons Despawn", "all", true, "True if dragons can despawn. Note that if this is false there may be SERIOUS lag issues.");
this.doDragonsSleep = buildBoolean(builder, "Tamed Dragons Sleep", "all", true, "True if tamed dragons go to sleep at night.");
this.dragonDigWhenStuck = buildBoolean(builder, "Dragons Dig When Stuck", "all", true, "True if dragons can break blocks if they get stuck. Turn this off if your dragons randomly explode.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.github.alexthe666.iceandfire.datagen;

import com.github.alexthe666.iceandfire.IceAndFire;
import com.github.alexthe666.iceandfire.datagen.tags.BannerPatternTagGenerator;
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
import com.github.alexthe666.iceandfire.datagen.tags.IafItemTags;
import com.github.alexthe666.iceandfire.datagen.tags.POITagGenerator;
import com.github.alexthe666.iceandfire.datagen.tags.*;
import net.minecraft.DetectedVersion;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
Expand Down Expand Up @@ -49,6 +46,7 @@ public static void gatherData(GatherDataEvent event) {
BlockTagsProvider blocktags = new IafBlockTags(output, provider, helper);
generator.addProvider(event.includeServer(), blocktags);
generator.addProvider(event.includeServer(), new IafItemTags(output, provider, blocktags.contentsGetter(), helper));
generator.addProvider(event.includeServer(), new IafEntityTags(output, provider, helper));

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.github.alexthe666.iceandfire.datagen.tags;

import com.github.alexthe666.iceandfire.IceAndFire;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.EntityTypeTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.CompletableFuture;

public class IafEntityTags extends EntityTypeTagsProvider {
public static TagKey<EntityType<?>> IMMUNE_TO_GORGON_STONE = createKey("immune_to_gorgon_stone");

public IafEntityTags(PackOutput output, CompletableFuture<HolderLookup.Provider> provider, @Nullable final ExistingFileHelper existingFileHelper) {
super(output, provider, IceAndFire.MODID, existingFileHelper);
}

@Override
protected void addTags(HolderLookup.Provider provider) {
tag(IMMUNE_TO_GORGON_STONE)
.addTag(Tags.EntityTypes.BOSSES);
}

private static TagKey<EntityType<?>> createKey(final String name) {
return TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation(IceAndFire.MODID, name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,13 @@ protected void customServerAiStep() {
breakBlock();
}

@Override
public void checkDespawn() {
if (IafConfig.canDragonsDespawn) {
super.checkDespawn();
}
}

public boolean canDestroyBlock(BlockPos pos, BlockState state) {
return state.getBlock().canEntityDestroy(state, level(), pos, this);
}
Expand Down Expand Up @@ -1589,7 +1596,14 @@ protected void updatePreyInMouth(Entity prey) {
this.setAnimation(ANIMATION_SHAKEPREY);
}
if (this.getAnimation() == ANIMATION_SHAKEPREY && this.getAnimationTick() > 55 && prey != null) {
prey.hurt(this.level().damageSources().mobAttack(this), prey instanceof Player ? 17F : (float) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue() * 4);
// TODO :: Why is damage to player hardcoded
float damage = prey instanceof Player ? 17F : (float) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue() * 4;
boolean didDamage = prey.hurt(this.level().damageSources().mobAttack(this), damage);

if (didDamage && IafConfig.canDragonsHealFromBiting) {
heal(damage);
}

prey.stopRiding();
}
yBodyRot = getYRot();
Expand Down Expand Up @@ -2311,7 +2325,12 @@ public void updateRider() {
this.setAnimation(EntityDragonBase.ANIMATION_BITE);
}
if (target != null && !DragonUtils.hasSameOwner(this, target)) {
logic.attackTarget(target, rider, (int) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue());
int damage = (int) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue();
boolean didDamage = logic.attackTarget(target, rider, damage);

if (didDamage && IafConfig.canDragonsHealFromBiting) {
heal(damage);
}
}
}
// Shift key to dismount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ public void updateDragonServer() {
}
}

public void attackTarget(Entity target, Player ridingPlayer, float damage) {
public boolean attackTarget(Entity target, Player ridingPlayer, float damage) {
if (ridingPlayer == null)
target.hurt(target.level().damageSources().mobAttack(dragon), damage);
return target.hurt(target.level().damageSources().mobAttack(dragon), damage);
else
target.hurt(target.level().damageSources().indirectMagic(dragon, ridingPlayer), damage);
return target.hurt(target.level().damageSources().indirectMagic(dragon, ridingPlayer), damage);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public void finalizeExplosion(boolean spawnParticles) {

for (BlockPos blockpos : this.getToBlow()) {
BlockState blockstate = this.world.getBlockState(blockpos);
Block block = blockstate.getBlock();
if (!blockstate.isAir()) {
BlockPos blockpos1 = blockpos.immutable();
this.world.getProfiler().push("explosion_blocks");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,18 @@ public static boolean canDragonBreak(Block block, Entity entity) {
}

public static boolean hasSameOwner(TamableAnimal cockatrice, Entity entity) {
if (entity instanceof TamableAnimal) {
TamableAnimal tameable = (TamableAnimal) entity;
if (entity instanceof TamableAnimal tameable) {
return tameable.getOwnerUUID() != null && cockatrice.getOwnerUUID() != null && tameable.getOwnerUUID().equals(cockatrice.getOwnerUUID());
}
return false;
}

public static boolean isAlive(LivingEntity entity) {
if (entity instanceof EntityDragonBase && ((EntityDragonBase) entity).isMobDead()) {
public static boolean isAlive(final LivingEntity entity) {
if (entity instanceof EntityDragonBase dragon && dragon.isMobDead()) {
return false;
}
return (!(entity instanceof IDeadMob) || !((IDeadMob) entity).isMobDead()) && !EntityGorgon.isStoneMob(entity);

return (!(entity instanceof IDeadMob deadMob) || !deadMob.isMobDead()) && !EntityGorgon.isStoneMob(entity);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.world.item.Item;

// TODO :: Has no usage at the moment
public class ItemDreadQueenStaff extends Item {

public ItemDreadQueenStaff() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.alexthe666.iceandfire.item;

import com.github.alexthe666.iceandfire.client.render.tile.RenderGorgonHead;
import com.github.alexthe666.iceandfire.datagen.tags.IafEntityTags;
import com.github.alexthe666.iceandfire.entity.EntityStoneStatue;
import com.github.alexthe666.iceandfire.entity.util.DragonUtils;
import com.github.alexthe666.iceandfire.entity.util.IBlacklistedFromStatues;
Expand Down Expand Up @@ -75,16 +76,19 @@ public void releaseUsing(@NotNull ItemStack stack, Level worldIn, LivingEntity e
Vec3 Vector3d = entity.getEyePosition(1.0F);
Vec3 Vector3d1 = entity.getViewVector(1.0F);
Vec3 Vector3d2 = Vector3d.add(Vector3d1.x * dist, Vector3d1.y * dist, Vector3d1.z * dist);
double d1 = dist;
Entity pointedEntity = null;
List<Entity> list = worldIn.getEntities(entity, entity.getBoundingBox().expandTowards(Vector3d1.x * dist, Vector3d1.y * dist, Vector3d1.z * dist).inflate(1.0D, 1.0D, 1.0D), new Predicate<Entity>() {
@Override
public boolean apply(@Nullable Entity entity) {
boolean blindness = entity instanceof LivingEntity && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS) || (entity instanceof IBlacklistedFromStatues && !((IBlacklistedFromStatues) entity).canBeTurnedToStone());
return entity != null && entity.isPickable() && !blindness && (entity instanceof Player || (entity instanceof LivingEntity && DragonUtils.isAlive((LivingEntity) entity)));
if (entity instanceof LivingEntity livingEntity) {
boolean isImmune = livingEntity instanceof IBlacklistedFromStatues blacklisted && !blacklisted.canBeTurnedToStone() || entity.getType().is(IafEntityTags.IMMUNE_TO_GORGON_STONE) || livingEntity.hasEffect(MobEffects.BLINDNESS);
return !isImmune && entity.isPickable() && !livingEntity.isDeadOrDying() && (entity instanceof Player || DragonUtils.isAlive(livingEntity));
}

return false;
}
});
double d2 = d1;
double d2 = dist;
for (int j = 0; j < list.size(); ++j) {
Entity entity1 = list.get(j);
AABB axisalignedbb = entity1.getBoundingBox().inflate(entity1.getPickRadius());
Expand All @@ -111,9 +115,9 @@ public boolean apply(@Nullable Entity entity) {
}
}
if (pointedEntity != null) {
if (pointedEntity instanceof LivingEntity) {
if (pointedEntity instanceof LivingEntity livingEntity) {
pointedEntity.playSound(IafSoundRegistry.TURN_STONE, 1, 1);
EntityStoneStatue statue = EntityStoneStatue.buildStatueEntity((LivingEntity) pointedEntity);
EntityStoneStatue statue = EntityStoneStatue.buildStatueEntity(livingEntity);
if (pointedEntity instanceof Player) {
pointedEntity.hurt(IafDamageRegistry.causeGorgonDamage(pointedEntity), Integer.MAX_VALUE);
} else {
Expand All @@ -125,7 +129,7 @@ public boolean apply(@Nullable Entity entity) {
if (!worldIn.isClientSide) {
worldIn.addFreshEntity(statue);
}
if (entity instanceof Player && !((Player) entity).isCreative()) {
if (entity instanceof Player player && !player.isCreative()) {
stack.shrink(1);
}
}
Expand Down
Loading

0 comments on commit 0874f1a

Please sign in to comment.