Skip to content

Commit

Permalink
Add more config options
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomate0613 committed Dec 6, 2023
1 parent bc08a85 commit fbc16a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/main/java/tomate/totaldragon/DragonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

// TODO Replace this with an actual config (placeholder for now)
public class DragonConfig {
public enum PhantomBehaviour {
NO_PHANTOMS_IN_FIGHT,
VANILLA_PHANTOMS,
IMPROVED_PHANTOMS_IN_FIGHT,
IMPROVED_PHANTOMS_ALWAYS
};

public static final boolean logDragonPhasesToInGameChat = false;
public static final boolean playersFallIntoOverworld = true;

public static final boolean chainReactionEndCrystals = true;

public static final boolean endCrystalSpawns = true;
public static final boolean spawnEndermitesInFight = true;
public static final PhantomBehaviour phantomBehaviour = PhantomBehaviour.IMPROVED_PHANTOMS_IN_FIGHT;
}
7 changes: 6 additions & 1 deletion src/main/java/tomate/totaldragon/mixin/EndCrystalMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public boolean hurt(DamageSource damageSource, float f) {
if (damageSource.getEntity() instanceof EnderDragon) {
return false;
}

if (!this.isRemoved() && !this.level().isClientSide && active) {
active = false;

Expand Down Expand Up @@ -76,13 +75,19 @@ public boolean hurt(DamageSource damageSource, float f) {

@Unique
private void spawnEndermite() {
if(!DragonConfig.spawnEndermitesInFight)
return;

var endermite = new Endermite(EntityType.ENDERMITE, level());
endermite.setPos(position());
level().addFreshEntity(endermite);
}

@Unique
private void spawnPhantoms(LivingEntity target) {
if(DragonConfig.phantomBehaviour == DragonConfig.PhantomBehaviour.NO_PHANTOMS_IN_FIGHT)
return;

var phantom = new Phantom(EntityType.PHANTOM, level());
phantom.setPos(position());
phantom.setTarget(target);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/tomate/totaldragon/mixin/PhantomMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import tomate.totaldragon.DragonConfig;

@Mixin(Phantom.class)
public abstract class PhantomMixin extends FlyingMob {
Expand All @@ -23,8 +24,8 @@ protected PhantomMixin(EntityType<? extends FlyingMob> entityType, Level level)

@Inject(at = @At("TAIL"), method = "<init>")
void init(EntityType<?> entityType, Level level, CallbackInfo ci) {
var dimensionsAccessible = ((EntityDimensionsAccessor)this);
dimensionsAccessible.setDimensions(dimensionsAccessible.getDimensions().scale(2, 1.2f));
if(DragonConfig.phantomBehaviour != DragonConfig.PhantomBehaviour.IMPROVED_PHANTOMS_ALWAYS && !(DragonConfig.phantomBehaviour == DragonConfig.PhantomBehaviour.IMPROVED_PHANTOMS_IN_FIGHT && level().dimension() != Level.END))
return;

updatePhantomSize();
}
Expand All @@ -46,6 +47,9 @@ public boolean hurt(DamageSource damageSource, float f) {
}

private void updatePhantomSize() {
var dimensionsAccessible = ((EntityDimensionsAccessor)this);
dimensionsAccessible.setDimensions(dimensionsAccessible.getDimensions().scale(2, 1.2f));

if(level().dimension() == Level.END) {
getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(25 + this.getPhantomSize());
return;
Expand Down

0 comments on commit fbc16a2

Please sign in to comment.