-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* root advancement * find outpost advancement * adjust the defeat frostologer advancement * fix brushing not triggering animation * increase brushing durability damage to match armadillo brushing * add brush polar bear advancement * rework fur armor advancements slightly * increase freezing for root advancement * better advancement title * location warmth loot condition * warm by light advancement * make craft fur armour a child of brush polar bear * sun lichen enchantment * remove warm sun lichens tag * update translation keys for add log to campfire advancement * custom sun lichen discharge advancement criterion * translate fur armour item tag * split the trim advancement in two * frozen by frost wand advancement * fix wrong criteria * add trigger for frost wand freezing * add freeze 3 creepers advancement * slightly decrease frost spell effect range * consistent advancement field ordering * add more xp to advancement rewards * reduce xp reward for freeze creepers * unit test location warmth loot condition * gametest weird criterion logic * suppress the unused warning
- Loading branch information
1 parent
b845b24
commit bf915ea
Showing
41 changed files
with
987 additions
and
178 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...ava/com/github/thedeathlycow/frostiful/entity/advancement/FrozenByFrostWandCriterion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.github.thedeathlycow.frostiful.entity.advancement; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.advancement.criterion.AbstractCriterion; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.loot.context.LootContext; | ||
import net.minecraft.predicate.NumberRange; | ||
import net.minecraft.predicate.entity.EntityPredicate; | ||
import net.minecraft.predicate.entity.LootContextPredicate; | ||
import net.minecraft.predicate.entity.LootContextPredicateValidator; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
|
||
import java.util.*; | ||
|
||
public class FrozenByFrostWandCriterion extends AbstractCriterion<FrozenByFrostWandCriterion.Conditions> { | ||
|
||
@Override | ||
public Codec<Conditions> getConditionsCodec() { | ||
return Conditions.CODEC; | ||
} | ||
|
||
public void trigger(ServerPlayerEntity player, Collection<LivingEntity> frozenEntities) { | ||
List<LootContext> victimContexts = new ArrayList<>(frozenEntities.size()); | ||
|
||
for (LivingEntity frozenEntity : frozenEntities) { | ||
victimContexts.add(EntityPredicate.createAdvancementEntityLootContext(player, frozenEntity)); | ||
} | ||
|
||
this.trigger(player, conditions -> conditions.matches(victimContexts)); | ||
} | ||
|
||
public record Conditions( | ||
Optional<LootContextPredicate> player, | ||
List<LootContextPredicate> victims, | ||
NumberRange.IntRange entitiesFrozen | ||
) implements AbstractCriterion.Conditions { | ||
public static final Codec<Conditions> CODEC = RecordCodecBuilder.create( | ||
instance -> instance.group( | ||
EntityPredicate.LOOT_CONTEXT_PREDICATE_CODEC | ||
.optionalFieldOf("player") | ||
.forGetter(Conditions::player), | ||
EntityPredicate.LOOT_CONTEXT_PREDICATE_CODEC | ||
.listOf() | ||
.optionalFieldOf("victims", List.of()) | ||
.forGetter(Conditions::victims), | ||
NumberRange.IntRange.CODEC | ||
.optionalFieldOf("entities_frozen", NumberRange.IntRange.ANY) | ||
.forGetter(Conditions::entitiesFrozen) | ||
) | ||
.apply(instance, Conditions::new) | ||
); | ||
|
||
/** | ||
* | ||
* Implementation: Finds the first victim that matches each predicate. If the predicate matches no victims, | ||
* returns false. Otherwise, checks the entities frozen count | ||
* | ||
* @param victims victims frozen | ||
* @return returns true | ||
*/ | ||
public boolean matches(Collection<LootContext> victims) { | ||
if (!this.victims.isEmpty()) { | ||
List<LootContext> unmatchedVictims = new ArrayList<>(victims); | ||
|
||
for (LootContextPredicate predicate : this.victims) { | ||
boolean matched = false; | ||
|
||
Iterator<LootContext> iterator = unmatchedVictims.iterator(); | ||
while (iterator.hasNext()) { | ||
LootContext lootContext = iterator.next(); | ||
if (predicate.test(lootContext)) { | ||
iterator.remove(); | ||
matched = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!matched) { | ||
return false; | ||
} | ||
} | ||
} | ||
return this.entitiesFrozen.test(victims.size()); | ||
} | ||
|
||
@Override | ||
public void validate(LootContextPredicateValidator validator) { | ||
AbstractCriterion.Conditions.super.validate(validator); | ||
validator.validateEntityPredicates(this.victims, ".victims"); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...va/com/github/thedeathlycow/frostiful/entity/advancement/SunLichenDischargeCriterion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.github.thedeathlycow.frostiful.entity.advancement; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.advancement.criterion.AbstractCriterion; | ||
import net.minecraft.predicate.NumberRange; | ||
import net.minecraft.predicate.entity.EntityPredicate; | ||
import net.minecraft.predicate.entity.LootContextPredicate; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
|
||
import java.util.Optional; | ||
|
||
public class SunLichenDischargeCriterion extends AbstractCriterion<SunLichenDischargeCriterion.Conditions> { | ||
|
||
public void trigger(ServerPlayerEntity player, int temperatureImparted) { | ||
this.trigger(player, conditions -> conditions.temperatureImparted.test(temperatureImparted)); | ||
} | ||
|
||
@Override | ||
public Codec<Conditions> getConditionsCodec() { | ||
return Conditions.CODEC; | ||
} | ||
|
||
public record Conditions( | ||
Optional<LootContextPredicate> player, | ||
NumberRange.IntRange temperatureImparted | ||
) implements AbstractCriterion.Conditions { | ||
public static final Codec<Conditions> CODEC = RecordCodecBuilder.create( | ||
instance -> instance.group( | ||
EntityPredicate.LOOT_CONTEXT_PREDICATE_CODEC | ||
.optionalFieldOf("player") | ||
.forGetter(Conditions::player), | ||
NumberRange.IntRange.CODEC | ||
.fieldOf("temperature_imparted") | ||
.orElse(NumberRange.IntRange.ANY) | ||
.forGetter(Conditions::temperatureImparted) | ||
).apply(instance, Conditions::new) | ||
); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...main/java/com/github/thedeathlycow/frostiful/entity/loot/LocationWarmthLootCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.github.thedeathlycow.frostiful.entity.loot; | ||
|
||
import com.github.thedeathlycow.frostiful.registry.FLootConditionTypes; | ||
import com.github.thedeathlycow.thermoo.api.predicate.TemperatureLootCondition; | ||
import com.github.thedeathlycow.thermoo.api.temperature.EnvironmentController; | ||
import com.github.thedeathlycow.thermoo.api.temperature.EnvironmentManager; | ||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.loot.condition.LocationCheckLootCondition; | ||
import net.minecraft.loot.condition.LootCondition; | ||
import net.minecraft.loot.condition.LootConditionType; | ||
import net.minecraft.loot.context.LootContext; | ||
import net.minecraft.loot.context.LootContextParameters; | ||
import net.minecraft.predicate.NumberRange; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.Objects; | ||
|
||
public record LocationWarmthLootCondition( | ||
NumberRange.IntRange value | ||
) implements LootCondition { | ||
|
||
public static final MapCodec<LocationWarmthLootCondition> CODEC = RecordCodecBuilder.mapCodec( | ||
instance -> instance.group( | ||
NumberRange.IntRange.CODEC | ||
.fieldOf("value") | ||
.orElse(NumberRange.IntRange.ANY) | ||
.forGetter(LocationWarmthLootCondition::value) | ||
).apply(instance, LocationWarmthLootCondition::new) | ||
); | ||
|
||
@Override | ||
public LootConditionType getType() { | ||
return FLootConditionTypes.LOCATION_WARMTH; | ||
} | ||
|
||
@Override | ||
public boolean test(LootContext lootContext) { | ||
World world = lootContext.getWorld(); | ||
BlockPos pos = BlockPos.ofFloored(Objects.requireNonNull(lootContext.get(LootContextParameters.ORIGIN))); | ||
|
||
int areaWarmth = EnvironmentManager.INSTANCE.getController().getHeatAtLocation(world, pos); | ||
return this.value.test(areaWarmth); | ||
} | ||
|
||
public static LootCondition.Builder builder(NumberRange.IntRange value) { | ||
return () -> new LocationWarmthLootCondition(value); | ||
} | ||
} |
Oops, something went wrong.