Skip to content

Commit

Permalink
Fixed Crucible not always registering perfect reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
hjake123 committed Oct 15, 2024
1 parent 3d6156d commit 0dd4391
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public Reaction markAlwaysPerfect(){
return this;
}

public void cloneReagentsOf(Reaction other){
this.reagents = other.reagents;
}

public String getAlias(){
return alias;
}
Expand Down Expand Up @@ -177,7 +181,7 @@ public void run(CrucibleBlockEntity crucible){
public boolean isPerfect(CrucibleBlockEntity crucible){
// If crucible only has the same number of powers as the reagents, and the reaction could run, then it would be running with nothing extra.
// Therefore, it is running 'perfectly'.
return crucible.getPowerMap().keySet().size() == reagents.size();
return crucible.getPowerCount() == reagents.size();
}

public abstract void render(final Level l, final CrucibleBlockEntity crucible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ private void constructReactions(){
REACTIONS.add(new AstralReaction("astral"));
REACTIONS.add(new AnnihilationReaction("astral_curse_annihilation", Powers.ASTRAL_POWER.get(), Powers.CURSE_POWER.get(), ReactionEffects::creation, ReactionRenders::creation));

REACTIONS.add(new FreeEffectReaction("size_shrink_effect", ReactionEffects::shrink, ReactionRenders::acid_based, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.ACID_POWER.get()).setStimulus(Reaction.Stimulus.NO_ELECTRIC));
REACTIONS.add(new FreeEffectReaction("size_grow_effect", ReactionEffects::grow, ReactionRenders::verdant_based, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.VERDANT_POWER.get()).setStimulus(Reaction.Stimulus.NO_ELECTRIC));
REACTIONS.add(new FreeEffectReaction("size_revert_effect", ReactionEffects::revert_from_small, null, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.ACID_POWER.get()).setStimulus(Reaction.Stimulus.ELECTRIC));
REACTIONS.add(new FreeEffectReaction("size_revert_effect_2", ReactionEffects::revert_from_large, null, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.VERDANT_POWER.get()).setStimulus(Reaction.Stimulus.ELECTRIC));
Reaction size_shrink_effect = new FreeEffectReaction("size_shrink_effect", ReactionEffects::shrink, ReactionRenders::acid_based, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.ACID_POWER.get()).setStimulus(Reaction.Stimulus.NO_ELECTRIC);
Reaction size_grow_effect = new FreeEffectReaction("size_grow_effect", ReactionEffects::grow, ReactionRenders::verdant_based, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.VERDANT_POWER.get()).setStimulus(Reaction.Stimulus.NO_ELECTRIC);
Reaction size_revert_effect = new FreeEffectReaction("size_revert_effect", ReactionEffects::revert_from_small, null, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.ACID_POWER.get()).setStimulus(Reaction.Stimulus.ELECTRIC);
size_revert_effect.cloneReagentsOf(size_shrink_effect);
Reaction size_revert_effect_2 = new FreeEffectReaction("size_revert_effect_2", ReactionEffects::revert_from_large, null, Powers.MIND_POWER.get(), Powers.BODY_POWER.get(), Powers.VERDANT_POWER.get()).setStimulus(Reaction.Stimulus.ELECTRIC);
size_revert_effect_2.cloneReagentsOf(size_grow_effect);

REACTIONS.addAll(size_shrink_effect, size_grow_effect, size_revert_effect, size_revert_effect_2);

REACTIONS.add(new OmenConversionReaction("ominous_transformation"));
REACTIONS.add(new FreeEffectReaction("omen_settling", ReactionEffects::omenSettling, ReactionRenders::ominous, Powers.OMEN_POWER.get()).setStimulus(Reaction.Stimulus.GOLD_SYMBOL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,12 @@ public boolean expendPower(Power t, int amount) {
return true;
}
if (level == amount) {
powers.put(t, 0);
powers.remove(t);
return true;
}

// This implies that all power t wasn't enough to meet amount.
powers.put(t, 0);
powers.remove(t);
return false;
}

Expand All @@ -668,13 +668,16 @@ public void expendPower() {

public int getTotalPowerLevel(){
int totalpp = 0;
if(powers == null) return 0;
for (Power p : powers.keySet()) {
totalpp += powers.get(p);
}
return totalpp;
}

public int getPowerCount(){
return powers.keySet().size();
}

// Manually decides the initial color of the mixture to prevent fading from water.
public void setStartingColor(Color starting){
mix_color.set(starting);
Expand Down

0 comments on commit 0dd4391

Please sign in to comment.