Class TemperaturePredicate
TemperatureAware
This is injected into EntityPredicate via mixin.
This mean that this is NOT a new loot condition, it is actually an extension of the vanilla predicate
EntityPredicate and can therefore be used anywhere that it is used. For exameple,
as part of the vanilla loot condition minecraft:entity_properties
Example usage:
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"thermoo.temperature": {
"scale": NumberRange.FloatRange,
"temperature": NumberRange.IntRange
}
}
}
Note that both scale and temperature are optional, and if not supplied will default to
NumberRange.FloatRange.ANY and NumberRange.IntRange.ANY respectively.
- See Also:
-
EntityPredicate
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TemperaturePredicate"Any" predicate that will always return as true when tested -
Constructor Summary
ConstructorsConstructorDescriptionTemperaturePredicate(net.minecraft.predicate.NumberRange.FloatRange scaleRange, net.minecraft.predicate.NumberRange.IntRange temperatureRange) Constructs a new temperature predicate with a scale and temperature range -
Method Summary
Modifier and TypeMethodDescriptionstatic TemperaturePredicatefromJson(@Nullable com.google.gson.JsonElement json) Returns theTemperaturePredicatethat is represented by the givenjson.booleantest(TemperatureAware tempAware) Tests the temperature of aTemperatureAwareagainst this predicate.com.google.gson.JsonElementtoJson()Serializes this predicate to JSON
-
Field Details
-
ANY
"Any" predicate that will always return as true when tested
-
-
Constructor Details
-
TemperaturePredicate
public TemperaturePredicate(net.minecraft.predicate.NumberRange.FloatRange scaleRange, net.minecraft.predicate.NumberRange.IntRange temperatureRange) Constructs a new temperature predicate with a scale and temperature range- Parameters:
scaleRange- The temperature scale range accepted by this predicatetemperatureRange- The absolute temperature value range accepted by this predicate
-
-
Method Details
-
test
Tests the temperature of aTemperatureAwareagainst this predicate.If this predicate is
ANYthen this test will always betrue.Otherwise, BOTH the temperature scale and temperature value of the
tempAwaremust match the ranges of this predicate- Parameters:
tempAware- TheTemperatureAwareto test- Returns:
- Returns true if the predicate accepts
tempAware
-
toJson
public com.google.gson.JsonElement toJson()Serializes this predicate to JSONIf this instance is
ANY, then returnsJsonNull- Returns:
- Returns a
JsonElementthat represents this instance
-
fromJson
@Contract("!null->new") public static TemperaturePredicate fromJson(@Nullable @Nullable com.google.gson.JsonElement json) Returns theTemperaturePredicatethat is represented by the givenjson.If the given
jsonis null orJsonNull, then returnsANY- Parameters:
json- The json object to deserialize- Returns:
- Returns the temperature predicate represented by the given
json.
-