use of virtuoel.pehkui.util.PehkuiEntityExtensions in project Pehkui by Virtuoel.
the class ScaleData method getScale.
/**
* Gets the scale with modifiers applied
*
* @param delta Tick delta for use with rendering. Use 1.0F if no delta is available.
* @return Scale with modifiers applied
*/
public float getScale(float delta) {
final Entity e = getEntity();
final boolean canCache = delta == 1.0F && e != null && e.world != null && !e.world.isClient && (e.getType() != EntityType.PLAYER || !getScaleType().getAffectsDimensions()) && !((PehkuiEntityExtensions) e).pehkui_isFirstUpdate();
if (canCache && !Float.isNaN(cachedScale)) {
return cachedScale;
}
float value = getBaseScale(delta);
for (final ScaleModifier m : getBaseValueModifiers()) {
value = m.modifyScale(this, value, delta);
}
if (canCache) {
cachedScale = value;
}
return value;
}
use of virtuoel.pehkui.util.PehkuiEntityExtensions in project Pehkui by Virtuoel.
the class PehkuiEntitySelectorOptions method register.
public static void register() {
EntitySelectorOptionsInvoker.callPutOption(Pehkui.id("scale").toString().replace(':', '.'), r -> cast(r).pehkui_setScaleRange(FloatRange.parse(r.getReader())), r -> cast(r).pehkui_getScaleRange().isDummy(), SCALE_RANGE_DESCRIPTION);
EntitySelectorOptionsInvoker.callPutOption(Pehkui.id("scale_type").toString().replace(':', '.'), r -> cast(r).pehkui_setScaleType(parseScaleType(r)), r -> cast(r).pehkui_getScaleType() == ScaleTypes.INVALID, SCALE_TYPE_DESCRIPTION);
EntitySelectorOptionsInvoker.callPutOption(Pehkui.id("computed_scale").toString().replace(':', '.'), r -> cast(r).pehkui_setComputedScaleRange(FloatRange.parse(r.getReader())), r -> cast(r).pehkui_getComputedScaleRange().isDummy(), SCALE_RANGE_DESCRIPTION);
EntitySelectorOptionsInvoker.callPutOption(Pehkui.id("computed_scale_type").toString().replace(':', '.'), r -> cast(r).pehkui_setComputedScaleType(parseScaleType(r)), r -> cast(r).pehkui_getComputedScaleType() == ScaleTypes.INVALID, SCALE_TYPE_DESCRIPTION);
EntitySelectorOptionsInvoker.callPutOption(Pehkui.id("scale_nbt").toString().replace(':', '.'), r -> {
final boolean negated = r.readNegationCharacter();
final NbtCompound parsed = (new StringNbtReader(r.getReader())).parseCompound();
r.setPredicate(entity -> {
final NbtCompound nbt = ((PehkuiEntityExtensions) entity).pehkui_writeScaleNbt(new NbtCompound());
return NbtHelper.matches(parsed, nbt, true) != negated;
});
}, reader -> true, SCALE_NBT_DESCRIPTION);
}
Aggregations